mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* ext/tk/lib/tk/text.rb: typo. call a wrong method.
* ext/tk/lib/tk/itemconfig.rb: ditto. * ext/tk/sample/ttk_wrapper.rb: bug fix. * ext/tk/sample/tktextio.rb: add binding for 'Ctrl-u' at console mode. * ext/tk/lib/tk.rb, ext/tk/lib/tk/itemfont.rb, ext/tk/lib/font.rb: support __IGNORE_UNKNOWN_CONFIGURE_OPTION__ about font options. * ext/tk/lib/tkextlib/iwidgets/scrolledcanvas.rb, ext/tk/lib/tkextlib/iwidgets/scrolledlistbox.rb, ext/tk/lib/tkextlib/iwidgets/scrolledtext.rb: bug fix. * ext/tk/lib/tkextlib/tile/tpaned.rb: improve TPaned#add. * ext/tk/lib/tk/timer.rb: add TkTimer#at_end(proc) to register the procedure which called at end of the timer. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@16020 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
15b2474e19
commit
9126130c4a
15 changed files with 161 additions and 39 deletions
22
ChangeLog
22
ChangeLog
|
|
@ -1,3 +1,25 @@
|
|||
Tue Apr 15 00:15:29 2008 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
|
||||
|
||||
* ext/tk/lib/tk/text.rb: typo. call a wrong method.
|
||||
|
||||
* ext/tk/lib/tk/itemconfig.rb: ditto.
|
||||
|
||||
* ext/tk/sample/ttk_wrapper.rb: bug fix.
|
||||
|
||||
* ext/tk/sample/tktextio.rb: add binding for 'Ctrl-u' at console mode.
|
||||
|
||||
* ext/tk/lib/tk.rb, ext/tk/lib/tk/itemfont.rb, ext/tk/lib/font.rb:
|
||||
support __IGNORE_UNKNOWN_CONFIGURE_OPTION__ about font options.
|
||||
|
||||
* ext/tk/lib/tkextlib/iwidgets/scrolledcanvas.rb,
|
||||
ext/tk/lib/tkextlib/iwidgets/scrolledlistbox.rb,
|
||||
ext/tk/lib/tkextlib/iwidgets/scrolledtext.rb: bug fix.
|
||||
|
||||
* ext/tk/lib/tkextlib/tile/tpaned.rb: improve TPaned#add.
|
||||
|
||||
* ext/tk/lib/tk/timer.rb: add TkTimer#at_end(proc) to register the
|
||||
procedure which called at end of the timer.
|
||||
|
||||
Mon Apr 14 19:54:21 2008 Akinori MUSHA <knu@iDaemons.org>
|
||||
|
||||
* array.c (rb_ary_flatten, rb_ary_flatten_bang): Take an optional
|
||||
|
|
|
|||
|
|
@ -3217,7 +3217,13 @@ module TkTreatFont
|
|||
next
|
||||
else
|
||||
fnt = hash_kv(fnt) if fnt.kind_of?(Hash)
|
||||
tk_call(*(__config_cmd << "-#{optkey}" << fnt))
|
||||
begin
|
||||
tk_call(*(__config_cmd << "-#{optkey}" << fnt))
|
||||
rescue => e
|
||||
unless TkConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__
|
||||
fail e
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
next
|
||||
|
|
@ -3271,7 +3277,13 @@ module TkTreatFont
|
|||
fobj = fontobj # create a new TkFont object
|
||||
else
|
||||
ltn = hash_kv(ltn) if ltn.kind_of?(Hash)
|
||||
tk_call(*(__config_cmd << "-#{optkey}" << ltn))
|
||||
begin
|
||||
tk_call(*(__config_cmd << "-#{optkey}" << ltn))
|
||||
rescue => e
|
||||
unless TkConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__
|
||||
fail e
|
||||
end
|
||||
end
|
||||
next
|
||||
end
|
||||
|
||||
|
|
@ -3323,7 +3335,13 @@ module TkTreatFont
|
|||
fobj = fontobj # create a new TkFont object
|
||||
else
|
||||
knj = hash_kv(knj) if knj.kind_of?(Hash)
|
||||
tk_call(*(__config_cmd << "-#{optkey}" << knj))
|
||||
begin
|
||||
tk_call(*(__config_cmd << "-#{optkey}" << knj))
|
||||
rescue => e
|
||||
unless TkConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__
|
||||
fail e
|
||||
end
|
||||
end
|
||||
next
|
||||
end
|
||||
|
||||
|
|
@ -5323,7 +5341,7 @@ TkWidget = TkWindow
|
|||
#Tk.freeze
|
||||
|
||||
module Tk
|
||||
RELEASE_DATE = '2008-04-02'.freeze
|
||||
RELEASE_DATE = '2008-04-13'.freeze
|
||||
|
||||
autoload :AUTO_PATH, 'tk/variable'
|
||||
autoload :TCL_PACKAGE_PATH, 'tk/variable'
|
||||
|
|
|
|||
|
|
@ -1056,7 +1056,13 @@ class TkFont
|
|||
|
||||
keys = _symbolkey2str(args.pop).update(fontslot)
|
||||
args.concat(hash_kv(keys))
|
||||
tk_call(*args)
|
||||
begin
|
||||
tk_call(*args)
|
||||
rescue => e
|
||||
unless TkConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__
|
||||
fail e
|
||||
end
|
||||
end
|
||||
Tk_FontUseTBL.mutex.synchronize{
|
||||
Tk_FontUseTBL[[win, tag, optkey].join(';')] = self
|
||||
}
|
||||
|
|
|
|||
|
|
@ -242,7 +242,7 @@ module TkItemConfigMethod
|
|||
__itemcget_core(tagOrId, option)
|
||||
rescue => e
|
||||
begin
|
||||
__itemconfiginfo_core(tagOrId)
|
||||
__itemcget_core(tagOrId)
|
||||
# not tag error -> option is unknown
|
||||
nil
|
||||
rescue
|
||||
|
|
@ -319,7 +319,8 @@ module TkItemConfigMethod
|
|||
|
||||
def __check_available_itemconfigure_options(tagOrId, keys)
|
||||
id = tagid(tagOrId)
|
||||
availables = self.current_itemconfiginfo(id).keys
|
||||
|
||||
availables = self.__current_itemconfiginfo(id).keys
|
||||
|
||||
# add non-standard keys
|
||||
availables |= __font_optkeys.map{|k|
|
||||
|
|
@ -329,6 +330,7 @@ module TkItemConfigMethod
|
|||
availables |= __item_keyonly_optkeys(id).keys.map{|k| k.to_s}
|
||||
|
||||
keys = _symbolkey2str(keys)
|
||||
|
||||
keys.delete_if{|k, v| !(availables.include?(k))}
|
||||
end
|
||||
|
||||
|
|
@ -340,7 +342,7 @@ module TkItemConfigMethod
|
|||
begin
|
||||
__itemconfigure_core(tagOrId, slot)
|
||||
rescue
|
||||
slot = __check_available_configure_options(tagOrId, slot)
|
||||
slot = __check_available_itemconfigure_options(tagOrId, slot)
|
||||
__itemconfigure_core(tagOrId, slot) unless slot.empty?
|
||||
end
|
||||
else
|
||||
|
|
@ -349,6 +351,7 @@ module TkItemConfigMethod
|
|||
rescue => e
|
||||
begin
|
||||
__itemconfiginfo_core(tagOrId)
|
||||
# not tag error -> option is unknown
|
||||
rescue
|
||||
fail e # tag error
|
||||
end
|
||||
|
|
@ -1125,7 +1128,7 @@ module TkItemConfigMethod
|
|||
end
|
||||
end
|
||||
|
||||
def current_itemconfiginfo(tagOrId, slot = nil)
|
||||
def __current_itemconfiginfo(tagOrId, slot = nil)
|
||||
if TkComm::GET_CONFIGINFO_AS_ARRAY
|
||||
if slot
|
||||
org_slot = slot
|
||||
|
|
@ -1147,6 +1150,7 @@ module TkItemConfigMethod
|
|||
ret[conf[0]] = conf[-1]
|
||||
end
|
||||
}
|
||||
|
||||
ret
|
||||
end
|
||||
else # ! TkComm::GET_CONFIGINFO_AS_ARRAY
|
||||
|
|
@ -1157,4 +1161,8 @@ module TkItemConfigMethod
|
|||
ret
|
||||
end
|
||||
end
|
||||
|
||||
def current_itemconfiginfo(tagOrId, slot = nil)
|
||||
__current_itemconfiginfo(tagOrId, slot)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -94,7 +94,13 @@ module TkTreatItemFont
|
|||
*(__item_config_cmd(tagid(tagOrId)) << {}))
|
||||
next
|
||||
else
|
||||
tk_call(*(__item_config_cmd(tagid(tagOrId)) << "-#{optkey}" << fnt))
|
||||
begin
|
||||
tk_call(*(__item_config_cmd(tagid(tagOrId)) << "-#{optkey}" << fnt))
|
||||
rescue => e
|
||||
unless TkConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__
|
||||
fail e
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
next
|
||||
|
|
@ -147,7 +153,13 @@ module TkTreatItemFont
|
|||
elsif Tk::JAPANIZED_TK
|
||||
fobj = fontobj # create a new TkFont object
|
||||
else
|
||||
tk_call(*(__item_config_cmd(tagid(tagOrId)) << "-#{optkey}" << ltn))
|
||||
begin
|
||||
tk_call(*(__item_config_cmd(tagid(tagOrId)) << "-#{optkey}" << ltn))
|
||||
rescue => e
|
||||
unless TkConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__
|
||||
fail e
|
||||
end
|
||||
end
|
||||
next
|
||||
end
|
||||
|
||||
|
|
@ -198,7 +210,13 @@ module TkTreatItemFont
|
|||
elsif Tk::JAPANIZED_TK
|
||||
fobj = fontobj # create a new TkFont object
|
||||
else
|
||||
tk_call(*(__item_config_cmd(tagid(tagOrId)) << "-#{optkey}" << knj))
|
||||
begin
|
||||
tk_call(*(__item_config_cmd(tagid(tagOrId)) << "-#{optkey}" << knj))
|
||||
rescue => e
|
||||
unless TkConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__
|
||||
fail e
|
||||
end
|
||||
end
|
||||
next
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -36,10 +36,10 @@ module TkTextTagConfig
|
|||
itemconfigure(['tag', tagOrId], slot, value)
|
||||
end
|
||||
def tag_configinfo(tagOrId, slot=nil)
|
||||
itemconfigure(['tag', tagOrId], slot)
|
||||
itemconfiginfo(['tag', tagOrId], slot)
|
||||
end
|
||||
def current_tag_configinfo(tagOrId, slot=nil)
|
||||
itemconfigure(['tag', tagOrId], slot)
|
||||
current_itemconfiginfo(['tag', tagOrId], slot)
|
||||
end
|
||||
|
||||
def window_cget(tagOrId, option)
|
||||
|
|
@ -49,10 +49,10 @@ module TkTextTagConfig
|
|||
itemconfigure(['window', tagOrId], slot, value)
|
||||
end
|
||||
def window_configinfo(tagOrId, slot=nil)
|
||||
itemconfigure(['window', tagOrId], slot)
|
||||
itemconfiginfo(['window', tagOrId], slot)
|
||||
end
|
||||
def current_window_configinfo(tagOrId, slot=nil)
|
||||
itemconfigure(['window', tagOrId], slot)
|
||||
current_itemconfiginfo(['window', tagOrId], slot)
|
||||
end
|
||||
|
||||
private :itemcget, :itemconfigure
|
||||
|
|
|
|||
|
|
@ -111,7 +111,8 @@ class TkTimer
|
|||
if @running == false || @proc_max == 0 || @do_loop == 0
|
||||
Tk_CBTBL.delete(@id) ;# for GC
|
||||
@running = false
|
||||
@wait_var.value = 0
|
||||
# @wait_var.value = 0
|
||||
__at_end__
|
||||
return
|
||||
end
|
||||
if @current_pos >= @proc_max
|
||||
|
|
@ -120,7 +121,8 @@ class TkTimer
|
|||
else
|
||||
Tk_CBTBL.delete(@id) ;# for GC
|
||||
@running = false
|
||||
@wait_var.value = 0
|
||||
# @wait_var.value = 0
|
||||
__at_end__
|
||||
return
|
||||
end
|
||||
end
|
||||
|
|
@ -151,6 +153,8 @@ class TkTimer
|
|||
|
||||
@wait_var = TkVariable.new(0)
|
||||
|
||||
@at_end_proc = nil
|
||||
|
||||
@cb_cmd = TkCore::INTERP.get_cb_entry(self.method(:do_callback))
|
||||
|
||||
@set_next = true
|
||||
|
|
@ -210,6 +214,12 @@ class TkTimer
|
|||
|
||||
attr_accessor :loop_exec
|
||||
|
||||
def __at_end__
|
||||
@at_end_proc.call(self) if @at_end_proc
|
||||
@wait_var.value = 0 # for wait
|
||||
end
|
||||
private :__at_end__
|
||||
|
||||
def cb_call
|
||||
@cb_cmd.call
|
||||
end
|
||||
|
|
@ -427,7 +437,8 @@ class TkTimer
|
|||
|
||||
def cancel
|
||||
@running = false
|
||||
@wait_var.value = 0
|
||||
# @wait_var.value = 0
|
||||
__at_end__
|
||||
tk_call 'after', 'cancel', @after_id if @after_id
|
||||
@after_id = nil
|
||||
|
||||
|
|
@ -471,6 +482,21 @@ class TkTimer
|
|||
end
|
||||
end
|
||||
|
||||
def at_end(*arg, &b)
|
||||
if arg.empty?
|
||||
if b
|
||||
@at_end_proc = b
|
||||
else
|
||||
# no proc
|
||||
return @at_end_proc
|
||||
end
|
||||
else
|
||||
fail ArgumentError, "wrong number of arguments" if arg.length != 1 || b
|
||||
@at_end_proc = arg[0]
|
||||
end
|
||||
self
|
||||
end
|
||||
|
||||
def wait(on_thread = true, check_root = false)
|
||||
if $SAFE >= 4
|
||||
fail SecurityError, "can't wait timer at $SAFE >= 4"
|
||||
|
|
@ -569,7 +595,8 @@ class TkRTTimer < TkTimer
|
|||
if @running == false || @proc_max == 0 || @do_loop == 0
|
||||
Tk_CBTBL.delete(@id) ;# for GC
|
||||
@running = false
|
||||
@wait_var.value = 0
|
||||
# @wait_var.value = 0
|
||||
__at_end__
|
||||
return
|
||||
end
|
||||
if @current_pos >= @proc_max
|
||||
|
|
@ -578,7 +605,8 @@ class TkRTTimer < TkTimer
|
|||
else
|
||||
Tk_CBTBL.delete(@id) ;# for GC
|
||||
@running = false
|
||||
@wait_var.value = 0
|
||||
# @wait_var.value = 0
|
||||
__at_end__
|
||||
return
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ class Tk::Toplevel<TkWindow
|
|||
|
||||
conf_methods = _symbolkey2str(__methodcall_optkeys())
|
||||
|
||||
keys.each{|k,v|
|
||||
keys.each{|k,v| # k is a String
|
||||
if conf_methods.key?(k)
|
||||
wm_cmds[conf_methods[k]] = v
|
||||
elsif Wm.method_defined?(k)
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ class Tk::Iwidgets::Scrolledcanvas
|
|||
end
|
||||
|
||||
def method_missing(id, *args)
|
||||
if @canvas.methods.include?(id.id2name)
|
||||
if @canvas.respond_to?(id)
|
||||
@canvas.__send__(id, *args)
|
||||
else
|
||||
super(id, *args)
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ class Tk::Iwidgets::Scrolledlistbox
|
|||
end
|
||||
|
||||
def method_missing(id, *args)
|
||||
if @listbox.methods.include?(id.id2name)
|
||||
if @listbox.respond_to?(id)
|
||||
@listbox.__send__(id, *args)
|
||||
else
|
||||
super(id, *args)
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ class Tk::Iwidgets::Scrolledtext
|
|||
end
|
||||
|
||||
def method_missing(id, *args)
|
||||
if @text.methods.include?(id.id2name)
|
||||
if @text.respond_to?(id)
|
||||
@text.__send__(id, *args)
|
||||
else
|
||||
super(id, *args)
|
||||
|
|
|
|||
|
|
@ -36,9 +36,21 @@ class Tk::Tile::TPaned < TkWindow
|
|||
[self::WidgetClassName, *(args.map!{|a| _get_eval_string(a)})].join('.')
|
||||
end
|
||||
|
||||
def add(win, keys)
|
||||
win = _epath(win)
|
||||
tk_send_without_enc('add', win, *hash_kv(keys))
|
||||
def add(*args)
|
||||
keys = args.pop
|
||||
fail ArgumentError, "no window in arguments" unless keys
|
||||
|
||||
if keys && keys.kind_of?(Hash)
|
||||
fail ArgumentError, "no window in arguments" if args == []
|
||||
opts = hash_kv(keys)
|
||||
else
|
||||
args.push(keys) if keys
|
||||
opts = []
|
||||
end
|
||||
|
||||
args.each{|win|
|
||||
tk_send_without_enc('add', _epath(win), *opts)
|
||||
}
|
||||
self
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -2,5 +2,5 @@
|
|||
# release date of tkextlib
|
||||
#
|
||||
module Tk
|
||||
Tkextlib_RELEASE_DATE = '2008-03-29'.freeze
|
||||
Tkextlib_RELEASE_DATE = '2008-04-14'.freeze
|
||||
end
|
||||
|
|
|
|||
|
|
@ -254,7 +254,15 @@ class TkTextIO < TkText
|
|||
Tk.callback_break
|
||||
end
|
||||
end
|
||||
private :_cb_up, :_cb_down, :_cb_left, :_cb_backspace, :_cb_ctrl_a
|
||||
def _cb_ctrl_u
|
||||
if @console_mode
|
||||
mark_set('insert', @ins_head)
|
||||
delete('insert', 'insert lineend')
|
||||
Tk.callback_break
|
||||
end
|
||||
end
|
||||
private :_cb_up, :_cb_down, :_cb_left, :_cb_backspace,
|
||||
:_cb_ctrl_a, :_cb_ctrl_u
|
||||
|
||||
def _setup_console_bindings
|
||||
@bindtag = TkBindTag.new
|
||||
|
|
@ -328,6 +336,8 @@ class TkTextIO < TkText
|
|||
|
||||
@bindtag.bind('Home'){ _cb_ctrl_a }
|
||||
@bindtag.bind('Control-a'){ _cb_ctrl_a }
|
||||
|
||||
@bindtag.bind('Control-u'){ _cb_ctrl_u }
|
||||
end
|
||||
private :_setup_console_bindings
|
||||
|
||||
|
|
|
|||
|
|
@ -51,6 +51,15 @@ if OPTS[:verbose]
|
|||
end
|
||||
|
||||
|
||||
##########################################################################
|
||||
# define Tcl/Tk procedures for compatibility.
|
||||
# those are required when want to use themes included
|
||||
# in "sample/tkextlib/tile/demo.rb".
|
||||
##########################################################################
|
||||
Tk::Tile.__define_LoadImages_proc_for_compatibility__!
|
||||
Tk::Tile::Style.__define_wrapper_proc_for_compatibility__!
|
||||
|
||||
|
||||
##########################################################################
|
||||
# use themes defined on the demo of Ttk (Tile) extension
|
||||
##########################################################################
|
||||
|
|
@ -91,15 +100,6 @@ themes_by_ruby.each{|f|
|
|||
}
|
||||
|
||||
|
||||
##########################################################################
|
||||
# define Tcl/Tk procedures for compatibility.
|
||||
# those are required when want to use themes included
|
||||
# in "sample/tkextlib/tile/demo.rb".
|
||||
##########################################################################
|
||||
Tk::Tile.__define_LoadImages_proc_for_compatibility__!
|
||||
Tk::Tile::Style.__define_wrapper_proc_for_compatibility__!
|
||||
|
||||
|
||||
##########################################################################
|
||||
# ignore unsupported options of Ttk widgets
|
||||
##########################################################################
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue