summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoretienne2016-12-16 13:38:30 +0000
committeretienne2016-12-16 13:38:30 +0000
commit57d462d43e713da41fa4d621fb77449a7e3a263e (patch)
tree8dbee8289b6b2aa66e2243a29b9925fd5b12a232 /src
parent7fa73e306994e3e72862bf495f53d7b3077f8408 (diff)
downloadivymon-57d462d43e713da41fa4d621fb77449a7e3a263e.zip
ivymon-57d462d43e713da41fa4d621fb77449a7e3a263e.tar.gz
ivymon-57d462d43e713da41fa4d621fb77449a7e3a263e.tar.bz2
ivymon-57d462d43e713da41fa4d621fb77449a7e3a263e.tar.xz
Diffstat (limited to 'src')
-rwxr-xr-xsrc/ivymon115
1 files changed, 82 insertions, 33 deletions
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('<Key-Tab>', sub {Tk->break});
+$mw->bind('all', '<Key-Tab>', sub {Tk->break});
+# virtual event <<LeftTab>> found in Tk::MainWindow
+$mw->bind('all', '<<LeftTab>>', sub {Tk->break});
+
my $focusedtext;
$mw->bind("Tk::Text", "<FocusIn>", [sub {
&clearSearch() if $_[1] ne $focusedtext;
@@ -552,6 +555,7 @@ my $messagesText =
$focusedtext = $messagesText;
&wheelmousebindings($messagesText);
$messagesText->bind('<1>', sub {$messagesText->focus;});
+$messagesText->bind('<Control-a>', \&selectMsgInTextWidget);
$messagesText->tagBind('sender', '<Double-1>', \&marker);
my $bgcolor = $messagesText->cget(-background);
@@ -686,6 +690,7 @@ $bindingsEntry->bind('<Down>' => [\&bindingNextExpression]);
$bindingsEntry->bind('<Control-n>' => [\&bindingNextExpression]);
$bindingsEntry->bind('<Up>' => [\&bindingPrevExpression]);
$bindingsEntry->bind('<Control-p>' => [\&bindingPrevExpression]);
+$bindingsEntry->bind('<Control-a>' => [\&select_all_entry]);
$bindingsEntry->focus;
@@ -701,6 +706,7 @@ my $bindingsList =
$bindingsList->bind('<1>', [\&selectBinding]);
$bindingsList->bind('<Double-1>', [\&addBinding]);
$bindingsEntry->bind('<Key>' => [\&findExprInList, $bindingsList]);
+$bindingsEntry->bind('<<LeftTab>>' => [\&findRvalue, -1]);
my $effectivebindingsList =
# need intermediate frame for balloon help
@@ -820,13 +826,18 @@ my $sendList =
-side => 'top',
-expand => 1);
-$sendEntry->bind('<Key>' => [\&findExprInList, $sendList]);
+$sendEntry->bind('<Key>' => sub {
+ &findExprInList($sendEntry, $sendList);
+ $recipientLabel->configure(-text => '');
+});
+$sendEntry->bind('<<LeftTab>>' => [\&findRvalue, -1]);
$sendEntry->bind('<Return>' => [\&addMsgToSend, undef, 1]);
$sendEntry->bind('<Down>' => [\&sendNextExpression]);
$sendEntry->bind('<Control-n>' => [\&sendNextExpression]);
$sendEntry->bind('<Up>' => [\&sendPrevExpression]);
$sendEntry->bind('<Control-p>' => [\&sendPrevExpression]);
+$sendEntry->bind('<Control-a>' => [\&select_all_entry]);
$sendList->bind('<1>', [\&selectMsgToSend]);
$sendList->bind('<Double-1>', [\&addMsgToSend, undef, 1]);
@@ -852,6 +863,7 @@ $searchEntry->bind('<<SearchPrev>>' => [\&searchPrev, 1]);
$searchEntry->bind('<<SearchNextExpr>>' => [\&searchNextExpression]);
$searchEntry->bind('<<SearchPrevExpr>>' => [\&searchPrevExpression]);
$searchEntry->bind('<Key>' => [\&searchOnTheFly]);
+$searchEntry->bind('<Control-a>' => [\&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<Search> frame provides an interface for searching pattern in messages wind
The B<Control> panel contains some general control buttons. Set or unset balloon help functionality with the I<Balloon help> checkbutton. Stop the messages scrolling with the I<Scroll Lock> button. You must do it if you want to insert a marker in the messages window. Restart scrolling with the I<Scroll> button. To access markers sequentially, press the I<Jump> button. With the I<Load> and I<Save> buttons, you can select input and output files. The I<Clear> button removes all displayed messages. At last, the I<Exit> button closes the application.
-
=head1 OPTIONS
=over