[Tkabber-dev] r1938 - in trunk/tkabber: . plugins/general

tkabber-svn at jabber.ru tkabber-svn at jabber.ru
Wed Sep 1 09:38:08 MSD 2010


Author: sergei
Date: 2010-09-01 09:38:08 +0400 (Wed, 01 Sep 2010)
New Revision: 1938

Modified:
   trunk/tkabber/ChangeLog
   trunk/tkabber/plugins/general/ispell.tcl
   trunk/tkabber/utils.tcl
Log:
	* utils.tcl, plugins/general/ispell.tcl: Created new hook for text
	  popup menus, moved spelling suggestions to the popup submenu
	  (thanks to Vitaly Takmazov).


Modified: trunk/tkabber/ChangeLog
===================================================================
--- trunk/tkabber/ChangeLog	2010-05-25 12:18:32 UTC (rev 1937)
+++ trunk/tkabber/ChangeLog	2010-09-01 05:38:08 UTC (rev 1938)
@@ -1,3 +1,9 @@
+2010-09-01  Sergei Golovan  <sgolovan at nes.ru>
+
+	* utils.tcl, plugins/general/ispell.tcl: Created new hook for text
+	  popup menus, moved spelling suggestions to the popup submenu
+	  (thanks to Vitaly Takmazov).
+
 2010-05-25  Sergei Golovan  <sgolovan at nes.ru>
 
 	* plugins/general/remote.tcl: Do not store service messages (with an

Modified: trunk/tkabber/plugins/general/ispell.tcl
===================================================================
--- trunk/tkabber/plugins/general/ispell.tcl	2010-05-25 12:18:32 UTC (rev 1937)
+++ trunk/tkabber/plugins/general/ispell.tcl	2010-09-01 05:38:08 UTC (rev 1938)
@@ -267,7 +267,7 @@
 
 #############################################################################
 
-proc ispell::popup_menu {iw x y} {
+proc ispell::popup_menu {m iw x y} {
     variable response
 
     set ind [$iw index @$x,$y]
@@ -280,28 +280,28 @@
     if {[catch { string trim $response } r]} {
 	return
     }
-    if {[winfo exists [set m .ispellpopupmenu]]} {
-	destroy $m
+    if {[winfo exists [set im $m.ispellpopupmenu]]} {
+	destroy $im
     }
+    menu $im -tearoff 0
+
     switch -- [string index $r 0] {
 	\& -
 	\? {
 	    regsub -all {: } $r {:} r
 	    regsub -all {, } $r {,} r
 	    set variants [split [lindex [split $r ":"] 1] ","]
-	    menu $m -tearoff 0
 	    foreach var $variants {
-		$m add command -label "$var" \
+		$im add command -label "$var" \
 		    -command [list [namespace current]::substitute $iw \
 				   $l.$wordstart $l.[expr {$wordend + 1}] \
 				   $var]
 	    }
-	    tk_popup $m [winfo pointerx .] [winfo pointery .]
+	    $m add cascade -menu $im -label [::msgcat::mc "Spelling"]
 	}
 	\# {
-	    menu $m -tearoff 0
-	    $m add command -label [::msgcat::mc "- nothing -"] -command {}
-	    tk_popup $m [winfo pointerx .] [winfo pointery .]
+	    $im add command -label [::msgcat::mc "- nothing -"] -command {}
+	    $m add cascade -menu $im -label [::msgcat::mc "Spelling"]
 	}
 	default {}
     }
@@ -349,7 +349,7 @@
     clear_ispell $iw
     bind $iw <KeyPress> [list [namespace current]::key_process %W %N]
     bind $iw <Return> +[list [namespace current]::clear_ispell %W]
-    bind $iw <3> [list [namespace current]::popup_menu %W %x %y]
+    hook::add textinput_popup_menu_hook [namespace current]::popup_menu
     $iw tag configure err -foreground [option get $iw errorColor Text]
     $iw tag configure combo -foreground [option get $iw comboColor Text]
 }

Modified: trunk/tkabber/utils.tcl
===================================================================
--- trunk/tkabber/utils.tcl	2010-05-25 12:18:32 UTC (rev 1937)
+++ trunk/tkabber/utils.tcl	2010-09-01 05:38:08 UTC (rev 1938)
@@ -259,6 +259,7 @@
     proc textUndoable {path args} {
 	eval {text $path -undo 1} $args
 	bind $path <Key-space> +[list %W edit separator]
+	bind $path <3> [list text_context_menu %W %X %Y %x %y]
 	hook::run text_on_create_hook $path
 	return $path
     }
@@ -287,6 +288,7 @@
 
     proc textUndoable {path args} {
 	eval {text $path} $args
+	bind $path <3> [list text_context_menu %W %X %Y %x %y]
 	hook::run text_on_create_hook $path
 	return $path
     }
@@ -299,6 +301,27 @@
     bind Text <Key> {text_on_keypress %W %A}
 }
 
+proc text_context_menu {W X Y x y} {
+    set m .input_popup
+    if {[winfo exists $m]} {
+	destroy $m
+    }
+
+    menu $m -tearoff 0
+    hook::run textinput_popup_menu_hook $m $W $x $y
+    
+    tk_popup $m $X $Y
+    
+}
+
+proc text_add_copypaste_to_menu {m w x y} {
+    $m add command -label [::msgcat::mc "Cut"] -command [list event generate $w <<Cut>>] -accelerator Ctrl-X
+    $m add command -label [::msgcat::mc "Copy"] -command [list event generate $w <<Copy>>] -accelerator Ctrl-C
+    $m add command -label [::msgcat::mc "Paste"] -command [list event generate $w <<Paste>>] -accelerator Ctrl-V
+}
+
+hook::add textinput_popup_menu_hook text_add_copypaste_to_menu 30
+
 ###########################################################################
 
 proc focus_next {path fr} {



More information about the Tkabber-dev mailing list