diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-03-30 15:00:12 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-03-30 15:00:12 +0000 |
commit | 72fdc42837649c8fd2988e7712749ca6d30c246b (patch) | |
tree | 3771797df1d09540f20d74f55086885490e6a439 /ext | |
parent | 8c20f66c485649560ed6082233dbe03cdcdaf7a3 (diff) | |
download | ruby-72fdc42837649c8fd2988e7712749ca6d30c246b.tar.gz ruby-72fdc42837649c8fd2988e7712749ca6d30c246b.tar.xz ruby-72fdc42837649c8fd2988e7712749ca6d30c246b.zip |
revert git backfire in r15860; sorry
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@15861 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-rw-r--r-- | ext/tk/sample/encstr_usage.rb | 5 | ||||
-rw-r--r-- | ext/tk/sample/irbtkw.rbw | 24 | ||||
-rw-r--r-- | ext/tk/sample/tkrttimer.rb | 13 | ||||
-rw-r--r-- | ext/tk/stubs.c | 64 |
4 files changed, 98 insertions, 8 deletions
diff --git a/ext/tk/sample/encstr_usage.rb b/ext/tk/sample/encstr_usage.rb index 4285ec861..b22c2504a 100644 --- a/ext/tk/sample/encstr_usage.rb +++ b/ext/tk/sample/encstr_usage.rb @@ -11,7 +11,7 @@ t1 = TkText.new(:height=>5).pack t2 = TkText.new(:height=>5).pack t3 = TkText.new(:height=>5).pack -src_str = IO.readlines('iso2022-kr.txt').join +src_str = IO.readlines(File.join(File.dirname(__FILE__),'iso2022-kr.txt')).join t1.insert('end', "use neither Tk::EncodedString class nor Tk.encoding= method\n\n") @@ -23,7 +23,8 @@ t2.insert('end', t2.insert('end', enc_str) Tk.encoding = 'iso2022-kr' -t3.insert('end', "use Tk.encoding = 'iso2022-kr'\n\n") +t3.insert('end', "use Tk.encoding = 'iso2022-kr' (Tk.force_default_encoding? == #{Tk.force_default_encoding?})\n\n") + t3.insert('end', src_str) Tk.mainloop diff --git a/ext/tk/sample/irbtkw.rbw b/ext/tk/sample/irbtkw.rbw index f6a35be6e..3fb6dde62 100644 --- a/ext/tk/sample/irbtkw.rbw +++ b/ext/tk/sample/irbtkw.rbw @@ -4,7 +4,7 @@ # # by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) # -release = '2006/11/06' +release = '2008/03/08' require 'tk' begin @@ -15,10 +15,32 @@ end require 'irb' +if TkCore::WITH_ENCODING +else + # $KCODE setup + case Tk.encoding + when 'shiftjis', 'cp932' + $KCODE='SJIS' + when 'euc-jp' + $KCODE='EUC' + when 'utf-8', 'unicode' + $KCODE='UTF8' + else + # unknown + end +end + # console setup top = TkToplevel.new(:title=>'IRB console') top.protocol(:WM_DELETE_WINDOW){ Tk.exit } +case (Tk.windowingsystem) +when 'win32' + fnt = ['MS Gothic', '-12'] +else + fnt = ['courier', '-12'] +end + console = TkTextIO.new(top, :mode=>:console, :width=>80).pack(:side=>:left, :expand=>true, :fill=>:both) diff --git a/ext/tk/sample/tkrttimer.rb b/ext/tk/sample/tkrttimer.rb index 531f4a8d5..0abd4ecbd 100644 --- a/ext/tk/sample/tkrttimer.rb +++ b/ext/tk/sample/tkrttimer.rb @@ -17,8 +17,17 @@ TkLabel.new(f2, :text=>'use TkRTTimer class').pack label2 = TkLabel.new(:parent=>f2, :relief=>:raised, :width=>10).pack(:fill=>:both) -TkLabel.new(:text=>'Interval setting of each timer is 10 ms.', - :padx=>10, :pady=>5).pack +TkLabel.new(:padx=>10, :pady=>5, :justify=>'left', :text=><<EOT).pack +Interval setting of each timer object is 10 ms. +Each timer object counts up the value on each callback +(the value is not the clock data). +The count of the TkTimer object is delayed by execution +time of callbacks and inaccuracy of interval. +On the other hand, the count of the TkRTTimer object is +not delayed. Its callback interval is not accurate too. +But it can compute error correction about the time when +a callback should start. +EOT # define the procedure repeated by the TkTimer object tick = proc{|aobj| #<== TkTimer object diff --git a/ext/tk/stubs.c b/ext/tk/stubs.c index d0aaf61f3..6d3b330f0 100644 --- a/ext/tk/stubs.c +++ b/ext/tk/stubs.c @@ -1,5 +1,11 @@ +/************************************************ + + stubs.c - Tcl/Tk stubs support + +************************************************/ + +#include "ruby.h" #include "stubs.h" -#include "ruby/ruby.h" #include <tcl.h> #include <tk.h> @@ -86,7 +92,12 @@ static DL_HANDLE tcl_dll = (DL_HANDLE)0; static DL_HANDLE tk_dll = (DL_HANDLE)0; int +#ifdef RUBY_VM ruby_open_tcl_dll(char *appname) +#else +ruby_open_tcl_dll(appname) + char *appname; +#endif { void (*p_Tcl_FindExecutable)(const char *); int n; @@ -168,7 +179,12 @@ ruby_open_tk_dll() } int +#ifdef RUBY_VM ruby_open_tcltk_dll(char *appname) +#else +ruby_open_tcltk_dll(appname) + char *appname; +#endif { return( ruby_open_tcl_dll(appname) || ruby_open_tk_dll() ); } @@ -187,7 +203,12 @@ tk_stubs_init_p() Tcl_Interp * +#ifdef RUBY_VM ruby_tcl_create_ip_and_stubs_init(int *st) +#else +ruby_tcl_create_ip_and_stubs_init(st) + int *st; +#endif { Tcl_Interp *tcl_ip; @@ -269,7 +290,12 @@ ruby_tcl_stubs_init() } int +#ifdef RUBY_VM ruby_tk_stubs_init(Tcl_Interp *tcl_ip) +#else +ruby_tk_stubs_init(tcl_ip) + Tcl_Interp *tcl_ip; +#endif { Tcl_ResetResult(tcl_ip); @@ -304,7 +330,12 @@ ruby_tk_stubs_init(Tcl_Interp *tcl_ip) } int +#ifdef RUBY_VM ruby_tk_stubs_safeinit(Tcl_Interp *tcl_ip) +#else +ruby_tk_stubs_safeinit(tcl_ip) + Tcl_Interp *tcl_ip; +#endif { Tcl_ResetResult(tcl_ip); @@ -390,7 +421,12 @@ static int open_tcl_dll = 0; static int call_tk_stubs_init = 0; int +#ifdef RUBY_VM ruby_open_tcl_dll(char *appname) +#else +ruby_open_tcl_dll(appname) + char *appname; +#endif { if (appname) { Tcl_FindExecutable(appname); @@ -402,7 +438,8 @@ ruby_open_tcl_dll(char *appname) return TCLTK_STUBS_OK; } -int ruby_open_tk_dll() +int +ruby_open_tk_dll() { if (!open_tcl_dll) { /* ruby_open_tcl_dll(RSTRING_PTR(rb_argv0)); */ @@ -412,7 +449,13 @@ int ruby_open_tk_dll() return TCLTK_STUBS_OK; } -int ruby_open_tcltk_dll(char *appname) +int +#ifdef RUBY_VM +ruby_open_tcltk_dll(char *appname) +#else +ruby_open_tcltk_dll(appname) + char *appname; +#endif { return( ruby_open_tcl_dll(appname) || ruby_open_tk_dll() ); } @@ -430,7 +473,12 @@ tk_stubs_init_p() } Tcl_Interp * +#ifdef RUBY_VM ruby_tcl_create_ip_and_stubs_init(int *st) +#else +ruby_tcl_create_ip_and_stubs_init(st) + int *st; +#endif { Tcl_Interp *tcl_ip; @@ -458,7 +506,12 @@ ruby_tcl_stubs_init() } int +#ifdef RUBY_VM ruby_tk_stubs_init(Tcl_Interp *tcl_ip) +#else +ruby_tk_stubs_init(tcl_ip) + Tcl_Interp *tcl_ip; +#endif { if (Tk_Init(tcl_ip) == TCL_ERROR) return FAIL_Tk_Init; @@ -474,7 +527,12 @@ ruby_tk_stubs_init(Tcl_Interp *tcl_ip) } int +#ifdef RUBY_VM ruby_tk_stubs_safeinit(Tcl_Interp *tcl_ip) +#else +ruby_tk_stubs_safeinit(tcl_ip) + Tcl_Interp *tcl_ip; +#endif { #if TCL_MAJOR_VERSION >= 8 if (Tk_SafeInit(tcl_ip) == TCL_ERROR) |