[Tkabber-dev] r886 - in trunk/tkabber-plugins: . spy

tkabber-svn at jabber.ru tkabber-svn at jabber.ru
Sun Jan 28 00:05:33 MSK 2007


Author: sergei
Date: 2007-01-28 00:05:31 +0300 (Sun, 28 Jan 2007)
New Revision: 886

Modified:
   trunk/tkabber-plugins/ChangeLog
   trunk/tkabber-plugins/spy/spy.tcl
Log:
	* spy/spy.tcl: Added search in spy presence window.


Modified: trunk/tkabber-plugins/ChangeLog
===================================================================
--- trunk/tkabber-plugins/ChangeLog	2007-01-27 11:05:13 UTC (rev 885)
+++ trunk/tkabber-plugins/ChangeLog	2007-01-27 21:05:31 UTC (rev 886)
@@ -1,3 +1,7 @@
+2006-01-27  Sergei Golovan <sgolovan at nes.ru>
+
+	* spy/spy.tcl: Added search in spy presence window.
+
 2006-01-26  Sergei Golovan <sgolovan at nes.ru>
 
 	* checkers/checkers.tcl, chess/chess.tcl, debug/debug.tcl,

Modified: trunk/tkabber-plugins/spy/spy.tcl
===================================================================
--- trunk/tkabber-plugins/spy/spy.tcl	2007-01-27 11:05:13 UTC (rev 885)
+++ trunk/tkabber-plugins/spy/spy.tcl	2007-01-27 21:05:31 UTC (rev 886)
@@ -86,7 +86,8 @@
     set log [text $w.log -font $font -wrap word]
     $sw setwidget $log
 
-    $log configure -state disabled
+    $log configure -state disabled -takefocus 1
+    bind $log <1> [list focus $log]
 
     $log tag configure timestamp \
 	-foreground [option get $w timestampforeground Spy]
@@ -98,6 +99,8 @@
 	-foreground [option get $w presenceforeground Spy]
     $log tag configure reason \
 	-foreground [option get $w reasonforeground Spy]
+
+    search::setup_panel $w
 }
 
 proc spy::set_watch {} {
@@ -361,3 +364,56 @@
 hook::add quit_hook [namespace current]::spy::deinit_spy 100
 hook::add finload_hook [namespace current]::spy::setup_menu
 
+namespace eval spy::search {}
+
+proc spy::search::open_panel {sf w} {
+    set sentry $sf.search
+
+    pack $sf -side bottom -anchor w -fill x -before $w.isw
+    focus $sentry
+
+    update idletasks
+    $w.log see end
+}
+
+proc spy::search::close_panel {sf w} {
+    $w.log tag remove search_highlight 0.0 end
+    pack forget $sf
+    focus $w.log
+}
+
+proc spy::search::setup_panel {w} {
+    set log $w.log
+
+    $log mark set sel_start end
+    $log mark set sel_end 0.0
+
+    set sf [frame [winfo parent $log].search]
+
+    set sentry \
+	[entry $sf.search \
+	       -validate all \
+	       -validatecommand [list plugins::search::validate_entry %W %P]]
+    pack $sentry -padx 1m -side left
+
+    set sbox [ButtonBox $sf.sbox -spacing 0]
+    $sbox add -text [::msgcat::mc "Search up"] \
+         -command [list plugins::search::do_text_search $log $sentry 1]
+    $sbox add -text [::msgcat::mc "Search down"] \
+         -command [list plugins::search::do_text_search $log $sentry 0]
+    pack $sbox -side left -padx 1m
+    
+    set cbox [ButtonBox $sf.cbox -spacing 0]
+    $cbox add -text [::msgcat::mc "Close"] \
+         -command [list [namespace current]::close_panel $sf $w]
+    pack $cbox -side right -padx 1m
+
+    bind $sentry <Key-Return> [double% [list $sbox invoke 0]]
+    bind $sentry <Shift-Key-Return> [double% [list $sbox invoke 1]]
+    bind $sentry <Escape> \
+	[double% [list [namespace current]::close_panel $sf $w]]
+
+    bind $w.log <<OpenSearchPanel>> \
+	[double% [list [namespace current]::open_panel $sf $w]]
+}
+



More information about the Tkabber-dev mailing list