summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoretienne2004-09-03 15:46:10 +0000
committeretienne2004-09-03 15:46:10 +0000
commit3caff0fd2c7ebfd0487facdb96fd0131ffee92c4 (patch)
treec8835e6969d04071e4699c33dd2d160e9b183063 /src
parentb4019a05c5e2141a45d3d7af107ddd97e7ec78e4 (diff)
downloadivymon-3caff0fd2c7ebfd0487facdb96fd0131ffee92c4.zip
ivymon-3caff0fd2c7ebfd0487facdb96fd0131ffee92c4.tar.gz
ivymon-3caff0fd2c7ebfd0487facdb96fd0131ffee92c4.tar.bz2
ivymon-3caff0fd2c7ebfd0487facdb96fd0131ffee92c4.tar.xz
added search functionality to all Text widgets
Diffstat (limited to 'src')
-rwxr-xr-xsrc/ivymon70
1 files changed, 39 insertions, 31 deletions
diff --git a/src/ivymon b/src/ivymon
index 7c35546..5262a41 100755
--- a/src/ivymon
+++ b/src/ivymon
@@ -260,7 +260,10 @@ $mw->title($title);
# Key-Tab binding is deactivated, because this event will be used by entries
# for completion functionality
$mw->bind('<Key-Tab>', sub {Tk->break});
-
+my $focusedtext;
+$mw->bind("Tk::Text", "<FocusIn>", [sub {
+ &clearSearch() if $_[1] ne $focusedtext;
+ $focusedtext = $_[1];}, Ev('W')]);
# create balloon help widget
my $balloonhelp = $mw->Balloon(-balloonposition => 'mouse',
@@ -387,6 +390,7 @@ my $messagesText =
)->pack(-fill => 'both',
-expand => 1,
-side => 'bottom');
+$focusedtext = $messagesText;
&wheelmousebindings($messagesText);
$messagesText->bind('<1>', sub {$messagesText->focus;});
$messagesText->tagBind('sender', '<Double-1>', \&marker);
@@ -1082,7 +1086,10 @@ sub filterClient {
-scrollbars => 'e',
)->pack(-side => 'top',
-fill => 'both',
- -expand => 1);
+ -expand => 1);
+ $clientsMessagesTpl{$client}->bind('<1>',
+ sub {$clientsMessagesTpl{$client}->focus;});
+
&wheelmousebindings($clientsMessagesTpl{$client});
$tpl->Button(-text => 'Close',
@@ -1296,19 +1303,20 @@ sub afterUpdatingMessages {
sub highlightString {
my ($i1, $i2) = @_;
# hidden data
- $messagesText->tagConfigure('found',
- -background => 'sienna',
- -foreground => 'ivory');
- $messagesText->tagAdd('found', $i1, $i2);
-
+ print "focusedtext=$focusedtext\n";
+ $focusedtext->tagConfigure('found',
+ -background => 'sienna',
+ -foreground => 'ivory');
+ $focusedtext->tagAdd('found', $i1, $i2);
+
} # end highlightString
sub highlightStringOff {
- $messagesText->tagDelete('found');
- $messagesText->tagConfigure('found',
- -background => 'sienna',
- -foreground => 'ivory');
+ $focusedtext->tagDelete('found');
+ $focusedtext->tagConfigure('found',
+ -background => 'sienna',
+ -foreground => 'ivory');
} # end highlightStringOff
@@ -1734,16 +1742,16 @@ sub searchOnTheFly {
my @searchopts = (-hidden, -count => \$strlen, -forwards);
push(@searchopts, -nocase) unless ($casesensitiveflag);
push(@searchopts, -regexp) if ($regexpflag);
- my $index = $messagesText->search(@searchopts, $string, $index0);
+ my $index = $focusedtext->search(@searchopts, $string, $index0);
print "index=$index strlen=$strlen\n";
if ($index) {
&highlightStringOff if $searchString and $string eq $searchString;
- $searchString = $messagesText->get($index, "$index + $strlen chars");
+ $searchString = $focusedtext->get($index, "$index + $strlen chars");
$searchIndex = $index;
&highlightString($index, "$index + $strlen chars");
- $messagesText->see($index);
+ $focusedtext->see($index);
} else {
- &warning2($messagesText);
+ &warning2($focusedtext);
}
} # end searchOnTheFly
@@ -1756,18 +1764,18 @@ sub searchNext {
my @searchopts = (-hidden, -count => \$strlen, -forwards);
push(@searchopts, -nocase) unless ($casesensitiveflag);
push(@searchopts, -regexp) if ($regexpflag);
- my $index = $messagesText->search(@searchopts, $string, $index0);
+ my $index = $focusedtext->search(@searchopts, $string, $index0);
#print "index=$index searchIndex=$searchIndex strlen=$strlen\n";
&highlightStringOff;
if ($index) {
&highlightString($index, "$index + $strlen chars");
- $messagesText->see($index);
- &warning1($messagesText) if defined($searchIndex) and
- $messagesText->compare($index, "<=" ,$searchIndex);
- $searchString = $messagesText->get($index, "$index + $strlen chars");
+ $focusedtext->see($index);
+ &warning1($focusedtext) if defined($searchIndex) and
+ $focusedtext->compare($index, "<=" ,$searchIndex);
+ $searchString = $focusedtext->get($index, "$index + $strlen chars");
$searchIndex = $index;
} else {
- &warning2($messagesText);
+ &warning2($focusedtext);
}
$searchHistoryIndex = -1;
&searchHistoryGenList($string);
@@ -1784,17 +1792,17 @@ sub searchPrev {
my @searchopts = (-hidden, -count => \$strlen, -backwards);
push(@searchopts, -nocase) unless ($casesensitiveflag);
push(@searchopts, -regexp) if ($regexpflag);
- my $index = $messagesText->search(@searchopts, $string, $index0);
+ my $index = $focusedtext->search(@searchopts, $string, $index0);
&highlightStringOff;
if ($index) {
&highlightString($index, "$index + $strlen chars");
- $messagesText->see($index);
- &warning1($messagesText) if defined($searchIndex) and
- $messagesText->compare($index, ">=" ,$searchIndex);
- $searchString = $messagesText->get($index, "$index + $strlen chars");
+ $focusedtext->see($index);
+ &warning1($focusedtext) if defined($searchIndex) and
+ $focusedtext->compare($index, ">=" ,$searchIndex);
+ $searchString = $focusedtext->get($index, "$index + $strlen chars");
$searchIndex = $index;
} else {
- &warning2($messagesText);
+ &warning2($focusedtext);
}
$searchHistoryIndex = -1;
&searchHistoryGenList($string);
@@ -1807,7 +1815,7 @@ sub searchAll {
my $string = $searchEntry->get;
my $strlen;
return unless $string;
- $messagesText->tagConfigure('found',
+ $focusedtext->tagConfigure('found',
-background => 'sienna',
-foreground => 'ivory');
my $index = '0.0';
@@ -1817,13 +1825,13 @@ sub searchAll {
push(@searchopts, -regexp) if ($regexpflag);
while ($index) {
- $index = $messagesText->search(@searchopts, $string, $index, 'end');
+ $index = $focusedtext->search(@searchopts, $string, $index, 'end');
last unless $index;
- $messagesText->tagAdd('found', $index, "$index + $strlen chars");
+ $focusedtext->tagAdd('found', $index, "$index + $strlen chars");
$index = "$index + 1 chars";
$found++;
}
- &warning2($messagesText) unless ($found);
+ &warning2($focusedtext) unless ($found);
$searchHistoryIndex = -1;
&searchHistoryGenList($string);
$searchString = undef;