[Tkabber-dev] r1450 - in trunk/tkabber-plugins: . unixkeys

tkabber-svn at jabber.ru tkabber-svn at jabber.ru
Sun Jun 8 17:06:15 MSD 2008


Author: sergei
Date: 2008-06-08 17:06:13 +0400 (Sun, 08 Jun 2008)
New Revision: 1450

Modified:
   trunk/tkabber-plugins/ChangeLog
   trunk/tkabber-plugins/unixkeys/README
   trunk/tkabber-plugins/unixkeys/TODO
   trunk/tkabber-plugins/unixkeys/unixkeys.tcl
Log:
	* unixkeys/README, unixkeys/TODO, unixkeys/unixkeys.tcl: Added
	  bindings to entry widgets also (thanks to Konstantin Khomoutov).


Modified: trunk/tkabber-plugins/ChangeLog
===================================================================
--- trunk/tkabber-plugins/ChangeLog	2008-06-05 13:48:38 UTC (rev 1449)
+++ trunk/tkabber-plugins/ChangeLog	2008-06-08 13:06:13 UTC (rev 1450)
@@ -1,3 +1,8 @@
+2008-06-08  Sergei Golovan <sgolovan at nes.ru>
+
+	* unixkeys/README, unixkeys/TODO, unixkeys/unixkeys.tcl: Added
+	  bindings to entry widgets also (thanks to Konstantin Khomoutov).
+
 2008-06-04  Sergei Golovan <sgolovan at nes.ru>
 
 	* receipts/msgs/pl.msg: Updated Polish translation (thanks to Irek

Modified: trunk/tkabber-plugins/unixkeys/README
===================================================================
--- trunk/tkabber-plugins/unixkeys/README	2008-06-05 13:48:38 UTC (rev 1449)
+++ trunk/tkabber-plugins/unixkeys/README	2008-06-08 13:06:13 UTC (rev 1450)
@@ -4,9 +4,9 @@
 
 I. The idea
 
-This plugins adds some Unix-style keybindings to Tk widgets of
-class Text -- those that are used for chat input windows in
-Tkabber.
+This plugins adds some Unix-style keybindings to various widgets
+used to enter text in Tkabber (namely, entry widgets, chat input
+windows, comboboxes etc).
 
 The text "Unix-style" is vague, so more precisely it stands for
 something like "resembles default keybindings of Emacs text
@@ -14,13 +14,13 @@
 be familiar to those using bash and Emacs. See the next section
 for complete listing of keybindings.
 
-
 II. Usage
 
 After this plugin is loaded by Tkabber, the keybindings it
-provides are available in all Tkabber's widgets of type "Text"
-(i.e. all multiline text editing controls).
+provides are available in all controls used to input text
+in Tkabber.
 
+
 The keybindings added are:
 
 * M-a -- move cursor to the start of text.
@@ -38,29 +38,35 @@
 * M-BackSpace, M-d -- delete text from the cursor to the end
                       of the current word.
 
-* C-x C-u -- Undo the last change.
+* C-x C-u -- Undo the last change (in multiline entry widgets).
 
 * C-x h -- Select all text.
 
-Also, on Windows, another keybinding is added:
+Also, on Windows, another keybinding is added to multiline
+entry widgets:
 
 * C-_ (Ctrl-Underscore) -- Undo the last change.
 
-And, finally, one convenience binding is added (this one is
-borrowed from Tk list widget):
+And, finally, two convenience bindings are added to multiline
+entry widgets (they're borrowed from single-line entry and
+listbox Tk widgets):
 
-* C-\ (Ctrl-backslash) -- Select all text.
+* C-/ (Ctrl-slash) -- Select all text.
+* C-\ (Ctrl-backslash) -- Clear selection.
 
 
-Since Tk text widgets already provide some Unix-style bindings,
-we can summarise the "complete Unix-style editing" capabilities
-which those widgets provide in concert with this plugin:
+Since text-oriented Tk widgets already provide some Unix-style
+bindings, we can summarise the complete "Unix-style editing
+capabilities" which those widgets provide in concert with this
+plugin:
 
 * C-f, C-b -- move cursor one character forward/backward.
 
 * M-f, M-b -- move cursor one word forward/backward.
 
-* C-a, C-e -- move cursor to the start/end of the current line.
+* C-a, C-e -- move cursor to the start/end of the current line
+  (in multiline entry widgets) or to the start/end of text
+  (in single-line entry widgets).
 
 * M-a, M-e -- move cursor to the start/end of text.
 
@@ -75,11 +81,14 @@
 * C-u, C-k -- delete text from the cursor to the start/end of
               the current line.
 
-* C-x C-u, C-_, C-z -- Undo the last change.
+* C-x C-u, C-_, C-z -- Undo the last change (only in multiline
+                       entry widgets).
 
-* C-\, C-x h -- Select all text.
+* C-/, C-x h -- Select all text.
 
+* C-\ -- Clear selection.
 
+
 III. Configuration.
 
 No configuration is needed except for one issue explained below.
@@ -111,12 +120,10 @@
 
 IV. Limitations.
 
-The bindings provided work only in multiline edit controls, they
-won't work in one-line edit controls (entry boxes).
-
 The bindings do not match *exactly* the behaviours of software
 they borrow from. For example, M-e in Emacs stands for "end of
-sentence", not "end of text in the buffer" as this plugin does.
+sentence", not "end of text in the buffer" as this plugin does
+for multiline entry widgets.
 
 The plugin requires special tweaking to get M-e working, as
 described above.

Modified: trunk/tkabber-plugins/unixkeys/TODO
===================================================================
--- trunk/tkabber-plugins/unixkeys/TODO	2008-06-05 13:48:38 UTC (rev 1449)
+++ trunk/tkabber-plugins/unixkeys/TODO	2008-06-08 13:06:13 UTC (rev 1450)
@@ -1,7 +1,5 @@
 $Id$
 
-* Should also work in Entry widgets.
+* M-a, M-e in text widgets should move by sentences.
 
-* M-a, M-e should move by sentencies.
-
 # vim:tw=64:noet

Modified: trunk/tkabber-plugins/unixkeys/unixkeys.tcl
===================================================================
--- trunk/tkabber-plugins/unixkeys/unixkeys.tcl	2008-06-05 13:48:38 UTC (rev 1449)
+++ trunk/tkabber-plugins/unixkeys/unixkeys.tcl	2008-06-08 13:06:13 UTC (rev 1450)
@@ -8,27 +8,38 @@
 # See README for usage guidelines.
 # See license.terms for details on usage and distribution.
 
+namespace eval unixkeys {
+    proc BindEntry {event script} {
+	bind Entry   $event $script
+	bind BwEntry $event $script
+    }
 
-namespace eval unixkeys {
     foreach mod {Alt Meta} {
-	bind Text <$mod-a> [bind Text <Control-Key-Home>]
-	bind Text <$mod-e> [bind Text <Control-Key-End>]
+	bind Text <$mod-Key-a> [bind Text <Control-Key-Home>]
+	bind Text <$mod-Key-e> [bind Text <Control-Key-End>]
+	BindEntry <$mod-Key-a> [bind Entry <Key-Home>]
+	BindEntry <$mod-Key-e> [bind Entry <Key-End>]
     }
 
     foreach mod {Alt Meta} {
-	bind Text <$mod-b> [bind Text <Control-Key-Left>]
-	bind Text <$mod-f> [bind Text <Control-Key-Right>]
+	bind Text <$mod-Key-b> [bind Text <Control-Key-Left>]
+	bind Text <$mod-Key-f> [bind Text <Control-Key-Right>]
     }
+    BindEntry <Alt-Key-b> [bind Entry <Meta-Key-b>]
+    BindEntry <Alt-Key-f> [bind Entry <Meta-Key-f>]
 
-    bind Text <Control-u> { %W delete {insert linestart} insert}
+    bind Text  <Control-Key-u> { %W delete {insert linestart} insert}
+    BindEntry <Control-Key-u>  { %W delete 0 insert }
 
     foreach {mod key} {Alt BackSpace Control w} {
-	bind Text <$mod-Key-$key> { %W delete [tk::TextPrevPos %W insert tcl_startOfPreviousWord] insert }
+	bind Text  <$mod-Key-$key> { %W delete [tk::TextPrevPos %W insert tcl_startOfPreviousWord] insert }
+	BindEntry <$mod-Key-$key>  { %W delete [tk::EntryPreviousWord %W insert] insert }
     }
 
     foreach key {d Delete} {
 	foreach mod {Alt Meta} {
-	    bind Text <$mod-Key-$key> { %W delete insert [::tk::TextNextPos %W insert tcl_endOfWord] }
+	    bind Text  <$mod-Key-$key> { %W delete insert [::tk::TextNextPos %W insert tcl_endOfWord] }
+	    BindEntry <$mod-Key-$key>  { %W delete insert [::tk::EntryNextWord %W insert] }
 	}
     }
 
@@ -37,8 +48,10 @@
     }
     event add <<Undo>> <Control-Key-x><Control-Key-u>
 
-    bind Text <Control-backslash> { %W tag add sel 1.0 end }
-    bind Text <Control-Key-x><h> { %W tag add sel 1.0 end }
+    bind Text <Control-slash>     { %W tag add sel 1.0 end }
+    bind Text <Control-backslash> { %W tag remove sel 1.0 end }
+    bind Text <Control-Key-x><h>  { %W tag add sel 1.0 end }
+    BindEntry <Control-Key-x><h>  [bind Entry <Control-slash>]
 }
 
 namespace delete unixkeys



More information about the Tkabber-dev mailing list