[Tkabber-dev] r867 - in trunk/tkabber-plugins: . cyrillize

tkabber-svn at jabber.ru tkabber-svn at jabber.ru
Thu Jan 11 15:13:33 MSK 2007


Author: sergei
Date: 2007-01-11 15:13:29 +0300 (Thu, 11 Jan 2007)
New Revision: 867

Modified:
   trunk/tkabber-plugins/ChangeLog
   trunk/tkabber-plugins/cyrillize/cyrillize.tcl
   trunk/tkabber-plugins/cyrillize/engrus.tbl
Log:
	* cyrillize/cyrillize.tcl: Added backward conversion from russian
	  to english (bound to <Control-quotedbl>).


Modified: trunk/tkabber-plugins/ChangeLog
===================================================================
--- trunk/tkabber-plugins/ChangeLog	2007-01-08 14:20:37 UTC (rev 866)
+++ trunk/tkabber-plugins/ChangeLog	2007-01-11 12:13:29 UTC (rev 867)
@@ -1,3 +1,8 @@
+2006-01-11  Sergei Golovan <sgolovan at nes.ru>
+
+	* cyrillize/cyrillize.tcl: Added backward conversion from russian
+	  to english (bound to <Control-quotedbl>).
+
 2006-01-06  Sergei Golovan <sgolovan at nes.ru>
 
 	* debug/debug.tcl, traffic/traffic.tcl: Changed config directory

Modified: trunk/tkabber-plugins/cyrillize/cyrillize.tcl
===================================================================
--- trunk/tkabber-plugins/cyrillize/cyrillize.tcl	2007-01-08 14:20:37 UTC (rev 866)
+++ trunk/tkabber-plugins/cyrillize/cyrillize.tcl	2007-01-11 12:13:29 UTC (rev 867)
@@ -4,16 +4,17 @@
 }
 
 proc cyrillize::load_table {} {
-    variable engrus
+    variable convert
 
     set f [file join [file dirname [info script]] engrus.tbl]
     set fd [open $f]
     fconfigure $fd -encoding koi8-r
-    set engrus_table [read $fd]
+    set convert_table [read $fd]
     close $fd
 
-    foreach {f t} $engrus_table {
-	set engrus($f) $t
+    foreach {f t} $convert_table {
+	set convert(eng,rus,$f) $t
+	set convert(rus,eng,$t) $f
     }
 }
 
@@ -21,15 +22,15 @@
 
 #puts [array get cyrillize::engrus]
 
-proc cyrillize::do {s} {
-    variable engrus
+proc cyrillize::do {s from to} {
+    variable convert
 
     set res ""
     foreach c [split $s ""] {
-	if {[info exists engrus($c)]} {
-	    append res $engrus($c)
-	} elseif {[info exists engrus([string tolower $c])]} {
-	    append res [string toupper $engrus([string tolower $c])]
+	if {[info exists convert($from,$to,$c)]} {
+	    append res $convert($from,$to,$c)
+	} elseif {[info exists convert($from,$to,[string tolower $c])]} {
+	    append res [string toupper $convert($from,$to,[string tolower $c])]
 	} else {
 	    append res $c
 	}
@@ -39,7 +40,7 @@
 
 #puts [cyrillize::do Ghbdtn]
 
-proc cyrillize::word {iw} {
+proc cyrillize::word {iw from to} {
     set ins [lindex [split [$iw index insert] .] 1]
     set line [$iw get "insert linestart" "insert lineend"]
     set wordstart [string wordstart $line [expr $ins - 1]]
@@ -47,20 +48,24 @@
 			      [crange $line 0 [expr $wordstart - 1]]]]
     set word [crange $line $wordstart [expr $ins - 1]]
 
-    set newword [do $word]
+    set newword [do $word $from $to]
     $iw delete "insert linestart +$wordstart chars" insert
     $iw insert insert $newword
 
     $iw mark set insert "insert linestart +$wordend chars"
 }
 
+event add <<Cyrillize-Eng-Rus>> <Control-quoteright>
+event add <<Cyrillize-Rus-Eng>> <Control-quotedbl>
+
 proc cyrillize::setup_bindings {chatid type} {
     variable history
 
     set iw [chat::input_win $chatid]
-    bind $iw <Control-quoteright> \
-	[list [namespace current]::word $iw]
-    bind $iw <Control-quoteright> +break
+    bind $iw <<Cyrillize-Eng-Rus>> [list [namespace current]::word $iw eng rus]
+    bind $iw <<Cyrillize-Eng-Rus>> +break
+    bind $iw <<Cyrillize-Rus-Eng>> [list [namespace current]::word $iw rus eng]
+    bind $iw <<Cyrillize-Rus-Eng>> +break
 }
 
 hook::add open_chat_post_hook [namespace current]::cyrillize::setup_bindings

Modified: trunk/tkabber-plugins/cyrillize/engrus.tbl
===================================================================
--- trunk/tkabber-plugins/cyrillize/engrus.tbl	2007-01-08 14:20:37 UTC (rev 866)
+++ trunk/tkabber-plugins/cyrillize/engrus.tbl	2007-01-11 12:13:29 UTC (rev 867)
@@ -33,6 +33,10 @@
 n   Ô
 m   Ø
 ,   Â
+<   â
 .   À
+>   à
 `   £
 ~   ³
+?   ,
+/   .



More information about the Tkabber-dev mailing list