[Tkabber-dev] r756 - in trunk/tkabber: . examples/xrdb plugins/chat plugins/filetransfer plugins/general plugins/unix

tkabber-svn at jabber.ru tkabber-svn at jabber.ru
Tue Oct 10 23:29:50 MSD 2006


Author: sergei
Date: 2006-10-10 23:29:22 +0400 (Tue, 10 Oct 2006)
New Revision: 756

Modified:
   trunk/tkabber/ChangeLog
   trunk/tkabber/datagathering.tcl
   trunk/tkabber/examples/xrdb/badlop-dark.xrdb
   trunk/tkabber/examples/xrdb/black.xrdb
   trunk/tkabber/examples/xrdb/dark.xrdb
   trunk/tkabber/examples/xrdb/dark2.xrdb
   trunk/tkabber/examples/xrdb/green.xrdb
   trunk/tkabber/examples/xrdb/ice.xrdb
   trunk/tkabber/examples/xrdb/light.xrdb
   trunk/tkabber/examples/xrdb/lighthouse.xrdb
   trunk/tkabber/examples/xrdb/ocean-deep.xrdb
   trunk/tkabber/examples/xrdb/teopetuk.xrdb
   trunk/tkabber/examples/xrdb/warm.xrdb
   trunk/tkabber/messages.tcl
   trunk/tkabber/plugins/chat/completion.tcl
   trunk/tkabber/plugins/filetransfer/http.tcl
   trunk/tkabber/plugins/filetransfer/jidlink.tcl
   trunk/tkabber/plugins/filetransfer/si.tcl
   trunk/tkabber/plugins/general/message_archive.tcl
   trunk/tkabber/plugins/general/subscribe_gateway.tcl
   trunk/tkabber/plugins/unix/ispell.tcl
   trunk/tkabber/userinfo.tcl
   trunk/tkabber/utils.tcl
