1 | package CFPlus::Macro; |
1 | package DC::Macro; |
2 | |
2 | |
3 | use strict; |
3 | use common::sense; |
4 | |
4 | |
5 | use List::Util (); |
5 | use List::Util (); |
6 | use CFPlus::UI; |
6 | use DC::UI; |
7 | |
7 | |
8 | our $REFRESH_MACRO_LIST; |
8 | our $REFRESH_MACRO_LIST; |
9 | |
9 | |
10 | our %DEFAULT_KEYMAP = ( |
10 | our %DEFAULT_KEYMAP = ( |
11 | (map +("($_)" => "!completer $_"), "a" .. "z"), |
11 | (map +("($_)" => "!completer $_"), "a" .. "z"), |
12 | "(!)" => "!completer shout ", |
12 | "(!)" => "!completer shout ", |
13 | "(\")" => "!completer say ", |
13 | "(\")" => "!completer say ", |
14 | "(')" => "!completer", |
14 | "(')" => "!completer", |
15 | |
15 | |
16 | "LShift-tab" => "!toggle-messagewindow", |
16 | # "LShift-tab" => "!toggle-messagewindow", |
17 | "RShift-tab" => "!toggle-messagewindow", |
17 | # "RShift-tab" => "!toggle-messagewindow", |
18 | "tab" => "!toggle-playerbook", |
18 | "tab" => "!toggle-playerbook", |
19 | "f1" => "!toggle-help", |
19 | "f1" => "!toggle-help", |
20 | "f2" => "!toggle-stats", |
20 | "f2" => "!toggle-stats", |
21 | "f3" => "!toggle-skills", |
21 | "f3" => "!toggle-skills", |
22 | "f4" => "!toggle-spells", |
22 | "f4" => "!toggle-spells", |
23 | "f5" => "!toggle-inventory", |
23 | "f5" => "!toggle-inventory", |
24 | "f9" => "!toggle-setup", |
24 | "f9" => "!toggle-setup", |
|
|
25 | |
25 | (map +("LAlt-$_" => "!switch-tab $_"), 0..9), |
26 | (map +("LRAM-$_" => "!switch-tab $_"), 0..9), |
26 | (map +("RAlt-$_" => "!switch-tab $_"), 0..9), |
|
|
27 | "LAlt-x" => "!close-current-tab", |
27 | "LRAM-x" => "!close-current-tab", |
|
|
28 | |
28 | "return" => "!activate-chat", |
29 | "return" => "!activate-chat", |
29 | "." => "!repeat-command", |
30 | "." => "!repeat-command", |
30 | |
31 | |
31 | "," => "take", |
32 | "," => "take", |
32 | "space" => "apply", |
33 | "space" => "apply", |
33 | "enter" => "examine", |
34 | "enter" => "examine", |
34 | "[+]" => "rotateshoottype +", |
35 | "[+]" => "rotateshoottype +", |
35 | "[-]" => "rotateshoottype -", |
36 | "[-]" => "rotateshoottype -", |
|
|
37 | |
|
|
38 | "LRAM-e" => "examine", |
36 | "LAlt-s" => "ready_skill find traps", |
39 | "LRAM-s" => "ready_skill find traps", |
37 | "LAlt-d" => "ready_skill disarm traps", |
40 | "LRAM-d" => "ready_skill disarm traps", |
38 | "LAlt-p" => "ready_skill praying", |
41 | "LRAM-p" => "ready_skill praying", |
39 | ); |
42 | ); |
40 | |
43 | |
41 | # allowed modifiers |
44 | # allowed modifiers |
42 | our %MODIFIER = ( |
45 | our %MODIFIER = ( |
43 | "LShift" => CFPlus::KMOD_LSHIFT, |
46 | "LShift" => DC::KMOD_LSHIFT, |
44 | "RShift" => CFPlus::KMOD_RSHIFT, |
47 | "RShift" => DC::KMOD_RSHIFT, |
45 | # "Shift" => CFPlus::KMOD_LSHIFT | CFPlus::KMOD_RSHIFT, |
48 | # "Shift" => DC::KMOD_LSHIFT | DC::KMOD_RSHIFT, |
46 | "LCtrl" => CFPlus::KMOD_LCTRL, |
49 | "LCtrl" => DC::KMOD_LCTRL, |
47 | "RCtrl" => CFPlus::KMOD_RCTRL, |
50 | "RCtrl" => DC::KMOD_RCTRL, |
48 | # "Ctrl" => CFPlus::KMOD_LCTRL | CFPlus::KMOD_RCTRL, |
51 | # "Ctrl" => DC::KMOD_LCTRL | DC::KMOD_RCTRL, |
49 | "LAlt" => CFPlus::KMOD_LALT, |
52 | "LAlt" => DC::KMOD_LALT, |
50 | "RAlt" => CFPlus::KMOD_RALT, |
53 | "RAlt" => DC::KMOD_RALT, |
51 | # "Alt" => CFPlus::KMOD_LALT | CFPlus::KMOD_RALT, |
54 | # "Alt" => DC::KMOD_LALT | DC::KMOD_RALT, |
52 | "LMeta" => CFPlus::KMOD_LMETA, |
55 | "LMeta" => DC::KMOD_LMETA, |
53 | "RMeta" => CFPlus::KMOD_RMETA, |
56 | "RMeta" => DC::KMOD_RMETA, |
54 | # "Meta" => CFPlus::KMOD_LMETA | CFPlus::KMOD_RMETA, |
57 | # "Meta" => DC::KMOD_LMETA | DC::KMOD_RMETA, |
55 | ); |
58 | ); |
56 | |
59 | |
57 | # allowed modifiers |
60 | # allowed modifiers |
58 | our $MODIFIER_MASK |= $_ for values %MODIFIER; |
61 | our $MODIFIER_MASK |= $_ for values %MODIFIER; |
59 | |
62 | |
60 | # can bind to these without any modifier |
63 | # can bind to these without any modifier |
61 | our @DIRECT_CHARS = qw(0 1 2 3 4 5 6 7 8 9); |
64 | our @DIRECT_CHARS = qw(0 1 2 3 4 5 6 7 8 9); |
62 | |
65 | |
63 | our @DIRECT_KEYS = ( |
66 | our @DIRECT_KEYS = ( |
64 | CFPlus::SDLK_F1, |
67 | DC::SDLK_F1, |
65 | CFPlus::SDLK_F2, |
68 | DC::SDLK_F2, |
66 | CFPlus::SDLK_F3, |
69 | DC::SDLK_F3, |
67 | CFPlus::SDLK_F4, |
70 | DC::SDLK_F4, |
68 | CFPlus::SDLK_F5, |
71 | DC::SDLK_F5, |
69 | CFPlus::SDLK_F6, |
72 | DC::SDLK_F6, |
70 | CFPlus::SDLK_F7, |
73 | DC::SDLK_F7, |
71 | CFPlus::SDLK_F8, |
74 | DC::SDLK_F8, |
72 | CFPlus::SDLK_F9, |
75 | DC::SDLK_F9, |
73 | CFPlus::SDLK_F10, |
76 | DC::SDLK_F10, |
74 | CFPlus::SDLK_F11, |
77 | DC::SDLK_F11, |
75 | CFPlus::SDLK_F12, |
78 | DC::SDLK_F12, |
76 | CFPlus::SDLK_F13, |
79 | DC::SDLK_F13, |
77 | CFPlus::SDLK_F14, |
80 | DC::SDLK_F14, |
78 | CFPlus::SDLK_F15, |
81 | DC::SDLK_F15, |
79 | ); |
82 | ); |
80 | |
83 | |
81 | our %MACRO_FUNCTION = ( |
84 | our %MACRO_FUNCTION = ( |
82 | "toggle-messagewindow" => sub { $::MESSAGE_WINDOW->toggle_visibility }, |
85 | "toggle-messagewindow" => sub { $::MESSAGE_WINDOW->toggle_visibility }, |
83 | "toggle-playerbook" => sub { $::PL_WINDOW->toggle_visibility }, |
86 | "toggle-playerbook" => sub { $::PL_WINDOW->toggle_visibility }, |
… | |
… | |
106 | |
109 | |
107 | our $DEFAULT_KEYMAP; |
110 | our $DEFAULT_KEYMAP; |
108 | |
111 | |
109 | sub init { |
112 | sub init { |
110 | $DEFAULT_KEYMAP ||= do { |
113 | $DEFAULT_KEYMAP ||= do { |
|
|
114 | local $MODIFIER{LRAM} = DC::KMOD_LRAM; # hack to enable internal LRAM modifer |
|
|
115 | |
111 | my %sym = map +(CFPlus::SDL_GetKeyName $_, $_), CFPlus::SDLK_FIRST .. CFPlus::SDLK_LAST; |
116 | my %sym = map +(DC::SDL_GetKeyName $_, $_), DC::SDLK_FIRST .. DC::SDLK_LAST; |
112 | my $map; |
117 | my $map; |
113 | |
118 | |
114 | while (my ($k, $v) = each %DEFAULT_KEYMAP) { |
119 | while (my ($k, $v) = each %DEFAULT_KEYMAP) { |
115 | if ($k =~ /^\((.)\)$/) { |
120 | if ($k =~ /^\((.)\)$/) { |
116 | $map->{U}{ord $1} = $v; |
121 | $map->{U}{ord $1} = $v; |
… | |
… | |
119 | my $sym = $sym{pop @mod} |
124 | my $sym = $sym{pop @mod} |
120 | or warn "unknown keysym $k\n"; |
125 | or warn "unknown keysym $k\n"; |
121 | |
126 | |
122 | my $mod = 0; $mod |= $MODIFIER{$_} for @mod; |
127 | my $mod = 0; $mod |= $MODIFIER{$_} for @mod; |
123 | |
128 | |
124 | $map->{K}[CFPlus::popcount $mod]{$mod}{$sym} = $v; |
129 | $map->{K}[DC::popcount $mod]{$mod}{$sym} = $v; |
125 | } |
130 | } |
126 | } |
131 | } |
127 | |
132 | |
128 | %DEFAULT_KEYMAP = (); |
133 | %DEFAULT_KEYMAP = (); |
129 | $map |
134 | $map |
… | |
… | |
131 | } |
136 | } |
132 | |
137 | |
133 | sub accelkey_to_string($) { |
138 | sub accelkey_to_string($) { |
134 | join "-", |
139 | join "-", |
135 | (grep $_[0][0] & $MODIFIER{$_}, keys %MODIFIER), |
140 | (grep $_[0][0] & $MODIFIER{$_}, keys %MODIFIER), |
136 | CFPlus::SDL_GetKeyName $_[0][1] |
141 | DC::SDL_GetKeyName $_[0][1] |
137 | } |
142 | } |
138 | |
143 | |
139 | sub trigger_to_string($) { |
144 | sub trigger_to_string($) { |
140 | my ($macro) = @_; |
145 | my ($macro) = @_; |
141 | |
146 | |
… | |
… | |
168 | $window->disconnect_all ("focus_out"); |
173 | $window->disconnect_all ("focus_out"); |
169 | $window->destroy; |
174 | $window->destroy; |
170 | &$end_cb; |
175 | &$end_cb; |
171 | }; |
176 | }; |
172 | |
177 | |
173 | $window = new CFPlus::UI::Toplevel |
178 | $window = new DC::UI::Toplevel |
174 | title => "Edit Macro Trigger", |
179 | title => "Edit Macro Trigger", |
175 | x => "center", |
180 | x => "center", |
176 | y => "center", |
181 | y => "center", |
177 | z => 1000, |
182 | z => 1000, |
178 | can_events => 1, |
183 | can_events => 1, |
… | |
… | |
186 | $done->(0); |
191 | $done->(0); |
187 | 1 |
192 | 1 |
188 | }, |
193 | }, |
189 | ; |
194 | ; |
190 | |
195 | |
191 | $window->add (my $vb = new CFPlus::UI::VBox); |
196 | $window->add (my $vb = new DC::UI::VBox); |
192 | |
197 | |
193 | $vb->add (new CFPlus::UI::Label |
198 | $vb->add (new DC::UI::Label |
194 | text => "To bind the macro to a key,\n" |
199 | text => "To bind the macro to a key,\n" |
195 | . "press a modifier (Ctrl, Alt\n" |
200 | . "press a modifier (Ctrl, Alt\n" |
196 | . "and/or Shift) and a key, or\n" |
201 | . "and/or Shift) and a key, or\n" |
197 | . "0-9 and F1-F15 without any modifier\n\n" |
202 | . "0-9 and F1-F15 without any modifier\n\n" |
198 | . "To cancel press Escape or close this.\n\n" |
203 | . "To cancel press Escape or close this.\n\n" |
199 | . "Accelerator key combo:", |
204 | . "Accelerator key combo:", |
200 | ellipsise => 0, |
205 | ellipsise => 0, |
201 | ); |
206 | ); |
202 | |
207 | |
203 | $vb->add (my $entry = new CFPlus::UI::Label |
208 | $vb->add (my $entry = new DC::UI::Label |
204 | fg => [0, 0, 0, 1], |
209 | fg => [0, 0, 0, 1], |
205 | bg => [1, 1, 0, 1], |
210 | bg => [1, 1, 0, 1], |
206 | ); |
211 | ); |
207 | |
212 | |
208 | my $key_cb = sub { |
213 | my $key_cb = sub { |
… | |
… | |
221 | map "$_-", |
226 | map "$_-", |
222 | grep $mod & $MODIFIER{$_}, |
227 | grep $mod & $MODIFIER{$_}, |
223 | keys %MODIFIER |
228 | keys %MODIFIER |
224 | ); |
229 | ); |
225 | |
230 | |
226 | return if $sym >= CFPlus::SDLK_MODIFIER_MIN |
231 | return if $sym >= DC::SDLK_MODIFIER_MIN |
227 | && $sym <= CFPlus::SDLK_MODIFIER_MAX; |
232 | && $sym <= DC::SDLK_MODIFIER_MAX; |
228 | |
233 | |
229 | if ($mod |
234 | if ($mod |
230 | || ((grep $_ eq chr $ev->{unicode}, @DIRECT_CHARS) |
235 | || ((grep $_ eq chr $ev->{unicode}, @DIRECT_CHARS) |
231 | || (grep $_ == $sym, @DIRECT_KEYS))) |
236 | || (grep $_ == $sym, @DIRECT_KEYS))) |
232 | { |
237 | { |
233 | $macro->{accelkey} = [$mod, $sym]; |
238 | $macro->{accelkey} = [$mod, $sym]; |
234 | $done->(1); |
239 | $done->(1); |
235 | } else { |
240 | } else { |
236 | $entry->set_text ("cannot bind " . (CFPlus::SDL_GetKeyName $sym) . " without modifier."); |
241 | $entry->set_text ("cannot bind " . (DC::SDL_GetKeyName $sym) . " without modifier."); |
237 | } |
242 | } |
238 | 1 |
243 | 1 |
239 | }; |
244 | }; |
240 | |
245 | |
241 | $window->connect (key_up => $key_cb); |
246 | $window->connect (key_up => $key_cb); |
… | |
… | |
306 | } |
311 | } |
307 | } |
312 | } |
308 | } |
313 | } |
309 | |
314 | |
310 | sub keyboard_setup { |
315 | sub keyboard_setup { |
311 | my $kbd_setup = new CFPlus::UI::VBox; |
316 | my $kbd_setup = new DC::UI::VBox; |
312 | |
317 | |
313 | $kbd_setup->add (my $list = new CFPlus::UI::VBox); |
318 | $kbd_setup->add (my $list = new DC::UI::VBox); |
314 | |
319 | |
315 | $list->add (new CFPlus::UI::FancyFrame |
320 | $list->add (new DC::UI::FancyFrame |
316 | label => "Options", |
321 | label => "Options", |
317 | child => (my $hb = new CFPlus::UI::HBox), |
322 | child => (my $hb = new DC::UI::HBox), |
318 | ); |
323 | ); |
319 | $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"); |
320 | $hb->add (new CFPlus::UI::CheckBox |
325 | $hb->add (new DC::UI::CheckBox |
321 | expand => 1, |
326 | expand => 1, |
322 | state => $::CFG->{shift_fire_stop}, |
327 | state => $::CFG->{shift_fire_stop}, |
323 | 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.", |
324 | on_changed => sub { |
329 | on_changed => sub { |
325 | my ($cbox, $value) = @_; |
330 | my ($cbox, $value) = @_; |
326 | $::CFG->{shift_fire_stop} = $value; |
331 | $::CFG->{shift_fire_stop} = $value; |
327 | 0 |
332 | 0 |
328 | }, |
333 | }, |
329 | ); |
334 | ); |
330 | |
335 | |
331 | $list->add (new CFPlus::UI::FancyFrame |
336 | $list->add (new DC::UI::FancyFrame |
332 | label => "Macros", |
337 | label => "Macros", |
333 | child => (my $macros = new CFPlus::UI::VBox), |
338 | child => (my $macros = new DC::UI::VBox), |
334 | ); |
339 | ); |
335 | |
340 | |
336 | my $refresh; |
341 | my $refresh; |
337 | |
342 | |
338 | 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>"; |
… | |
… | |
341 | |
346 | |
342 | my $edit_macro = sub { |
347 | my $edit_macro = sub { |
343 | my ($macro) = @_; |
348 | my ($macro) = @_; |
344 | |
349 | |
345 | $kbd_setup->clear; |
350 | $kbd_setup->clear; |
346 | $kbd_setup->add (new CFPlus::UI::Button |
351 | $kbd_setup->add (new DC::UI::Button |
347 | text => "Return", |
352 | text => "Return", |
348 | tooltip => "Return to the macro list.", |
353 | tooltip => "Return to the macro list.", |
349 | on_activate => sub { |
354 | on_activate => sub { |
350 | $kbd_setup->clear; |
355 | $kbd_setup->clear; |
351 | $kbd_setup->add ($list); |
356 | $kbd_setup->add ($list); |
352 | $refresh->(); |
357 | $refresh->(); |
353 | 1 |
358 | 1 |
354 | }, |
359 | }, |
355 | ); |
360 | ); |
356 | $kbd_setup->add (new CFPlus::UI::FancyFrame |
361 | $kbd_setup->add (new DC::UI::FancyFrame |
357 | label => "Edit Macro", |
362 | label => "Edit Macro", |
358 | child => (my $editor = new CFPlus::UI::Table col_expand => [0, 1]), |
363 | child => (my $editor = new DC::UI::Table col_expand => [0, 1]), |
359 | ); |
364 | ); |
360 | |
365 | |
361 | $editor->add_at (0, 1, new CFPlus::UI::Label |
366 | $editor->add_at (0, 1, new DC::UI::Label |
362 | text => "Trigger", |
367 | text => "Trigger", |
363 | tooltip => $tooltip_trigger, |
368 | tooltip => $tooltip_trigger, |
364 | can_hover => 1, |
369 | can_hover => 1, |
365 | can_events => 1, |
370 | can_events => 1, |
366 | ); |
371 | ); |
367 | $editor->add_at (0, 2, new CFPlus::UI::Label |
372 | $editor->add_at (0, 2, new DC::UI::Label |
368 | text => "Actions", |
373 | text => "Actions", |
369 | tooltip => $tooltip_commands, |
374 | tooltip => $tooltip_commands, |
370 | can_hover => 1, |
375 | can_hover => 1, |
371 | can_events => 1, |
376 | can_events => 1, |
372 | ); |
377 | ); |
373 | |
378 | |
374 | $editor->add_at (1, 2, my $textedit = new CFPlus::UI::TextEdit |
379 | $editor->add_at (1, 2, my $textedit = new DC::UI::TextEdit |
375 | text => macro_to_text $macro, |
380 | text => macro_to_text $macro, |
376 | tooltip => $tooltip_commands, |
381 | tooltip => $tooltip_commands, |
377 | on_changed => sub { |
382 | on_changed => sub { |
378 | $macro->{action} = macro_from_text $macro, $_[1]; |
383 | $macro->{action} = macro_from_text $macro, $_[1]; |
379 | }, |
384 | }, |
380 | ); |
385 | ); |
381 | |
386 | |
382 | $editor->add_at (1, 1, my $accel = new CFPlus::UI::Button |
387 | $editor->add_at (1, 1, my $accel = new DC::UI::Button |
383 | text => trigger_to_string $macro, |
388 | text => trigger_to_string $macro, |
384 | tooltip => "To change the trigger for a macro, activate this button.", |
389 | tooltip => "To change the trigger for a macro, activate this button.", |
385 | on_activate => sub { |
390 | on_activate => sub { |
386 | my ($accel) = @_; |
391 | my ($accel) = @_; |
387 | trigger_edit $macro, sub { |
392 | trigger_edit $macro, sub { |
… | |
… | |
390 | 1 |
395 | 1 |
391 | }, |
396 | }, |
392 | ); |
397 | ); |
393 | |
398 | |
394 | my $recording; |
399 | my $recording; |
395 | $editor->add_at (1, 3, new CFPlus::UI::Button |
400 | $editor->add_at (1, 3, new DC::UI::Button |
396 | text => "Start Recording", |
401 | text => "Start Recording", |
397 | tooltip => "Start/Stop command recording: when recording, " |
402 | tooltip => "Start/Stop command recording: when recording, " |
398 | . "actions and commands you invoke are appended to this macro. " |
403 | . "actions and commands you invoke are appended to this macro. " |
399 | . "You can only record when you are logged in.", |
404 | . "You can only record when you are logged in.", |
400 | on_destroy => sub { |
405 | on_destroy => sub { |
… | |
… | |
416 | } |
421 | } |
417 | }, |
422 | }, |
418 | ); |
423 | ); |
419 | }; |
424 | }; |
420 | |
425 | |
421 | $macros->add (new CFPlus::UI::Button |
426 | $macros->add (new DC::UI::Button |
422 | text => "New Macro", |
427 | text => "New Macro", |
423 | tooltip => "Creates a new, empty, macro you can edit.", |
428 | tooltip => "Creates a new, empty, macro you can edit.", |
424 | on_activate => sub { |
429 | on_activate => sub { |
425 | my $macro = { }; |
430 | my $macro = { }; |
426 | push @{ $::PROFILE->{macro} }, $macro; |
431 | push @{ $::PROFILE->{macro} }, $macro; |
427 | $edit_macro->($macro); |
432 | $edit_macro->($macro); |
428 | }, |
433 | }, |
429 | ); |
434 | ); |
430 | |
435 | |
431 | $macros->add (my $macrolist = new CFPlus::UI::Table col_expand => [0, 1]); |
436 | $macros->add (my $macrolist = new DC::UI::Table col_expand => [0, 1]); |
432 | |
437 | |
433 | $REFRESH_MACRO_LIST = $refresh = sub { |
438 | $REFRESH_MACRO_LIST = $refresh = sub { |
434 | $macrolist->clear; |
439 | $macrolist->clear; |
435 | |
440 | |
436 | $macrolist->add_at (0, 1, new CFPlus::UI::Label |
441 | $macrolist->add_at (0, 1, new DC::UI::Label |
437 | 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", |
438 | align => 0, |
447 | align => 0, |
439 | tooltip => $tooltip_trigger . $tooltip_common, |
|
|
440 | ); |
|
|
441 | $macrolist->add_at (1, 1, new CFPlus::UI::Label |
|
|
442 | text => "Commands", |
|
|
443 | tooltip => $tooltip_commands . $tooltip_common, |
448 | tooltip => $tooltip_commands . $tooltip_common, |
444 | ); |
449 | ); |
445 | |
450 | |
446 | for my $idx (0 .. $#{$::PROFILE->{macro} || []}) { |
451 | for my $idx (0 .. $#{$::PROFILE->{macro} || []}) { |
447 | my $macro = $::PROFILE->{macro}[$idx]; |
452 | my $macro = $::PROFILE->{macro}[$idx]; |
… | |
… | |
451 | my ($widget, $ev) = @_; |
456 | my ($widget, $ev) = @_; |
452 | |
457 | |
453 | if ($ev->{button} == 1) { |
458 | if ($ev->{button} == 1) { |
454 | $edit_macro->($macro), |
459 | $edit_macro->($macro), |
455 | } elsif ($ev->{button} == 2) { |
460 | } elsif ($ev->{button} == 2) { |
456 | $::CONN->macro_send ($macro) if $::CONN; |
461 | execute ($macro); |
457 | } elsif ($ev->{button} == 3) { |
462 | } elsif ($ev->{button} == 3) { |
458 | (new CFPlus::UI::Menu |
463 | (new DC::UI::Menu |
459 | items => [ |
464 | items => [ |
460 | ["Edit" => sub { $edit_macro->($macro) }], |
465 | ["Edit" => sub { $edit_macro->($macro) }], |
461 | ["Invoke" => sub { $::CONN->macro_send ($macro) if $::CONN }], |
466 | ["Invoke" => sub { execute ($macro) }], |
462 | ["Delete" => sub { |
467 | ["Delete" => sub { |
463 | # might want to use grep instead |
468 | # might want to use grep instead |
464 | splice @{$::PROFILE->{macro}}, $idx, 1, (); |
469 | splice @{$::PROFILE->{macro}}, $idx, 1, (); |
465 | $refresh->(); |
470 | $refresh->(); |
466 | }], |
471 | }], |
… | |
… | |
471 | } |
476 | } |
472 | |
477 | |
473 | 1 |
478 | 1 |
474 | }; |
479 | }; |
475 | |
480 | |
476 | $macrolist->add_at (0, $y, new CFPlus::UI::Label |
481 | $macrolist->add_at (0, $y, new DC::UI::Label |
477 | text => trigger_to_string $macro, |
482 | text => trigger_to_string $macro, |
478 | tooltip => $tooltip_trigger . $tooltip_common, |
483 | tooltip => $tooltip_trigger . $tooltip_common, |
479 | align => 0, |
484 | fg => [1, 0.8, 0.8], |
480 | can_hover => 1, |
485 | can_hover => 1, |
481 | can_events => 1, |
486 | can_events => 1, |
482 | on_button_down => $macro_cb, |
487 | on_button_down => $macro_cb, |
483 | ); |
488 | ); |
484 | |
489 | |
485 | $macrolist->add_at (1, $y, new CFPlus::UI::Label |
490 | $macrolist->add_at (1, $y, new DC::UI::Label |
486 | text => (join "; ", @{ $macro->{action} || [] }), |
491 | text => (join "; ", @{ $macro->{action} || [] }), |
487 | tooltip => $tooltip_commands . $tooltip_common, |
492 | tooltip => $tooltip_commands . $tooltip_common, |
|
|
493 | fg => [0.9, 0.9, 0.9], |
|
|
494 | align => 0, |
488 | expand => 1, |
495 | expand => 1, |
489 | ellipsise => 3, |
496 | ellipsise => 3, |
490 | can_hover => 1, |
497 | can_hover => 1, |
491 | can_events => 1, |
498 | can_events => 1, |
492 | on_button_down => $macro_cb, |
499 | on_button_down => $macro_cb, |