summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
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 362d13f8d06..1a6d16a6da8 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 8a772f5ddac..5d1d68d902c 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