diff options
Diffstat (limited to 'ext/tk/lib/tk.rb')
-rw-r--r-- | ext/tk/lib/tk.rb | 334 |
1 files changed, 167 insertions, 167 deletions
diff --git a/ext/tk/lib/tk.rb b/ext/tk/lib/tk.rb index 85c1e76f83..49e4ca2564 100644 --- a/ext/tk/lib/tk.rb +++ b/ext/tk/lib/tk.rb @@ -76,7 +76,7 @@ module TkComm unless const_defined?(:GET_CONFIGINFO_AS_ARRAY) # GET_CONFIGINFO_AS_ARRAY = false => returns a Hash { opt =>val, ... } # true => returns an Array [[opt,val], ... ] - # val is a list which includes resource info. + # val is a list which includes resource info. GET_CONFIGINFO_AS_ARRAY = true end unless const_defined?(:GET_CONFIGINFOwoRES_AS_ARRAY) @@ -177,7 +177,7 @@ module TkComm #{classname_def} end" end - Object.class_eval "#{gen_class_name}.new('widgetname'=>'#{path}', + Object.class_eval "#{gen_class_name}.new('widgetname'=>'#{path}', 'without_creating'=>true)" =end base = Object @@ -192,7 +192,7 @@ module TkComm #{klass}" end } - base.class_eval "#{gen_class_name}.new('widgetname'=>'#{path}', + base.class_eval "#{gen_class_name}.new('widgetname'=>'#{path}', 'without_creating'=>true)" end private :_genobj_for_tkwidget @@ -233,7 +233,7 @@ module TkComm val.to_i when /\A\.\S*\z/ #Tk_WINDOWS[val] ? Tk_WINDOWS[val] : _genobj_for_tkwidget(val) - TkCore::INTERP.tk_windows[val]? + TkCore::INTERP.tk_windows[val]? TkCore::INTERP.tk_windows[val] : _genobj_for_tkwidget(val) when /\Ai(_\d+_)?\d+\z/ TkImage::Tk_IMGTBL.mutex.synchronize{ @@ -438,7 +438,7 @@ else def tk_split_list(str, depth=0, src_enc=true, dst_enc=true) return [] if str == "" - tk_split_escstr(str).collect{|token| + tk_split_escstr(str).collect{|token| tk_split_sublist(token, depth - 1) } end @@ -584,7 +584,7 @@ end def window(val) if val =~ /^\./ #Tk_WINDOWS[val]? Tk_WINDOWS[val] : _genobj_for_tkwidget(val) - TkCore::INTERP.tk_windows[val]? + TkCore::INTERP.tk_windows[val]? TkCore::INTERP.tk_windows[val] : _genobj_for_tkwidget(val) else nil @@ -620,7 +620,7 @@ end def subst(str, *opts) # opts := :nobackslashes | :nocommands | novariables - tk_call('subst', + tk_call('subst', *(opts.collect{|opt| opt = opt.to_s (opt[0] == ?-)? opt: '-' << opt @@ -678,7 +678,7 @@ end else str = str.to_s() || '' unless str.kind_of? String - fail RuntimeError, "fail to convert the object to a string" + fail RuntimeError, "fail to convert the object to a string" end str = _toUTF8(str) if enc_mode end @@ -717,7 +717,7 @@ end begin obj = obj.to_s || '' rescue - fail RuntimeError, "fail to convert object '#{obj}' to string" + fail RuntimeError, "fail to convert object '#{obj}' to string" end (enc_mode)? _toUTF8(obj): obj end @@ -936,7 +936,7 @@ module TkComm def _bind_core(mode, what, context, cmd, *args) id = install_bind(cmd, *args) if cmd begin - tk_call_without_enc(*(what + ["<#{tk_event_sequence(context)}>", + tk_call_without_enc(*(what + ["<#{tk_event_sequence(context)}>", mode + id])) rescue uninstall_cmd(id) if cmd @@ -995,7 +995,7 @@ module TkComm def _bind_core_for_event_class(klass, mode, what, context, cmd, *args) id = install_bind_for_event_class(klass, cmd, *args) if cmd begin - tk_call_without_enc(*(what + ["<#{tk_event_sequence(context)}>", + tk_call_without_enc(*(what + ["<#{tk_event_sequence(context)}>", mode + id])) rescue uninstall_cmd(id) if cmd @@ -1021,8 +1021,8 @@ module TkComm private :tk_event_sequence private :_bind_core, :_bind, :_bind_append, :_bind_remove, :_bindinfo - private :_bind_core_for_event_class, :_bind_for_event_class, - :_bind_append_for_event_class, :_bind_remove_for_event_class, + private :_bind_core_for_event_class, :_bind_for_event_class, + :_bind_append_for_event_class, :_bind_remove_for_event_class, :_bindinfo_for_event_class #def bind(tagOrClass, context, cmd=Proc.new, *args) @@ -1133,11 +1133,11 @@ module TkCore if WITH_RUBY_VM ### check Ruby 1.9 !!!!!!! # *** NEED TO FIX *** ip = TclTkIp.new(name, opts) - if ip._invoke_without_enc('tk', 'windowingsystem') == 'aqua' && + if ip._invoke_without_enc('tk', 'windowingsystem') == 'aqua' && (TclTkLib.get_version <=> [8,4,TclTkLib::RELEASE_TYPE::FINAL,9]) > 0 # *** KNOWN BUG *** - # Main event loop thread of TkAqua (> Tk8.4.9) must be the main - # application thread. So, ruby1.9 users must call Tk.mainloop on + # Main event loop thread of TkAqua (> Tk8.4.9) must be the main + # application thread. So, ruby1.9 users must call Tk.mainloop on # the main application thread. RUN_EVENTLOOP_ON_MAIN_THREAD = true INTERP = ip @@ -1318,7 +1318,7 @@ module TkCore def INTERP.remove_tk_procs(*names) names.each{|name| name = name.to_s - @add_tk_procs.delete_if{|elem| + @add_tk_procs.delete_if{|elem| elem.kind_of?(Array) && elem[0].to_s == name } self._invoke('rename', name, '') @@ -1337,7 +1337,7 @@ module TkCore end WIDGET_DESTROY_HOOK = '<WIDGET_DESTROY_HOOK>' - INTERP._invoke_without_enc('event', 'add', + INTERP._invoke_without_enc('event', 'add', "<#{WIDGET_DESTROY_HOOK}>", '<Destroy>') INTERP._invoke_without_enc('bind', 'all', "<#{WIDGET_DESTROY_HOOK}>", install_cmd(proc{|path| @@ -1354,7 +1354,7 @@ module TkCore end }) << ' %W') - INTERP.add_tk_procs(TclTkLib::FINALIZE_PROC_NAME, '', + INTERP.add_tk_procs(TclTkLib::FINALIZE_PROC_NAME, '', "catch { bind all <#{WIDGET_DESTROY_HOOK}> {} }") INTERP.add_tk_procs('rb_out', 'ns args', <<-'EOL') @@ -1457,10 +1457,10 @@ module TkCore fail(e) rescue Exception => e begin - msg = _toUTF8(e.class.inspect) + ': ' + - _toUTF8(e.message) + "\n" + - "\n---< backtrace of Ruby side >-----\n" + - _toUTF8(e.backtrace.join("\n")) + + msg = _toUTF8(e.class.inspect) + ': ' + + _toUTF8(e.message) + "\n" + + "\n---< backtrace of Ruby side >-----\n" + + _toUTF8(e.backtrace.join("\n")) + "\n---< backtrace of Tk side >-------" if TkCore::WITH_ENCODING msg.force_encoding('utf-8') @@ -1468,9 +1468,9 @@ module TkCore msg.instance_variable_set(:@encoding, 'utf-8') end rescue Exception - msg = e.class.inspect + ': ' + e.message + "\n" + - "\n---< backtrace of Ruby side >-----\n" + - e.backtrace.join("\n") + + msg = e.class.inspect + ': ' + e.message + "\n" + + "\n---< backtrace of Ruby side >-----\n" + + e.backtrace.join("\n") + "\n---< backtrace of Tk side >-------" end # TkCore::INTERP._set_global_var('errorInfo', msg) @@ -1483,15 +1483,15 @@ module TkCore # arg = tk_split_list(arg_str) arg = tk_split_simplelist(arg_str) #_get_eval_string(TkUtil.eval_cmd(Tk_CMDTBL[arg.shift], *arg)) - #_get_eval_string(TkUtil.eval_cmd(TkCore::INTERP.tk_cmd_tbl[arg.shift], + #_get_eval_string(TkUtil.eval_cmd(TkCore::INTERP.tk_cmd_tbl[arg.shift], # *arg)) # TkCore::INTERP.tk_cmd_tbl[arg.shift].call(*arg) begin TkCore::INTERP.tk_cmd_tbl[arg.shift].call(*arg) rescue Exception => e - raise(e, e.class.inspect + ': ' + e.message + "\n" + - "\n---< backtrace of Ruby side >-----\n" + - e.backtrace.join("\n") + + raise(e, e.class.inspect + ': ' + e.message + "\n" + + "\n---< backtrace of Ruby side >-----\n" + + e.backtrace.join("\n") + "\n---< backtrace of Tk side >-------") end #=begin @@ -1509,7 +1509,7 @@ module TkCore # cb_obj.call(*arg) # rescue # trace = $!.backtrace -# raise $!, "\n#{trace[0]}: #{$!.message} (#{$!.class})\n" + +# raise $!, "\n#{trace[0]}: #{$!.message} (#{$!.class})\n" + # "\tfrom #{trace[1..pos].join("\n\tfrom ")}" # end # end @@ -1703,11 +1703,11 @@ module TkCore TclTkLib.mainloop(check_root) elsif TkCore::RUN_EVENTLOOP_ON_MAIN_THREAD - # if TclTkLib::WINDOWING_SYSTEM == 'aqua' && + # if TclTkLib::WINDOWING_SYSTEM == 'aqua' && if TkCore::INTERP._invoke_without_enc('tk','windowingsystem')=='aqua' && - Thread.current != Thread.main && + Thread.current != Thread.main && (TclTkLib.get_version <=> [8,4,TclTkLib::RELEASE_TYPE::FINAL,9]) > 0 - raise RuntimeError, + raise RuntimeError, "eventloop on TkAqua ( > Tk8.4.9 ) works on the main thread only" end TclTkLib.mainloop(check_root) @@ -1810,11 +1810,11 @@ module TkCore if context.kind_of?(TkEvent::Event) context.generate(win, ((keys)? keys: {})) elsif keys - tk_call_without_enc('event', 'generate', win, - "<#{tk_event_sequence(context)}>", + tk_call_without_enc('event', 'generate', win, + "<#{tk_event_sequence(context)}>", *hash_kv(keys, true)) else - tk_call_without_enc('event', 'generate', win, + tk_call_without_enc('event', 'generate', win, "<#{tk_event_sequence(context)}>") end nil @@ -1919,9 +1919,9 @@ module TkCore # err = $! begin args.unshift "unknown" - #res = INTERP._invoke(*args).taint - #res = INTERP._invoke(enc_mode, *args) - res = _ip_invoke_core(enc_mode, *args) + #res = INTERP._invoke(*args).taint + #res = INTERP._invoke(enc_mode, *args) + res = _ip_invoke_core(enc_mode, *args) # >>>>> _invoke returns a TAINTED string <<<<< rescue StandardError => err2 fail err2 unless /^invalid command/ =~ err2.message @@ -2003,7 +2003,7 @@ module Tk TK_MAJOR_VERSION = major.to_i TK_MINOR_VERSION = minor.to_i - JAPANIZED_TK = (INTERP._invoke_without_enc("info", "commands", + JAPANIZED_TK = (INTERP._invoke_without_enc("info", "commands", "kanji") != "").freeze def Tk.const_missing(sym) @@ -2032,14 +2032,14 @@ module Tk fail SecurityError, "can't get #{sym} when $SAFE >= 4" end INTERP._invoke_without_enc('global', 'tcl_platform') - Hash[*tk_split_simplelist(INTERP._invoke_without_enc('array', 'get', + Hash[*tk_split_simplelist(INTERP._invoke_without_enc('array', 'get', 'tcl_platform'))] when :ENV INTERP._invoke_without_enc('global', 'env') Hash[*tk_split_simplelist(INTERP._invoke('array', 'get', 'env'))] - #when :AUTO_PATH #<=== + #when :AUTO_PATH #<=== # tk_split_simplelist(INTERP._invoke('set', 'auto_path')) #when :AUTO_OLDPATH @@ -2057,7 +2057,7 @@ module Tk var_nam = 'tkPriv' end INTERP._invoke_without_enc('global', var_nam) - Hash[*tk_split_simplelist(INTERP._invoke('array', 'get', + Hash[*tk_split_simplelist(INTERP._invoke('array', 'get', var_nam))].each{|k,v| k.freeze case v @@ -2284,9 +2284,9 @@ module Tk end # NOTE:: - # If no eventloop-thread is running, "thread_update" method is same - # to "update" method. Else, "thread_update" method waits to complete - # idletask operation on the eventloop-thread. + # If no eventloop-thread is running, "thread_update" method is same + # to "update" method. Else, "thread_update" method waits to complete + # idletask operation on the eventloop-thread. def Tk.thread_update(idle=nil) if idle tk_call_without_enc('thread_update', 'idletasks') @@ -2358,7 +2358,7 @@ module Tk def Tk.add_kinsoku(chars, mode='both') begin if /^8\.*/ === TK_VERSION && JAPANIZED_TK - tk_split_simplelist(tk_call('kinsoku', 'add', mode, + tk_split_simplelist(tk_call('kinsoku', 'add', mode, *(chars.split('')))) else [] @@ -2370,7 +2370,7 @@ module Tk def Tk.delete_kinsoku(chars, mode='both') begin if /^8\.*/ === TK_VERSION && JAPANIZED_TK - tk_split_simplelist(tk_call('kinsoku', 'delete', mode, + tk_split_simplelist(tk_call('kinsoku', 'delete', mode, *(chars.split('')))) end rescue @@ -2380,7 +2380,7 @@ module Tk def Tk.toUTF8(str, encoding = nil) _toUTF8(str, encoding) end - + def Tk.fromUTF8(str, encoding = nil) _fromUTF8(str, encoding) end @@ -2437,11 +2437,11 @@ if (/^(8\.[1-9]|9\.|[1-9][0-9])/ =~ Tk::TCL_VERSION && !Tk::JAPANIZED_TK) ENCODING_TABLE = TkCore::INTERP.encoding_table =begin ENCODING_TABLE = { - 'binary' => BINARY, - # 'UNKNOWN-8BIT' => UNKNOWN, + 'binary' => BINARY, + # 'UNKNOWN-8BIT' => UNKNOWN, } - list = TkCore::INTERP._invoke_without_enc(ENCNAMES_CMD[0], + list = TkCore::INTERP._invoke_without_enc(ENCNAMES_CMD[0], ENCNAMES_CMD[1]) TkCore::INTERP._split_tklist(list).each{|name| begin @@ -2489,7 +2489,7 @@ if (/^(8\.[1-9]|9\.|[1-9][0-9])/ =~ Tk::TCL_VERSION && !Tk::JAPANIZED_TK) end # Is it new ? - list = TkCore::INTERP._invoke_without_enc(ENCNAMES_CMD[0], + list = TkCore::INTERP._invoke_without_enc(ENCNAMES_CMD[0], ENCNAMES_CMD[1]) TkComm.simplelist(list).each{|name| if ((enc == RubyEncoding.find(name)) rescue false) @@ -2506,7 +2506,7 @@ if (/^(8\.[1-9]|9\.|[1-9][0-9])/ =~ Tk::TCL_VERSION && !Tk::JAPANIZED_TK) # Is it new ? if (enc_obj = (RubyEncoding.find(name) rescue false)) - list = TkCore::INTERP._invoke_without_enc(ENCNAMES_CMD[0], + list = TkCore::INTERP._invoke_without_enc(ENCNAMES_CMD[0], ENCNAMES_CMD[1]) if TkComm.simplelist(list).index(name) # Tk's encoding name ? @@ -2660,7 +2660,7 @@ if (/^(8\.[1-9]|9\.|[1-9][0-9])/ =~ Tk::TCL_VERSION && !Tk::JAPANIZED_TK) else str.instance_variable_set('@encoding', 'binary') end - ret = TkCore::INTERP._invoke_without_enc('encoding', 'convertfrom', + ret = TkCore::INTERP._invoke_without_enc('encoding', 'convertfrom', enc, str) if TkCore::WITH_ENCODING ret.force_encoding('utf-8') @@ -2674,7 +2674,7 @@ if (/^(8\.[1-9]|9\.|[1-9][0-9])/ =~ Tk::TCL_VERSION && !Tk::JAPANIZED_TK) def encoding_convertto(str, enc=nil) # str must be a UTF-8 string enc = encoding_system_name unless enc - ret = TkCore::INTERP._invoke_without_enc('encoding', 'convertto', + ret = TkCore::INTERP._invoke_without_enc('encoding', 'convertto', enc, str) #ret.instance_variable_set('@encoding', 'binary') if TkCore::WITH_ENCODING @@ -2758,7 +2758,7 @@ if (/^(8\.[1-9]|9\.|[1-9][0-9])/ =~ Tk::TCL_VERSION && !Tk::JAPANIZED_TK) enc_name ||= str.instance_variable_get(:@encoding) - enc_name ||= + enc_name ||= Tk::Encoding::ENCODING_TABLE.get_name(str.encoding) rescue nil if enc_name @@ -2775,7 +2775,7 @@ if (/^(8\.[1-9]|9\.|[1-9][0-9])/ =~ Tk::TCL_VERSION && !Tk::JAPANIZED_TK) end end - #enc_name ||= + #enc_name ||= # Tk::Encoding::ENCODING_TABLE.get_name(Tk.encoding) rescue nil enc_name ||= Tk::Encoding::ENCODING_TABLE.get_name(nil) @@ -2796,7 +2796,7 @@ if (/^(8\.[1-9]|9\.|[1-9][0-9])/ =~ Tk::TCL_VERSION && !Tk::JAPANIZED_TK) def _fromUTF8(str, enc = nil) # str must be UTF-8 or binary. enc_name = str.instance_variable_get(:@encoding) - enc_name ||= + enc_name ||= Tk::Encoding::ENCODING_TABLE.get_name(str.encoding) rescue nil # is 'binary' encoding? @@ -2986,7 +2986,7 @@ if (/^(8\.[1-9]|9\.|[1-9][0-9])/ =~ Tk::TCL_VERSION && !Tk::JAPANIZED_TK) end # estimate encoding - unless TkCore::WITH_ENCODING + unless TkCore::WITH_ENCODING case $KCODE when /^e/i # EUC Tk.encoding = 'euc-jp' @@ -3094,7 +3094,7 @@ if (/^(8\.[1-9]|9\.|[1-9][0-9])/ =~ Tk::TCL_VERSION && !Tk::JAPANIZED_TK) enc_name = nil rescue ArgumentError enc_name = nil - fail ArgumentError, + fail ArgumentError, "DEFAULT_TK_ENCODING has an unknown encoding #{default_def}" end @@ -3271,19 +3271,19 @@ module TkTreatFont if key pathname = [win, tag, key].join(';') - TkFont.used_on(pathname) || + TkFont.used_on(pathname) || TkFont.init_widget_font(pathname, *__confinfo_cmd) elsif optkeys.size == 1 pathname = [win, tag, optkeys[0]].join(';') - TkFont.used_on(pathname) || + TkFont.used_on(pathname) || TkFont.init_widget_font(pathname, *__confinfo_cmd) else fonts = {} optkeys.each{|key| key = key.to_s pathname = [win, tag, key].join(';') - fonts[key] = - TkFont.used_on(pathname) || + fonts[key] = + TkFont.used_on(pathname) || TkFont.init_widget_font(pathname, *__confinfo_cmd) } fonts @@ -3313,8 +3313,8 @@ module TkTreatFont next else if fnt - if (slot.key?(l_optkey) || - slot.key?(a_optkey) || + if (slot.key?(l_optkey) || + slot.key?(a_optkey) || slot.key?(k_optkey)) fnt = TkFont.new(fnt) @@ -3325,7 +3325,7 @@ module TkTreatFont fnt.latin_replace(lfnt) if lfnt fnt.kanji_replace(kfnt) if kfnt - fnt.call_font_configure([pathname, optkey], + fnt.call_font_configure([pathname, optkey], *(__config_cmd << {})) next else @@ -3350,7 +3350,7 @@ module TkTreatFont kfnt = slot.delete(k_optkey) if lfnt && kfnt - TkFont.new(lfnt, kfnt).call_font_configure([pathname, optkey], + TkFont.new(lfnt, kfnt).call_font_configure([pathname, optkey], *(__config_cmd << {})) elsif lfnt latinfont_configure([lfnt, optkey]) @@ -3508,7 +3508,7 @@ module TkTreatFont def latinfont_copy(win, wintag=nil, winkey=nil, targetkey=nil) if targetkey - fontobj(targetkey).dup.call_font_configure([__pathname, targetkey], + fontobj(targetkey).dup.call_font_configure([__pathname, targetkey], *(__config_cmd << {})) else fontobj.dup.call_font_configure(__pathname, *(__config_cmd << {})) @@ -3533,7 +3533,7 @@ module TkTreatFont def kanjifont_copy(win, wintag=nil, winkey=nil, targetkey=nil) if targetkey - fontobj(targetkey).dup.call_font_configure([__pathname, targetkey], + fontobj(targetkey).dup.call_font_configure([__pathname, targetkey], *(__config_cmd << {})) else fontobj.dup.call_font_configure(__pathname, *(__config_cmd << {})) @@ -3585,7 +3585,7 @@ module TkConfigMethod private :__confinfo_cmd def __configinfo_struct - {:key=>0, :alias=>1, :db_name=>1, :db_class=>2, + {:key=>0, :alias=>1, :db_name=>1, :db_class=>2, :default_value=>3, :current_value=>4} end private :__configinfo_struct @@ -3612,10 +3612,10 @@ module TkConfigMethod def __strval_optkeys [ - 'text', 'label', 'show', 'data', 'file', - 'activebackground', 'activeforeground', 'background', - 'disabledforeground', 'disabledbackground', 'foreground', - 'highlightbackground', 'highlightcolor', 'insertbackground', + 'text', 'label', 'show', 'data', 'file', + 'activebackground', 'activeforeground', 'background', + 'disabledforeground', 'disabledbackground', 'foreground', + 'highlightbackground', 'highlightcolor', 'insertbackground', 'selectbackground', 'selectforeground', 'troughcolor' ] end @@ -3704,7 +3704,7 @@ module TkConfigMethod def __cget_core(slot) orig_slot = slot slot = slot.to_s - + if slot.length == 0 fail ArgumentError, "Invalid option `#{orig_slot.inspect}'" end @@ -3931,12 +3931,12 @@ module TkConfigMethod def __configinfo_core(slot = nil) if TkComm::GET_CONFIGINFO_AS_ARRAY - if (slot && + if (slot && slot.to_s =~ /^(|latin|ascii|kanji)(#{__font_optkeys.join('|')})$/) fontkey = $2 # conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__confinfo_cmd << "-#{fontkey}")))) conf = tk_split_simplelist(tk_call_without_enc(*(__confinfo_cmd << "-#{fontkey}")), false, true) - conf[__configinfo_struct[:key]] = + conf[__configinfo_struct[:key]] = conf[__configinfo_struct[:key]][1..-1] if ( ! __configinfo_struct[:alias] \ || conf.size > __configinfo_struct[:alias] + 1 ) @@ -3948,7 +3948,7 @@ module TkConfigMethod elsif ( __configinfo_struct[:alias] \ && conf.size == __configinfo_struct[:alias] + 1 \ && conf[__configinfo_struct[:alias]][0] == ?- ) - conf[__configinfo_struct[:alias]] = + conf[__configinfo_struct[:alias]] = conf[__configinfo_struct[:alias]][1..-1] end conf @@ -3998,7 +3998,7 @@ module TkConfigMethod if ( __configinfo_struct[:default_value] \ && conf[__configinfo_struct[:default_value]]) begin - conf[__configinfo_struct[:default_value]] = + conf[__configinfo_struct[:default_value]] = number(conf[__configinfo_struct[:default_value]]) rescue conf[__configinfo_struct[:default_value]] = nil @@ -4006,7 +4006,7 @@ module TkConfigMethod end if ( conf[__configinfo_struct[:current_value]] ) begin - conf[__configinfo_struct[:current_value]] = + conf[__configinfo_struct[:current_value]] = number(conf[__configinfo_struct[:current_value]]) rescue conf[__configinfo_struct[:current_value]] = nil @@ -4019,11 +4019,11 @@ module TkConfigMethod if ( __configinfo_struct[:default_value] \ && conf[__configinfo_struct[:default_value]]) - conf[__configinfo_struct[:default_value]] = + conf[__configinfo_struct[:default_value]] = num_or_str(conf[__configinfo_struct[:default_value]]) end if ( conf[__configinfo_struct[:current_value]] ) - conf[__configinfo_struct[:current_value]] = + conf[__configinfo_struct[:current_value]] = num_or_str(conf[__configinfo_struct[:current_value]]) end @@ -4034,7 +4034,7 @@ module TkConfigMethod if ( __configinfo_struct[:default_value] \ && conf[__configinfo_struct[:default_value]]) begin - conf[__configinfo_struct[:default_value]] = + conf[__configinfo_struct[:default_value]] = bool(conf[__configinfo_struct[:default_value]]) rescue conf[__configinfo_struct[:default_value]] = nil @@ -4042,7 +4042,7 @@ module TkConfigMethod end if ( conf[__configinfo_struct[:current_value]] ) begin - conf[__configinfo_struct[:current_value]] = + conf[__configinfo_struct[:current_value]] = bool(conf[__configinfo_struct[:current_value]]) rescue conf[__configinfo_struct[:current_value]] = nil @@ -4055,11 +4055,11 @@ module TkConfigMethod if ( __configinfo_struct[:default_value] \ && conf[__configinfo_struct[:default_value]]) - conf[__configinfo_struct[:default_value]] = + conf[__configinfo_struct[:default_value]] = simplelist(conf[__configinfo_struct[:default_value]]) end if ( conf[__configinfo_struct[:current_value]] ) - conf[__configinfo_struct[:current_value]] = + conf[__configinfo_struct[:current_value]] = simplelist(conf[__configinfo_struct[:current_value]]) end @@ -4070,12 +4070,12 @@ module TkConfigMethod if ( __configinfo_struct[:default_value] \ && conf[__configinfo_struct[:default_value]] \ && conf[__configinfo_struct[:default_value]] =~ /^[0-9]/ ) - conf[__configinfo_struct[:default_value]] = + conf[__configinfo_struct[:default_value]] = list(conf[__configinfo_struct[:default_value]]) end if ( conf[__configinfo_struct[:current_value]] \ && conf[__configinfo_struct[:current_value]] =~ /^[0-9]/ ) - conf[__configinfo_struct[:current_value]] = + conf[__configinfo_struct[:current_value]] = list(conf[__configinfo_struct[:current_value]]) end @@ -4108,13 +4108,13 @@ module TkConfigMethod # conf = tk_split_list(_fromUTF8(tk_call_without_enc(*(__confinfo_cmd << "-#{slot}")))) conf = tk_split_list(tk_call_without_enc(*(__confinfo_cmd << "-#{slot}")), 0, false, true) end - conf[__configinfo_struct[:key]] = + conf[__configinfo_struct[:key]] = conf[__configinfo_struct[:key]][1..-1] if ( __configinfo_struct[:alias] \ && conf.size == __configinfo_struct[:alias] + 1 \ && conf[__configinfo_struct[:alias]][0] == ?- ) - conf[__configinfo_struct[:alias]] = + conf[__configinfo_struct[:alias]] = conf[__configinfo_struct[:alias]][1..-1] end @@ -4125,7 +4125,7 @@ module TkConfigMethod # conf = tk_split_simplelist(conflist) ret = tk_split_simplelist(tk_call_without_enc(*__confinfo_cmd), false, false).collect{|conflist| conf = tk_split_simplelist(conflist, false, true) - conf[__configinfo_struct[:key]] = + conf[__configinfo_struct[:key]] = conf[__configinfo_struct[:key]][1..-1] optkey = conf[__configinfo_struct[:key]] @@ -4161,7 +4161,7 @@ module TkConfigMethod if ( __configinfo_struct[:default_value] \ && conf[__configinfo_struct[:default_value]] ) begin - conf[__configinfo_struct[:default_value]] = + conf[__configinfo_struct[:default_value]] = number(conf[__configinfo_struct[:default_value]]) rescue conf[__configinfo_struct[:default_value]] = nil @@ -4169,7 +4169,7 @@ module TkConfigMethod end if ( conf[__configinfo_struct[:current_value]] ) begin - conf[__configinfo_struct[:current_value]] = + conf[__configinfo_struct[:current_value]] = number(conf[__configinfo_struct[:current_value]]) rescue conf[__configinfo_struct[:current_value]] = nil @@ -4179,11 +4179,11 @@ module TkConfigMethod when /^(#{__numstrval_optkeys.join('|')})$/ if ( __configinfo_struct[:default_value] \ && conf[__configinfo_struct[:default_value]] ) - conf[__configinfo_struct[:default_value]] = + conf[__configinfo_struct[:default_value]] = num_or_str(conf[__configinfo_struct[:default_value]]) end if ( conf[__configinfo_struct[:current_value]] ) - conf[__configinfo_struct[:current_value]] = + conf[__configinfo_struct[:current_value]] = num_or_str(conf[__configinfo_struct[:current_value]]) end @@ -4191,7 +4191,7 @@ module TkConfigMethod if ( __configinfo_struct[:default_value] \ && conf[__configinfo_struct[:default_value]] ) begin - conf[__configinfo_struct[:default_value]] = + conf[__configinfo_struct[:default_value]] = bool(conf[__configinfo_struct[:default_value]]) rescue conf[__configinfo_struct[:default_value]] = nil @@ -4199,7 +4199,7 @@ module TkConfigMethod end if ( conf[__configinfo_struct[:current_value]] ) begin - conf[__configinfo_struct[:current_value]] = + conf[__configinfo_struct[:current_value]] = bool(conf[__configinfo_struct[:current_value]]) rescue conf[__configinfo_struct[:current_value]] = nil @@ -4209,11 +4209,11 @@ module TkConfigMethod when /^(#{__listval_optkeys.join('|')})$/ if ( __configinfo_struct[:default_value] \ && conf[__configinfo_struct[:default_value]] ) - conf[__configinfo_struct[:default_value]] = + conf[__configinfo_struct[:default_value]] = simplelist(conf[__configinfo_struct[:default_value]]) end if ( conf[__configinfo_struct[:current_value]] ) - conf[__configinfo_struct[:current_value]] = + conf[__configinfo_struct[:current_value]] = simplelist(conf[__configinfo_struct[:current_value]]) end @@ -4221,12 +4221,12 @@ module TkConfigMethod if ( __configinfo_struct[:default_value] \ && conf[__configinfo_struct[:default_value]] \ && conf[__configinfo_struct[:default_value]] =~ /^[0-9]/ ) - conf[__configinfo_struct[:default_value]] = + conf[__configinfo_struct[:default_value]] = list(conf[__configinfo_struct[:default_value]]) end if ( conf[__configinfo_struct[:current_value]] \ && conf[__configinfo_struct[:current_value]] =~ /^[0-9]/ ) - conf[__configinfo_struct[:current_value]] = + conf[__configinfo_struct[:current_value]] = list(conf[__configinfo_struct[:current_value]]) end @@ -4253,20 +4253,20 @@ module TkConfigMethod if ( __configinfo_struct[:default_value] \ && conf[__configinfo_struct[:default_value]] ) if conf[__configinfo_struct[:default_value]].index('{') - conf[__configinfo_struct[:default_value]] = - tk_split_list(conf[__configinfo_struct[:default_value]]) + conf[__configinfo_struct[:default_value]] = + tk_split_list(conf[__configinfo_struct[:default_value]]) else - conf[__configinfo_struct[:default_value]] = - tk_tcl2ruby(conf[__configinfo_struct[:default_value]]) + conf[__configinfo_struct[:default_value]] = + tk_tcl2ruby(conf[__configinfo_struct[:default_value]]) end end if conf[__configinfo_struct[:current_value]] if conf[__configinfo_struct[:current_value]].index('{') - conf[__configinfo_struct[:current_value]] = - tk_split_list(conf[__configinfo_struct[:current_value]]) + conf[__configinfo_struct[:current_value]] = + tk_split_list(conf[__configinfo_struct[:current_value]]) else - conf[__configinfo_struct[:current_value]] = - tk_tcl2ruby(conf[__configinfo_struct[:current_value]]) + conf[__configinfo_struct[:current_value]] = + tk_tcl2ruby(conf[__configinfo_struct[:current_value]]) end end end @@ -4274,7 +4274,7 @@ module TkConfigMethod if ( __configinfo_struct[:alias] \ && conf.size == __configinfo_struct[:alias] + 1 \ && conf[__configinfo_struct[:alias]][0] == ?- ) - conf[__configinfo_struct[:alias]] = + conf[__configinfo_struct[:alias]] = conf[__configinfo_struct[:alias]][1..-1] end @@ -4305,12 +4305,12 @@ module TkConfigMethod end else # ! TkComm::GET_CONFIGINFO_AS_ARRAY - if (slot && + if (slot && slot.to_s =~ /^(|latin|ascii|kanji)(#{__font_optkeys.join('|')})$/) fontkey = $2 # conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__confinfo_cmd << "-#{fontkey}")))) conf = tk_split_simplelist(tk_call_without_enc(*(__confinfo_cmd << "-#{fontkey}")), false, true) - conf[__configinfo_struct[:key]] = + conf[__configinfo_struct[:key]] = conf[__configinfo_struct[:key]][1..-1] if ( ! __configinfo_struct[:alias] \ @@ -4324,7 +4324,7 @@ module TkConfigMethod elsif ( __configinfo_struct[:alias] \ && conf.size == __configinfo_struct[:alias] + 1 ) if conf[__configinfo_struct[:alias]][0] == ?- - conf[__configinfo_struct[:alias]] = + conf[__configinfo_struct[:alias]] = conf[__configinfo_struct[:alias]][1..-1] end { conf[0] => conf[1] } @@ -4377,7 +4377,7 @@ module TkConfigMethod if ( __configinfo_struct[:default_value] \ && conf[__configinfo_struct[:default_value]] ) begin - conf[__configinfo_struct[:default_value]] = + conf[__configinfo_struct[:default_value]] = number(conf[__configinfo_struct[:default_value]]) rescue conf[__configinfo_struct[:default_value]] = nil @@ -4385,7 +4385,7 @@ module TkConfigMethod end if ( conf[__configinfo_struct[:current_value]] ) begin - conf[__configinfo_struct[:current_value]] = + conf[__configinfo_struct[:current_value]] = number(conf[__configinfo_struct[:current_value]]) rescue conf[__configinfo_struct[:current_value]] = nil @@ -4398,11 +4398,11 @@ module TkConfigMethod if ( __configinfo_struct[:default_value] \ && conf[__configinfo_struct[:default_value]] ) - conf[__configinfo_struct[:default_value]] = + conf[__configinfo_struct[:default_value]] = num_or_str(conf[__configinfo_struct[:default_value]]) end if ( conf[__configinfo_struct[:current_value]] ) - conf[__configinfo_struct[:current_value]] = + conf[__configinfo_struct[:current_value]] = num_or_str(conf[__configinfo_struct[:current_value]]) end @@ -4413,7 +4413,7 @@ module TkConfigMethod if ( __configinfo_struct[:default_value] \ && conf[__configinfo_struct[:default_value]] ) begin - conf[__configinfo_struct[:default_value]] = + conf[__configinfo_struct[:default_value]] = bool(conf[__configinfo_struct[:default_value]]) rescue conf[__configinfo_struct[:default_value]] = nil @@ -4421,7 +4421,7 @@ module TkConfigMethod end if ( conf[__configinfo_struct[:current_value]] ) begin - conf[__configinfo_struct[:current_value]] = + conf[__configinfo_struct[:current_value]] = bool(conf[__configinfo_struct[:current_value]]) rescue conf[__configinfo_struct[:current_value]] = nil @@ -4434,11 +4434,11 @@ module TkConfigMethod if ( __configinfo_struct[:default_value] \ && conf[__configinfo_struct[:default_value]] ) - conf[__configinfo_struct[:default_value]] = + conf[__configinfo_struct[:default_value]] = simplelist(conf[__configinfo_struct[:default_value]]) end if ( conf[__configinfo_struct[:current_value]] ) - conf[__configinfo_struct[:current_value]] = + conf[__configinfo_struct[:current_value]] = simplelist(conf[__configinfo_struct[:current_value]]) end @@ -4449,12 +4449,12 @@ module TkConfigMethod if ( __configinfo_struct[:default_value] \ && conf[__configinfo_struct[:default_value]] \ && conf[__configinfo_struct[:default_value]] =~ /^[0-9]/ ) - conf[__configinfo_struct[:default_value]] = + conf[__configinfo_struct[:default_value]] = list(conf[__configinfo_struct[:default_value]]) end if ( conf[__configinfo_struct[:current_value]] \ && conf[__configinfo_struct[:current_value]] =~ /^[0-9]/ ) - conf[__configinfo_struct[:current_value]] = + conf[__configinfo_struct[:current_value]] = list(conf[__configinfo_struct[:current_value]]) end @@ -4486,13 +4486,13 @@ module TkConfigMethod # conf = tk_split_list(_fromUTF8(tk_call_without_enc(*(__confinfo_cmd << "-#{slot}")))) conf = tk_split_list(tk_call_without_enc(*(__confinfo_cmd << "-#{slot}")), 0, false, true) end - conf[__configinfo_struct[:key]] = + conf[__configinfo_struct[:key]] = conf[__configinfo_struct[:key]][1..-1] if ( __configinfo_struct[:alias] \ && conf.size == __configinfo_struct[:alias] + 1 ) if conf[__configinfo_struct[:alias]][0] == ?- - conf[__configinfo_struct[:alias]] = + conf[__configinfo_struct[:alias]] = conf[__configinfo_struct[:alias]][1..-1] end { conf[0] => conf[1] } @@ -4506,7 +4506,7 @@ module TkConfigMethod # conf = tk_split_simplelist(conflist) tk_split_simplelist(tk_call_without_enc(*__confinfo_cmd), false, false).each{|conflist| conf = tk_split_simplelist(conflist, false, true) - conf[__configinfo_struct[:key]] = + conf[__configinfo_struct[:key]] = conf[__configinfo_struct[:key]][1..-1] optkey = conf[__configinfo_struct[:key]] @@ -4542,7 +4542,7 @@ module TkConfigMethod if ( __configinfo_struct[:default_value] \ && conf[__configinfo_struct[:default_value]] ) begin - conf[__configinfo_struct[:default_value]] = + conf[__configinfo_struct[:default_value]] = number(conf[__configinfo_struct[:default_value]]) rescue conf[__configinfo_struct[:default_value]] = nil @@ -4550,7 +4550,7 @@ module TkConfigMethod end if ( conf[__configinfo_struct[:current_value]] ) begin - conf[__configinfo_struct[:current_value]] = + conf[__configinfo_struct[:current_value]] = number(conf[__configinfo_struct[:current_value]]) rescue conf[__configinfo_struct[:current_value]] = nil @@ -4560,11 +4560,11 @@ module TkConfigMethod when /^(#{__numstrval_optkeys.join('|')})$/ if ( __configinfo_struct[:default_value] \ && conf[__configinfo_struct[:default_value]] ) - conf[__configinfo_struct[:default_value]] = + conf[__configinfo_struct[:default_value]] = num_or_str(conf[__configinfo_struct[:default_value]]) end if ( conf[__configinfo_struct[:current_value]] ) - conf[__configinfo_struct[:current_value]] = + conf[__configinfo_struct[:current_value]] = num_or_str(conf[__configinfo_struct[:current_value]]) end @@ -4572,7 +4572,7 @@ module TkConfigMethod if ( __configinfo_struct[:default_value] \ && conf[__configinfo_struct[:default_value]] ) begin - conf[__configinfo_struct[:default_value]] = + conf[__configinfo_struct[:default_value]] = bool(conf[__configinfo_struct[:default_value]]) rescue conf[__configinfo_struct[:default_value]] = nil @@ -4580,7 +4580,7 @@ module TkConfigMethod end if ( conf[__configinfo_struct[:current_value]] ) begin - conf[__configinfo_struct[:current_value]] = + conf[__configinfo_struct[:current_value]] = bool(conf[__configinfo_struct[:current_value]]) rescue conf[__configinfo_struct[:current_value]] = nil @@ -4590,11 +4590,11 @@ module TkConfigMethod when /^(#{__listval_optkeys.join('|')})$/ if ( __configinfo_struct[:default_value] \ && conf[__configinfo_struct[:default_value]] ) - conf[__configinfo_struct[:default_value]] = + conf[__configinfo_struct[:default_value]] = simplelist(conf[__configinfo_struct[:default_value]]) end if ( conf[__configinfo_struct[:current_value]] ) - conf[__configinfo_struct[:current_value]] = + conf[__configinfo_struct[:current_value]] = simplelist(conf[__configinfo_struct[:current_value]]) end @@ -4602,12 +4602,12 @@ module TkConfigMethod if ( __configinfo_struct[:default_value] \ && conf[__configinfo_struct[:default_value]] \ && conf[__configinfo_struct[:default_value]] =~ /^[0-9]/ ) - conf[__configinfo_struct[:default_value]] = + conf[__configinfo_struct[:default_value]] = list(conf[__configinfo_struct[:default_value]]) end if ( conf[__configinfo_struct[:current_value]] \ && conf[__configinfo_struct[:current_value]] =~ /^[0-9]/ ) - conf[__configinfo_struct[:current_value]] = + conf[__configinfo_struct[:current_value]] = list(conf[__configinfo_struct[:current_value]]) end @@ -4634,20 +4634,20 @@ module TkConfigMethod if ( __configinfo_struct[:default_value] \ && conf[__configinfo_struct[:default_value]] ) if conf[__configinfo_struct[:default_value]].index('{') - conf[__configinfo_struct[:default_value]] = - tk_split_list(conf[__configinfo_struct[:default_value]]) + conf[__configinfo_struct[:default_value]] = + tk_split_list(conf[__configinfo_struct[:default_value]]) else - conf[__configinfo_struct[:default_value]] = - tk_tcl2ruby(conf[__configinfo_struct[:default_value]]) + conf[__configinfo_struct[:default_value]] = + tk_tcl2ruby(conf[__configinfo_struct[:default_value]]) end end if conf[__configinfo_struct[:current_value]] if conf[__configinfo_struct[:current_value]].index('{') - conf[__configinfo_struct[:current_value]] = - tk_split_list(conf[__configinfo_struct[:current_value]]) + conf[__configinfo_struct[:current_value]] = + tk_split_list(conf[__configinfo_struct[:current_value]]) else - conf[__configinfo_struct[:current_value]] = - tk_tcl2ruby(conf[__configinfo_struct[:current_value]]) + conf[__configinfo_struct[:current_value]] = + tk_tcl2ruby(conf[__configinfo_struct[:current_value]]) end end end @@ -4655,7 +4655,7 @@ module TkConfigMethod if ( __configinfo_struct[:alias] \ && conf.size == __configinfo_struct[:alias] + 1 ) if conf[__configinfo_struct[:alias]][0] == ?- - conf[__configinfo_struct[:alias]] = + conf[__configinfo_struct[:alias]] = conf[__configinfo_struct[:alias]][1..-1] end ret[conf[0]] = conf[1] @@ -4717,7 +4717,7 @@ module TkConfigMethod end slot = conf[__configinfo_struct[:alias]] end while(org_slot != slot) - fail RuntimeError, + fail RuntimeError, "there is a configure alias loop about '#{org_slot}'" else ret = {} @@ -4731,7 +4731,7 @@ module TkConfigMethod end else # ! TkComm::GET_CONFIGINFO_AS_ARRAY ret = {} - configinfo(slot).each{|key, conf| + configinfo(slot).each{|key, conf| ret[key] = conf[-1] if conf.kind_of?(Array) } ret @@ -4804,13 +4804,13 @@ class TkObject<TkKernel cget(name) rescue if self.kind_of?(TkWindow) - fail NameError, + fail NameError, "unknown option '#{id}' for #{self.inspect} (deleted widget?)" else super(id, *args) end -# fail NameError, -# "undefined local variable or method `#{name}' for #{self.to_s}", +# fail NameError, +# "undefined local variable or method `#{name}' for #{self.to_s}", # error_at end else @@ -4834,14 +4834,14 @@ class TkObject<TkKernel if context.kind_of?(TkEvent::Event) context.generate(self, ((keys)? keys: {})) elsif keys - #tk_call('event', 'generate', path, + #tk_call('event', 'generate', path, # "<#{tk_event_sequence(context)}>", *hash_kv(keys)) - tk_call_without_enc('event', 'generate', path, - "<#{tk_event_sequence(context)}>", + tk_call_without_enc('event', 'generate', path, + "<#{tk_event_sequence(context)}>", *hash_kv(keys, true)) else #tk_call('event', 'generate', path, "<#{tk_event_sequence(context)}>") - tk_call_without_enc('event', 'generate', path, + tk_call_without_enc('event', 'generate', path, "<#{tk_event_sequence(context)}>") end end @@ -4874,10 +4874,10 @@ class TkWindow<TkObject end TkCommandNames = [].freeze - ## ==> If TkCommandNames[0] is a string (not a null string), - ## assume the string is a Tcl/Tk's create command of the widget class. + ## ==> If TkCommandNames[0] is a string (not a null string), + ## assume the string is a Tcl/Tk's create command of the widget class. WidgetClassName = ''.freeze - # WidgetClassNames[WidgetClassName] = self + # WidgetClassNames[WidgetClassName] = self ## ==> If self is a widget class, entry to the WidgetClassNames table. def self.to_eval self::WidgetClassName @@ -4890,8 +4890,8 @@ class TkWindow<TkObject widgetname = keys.delete('widgetname') install_win(if parent then parent.path end, widgetname) without_creating = keys.delete('without_creating') - # if without_creating && !widgetname - # fail ArgumentError, + # if without_creating && !widgetname + # fail ArgumentError, # "if set 'without_creating' to true, need to define 'widgetname'" # end elsif keys @@ -4899,8 +4899,8 @@ class TkWindow<TkObject widgetname = keys.delete('widgetname') install_win(if parent then parent.path end, widgetname) without_creating = keys.delete('without_creating') - # if without_creating && !widgetname - # fail ArgumentError, + # if without_creating && !widgetname + # fail ArgumentError, # "if set 'without_creating' to true, need to define 'widgetname'" # end else @@ -4992,7 +4992,7 @@ class TkWindow<TkObject tk_call_without_enc('destroy', @path) rescue # cannot rescue options error - fail e + fail e else # re-create widget tk_call_without_enc(cmd, @path, *hash_kv(keys, true)) @@ -5297,7 +5297,7 @@ class TkWindow<TkObject # conf[0] = conf[0][1..-1] # conf #else - # tk_split_simplelist(tk_call('place', + # tk_split_simplelist(tk_call('place', # 'configure', epath)).collect{|conflist| # conf = tk_split_simplelist(conflist) # conf[0] = conf[0][1..-1] @@ -5507,7 +5507,7 @@ class TkWindow<TkObject taglist else list(tk_call('bindtags', path)).collect{|tag| - if tag.kind_of?(String) + if tag.kind_of?(String) if cls = WidgetClassNames[tag] cls elsif btag = TkBindTag.id2obj(tag) |