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