ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra-Client/DC/Macro.pm
(Generate patch)

Comparing deliantra/Deliantra-Client/DC/Macro.pm (file contents):
Revision 1.1 by root, Sat Dec 9 02:21:25 2006 UTC vs.
Revision 1.22 by root, Sat Apr 3 02:58:24 2010 UTC

1package CFPlus::Macro; 1package DC::Macro;
2 2
3use strict; 3use common::sense;
4 4
5use List::Util ();
5use CFPlus::UI; 6use DC::UI;
6 7
7our $REFRESH_MACRO_LIST; 8our $REFRESH_MACRO_LIST;
9
10our %DEFAULT_KEYMAP = (
11 (map +("($_)" => "!completer $_"), "a" .. "z"),
12 "(!)" => "!completer shout ",
13 "(\")" => "!completer say ",
14 "(')" => "!completer",
15
16# "LShift-tab" => "!toggle-messagewindow",
17# "RShift-tab" => "!toggle-messagewindow",
18 "tab" => "!toggle-playerbook",
19 "f1" => "!toggle-help",
20 "f2" => "!toggle-stats",
21 "f3" => "!toggle-skills",
22 "f4" => "!toggle-spells",
23 "f5" => "!toggle-inventory",
24 "f9" => "!toggle-setup",
25
26 (map +("LRAM-$_" => "!switch-tab $_"), 0..9),
27 "LRAM-x" => "!close-current-tab",
28
29 "return" => "!activate-chat",
30 "." => "!repeat-command",
31
32 "," => "take",
33 "space" => "apply",
34 "enter" => "examine",
35 "[+]" => "rotateshoottype +",
36 "[-]" => "rotateshoottype -",
37
38 "LRAM-e" => "examine",
39 "LRAM-s" => "ready_skill find traps",
40 "LRAM-d" => "ready_skill disarm traps",
41 "LRAM-p" => "ready_skill praying",
42);
8 43
9# allowed modifiers 44# allowed modifiers
10our %MODIFIER = ( 45our %MODIFIER = (
11 "LShift" => CFPlus::KMOD_LSHIFT, 46 "LShift" => DC::KMOD_LSHIFT,
12 "RShift" => CFPlus::KMOD_RSHIFT, 47 "RShift" => DC::KMOD_RSHIFT,
48# "Shift" => DC::KMOD_LSHIFT | DC::KMOD_RSHIFT,
13 "LCtrl" => CFPlus::KMOD_LCTRL, 49 "LCtrl" => DC::KMOD_LCTRL,
14 "RCtrl" => CFPlus::KMOD_RCTRL, 50 "RCtrl" => DC::KMOD_RCTRL,
51# "Ctrl" => DC::KMOD_LCTRL | DC::KMOD_RCTRL,
15 "LAlt" => CFPlus::KMOD_LALT, 52 "LAlt" => DC::KMOD_LALT,
16 "RAlt" => CFPlus::KMOD_RALT, 53 "RAlt" => DC::KMOD_RALT,
54# "Alt" => DC::KMOD_LALT | DC::KMOD_RALT,
17 "LMeta" => CFPlus::KMOD_LMETA, 55 "LMeta" => DC::KMOD_LMETA,
18 "RMeta" => CFPlus::KMOD_RMETA, 56 "RMeta" => DC::KMOD_RMETA,
57# "Meta" => DC::KMOD_LMETA | DC::KMOD_RMETA,
19); 58);
20 59
21# allowed modifiers 60# allowed modifiers
22our $MODIFIER_MASK |= $_ for values %MODIFIER; 61our $MODIFIER_MASK |= $_ for values %MODIFIER;
23 62
24# can bind to these without any modifier 63# can bind to these without any modifier
25our @DIRECT_CHARS = qw(0 1 2 3 4 5 6 7 8 9); 64our @DIRECT_CHARS = qw(0 1 2 3 4 5 6 7 8 9);
26 65
27our @DIRECT_KEYS = ( 66our @DIRECT_KEYS = (
28 CFPlus::SDLK_F1, 67 DC::SDLK_F1,
29 CFPlus::SDLK_F2, 68 DC::SDLK_F2,
30 CFPlus::SDLK_F3, 69 DC::SDLK_F3,
31 CFPlus::SDLK_F4, 70 DC::SDLK_F4,
32 CFPlus::SDLK_F5, 71 DC::SDLK_F5,
33 CFPlus::SDLK_F6, 72 DC::SDLK_F6,
34 CFPlus::SDLK_F7, 73 DC::SDLK_F7,
35 CFPlus::SDLK_F8, 74 DC::SDLK_F8,
36 CFPlus::SDLK_F9, 75 DC::SDLK_F9,
37 CFPlus::SDLK_F10, 76 DC::SDLK_F10,
38 CFPlus::SDLK_F11, 77 DC::SDLK_F11,
39 CFPlus::SDLK_F12, 78 DC::SDLK_F12,
40 CFPlus::SDLK_F13, 79 DC::SDLK_F13,
41 CFPlus::SDLK_F14, 80 DC::SDLK_F14,
42 CFPlus::SDLK_F15, 81 DC::SDLK_F15,
43); 82);
83
84our %MACRO_FUNCTION = (
85 "toggle-messagewindow" => sub { $::MESSAGE_WINDOW->toggle_visibility },
86 "toggle-playerbook" => sub { $::PL_WINDOW->toggle_visibility },
87 "toggle-help" => sub { $::HELP_WINDOW->toggle_visibility },
88 "toggle-stats" => sub { ::toggle_player_page ($::STATS_PAGE) },
89 "toggle-skills" => sub { ::toggle_player_page ($::SKILL_PAGE) },
90 "toggle-spells" => sub { ::toggle_player_page ($::SPELL_PAGE) },
91 "toggle-inventory" => sub { ::toggle_player_page ($::INVENTORY_PAGE) },
92 "toggle-pickup" => sub { ::toggle_player_page ($::PICKUP_PAGE) },
93 "toggle-setup" => sub { $::SETUP_DIALOG->toggle_visibility },
94 "toggle-setup" => sub { $::SETUP_DIALOG->toggle_visibility },
95 "switch-tab" => sub { $::MESSAGE_WINDOW->user_switch_to_page (0 + shift) },
96 "close-current-tab" => sub { $::MESSAGE_WINDOW->close_current_tab },
97 "activate-chat" => sub { $::MESSAGE_WINDOW->activate_current },
98 "repeat-command" => sub {
99 $::CONN->user_send ($::COMPLETER->{last_command})
100 if $::CONN && exists $::COMPLETER->{last_command};
101 },
102 "completer" => sub {
103 if ($::CONN) {
104 $::COMPLETER->set_prefix (shift);
105 $::COMPLETER->show;
106 }
107 },
108);
109
110our $DEFAULT_KEYMAP;
111
112sub init {
113 $DEFAULT_KEYMAP ||= do {
114 local $MODIFIER{LRAM} = DC::KMOD_LRAM; # hack to enable internal LRAM modifer
115
116 my %sym = map +(DC::SDL_GetKeyName $_, $_), DC::SDLK_FIRST .. DC::SDLK_LAST;
117 my $map;
118
119 while (my ($k, $v) = each %DEFAULT_KEYMAP) {
120 if ($k =~ /^\((.)\)$/) {
121 $map->{U}{ord $1} = $v;
122 } else {
123 my @mod = split /-/, $k;
124 my $sym = $sym{pop @mod}
125 or warn "unknown keysym $k\n";
126
127 my $mod = 0; $mod |= $MODIFIER{$_} for @mod;
128
129 $map->{K}[DC::popcount $mod]{$mod}{$sym} = $v;
130 }
131 }
132
133 %DEFAULT_KEYMAP = ();
134 $map
135 };
136}
44 137
45sub accelkey_to_string($) { 138sub accelkey_to_string($) {
46 join "-", 139 join "-",
47 (grep $_[0][0] & $MODIFIER{$_}, 140 (grep $_[0][0] & $MODIFIER{$_}, keys %MODIFIER),
48 keys %MODIFIER),
49 CFPlus::SDL_GetKeyName $_[0][1] 141 DC::SDL_GetKeyName $_[0][1]
50} 142}
51 143
52sub trigger_to_string($) { 144sub trigger_to_string($) {
53 my ($macro) = @_; 145 my ($macro) = @_;
54 146
81 $window->disconnect_all ("focus_out"); 173 $window->disconnect_all ("focus_out");
82 $window->destroy; 174 $window->destroy;
83 &$end_cb; 175 &$end_cb;
84 }; 176 };
85 177
86 $window = new CFPlus::UI::Toplevel 178 $window = new DC::UI::Toplevel
87 title => "Edit Macro Trigger", 179 title => "Edit Macro Trigger",
88 x => "center", 180 x => "center",
89 y => "center", 181 y => "center",
90 z => 1000, 182 z => 1000,
91 can_events => 1, 183 can_events => 1,
99 $done->(0); 191 $done->(0);
100 1 192 1
101 }, 193 },
102 ; 194 ;
103 195
104 $window->add (my $vb = new CFPlus::UI::VBox); 196 $window->add (my $vb = new DC::UI::VBox);
105 197
106 $vb->add (new CFPlus::UI::Label 198 $vb->add (new DC::UI::Label
107 text => "To bind the macro to a key,\n" 199 text => "To bind the macro to a key,\n"
108 . "press a modifier (Ctrl, Alt\n" 200 . "press a modifier (Ctrl, Alt\n"
109 . "and/or Shift) and a key, or\n" 201 . "and/or Shift) and a key, or\n"
110 . "0-9 and F1-F15 without any modifier\n\n" 202 . "0-9 and F1-F15 without any modifier\n\n"
111 . "To cancel press Escape or close this.\n\n" 203 . "To cancel press Escape or close this.\n\n"
112 . "Accelerator key combo:", 204 . "Accelerator key combo:",
113 ellipsise => 0, 205 ellipsise => 0,
114 ); 206 );
115 207
116 $vb->add (my $entry = new CFPlus::UI::Label 208 $vb->add (my $entry = new DC::UI::Label
117 fg => [0, 0, 0, 1], 209 fg => [0, 0, 0, 1],
118 bg => [1, 1, 0, 1], 210 bg => [1, 1, 0, 1],
119 ); 211 );
120 212
121 my $key_cb = sub { 213 my $key_cb = sub {
134 map "$_-", 226 map "$_-",
135 grep $mod & $MODIFIER{$_}, 227 grep $mod & $MODIFIER{$_},
136 keys %MODIFIER 228 keys %MODIFIER
137 ); 229 );
138 230
139 return if $sym >= CFPlus::SDLK_MODIFIER_MIN 231 return if $sym >= DC::SDLK_MODIFIER_MIN
140 && $sym <= CFPlus::SDLK_MODIFIER_MAX; 232 && $sym <= DC::SDLK_MODIFIER_MAX;
141 233
142 if ($mod 234 if ($mod
143 || ((grep $_ eq chr $ev->{unicode}, @DIRECT_CHARS) 235 || ((grep $_ eq chr $ev->{unicode}, @DIRECT_CHARS)
144 || (grep $_ == $sym, @DIRECT_KEYS))) 236 || (grep $_ == $sym, @DIRECT_KEYS)))
145 { 237 {
146 $macro->{accelkey} = [$mod, $sym]; 238 $macro->{accelkey} = [$mod, $sym];
147 $done->(1); 239 $done->(1);
148 } else { 240 } else {
149 $entry->set_text ("cannot bind " . (CFPlus::SDL_GetKeyName $sym) . " without modifier."); 241 $entry->set_text ("cannot bind " . (DC::SDL_GetKeyName $sym) . " without modifier.");
150 } 242 }
151 1 243 1
152 }; 244 };
153 245
154 $window->connect (key_up => $key_cb); 246 $window->connect (key_up => $key_cb);
156 248
157 $window->grab_focus; 249 $window->grab_focus;
158 $window->show; 250 $window->show;
159} 251}
160 252
253sub find_default($) {
254 my ($ev) = @_;
255
256 for my $m (reverse grep $_, @{ $DEFAULT_KEYMAP->{K} }) {
257 for (keys %$m) {
258 if ($_ == ($ev->{mod} & $_)) {
259 if (defined (my $cmd = $m->{$_}{$ev->{sym}})) {
260 return $cmd;
261 }
262 }
263 }
264 }
265
266 if (my $cmd = $DEFAULT_KEYMAP->{U}{$ev->{unicode}}) {
267 return $cmd;
268 }
269
270 ()
271}
272
273# find macro by event
274sub find($) {
275 my ($ev) = @_;
276
277 # try user-defined macros
278 if (my @user =
279 grep {
280 if (my $key = $_->{accelkey}) {
281 $key->[1] == $ev->{sym}
282 && $key->[0] == ($ev->{mod} & $MODIFIER_MASK)
283 } else {
284 0
285 }
286 } @{ $::PROFILE->{macro} || [] }
287 ) {
288 return @user;
289 }
290
291 # now try default keymap
292 if (defined (my $def = find_default $ev)) {
293 return {
294 action => [$def],
295 };
296 }
297
298 ()
299}
300
301sub execute {
302 my ($macro) = @_;
303
304 for (@{ $macro->{action} }) {
305 if (/^\!(\S+)\s?(.*)$/) {
306 $MACRO_FUNCTION{$1}->($2)
307 if exists $MACRO_FUNCTION{$1};
308 } else {
309 $::CONN->send_command ($_)
310 if $::CONN;
311 }
312 }
313}
314
161sub keyboard_setup { 315sub keyboard_setup {
162 my $kbd_setup = new CFPlus::UI::VBox; 316 my $kbd_setup = new DC::UI::VBox;
163 317
164 $kbd_setup->add (my $list = new CFPlus::UI::VBox); 318 $kbd_setup->add (my $list = new DC::UI::VBox);
165 319
166 $list->add (new CFPlus::UI::FancyFrame 320 $list->add (new DC::UI::FancyFrame
167 label => "Options", 321 label => "Options",
168 child => (my $hb = new CFPlus::UI::HBox), 322 child => (my $hb = new DC::UI::HBox),
169 ); 323 );
170 $hb->add (new CFPlus::UI::Label text => "only shift-up stops fire"); 324 $hb->add (new DC::UI::Label text => "only shift-up stops fire");
171 $hb->add (new CFPlus::UI::CheckBox 325 $hb->add (new DC::UI::CheckBox
172 expand => 1, 326 expand => 1,
173 state => $::CFG->{shift_fire_stop}, 327 state => $::CFG->{shift_fire_stop},
174 tooltip => "If this checkbox is enabled you will stop fire only if you stop pressing shift.", 328 tooltip => "If this checkbox is enabled you will stop fire only if you stop pressing shift.",
175 on_changed => sub { 329 on_changed => sub {
176 my ($cbox, $value) = @_; 330 my ($cbox, $value) = @_;
177 $::CFG->{shift_fire_stop} = $value; 331 $::CFG->{shift_fire_stop} = $value;
178 0 332 0
179 }, 333 },
180 ); 334 );
181 335
182 $list->add (new CFPlus::UI::FancyFrame 336 $list->add (new DC::UI::FancyFrame
183 label => "Bindings", 337 label => "Macros",
184 child => (my $macros = new CFPlus::UI::Table), 338 child => (my $macros = new DC::UI::VBox),
185 ); 339 );
186 340
187 my $refresh; 341 my $refresh;
188 342
189 my $tooltip_common = "\n\n<small>Left click - edit macro\nMiddle click - invoke macro\nRight click - further options</small>"; 343 my $tooltip_common = "\n\n<small>Left click - edit macro\nMiddle click - invoke macro\nRight click - further options</small>";
192 346
193 my $edit_macro = sub { 347 my $edit_macro = sub {
194 my ($macro) = @_; 348 my ($macro) = @_;
195 349
196 $kbd_setup->clear; 350 $kbd_setup->clear;
197 $kbd_setup->add (new CFPlus::UI::Button 351 $kbd_setup->add (new DC::UI::Button
198 text => "Return", 352 text => "Return",
199 tooltip => "Return to the macro list.", 353 tooltip => "Return to the macro list.",
200 on_activate => sub { 354 on_activate => sub {
201 $kbd_setup->clear; 355 $kbd_setup->clear;
202 $kbd_setup->add ($list); 356 $kbd_setup->add ($list);
203 $refresh->(); 357 $refresh->();
204 1 358 1
205 }, 359 },
206 ); 360 );
207 $kbd_setup->add (new CFPlus::UI::FancyFrame 361 $kbd_setup->add (new DC::UI::FancyFrame
208 label => "Edit Macro", 362 label => "Edit Macro",
209 child => (my $editor = new CFPlus::UI::Table col_expand => [0, 1]), 363 child => (my $editor = new DC::UI::Table col_expand => [0, 1]),
210 ); 364 );
211 365
212 $editor->add (0, 1, new CFPlus::UI::Label 366 $editor->add_at (0, 1, new DC::UI::Label
213 text => "Trigger", 367 text => "Trigger",
214 tooltip => $tooltip_trigger, 368 tooltip => $tooltip_trigger,
215 can_hover => 1, 369 can_hover => 1,
216 can_events => 1, 370 can_events => 1,
217 ); 371 );
218 $editor->add (0, 2, new CFPlus::UI::Label 372 $editor->add_at (0, 2, new DC::UI::Label
219 text => "Actions", 373 text => "Actions",
220 tooltip => $tooltip_commands, 374 tooltip => $tooltip_commands,
221 can_hover => 1, 375 can_hover => 1,
222 can_events => 1, 376 can_events => 1,
223 ); 377 );
224 378
225 $editor->add (1, 2, my $textedit = new CFPlus::UI::TextEdit 379 $editor->add_at (1, 2, my $textedit = new DC::UI::TextEdit
226 text => macro_to_text $macro, 380 text => macro_to_text $macro,
227 tooltip => $tooltip_commands, 381 tooltip => $tooltip_commands,
228 on_changed => sub { 382 on_changed => sub {
229 $macro->{action} = macro_from_text $macro, $_[1]; 383 $macro->{action} = macro_from_text $macro, $_[1];
230 }, 384 },
231 ); 385 );
232 386
233 $editor->add (1, 1, my $accel = new CFPlus::UI::Button 387 $editor->add_at (1, 1, my $accel = new DC::UI::Button
234 text => trigger_to_string $macro, 388 text => trigger_to_string $macro,
235 tooltip => "To change the trigger for a macro, activate this button.", 389 tooltip => "To change the trigger for a macro, activate this button.",
236 on_activate => sub { 390 on_activate => sub {
237 my ($accel) = @_; 391 my ($accel) = @_;
238 trigger_edit $macro, sub { 392 trigger_edit $macro, sub {
241 1 395 1
242 }, 396 },
243 ); 397 );
244 398
245 my $recording; 399 my $recording;
246 $editor->add (1, 3, new CFPlus::UI::Button 400 $editor->add_at (1, 3, new DC::UI::Button
247 text => "Start Recording", 401 text => "Start Recording",
248 tooltip => "Start/Stop command recording: when recording, " 402 tooltip => "Start/Stop command recording: when recording, "
249 . "actions and commands you invoke are appended to this macro. " 403 . "actions and commands you invoke are appended to this macro. "
250 . "You can only record when you are logged in.", 404 . "You can only record when you are logged in.",
251 on_destroy => sub { 405 on_destroy => sub {
255 my ($widget) = @_; 409 my ($widget) = @_;
256 410
257 $recording = $::CONN && !$recording; 411 $recording = $::CONN && !$recording;
258 if ($recording) { 412 if ($recording) {
259 $widget->set_text ("Stop Recording"); 413 $widget->set_text ("Stop Recording");
260 my $action = $macro->{action} ||= [];
261 $::CONN->record (sub { 414 $::CONN->record (sub {
262 push @$action, $_[0]; 415 push @{ $macro->{action} }, $_[0];
263 $textedit->set_text (macro_to_text $macro); 416 $textedit->set_text (macro_to_text $macro);
264 }) if $::CONN; 417 }) if $::CONN;
265 } else { 418 } else {
266 $widget->set_text ("Start Recording"); 419 $widget->set_text ("Start Recording");
267 $::CONN->record if $::CONN; 420 $::CONN->record if $::CONN;
268 } 421 }
269 }, 422 },
270 ); 423 );
271 }; 424 };
272 425
426 $macros->add (new DC::UI::Button
427 text => "New Macro",
428 tooltip => "Creates a new, empty, macro you can edit.",
429 on_activate => sub {
430 my $macro = { };
431 push @{ $::PROFILE->{macro} }, $macro;
432 $edit_macro->($macro);
433 },
434 );
435
436 $macros->add (my $macrolist = new DC::UI::Table col_expand => [0, 1]);
437
273 $REFRESH_MACRO_LIST = $refresh = sub { 438 $REFRESH_MACRO_LIST = $refresh = sub {
274 $macros->clear; 439 $macrolist->clear;
275 440
276 $macros->add (0, 0, new CFPlus::UI::Label 441 $macrolist->add_at (0, 1, new DC::UI::Label
277 text => "Trigger", 442 text => "Trigger",
443 tooltip => $tooltip_trigger . $tooltip_common,
444 );
445 $macrolist->add_at (1, 1, new DC::UI::Label
446 text => "Actions",
278 align => 0, 447 align => 0,
279 tooltip => $tooltip_trigger . $tooltip_common,
280 );
281 $macros->add (1, 0, new CFPlus::UI::Label
282 text => "Commands",
283 tooltip => $tooltip_commands . $tooltip_common, 448 tooltip => $tooltip_commands . $tooltip_common,
284 ); 449 );
285 450
286 for my $idx (0 .. $#{$::PROFILE->{macro} || []}) { 451 for my $idx (0 .. $#{$::PROFILE->{macro} || []}) {
287 my $macro = $::PROFILE->{macro}[$idx]; 452 my $macro = $::PROFILE->{macro}[$idx];
288 my $y = $idx + 1; 453 my $y = $idx + 2;
289 454
290 my $macro_cb = sub { 455 my $macro_cb = sub {
291 my ($widget, $ev) = @_; 456 my ($widget, $ev) = @_;
292 457
293 if ($ev->{button} == 1) { 458 if ($ev->{button} == 1) {
294 $edit_macro->($macro), 459 $edit_macro->($macro),
295 } elsif ($ev->{button} == 2) { 460 } elsif ($ev->{button} == 2) {
296 $::CONN->macro_send ($macro) if $::CONN; 461 execute ($macro);
297 } elsif ($ev->{button} == 3) { 462 } elsif ($ev->{button} == 3) {
298 (new CFPlus::UI::Menu 463 (new DC::UI::Menu
299 items => [ 464 items => [
300 ["Edit" => sub { $edit_macro->($macro) }], 465 ["Edit" => sub { $edit_macro->($macro) }],
301 ["Invoke" => sub { $::CONN->macro_send ($macro) if $::CONN }], 466 ["Invoke" => sub { execute ($macro) }],
302 ["Delete" => sub { 467 ["Delete" => sub {
303 # might want to use grep instead 468 # might want to use grep instead
304 splice @{$::PROFILE->{macro}}, $idx, 1, (); 469 splice @{$::PROFILE->{macro}}, $idx, 1, ();
305 $refresh->(); 470 $refresh->();
306 }], 471 }],
311 } 476 }
312 477
313 1 478 1
314 }; 479 };
315 480
316 $macros->add (0, $y, new CFPlus::UI::Label 481 $macrolist->add_at (0, $y, new DC::UI::Label
317 text => trigger_to_string $macro, 482 text => trigger_to_string $macro,
318 tooltip => $tooltip_trigger . $tooltip_common, 483 tooltip => $tooltip_trigger . $tooltip_common,
319 align => 0, 484 fg => [1, 0.8, 0.8],
320 can_hover => 1, 485 can_hover => 1,
321 can_events => 1, 486 can_events => 1,
322 on_button_down => $macro_cb, 487 on_button_down => $macro_cb,
323 ); 488 );
324 489
325 $macros->add (1, $y, new CFPlus::UI::Label 490 $macrolist->add_at (1, $y, new DC::UI::Label
326 text => (join "; ", @{ $macro->{action} }), 491 text => (join "; ", @{ $macro->{action} || [] }),
327 tooltip => $tooltip_commands . $tooltip_common, 492 tooltip => $tooltip_commands . $tooltip_common,
493 fg => [0.9, 0.9, 0.9],
494 align => 0,
328 expand => 1, 495 expand => 1,
329 ellipsise => 3, 496 ellipsise => 3,
330 can_hover => 1, 497 can_hover => 1,
331 can_events => 1, 498 can_events => 1,
332 on_button_down => $macro_cb, 499 on_button_down => $macro_cb,
340} 507}
341 508
342# this is a shortcut method that asks for a binding 509# this is a shortcut method that asks for a binding
343# and then just binds it. 510# and then just binds it.
344sub quick_macro { 511sub quick_macro {
345 my ($self, $cmds, $end_cb) = @_; 512 my ($cmds, $end_cb) = @_;
346 513
347 my $macro = { 514 my $macro = {
348 action => $cmds, 515 action => $cmds,
349 }; 516 };
350 517
351 trigger_edit $macro, sub { 518 trigger_edit $macro, sub {
352
353 if ($_[0]) { 519 if ($_[0]) {
354 push @{ $::PROFILE->{macro} }, $macro; 520 push @{ $::PROFILE->{macro} }, $macro;
355 $REFRESH_MACRO_LIST->(); 521 $REFRESH_MACRO_LIST->();
356 } 522 }
357 523
358 &$end_cb if $end_cb; 524 &$end_cb if $end_cb;
359 }; 525 };
360} 526}
361 527
5281

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines