… | |
… | |
221 | $kbd_setup->add (new CFPlus::UI::FancyFrame |
221 | $kbd_setup->add (new CFPlus::UI::FancyFrame |
222 | label => "Edit Macro", |
222 | label => "Edit Macro", |
223 | child => (my $editor = new CFPlus::UI::Table col_expand => [0, 1]), |
223 | child => (my $editor = new CFPlus::UI::Table col_expand => [0, 1]), |
224 | ); |
224 | ); |
225 | |
225 | |
226 | $editor->add (0, 1, new CFPlus::UI::Label |
226 | $editor->add_at (0, 1, new CFPlus::UI::Label |
227 | text => "Trigger", |
227 | text => "Trigger", |
228 | tooltip => $tooltip_trigger, |
228 | tooltip => $tooltip_trigger, |
229 | can_hover => 1, |
229 | can_hover => 1, |
230 | can_events => 1, |
230 | can_events => 1, |
231 | ); |
231 | ); |
232 | $editor->add (0, 2, new CFPlus::UI::Label |
232 | $editor->add_at (0, 2, new CFPlus::UI::Label |
233 | text => "Actions", |
233 | text => "Actions", |
234 | tooltip => $tooltip_commands, |
234 | tooltip => $tooltip_commands, |
235 | can_hover => 1, |
235 | can_hover => 1, |
236 | can_events => 1, |
236 | can_events => 1, |
237 | ); |
237 | ); |
238 | |
238 | |
239 | $editor->add (1, 2, my $textedit = new CFPlus::UI::TextEdit |
239 | $editor->add_at (1, 2, my $textedit = new CFPlus::UI::TextEdit |
240 | text => macro_to_text $macro, |
240 | text => macro_to_text $macro, |
241 | tooltip => $tooltip_commands, |
241 | tooltip => $tooltip_commands, |
242 | on_changed => sub { |
242 | on_changed => sub { |
243 | $macro->{action} = macro_from_text $macro, $_[1]; |
243 | $macro->{action} = macro_from_text $macro, $_[1]; |
244 | }, |
244 | }, |
245 | ); |
245 | ); |
246 | |
246 | |
247 | $editor->add (1, 1, my $accel = new CFPlus::UI::Button |
247 | $editor->add_at (1, 1, my $accel = new CFPlus::UI::Button |
248 | text => trigger_to_string $macro, |
248 | text => trigger_to_string $macro, |
249 | tooltip => "To change the trigger for a macro, activate this button.", |
249 | tooltip => "To change the trigger for a macro, activate this button.", |
250 | on_activate => sub { |
250 | on_activate => sub { |
251 | my ($accel) = @_; |
251 | my ($accel) = @_; |
252 | trigger_edit $macro, sub { |
252 | trigger_edit $macro, sub { |
… | |
… | |
255 | 1 |
255 | 1 |
256 | }, |
256 | }, |
257 | ); |
257 | ); |
258 | |
258 | |
259 | my $recording; |
259 | my $recording; |
260 | $editor->add (1, 3, new CFPlus::UI::Button |
260 | $editor->add_at (1, 3, new CFPlus::UI::Button |
261 | text => "Start Recording", |
261 | text => "Start Recording", |
262 | tooltip => "Start/Stop command recording: when recording, " |
262 | tooltip => "Start/Stop command recording: when recording, " |
263 | . "actions and commands you invoke are appended to this macro. " |
263 | . "actions and commands you invoke are appended to this macro. " |
264 | . "You can only record when you are logged in.", |
264 | . "You can only record when you are logged in.", |
265 | on_destroy => sub { |
265 | on_destroy => sub { |
… | |
… | |
269 | my ($widget) = @_; |
269 | my ($widget) = @_; |
270 | |
270 | |
271 | $recording = $::CONN && !$recording; |
271 | $recording = $::CONN && !$recording; |
272 | if ($recording) { |
272 | if ($recording) { |
273 | $widget->set_text ("Stop Recording"); |
273 | $widget->set_text ("Stop Recording"); |
274 | my $action = $macro->{action} ||= []; |
|
|
275 | $::CONN->record (sub { |
274 | $::CONN->record (sub { |
276 | push @$action, $_[0]; |
275 | push @{ $macro->{action} }, $_[0]; |
277 | $textedit->set_text (macro_to_text $macro); |
276 | $textedit->set_text (macro_to_text $macro); |
278 | }) if $::CONN; |
277 | }) if $::CONN; |
279 | } else { |
278 | } else { |
280 | $widget->set_text ("Start Recording"); |
279 | $widget->set_text ("Start Recording"); |
281 | $::CONN->record if $::CONN; |
280 | $::CONN->record if $::CONN; |
… | |
… | |
297 | $macros->add (my $macrolist = new CFPlus::UI::Table col_expand => [0, 1]); |
296 | $macros->add (my $macrolist = new CFPlus::UI::Table col_expand => [0, 1]); |
298 | |
297 | |
299 | $REFRESH_MACRO_LIST = $refresh = sub { |
298 | $REFRESH_MACRO_LIST = $refresh = sub { |
300 | $macrolist->clear; |
299 | $macrolist->clear; |
301 | |
300 | |
302 | $macrolist->add (0, 1, new CFPlus::UI::Label |
301 | $macrolist->add_at (0, 1, new CFPlus::UI::Label |
303 | text => "Trigger", |
302 | text => "Trigger", |
304 | align => 0, |
303 | align => 0, |
305 | tooltip => $tooltip_trigger . $tooltip_common, |
304 | tooltip => $tooltip_trigger . $tooltip_common, |
306 | ); |
305 | ); |
307 | $macrolist->add (1, 1, new CFPlus::UI::Label |
306 | $macrolist->add_at (1, 1, new CFPlus::UI::Label |
308 | text => "Commands", |
307 | text => "Commands", |
309 | tooltip => $tooltip_commands . $tooltip_common, |
308 | tooltip => $tooltip_commands . $tooltip_common, |
310 | ); |
309 | ); |
311 | |
310 | |
312 | for my $idx (0 .. $#{$::PROFILE->{macro} || []}) { |
311 | for my $idx (0 .. $#{$::PROFILE->{macro} || []}) { |
… | |
… | |
337 | } |
336 | } |
338 | |
337 | |
339 | 1 |
338 | 1 |
340 | }; |
339 | }; |
341 | |
340 | |
342 | $macrolist->add (0, $y, new CFPlus::UI::Label |
341 | $macrolist->add_at (0, $y, new CFPlus::UI::Label |
343 | text => trigger_to_string $macro, |
342 | text => trigger_to_string $macro, |
344 | tooltip => $tooltip_trigger . $tooltip_common, |
343 | tooltip => $tooltip_trigger . $tooltip_common, |
345 | align => 0, |
344 | align => 0, |
346 | can_hover => 1, |
345 | can_hover => 1, |
347 | can_events => 1, |
346 | can_events => 1, |
348 | on_button_down => $macro_cb, |
347 | on_button_down => $macro_cb, |
349 | ); |
348 | ); |
350 | |
349 | |
351 | $macrolist->add (1, $y, new CFPlus::UI::Label |
350 | $macrolist->add_at (1, $y, new CFPlus::UI::Label |
352 | text => (join "; ", @{ $macro->{action} || [] }), |
351 | text => (join "; ", @{ $macro->{action} || [] }), |
353 | tooltip => $tooltip_commands . $tooltip_common, |
352 | tooltip => $tooltip_commands . $tooltip_common, |
354 | expand => 1, |
353 | expand => 1, |
355 | ellipsise => 3, |
354 | ellipsise => 3, |
356 | can_hover => 1, |
355 | can_hover => 1, |