Log:
	* utils.tcl: Added another workaround for XIM input.

	* plugins/unix/ispell.tcl: Use workaround from utils.tcl.
	  Redesigned ispell plugin to work not only in chat windows.
	  Reassigned two resources from Chat to Text class.

	* examples/xrdb/*: Reassigned two resources from Chat to Text
	  class.

	* plugins/chat/completion.tcl: Bugfix, check if window with
	  tab completion exists.

	* datagathering.tcl, messages.tcl, plugins/filetransfer/http.tcl,
	  plugins/filetransfer/jidlink.tcl, plugins/filetransfer/si.tcl,
	  plugins/general/message_archive.tcl,
	  plugins/general/subscribe_gateway.tcl, userinfo.tcl:
	  Use wrapper textUndoable which enables undo mechanism and
	  initialises spellchecker for the text window.


Modified: trunk/tkabber/ChangeLog
===================================================================
--- trunk/tkabber/ChangeLog	2006-10-10 07:26:11 UTC (rev 755)
+++ trunk/tkabber/ChangeLog	2006-10-10 19:29:22 UTC (rev 756)
@@ -1,3 +1,24 @@
+2006-10-11  Sergei Golovan  <sgolovan at nes.ru>
+
+	* utils.tcl: Added another workaround for XIM input.
+
+	* plugins/unix/ispell.tcl: Use workaround from utils.tcl.
+	  Redesigned ispell plugin to work not only in chat windows.
+	  Reassigned two resources from Chat to Text class.
+
+	* examples/xrdb/*: Reassigned two resources from Chat to Text
+	  class.
+
+	* plugins/chat/completion.tcl: Bugfix, check if window with
+	  tab completion exists.
+
+	* datagathering.tcl, messages.tcl, plugins/filetransfer/http.tcl,
+	  plugins/filetransfer/jidlink.tcl, plugins/filetransfer/si.tcl,
+	  plugins/general/message_archive.tcl,
+	  plugins/general/subscribe_gateway.tcl, userinfo.tcl:
+	  Use wrapper textUndoable which enables undo mechanism and
+	  initialises spellchecker for the text window.
+
 2006-10-10  Sergei Golovan  <sgolovan at nes.ru>
 
 	* plugins/chat/completion.tcl: Made workaround for XIM in

Modified: trunk/tkabber/datagathering.tcl
===================================================================
--- trunk/tkabber/datagathering.tcl	2006-10-10 07:26:11 UTC (rev 755)
+++ trunk/tkabber/datagathering.tcl	2006-10-10 19:29:22 UTC (rev 756)
@@ -386,7 +386,7 @@
 	text-multi {
 	    add_label $g $row $label $required
 	    set sw [ScrolledWindow $g.textsw$row -scrollbar vertical]
-	    text $g.text$row -font $font -height 6 -width 50
+	    textUndoable $g.text$row -font $font -height 6 -width 50
 	    $sw setwidget $g.text$row
 	    bind $g.text$row <Control-Key-Return> { }
 	    bind $g.text$row <Return> "[bind Text <Return>]\nbreak"

Modified: trunk/tkabber/examples/xrdb/badlop-dark.xrdb
===================================================================
--- trunk/tkabber/examples/xrdb/badlop-dark.xrdb	2006-10-10 07:26:11 UTC (rev 755)
+++ trunk/tkabber/examples/xrdb/badlop-dark.xrdb	2006-10-10 19:29:22 UTC (rev 756)
@@ -192,8 +192,8 @@
 *urlactiveforeground:	    	    #add8e6
 
 ! Colors of erroneous words (when ispell module is using)
-*Chat.errorColor:		    #ff7f50
-*Chat.comboColor:		    #add8e6
+*Text.errorColor:		    #ff7f50
+*Text.comboColor:		    #add8e6
 
 *Chat.inputheight:                  3
 

Modified: trunk/tkabber/examples/xrdb/black.xrdb
===================================================================
--- trunk/tkabber/examples/xrdb/black.xrdb	2006-10-10 07:26:11 UTC (rev 755)
+++ trunk/tkabber/examples/xrdb/black.xrdb	2006-10-10 19:29:22 UTC (rev 756)
@@ -70,8 +70,8 @@
 *Chat.errforeground:		    coral3
 *urlforeground:			    cornflowerblue
 *urlactiveforeground:		    skyblue
-*Chat.errorColor:		    coral3
-*Chat.comboColor:		    cornflowerblue
+*Text.errorColor:		    coral3
+*Text.comboColor:		    cornflowerblue
 
 *ProgressBar.foreground:	    grey
 

Modified: trunk/tkabber/examples/xrdb/dark.xrdb
===================================================================
--- trunk/tkabber/examples/xrdb/dark.xrdb	2006-10-10 07:26:11 UTC (rev 755)
+++ trunk/tkabber/examples/xrdb/dark.xrdb	2006-10-10 19:29:22 UTC (rev 756)
@@ -157,8 +157,8 @@
 *urlactiveforeground:	    lightblue1
 
 ! Colors of erroneous words (when ispell module is using)
-*Chat.errorColor:		    coral
-*Chat.comboColor:		    lightblue
+*Text.errorColor:		    coral
+*Text.comboColor:		    lightblue
 
 ! Colors of tab labels (when in tabbed mode)
 ! Usual color

Modified: trunk/tkabber/examples/xrdb/dark2.xrdb
===================================================================
--- trunk/tkabber/examples/xrdb/dark2.xrdb	2006-10-10 07:26:11 UTC (rev 755)
+++ trunk/tkabber/examples/xrdb/dark2.xrdb	2006-10-10 19:29:22 UTC (rev 756)
@@ -157,8 +157,8 @@
 *urlactiveforeground:		    #c0ede0
 
 ! Colors of erroneous words (when ispell module is using)
-*Chat.errorColor:		    #f99393
-*Chat.comboColor:		    #add8cc
+*Text.errorColor:		    #f99393
+*Text.comboColor:		    #add8cc
 
 *Customize.varforeground:	    #add8cc
 

Modified: trunk/tkabber/examples/xrdb/green.xrdb
===================================================================
--- trunk/tkabber/examples/xrdb/green.xrdb	2006-10-10 07:26:11 UTC (rev 755)
+++ trunk/tkabber/examples/xrdb/green.xrdb	2006-10-10 19:29:22 UTC (rev 756)
@@ -85,8 +85,8 @@
 *Chat.errforeground:	        orange
 *urlforeground:			DarkOliveGreen2
 *urlactiveforeground:	    Green
-*Chat.errorColor:	    orange
-*Chat.comboColor:	    Yellow
+*Text.errorColor:	    orange
+*Text.comboColor:	    Yellow
 
 *NoteBook.alertColor0: PaleGreen3
 *NoteBook.alertColor1: PaleGreen2

Modified: trunk/tkabber/examples/xrdb/ice.xrdb
===================================================================
--- trunk/tkabber/examples/xrdb/ice.xrdb	2006-10-10 07:26:11 UTC (rev 755)
+++ trunk/tkabber/examples/xrdb/ice.xrdb	2006-10-10 19:29:22 UTC (rev 756)
@@ -167,8 +167,8 @@
 *urlactiveforeground:	    dodgerblue3
 
 ! Colors of erroneous words (when ispell module is using)
-*Chat.errorColor:		    firebrick4
-*Chat.comboColor:		    dodgerblue4
+*Text.errorColor:		    firebrick4
+*Text.comboColor:		    dodgerblue4
 
 ! Colors of tab labels (when in tabbed mode)
 ! Usual color

Modified: trunk/tkabber/examples/xrdb/light.xrdb
===================================================================
--- trunk/tkabber/examples/xrdb/light.xrdb	2006-10-10 07:26:11 UTC (rev 755)
+++ trunk/tkabber/examples/xrdb/light.xrdb	2006-10-10 19:29:22 UTC (rev 756)
@@ -167,8 +167,8 @@
 *urlactiveforeground:	    dodgerblue3
 
 ! Colors of erroneous words (when ispell module is using)
-*Chat.errorColor:		    firebrick4
-*Chat.comboColor:		    dodgerblue4
+*Text.errorColor:		    firebrick4
+*Text.comboColor:		    dodgerblue4
 
 ! Colors of tab labels (when in tabbed mode)
 ! Usual color

Modified: trunk/tkabber/examples/xrdb/lighthouse.xrdb
===================================================================
--- trunk/tkabber/examples/xrdb/lighthouse.xrdb	2006-10-10 07:26:11 UTC (rev 755)
+++ trunk/tkabber/examples/xrdb/lighthouse.xrdb	2006-10-10 19:29:22 UTC (rev 756)
@@ -155,8 +155,8 @@
 *urlactiveforeground:		    dodgerblue3
 
 ! Colors of erroneous words (when ispell module is using)
-*Chat.errorColor:		    firebrick4
-*Chat.comboColor:		    dodgerblue4
+*Text.errorColor:		    firebrick4
+*Text.comboColor:		    dodgerblue4
 
 ! Colors of tab labels (when in tabbed mode)
 ! Usual color

Modified: trunk/tkabber/examples/xrdb/ocean-deep.xrdb
===================================================================
--- trunk/tkabber/examples/xrdb/ocean-deep.xrdb	2006-10-10 07:26:11 UTC (rev 755)
+++ trunk/tkabber/examples/xrdb/ocean-deep.xrdb	2006-10-10 19:29:22 UTC (rev 756)
@@ -297,8 +297,8 @@
 *urlactiveforeground:             #add8e6
 
 ! Colors of erroneous words (when ispell module is using)
-*Chat.errorColor:                 #ff7f50
-*Chat.comboColor:                 #add8e6
+*Text.errorColor:                 #ff7f50
+*Text.comboColor:                 #add8e6
 
 *Chat.inputheight:                3
 

Modified: trunk/tkabber/examples/xrdb/teopetuk.xrdb
===================================================================
--- trunk/tkabber/examples/xrdb/teopetuk.xrdb	2006-10-10 07:26:11 UTC (rev 755)
+++ trunk/tkabber/examples/xrdb/teopetuk.xrdb	2006-10-10 19:29:22 UTC (rev 756)
@@ -164,8 +164,8 @@
 *urlactiveforeground:		    dodgerblue3
 
 ! Colors of erroneous words (when ispell module is using)
-*Chat.errorColor:		    firebrick4
-*Chat.comboColor:		    dodgerblue4
+*Text.errorColor:		    firebrick4
+*Text.comboColor:		    dodgerblue4
 
 ! Colors of tab labels (when in tabbed mode)
 ! Usual color

Modified: trunk/tkabber/examples/xrdb/warm.xrdb
===================================================================
--- trunk/tkabber/examples/xrdb/warm.xrdb	2006-10-10 07:26:11 UTC (rev 755)
+++ trunk/tkabber/examples/xrdb/warm.xrdb	2006-10-10 19:29:22 UTC (rev 756)
@@ -192,8 +192,8 @@
 *urlactiveforeground:	    dodgerblue3
 
 ! Colors of erroneous words (when ispell module is using)
-*Chat.errorColor:		    firebrick
-*Chat.comboColor:		    dodgerblue4
+*Text.errorColor:		    firebrick
+*Text.comboColor:		    dodgerblue4
 
 ! Colors of tab labels (when in tabbed mode)
 ! Usual color

Modified: trunk/tkabber/messages.tcl
===================================================================
--- trunk/tkabber/messages.tcl	2006-10-10 07:26:11 UTC (rev 755)
+++ trunk/tkabber/messages.tcl	2006-10-10 19:29:22 UTC (rev 756)
@@ -844,7 +844,7 @@
     ScrolledWindow $mw.sw
     pack $mw.sw -side top -fill both -expand yes -in $mw.frame
 
-    text $mw.body -width 60 -height 8 -wrap word
+    textUndoable $mw.body -width 60 -height 8 -wrap word
     $mw.body insert 0.0 [::msgcat::mc "I would like to add you to my roster."]
     pack $mw.body -side top -fill both -expand yes -in $mw.sw
     $mw.sw setwidget $mw.body

Modified: trunk/tkabber/plugins/chat/completion.tcl
===================================================================
--- trunk/tkabber/plugins/chat/completion.tcl	2006-10-10 07:26:11 UTC (rev 755)
+++ trunk/tkabber/plugins/chat/completion.tcl	2006-10-10 19:29:22 UTC (rev 756)
@@ -250,6 +250,8 @@
     variable completion
 
     set iw [chat::input_win $chatid]
+    if {![winfo exists $iw]} return
+
     if {[$iw index insert] != $idx} {
 	set completion(state,$chatid) normal
     }

Modified: trunk/tkabber/plugins/filetransfer/http.tcl
===================================================================
--- trunk/tkabber/plugins/filetransfer/http.tcl	2006-10-10 07:26:11 UTC (rev 755)
+++ trunk/tkabber/plugins/filetransfer/http.tcl	2006-10-10 19:29:22 UTC (rev 756)
@@ -57,7 +57,7 @@
 	-command [list [namespace current]::set_send_file_name $winid]
 
     label $f.ldesc -text [::msgcat::mc "Description:"]
-    text $f.desc -width 50 -height 5
+    textUndoable $f.desc -width 50 -height 5 -wrap word
 
     label $f.lip -text [::msgcat::mc "IP address:"]
     entry $f.ip -textvariable [list [namespace current]::ip$winid]

Modified: trunk/tkabber/plugins/filetransfer/jidlink.tcl
===================================================================
--- trunk/tkabber/plugins/filetransfer/jidlink.tcl	2006-10-10 07:26:11 UTC (rev 755)
+++ trunk/tkabber/plugins/filetransfer/jidlink.tcl	2006-10-10 19:29:22 UTC (rev 756)
@@ -69,7 +69,7 @@
 	-command [list [namespace current]::set_send_file_name $winid]
 
     label $f.ldesc -text [::msgcat::mc "Description:"]
-    text $f.desc -width 50 -height 5
+    textUndoable $f.desc -width 50 -height 5 -wrap word
 
     ProgressBar $f.pb -variable [namespace current]::progress$f.pb
     variable progress$f.pb 0

Modified: trunk/tkabber/plugins/filetransfer/si.tcl
===================================================================
--- trunk/tkabber/plugins/filetransfer/si.tcl	2006-10-10 07:26:11 UTC (rev 755)
+++ trunk/tkabber/plugins/filetransfer/si.tcl	2006-10-10 19:29:22 UTC (rev 756)
@@ -60,7 +60,7 @@
 	-command [list [namespace current]::set_send_file_name $token]
 
     label $f.ldesc -text [::msgcat::mc "Description:"]
-    text $f.desc -width 50 -height 5
+    textUndoable $f.desc -width 50 -height 5 -wrap word
 
     ProgressBar $f.pb -variable ${token}(progress)
     set state(pb) $f.pb

Modified: trunk/tkabber/plugins/general/message_archive.tcl
===================================================================
--- trunk/tkabber/plugins/general/message_archive.tcl	2006-10-10 07:26:11 UTC (rev 755)
+++ trunk/tkabber/plugins/general/message_archive.tcl	2006-10-10 19:29:22 UTC (rev 756)
@@ -72,7 +72,7 @@
     pack $dw.subject.subj -side left
 
     set body [ScrolledWindow $dw.sw]
-    text $body.body -height 20 -state disabled
+    text $body.body -height 20 -state disabled -wrap word
     pack $body -expand yes -fill both -anchor nw
     $body setwidget $body.body
     $body.body tag configure emphasized -elide 1

Modified: trunk/tkabber/plugins/general/subscribe_gateway.tcl
===================================================================
--- trunk/tkabber/plugins/general/subscribe_gateway.tcl	2006-10-10 07:26:11 UTC (rev 755)
+++ trunk/tkabber/plugins/general/subscribe_gateway.tcl	2006-10-10 19:29:22 UTC (rev 756)
@@ -77,7 +77,7 @@
     ScrolledWindow $mw.sw
     pack $mw.sw -side top -fill both -expand yes -in $mw.frame
 
-    text $mw.body -width 60 -height 8 -wrap word
+    textUndoable $mw.body -width 60 -height 8 -wrap word
     $mw.body insert 0.0 "I would like to add you to my roster."
     pack $mw.body -side top -fill both -expand yes -in $mw.sw
     $mw.sw setwidget $mw.body

Modified: trunk/tkabber/plugins/unix/ispell.tcl
===================================================================
--- trunk/tkabber/plugins/unix/ispell.tcl	2006-10-10 07:26:11 UTC (rev 755)
+++ trunk/tkabber/plugins/unix/ispell.tcl	2006-10-10 19:29:22 UTC (rev 756)
@@ -23,8 +23,8 @@
 	[::msgcat::mc "Ispell dictionary encoding. If it is empty, system encoding is used."] -type string -group Ispell
     variable misspelled
     variable word_id 0
-    option add *Chat.errorColor Red widgetDefault
-    option add *Chat.comboColor Blue widgetDefault
+    option add *Text.errorColor Red widgetDefault
+    option add *Text.comboColor Blue widgetDefault
 }
 
 proc ispell::start {} {
@@ -207,14 +207,6 @@
     set state($iw) 0
 }
     
-proc ispell::after_process {iw sym} {
-    variable after_id
-    if {![info exists after_id($iw)]} {
-	set after_id($iw) \
-	    [after idle [list [namespace current]::process_line $iw $sym]]
-    }
-}
-
 proc ispell::popup_menu {iw x y} {
     variable response
 
@@ -259,18 +251,27 @@
     $iw insert $wordstart $sub
 }
 
-proc ispell::setup_bindings {chatid type} {
-    global usetabbar
-    variable history
+proc ispell::after_process {iw sym} {
+    variable state
+    variable after_id
 
-    set iw [chat::input_win $chatid]
+    if {![info exists state($iw)]} return
+
+    if {![info exists after_id($iw)]} {
+	set after_id($iw) \
+	    [after idle [list [namespace current]::process_line $iw $sym]]
+    }
+}
+
+hook::add text_on_keypress_hook [namespace current]::ispell::after_process
+
+proc ispell::setup_bindings {iw} {
     clear_ispell $iw
     bind $iw <Return> +[list [namespace current]::clear_ispell $iw]
-    bind $iw <Key> +[list [namespace current]::after_process $iw %A]
     bind $iw <3> [list [namespace current]::popup_menu $iw %x %y]
-    $iw tag configure err -foreground [option get [winfo parent $iw] errorColor Chat]
-    $iw tag configure combo -foreground [option get [winfo parent $iw] comboColor Chat]
+    $iw tag configure err -foreground [option get $iw errorColor Text]
+    $iw tag configure combo -foreground [option get $iw comboColor Text]
 }
 
-hook::add open_chat_post_hook [namespace current]::ispell::setup_bindings
+hook::add text_on_create_hook [namespace current]::ispell::setup_bindings
 

Modified: trunk/tkabber/userinfo.tcl
===================================================================
--- trunk/tkabber/userinfo.tcl	2006-10-10 07:26:11 UTC (rev 755)
+++ trunk/tkabber/userinfo.tcl	2006-10-10 19:29:22 UTC (rev 756)
@@ -317,7 +317,11 @@
 
     set a [pack_frame $about.about [string trim [::msgcat::mc "About "]]]
     set sw [ScrolledWindow $a.sw -scrollbar vertical]
-    text $a.text -font $font -height 12 -wrap word
+    if {!$editable} {
+	text $a.text -font $font -height 12 -wrap word
+    } else {
+	textUndoable $a.text -font $font -height 12 -wrap word
+    }
     $sw setwidget $a.text
     $a.text tag configure emphasized -elide 1
     $a.text tag configure nonemphasized -elide 0

Modified: trunk/tkabber/utils.tcl
===================================================================
--- trunk/tkabber/utils.tcl	2006-10-10 07:26:11 UTC (rev 755)
+++ trunk/tkabber/utils.tcl	2006-10-10 19:29:22 UTC (rev 756)
@@ -258,27 +258,60 @@
 	 }"
 }
 
-proc Spinbox {path from to incr textvar} {
-    
-    if {[info tclversion] >= 8.4} {
+###########################################################################
+
+if {[info tclversion] >= 8.4} {
+    # Tk 8.4 or newer
+
+    proc Spinbox {path from to incr textvar} {
 	return [spinbox $path -from $from -to $to -increment $incr \
 		    -buttoncursor left_ptr \
 		    -textvariable $textvar]
-    } else {
+    }
+
+    proc textUndoable {path args} {
+	eval {text $path -undo 1} $args
+	bind $path <Key-space> +[list %W edit separator]
+	hook::run text_on_create_hook $path
+	return $path
+    }
+
+    # There is an evil bug in Tk, which does not allow inserting symbols
+    # using XIM if more than one bound script uses %A.
+    # See http://sourceforge.net/tracker/index.php?func=detail&aid=1373712&group_id=12997&atid=112997
+    # Workaround overwrites existiong binding and uses hook to
+    # simulate event with %A substituted.
+    # Usage example see in plugins/unix/ispell.tcl.
+    proc text_on_keypress {path sym} {
+	tk::TextInsert $path $sym
+	hook::run text_on_keypress_hook $path $sym
+    }
+
+    bind Text <Key> {text_on_keypress %W %A}
+} else {
+    # Tk 8.3
+    
+    proc Spinbox {path from to incr textvar} {
 	return [SpinBox $path -range [list $from $to $incr] \
 			-textvariable $textvar]
     }
-}
 
-proc textUndoable {path args} {
-    if {![catch {eval {text $path -undo 1} $args} res]} {
-	bind $path <Key-space> +[list %W edit separator]
-	return $res
-    } else {
-	return [eval {text $path} $args]
+    proc textUndoable {path args} {
+	eval {text $path} $args
+	hook::run text_on_create_hook $path
+	return $path
     }
+
+    proc text_on_keypress {path sym} {
+	tkTextInsert $path $sym
+	hook::run text_on_keypress_hook $path $sym
+    }
+
+    bind Text <Key> {text_on_keypress %W %A}
 }
 
+###########################################################################
+
 proc focus_next {path fr} {
     focus [Widget::focusNext $path]
     set widget [focus]



More information about the Tkabber-dev mailing list