summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1998-06-19 09:32:13 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1998-06-19 09:32:13 +0000
commitf9747b7a571556b6b8add7cfd4e324ad316d50b3 (patch)
tree3971f82312c9b748dcf763fd24e91489657fb36c /lib
parent992923053cfb51dc04c6a7ee07ca6fff1b61d1a5 (diff)
1.1b9_27
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/v1_1r@246 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r--lib/cgi-lib.rb2
-rw-r--r--lib/tk.rb82
2 files changed, 51 insertions, 33 deletions
diff --git a/lib/cgi-lib.rb b/lib/cgi-lib.rb
index 362d13f8d0..1a6d16a6da 100644
--- a/lib/cgi-lib.rb
+++ b/lib/cgi-lib.rb
@@ -81,7 +81,7 @@ class CGI < SimpleDelegator
end
def CGI.error
- m = $!.dup
+ m = $!.to_s.dup
m.gsub!(/&/, '&amp;')
m.gsub!(/</, '&lt;')
m.gsub!(/>/, '&gt;')
diff --git a/lib/tk.rb b/lib/tk.rb
index 8a772f5dda..5d1d68d902 100644
--- a/lib/tk.rb
+++ b/lib/tk.rb
@@ -142,6 +142,29 @@ module TkComm
end
private :bool, :number, :string, :list, :window, :procedure
+ def _get_eval_string(str)
+ return nil if str == None
+ if str.kind_of?(Hash)
+ str = hash_kv(str).join(" ")
+ elsif str.kind_of?(Array)
+ str = array2tk_list(str)
+ elsif str.kind_of?(Proc)
+ str = install_cmd(str)
+ elsif str == nil
+ str = ""
+ elsif str == false
+ str = "0"
+ elsif str == true
+ str = "1"
+ elsif (str.respond_to?(:to_eval))
+ str = str.to_eval()
+ else
+ str = str.to_s()
+ end
+ return str
+ end
+ private :_get_eval_string
+
Tk_IDs = [0] # [0]-cmdid, [1]-winid
def _curr_cmd_id
id = format("c%.4d", Tk_IDs[0])
@@ -262,12 +285,26 @@ module TkComm
end
def after(ms, cmd=Proc.new)
- myid = _curr_cmd_id
- tk_call 'after', ms,
- install_cmd(proc{
- TkUtil.eval_cmd cmd
- uninstall_cmd myid
- })
+ myid = _curr_cmd_id
+ INTERP._eval('after '+ms+' '+_get_eval_string(install_cmd(proc{
+ TkUtil.eval_cmd cmd
+ uninstall_cmd myid
+ })))
+ return
+ if false #defined? Thread
+ Thread.start do
+ ms = Float(ms)/1000
+ ms = 10 if ms == 0
+ sleep ms/1000
+ cmd.call
+ end
+ else
+ myid = _curr_cmd_id
+ INTERP._eval('after '+ms+' '+_get_eval_string(install_cmd(proc{
+ TkUtil.eval_cmd cmd
+ uninstall_cmd myid
+ })))
+ end
end
def update(idle=nil)
@@ -296,28 +333,6 @@ module TkCore
TclTkLib.mainloop
end
- def _get_eval_string(str)
- return nil if str == None
- if str.kind_of?(Hash)
- str = hash_kv(str).join(" ")
- elsif str.kind_of?(Array)
- str = array2tk_list(str)
- elsif str.kind_of?(Proc)
- str = install_cmd(v)
- elsif str == nil
- str = ""
- elsif str == false
- str = "0"
- elsif str == true
- str = "1"
- elsif (str.respond_to?(:to_eval))
- str = str.to_eval()
- else
- str = str.to_s()
- end
- return str
- end
-
def tk_call(*args)
print args.join(" "), "\n" if $DEBUG
args.filter {|x|_get_eval_string(x)}
@@ -981,11 +996,14 @@ class TkObject<TkKernel
private :tk_send
def method_missing(id, *args)
- if (args.length == 1)
- configure id.id2name, args[0]
+ name = id.id2name
+ case args.length
+ when 1
+ configure name, args[0]
+ when 0
+ fail NameError, "undefined local variable or method `#{name}' for #{self.to_s}", error_at
else
- $@ = error_at
- super
+ fail NameError, "undefined method `#{name}' for #{self.to_s}", error_at
end
end