mirror of
https://github.com/ruby/ruby.git
synced 2025-08-24 13:34:17 +02:00

avoid SEGV trouble. * ext/tk/tkutil/tkutil.c; fix a bug on converting a SJIS string array to a Tcl's list string. * ext/tk/tcltklib.c: wrap Tcl's original "namespace" command to protect from namespace crash. * ext/tk/lib/multi-tk.rb: enforce exception-handling. * ext/tk/lib/multi-tk.rb: catch IRB_EXIT to work on irb. * ext/tk/lib/tk.rb: ditto. * ext/tk/tcltklib.c: add TclTkLib.mainloop_thread? * ext/tk/lib/multi-tk.rb: (bug fix) callback returns a value. * ext/tk/lib/tk/canvas.rb (delete): bug fix when multiple arguments. * ext/tk/lib/clock.rb: fix 'no method error'. * ext/tk/lib/clock.rb (self.clicks): accept a Symbol argument. * ext/tk/lib/variable.rb: be able to set default_value_type; :numeric, :bool, :string, :symbol, :list, :numlist or nil (default; same to :string). If set a type, TkVariable#value returns a value of the type. * ext/tk/lib/tkextlib/tclx/tclx.rb: add Tk::TclX.signal to warn the risk of using TclX extension's 'signal' command. * ext/tk/sample/irbtk.rb: irb with Ruby/Tk. * ext/tk/sample/demos-*/anilabel.rb: bug fix on 'show code' * ext/tk/sample/demos-*/aniwave.rb: new Ruby/Tk animation demo. * ext/tk/sample/demos-*/pendulum.rb: ditto. * ext/tk/sample/demos-*/goldberg.rb: ditto. * ext/tk/sample/demos-*/widget: add entries of animation demos. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8046 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
71 lines
1.6 KiB
Ruby
71 lines
1.6 KiB
Ruby
#
|
|
# tk/clock.rb : methods for clock command
|
|
#
|
|
require 'tk'
|
|
|
|
module Tk
|
|
module Clock
|
|
include Tk
|
|
extend TkCore
|
|
|
|
def self.add(clk, *args)
|
|
tk_call_without_enc('clock','add', clk, *args).to_i
|
|
end
|
|
|
|
def self.clicks(ms=nil)
|
|
ms = ms.to_s if ms.kind_of?(Symbol)
|
|
case ms
|
|
when nil, ''
|
|
tk_call_without_enc('clock','clicks').to_i
|
|
when /^mic/
|
|
tk_call_without_enc('clock','clicks','-microseconds').to_i
|
|
when /^mil/
|
|
tk_call_without_enc('clock','clicks','-milliseconds').to_i
|
|
else
|
|
tk_call_without_enc('clock','clicks','-milliseconds').to_i
|
|
end
|
|
end
|
|
|
|
def self.format(clk, form=nil)
|
|
if form
|
|
tk_call('clock','format',clk,'-format',form)
|
|
else
|
|
tk_call('clock','format',clk)
|
|
end
|
|
end
|
|
|
|
def self.formatGMT(clk, form=nil)
|
|
if form
|
|
tk_call('clock','format',clk,'-format',form,'-gmt','1')
|
|
else
|
|
tk_call('clock','format',clk,'-gmt','1')
|
|
end
|
|
end
|
|
|
|
def self.scan(str, base=nil)
|
|
if base
|
|
tk_call('clock','scan',str,'-base',base).to_i
|
|
else
|
|
tk_call('clock','scan',str).to_i
|
|
end
|
|
end
|
|
|
|
def self.scanGMT(str, base=nil)
|
|
if base
|
|
tk_call('clock','scan',str,'-base',base,'-gmt','1').to_i
|
|
else
|
|
tk_call('clock','scan',str,'-gmt','1').to_i
|
|
end
|
|
end
|
|
|
|
def self.seconds
|
|
tk_call_without_enc('clock','seconds').to_i
|
|
end
|
|
def self.milliseconds
|
|
tk_call_without_enc('clock','milliseconds').to_i
|
|
end
|
|
def self.microseconds
|
|
tk_call_without_enc('clock','microseconds').to_i
|
|
end
|
|
end
|
|
end
|