diff options
-rwxr-xr-x | src/ivymon | 70 |
1 files changed, 39 insertions, 31 deletions
@@ -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; |