From 57d462d43e713da41fa4d621fb77449a7e3a263e Mon Sep 17 00:00:00 2001 From: etienne Date: Fri, 16 Dec 2016 13:38:30 +0000 Subject: --- debian/changelog | 10 +++++ src/ivymon | 115 +++++++++++++++++++++++++++++++++++++++---------------- 2 files changed, 92 insertions(+), 33 deletions(-) diff --git a/debian/changelog b/debian/changelog index efc7a67..527408b 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,13 @@ +ivymon (1.27) unstable; urgency=low + + * Entries content can be selected using the shortcut. + * In entries containing expressions like var=rvalue, previous rvalue + can be selected using the shortcut. + * An ivy message can be selected by pointing it in the messages frame + then using the shortcut. + + -- Daniel Etienne Fri, 16 Dec 2016 14:00:00 +0200 + ivymon (1.26) unstable; urgency=low * Default history size is restored to 200000 messages (previous value diff --git a/src/ivymon b/src/ivymon index 5b6ecde..debb7dc 100755 --- a/src/ivymon +++ b/src/ivymon @@ -94,7 +94,7 @@ use Tk::CmdLine; use vars qw/$VERSION $opt_help $opt_b $opt_bus $opt_history @opt_bind $opt_verbose @opt_send $opt_size $opt_undersize $opt_out $opt_debug $opt_buf/; # **** VERSION **** -$VERSION = '1.26'; # TODO a modifier +$VERSION = '1.27'; # TODO a modifier # options initialisation # geometry @@ -364,7 +364,10 @@ EOF # Key-Tab binding is deactivated, because this event will be used by entries # for completion functionality -$mw->bind('', sub {Tk->break}); +$mw->bind('all', '', sub {Tk->break}); +# virtual event <> found in Tk::MainWindow +$mw->bind('all', '<>', sub {Tk->break}); + my $focusedtext; $mw->bind("Tk::Text", "", [sub { &clearSearch() if $_[1] ne $focusedtext; @@ -552,6 +555,7 @@ my $messagesText = $focusedtext = $messagesText; &wheelmousebindings($messagesText); $messagesText->bind('<1>', sub {$messagesText->focus;}); +$messagesText->bind('', \&selectMsgInTextWidget); $messagesText->tagBind('sender', '', \&marker); my $bgcolor = $messagesText->cget(-background); @@ -686,6 +690,7 @@ $bindingsEntry->bind('' => [\&bindingNextExpression]); $bindingsEntry->bind('' => [\&bindingNextExpression]); $bindingsEntry->bind('' => [\&bindingPrevExpression]); $bindingsEntry->bind('' => [\&bindingPrevExpression]); +$bindingsEntry->bind('' => [\&select_all_entry]); $bindingsEntry->focus; @@ -701,6 +706,7 @@ my $bindingsList = $bindingsList->bind('<1>', [\&selectBinding]); $bindingsList->bind('', [\&addBinding]); $bindingsEntry->bind('' => [\&findExprInList, $bindingsList]); +$bindingsEntry->bind('<>' => [\&findRvalue, -1]); my $effectivebindingsList = # need intermediate frame for balloon help @@ -820,13 +826,18 @@ my $sendList = -side => 'top', -expand => 1); -$sendEntry->bind('' => [\&findExprInList, $sendList]); +$sendEntry->bind('' => sub { + &findExprInList($sendEntry, $sendList); + $recipientLabel->configure(-text => ''); +}); +$sendEntry->bind('<>' => [\&findRvalue, -1]); $sendEntry->bind('' => [\&addMsgToSend, undef, 1]); $sendEntry->bind('' => [\&sendNextExpression]); $sendEntry->bind('' => [\&sendNextExpression]); $sendEntry->bind('' => [\&sendPrevExpression]); $sendEntry->bind('' => [\&sendPrevExpression]); +$sendEntry->bind('' => [\&select_all_entry]); $sendList->bind('<1>', [\&selectMsgToSend]); $sendList->bind('', [\&addMsgToSend, undef, 1]); @@ -852,6 +863,7 @@ $searchEntry->bind('<>' => [\&searchPrev, 1]); $searchEntry->bind('<>' => [\&searchNextExpression]); $searchEntry->bind('<>' => [\&searchPrevExpression]); $searchEntry->bind('' => [\&searchOnTheFly]); +$searchEntry->bind('' => [\&select_all_entry]); my $checkbutt_fm = $search_fm->Frame()->grid(-column => 1, @@ -975,20 +987,26 @@ for my $msg (sort(@send_def)) { # Balloon help messages #---------------------------------------------------------------------------------- +my $selectionText = + "Use the [Control-a] shortcut to select the entire\n". + "entry text. "; + my $completionText = - "Provides completion functionality : type part \n". - "of a word and hit the [Tab] key to activate \n". - "completion. "; + "Type part of a word and hit the [Tab] key to \n". + "activate completion. "; my $historyText = - "Provides history functionality : use [Up] and \n". - "[Down] keys to navigate in inputs history. "; + "Use [Up] and [Down] keys to navigate in inputs \n". + "history. "; my $insertionText = - "Also makes values entries easier : when you hit \n". - "the [Tab] key, the insertion cursor move to the \n". - "next rvalue field, and select it if defined. "; - + "If entry contains expressions such as 'Var=Rvalue',\n". + "pressing the [Tab] key let you search the next Rvalue; \n". + "the insertion cursor is moved after the next '=' char \n". + "and the Rvalue is selected if defined. \n". + "The [Shift-Tab] shortcut let you search the previous \n". + "Rvalue."; + $balloonhelp->attach($messagesMaxLabel, -balloonmsg => "Maximum number of recordable messages\n". "(=history size value) " @@ -1009,6 +1027,7 @@ $balloonhelp->attach($bindingsEntry, -balloonmsg => "This input field is used to enter new bindings or\n". "edit default one from list above. In both case, \n". "hit [Enter] to apply. \n". + $selectionText."\n". $historyText."\n". $completionText."\n". $insertionText @@ -1036,6 +1055,7 @@ $balloonhelp->attach($sendEntry, -balloonmsg => "This input field is used to enter new messages or\n". "edit default one from list above. In both case, \n". "hit [Enter] to send it. \n". + $selectionText."\n". $historyText."\n". $completionText."\n". $insertionText @@ -1058,13 +1078,16 @@ $balloonhelp->attach($messagesText, -balloonmsg => "message sender name (marker will be create after\n". "the message). Then, you can quickly access markers \n". "using the [Jump] button in control panel. To remove a \n". - "marker, just double-click on it. " + "marker, just double-click on it.\n". + "To select a message, point it then use the [Control-a]\n". + "shortcut." ); $balloonhelp->attach($searchEntry, -balloonmsg => "This input field is used to search expressions in \n". "messages list. Hit [Return], [Ctrl-s] or [Ctrl-f]\n". "key to search forward and [Shift-Return] or [Ctrl-r]\n". "key to search backward. \n". + $selectionText."\n". $historyText ); $balloonhelp->attach($scrollLockButton, -balloonmsg => @@ -1690,6 +1713,14 @@ sub highlightStringOff { -foreground => 'ivory'); } # end highlightStringOff +sub selectMsgInTextWidget { + my $index0 = $messagesText->index('current linestart'); + my $seltext = $messagesText->get($index0, "$index0 + 1 lines - 2 chars"); + my $num = index($seltext, '"'); + $num++; + $messagesText->tagAdd("sel", "$index0 + $num chars", "$index0 + 1 lines - 2 chars"); + +} # end selectMsgInTextWidget #---------------------------------------------------------------------------------- # Functions related to the 'Bindings' frame @@ -1735,7 +1766,6 @@ sub bindingPrevExpression { } # end bindingPrevExpression - sub clearBinding { $bindingsEntry->delete(0, 'end'); $bindingsList->selectionClear(0, 'end'); @@ -2794,6 +2824,13 @@ sub configProgressbar { # Utils functions #---------------------------------------------------------------------------------- +sub select_all_entry { + my $entry = shift; + $entry->selectionRange(0, 'end'); + +} # end select_all_entry + + sub enlarge_bindingsfm { @packinfo = (); @@ -2861,12 +2898,13 @@ sub wheelmousebindings { sub findExprInList { my ($entry, $list) = @_; - $recipientLabel->configure(-text => ''); my $key = $entry->XEvent->K; my $expr = $entry->get; #print "expr=$expr\n"; my @elems = $list->get(0, "end"); - # if key is Tab + ### if key is Tab + # . make completion if possible and/or + # . move cursor after the next '=' char and select rvalue if exists if ($key eq 'Tab') { my $index = 0; my @found; @@ -2884,7 +2922,7 @@ sub findExprInList { &warning2($entry); my @cursel = $list->curselection; $list->selectionClear(@cursel) if @cursel > 0; - &findRvalue($entry, $expr); + &findRvalue($entry, 1); # only one expression is found } elsif (@found == 1) { my @cursel = $list->curselection; @@ -2896,7 +2934,7 @@ sub findExprInList { $entry->delete(0, 'end'); $entry->insert(0, scalar $list->get($found[0])); } - &findRvalue($entry, $expr); + &findRvalue($entry, 1); # several expressions are found } else { @@ -2921,12 +2959,13 @@ sub findExprInList { $entry->insert('end', $commonstr); } - # if entry is empty and if key is not Tab (key is backspace) + ### if entry is empty and if key is not Tab (key is backspace) } elsif (not $expr) { my @cursel = $list->curselection; $list->selectionClear(@cursel) if @cursel > 0; - # if entry is not empty and key is not Tab + ### if entry is not empty and key is not Tab + # . select the first item of list which matches } else { my $index = 0; for my $elem (sort @elems) { @@ -2945,32 +2984,43 @@ sub findExprInList { } # end findExprInList - sub findRvalue { my $entry = shift; - my $expr = shift; + my $arg = shift; + my $expr = $entry->get; + + my $index; my $cursorIndex = $entry->index('insert'); - my $index = index($expr, '=', $cursorIndex); - if ($index < 0) { - $index = index($expr, '='); + if ($arg == 1) { + # search next rvalue from current cursor position + $index = index($expr, '=', $cursorIndex); + # if not index found, search from beginning + if ($index < 0) { + $index = index($expr, '='); + } + } else { + # search prev rvalue from current cursor position + $index = rindex($expr, '=', $cursorIndex-2); + # if not index found, search from the beginning + if ($index < 0) { + $index = rindex($expr, '='); + } } return if $index < 0; my $rvalue = substr($expr, $index+1); $entry->selectionClear; if ($rvalue =~ /(^\S+)/) { - $rvalue = $1; - # skip char ) at the end of string - $rvalue =~ s/\)$//; - $entry->selectionFrom($index+1); - $entry->selectionTo($index +1 + length($rvalue)); + $rvalue = $1; + # skip char ) at the end of string + $rvalue =~ s/\)$//; + $entry->selectionFrom($index+1); + $entry->selectionTo($index +1 + length($rvalue)); } $entry->icursor($index+1); $entry->xview($index-15); - } # end findRvalue - sub fmt_size { my ($size) = shift; my $unit = 'B'; @@ -3084,7 +3134,6 @@ The B frame provides an interface for searching pattern in messages wind The B panel contains some general control buttons. Set or unset balloon help functionality with the I checkbutton. Stop the messages scrolling with the I button. You must do it if you want to insert a marker in the messages window. Restart scrolling with the I button. To access markers sequentially, press the I button. With the I and I buttons, you can select input and output files. The I button removes all displayed messages. At last, the I button closes the application. - =head1 OPTIONS =over -- cgit v1.1