@@ -311,7 +311,7 @@ def initialize(seq,b,f,h,k,s,t,w,x,y,aa,ee,kk,nn,ww,tt,xx,yy)
311
311
312
312
def install_bind ( cmd , args = nil )
313
313
if args
314
- id = install_cmd ( proc { |arg |
314
+ id = install_cmd ( proc { |* arg |
315
315
TkUtil . eval_cmd cmd , *arg
316
316
} )
317
317
id + " " + args
@@ -784,6 +784,96 @@ def withdraw
784
784
end
785
785
end
786
786
787
+ ###########################################
788
+ # convert kanji string to/from utf-8
789
+ ###########################################
790
+ if /^8\. [1-9]/ =~ Tk ::TCL_VERSION && !Tk ::JAPANIZED_TK
791
+ class TclTkIp
792
+ # from tkencoding.rb by ttate@jaist.ac.jp
793
+ alias __eval _eval
794
+ alias __invoke _invoke
795
+ private :__eval
796
+ private :__invoke
797
+
798
+ attr_accessor :encoding
799
+
800
+ def _eval ( cmd )
801
+ if @encoding
802
+ _fromUTF8 ( __eval ( _toUTF8 ( cmd , @encoding ) ) , @encoding )
803
+ else
804
+ __eval ( cmd )
805
+ end
806
+ end
807
+
808
+ def _invoke ( *cmds )
809
+ if @encoding
810
+ cmds = cmds . collect { |cmd | _toUTF8 ( cmd , @encoding ) }
811
+ _fromUTF8 ( __invoke ( *cmds ) , @encoding )
812
+ else
813
+ __invoke ( *cmds )
814
+ end
815
+ end
816
+ end
817
+
818
+ module Tk
819
+ def encoding = ( name )
820
+ INTERP . encoding = name
821
+ end
822
+
823
+ def encoding
824
+ INTERP . encoding
825
+ end
826
+
827
+ def encoding_names
828
+ tk_split_simplelist ( tk_call ( 'encoding' , 'names' ) )
829
+ end
830
+
831
+ def encoding_system
832
+ tk_call ( 'encoding' , 'system' )
833
+ end
834
+
835
+ def encoding_system = ( enc )
836
+ tk_call ( 'encoding' , 'system' , enc )
837
+ end
838
+ end
839
+
840
+ # estimate encoding
841
+ case $KCODE
842
+ when /^e/i # EUC
843
+ Tk . encoding = 'euc-jp'
844
+ when /^s/i # SJIS
845
+ Tk . encoding = 'shiftjis'
846
+ when /^u/i # UTF8
847
+ Tk . encoding = 'utf-8'
848
+ else # NONE
849
+ begin
850
+ Tk . encoding = Tk . encoding_system
851
+ rescue StandardError , NameError
852
+ Tk . encoding = 'utf-8'
853
+ end
854
+ end
855
+
856
+ else
857
+ # dummy methods
858
+ module Tk
859
+ def encoding = ( name )
860
+ nil
861
+ end
862
+ def encoding
863
+ nil
864
+ end
865
+ def encoding_names
866
+ nil
867
+ end
868
+ def encoding_system
869
+ nil
870
+ end
871
+ def encoding_system = ( enc )
872
+ nil
873
+ end
874
+ end
875
+ end
876
+
787
877
module TkBindCore
788
878
def bind ( context , cmd = Proc . new , args = nil )
789
879
Tk . bind ( to_eval , context , cmd , args )
0 commit comments