From e4b53b22228d935847b72e8f9ab0f49a15b54215 Mon Sep 17 00:00:00 2001 From: matz Date: Tue, 1 Feb 2000 03:12:21 +0000 Subject: 2000-02-01 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@611 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/tk/lib/tk.rb | 62 +++++++++++++++++++++++++++++++++++++-------------- ext/tk/lib/tkentry.rb | 8 ++----- 2 files changed, 47 insertions(+), 23 deletions(-) (limited to 'ext/tk') diff --git a/ext/tk/lib/tk.rb b/ext/tk/lib/tk.rb index 931cb90819..c344a2bf8e 100644 --- a/ext/tk/lib/tk.rb +++ b/ext/tk/lib/tk.rb @@ -196,7 +196,9 @@ module TkComm def _get_eval_string(str) return nil if str == None - if str.kind_of?(Hash) + if str.kind_of?(String) + # do nothing + elsif str.kind_of?(Hash) str = hash_kv(str).join(" ") elsif str.kind_of?(Array) str = array2tk_list(str) @@ -417,11 +419,11 @@ module TkCore INTERP._invoke("proc", "rb_out", "args", "if {[set st [catch {ruby [format \"TkCore.callback %%Q!%s!\" $args]} ret]] != 0} {if {[regsub -all {!} $args {\\!} newargs] == 0} {return -code $st $ret} {if {[set st [catch {ruby [format \"TkCore.callback %%Q!%s!\" $newargs]} ret]] != 0} {return -code $st $ret} {return $ret}}} {return $ret}") def callback_break - raise TkCallbackBreak, "Tk callback returns 'break' status" + fail TkCallbackBreak, "Tk callback returns 'break' status" end def callback_continue - raise TkCallbackContinue, "Tk callback returns 'continue' status" + fail TkCallbackContinue, "Tk callback returns 'continue' status" end def after(ms, cmd=Proc.new) @@ -527,8 +529,8 @@ module TkCore args.unshift "unknown" res = INTERP._invoke(*args) rescue - raise unless /^invalid command/ =~ $! - raise err + fail unless /^invalid command/ =~ $! + fail err end end if INTERP._return_value() != 0 @@ -583,6 +585,32 @@ module Tk def yscrollcommand(cmd=Proc.new) configure_cmd 'yscrollcommand', cmd end + def xview(*index) + v = tk_send('xview', *index) + list(v) if index.size == 0 + end + def yview(*index) + v = tk_send('yview', *index) + list(v) if index.size == 0 + end + def xscrollbar(bar=nil) + if bar + @xscrollbar = bar + @xscrollbar.orient 'horizontal' + self.xscrollcommand {|arg| @xscrollbar.set *arg} + @xscrollbar.command {|arg| self.xview *arg} + end + @xscrollbar + end + def yscrollbar(bar=nil) + if bar + @yscrollbar = bar + @yscrollbar.orient 'vertical' + self.yscrollcommand {|arg| @yscrollbar.set *arg} + @yscrollbar.command {|arg| self.yview *arg} + end + @yscrollbar + end end module Wm @@ -784,7 +812,7 @@ class TkVariable INTERP._eval(format('global %s; set %s', @id, @id)) rescue if INTERP._eval(format('global %s; array exists %s', @id, @id)) != "1" - raise + fail else Hash[*tk_split_simplelist(INTERP._eval(format('global %s; array get %s', @id, @id)))] @@ -798,7 +826,7 @@ class TkVariable INTERP._eval(format('global %s; set %s %s', @id, @id, s)) rescue if INTERP._eval(format('global %s; array exists %s', @id, @id)) != "1" - raise + fail else if val == [] INTERP._eval(format('global %s; unset %s; set %s(0) 0; unset %s(0)', @@ -815,7 +843,7 @@ class TkVariable INTERP._eval(format('global %s; unset %s; array set %s %s', @id, @id, @id, s)) else - raise + fail end end end @@ -2149,7 +2177,7 @@ end class TkTextWin