From 94d960beb57ead291992a6ceb34871b377ade1d1 Mon Sep 17 00:00:00 2001 From: nagai Date: Mon, 11 Oct 2004 04:51:21 +0000 Subject: * ext/tk/lib/tk/*: untabify git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@7029 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/tk/lib/multi-tk.rb | 976 ++++++------ ext/tk/lib/remote-tk.rb | 34 +- ext/tk/lib/tk.rb | 1964 ++++++++++++------------ ext/tk/lib/tk/canvas.rb | 372 +++-- ext/tk/lib/tk/clock.rb | 24 +- ext/tk/lib/tk/composite.rb | 328 ++-- ext/tk/lib/tk/console.rb | 2 +- ext/tk/lib/tk/dialog.rb | 60 +- ext/tk/lib/tk/encodedstr.rb | 48 +- ext/tk/lib/tk/entry.rb | 6 +- ext/tk/lib/tk/event.rb | 38 +- ext/tk/lib/tk/font.rb | 806 +++++----- ext/tk/lib/tk/grid.rb | 50 +- ext/tk/lib/tk/image.rb | 34 +- ext/tk/lib/tk/itemconfig.rb | 1168 +++++++------- ext/tk/lib/tk/itemfont.rb | 184 +-- ext/tk/lib/tk/kinput.rb | 6 +- ext/tk/lib/tk/listbox.rb | 226 +-- ext/tk/lib/tk/menu.rb | 238 +-- ext/tk/lib/tk/menubar.rb | 20 +- ext/tk/lib/tk/menuspec.rb | 194 +-- ext/tk/lib/tk/msgcat.rb | 94 +- ext/tk/lib/tk/namespace.rb | 46 +- ext/tk/lib/tk/optiondb.rb | 162 +- ext/tk/lib/tk/optionobj.rb | 148 +- ext/tk/lib/tk/package.rb | 20 +- ext/tk/lib/tk/palette.rb | 8 +- ext/tk/lib/tk/panedwindow.rb | 132 +- ext/tk/lib/tk/place.rb | 50 +- ext/tk/lib/tk/root.rb | 22 +- ext/tk/lib/tk/scale.rb | 12 +- ext/tk/lib/tk/scrollable.rb | 32 +- ext/tk/lib/tk/scrollbar.rb | 10 +- ext/tk/lib/tk/scrollbox.rb | 6 +- ext/tk/lib/tk/selection.rb | 6 +- ext/tk/lib/tk/spinbox.rb | 6 +- ext/tk/lib/tk/text.rb | 994 ++++++------ ext/tk/lib/tk/textimage.rb | 14 +- ext/tk/lib/tk/textmark.rb | 6 +- ext/tk/lib/tk/texttag.rb | 60 +- ext/tk/lib/tk/textwindow.rb | 72 +- ext/tk/lib/tk/timer.rb | 78 +- ext/tk/lib/tk/toplevel.rb | 58 +- ext/tk/lib/tk/validation.rb | 198 +-- ext/tk/lib/tk/variable.rb | 386 ++--- ext/tk/lib/tk/virtevent.rb | 32 +- ext/tk/lib/tk/winfo.rb | 10 +- ext/tk/lib/tk/winpkg.rb | 32 +- ext/tk/lib/tk/wm.rb | 206 +-- ext/tk/lib/tk/xim.rb | 60 +- ext/tk/lib/tkclass.rb | 8 +- ext/tk/lib/tkextlib/ICONS/icons.rb | 58 +- ext/tk/lib/tkextlib/bwidget.rb | 12 +- ext/tk/lib/tkextlib/bwidget/dialog.rb | 14 +- ext/tk/lib/tkextlib/bwidget/listbox.rb | 10 +- ext/tk/lib/tkextlib/bwidget/messagedlg.rb | 108 +- ext/tk/lib/tkextlib/bwidget/notebook.rb | 2 +- ext/tk/lib/tkextlib/bwidget/passwddlg.rb | 2 +- ext/tk/lib/tkextlib/bwidget/tree.rb | 22 +- ext/tk/lib/tkextlib/itcl/incr_tcl.rb | 60 +- ext/tk/lib/tkextlib/itk/incr_tk.rb | 406 ++--- ext/tk/lib/tkextlib/iwidgets.rb | 4 +- ext/tk/lib/tkextlib/iwidgets/calendar.rb | 2 +- ext/tk/lib/tkextlib/iwidgets/entryfield.rb | 16 +- ext/tk/lib/tkextlib/iwidgets/hierarchy.rb | 34 +- ext/tk/lib/tkextlib/iwidgets/menubar.rb | 50 +- ext/tk/lib/tkextlib/iwidgets/notebook.rb | 2 +- ext/tk/lib/tkextlib/iwidgets/scrolledcanvas.rb | 12 +- ext/tk/lib/tkextlib/iwidgets/scrolledtext.rb | 346 ++--- ext/tk/lib/tkextlib/iwidgets/spinner.rb | 16 +- ext/tk/lib/tkextlib/iwidgets/toolbar.rb | 2 +- ext/tk/lib/tkextlib/pkg_checker.rb | 34 +- ext/tk/lib/tkextlib/tcllib/autoscroll.rb | 72 +- ext/tk/lib/tkextlib/tcllib/ctext.rb | 16 +- ext/tk/lib/tkextlib/tcllib/cursor.rb | 24 +- ext/tk/lib/tkextlib/tcllib/datefield.rb | 12 +- ext/tk/lib/tkextlib/tcllib/ip_entry.rb | 10 +- ext/tk/lib/tkextlib/tcllib/plotchart.rb | 258 ++-- ext/tk/lib/tkextlib/tcllib/style.rb | 4 +- ext/tk/lib/tkextlib/tcllib/tkpiechart.rb | 56 +- ext/tk/lib/tkextlib/tclx/tclx.rb | 30 +- ext/tk/lib/tkextlib/tile.rb | 28 +- ext/tk/lib/tkextlib/tkDND/shape.rb | 96 +- ext/tk/lib/tkextlib/tkDND/tkdnd.rb | 118 +- ext/tk/lib/tkextlib/tkHTML/htmlwidget.rb | 6 +- ext/tk/lib/tkextlib/tkimg.rb | 4 +- ext/tk/lib/tkextlib/tkimg/bmp.rb | 10 +- ext/tk/lib/tkextlib/tkimg/gif.rb | 10 +- ext/tk/lib/tkextlib/tkimg/ico.rb | 10 +- ext/tk/lib/tkextlib/tkimg/jpeg.rb | 10 +- ext/tk/lib/tkextlib/tkimg/pcx.rb | 10 +- ext/tk/lib/tkextlib/tkimg/pixmap.rb | 10 +- ext/tk/lib/tkextlib/tkimg/png.rb | 10 +- ext/tk/lib/tkextlib/tkimg/ppm.rb | 10 +- ext/tk/lib/tkextlib/tkimg/ps.rb | 10 +- ext/tk/lib/tkextlib/tkimg/sgi.rb | 10 +- ext/tk/lib/tkextlib/tkimg/sun.rb | 10 +- ext/tk/lib/tkextlib/tkimg/tga.rb | 10 +- ext/tk/lib/tkextlib/tkimg/tiff.rb | 10 +- ext/tk/lib/tkextlib/tkimg/window.rb | 10 +- ext/tk/lib/tkextlib/tkimg/xbm.rb | 10 +- ext/tk/lib/tkextlib/tkimg/xpm.rb | 10 +- ext/tk/lib/tkextlib/tktable/tktable.rb | 172 +-- ext/tk/lib/tkextlib/tktrans/tktrans.rb | 4 +- ext/tk/lib/tkextlib/treectrl/tktreectrl.rb | 56 +- ext/tk/lib/tkextlib/vu.rb | 4 +- ext/tk/lib/tkextlib/vu/charts.rb | 4 +- ext/tk/lib/tkextlib/vu/dial.rb | 4 +- ext/tk/lib/tkextlib/winico/winico.rb | 64 +- 109 files changed, 6095 insertions(+), 6065 deletions(-) (limited to 'ext/tk/lib') diff --git a/ext/tk/lib/multi-tk.rb b/ext/tk/lib/multi-tk.rb index 061123b79e..38e4b28dec 100644 --- a/ext/tk/lib/multi-tk.rb +++ b/ext/tk/lib/multi-tk.rb @@ -1,6 +1,6 @@ # -# multi-tk.rb - supports multi Tk interpreters -# by Hidetoshi NAGAI +# multi-tk.rb - supports multi Tk interpreters +# by Hidetoshi NAGAI require 'tcltklib' require 'tkutil' @@ -78,17 +78,17 @@ class MultiTkIp end def call(*args) begin - unless @ip.deleted? - @ip.cb_eval(@cmd, *args) - end + unless @ip.deleted? + @ip.cb_eval(@cmd, *args) + end rescue TkCallbackBreak, TkCallbackContinue => e - fail e + fail e rescue Exception => e - if @ip.safe? - # ignore - else - fail e - end + if @ip.safe? + # ignore + else + fail e + end end end }.freeze @@ -106,19 +106,19 @@ class MultiTkIp def _check_and_return(thread, exception, wait=0) unless thread unless exception.kind_of?(MultiTkIp_OK) || safe? - msg = "#{exception.class}: #{exception.message}" - begin - if @interp.deleted? - warn('Warning: ' + msg) - elsif @interp._eval_without_enc('info command bgerror').size != 0 - @interp._eval(@interp._merge_tklist('bgerror', msg)) - else - warn('Warning: ' + msg) - end - rescue Exception => e - warn('Warning: ' + msg) - warn('Warning: ' + e.message) - end + msg = "#{exception.class}: #{exception.message}" + begin + if @interp.deleted? + warn('Warning: ' + msg) + elsif @interp._eval_without_enc('info command bgerror').size != 0 + @interp._eval(@interp._merge_tklist('bgerror', msg)) + else + warn('Warning: ' + msg) + end + rescue Exception => e + warn('Warning: ' + msg) + warn('Warning: ' + e.message) + end end return nil end @@ -127,7 +127,7 @@ class MultiTkIp # no wait Thread.pass if thread.stop? - thread.raise exception + thread.raise exception end return thread end @@ -135,9 +135,9 @@ class MultiTkIp # wait to stop the caller thread wait.times{ if thread.stop? - # ready to send exception - thread.raise exception - return thread + # ready to send exception + thread.raise exception + return thread end # wait @@ -188,39 +188,39 @@ class MultiTkIp def _destroy_slaves_of_slaveIP(ip) unless ip.deleted? ip._split_tklist(ip._invoke('interp', 'slaves')).each{|name| - begin - ip._eval_without_enc("#{name} eval {foreach i [after info] {after cancel $i}}") - rescue Exception - end - begin - # ip._invoke('interp', 'eval', name, 'destroy', '.') - ip._invoke(name, 'eval', 'destroy', '.') - rescue Exception - end - - # safe_base? - if ip._eval_without_enc("catch {::safe::interpConfigure #{name}}") == '0' - begin - ip._eval_without_enc("::safe::interpDelete #{name}") - rescue Exception - end - end + begin + ip._eval_without_enc("#{name} eval {foreach i [after info] {after cancel $i}}") + rescue Exception + end + begin + # ip._invoke('interp', 'eval', name, 'destroy', '.') + ip._invoke(name, 'eval', 'destroy', '.') + rescue Exception + end + + # safe_base? + if ip._eval_without_enc("catch {::safe::interpConfigure #{name}}") == '0' + begin + ip._eval_without_enc("::safe::interpDelete #{name}") + rescue Exception + end + end =begin - if ip._invoke('interp', 'exists', name) == '1' - begin - ip._invoke(name, 'eval', 'exit') - rescue Exception - end - end + if ip._invoke('interp', 'exists', name) == '1' + begin + ip._invoke(name, 'eval', 'exit') + rescue Exception + end + end =end - unless ip.deleted? - if ip._invoke('interp', 'exists', name) == '1' - begin - ip._invoke('interp', 'delete', name) - rescue Exception - end - end - end + unless ip.deleted? + if ip._invoke('interp', 'exists', name) == '1' + begin + ip._invoke('interp', 'delete', name) + rescue Exception + end + end + end } end end @@ -233,139 +233,139 @@ class MultiTkIp rescue SystemExit => e # delete IP unless @interp.deleted? - @slave_ip_tbl.each{|name, subip| - _destroy_slaves_of_slaveIP(subip) - begin - subip._eval_without_enc("foreach i [after info] {after cancel $i}") - rescue Exception - end + @slave_ip_tbl.each{|name, subip| + _destroy_slaves_of_slaveIP(subip) + begin + subip._eval_without_enc("foreach i [after info] {after cancel $i}") + rescue Exception + end =begin - begin - subip._invoke('destroy', '.') unless subip.deleted? - rescue Exception - end + begin + subip._invoke('destroy', '.') unless subip.deleted? + rescue Exception + end =end - # safe_base? - if @interp._eval_without_enc("catch {::safe::interpConfigure #{name}}") == '0' - begin - @interp._eval_without_enc("::safe::interpDelete #{name}") - rescue Exception - else - next if subip.deleted? - end - end - if subip.respond_to?(:safe_base?) && subip.safe_base? && - !subip.deleted? - # do 'exit' to call the delete_hook procedure - begin - subip._eval_without_enc('exit') - rescue Exception - end - else - begin - subip.delete unless subip.deleted? - rescue Exception - end - end - } - - begin - @interp._eval_without_enc("foreach i [after info] {after cancel $i}") - rescue Exception - end - begin - @interp._invoke('destroy', '.') unless @interp.deleted? - rescue Exception - end - if @safe_base && !@interp.deleted? - # do 'exit' to call the delete_hook procedure - @interp._eval_without_enc('exit') - else - @interp.delete unless @interp.deleted? - end + # safe_base? + if @interp._eval_without_enc("catch {::safe::interpConfigure #{name}}") == '0' + begin + @interp._eval_without_enc("::safe::interpDelete #{name}") + rescue Exception + else + next if subip.deleted? + end + end + if subip.respond_to?(:safe_base?) && subip.safe_base? && + !subip.deleted? + # do 'exit' to call the delete_hook procedure + begin + subip._eval_without_enc('exit') + rescue Exception + end + else + begin + subip.delete unless subip.deleted? + rescue Exception + end + end + } + + begin + @interp._eval_without_enc("foreach i [after info] {after cancel $i}") + rescue Exception + end + begin + @interp._invoke('destroy', '.') unless @interp.deleted? + rescue Exception + end + if @safe_base && !@interp.deleted? + # do 'exit' to call the delete_hook procedure + @interp._eval_without_enc('exit') + else + @interp.delete unless @interp.deleted? + end end if e.backtrace[0] =~ /^(.+?):(\d+):in `(exit|exit!|abort)'/ - _check_and_return(thread, MultiTkIp_OK.new($3 == 'exit')) + _check_and_return(thread, MultiTkIp_OK.new($3 == 'exit')) else - _check_and_return(thread, MultiTkIp_OK.new(nil)) + _check_and_return(thread, MultiTkIp_OK.new(nil)) end if master? && !safe? && allow_ruby_exit? =begin - ObjectSpace.each_object(TclTkIp){|obj| - obj.delete unless obj.deleted? - } + ObjectSpace.each_object(TclTkIp){|obj| + obj.delete unless obj.deleted? + } =end - #exit(e.status) - fail e + #exit(e.status) + fail e end # break rescue SecurityError => e # in 'exit', 'exit!', and 'abort' : security error --> delete IP if e.backtrace[0] =~ /^(.+?):(\d+):in `(exit|exit!|abort)'/ - ret = ($3 == 'exit') - unless @interp.deleted? - @slave_ip_tbl.each{|name, subip| - _destroy_slaves_of_slaveIP(subip) - begin - subip._eval_without_enc("foreach i [after info] {after cancel $i}") - rescue Exception - end + ret = ($3 == 'exit') + unless @interp.deleted? + @slave_ip_tbl.each{|name, subip| + _destroy_slaves_of_slaveIP(subip) + begin + subip._eval_without_enc("foreach i [after info] {after cancel $i}") + rescue Exception + end =begin - begin - subip._invoke('destroy', '.') unless subip.deleted? - rescue Exception - end + begin + subip._invoke('destroy', '.') unless subip.deleted? + rescue Exception + end =end - # safe_base? - if @interp._eval_without_enc("catch {::safe::interpConfigure #{name}}") == '0' - begin - @interp._eval_without_enc("::safe::interpDelete #{name}") - rescue Exception - else - next if subip.deleted? - end - end - if subip.respond_to?(:safe_base?) && subip.safe_base? && - !subip.deleted? - # do 'exit' to call the delete_hook procedure - begin - subip._eval_without_enc('exit') - rescue Exception - end - else - begin - subip.delete unless subip.deleted? - rescue Exception - end - end - } - - begin - @interp._eval_without_enc("foreach i [after info] {after cancel $i}") - rescue Exception - end + # safe_base? + if @interp._eval_without_enc("catch {::safe::interpConfigure #{name}}") == '0' + begin + @interp._eval_without_enc("::safe::interpDelete #{name}") + rescue Exception + else + next if subip.deleted? + end + end + if subip.respond_to?(:safe_base?) && subip.safe_base? && + !subip.deleted? + # do 'exit' to call the delete_hook procedure + begin + subip._eval_without_enc('exit') + rescue Exception + end + else + begin + subip.delete unless subip.deleted? + rescue Exception + end + end + } + + begin + @interp._eval_without_enc("foreach i [after info] {after cancel $i}") + rescue Exception + end =begin - begin - @interp._invoke('destroy', '.') unless @interp.deleted? - rescue Exception - end + begin + @interp._invoke('destroy', '.') unless @interp.deleted? + rescue Exception + end =end - if @safe_base && !@interp.deleted? - # do 'exit' to call the delete_hook procedure - @interp._eval_without_enc('exit') - else - @interp.delete unless @interp.deleted? - end - end - _check_and_return(thread, MultiTkIp_OK.new(ret)) - # break + if @safe_base && !@interp.deleted? + # do 'exit' to call the delete_hook procedure + @interp._eval_without_enc('exit') + else + @interp.delete unless @interp.deleted? + end + end + _check_and_return(thread, MultiTkIp_OK.new(ret)) + # break else - # raise security error - _check_and_return(thread, e) + # raise security error + _check_and_return(thread, e) end rescue Exception => e @@ -381,16 +381,16 @@ class MultiTkIp def _receiver_eval_proc(last_thread, safe_level, thread, cmd, *args) if thread Thread.new{ - last_thread.join if last_thread - unless @interp.deleted? - _receiver_eval_proc_core(safe_level, thread, cmd, *args) - end + last_thread.join if last_thread + unless @interp.deleted? + _receiver_eval_proc_core(safe_level, thread, cmd, *args) + end } else Thread.new{ - unless @interp.deleted? - _receiver_eval_proc_core(safe_level, thread, cmd, *args) - end + unless @interp.deleted? + _receiver_eval_proc_core(safe_level, thread, cmd, *args) + end } last_thread end @@ -401,8 +401,8 @@ class MultiTkIp def _receiver_mainloop(check_root) Thread.new{ while !@interp.deleted? - break if @interp._invoke_without_enc('info', 'command', '.').size == 0 - sleep 0.5 + break if @interp._invoke_without_enc('info', 'command', '.').size == 0 + sleep 0.5 end } end @@ -415,54 +415,54 @@ class MultiTkIp last_thread = nil loop do - break if @interp.deleted? - thread, cmd, *args = @cmd_queue.deq - if thread == @system - # control command - case cmd - when 'set_safe_level' - begin - safe_level = args[0] if safe_level < args[0] - rescue Exception - end - when 'call_mainloop' - thread = args.shift - _check_and_return(thread, - MultiTkIp_OK.new(_receiver_mainloop(*args))) - else - # ignore - end - - else - # procedure - last_thread = _receiver_eval_proc(last_thread, safe_level, - thread, cmd, *args) - end + break if @interp.deleted? + thread, cmd, *args = @cmd_queue.deq + if thread == @system + # control command + case cmd + when 'set_safe_level' + begin + safe_level = args[0] if safe_level < args[0] + rescue Exception + end + when 'call_mainloop' + thread = args.shift + _check_and_return(thread, + MultiTkIp_OK.new(_receiver_mainloop(*args))) + else + # ignore + end + + else + # procedure + last_thread = _receiver_eval_proc(last_thread, safe_level, + thread, cmd, *args) + end end } # watchdog of receiver watchdog = Thread.new{ begin - loop do - sleep 1 - break unless receiver.alive? - end + loop do + sleep 1 + break unless receiver.alive? + end rescue Exception - # ignore all kind of Exception + # ignore all kind of Exception end # receiver is dead loop do - thread, cmd, *args = @cmd_queue.deq - next unless thread - if thread.alive? - if @interp.deleted? - thread.raise RuntimeError, 'the interpreter is already deleted' - else - thread.raise RuntimeError, - 'the interpreter no longer receives command procedures' - end - end + thread, cmd, *args = @cmd_queue.deq + next unless thread + if thread.alive? + if @interp.deleted? + thread.raise RuntimeError, 'the interpreter is already deleted' + else + thread.raise RuntimeError, + 'the interpreter no longer receives command procedures' + end + end end } @@ -528,38 +528,38 @@ class MultiTkIp @assign_request = Class.new(Exception){ def self.new(target, ret) - obj = super() - obj.target = target - obj.ret = ret - obj + obj = super() + obj.target = target + obj.ret = ret + obj end attr_accessor :target, :ret } @assign_thread = Thread.new{ loop do - begin - Thread.stop - rescue @assign_request=>req - begin - req.ret[0] = req.target.instance_eval{ - @cmd_receiver, @receiver_watchdog = - _create_receiver_and_watchdog(@safe_level[0]) - @threadgroup.add @cmd_receiver - @threadgroup.add @receiver_watchdog - @threadgroup.enclose - true - } - rescue Exception=>e - begin - req.ret[0] = e - rescue Exception - # ignore - end - end - rescue Exception - # ignore - end + begin + Thread.stop + rescue @assign_request=>req + begin + req.ret[0] = req.target.instance_eval{ + @cmd_receiver, @receiver_watchdog = + _create_receiver_and_watchdog(@safe_level[0]) + @threadgroup.add @cmd_receiver + @threadgroup.add @receiver_watchdog + @threadgroup.enclose + true + } + rescue Exception=>e + begin + req.ret[0] = e + rescue Exception + # ignore + end + end + rescue Exception + # ignore + end end } @@ -567,14 +567,14 @@ class MultiTkIp ret = [nil] @assign_thread.raise(@assign_request.new(target, ret)) while ret[0] == nil - unless @assign_thread.alive? - raise RuntimeError, 'lost the thread to assign a receiver and a watchdog thread' - end + unless @assign_thread.alive? + raise RuntimeError, 'lost the thread to assign a receiver and a watchdog thread' + end end if ret[0].kind_of?(Exception) - raise ret[0] + raise ret[0] else - ret[0] + ret[0] end end @@ -592,21 +592,21 @@ class MultiTkIp # trust if on ThreadGroup::Default or @@DEFAULT_MASTER's ThreadGroup if @@IP_TABLE[Thread.current.group] == @@DEFAULT_MASTER begin - class << subclass - self.methods.each{|m| - begin - unless m == '__id__' || m == '__send__' || m == 'freeze' - undef_method(m) - end - rescue Exception - # ignore all exceptions - end - } - end + class << subclass + self.methods.each{|m| + begin + unless m == '__id__' || m == '__send__' || m == 'freeze' + undef_method(m) + end + rescue Exception + # ignore all exceptions + end + } + end ensure - subclass.freeze - fail SecurityError, - "cannot create subclass of MultiTkIp on a untrusted ThreadGroup" + subclass.freeze + fail SecurityError, + "cannot create subclass of MultiTkIp on a untrusted ThreadGroup" end end end @@ -629,13 +629,13 @@ class MultiTkIp keys.each{|k,v| k_str = k.to_s if k_str == 'name' - name = v + name = v elsif k_str == 'safe' - safe = v + safe = v elsif SAFE_OPT_LIST.member?(k_str) - safe_opts[k_str] = v + safe_opts[k_str] = v else - tk_opts[k_str] = v + tk_opts[k_str] = v end } @@ -664,15 +664,15 @@ class MultiTkIp # check 'display' if !new_keys.key?('display') begin - #new_keys['display'] = @interp._invoke('winfo screen .') - new_keys['display'] = @interp._invoke('winfo', 'screen', '.') + #new_keys['display'] = @interp._invoke('winfo screen .') + new_keys['display'] = @interp._invoke('winfo', 'screen', '.') rescue - if ENV[DISPLAY] - new_keys['display'] = ENV[DISPLAY] - elsif !new_keys.key?('use') - warn "Warning: no screen info or ENV[DISPLAY], so use ':0.0'" - new_keys['display'] = ':0.0' - end + if ENV[DISPLAY] + new_keys['display'] = ENV[DISPLAY] + elsif !new_keys.key?('use') + warn "Warning: no screen info or ENV[DISPLAY], so use ':0.0'" + new_keys['display'] = ':0.0' + end end end @@ -681,30 +681,30 @@ class MultiTkIp # given 'use' case new_keys['use'] when TkWindow - new_keys['use'] = TkWinfo.id(new_keys['use']) - #assoc_display = @interp._eval('winfo screen .') - assoc_display = @interp._invoke('winfo', 'screen', '.') + new_keys['use'] = TkWinfo.id(new_keys['use']) + #assoc_display = @interp._eval('winfo screen .') + assoc_display = @interp._invoke('winfo', 'screen', '.') when /^\..*/ - new_keys['use'] = @interp._invoke('winfo', 'id', new_keys['use']) - assoc_display = @interp._invoke('winfo', 'screen', new_keys['use']) + new_keys['use'] = @interp._invoke('winfo', 'id', new_keys['use']) + assoc_display = @interp._invoke('winfo', 'screen', new_keys['use']) else - begin - pathname = @interp._invoke('winfo', 'pathname', new_keys['use']) - assco_display = @interp._invoke('winfo', 'screen', pathname) - rescue - assoc_display = new_keys['display'] - end + begin + pathname = @interp._invoke('winfo', 'pathname', new_keys['use']) + assco_display = @interp._invoke('winfo', 'screen', pathname) + rescue + assoc_display = new_keys['display'] + end end # match display? if assoc_display != new_keys['display'] - if optkeys.keys?(:display) || optkeys.keys?('display') - fail RuntimeError, - "conflicting 'display'=>#{new_keys['display']} " + - "and display '#{assoc_display}' on 'use'=>#{new_keys['use']}" - else - new_keys['display'] = assoc_display - end + if optkeys.keys?(:display) || optkeys.keys?('display') + fail RuntimeError, + "conflicting 'display'=>#{new_keys['display']} " + + "and display '#{assoc_display}' on 'use'=>#{new_keys['use']}" + else + new_keys['display'] = assoc_display + end end end @@ -746,11 +746,11 @@ class MultiTkIp # procedure to delete slave interpreter slave_delete_proc = proc{ unless slave_ip.deleted? - #if slave_ip._invoke('info', 'command', '.') != "" - # slave_ip._invoke('destroy', '.') - #end - #slave_ip.delete - slave_ip._eval_without_enc('exit') + #if slave_ip._invoke('info', 'command', '.') != "" + # slave_ip._invoke('destroy', '.') + #end + #slave_ip.delete + slave_ip._eval_without_enc('exit') end top.destroy if top.winfo_exist? } @@ -763,15 +763,15 @@ class MultiTkIp fc.bindtags = fc.bindtags.unshift(tag) TkFrame.new(fc, :bd=>0){|f| - TkButton.new(f, - :text=>'Delete', :bd=>1, :padx=>2, :pady=>0, - :highlightthickness=>0, :command=>slave_delete_proc - ).pack(:side=>:right, :fill=>:both) - f.pack(:side=>:right, :fill=>:both, :expand=>true) + TkButton.new(f, + :text=>'Delete', :bd=>1, :padx=>2, :pady=>0, + :highlightthickness=>0, :command=>slave_delete_proc + ).pack(:side=>:right, :fill=>:both) + f.pack(:side=>:right, :fill=>:both, :expand=>true) } TkLabel.new(fc, :text=>msg, :padx=>2, :pady=>0, - :anchor=>:w).pack(:side=>:left, :fill=>:both, :expand=>true) + :anchor=>:w).pack(:side=>:left, :fill=>:both, :expand=>true) fc.pack(:side=>:bottom, :fill=>:x) } @@ -803,11 +803,11 @@ class MultiTkIp if tk_opts tk_opts = __check_safetk_optkeys(tk_opts) if tk_opts.key?('use') - @slave_ip_top[ip_name] = '' + @slave_ip_top[ip_name] = '' else - tk_opts, top_path = __create_safetk_frame(slave_ip, ip_name, app_name, - tk_opts) - @slave_ip_top[ip_name] = top_path + tk_opts, top_path = __create_safetk_frame(slave_ip, ip_name, app_name, + tk_opts) + @slave_ip_top[ip_name] = top_path end @interp._eval("::safe::loadTk #{ip_name} #{_keys2opts(tk_opts)}") else @@ -816,13 +816,13 @@ class MultiTkIp if safe_opts.key?('deleteHook') || safe_opts.key?(:deleteHook) @interp._eval("::safe::interpConfigure #{ip_name} " + - _keys2opts(safe_opts)) + _keys2opts(safe_opts)) else @interp._eval("::safe::interpConfigure #{ip_name} " + - _keys2opts(safe_opts) + '-deleteHook {' + - TkComm._get_eval_string(proc{|slave| - self._default_delete_hook(slave) - }) + '}') + _keys2opts(safe_opts) + '-deleteHook {' + + TkComm._get_eval_string(proc{|slave| + self._default_delete_hook(slave) + }) + '}') end [slave_ip, ip_name] @@ -890,34 +890,34 @@ class MultiTkIp @ip_name = nil if safe - safe = $SAFE if safe < $SAFE - @safe_level = [safe] + safe = $SAFE if safe < $SAFE + @safe_level = [safe] else - @safe_level = [$SAFE] + @safe_level = [$SAFE] end else # create slave-ip if safeip || master.safe? - @safe_base = true - @interp, @ip_name = master.__create_safe_slave_obj(safe_opts, - name, tk_opts) - if safe - safe = master.safe_level if safe < master.safe_level - @safe_level = [safe] - else - @safe_level = [4] - end + @safe_base = true + @interp, @ip_name = master.__create_safe_slave_obj(safe_opts, + name, tk_opts) + if safe + safe = master.safe_level if safe < master.safe_level + @safe_level = [safe] + else + @safe_level = [4] + end else - @interp, @ip_name = master.__create_trusted_slave_obj(name, tk_opts) - if safe - safe = master.safe_level if safe < master.safe_level - @safe_level = [safe] - else - @safe_level = [master.safe_level] - end + @interp, @ip_name = master.__create_trusted_slave_obj(name, tk_opts) + if safe + safe = master.safe_level if safe < master.safe_level + @safe_level = [safe] + else + @safe_level = [master.safe_level] + end end @set_alias_proc = proc{|name| - master._invoke('interp', 'alias', @ip_name, name, '', name) + master._invoke('interp', 'alias', @ip_name, name, '', name) }.freeze end @@ -959,22 +959,22 @@ class MultiTkIp if @slave_ip_top[slave].kind_of?(String) # call default hook of safetk.tcl (ignore exceptions) if @slave_ip_top[slave] == '' - begin - @interp._eval("::safe::disallowTk #{slave}") - rescue - warn("Waring: fail to call '::safe::disallowTk'") if $DEBUG - end + begin + @interp._eval("::safe::disallowTk #{slave}") + rescue + warn("Waring: fail to call '::safe::disallowTk'") if $DEBUG + end else # toplevel path - begin - @interp._eval("::safe::tkDelete {} #{@slave_ip_top[slave]} #{slave}") - rescue - warn("Waring: fail to call '::safe::tkDelete'") if $DEBUG - begin - @interp._eval("destroy #{@slave_ip_top[slave]}") - rescue - warn("Waring: fail to destroy toplevel") if $DEBUG - end - end + begin + @interp._eval("::safe::tkDelete {} #{@slave_ip_top[slave]} #{slave}") + rescue + warn("Waring: fail to call '::safe::tkDelete'") if $DEBUG + begin + @interp._eval("destroy #{@slave_ip_top[slave]}") + rescue + warn("Waring: fail to destroy toplevel") if $DEBUG + end + end end end @slave_ip_tbl.delete(slave) @@ -998,8 +998,8 @@ class MultiTkIp else ip = @@IP_TABLE[Thread.current.group] unless ip - fail SecurityError, - "cannot call Tk methods on #{Thread.current.inspect}" + fail SecurityError, + "cannot call Tk methods on #{Thread.current.inspect}" end ip end @@ -1019,7 +1019,7 @@ class << MultiTkIp elsif safe.kind_of?(Integer) raise ArgumentError, "unexpected argument(s)" unless keys.kind_of?(Hash) if !keys.key?(:safe) && !keys.key?('safe') - keys[:safe] = safe + keys[:safe] = safe end elsif safe == nil # do nothing @@ -1040,7 +1040,7 @@ class << MultiTkIp elsif safe.kind_of?(Integer) raise ArgumentError, "unexpected argument(s)" unless keys.kind_of?(Hash) if !keys.key?(:safe) && !keys.key?('safe') - keys[:safe] = safe + keys[:safe] = safe end elsif safe == nil # do nothing @@ -1060,7 +1060,7 @@ class << MultiTkIp elsif safe.kind_of?(Integer) raise ArgumentError, "unexpected argument(s)" unless keys.kind_of?(Hash) if !keys.key?(:safe) && !keys.key?('safe') - keys[:safe] = safe + keys[:safe] = safe end else raise ArgumentError, "unexpected argument(s)" @@ -1082,9 +1082,9 @@ class MultiTkIp s << ':master' else if @interp.safe? - s << ':safe-slave' + s << ':safe-slave' else - s << ':trusted-slave' + s << ':trusted-slave' end end s << '>' @@ -1144,11 +1144,11 @@ class MultiTkIp def slaves(all = false) @interp._invoke('interp','slaves').split.map!{|name| if @slave_ip_tbl.key?(name) - @slave_ip_tbl[name] + @slave_ip_tbl[name] elsif all - name + name else - nil + nil end }.compact! end @@ -1197,9 +1197,9 @@ class MultiTkIp init_ip_env.each{|script| script.call(self)} add_tk_procs.each{|name, args, body| if master? - @interp._invoke('proc', name, args, body) if args && body + @interp._invoke('proc', name, args, body) if args && body else - @set_alias_proc.call(name) + @set_alias_proc.call(name) end } end @@ -1226,7 +1226,7 @@ class MultiTkIp @@TK_TABLE_LIST << obj obj.instance_eval <<-EOD def self.method_missing(m, *args) - MultiTkIp.tk_object_table(#{id}).__send__(m, *args) + MultiTkIp.tk_object_table(#{id}).__send__(m, *args) end EOD obj.freeze @@ -1285,23 +1285,23 @@ class MultiTkIp # on IP thread if (@cmd_receiver == Thread.current) begin - ret = cmd.call(*args) + ret = cmd.call(*args) rescue SystemExit - # exit IP - warn("Warning: "+ $! + " on " + self.inspect) if $DEBUG - begin - self._eval_without_enc('exit') - rescue Exception - end - self.delete - ret = nil + # exit IP + warn("Warning: "+ $! + " on " + self.inspect) if $DEBUG + begin + self._eval_without_enc('exit') + rescue Exception + end + self.delete + ret = nil rescue Exception => e - if $DEBUG - warn("Warning: " + e.class.inspect + - ((e.message.length > 0)? ' "' + e.message + '"': '') + - " on " + self.inspect) - end - ret = e + if $DEBUG + warn("Warning: " + e.class.inspect + + ((e.message.length > 0)? ' "' + e.message + '"': '') + + " on " + self.inspect) + end + ret = e end return ret end @@ -1309,15 +1309,15 @@ class MultiTkIp # send cmd to the proc-queue unless req_val begin - @cmd_queue.enq([nil, cmd, *args]) + @cmd_queue.enq([nil, cmd, *args]) rescue Exception => e - # ignore - if $DEBUG || true - warn("Warning: " + e.class.inspect + - ((e.message.length > 0)? ' "' + e.message + '"': '') + - " on " + self.inspect) - end - return e + # ignore + if $DEBUG || true + warn("Warning: " + e.class.inspect + + ((e.message.length > 0)? ' "' + e.message + '"': '') + + " on " + self.inspect) + end + return e end return nil end @@ -1333,20 +1333,20 @@ class MultiTkIp # exit IP warn("Warning: " + $! + " on " + self.inspect) if $DEBUG begin - self._eval_without_enc('exit') + self._eval_without_enc('exit') rescue Exception end if !safe? && allow_ruby_exit? - self.delete - fail e + self.delete + fail e else - self.delete + self.delete end rescue Exception => e if $DEBUG - warn("Warning: " + e.class.inspect + - ((e.message.length > 0)? ' "' + e.message + '"': '') + - " on " + self.inspect) + warn("Warning: " + e.class.inspect + + ((e.message.length > 0)? ' "' + e.message + '"': '') + + " on " + self.inspect) end return e end @@ -1388,14 +1388,14 @@ class MultiTkIp cmd = Proc.new else unless (cmd = args.shift) - fail ArgumentError, "A Proc or Method object is expected for 1st argument" + fail ArgumentError, "A Proc or Method object is expected for 1st argument" end end eval_proc_core(true, - proc{|safe, *params| - $SAFE=safe; Thread.new(*params, &cmd).value - }, - *args) + proc{|safe, *params| + $SAFE=safe; Thread.new(*params, &cmd).value + }, + *args) end alias call eval_proc @@ -1404,15 +1404,15 @@ class MultiTkIp cmd = Proc.new else unless (cmd = args.shift) - fail ArgumentError, "A Proc or Method object is expected for 1st argument" + fail ArgumentError, "A Proc or Method object is expected for 1st argument" end end Thread.new{ eval_proc_core(false, - proc{|safe, *params| - $SAFE=safe; Thread.new(*params, &cmd).value - }, - *args) + proc{|safe, *params| + $SAFE=safe; Thread.new(*params, &cmd).value + }, + *args) } end alias background_eval_proc bg_eval_proc @@ -1436,7 +1436,7 @@ class MultiTkIp end Thread.new{ eval_proc_core(true, - proc{|safe| $SAFE=safe; Kernel.eval(cmd, *eval_args)}) + proc{|safe| $SAFE=safe; Kernel.eval(cmd, *eval_args)}) } end alias background_eval_string bg_eval_string @@ -1723,35 +1723,35 @@ class MultiTkIp #return self if self != @@DEFAULT_MASTER if self != @@DEFAULT_MASTER if @wait_on_mainloop[0] - begin - @wait_on_mainloop[1] = true - @cmd_queue.enq([@system, 'call_mainloop', - Thread.current, check_root]) - Thread.stop - rescue MultiTkIp_OK => ret - # return value - @wait_on_mainloop[1] = false - return ret.value.value - rescue SystemExit - # exit IP - warn("Warning: " + $! + " on " + self.inspect) if $DEBUG - @wait_on_mainloop[1] = false - begin - self._eval_without_enc('exit') - rescue Exception - end - self.delete - rescue Exception => e - if $DEBUG - warn("Warning: " + e.class.inspect + - ((e.message.length > 0)? ' "' + e.message + '"': '') + - " on " + self.inspect) - end - @wait_on_mainloop[1] = false - return e - ensure - @wait_on_mainloop[1] = false - end + begin + @wait_on_mainloop[1] = true + @cmd_queue.enq([@system, 'call_mainloop', + Thread.current, check_root]) + Thread.stop + rescue MultiTkIp_OK => ret + # return value + @wait_on_mainloop[1] = false + return ret.value.value + rescue SystemExit + # exit IP + warn("Warning: " + $! + " on " + self.inspect) if $DEBUG + @wait_on_mainloop[1] = false + begin + self._eval_without_enc('exit') + rescue Exception + end + self.delete + rescue Exception => e + if $DEBUG + warn("Warning: " + e.class.inspect + + ((e.message.length > 0)? ' "' + e.message + '"': '') + + " on " + self.inspect) + end + @wait_on_mainloop[1] = false + return e + ensure + @wait_on_mainloop[1] = false + end end return end @@ -1762,27 +1762,27 @@ class MultiTkIp @wait_on_mainloop[1] = false else begin - @wait_on_mainloop[1] = true - loop do - break unless self.alive? - if check_root - begin - break if TclTkLib.num_of_mainwindows == 0 - rescue Exception - break - end - end - @interp.mainloop(check_root) - end + @wait_on_mainloop[1] = true + loop do + break unless self.alive? + if check_root + begin + break if TclTkLib.num_of_mainwindows == 0 + rescue Exception + break + end + end + @interp.mainloop(check_root) + end #rescue StandardError rescue Exception - if TclTkLib.mainloop_abort_on_exception != nil - STDERR.print("Warning: Tk mainloop receives ", $!.class.inspect, - " exception (ignore) : ", $!.message, "\n"); - end - retry + if TclTkLib.mainloop_abort_on_exception != nil + STDERR.print("Warning: Tk mainloop receives ", $!.class.inspect, + " exception (ignore) : ", $!.message, "\n"); + end + retry ensure - @wait_on_mainloop[1] = false + @wait_on_mainloop[1] = false end end self @@ -1813,36 +1813,36 @@ class MultiTkIp _destroy_slaves_of_slaveIP(subip) =begin begin - subip._invoke('destroy', '.') unless subip.deleted? + subip._invoke('destroy', '.') unless subip.deleted? rescue Exception end =end begin - subip._eval_without_enc("foreach i [after info] {after cancel $i}") + subip._eval_without_enc("foreach i [after info] {after cancel $i}") rescue Exception end # safe_base? if @interp._eval_without_enc("catch {::safe::interpConfigure #{name}}") == '0' - begin - @interp._eval_without_enc("::safe::interpDelete #{name}") - rescue Exception - else - next if subip.deleted? - end + begin + @interp._eval_without_enc("::safe::interpDelete #{name}") + rescue Exception + else + next if subip.deleted? + end end if subip.respond_to?(:safe_base?) && subip.safe_base? && - !subip.deleted? - # do 'exit' to call the delete_hook procedure - begin - subip._eval_without_enc('exit') - rescue Exception - end + !subip.deleted? + # do 'exit' to call the delete_hook procedure + begin + subip._eval_without_enc('exit') + rescue Exception + end else - begin - subip.delete unless subip.deleted? - rescue Exception - end + begin + subip.delete unless subip.deleted? + rescue Exception + end end } @@ -1872,9 +1872,9 @@ class MultiTkIp def abort(msg = nil) if master? if msg - Kernel.abort(msg) + Kernel.abort(msg) else - Kernel.abort + Kernel.abort end else # ignore msg @@ -2076,7 +2076,7 @@ class MultiTkIp def def_alias(slave, new_cmd, org_cmd, *args) ret = @interp._invoke('interp', 'alias', _slavearg(slave), new_cmd, - '', org_cmd, *args) + '', org_cmd, *args) (ret == new_cmd)? self: nil end def self.def_alias(slave, new_cmd, org_cmd, *args) @@ -2161,7 +2161,7 @@ class MultiTkIp def invoke_hidden_on_global(slave, cmd, *args) @interp._invoke('interp', 'invokehidden', _slavearg(slave), - '-global', cmd, *args) + '-global', cmd, *args) end def self.invoke_hidden_on_global(slave, cmd, *args) __getip.invoke_hidden_on_global(slave, cmd, *args) @@ -2178,7 +2178,7 @@ class MultiTkIp def recursion_limit(slave = '', limit = None) number(@interp._invoke('interp', 'recursionlimit', - _slavearg(slave), limit)) + _slavearg(slave), limit)) end def self.recursion_limit(slave = '', limit = None) __getip.recursion_limit(slave) @@ -2279,7 +2279,7 @@ class MultiTkIp ip._eval('::safe::interpConfigure ' + @ip_name + ' ' + _keys2opts(slot)) else ip._eval('::safe::interpConfigure ' + @ip_name + ' ' + - "-#{slot} #{_get_eval_string(value)}") + "-#{slot} #{_get_eval_string(value)}") end self end @@ -2289,28 +2289,28 @@ class MultiTkIp ret = {} if slot conf = _lst2ary(ip._eval("::safe::interpConfigure " + - @ip_name + " -#{slot}")) + @ip_name + " -#{slot}")) if conf[0] == '-deleteHook' - if conf[1] =~ /^rb_out\S* (c(_\d+_)?\d+)/ - ret[conf[0][1..-1]] = MultiTkIp._tk_cmd_tbl[$1] - else - ret[conf[0][1..-1]] = conf[1] - end + if conf[1] =~ /^rb_out\S* (c(_\d+_)?\d+)/ + ret[conf[0][1..-1]] = MultiTkIp._tk_cmd_tbl[$1] + else + ret[conf[0][1..-1]] = conf[1] + end else - ret[conf[0][1..-1]] = conf[1] + ret[conf[0][1..-1]] = conf[1] end else Hash[*_lst2ary(ip._eval("::safe::interpConfigure " + - @ip_name))].each{|k, v| - if k == '-deleteHook' - if v =~ /^rb_out\S* (c(_\d+_)?\d+)/ - ret[k[1..-1]] = MultiTkIp._tk_cmd_tbl[$1] - else - ret[k[1..-1]] = v - end - else - ret[k[1..-1]] = v - end + @ip_name))].each{|k, v| + if k == '-deleteHook' + if v =~ /^rb_out\S* (c(_\d+_)?\d+)/ + ret[k[1..-1]] = MultiTkIp._tk_cmd_tbl[$1] + else + ret[k[1..-1]] = v + end + else + ret[k[1..-1]] = v + end } end ret diff --git a/ext/tk/lib/remote-tk.rb b/ext/tk/lib/remote-tk.rb index 77dbacfb13..1ef5310bde 100644 --- a/ext/tk/lib/remote-tk.rb +++ b/ext/tk/lib/remote-tk.rb @@ -1,6 +1,6 @@ # -# remote-tk.rb - supports to control remote Tk interpreters -# by Hidetoshi NAGAI +# remote-tk.rb - supports to control remote Tk interpreters +# by Hidetoshi NAGAI if defined? MultiTkIp fail RuntimeError, "'remote-tk' library must be required before requiring 'multi-tk'" @@ -137,14 +137,14 @@ class RemoteTkIp return nil if timeout < 1 @ret_val.value = '' @interp._invoke('send', '-async', @remote, - 'send', '-async', Tk.appname, - "set #{@ret_val.id} ready") + 'send', '-async', Tk.appname, + "set #{@ret_val.id} ready") Tk.update if @ret_val != 'ready' (1..(timeout*5)).each{ - sleep 0.2 - Tk.update - break if @ret_val == 'ready' + sleep 0.2 + Tk.update + break if @ret_val == 'ready' } end @ret_val.value == 'ready' @@ -154,16 +154,16 @@ class RemoteTkIp def _create_connection ip_id = '_' + @interp._invoke('send', @remote, <<-'EOS') + '_' if {[catch {set _rubytk_control_ip_id_} ret] != 0} { - set _rubytk_control_ip_id_ 0 + set _rubytk_control_ip_id_ 0 } else { - set _rubytk_control_ip_id_ [expr $ret + 1] + set _rubytk_control_ip_id_ [expr $ret + 1] } return $_rubytk_control_ip_id_ EOS @interp._invoke('send', @remote, <<-EOS) proc rb_out#{ip_id} args { - send #{@appname} rb_out \$args + send #{@appname} rb_out \$args } EOS @@ -182,17 +182,17 @@ class RemoteTkIp cmds = @interp._merge_tklist(*_conv_args([], enc_mode, *cmds)) if @displayof if async - @interp.__invoke('send', '-async', '-displayof', @displayof, - '--', @remote, *cmds) + @interp.__invoke('send', '-async', '-displayof', @displayof, + '--', @remote, *cmds) else - @interp.__invoke('send', '-displayof', @displayof, - '--', @remote, *cmds) + @interp.__invoke('send', '-displayof', @displayof, + '--', @remote, *cmds) end else if async - @interp.__invoke('send', '-async', '--', @remote, *cmds) + @interp.__invoke('send', '-async', '--', @remote, *cmds) else - @interp.__invoke('send', '--', @remote, *cmds) + @interp.__invoke('send', '--', @remote, *cmds) end end end @@ -271,7 +271,7 @@ class RemoteTkIp def deleted? if @displayof lst = @interp._invoke_without_enc('winfo', 'interps', - '-displayof', @displayof) + '-displayof', @displayof) else lst = @interp._invoke_without_enc('winfo', 'interps') end diff --git a/ext/tk/lib/tk.rb b/ext/tk/lib/tk.rb index a5d2645e98..5fa4665922 100644 --- a/ext/tk/lib/tk.rb +++ b/ext/tk/lib/tk.rb @@ -1,7 +1,7 @@ # -# tk.rb - Tk interface module using tcltklib -# $Date$ -# by Yukihiro Matsumoto +# tk.rb - Tk interface module using tcltklib +# $Date$ +# by Yukihiro Matsumoto # use Shigehiro's tcltklib require 'tcltklib' @@ -96,32 +96,32 @@ module TkComm else # ruby_class == nil mods = TkExtlibAutoloadModule.find_all{|m| m.const_defined?(tk_class)} mods.each{|mod| - begin - mod.const_get(tk_class) # auto_load - break if (ruby_class = WidgetClassNames[tk_class]) - rescue LoadError - # ignore load error - end + begin + mod.const_get(tk_class) # auto_load + break if (ruby_class = WidgetClassNames[tk_class]) + rescue LoadError + # ignore load error + end } unless ruby_class - std_class = 'Tk' << tk_class - if Object.const_defined?(std_class) - Object.const_get(std_class) # auto_load - ruby_class = WidgetClassNames[tk_class] - end + std_class = 'Tk' << tk_class + if Object.const_defined?(std_class) + Object.const_get(std_class) # auto_load + ruby_class = WidgetClassNames[tk_class] + end end if ruby_class - # found - ruby_class_name = ruby_class.name - gen_class_name = ruby_class_name - classname_def = '' + # found + ruby_class_name = ruby_class.name + gen_class_name = ruby_class_name + classname_def = '' else - # unknown - ruby_class_name = 'TkWindow' - gen_class_name = 'TkWidget_' + tk_class - classname_def = "WidgetClassName = '#{tk_class}'.freeze" + # unknown + ruby_class_name = 'TkWindow' + gen_class_name = 'TkWidget_' + tk_class + classname_def = "WidgetClassName = '#{tk_class}'.freeze" end end @@ -135,19 +135,19 @@ module TkComm else mod = TkExtlibAutoloadModule.find{|m| m.const_defined?(tk_class)} if mod - ruby_class_name = mod.name + '::' + tk_class - gen_class_name = ruby_class_name - classname_def = '' + ruby_class_name = mod.name + '::' + tk_class + gen_class_name = ruby_class_name + classname_def = '' elsif Object.const_defined?('Tk' + tk_class) - ruby_class_name = 'Tk' + tk_class - # gen_class_name = ruby_class_name + 'GeneratedOnTk' - gen_class_name = ruby_class_name - classname_def = '' + ruby_class_name = 'Tk' + tk_class + # gen_class_name = ruby_class_name + 'GeneratedOnTk' + gen_class_name = ruby_class_name + classname_def = '' else - ruby_class_name = 'TkWindow' - # gen_class_name = ruby_class_name + tk_class + 'GeneratedOnTk' - gen_class_name = 'TkWidget_' + tk_class - classname_def = "WidgetClassName = '#{tk_class}'.freeze" + ruby_class_name = 'TkWindow' + # gen_class_name = ruby_class_name + tk_class + 'GeneratedOnTk' + gen_class_name = 'TkWidget_' + tk_class + classname_def = "WidgetClassName = '#{tk_class}'.freeze" end end =end @@ -165,9 +165,9 @@ module TkComm gen_class_name.split('::').each{|klass| next if klass == '' if base.const_defined?(klass) - base = base.class_eval klass + base = base.class_eval klass else - base = base.class_eval "class #{klass}<#{ruby_class_name} + base = base.class_eval "class #{klass}<#{ruby_class_name} #{classname_def} end #{klass}" @@ -215,19 +215,19 @@ module TkComm val.gsub(/\\ /, ' ') when /[^\\] / if listobj - tk_split_escstr(val).collect{|elt| - tk_tcl2ruby(elt, enc_mode, listobj) - } + tk_split_escstr(val).collect{|elt| + tk_tcl2ruby(elt, enc_mode, listobj) + } elsif enc_mode - _fromUTF8(val) + _fromUTF8(val) else - val + val end else if enc_mode - _fromUTF8(val) + _fromUTF8(val) else - val + val end end end @@ -288,14 +288,14 @@ if USE_TCLs_LIST_FUNCTIONS dst = ary.collect{|e| if e.kind_of? Array - array2tk_list(e) + array2tk_list(e) elsif e.kind_of? Hash - tmp_ary = [] - #e.each{|k,v| tmp_ary << k << v } - e.each{|k,v| tmp_ary << "-#{_get_eval_string(k)}" << v } - array2tk_list(tmp_ary) + tmp_ary = [] + #e.each{|k,v| tmp_ary << k << v } + e.each{|k,v| tmp_ary << "-#{_get_eval_string(k)}" << v } + array2tk_list(tmp_ary) else - _get_eval_string(e) + _get_eval_string(e) end } TkCore::INTERP._merge_tklist(*dst) @@ -402,7 +402,7 @@ else if c == '\\' && !escape escape = true token = (token || "") << c if brace > 0 - next + next end brace += 1 if c == '{' && !escape brace -= 1 if c == '}' && !escape @@ -421,14 +421,14 @@ else def array2tk_list(ary) ary.collect{|e| if e.kind_of? Array - "{#{array2tk_list(e)}}" + "{#{array2tk_list(e)}}" elsif e.kind_of? Hash - # "{#{e.to_a.collect{|ee| array2tk_list(ee)}.join(' ')}}" - e.each{|k,v| tmp_ary << "-#{_get_eval_string(k)}" << v } - array2tk_list(tmp_ary) + # "{#{e.to_a.collect{|ee| array2tk_list(ee)}.join(' ')}}" + e.each{|k,v| tmp_ary << "-#{_get_eval_string(k)}" << v } + array2tk_list(tmp_ary) else - s = _get_eval_string(e) - (s.index(/\s/) || s.size == 0)? "{#{s}}": s + s = _get_eval_string(e) + (s.index(/\s/) || s.size == 0)? "{#{s}}": s end }.join(" ") end @@ -466,13 +466,13 @@ end dst = [] if keys and keys != None keys.each{|k, v| - #dst.push("-#{k}") - dst.push('-' + k.to_s) - if v != None - # v = _get_eval_string(v, enc_mode) if (enc_mode || flat) - v = _get_eval_string(v, enc_mode) if enc_mode - dst.push(v) - end + #dst.push("-#{k}") + dst.push('-' + k.to_s) + if v != None + # v = _get_eval_string(v, enc_mode) if (enc_mode || flat) + v = _get_eval_string(v, enc_mode) if enc_mode + dst.push(v) + end } end if conf @@ -600,7 +600,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 @@ -634,14 +634,14 @@ end nil else if (obj.respond_to?(:to_eval)) - (enc_mode)? _toUTF8(obj.to_eval): obj.to_eval + (enc_mode)? _toUTF8(obj.to_eval): obj.to_eval else - begin - obj = obj.to_s || '' - rescue - fail RuntimeError, "fail to convert object '#{obj}' to string" - end - (enc_mode)? _toUTF8(obj): obj + begin + obj = obj.to_s || '' + rescue + fail RuntimeError, "fail to convert object '#{obj}' to string" + end + (enc_mode)? _toUTF8(obj): obj end end end @@ -751,12 +751,12 @@ end def install_win(ppath,name=nil) if name if name == '' - raise ArgumentError, "invalid wiget-name '#{name}'" + raise ArgumentError, "invalid wiget-name '#{name}'" end if name[0] == ?. - @path = '' + name - @path.freeze - return TkCore::INTERP.tk_windows[@path] = self + @path = '' + name + @path.freeze + return TkCore::INTERP.tk_windows[@path] = self end else name = "w" + TkCore::INTERP._ip_id_ + Tk_IDs[1] @@ -800,11 +800,11 @@ module TkComm end if context.kind_of? Array context = context.collect{|ev| - if ev.kind_of? TkVirtualEvent - ev.path - else - ev - end + if ev.kind_of? TkVirtualEvent + ev.path + else + ev + end }.join("><") end if /,/ =~ context @@ -818,7 +818,7 @@ module TkComm id = install_bind(cmd, args) if cmd begin tk_call_without_enc(*(what + ["<#{tk_event_sequence(context)}>", - mode + id])) + mode + id])) rescue uninstall_cmd(id) if cmd fail @@ -840,26 +840,26 @@ module TkComm def _bindinfo(what, context=nil) if context tk_call_without_enc(*what+["<#{tk_event_sequence(context)}>"]) .collect {|cmdline| - if cmdline =~ /^rb_out\S* (c(?:_\d+_)?\d+)\s+(.*)$/ - #[Tk_CMDTBL[$1], $2] - [TkCore::INTERP.tk_cmd_tbl[$1], $2] - else - cmdline - end + if cmdline =~ /^rb_out\S* (c(?:_\d+_)?\d+)\s+(.*)$/ + #[Tk_CMDTBL[$1], $2] + [TkCore::INTERP.tk_cmd_tbl[$1], $2] + else + cmdline + end } else tk_split_simplelist(tk_call_without_enc(*what)).collect!{|seq| - l = seq.scan(/<*[^<>]+>*/).collect!{|subseq| - case (subseq) - when /^<<[^<>]+>>$/ - TkVirtualEvent.getobj(subseq[1..-2]) - when /^<[^<>]+>$/ - subseq[1..-2] - else - subseq.split('') - end - }.flatten - (l.size == 1) ? l[0] : l + l = seq.scan(/<*[^<>]+>*/).collect!{|subseq| + case (subseq) + when /^<<[^<>]+>>$/ + TkVirtualEvent.getobj(subseq[1..-2]) + when /^<[^<>]+>$/ + subseq[1..-2] + else + subseq.split('') + end + }.flatten + (l.size == 1) ? l[0] : l } end end @@ -868,7 +868,7 @@ module TkComm id = install_bind_for_event_class(klass, cmd, args) if cmd begin tk_call_without_enc(*(what + ["<#{tk_event_sequence(context)}>", - mode + id])) + mode + id])) rescue uninstall_cmd(id) if cmd fail @@ -950,9 +950,9 @@ module TkCore end if self.const_defined? :IP_OPTS if IP_OPTS.kind_of?(Hash) - opts = hash_kv(IP_OPTS).join(' ') + opts = hash_kv(IP_OPTS).join(' ') else - opts = IP_OPTS.to_s + opts = IP_OPTS.to_s end else opts = '' @@ -974,25 +974,25 @@ module TkCore @add_tk_procs = [].taint # table of [name, args, body] @cb_entry_class = Class.new(TkCallbackEntry){|c| - class << c - def inspect - sprintf("#", self.__id__) - end - alias to_s inspect - end - - def initialize(ip, cmd) - @ip = ip - @cmd = cmd - end - attr_reader :ip, :cmd - def call(*args) - @ip.cb_eval(@cmd, *args) - end - def inspect - sprintf("#", self.__id__) - end - alias to_s inspect + class << c + def inspect + sprintf("#", self.__id__) + end + alias to_s inspect + end + + def initialize(ip, cmd) + @ip = ip + @cmd = cmd + end + attr_reader :ip, :cmd + def call(*args) + @ip.cb_eval(@cmd, *args) + end + def inspect + sprintf("#", self.__id__) + end + alias to_s inspect }.freeze } @@ -1008,10 +1008,10 @@ module TkCore class Tk_OBJECT_TABLE def initialize(id) - @id = id + @id = id end def method_missing(m, *args, &b) - TkCore::INTERP.tk_object_table(@id).__send__(m, *args, &b) + TkCore::INTERP.tk_object_table(@id).__send__(m, *args, &b) end end @@ -1025,7 +1025,7 @@ module TkCore # obj = Object.new # obj.instance_eval <<-EOD # def self.method_missing(m, *args) -# TkCore::INTERP.tk_object_table(#{id}).send(m, *args) +# TkCore::INTERP.tk_object_table(#{id}).send(m, *args) # end # EOD # return obj @@ -1056,23 +1056,23 @@ module TkCore WIDGET_DESTROY_HOOK = '' INTERP._invoke_without_enc('event', 'add', - "<#{WIDGET_DESTROY_HOOK}>", 'Destroy') + "<#{WIDGET_DESTROY_HOOK}>", 'Destroy') INTERP._invoke_without_enc('bind', 'all', "<#{WIDGET_DESTROY_HOOK}>", - install_bind(proc{|xpath| - path = xpath[1..-1] - unless TkCore::INTERP.deleted? - if (widget = TkCore::INTERP.tk_windows[path]) - if widget.respond_to?(:__destroy_hook__) - begin - widget.__destroy_hook__ - rescue Exception - end - end - end - end - }, 'x%W')) + install_bind(proc{|xpath| + path = xpath[1..-1] + unless TkCore::INTERP.deleted? + if (widget = TkCore::INTERP.tk_windows[path]) + if widget.respond_to?(:__destroy_hook__) + begin + widget.__destroy_hook__ + rescue Exception + end + end + end + end + }, 'x%W')) INTERP.add_tk_procs(TclTkLib::FINALIZE_PROC_NAME, '', - "bind all <#{WIDGET_DESTROY_HOOK}> {}") + "bind all <#{WIDGET_DESTROY_HOOK}> {}") INTERP.add_tk_procs('rb_out', 'args', <<-'EOL') if {[set st [catch {eval {ruby_cmd TkCore callback} $args} ret]] != 0} { @@ -1087,7 +1087,7 @@ module TkCore return -code $st $ret } } else { - return $ret + return $ret } EOL =begin @@ -1108,7 +1108,7 @@ module TkCore return -code $st $ret } } else { - return $ret + return $ret } EOL =end @@ -1132,17 +1132,17 @@ module TkCore exit!(1) rescue Exception => e begin - 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 >-------" - msg.instance_variable_set(:@encoding, 'utf-8') + 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 >-------" + msg.instance_variable_set(:@encoding, 'utf-8') rescue Exception - msg = e.class.inspect + ': ' + e.message + "\n" + - "\n---< backtrace of Ruby side >-----\n" + - e.backtrace.join("\n") + - "\n---< backtrace of Tk side >-------" + msg = e.class.inspect + ': ' + e.message + "\n" + + "\n---< backtrace of Ruby side >-----\n" + + e.backtrace.join("\n") + + "\n---< backtrace of Tk side >-------" end fail(e, msg) end @@ -1153,7 +1153,7 @@ module TkCore 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], - # *arg)) + # *arg)) # TkCore::INTERP.tk_cmd_tbl[arg.shift].call(*arg) begin TkCore::INTERP.tk_cmd_tbl[arg.shift].call(*arg) @@ -1169,17 +1169,17 @@ module TkCore # cb_obj.call(*arg) # else # begin -# raise 'check backtrace' +# raise 'check backtrace' # rescue -# # ignore backtrace before 'callback' -# pos = -($!.backtrace.size) +# # ignore backtrace before 'callback' +# pos = -($!.backtrace.size) # end # begin -# cb_obj.call(*arg) +# cb_obj.call(*arg) # rescue -# trace = $!.backtrace -# raise $!, "\n#{trace[0]}: #{$!.message} (#{$!.class})\n" + -# "\tfrom #{trace[1..pos].join("\n\tfrom ")}" +# trace = $!.backtrace +# raise $!, "\n#{trace[0]}: #{$!.message} (#{$!.class})\n" + +# "\tfrom #{trace[1..pos].join("\n\tfrom ")}" # end # end #=end @@ -1203,10 +1203,10 @@ module TkCore # return # if false #defined? Thread # Thread.start do -# ms = Float(ms)/1000 -# ms = 10 if ms == 0 -# sleep ms/1000 -# cmd.call +# ms = Float(ms)/1000 +# ms = 10 if ms == 0 +# sleep ms/1000 +# cmd.call # end # else # cmdid = install_cmd(cmd) @@ -1383,11 +1383,11 @@ module TkCore #window = window.path if window.kind_of?(TkObject) if keys tk_call_without_enc('event', 'generate', window, - "<#{tk_event_sequence(context)}>", - *hash_kv(keys, true)) + "<#{tk_event_sequence(context)}>", + *hash_kv(keys, true)) else tk_call_without_enc('event', 'generate', window, - "<#{tk_event_sequence(context)}>") + "<#{tk_event_sequence(context)}>") end nil end @@ -1488,10 +1488,10 @@ module TkCore #res = INTERP._invoke(*args).taint #res = INTERP._invoke(enc_mode, *args) res = _ip_invoke_core(enc_mode, *args) - # >>>>> _invoke returns a TAINTED string <<<<< + # >>>>> _invoke returns a TAINTED string <<<<< rescue StandardError => err2 - fail err2 unless /^invalid command/ =~ err2.message - fail err + fail err2 unless /^invalid command/ =~ err2.message + fail err end end if INTERP._return_value() != 0 @@ -1535,7 +1535,7 @@ module Tk TK_MINOR_VERSION = minor.to_i JAPANIZED_TK = (INTERP._invoke_without_enc("info", "commands", - "kanji") != "").freeze + "kanji") != "").freeze def Tk.const_missing(sym) case(sym) @@ -1560,11 +1560,11 @@ module Tk when :PLATFORM, :TCL_PLATFORM if $SAFE >= 4 - fail SecurityError, "can't get #{sym} when $SAFE >= 4" + 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', - 'tcl_platform'))] + 'tcl_platform'))] when :ENV INTERP._invoke_without_enc('global', 'env') @@ -1583,22 +1583,22 @@ module Tk when :PRIV, :PRIVATE, :TK_PRIV priv = {} if INTERP._invoke_without_enc('info', 'vars', 'tk::Priv') != "" - var_nam = 'tk::Priv' + var_nam = 'tk::Priv' else - var_nam = 'tkPriv' + var_nam = 'tkPriv' end INTERP._invoke_without_enc('global', var_nam) Hash[*tk_split_simplelist(INTERP._invoke('array', 'get', - var_nam))].each{|k,v| - k.freeze - case v - when /^-?\d+$/ - priv[k] = v.to_i - when /^-?\d+\.?\d*(e[-+]?\d+)?$/ - priv[k] = v.to_f - else - priv[k] = v.freeze - end + var_nam))].each{|k,v| + k.freeze + case v + when /^-?\d+$/ + priv[k] = v.to_i + when /^-?\d+\.?\d*(e[-+]?\d+)?$/ + priv[k] = v.to_f + else + priv[k] = v.freeze + end } priv @@ -1618,8 +1618,8 @@ module Tk case code[0] when 'CHILDKILLED', 'CHILDSTATUS', 'CHILDSUSP' begin - pid = Integer(code[1]) - code[1] = pid + pid = Integer(code[1]) + code[1] = pid rescue end end @@ -1840,45 +1840,45 @@ if (/^(8\.[1-9]|9\.|[1-9][0-9])/ =~ Tk::TCL_VERSION && !Tk::JAPANIZED_TK) def _toUTF8(str, encoding = nil) # decide encoding if encoding - encoding = encoding.to_s + encoding = encoding.to_s elsif str.kind_of?(Tk::EncodedString) && str.encoding != nil - encoding = str.encoding.to_s + encoding = str.encoding.to_s elsif str.instance_variable_get(:@encoding) - encoding = str.instance_variable_get(:@encoding).to_s + encoding = str.instance_variable_get(:@encoding).to_s elsif defined?(@encoding) && @encoding != nil - encoding = @encoding.to_s + encoding = @encoding.to_s else - encoding = __invoke('encoding', 'system') + encoding = __invoke('encoding', 'system') end # convert case encoding when 'utf-8', 'binary' - str + str else - __toUTF8(str, encoding) + __toUTF8(str, encoding) end end def _fromUTF8(str, encoding = nil) unless encoding - if defined?(@encoding) && @encoding != nil - encoding = @encoding.to_s - else - encoding = __invoke('encoding', 'system') - end + if defined?(@encoding) && @encoding != nil + encoding = @encoding.to_s + else + encoding = __invoke('encoding', 'system') + end end if str.kind_of?(Tk::EncodedString) - if str.encoding == 'binary' - str - else - __fromUTF8(str, encoding) - end + if str.encoding == 'binary' + str + else + __fromUTF8(str, encoding) + end elsif str.instance_variable_get(:@encoding).to_s == 'binary' - str + str else - __fromUTF8(str, encoding) + __fromUTF8(str, encoding) end end =end @@ -1897,53 +1897,53 @@ if (/^(8\.[1-9]|9\.|[1-9][0-9])/ =~ Tk::TCL_VERSION && !Tk::JAPANIZED_TK) =begin def _eval(cmd) if defined?(@encoding) && @encoding != 'utf-8' - ret = if cmd.kind_of?(Tk::EncodedString) - case cmd.encoding - when 'utf-8', 'binary' - __eval(cmd) - else - __eval(_toUTF8(cmd, cmd.encoding)) - end - elsif cmd.instance_variable_get(:@encoding) == 'binary' - __eval(cmd) - else - __eval(_toUTF8(cmd, @encoding)) - end - if ret.kind_of?(String) && ret.instance_variable_get(:@encoding) == 'binary' - ret - else - _fromUTF8(ret, @encoding) - end + ret = if cmd.kind_of?(Tk::EncodedString) + case cmd.encoding + when 'utf-8', 'binary' + __eval(cmd) + else + __eval(_toUTF8(cmd, cmd.encoding)) + end + elsif cmd.instance_variable_get(:@encoding) == 'binary' + __eval(cmd) + else + __eval(_toUTF8(cmd, @encoding)) + end + if ret.kind_of?(String) && ret.instance_variable_get(:@encoding) == 'binary' + ret + else + _fromUTF8(ret, @encoding) + end else - __eval(cmd) + __eval(cmd) end end def _invoke(*cmds) if defined?(@encoding) && @encoding != 'utf-8' - cmds = cmds.collect{|cmd| - if cmd.kind_of?(Tk::EncodedString) - case cmd.encoding - when 'utf-8', 'binary' - cmd - else - _toUTF8(cmd, cmd.encoding) - end - elsif cmd.instance_variable_get(:@encoding) == 'binary' - cmd - else - _toUTF8(cmd, @encoding) - end - } - ret = __invoke(*cmds) - if ret.kind_of?(String) && ret.instance_variable_get(:@encoding) == 'binary' - ret - else - _fromUTF8(ret, @encoding) - end + cmds = cmds.collect{|cmd| + if cmd.kind_of?(Tk::EncodedString) + case cmd.encoding + when 'utf-8', 'binary' + cmd + else + _toUTF8(cmd, cmd.encoding) + end + elsif cmd.instance_variable_get(:@encoding) == 'binary' + cmd + else + _toUTF8(cmd, @encoding) + end + } + ret = __invoke(*cmds) + if ret.kind_of?(String) && ret.instance_variable_get(:@encoding) == 'binary' + ret + else + _fromUTF8(ret, @encoding) + end else - __invoke(*cmds) - end + __invoke(*cmds) + end end =end end @@ -1955,39 +1955,39 @@ if (/^(8\.[1-9]|9\.|[1-9][0-9])/ =~ Tk::TCL_VERSION && !Tk::JAPANIZED_TK) TkCommandNames = ['encoding'.freeze].freeze def encoding=(name) - TkCore::INTERP.encoding = name + TkCore::INTERP.encoding = name end def encoding - TkCore::INTERP.encoding + TkCore::INTERP.encoding end def encoding_names - tk_split_simplelist(tk_call('encoding', 'names')) + tk_split_simplelist(tk_call('encoding', 'names')) end def encoding_system - tk_call('encoding', 'system') + tk_call('encoding', 'system') end def encoding_system=(enc) - tk_call('encoding', 'system', enc) + tk_call('encoding', 'system', enc) end def encoding_convertfrom(str, enc=nil) - # str must be a Tcl's internal string expression in enc. - # the return value is a UTF-8 string. - enc = encoding_system unless enc - TkCore::INTERP.__invoke('encoding', 'convertfrom', enc, str) + # str must be a Tcl's internal string expression in enc. + # the return value is a UTF-8 string. + enc = encoding_system unless enc + TkCore::INTERP.__invoke('encoding', 'convertfrom', enc, str) end alias encoding_convert_from encoding_convertfrom def encoding_convertto(str, enc=nil) - # str must be a UTF-8 string. - # The return value is a Tcl's internal string expression in enc. + # str must be a UTF-8 string. + # The return value is a Tcl's internal string expression in enc. # To get an usual enc string, use Tk.fromUTF8(ret_val, enc). - enc = encoding_system unless enc - TkCore::INTERP.__invoke('encoding', 'convertto', enc, str) + enc = encoding_system unless enc + TkCore::INTERP.__invoke('encoding', 'convertto', enc, str) end alias encoding_convert_to encoding_convertto end @@ -2026,28 +2026,28 @@ else extend Encoding def encoding=(name) - nil + nil end def encoding - nil + nil end def encoding_names - nil + nil end def encoding_system - nil + nil end def encoding_system=(enc) - nil + nil end def encoding_convertfrom(str, enc=None) - str + str end alias encoding_convert_from encoding_convertfrom def encoding_convertto(str, enc=None) - str + str end alias encoding_convert_to encoding_convertto end @@ -2098,19 +2098,19 @@ module TkTreatFont if key pathname = [win, tag, key].join(';') TkFont.used_on(pathname) || - TkFont.init_widget_font(pathname, *__config_cmd) + TkFont.init_widget_font(pathname, *__config_cmd) elsif optkeys.size == 1 pathname = [win, tag, optkeys[0]].join(';') TkFont.used_on(pathname) || - TkFont.init_widget_font(pathname, *__config_cmd) + TkFont.init_widget_font(pathname, *__config_cmd) else fonts = {} optkeys.each{|key| - key = key.to_s - pathname = [win, tag, key].join(';') - fonts[key] = - TkFont.used_on(pathname) || - TkFont.init_widget_font(pathname, *__config_cmd) + key = key.to_s + pathname = [win, tag, key].join(';') + fonts[key] = + TkFont.used_on(pathname) || + TkFont.init_widget_font(pathname, *__config_cmd) } fonts end @@ -2129,38 +2129,38 @@ module TkTreatFont k_optkey = 'kanji' << optkey if slot.key?(optkey) - fnt = slot.delete(optkey) - if fnt.kind_of?(TkFont) - slot.delete(l_optkey) - slot.delete(a_optkey) - slot.delete(k_optkey) - - fnt.call_font_configure([pathname, optkey], *(__config_cmd << {})) - next - else - if fnt - if (slot.key?(l_optkey) || - slot.key?(a_optkey) || - slot.key?(k_optkey)) - fnt = TkFont.new(fnt) - - lfnt = slot.delete(l_optkey) - lfnt = slot.delete(a_optkey) if slot.key?(a_optkey) - kfnt = slot.delete(k_optkey) - - fnt.latin_replace(lfnt) if lfnt - fnt.kanji_replace(kfnt) if kfnt - - fnt.call_font_configure([pathname, optkey], - *(__config_cmd << {})) - next - else - fnt = hash_kv(fnt) if fnt.kind_of?(Hash) - tk_call(*(__config_cmd << "-#{optkey}" << fnt)) - end - end - next - end + fnt = slot.delete(optkey) + if fnt.kind_of?(TkFont) + slot.delete(l_optkey) + slot.delete(a_optkey) + slot.delete(k_optkey) + + fnt.call_font_configure([pathname, optkey], *(__config_cmd << {})) + next + else + if fnt + if (slot.key?(l_optkey) || + slot.key?(a_optkey) || + slot.key?(k_optkey)) + fnt = TkFont.new(fnt) + + lfnt = slot.delete(l_optkey) + lfnt = slot.delete(a_optkey) if slot.key?(a_optkey) + kfnt = slot.delete(k_optkey) + + fnt.latin_replace(lfnt) if lfnt + fnt.kanji_replace(kfnt) if kfnt + + fnt.call_font_configure([pathname, optkey], + *(__config_cmd << {})) + next + else + fnt = hash_kv(fnt) if fnt.kind_of?(Hash) + tk_call(*(__config_cmd << "-#{optkey}" << fnt)) + end + end + next + end end lfnt = slot.delete(l_optkey) @@ -2168,12 +2168,12 @@ module TkTreatFont kfnt = slot.delete(k_optkey) if lfnt && kfnt - TkFont.new(lfnt, kfnt).call_font_configure([pathname, optkey], - *(__config_cmd << {})) + TkFont.new(lfnt, kfnt).call_font_configure([pathname, optkey], + *(__config_cmd << {})) elsif lfnt - latinfont_configure([lfnt, optkey]) + latinfont_configure([lfnt, optkey]) elsif kfnt - kanjifont_configure([kfnt, optkey]) + kanjifont_configure([kfnt, optkey]) end } @@ -2205,27 +2205,27 @@ module TkTreatFont pathname = [win, tag, optkey].join(';') if (fobj = TkFont.used_on(pathname)) - fobj = TkFont.new(fobj) # create a new TkFont object + fobj = TkFont.new(fobj) # create a new TkFont object elsif Tk::JAPANIZED_TK - fobj = fontobj # create a new TkFont object + fobj = fontobj # create a new TkFont object else - ltn = hash_kv(ltn) if ltn.kind_of?(Hash) - tk_call(*(__config_cmd << "-#{optkey}" << ltn)) - next + ltn = hash_kv(ltn) if ltn.kind_of?(Hash) + tk_call(*(__config_cmd << "-#{optkey}" << ltn)) + next end if fobj.kind_of?(TkFont) - if ltn.kind_of?(TkFont) - conf = {} - ltn.latin_configinfo.each{|key,val| conf[key] = val} - if keys - fobj.latin_configure(conf.update(keys)) - else - fobj.latin_configure(conf) - end - else - fobj.latin_replace(ltn) - end + if ltn.kind_of?(TkFont) + conf = {} + ltn.latin_configinfo.each{|key,val| conf[key] = val} + if keys + fobj.latin_configure(conf.update(keys)) + else + fobj.latin_configure(conf) + end + else + fobj.latin_replace(ltn) + end end fobj.call_font_configure([pathname, optkey], *(__config_cmd << {})) @@ -2257,27 +2257,27 @@ module TkTreatFont pathname = [win, tag, optkey].join(';') if (fobj = TkFont.used_on(pathname)) - fobj = TkFont.new(fobj) # create a new TkFont object + fobj = TkFont.new(fobj) # create a new TkFont object elsif Tk::JAPANIZED_TK - fobj = fontobj # create a new TkFont object + fobj = fontobj # create a new TkFont object else - knj = hash_kv(knj) if knj.kind_of?(Hash) - tk_call(*(__config_cmd << "-#{optkey}" << knj)) - next + knj = hash_kv(knj) if knj.kind_of?(Hash) + tk_call(*(__config_cmd << "-#{optkey}" << knj)) + next end if fobj.kind_of?(TkFont) - if knj.kind_of?(TkFont) - conf = {} - knj.kanji_configinfo.each{|key,val| conf[key] = val} - if keys - fobj.kanji_configure(conf.update(keys)) - else - fobj.kanji_configure(conf) - end - else - fobj.kanji_replace(knj) - end + if knj.kind_of?(TkFont) + conf = {} + knj.kanji_configinfo.each{|key,val| conf[key] = val} + if keys + fobj.kanji_configure(conf.update(keys)) + else + fobj.kanji_configure(conf) + end + else + fobj.kanji_replace(knj) + end end fobj.call_font_configure([pathname, optkey], *(__config_cmd << {})) @@ -2288,15 +2288,15 @@ module TkTreatFont def font_copy(window, wintag=nil, winkey=nil, targetkey=nil) if wintag if winkey - fnt = window.tagfontobj(wintag, winkey).dup + fnt = window.tagfontobj(wintag, winkey).dup else - fnt = window.tagfontobj(wintag).dup + fnt = window.tagfontobj(wintag).dup end else if winkey - fnt = window.fontobj(winkey).dup + fnt = window.fontobj(winkey).dup else - fnt = window.fontobj.dup + fnt = window.fontobj.dup end end @@ -2311,22 +2311,22 @@ module TkTreatFont def latinfont_copy(window, wintag=nil, winkey=nil, targetkey=nil) if targetkey fontobj(targetkey).dup.call_font_configure([__pathname, targetkey], - *(__config_cmd << {})) + *(__config_cmd << {})) else fontobj.dup.call_font_configure(__pathname, *(__config_cmd << {})) end if wintag if winkey - fontobj.latin_replace(window.tagfontobj(wintag, winkey).latin_font_id) + fontobj.latin_replace(window.tagfontobj(wintag, winkey).latin_font_id) else - fontobj.latin_replace(window.tagfontobj(wintag).latin_font_id) + fontobj.latin_replace(window.tagfontobj(wintag).latin_font_id) end else if winkey - fontobj.latin_replace(window.fontobj(winkey).latin_font_id) + fontobj.latin_replace(window.fontobj(winkey).latin_font_id) else - fontobj.latin_replace(window.fontobj.latin_font_id) + fontobj.latin_replace(window.fontobj.latin_font_id) end end self @@ -2336,22 +2336,22 @@ module TkTreatFont def kanjifont_copy(window, wintag=nil, winkey=nil, targetkey=nil) if targetkey fontobj(targetkey).dup.call_font_configure([__pathname, targetkey], - *(__config_cmd << {})) + *(__config_cmd << {})) else - fontobj.dup.call_font_configure(__pathname, *(__config_cmd << {})) + fontobj.dup.call_font_configure(__pathname, *(__config_cmd << {})) end if wintag if winkey - fontobj.kanji_replace(window.tagfontobj(wintag, winkey).kanji_font_id) + fontobj.kanji_replace(window.tagfontobj(wintag, winkey).kanji_font_id) else - fontobj.kanji_replace(window.tagfontobj(wintag).kanji_font_id) + fontobj.kanji_replace(window.tagfontobj(wintag).kanji_font_id) end else if winkey - fontobj.kanji_replace(window.fontobj(winkey).kanji_font_id) + fontobj.kanji_replace(window.fontobj(winkey).kanji_font_id) else - fontobj.kanji_replace(window.fontobj.kanji_font_id) + fontobj.kanji_replace(window.fontobj.kanji_font_id) end end self @@ -2426,16 +2426,16 @@ module TkConfigMethod keys.each{|k, v| optkey = keyonly.find{|kk,vv| kk.to_s == k.to_s} if optkey - defkey, undefkey = optkey - if v - keys2[defkey.to_s] = None - elsif undefkey - keys2[undefkey.to_s] = None - else - # remove key - end + defkey, undefkey = optkey + if v + keys2[defkey.to_s] = None + elsif undefkey + keys2[undefkey.to_s] = None + else + # remove key + end else - keys2[k.to_s] = v + keys2[k.to_s] = v end } keys2 @@ -2466,9 +2466,9 @@ module TkConfigMethod case slot when /^(#{__numval_optkeys.join('|')})$/ begin - number(tk_call_without_enc(*(__cget_cmd << "-#{slot}"))) + number(tk_call_without_enc(*(__cget_cmd << "-#{slot}"))) rescue - nil + nil end when /^(#{__numstrval_optkeys.join('|')})$/ @@ -2476,9 +2476,9 @@ module TkConfigMethod when /^(#{__boolval_optkeys.join('|')})$/ begin - bool(tk_call_without_enc(*(__cget_cmd << "-#{slot}"))) + bool(tk_call_without_enc(*(__cget_cmd << "-#{slot}"))) rescue - nil + nil end when /^(#{__listval_optkeys.join('|')})$/ @@ -2487,9 +2487,9 @@ module TkConfigMethod when /^(#{__numlistval_optkeys.join('|')})$/ conf = tk_call_without_enc(*(__cget_cmd << "-#{slot}")) if conf =~ /^[0-9+-]/ - list(conf) + list(conf) else - conf + conf end when /^(#{__strval_optkeys.join('|')})$/ @@ -2500,13 +2500,13 @@ module TkConfigMethod fontkey = $2 fnt = tk_tcl2ruby(tk_call_without_enc(*(__cget_cmd << "-#{fontkey}")), true) unless fnt.kind_of?(TkFont) - fnt = fontobj(fontkey) + fnt = fontobj(fontkey) end if fontcode == 'kanji' && JAPANIZED_TK && TK_VERSION =~ /^4\.*/ - # obsolete; just for compatibility - fnt.kanji_font + # obsolete; just for compatibility + fnt.kanji_font else - fnt + fnt end else @@ -2519,48 +2519,48 @@ module TkConfigMethod slot = _symbolkey2str(slot) __methodcall_optkeys.each{|key, method| - value = slot.delete(key.to_s) - self.__send__(method, value) if value + value = slot.delete(key.to_s) + self.__send__(method, value) if value } __keyonly_optkeys.each{|defkey, undefkey| - conf = slot.find{|kk, vv| kk == defkey.to_s} - if conf - k, v = conf - if v - slot[k] = None - else - slot[undefkey.to_s] = None if undefkey - slot.delete(k) - end - end + conf = slot.find{|kk, vv| kk == defkey.to_s} + if conf + k, v = conf + if v + slot[k] = None + else + slot[undefkey.to_s] = None if undefkey + slot.delete(k) + end + end } if (slot.find{|k, v| k =~ /^(|latin|ascii|kanji)(#{__font_optkeys.join('|')})$/}) - font_configure(slot) + font_configure(slot) elsif slot.size > 0 - tk_call(*(__config_cmd.concat(hash_kv(slot)))) + tk_call(*(__config_cmd.concat(hash_kv(slot)))) end else slot = slot.to_s if ( conf = __keyonly_optkeys.find{|k, v| k.to_s == slot} ) - defkey, undefkey = conf - if value - tk_call(*(__config_cmd << "-#{defkey}")) - elsif undefkey - tk_call(*(__config_cmd << "-#{undefkey}")) - end + defkey, undefkey = conf + if value + tk_call(*(__config_cmd << "-#{defkey}")) + elsif undefkey + tk_call(*(__config_cmd << "-#{undefkey}")) + end elsif ( method = _symbolkey2str(__methodcall_optkeys)[slot] ) - self.__send__(method, value) + self.__send__(method, value) elsif (slot =~ /^(|latin|ascii|kanji)(#{__font_optkeys.join('|')})$/) - if value == None - fontobj($2) - else - font_configure({slot=>value}) - end + if value == None + fontobj($2) + else + font_configure({slot=>value}) + end else - tk_call(*(__config_cmd << "-#{slot}" << value)) + tk_call(*(__config_cmd << "-#{slot}" << value)) end end self @@ -2573,529 +2573,529 @@ module TkConfigMethod def configinfo(slot = nil) if TkComm::GET_CONFIGINFO_AS_ARRAY if (slot.to_s =~ /^(|latin|ascii|kanji)(#{__font_optkeys.join('|')})$/) - fontkey = $2 - conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__config_cmd << "-#{fontkey}")))) - conf[__configinfo_struct[:key]] = - conf[__configinfo_struct[:key]][1..-1] - if ( ! __configinfo_struct[:alias] \ - || conf.size > __configinfo_struct[:alias] + 1 ) - conf[__configinfo_struct[:current_value]] = fontobj(fontkey) - elsif ( __configinfo_struct[:alias] \ - && conf.size == __configinfo_struct[:alias] + 1 \ - && conf[__configinfo_struct[:alias]][0] == ?- ) - conf[__configinfo_struct[:alias]] = - conf[__configinfo_struct[:alias]][1..-1] - end - conf + fontkey = $2 + conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__config_cmd << "-#{fontkey}")))) + conf[__configinfo_struct[:key]] = + conf[__configinfo_struct[:key]][1..-1] + if ( ! __configinfo_struct[:alias] \ + || conf.size > __configinfo_struct[:alias] + 1 ) + conf[__configinfo_struct[:current_value]] = fontobj(fontkey) + elsif ( __configinfo_struct[:alias] \ + && conf.size == __configinfo_struct[:alias] + 1 \ + && conf[__configinfo_struct[:alias]][0] == ?- ) + conf[__configinfo_struct[:alias]] = + conf[__configinfo_struct[:alias]][1..-1] + end + conf else - if slot - slot = slot.to_s - case slot - when /^(#{__methodcall_optkeys.keys.join('|')})$/ - method = _symbolkey2str(__methodcall_optkeys)[slot] - return [slot, '', '', '', self.__send__(method)] - - when /^(#{__numval_optkeys.join('|')})$/ - conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__config_cmd << "-#{slot}")))) - - if ( __configinfo_struct[:default_value] \ - && conf[__configinfo_struct[:default_value]]) - begin - conf[__configinfo_struct[:default_value]] = - number(conf[__configinfo_struct[:default_value]]) - rescue - conf[__configinfo_struct[:default_value]] = nil - end - end - if ( conf[__configinfo_struct[:current_value]] ) - begin - conf[__configinfo_struct[:current_value]] = - number(conf[__configinfo_struct[:current_value]]) - rescue - conf[__configinfo_struct[:current_value]] = nil - end - end - - when /^(#{__numstrval_optkeys.join('|')})$/ - conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__config_cmd << "-#{slot}")))) - - if ( __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]] = - num_or_str(conf[__configinfo_struct[:current_value]]) - end - - when /^(#{__boolval_optkeys.join('|')})$/ - conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__config_cmd << "-#{slot}")))) - - if ( __configinfo_struct[:default_value] \ - && conf[__configinfo_struct[:default_value]]) - begin - conf[__configinfo_struct[:default_value]] = - bool(conf[__configinfo_struct[:default_value]]) - rescue - conf[__configinfo_struct[:default_value]] = nil - end - end - if ( conf[__configinfo_struct[:current_value]] ) - begin - conf[__configinfo_struct[:current_value]] = - bool(conf[__configinfo_struct[:current_value]]) - rescue - conf[__configinfo_struct[:current_value]] = nil - end - end - - when /^(#{__listval_optkeys.join('|')})$/ - conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__config_cmd << "-#{slot}")))) - - if ( __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]] = - simplelist(conf[__configinfo_struct[:current_value]]) - end - - when /^(#{__numlistval_optkeys.join('|')})$/ - conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__config_cmd << "-#{slot}")))) - - if ( __configinfo_struct[:default_value] \ - && conf[__configinfo_struct[:default_value]] \ - && conf[__configinfo_struct[:default_value]] =~ /^[0-9]/ ) - 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]] = - list(conf[__configinfo_struct[:current_value]]) - end - - when /^(#{__strval_optkeys.join('|')})$/ - conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__config_cmd << "-#{slot}")))) - else - conf = tk_split_list(_fromUTF8(tk_call_without_enc(*(__config_cmd << "-#{slot}")))) - end - 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]][1..-1] - end - - conf - - else - ret = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*__config_cmd))).collect{|conflist| - conf = tk_split_simplelist(conflist) - conf[__configinfo_struct[:key]] = - conf[__configinfo_struct[:key]][1..-1] - - case conf[__configinfo_struct[:key]] - when /^(#{__strval_optkeys.join('|')})$/ - # do nothing - - when /^(#{__numval_optkeys.join('|')})$/ - if ( __configinfo_struct[:default_value] \ - && conf[__configinfo_struct[:default_value]] ) - begin - conf[__configinfo_struct[:default_value]] = - number(conf[__configinfo_struct[:default_value]]) - rescue - conf[__configinfo_struct[:default_value]] = nil - end - end - if ( conf[__configinfo_struct[:current_value]] ) - begin - conf[__configinfo_struct[:current_value]] = - number(conf[__configinfo_struct[:current_value]]) - rescue - conf[__configinfo_struct[:current_value]] = nil - end - end - - when /^(#{__numstrval_optkeys.join('|')})$/ - if ( __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]] = - num_or_str(conf[__configinfo_struct[:current_value]]) - end - - when /^(#{__boolval_optkeys.join('|')})$/ - if ( __configinfo_struct[:default_value] \ - && conf[__configinfo_struct[:default_value]] ) - begin - conf[__configinfo_struct[:default_value]] = - bool(conf[__configinfo_struct[:default_value]]) - rescue - conf[__configinfo_struct[:default_value]] = nil - end - end - if ( conf[__configinfo_struct[:current_value]] ) - begin - conf[__configinfo_struct[:current_value]] = - bool(conf[__configinfo_struct[:current_value]]) - rescue - conf[__configinfo_struct[:current_value]] = nil - end - end - - when /^(#{__listval_optkeys.join('|')})$/ - if ( __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]] = - simplelist(conf[__configinfo_struct[:current_value]]) - end - - when /^(#{__numlistval_optkeys.join('|')})$/ - if ( __configinfo_struct[:default_value] \ - && conf[__configinfo_struct[:default_value]] \ - && conf[__configinfo_struct[:default_value]] =~ /^[0-9]/ ) - 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]] = - list(conf[__configinfo_struct[:current_value]]) - end - - else - 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]]) - else - 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]]) - else - conf[__configinfo_struct[:current_value]] = - tk_tcl2ruby(conf[__configinfo_struct[:current_value]]) - end - end - end - - if ( __configinfo_struct[:alias] \ - && conf.size == __configinfo_struct[:alias] + 1 \ - && conf[__configinfo_struct[:alias]][0] == ?- ) - conf[__configinfo_struct[:alias]] = - conf[__configinfo_struct[:alias]][1..-1] - end - - conf - } - - __font_optkeys.each{|optkey| - optkey = optkey.to_s - fontconf = ret.assoc(optkey) - if fontconf && fontconf.size > 2 - ret.delete_if{|inf| inf[0] =~ /^(|latin|ascii|kanji)#{optkey}$/} - fontconf[__configinfo_struct[:current_value]] = fontobj(optkey) - ret.push(fontconf) - end - } - - __methodcall_optkeys.each{|optkey, method| - ret << [optkey.to_s, '', '', '', self.__send__(method)] - } - - ret - end + if slot + slot = slot.to_s + case slot + when /^(#{__methodcall_optkeys.keys.join('|')})$/ + method = _symbolkey2str(__methodcall_optkeys)[slot] + return [slot, '', '', '', self.__send__(method)] + + when /^(#{__numval_optkeys.join('|')})$/ + conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__config_cmd << "-#{slot}")))) + + if ( __configinfo_struct[:default_value] \ + && conf[__configinfo_struct[:default_value]]) + begin + conf[__configinfo_struct[:default_value]] = + number(conf[__configinfo_struct[:default_value]]) + rescue + conf[__configinfo_struct[:default_value]] = nil + end + end + if ( conf[__configinfo_struct[:current_value]] ) + begin + conf[__configinfo_struct[:current_value]] = + number(conf[__configinfo_struct[:current_value]]) + rescue + conf[__configinfo_struct[:current_value]] = nil + end + end + + when /^(#{__numstrval_optkeys.join('|')})$/ + conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__config_cmd << "-#{slot}")))) + + if ( __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]] = + num_or_str(conf[__configinfo_struct[:current_value]]) + end + + when /^(#{__boolval_optkeys.join('|')})$/ + conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__config_cmd << "-#{slot}")))) + + if ( __configinfo_struct[:default_value] \ + && conf[__configinfo_struct[:default_value]]) + begin + conf[__configinfo_struct[:default_value]] = + bool(conf[__configinfo_struct[:default_value]]) + rescue + conf[__configinfo_struct[:default_value]] = nil + end + end + if ( conf[__configinfo_struct[:current_value]] ) + begin + conf[__configinfo_struct[:current_value]] = + bool(conf[__configinfo_struct[:current_value]]) + rescue + conf[__configinfo_struct[:current_value]] = nil + end + end + + when /^(#{__listval_optkeys.join('|')})$/ + conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__config_cmd << "-#{slot}")))) + + if ( __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]] = + simplelist(conf[__configinfo_struct[:current_value]]) + end + + when /^(#{__numlistval_optkeys.join('|')})$/ + conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__config_cmd << "-#{slot}")))) + + if ( __configinfo_struct[:default_value] \ + && conf[__configinfo_struct[:default_value]] \ + && conf[__configinfo_struct[:default_value]] =~ /^[0-9]/ ) + 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]] = + list(conf[__configinfo_struct[:current_value]]) + end + + when /^(#{__strval_optkeys.join('|')})$/ + conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__config_cmd << "-#{slot}")))) + else + conf = tk_split_list(_fromUTF8(tk_call_without_enc(*(__config_cmd << "-#{slot}")))) + end + 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]][1..-1] + end + + conf + + else + ret = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*__config_cmd))).collect{|conflist| + conf = tk_split_simplelist(conflist) + conf[__configinfo_struct[:key]] = + conf[__configinfo_struct[:key]][1..-1] + + case conf[__configinfo_struct[:key]] + when /^(#{__strval_optkeys.join('|')})$/ + # do nothing + + when /^(#{__numval_optkeys.join('|')})$/ + if ( __configinfo_struct[:default_value] \ + && conf[__configinfo_struct[:default_value]] ) + begin + conf[__configinfo_struct[:default_value]] = + number(conf[__configinfo_struct[:default_value]]) + rescue + conf[__configinfo_struct[:default_value]] = nil + end + end + if ( conf[__configinfo_struct[:current_value]] ) + begin + conf[__configinfo_struct[:current_value]] = + number(conf[__configinfo_struct[:current_value]]) + rescue + conf[__configinfo_struct[:current_value]] = nil + end + end + + when /^(#{__numstrval_optkeys.join('|')})$/ + if ( __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]] = + num_or_str(conf[__configinfo_struct[:current_value]]) + end + + when /^(#{__boolval_optkeys.join('|')})$/ + if ( __configinfo_struct[:default_value] \ + && conf[__configinfo_struct[:default_value]] ) + begin + conf[__configinfo_struct[:default_value]] = + bool(conf[__configinfo_struct[:default_value]]) + rescue + conf[__configinfo_struct[:default_value]] = nil + end + end + if ( conf[__configinfo_struct[:current_value]] ) + begin + conf[__configinfo_struct[:current_value]] = + bool(conf[__configinfo_struct[:current_value]]) + rescue + conf[__configinfo_struct[:current_value]] = nil + end + end + + when /^(#{__listval_optkeys.join('|')})$/ + if ( __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]] = + simplelist(conf[__configinfo_struct[:current_value]]) + end + + when /^(#{__numlistval_optkeys.join('|')})$/ + if ( __configinfo_struct[:default_value] \ + && conf[__configinfo_struct[:default_value]] \ + && conf[__configinfo_struct[:default_value]] =~ /^[0-9]/ ) + 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]] = + list(conf[__configinfo_struct[:current_value]]) + end + + else + 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]]) + else + 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]]) + else + conf[__configinfo_struct[:current_value]] = + tk_tcl2ruby(conf[__configinfo_struct[:current_value]]) + end + end + end + + if ( __configinfo_struct[:alias] \ + && conf.size == __configinfo_struct[:alias] + 1 \ + && conf[__configinfo_struct[:alias]][0] == ?- ) + conf[__configinfo_struct[:alias]] = + conf[__configinfo_struct[:alias]][1..-1] + end + + conf + } + + __font_optkeys.each{|optkey| + optkey = optkey.to_s + fontconf = ret.assoc(optkey) + if fontconf && fontconf.size > 2 + ret.delete_if{|inf| inf[0] =~ /^(|latin|ascii|kanji)#{optkey}$/} + fontconf[__configinfo_struct[:current_value]] = fontobj(optkey) + ret.push(fontconf) + end + } + + __methodcall_optkeys.each{|optkey, method| + ret << [optkey.to_s, '', '', '', self.__send__(method)] + } + + ret + end end else # ! TkComm::GET_CONFIGINFO_AS_ARRAY if (slot.to_s =~ /^(|latin|ascii|kanji)(#{__font_optkeys.join('|')})$/) - fontkey = $2 - conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__config_cmd << "-#{fontkey}")))) - conf[__configinfo_struct[:key]] = - conf[__configinfo_struct[:key]][1..-1] - - if ( ! __configinfo_struct[:alias] \ - || conf.size > __configinfo_struct[:alias] + 1 ) - conf[__configinfo_struct[:current_value]] = fontobj(fontkey) - { conf.shift => conf } - elsif ( __configinfo_struct[:alias] \ - && conf.size == __configinfo_struct[:alias] + 1 ) - if conf[__configinfo_struct[:alias]][0] == ?- - conf[__configinfo_struct[:alias]] = - conf[__configinfo_struct[:alias]][1..-1] - end - { conf[0] => conf[1] } - else - { conf.shift => conf } - end + fontkey = $2 + conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__config_cmd << "-#{fontkey}")))) + conf[__configinfo_struct[:key]] = + conf[__configinfo_struct[:key]][1..-1] + + if ( ! __configinfo_struct[:alias] \ + || conf.size > __configinfo_struct[:alias] + 1 ) + conf[__configinfo_struct[:current_value]] = fontobj(fontkey) + { conf.shift => conf } + elsif ( __configinfo_struct[:alias] \ + && conf.size == __configinfo_struct[:alias] + 1 ) + if conf[__configinfo_struct[:alias]][0] == ?- + conf[__configinfo_struct[:alias]] = + conf[__configinfo_struct[:alias]][1..-1] + end + { conf[0] => conf[1] } + else + { conf.shift => conf } + end else - if slot - slot = slot.to_s - case slot - when /^(#{__methodcall_optkeys.keys.join('|')})$/ - method = _symbolkey2str(__methodcall_optkeys)[slot] - return {slot => ['', '', '', self.__send__(method)]} - - when /^(#{__numval_optkeys.join('|')})$/ - conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__config_cmd << "-#{slot}")))) - - if ( __configinfo_struct[:default_value] \ - && conf[__configinfo_struct[:default_value]] ) - begin - conf[__configinfo_struct[:default_value]] = - number(conf[__configinfo_struct[:default_value]]) - rescue - conf[__configinfo_struct[:default_value]] = nil - end - end - if ( conf[__configinfo_struct[:current_value]] ) - begin - conf[__configinfo_struct[:current_value]] = - number(conf[__configinfo_struct[:current_value]]) - rescue - conf[__configinfo_struct[:current_value]] = nil - end - end - - when /^(#{__numstrval_optkeys.join('|')})$/ - conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__config_cmd << "-#{slot}")))) - - if ( __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]] = - num_or_str(conf[__configinfo_struct[:current_value]]) - end - - when /^(#{__boolval_optkeys.join('|')})$/ - conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__config_cmd << "-#{slot}")))) - - if ( __configinfo_struct[:default_value] \ - && conf[__configinfo_struct[:default_value]] ) - begin - conf[__configinfo_struct[:default_value]] = - bool(conf[__configinfo_struct[:default_value]]) - rescue - conf[__configinfo_struct[:default_value]] = nil - end - end - if ( conf[__configinfo_struct[:current_value]] ) - begin - conf[__configinfo_struct[:current_value]] = - bool(conf[__configinfo_struct[:current_value]]) - rescue - conf[__configinfo_struct[:current_value]] = nil - end - end - - when /^(#{__listval_optkeys.join('|')})$/ - conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__config_cmd << "-#{slot}")))) - - if ( __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]] = - simplelist(conf[__configinfo_struct[:current_value]]) - end - - when /^(#{__numlistval_optkeys.join('|')})$/ - conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__config_cmd << "-#{slot}")))) - - if ( __configinfo_struct[:default_value] \ - && conf[__configinfo_struct[:default_value]] \ - && conf[__configinfo_struct[:default_value]] =~ /^[0-9]/ ) - 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]] = - list(conf[__configinfo_struct[:current_value]]) - end - - when /^(#{__strval_optkeys.join('|')})$/ - conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__config_cmd << "-#{slot}")))) - else - conf = tk_split_list(_fromUTF8(tk_send_without_enc(*(__config_cmd << "-#{slot}")))) - end - 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]][1..-1] - end - { conf[0] => conf[1] } - else - { conf.shift => conf } - end - - else - ret = {} - tk_split_simplelist(_fromUTF8(tk_call_without_enc(*__config_cmd))).each{|conflist| - conf = tk_split_simplelist(conflist) - conf[__configinfo_struct[:key]] = - conf[__configinfo_struct[:key]][1..-1] - - case conf[__configinfo_struct[:key]] - when /^(#{__strval_optkeys.join('|')})$/ - # do nothing - - when /^(#{__numval_optkeys.join('|')})$/ - if ( __configinfo_struct[:default_value] \ - && conf[__configinfo_struct[:default_value]] ) - begin - conf[__configinfo_struct[:default_value]] = - number(conf[__configinfo_struct[:default_value]]) - rescue - conf[__configinfo_struct[:default_value]] = nil - end - end - if ( conf[__configinfo_struct[:current_value]] ) - begin - conf[__configinfo_struct[:current_value]] = - number(conf[__configinfo_struct[:current_value]]) - rescue - conf[__configinfo_struct[:current_value]] = nil - end - end - - when /^(#{__numstrval_optkeys.join('|')})$/ - if ( __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]] = - num_or_str(conf[__configinfo_struct[:current_value]]) - end - - when /^(#{__boolval_optkeys.join('|')})$/ - if ( __configinfo_struct[:default_value] \ - && conf[__configinfo_struct[:default_value]] ) - begin - conf[__configinfo_struct[:default_value]] = - bool(conf[__configinfo_struct[:default_value]]) - rescue - conf[__configinfo_struct[:default_value]] = nil - end - end - if ( conf[__configinfo_struct[:current_value]] ) - begin - conf[__configinfo_struct[:current_value]] = - bool(conf[__configinfo_struct[:current_value]]) - rescue - conf[__configinfo_struct[:current_value]] = nil - end - end - - when /^(#{__listval_optkeys.join('|')})$/ - if ( __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]] = - simplelist(conf[__configinfo_struct[:current_value]]) - end - - when /^(#{__numlistval_optkeys.join('|')})$/ - if ( __configinfo_struct[:default_value] \ - && conf[__configinfo_struct[:default_value]] \ - && conf[__configinfo_struct[:default_value]] =~ /^[0-9]/ ) - 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]] = - list(conf[__configinfo_struct[:current_value]]) - end - - else - 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]]) - else - 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]]) - else - conf[__configinfo_struct[:current_value]] = - tk_tcl2ruby(conf[__configinfo_struct[:current_value]]) - end - end - end - - if ( __configinfo_struct[:alias] \ - && conf.size == __configinfo_struct[:alias] + 1 ) - if conf[__configinfo_struct[:alias]][0] == ?- - conf[__configinfo_struct[:alias]] = - conf[__configinfo_struct[:alias]][1..-1] - end - ret[conf[0]] = conf[1] - else - ret[conf.shift] = conf - end - } - - __font_optkeys.each{|optkey| - optkey = optkey.to_s - fontconf = ret[optkey] - if fontconf.kind_of?(Array) - ret.delete(optkey) - ret.delete('latin' << optkey) - ret.delete('ascii' << optkey) - ret.delete('kanji' << optkey) - fontconf[__configinfo_struct[:current_value]] = fontobj(optkey) - ret[optkey] = fontconf - end - } - - __methodcall_optkeys.each{|optkey, method| - ret[optkey.to_s] = ['', '', '', self.__send__(method)] - } - - ret - end + if slot + slot = slot.to_s + case slot + when /^(#{__methodcall_optkeys.keys.join('|')})$/ + method = _symbolkey2str(__methodcall_optkeys)[slot] + return {slot => ['', '', '', self.__send__(method)]} + + when /^(#{__numval_optkeys.join('|')})$/ + conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__config_cmd << "-#{slot}")))) + + if ( __configinfo_struct[:default_value] \ + && conf[__configinfo_struct[:default_value]] ) + begin + conf[__configinfo_struct[:default_value]] = + number(conf[__configinfo_struct[:default_value]]) + rescue + conf[__configinfo_struct[:default_value]] = nil + end + end + if ( conf[__configinfo_struct[:current_value]] ) + begin + conf[__configinfo_struct[:current_value]] = + number(conf[__configinfo_struct[:current_value]]) + rescue + conf[__configinfo_struct[:current_value]] = nil + end + end + + when /^(#{__numstrval_optkeys.join('|')})$/ + conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__config_cmd << "-#{slot}")))) + + if ( __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]] = + num_or_str(conf[__configinfo_struct[:current_value]]) + end + + when /^(#{__boolval_optkeys.join('|')})$/ + conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__config_cmd << "-#{slot}")))) + + if ( __configinfo_struct[:default_value] \ + && conf[__configinfo_struct[:default_value]] ) + begin + conf[__configinfo_struct[:default_value]] = + bool(conf[__configinfo_struct[:default_value]]) + rescue + conf[__configinfo_struct[:default_value]] = nil + end + end + if ( conf[__configinfo_struct[:current_value]] ) + begin + conf[__configinfo_struct[:current_value]] = + bool(conf[__configinfo_struct[:current_value]]) + rescue + conf[__configinfo_struct[:current_value]] = nil + end + end + + when /^(#{__listval_optkeys.join('|')})$/ + conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__config_cmd << "-#{slot}")))) + + if ( __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]] = + simplelist(conf[__configinfo_struct[:current_value]]) + end + + when /^(#{__numlistval_optkeys.join('|')})$/ + conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__config_cmd << "-#{slot}")))) + + if ( __configinfo_struct[:default_value] \ + && conf[__configinfo_struct[:default_value]] \ + && conf[__configinfo_struct[:default_value]] =~ /^[0-9]/ ) + 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]] = + list(conf[__configinfo_struct[:current_value]]) + end + + when /^(#{__strval_optkeys.join('|')})$/ + conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__config_cmd << "-#{slot}")))) + else + conf = tk_split_list(_fromUTF8(tk_send_without_enc(*(__config_cmd << "-#{slot}")))) + end + 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]][1..-1] + end + { conf[0] => conf[1] } + else + { conf.shift => conf } + end + + else + ret = {} + tk_split_simplelist(_fromUTF8(tk_call_without_enc(*__config_cmd))).each{|conflist| + conf = tk_split_simplelist(conflist) + conf[__configinfo_struct[:key]] = + conf[__configinfo_struct[:key]][1..-1] + + case conf[__configinfo_struct[:key]] + when /^(#{__strval_optkeys.join('|')})$/ + # do nothing + + when /^(#{__numval_optkeys.join('|')})$/ + if ( __configinfo_struct[:default_value] \ + && conf[__configinfo_struct[:default_value]] ) + begin + conf[__configinfo_struct[:default_value]] = + number(conf[__configinfo_struct[:default_value]]) + rescue + conf[__configinfo_struct[:default_value]] = nil + end + end + if ( conf[__configinfo_struct[:current_value]] ) + begin + conf[__configinfo_struct[:current_value]] = + number(conf[__configinfo_struct[:current_value]]) + rescue + conf[__configinfo_struct[:current_value]] = nil + end + end + + when /^(#{__numstrval_optkeys.join('|')})$/ + if ( __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]] = + num_or_str(conf[__configinfo_struct[:current_value]]) + end + + when /^(#{__boolval_optkeys.join('|')})$/ + if ( __configinfo_struct[:default_value] \ + && conf[__configinfo_struct[:default_value]] ) + begin + conf[__configinfo_struct[:default_value]] = + bool(conf[__configinfo_struct[:default_value]]) + rescue + conf[__configinfo_struct[:default_value]] = nil + end + end + if ( conf[__configinfo_struct[:current_value]] ) + begin + conf[__configinfo_struct[:current_value]] = + bool(conf[__configinfo_struct[:current_value]]) + rescue + conf[__configinfo_struct[:current_value]] = nil + end + end + + when /^(#{__listval_optkeys.join('|')})$/ + if ( __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]] = + simplelist(conf[__configinfo_struct[:current_value]]) + end + + when /^(#{__numlistval_optkeys.join('|')})$/ + if ( __configinfo_struct[:default_value] \ + && conf[__configinfo_struct[:default_value]] \ + && conf[__configinfo_struct[:default_value]] =~ /^[0-9]/ ) + 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]] = + list(conf[__configinfo_struct[:current_value]]) + end + + else + 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]]) + else + 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]]) + else + conf[__configinfo_struct[:current_value]] = + tk_tcl2ruby(conf[__configinfo_struct[:current_value]]) + end + end + end + + if ( __configinfo_struct[:alias] \ + && conf.size == __configinfo_struct[:alias] + 1 ) + if conf[__configinfo_struct[:alias]][0] == ?- + conf[__configinfo_struct[:alias]] = + conf[__configinfo_struct[:alias]][1..-1] + end + ret[conf[0]] = conf[1] + else + ret[conf.shift] = conf + end + } + + __font_optkeys.each{|optkey| + optkey = optkey.to_s + fontconf = ret[optkey] + if fontconf.kind_of?(Array) + ret.delete(optkey) + ret.delete('latin' << optkey) + ret.delete('ascii' << optkey) + ret.delete('kanji' << optkey) + fontconf[__configinfo_struct[:current_value]] = fontobj(optkey) + ret[optkey] = fontconf + end + } + + __methodcall_optkeys.each{|optkey, method| + ret[optkey.to_s] = ['', '', '', self.__send__(method)] + } + + ret + end end end end @@ -3103,31 +3103,31 @@ module TkConfigMethod def current_configinfo(slot = nil) if TkComm::GET_CONFIGINFO_AS_ARRAY if slot - org_slot = slot - begin - conf = configinfo(slot) - if ( ! __configinfo_struct[:alias] \ - || conf.size > __configinfo_struct[:alias] + 1 ) - return {conf[0] => conf[-1]} - end - slot = conf[__configinfo_struct[:alias]] - end while(org_slot != slot) - fail RuntimeError, - "there is a configure alias loop about '#{org_slot}'" + org_slot = slot + begin + conf = configinfo(slot) + if ( ! __configinfo_struct[:alias] \ + || conf.size > __configinfo_struct[:alias] + 1 ) + return {conf[0] => conf[-1]} + end + slot = conf[__configinfo_struct[:alias]] + end while(org_slot != slot) + fail RuntimeError, + "there is a configure alias loop about '#{org_slot}'" else - ret = {} - configinfo().each{|conf| - if ( ! __configinfo_struct[:alias] \ - || conf.size > __configinfo_struct[:alias] + 1 ) - ret[conf[0]] = conf[-1] - end - } - ret + ret = {} + configinfo().each{|conf| + if ( ! __configinfo_struct[:alias] \ + || conf.size > __configinfo_struct[:alias] + 1 ) + ret[conf[0]] = conf[-1] + end + } + ret end else # ! TkComm::GET_CONFIGINFO_AS_ARRAY ret = {} - configinfo(slot).each{|key, conf| - ret[key] = conf[-1] if conf.kind_of?(Array) + configinfo(slot).each{|key, conf| + ret[key] = conf[-1] if conf.kind_of?(Array) } ret end @@ -3169,17 +3169,17 @@ class TkObject", *hash_kv(keys)) + # "<#{tk_event_sequence(context)}>", *hash_kv(keys)) tk_call_without_enc('event', 'generate', path, - "<#{tk_event_sequence(context)}>", - *hash_kv(keys, true)) + "<#{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_event_sequence(context)}>") + "<#{tk_event_sequence(context)}>") end end @@ -3277,24 +3277,24 @@ class TkWindow -# $Date$ -# by Hidetoshi Nagai +# tk/canvas.rb - Tk canvas classes +# $Date$ +# by Yukihiro Matsumoto # require 'tk' require 'tk/canvastag' @@ -93,7 +91,7 @@ class TkCanvasvalue}) - end + key == 'kanjifont' || key == :kanjifont || + key == 'latinfont' || key == :latinfont || + key == 'asciifont' || key == :asciifont ) + if value == None + tagfontobj(tagid(tagOrId)) + else + tagfont_configure(tagid(tagOrId), {key=>value}) + end else - _fromUTF8(tk_send_without_enc('itemconfigure', tagid(tagOrId), - "-#{key}", _get_eval_enc_str(value))) + _fromUTF8(tk_send_without_enc('itemconfigure', tagid(tagOrId), + "-#{key}", _get_eval_enc_str(value))) end end self @@ -294,142 +292,142 @@ class TkCanvas ['', '', '', self.coords(tagOrId)]} - when 'dash', 'activedash', 'disableddash' - conf = tk_split_simplelist(tk_send_without_enc('itemconfigure', - tagid(tagOrId), - "-#{key}")) - if conf[3] && conf[3] =~ /^[0-9]/ - conf[3] = list(conf[3]) - end - if conf[4] && conf[4] =~ /^[0-9]/ - conf[4] = list(conf[4]) - end - when 'text', 'label', 'show', 'data', 'file', 'maskdata', 'maskfile' - conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('itemconfigure', tagid(tagOrId), "-#{key}"))) - when 'font', 'kanjifont' - conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('itemconfigure', tagid(tagOrId),"-#{key}"))) - conf[4] = tagfont_configinfo(tagid(tagOrId), conf[4]) - else - conf = tk_split_list(_fromUTF8(tk_send_without_enc('itemconfigure', tagid(tagOrId), "-#{key}"))) - end - key = conf.shift[1..-1] - { key => conf } + case key.to_s + when 'coords' + {'coords' => ['', '', '', self.coords(tagOrId)]} + when 'dash', 'activedash', 'disableddash' + conf = tk_split_simplelist(tk_send_without_enc('itemconfigure', + tagid(tagOrId), + "-#{key}")) + if conf[3] && conf[3] =~ /^[0-9]/ + conf[3] = list(conf[3]) + end + if conf[4] && conf[4] =~ /^[0-9]/ + conf[4] = list(conf[4]) + end + when 'text', 'label', 'show', 'data', 'file', 'maskdata', 'maskfile' + conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('itemconfigure', tagid(tagOrId), "-#{key}"))) + when 'font', 'kanjifont' + conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('itemconfigure', tagid(tagOrId),"-#{key}"))) + conf[4] = tagfont_configinfo(tagid(tagOrId), conf[4]) + else + conf = tk_split_list(_fromUTF8(tk_send_without_enc('itemconfigure', tagid(tagOrId), "-#{key}"))) + end + key = conf.shift[1..-1] + { key => conf } else - ret = {} - tk_split_simplelist(_fromUTF8(tk_send_without_enc('itemconfigure', tagid(tagOrId)))).each{|conflist| - conf = tk_split_simplelist(conflist) - key = conf.shift[1..-1] - case key - when 'text', 'label', 'show', 'data', 'file', 'maskdata', 'maskfile' - when 'dash', 'activedash', 'disableddash' - if conf[2] && conf[2] =~ /^[0-9]/ - conf[2] = list(conf[2]) - end - if conf[3] && conf[3] =~ /^[0-9]/ - conf[3] = list(conf[3]) - end - else - if conf[2] - if conf[2].index('{') - conf[2] = tk_split_list(conf[2]) - else - conf[2] = tk_tcl2ruby(conf[2]) - end - end - if conf[3] - if conf[3].index('{') - conf[3] = tk_split_list(conf[3]) - else - conf[3] = tk_tcl2ruby(conf[3]) - end - end - end - if conf.size == 1 - ret[key] = conf[0][1..-1] # alias info - else - ret[key] = conf - end - } - - fontconf = ret['font'] - if fontconf - ret.delete('font') - ret.delete('kanjifont') - fontconf[3] = tagfont_configinfo(tagid(tagOrId), fontconf[3]) - ret['font'] = fontconf - end - - ret['coords'] = ['', '', '', self.coords(tagOrId)] - - ret + ret = {} + tk_split_simplelist(_fromUTF8(tk_send_without_enc('itemconfigure', tagid(tagOrId)))).each{|conflist| + conf = tk_split_simplelist(conflist) + key = conf.shift[1..-1] + case key + when 'text', 'label', 'show', 'data', 'file', 'maskdata', 'maskfile' + when 'dash', 'activedash', 'disableddash' + if conf[2] && conf[2] =~ /^[0-9]/ + conf[2] = list(conf[2]) + end + if conf[3] && conf[3] =~ /^[0-9]/ + conf[3] = list(conf[3]) + end + else + if conf[2] + if conf[2].index('{') + conf[2] = tk_split_list(conf[2]) + else + conf[2] = tk_tcl2ruby(conf[2]) + end + end + if conf[3] + if conf[3].index('{') + conf[3] = tk_split_list(conf[3]) + else + conf[3] = tk_tcl2ruby(conf[3]) + end + end + end + if conf.size == 1 + ret[key] = conf[0][1..-1] # alias info + else + ret[key] = conf + end + } + + fontconf = ret['font'] + if fontconf + ret.delete('font') + ret.delete('kanjifont') + fontconf[3] = tagfont_configinfo(tagid(tagOrId), fontconf[3]) + ret['font'] = fontconf + end + + ret['coords'] = ['', '', '', self.coords(tagOrId)] + + ret end end end @@ -437,19 +435,19 @@ class TkCanvas conf[4]} + conf = itemconfiginfo(tagOrId, key) + {conf[0] => conf[4]} else - ret = {} - itemconfiginfo(tagOrId).each{|conf| - ret[conf[0]] = conf[4] if conf.size > 2 - } - ret + ret = {} + itemconfiginfo(tagOrId).each{|conf| + ret[conf[0]] = conf[4] if conf.size > 2 + } + ret end else # ! TkComm::GET_CONFIGINFO_AS_ARRAY ret = {} itemconfiginfo(tagOrId, key).each{|k, conf| - ret[k] = conf[-1] if conf.kind_of?(Array) + ret[k] = conf[-1] if conf.kind_of?(Array) } ret end @@ -551,32 +549,32 @@ class TkcItem m_set, :cget => m_cget, :info => m_info + :set => m_set, :cget => m_cget, :info => m_info } } end @@ -55,9 +55,9 @@ module TkComposite option = option.to_s if @delegates[alias_opt].kind_of?(Array) if (elem = @delegates[alias_opt].assoc(option)) - wins.each{|w| elem[1].push(w)} + wins.each{|w| elem[1].push(w)} else - @delegates[alias_opt] << [option, wins] + @delegates[alias_opt] << [option, wins] end else @delegates[alias_opt] = [ [option, wins] ] @@ -73,13 +73,13 @@ module TkComposite if @option_methods.include?(slot) if @option_methods[slot][:cget] - return self.__send__(@option_methods[slot][:cget]) + return self.__send__(@option_methods[slot][:cget]) else - if @option_setting[slot] - return @option_setting[slot] - else - return '' - end + if @option_setting[slot] + return @option_setting[slot] + else + return '' + end end end @@ -88,11 +88,11 @@ module TkComposite begin if tbl - opt, wins = tbl[-1] - opt = slot if opt == 'DEFAULT' - if wins && wins[-1] - return wins[-1].cget(opt) - end + opt, wins = tbl[-1] + opt = slot if opt == 'DEFAULT' + if wins && wins[-1] + return wins[-1].cget(opt) + end end rescue end @@ -110,11 +110,11 @@ module TkComposite if @option_methods.include?(slot) unless @option_methods[slot][:cget] - if value.kind_of?(Symbol) - @option_setting[slot] = value.to_s - else - @option_setting[slot] = value - end + if value.kind_of?(Symbol) + @option_setting[slot] = value.to_s + else + @option_setting[slot] = value + end end return self.__send__(@option_methods[slot][:set], value) end @@ -124,12 +124,12 @@ module TkComposite begin if tbl - last = nil - tbl.each{|opt, wins| - opt = slot if opt == 'DEFAULT' - wins.each{|w| last = w.configure(opt, value)} - } - return last + last = nil + tbl.each{|opt, wins| + opt = slot if opt == 'DEFAULT' + wins.each{|w| last = w.configure(opt, value)} + } + return last end rescue end @@ -140,153 +140,153 @@ module TkComposite def configinfo(slot = nil) if TkComm::GET_CONFIGINFO_AS_ARRAY if slot - slot = slot.to_s - if @option_methods.include?(slot) - if @option_methods[slot][:info] - return self.__send__(@option_methods[slot][:info]) - else - return [slot, '', '', '', self.cget(slot)] - end - end - - tbl = @delegates[slot] - tbl = @delegates['DEFAULT'] unless tbl - - begin - if tbl - if tbl.length == 1 - opt, wins = tbl[0] - if slot == opt || opt == 'DEFAULT' - return wins[-1].configinfo(slot) - else - info = wins[-1].configinfo(opt) - info[0] = slot - return info - end - else - opt, wins = tbl[-1] - return [slot, '', '', '', wins[-1].cget(opt)] - end - end - rescue - end - - super + slot = slot.to_s + if @option_methods.include?(slot) + if @option_methods[slot][:info] + return self.__send__(@option_methods[slot][:info]) + else + return [slot, '', '', '', self.cget(slot)] + end + end + + tbl = @delegates[slot] + tbl = @delegates['DEFAULT'] unless tbl + + begin + if tbl + if tbl.length == 1 + opt, wins = tbl[0] + if slot == opt || opt == 'DEFAULT' + return wins[-1].configinfo(slot) + else + info = wins[-1].configinfo(opt) + info[0] = slot + return info + end + else + opt, wins = tbl[-1] + return [slot, '', '', '', wins[-1].cget(opt)] + end + end + rescue + end + + super else # slot == nil - info_list = super - - tbl = @delegates['DEFAULT'] - if tbl - wins = tbl[0][1] - if wins && wins[-1] - wins[-1].configinfo.each{|info| - slot = info[0] - info_list.delete_if{|i| i[0] == slot} << info - } - end - end - - @delegates.each{|slot, tbl| - next if slot == 'DEFAULT' - if tbl.length == 1 - opt, wins = tbl[0] - next unless wins && wins[-1] - if slot == opt - info_list.delete_if{|i| i[0] == slot} << - wins[-1].configinfo(slot) - else - info = wins[-1].configinfo(opt) - info[0] = slot - info_list.delete_if{|i| i[0] == slot} << info - end - else - opt, wins = tbl[-1] - info_list.delete_if{|i| i[0] == slot} << - [slot, '', '', '', wins[-1].cget(opt)] - end - } - - @option_methods.each{|slot, m| - if m[:info] - info = self.__send__(m[:info]) - else - info = [slot, '', '', '', self.cget(slot)] - end - info_list.delete_if{|i| i[0] == slot} << info - } - - info_list + info_list = super + + tbl = @delegates['DEFAULT'] + if tbl + wins = tbl[0][1] + if wins && wins[-1] + wins[-1].configinfo.each{|info| + slot = info[0] + info_list.delete_if{|i| i[0] == slot} << info + } + end + end + + @delegates.each{|slot, tbl| + next if slot == 'DEFAULT' + if tbl.length == 1 + opt, wins = tbl[0] + next unless wins && wins[-1] + if slot == opt + info_list.delete_if{|i| i[0] == slot} << + wins[-1].configinfo(slot) + else + info = wins[-1].configinfo(opt) + info[0] = slot + info_list.delete_if{|i| i[0] == slot} << info + end + else + opt, wins = tbl[-1] + info_list.delete_if{|i| i[0] == slot} << + [slot, '', '', '', wins[-1].cget(opt)] + end + } + + @option_methods.each{|slot, m| + if m[:info] + info = self.__send__(m[:info]) + else + info = [slot, '', '', '', self.cget(slot)] + end + info_list.delete_if{|i| i[0] == slot} << info + } + + info_list end else # ! TkComm::GET_CONFIGINFO_AS_ARRAY if slot - slot = slot.to_s - if @option_methods.include?(slot) - if @option_methods[slot][:info] - return self.__send__(@option_methods[slot][:info]) - else - return {slot => ['', '', '', self.cget(slot)]} - end - end - - tbl = @delegates[slot] - tbl = @delegates['DEFAULT'] unless tbl - - begin - if tbl - if tbl.length == 1 - opt, wins = tbl[0] - if slot == opt || opt == 'DEFAULT' - return wins[-1].configinfo(slot) - else - return {slot => wins[-1].configinfo(opt)[opt]} - end - else - opt, wins = tbl[-1] - return {slot => ['', '', '', wins[-1].cget(opt)]} - end - end - rescue - end - - super + slot = slot.to_s + if @option_methods.include?(slot) + if @option_methods[slot][:info] + return self.__send__(@option_methods[slot][:info]) + else + return {slot => ['', '', '', self.cget(slot)]} + end + end + + tbl = @delegates[slot] + tbl = @delegates['DEFAULT'] unless tbl + + begin + if tbl + if tbl.length == 1 + opt, wins = tbl[0] + if slot == opt || opt == 'DEFAULT' + return wins[-1].configinfo(slot) + else + return {slot => wins[-1].configinfo(opt)[opt]} + end + else + opt, wins = tbl[-1] + return {slot => ['', '', '', wins[-1].cget(opt)]} + end + end + rescue + end + + super else # slot == nil - info_list = super - - tbl = @delegates['DEFAULT'] - if tbl - wins = tbl[0][1] - info_list.update(wins[-1].configinfo) if wins && wins[-1] - end - - @delegates.each{|slot, tbl| - next if slot == 'DEFAULT' - if tbl.length == 1 - opt, wins = tbl[0] - next unless wins && wins[-1] - if slot == opt - info_list.update(wins[-1].configinfo(slot)) - else - info_list.update({slot => wins[-1].configinfo(opt)[opt]}) - end - else - opt, wins = tbl[-1] - info_list.update({slot => ['', '', '', wins[-1].cget(opt)]}) - end - } - - @option_methods.each{|slot, m| - if m[:info] - info = self.__send__(m[:info]) - else - info = {slot => ['', '', '', self.cget(slot)]} - end - info_list.update(info) - } - - info_list + info_list = super + + tbl = @delegates['DEFAULT'] + if tbl + wins = tbl[0][1] + info_list.update(wins[-1].configinfo) if wins && wins[-1] + end + + @delegates.each{|slot, tbl| + next if slot == 'DEFAULT' + if tbl.length == 1 + opt, wins = tbl[0] + next unless wins && wins[-1] + if slot == opt + info_list.update(wins[-1].configinfo(slot)) + else + info_list.update({slot => wins[-1].configinfo(opt)[opt]}) + end + else + opt, wins = tbl[-1] + info_list.update({slot => ['', '', '', wins[-1].cget(opt)]}) + end + } + + @option_methods.each{|slot, m| + if m[:info] + info = self.__send__(m[:info]) + else + info = {slot => ['', '', '', self.cget(slot)]} + end + info_list.update(info) + } + + info_list end end end diff --git a/ext/tk/lib/tk/console.rb b/ext/tk/lib/tk/console.rb index 855ee6a94f..f0d2c7aa87 100644 --- a/ext/tk/lib/tk/console.rb +++ b/ext/tk/lib/tk/console.rb @@ -24,6 +24,6 @@ module TkConsole # I have no idea to support a Ruby script seamlessly. # _fromUTF8(tk_call_without_enc('console', 'eval', - _get_eval_enc_str(tcl_script))) + _get_eval_enc_str(tcl_script))) end end diff --git a/ext/tk/lib/tk/dialog.rb b/ext/tk/lib/tk/dialog.rb index d6355f21c1..2ced26b193 100644 --- a/ext/tk/lib/tk/dialog.rb +++ b/ext/tk/lib/tk/dialog.rb @@ -17,34 +17,34 @@ class TkDialog2 < TkWindow def _set_button_config(configs) set_config = proc{|c,i| if $VERBOSE && (c.has_key?('command') || c.has_key?(:command)) - STDERR.print("Warning: cannot give a command option " + - "to the dialog button#{i}. It was removed.\n") + STDERR.print("Warning: cannot give a command option " + + "to the dialog button#{i}. It was removed.\n") end c.delete('command'); c.delete(:command) # @config << Kernel.format("%s.button%s configure %s; ", - # @path, i, hash_kv(c).join(' ')) + # @path, i, hash_kv(c).join(' ')) @config << @path+'.button'+i.to_s+'configure '+hash_kv(c).join(' ')+'; ' } case configs when Proc @buttons.each_index{|i| - if (c = configs.call(i)).kind_of? Hash - set_config.call(c,i) - end + if (c = configs.call(i)).kind_of? Hash + set_config.call(c,i) + end } when Array @buttons.each_index{|i| - if (c = configs[i]).kind_of? Hash - set_config.call(c,i) - end + if (c = configs[i]).kind_of? Hash + set_config.call(c,i) + end } when Hash @buttons.each_with_index{|s,i| - if (c = configs[s]).kind_of? Hash - set_config.call(c,i) - end + if (c = configs[s]).kind_of? Hash + set_config.call(c,i) + end } end @config = 'after idle {' + @config + '};' if @config != "" @@ -99,7 +99,7 @@ class TkDialog2 < TkWindow if @buttons.kind_of? Array _set_button_config(@buttons.collect{|cfg| - (cfg.kind_of? Array)? cfg[1]: nil}) + (cfg.kind_of? Array)? cfg[1]: nil}) @buttons = @buttons.collect{|cfg| (cfg.kind_of? Array)? cfg[0]: cfg} end if @buttons.kind_of? Hash @@ -109,36 +109,36 @@ class TkDialog2 < TkWindow @buttons = tk_split_simplelist(@buttons) if @buttons.kind_of? String @buttons = @buttons.collect{|s| if s.kind_of? Array - s = s.join(' ') + s = s.join(' ') end if s.include? ?\s - '{' + s + '}' + '{' + s + '}' else - s + s end } if @message_config.kind_of? Hash # @config << Kernel.format("%s.msg configure %s;", - # @path, hash_kv(@message_config).join(' ')) + # @path, hash_kv(@message_config).join(' ')) @config << @path+'.msg configure '+hash_kv(@message_config).join(' ')+';' end if @msgframe_config.kind_of? Hash # @config << Kernel.format("%s.top configure %s;", - # @path, hash_kv(@msgframe_config).join(' ')) + # @path, hash_kv(@msgframe_config).join(' ')) @config << @path+'.top configure '+hash_kv(@msgframe_config).join(' ')+';' end if @btnframe_config.kind_of? Hash # @config << Kernel.format("%s.bot configure %s;", - # @path, hash_kv(@btnframe_config).join(' ')) + # @path, hash_kv(@btnframe_config).join(' ')) @config << @path+'.bot configure '+hash_kv(@btnframe_config).join(' ')+';' end if @bitmap_config.kind_of? Hash # @config << Kernel.format("%s.bitmap configure %s;", - # @path, hash_kv(@bitmap_config).join(' ')) + # @path, hash_kv(@bitmap_config).join(' ')) @config << @path+'.bitmap configure '+hash_kv(@bitmap_config).join(' ')+';' end @@ -158,16 +158,16 @@ class TkDialog2 < TkWindow end default_button = '{}' if default_button == nil #Tk.ip_eval('eval {global '+@var.id+';'+@config+ - # 'set '+@var.id+' [tk_dialog '+ - # @path+" "+@title+" {#{@message}} "+@bitmap+" "+ - # String(default_button)+" "+@buttons.join(' ')+']}') + # 'set '+@var.id+' [tk_dialog '+ + # @path+" "+@title+" {#{@message}} "+@bitmap+" "+ + # String(default_button)+" "+@buttons.join(' ')+']}') Tk.ip_eval(@config) # @val = Tk.ip_eval('tk_dialog ' + @path + ' ' + @title + - # ' {' + @message + '} ' + @bitmap + ' ' + - # String(default_button) + ' ' + @buttons.join(' ')).to_i + # ' {' + @message + '} ' + @bitmap + ' ' + + # String(default_button) + ' ' + @buttons.join(' ')).to_i @val = Tk.ip_eval(self.class::TkCommandNames[0] + ' ' + @path + ' ' + - @title + ' {' + @message + '} ' + @bitmap + ' ' + - String(default_button) + ' ' + @buttons.join(' ')).to_i + @title + ' {' + @message + '} ' + @bitmap + ' ' + + String(default_button) + ' ' + @buttons.join(' ')).to_i end def value @@ -248,10 +248,10 @@ class TkWarning2 < TkDialog2 def initialize(parent = nil, mes = nil) if !mes if parent.kind_of? TkWindow - mes = "" + mes = "" else - mes = parent.to_s - parent = nil + mes = parent.to_s + parent = nil end end super(parent, :message=>mes) diff --git a/ext/tk/lib/tk/encodedstr.rb b/ext/tk/lib/tk/encodedstr.rb index 5eb989f420..aed0e7524e 100644 --- a/ext/tk/lib/tk/encodedstr.rb +++ b/ext/tk/lib/tk/encodedstr.rb @@ -24,11 +24,11 @@ module Tk def self.utf_to_backslash_sequence(str) str.unpack('U*').collect{|c| - if c <= 0xFF # ascii character - c.chr - else - format('\u%X', c) - end + if c <= 0xFF # ascii character + c.chr + else + format('\u%X', c) + end }.join('') end def self.utf_to_backslash(str) @@ -37,23 +37,23 @@ module Tk def self.to_backslash_sequence(str) str.unpack('U*').collect{|c| - if c <= 0x1F # control character - case c - when 0x07; '\a' - when 0x08; '\b' - when 0x09; '\t' - when 0x0a; '\n' - when 0x0b; '\v' - when 0x0c; '\f' - when 0x0d; '\r' - else - format('\x%02X', c) - end - elsif c <= 0xFF # ascii character - c.chr - else - format('\u%X', c) - end + if c <= 0x1F # control character + case c + when 0x07; '\a' + when 0x08; '\b' + when 0x09; '\t' + when 0x0a; '\n' + when 0x0b; '\v' + when 0x0c; '\f' + when 0x0d; '\r' + else + format('\x%02X', c) + end + elsif c <= 0xFF # ascii character + c.chr + else + format('\u%X', c) + end }.join('') end @@ -68,8 +68,8 @@ module Tk def initialize(str, enc = nil) super(str) @encoding = ( enc || - ((self.class::Encoding)? - self.class::Encoding : Tk.encoding_system) ) + ((self.class::Encoding)? + self.class::Encoding : Tk.encoding_system) ) end attr_reader :encoding diff --git a/ext/tk/lib/tk/entry.rb b/ext/tk/lib/tk/entry.rb index 0e45538c76..2a8a9d413c 100644 --- a/ext/tk/lib/tk/entry.rb +++ b/ext/tk/lib/tk/entry.rb @@ -1,7 +1,7 @@ # -# tk/entry.rb - Tk entry classes -# $Date$ -# by Yukihiro Matsumoto +# tk/entry.rb - Tk entry classes +# $Date$ +# by Yukihiro Matsumoto require 'tk' require 'tk/label' diff --git a/ext/tk/lib/tk/event.rb b/ext/tk/lib/tk/event.rb index 9c46cb5d75..16adeedc6c 100644 --- a/ext/tk/lib/tk/event.rb +++ b/ext/tk/lib/tk/event.rb @@ -33,7 +33,7 @@ module TkEvent CreateNotify = 16 DestroyNotify = 17 UnmapNotify = 18 - MapNotify = 19 + MapNotify = 19 MapRequest = 20 ReparentNotify = 21 ConfigureNotify = 22 @@ -93,12 +93,12 @@ module TkEvent [ ?w, TkComm.method(:window) ], [ ?x, proc{|val| - begin - TkComm::number(val) - rescue ArgumentError - val - end - } + begin + TkComm::number(val) + rescue ArgumentError + val + end + } ], nil @@ -141,14 +141,14 @@ module TkEvent keys = klass._get_subst_key(args) if cmd.kind_of?(String) - id = cmd + id = cmd elsif cmd.kind_of?(TkCallbackEntry) - id = install_cmd(cmd) + id = install_cmd(cmd) else - id = install_cmd(proc{|*arg| - ex_args = [] - extra_args_tbl.reverse_each{|conv| ex_args << conv.call(arg.pop)} - TkUtil.eval_cmd(cmd, *(ex_args.concat(klass.scan_args(keys, arg)))) + id = install_cmd(proc{|*arg| + ex_args = [] + extra_args_tbl.reverse_each{|conv| ex_args << conv.call(arg.pop)} + TkUtil.eval_cmd(cmd, *(ex_args.concat(klass.scan_args(keys, arg)))) }) end id + ' ' + args @@ -156,15 +156,15 @@ module TkEvent keys, args = klass._get_all_subst_keys if cmd.kind_of?(String) - id = cmd + id = cmd elsif cmd.kind_of?(TkCallbackEntry) - id = install_cmd(cmd) + id = install_cmd(cmd) else id = install_cmd(proc{|*arg| - ex_args = [] - extra_args_tbl.reverse_each{|conv| ex_args << conv.call(arg.pop)} - TkUtil.eval_cmd(cmd, - *(ex_args << klass.new(*klass.scan_args(keys, arg)))) + ex_args = [] + extra_args_tbl.reverse_each{|conv| ex_args << conv.call(arg.pop)} + TkUtil.eval_cmd(cmd, + *(ex_args << klass.new(*klass.scan_args(keys, arg)))) }) end id + ' ' + args diff --git a/ext/tk/lib/tk/font.rb b/ext/tk/lib/tk/font.rb index 527584f1ed..02e09c6066 100644 --- a/ext/tk/lib/tk/font.rb +++ b/ext/tk/lib/tk/font.rb @@ -30,36 +30,36 @@ class TkFont if JAPANIZED_TK begin fontnames = tk_call('font', 'names') - case fontnames - when /defaultgui/ + case fontnames + when /defaultgui/ # Tcl/Tk-JP for Windows ltn = 'defaultgui' knj = 'defaultgui' - when /Mincho:Helvetica-Bold-12/ + when /Mincho:Helvetica-Bold-12/ # Tcl/Tk-JP for UNIX/X ltn, knj = tk_split_simplelist(tk_call('font', 'configure', 'Mincho:Helvetica-Bold-12', '-compound')) else # unknown Tcl/Tk-JP - platform = tk_call('set', 'tcl_platform(platform)') - case platform - when 'unix' - ltn = {'family'=>'Helvetica'.freeze, - 'size'=>-12, 'weight'=>'bold'.freeze} - #knj = 'k14' - #knj = '-misc-fixed-medium-r-normal--14-*-*-*-c-*-jisx0208.1983-0' - knj = '-*-fixed-bold-r-normal--12-*-*-*-c-*-jisx0208.1983-0' - when 'windows' - ltn = {'family'=>'MS Sans Serif'.freeze, 'size'=>8} - knj = 'mincho' - when 'macintosh' - ltn = 'system' - knj = 'mincho' - else # unknown - ltn = 'Helvetica' - knj = 'mincho' - end + platform = tk_call('set', 'tcl_platform(platform)') + case platform + when 'unix' + ltn = {'family'=>'Helvetica'.freeze, + 'size'=>-12, 'weight'=>'bold'.freeze} + #knj = 'k14' + #knj = '-misc-fixed-medium-r-normal--14-*-*-*-c-*-jisx0208.1983-0' + knj = '-*-fixed-bold-r-normal--12-*-*-*-c-*-jisx0208.1983-0' + when 'windows' + ltn = {'family'=>'MS Sans Serif'.freeze, 'size'=>8} + knj = 'mincho' + when 'macintosh' + ltn = 'system' + knj = 'mincho' + else # unknown + ltn = 'Helvetica' + knj = 'mincho' + end end rescue ltn = 'Helvetica' @@ -68,20 +68,20 @@ class TkFont else # not JAPANIZED_TK begin - platform = tk_call('set', 'tcl_platform(platform)') - case platform - when 'unix' - ltn = {'family'=>'Helvetica'.freeze, - 'size'=>-12, 'weight'=>'bold'.freeze} - when 'windows' - ltn = {'family'=>'MS Sans Serif'.freeze, 'size'=>8} - when 'macintosh' - ltn = 'system' - else # unknown - ltn = 'Helvetica' - end + platform = tk_call('set', 'tcl_platform(platform)') + case platform + when 'unix' + ltn = {'family'=>'Helvetica'.freeze, + 'size'=>-12, 'weight'=>'bold'.freeze} + when 'windows' + ltn = {'family'=>'MS Sans Serif'.freeze, 'size'=>8} + when 'macintosh' + ltn = 'system' + else # unknown + ltn = 'Helvetica' + end rescue - ltn = 'Helvetica' + ltn = 'Helvetica' end knj = ltn.dup @@ -106,14 +106,14 @@ class TkFont class DescendantFont def initialize(compound, type) unless compound.kind_of?(TkFont) - fail ArgumentError, "a TkFont object is expected for the 1st argument" + fail ArgumentError, "a TkFont object is expected for the 1st argument" end @compound = compound case type when 'kanji', 'latin', 'ascii' - @type = type + @type = type else - fail ArgumentError, "unknown type '#{type}'" + fail ArgumentError, "unknown type '#{type}'" end end @@ -155,9 +155,9 @@ class TkFont when /^8\.*/ if window - tk_split_simplelist(tk_call('font', 'families', '-displayof', window)) + tk_split_simplelist(tk_call('font', 'families', '-displayof', window)) else - tk_split_simplelist(tk_call('font', 'families')) + tk_split_simplelist(tk_call('font', 'families')) end end end @@ -205,11 +205,11 @@ class TkFont regexp = /^-(|kanji)#{key} / conf_list = tk_split_simplelist(tk_call(*args)). - find_all{|prop| prop =~ regexp}. - collect{|prop| tk_split_simplelist(prop)} + find_all{|prop| prop =~ regexp}. + collect{|prop| tk_split_simplelist(prop)} if conf_list.size == 0 - raise RuntimeError, "the widget may not support 'font' option" + raise RuntimeError, "the widget may not support 'font' option" end args << {} @@ -231,11 +231,11 @@ class TkFont regexp = /^-#{key} / conf_list = tk_split_simplelist(tk_call(*args)). - find_all{|prop| prop =~ regexp}. - collect{|prop| tk_split_simplelist(prop)} + find_all{|prop| prop =~ regexp}. + collect{|prop| tk_split_simplelist(prop)} if conf_list.size == 0 - raise RuntimeError, "the widget may not support 'font' option" + raise RuntimeError, "the widget may not support 'font' option" end args << {} @@ -247,23 +247,23 @@ class TkFont fnt = nil if fnt == [] || fnt == "" unless fnt - TkFont.new(nil, nil).call_font_configure([path, key], *args) + TkFont.new(nil, nil).call_font_configure([path, key], *args) else - begin - compound = tk_split_simplelist( + begin + compound = tk_split_simplelist( Hash[*tk_split_simplelist(tk_call('font', 'configure', - fnt))].collect{|key,value| + fnt))].collect{|key,value| [key[1..-1], value] }.assoc('compound')[1]) - rescue - compound = [] - end - if compound == [] - TkFont.new(fnt).call_font_configure([path, key], *args) - else - TkFont.new(compound[0], - compound[1]).call_font_configure([path, key], *args) - end + rescue + compound = [] + end + if compound == [] + TkFont.new(fnt).call_font_configure([path, key], *args) + else + TkFont.new(compound[0], + compound[1]).call_font_configure([path, key], *args) + end end end end @@ -307,33 +307,33 @@ class TkFont # compound font check if Tk::TK_VERSION == '8.0' && JAPANIZED_TK begin - compound = tk_split_simplelist(tk_call('font', 'configure', - ltn, '-compound')) - if knj == nil - if compound != [] - ltn, knj = compound - end - else - if compound != [] - ltn = compound[0] - end - compound = tk_split_simplelist(tk_call('font', 'configure', - knj, '-compound')) - if compound != [] - knj = compound[1] - end - end + compound = tk_split_simplelist(tk_call('font', 'configure', + ltn, '-compound')) + if knj == nil + if compound != [] + ltn, knj = compound + end + else + if compound != [] + ltn = compound[0] + end + compound = tk_split_simplelist(tk_call('font', 'configure', + knj, '-compound')) + if compound != [] + knj = compound[1] + end + end rescue end end if ltn if JAPANIZED_TK && !knj - if Tk::TK_VERSION =~ /^4.*/ - knj = DEFAULT_KANJI_FONT_NAME - else - knj = ltn - end + if Tk::TK_VERSION =~ /^4.*/ + knj = DEFAULT_KANJI_FONT_NAME + else + knj = ltn + end end else ltn = DEFAULT_LATIN_FONT_NAME @@ -372,28 +372,28 @@ class TkFont finfo = {} finfo['family'] = font[0].to_s if font[1] - fsize = font[1].to_s - if fsize != '0' && fsize =~ /^(|\+|-)([0-9]+)$/ - if $1 == '-' - finfo['pixels'] = $2 - else - finfo['points'] = $2 - end - else - finfo['points'] = '13' - end + fsize = font[1].to_s + if fsize != '0' && fsize =~ /^(|\+|-)([0-9]+)$/ + if $1 == '-' + finfo['pixels'] = $2 + else + finfo['points'] = $2 + end + else + finfo['points'] = '13' + end end font[2..-1].each{|style| - case (style) - when 'normal' - finfo['weight'] = style - when 'bold' - finfo['weight'] = style - when 'roman' - finfo['slant'] = 'r' - when 'italic' - finfo['slant'] = 'i' - end + case (style) + when 'normal' + finfo['weight'] = style + when 'bold' + finfo['weight'] = style + when 'roman' + finfo['slant'] = 'r' + when 'italic' + finfo['slant'] = 'i' + end } @latinfont = '-' + _get_font_info_from_hash(finfo).join('-') + '-' @@ -424,28 +424,28 @@ class TkFont finfo = {} finfo['family'] = font[0].to_s if font[1] - fsize = font[1].to_s - if fsize != '0' && fsize =~ /^(|\+|-)([0-9]+)$/ - if $1 == '-' - finfo['pixels'] = $2 - else - finfo['points'] = $2 - end - else - finfo['points'] = '13' - end + fsize = font[1].to_s + if fsize != '0' && fsize =~ /^(|\+|-)([0-9]+)$/ + if $1 == '-' + finfo['pixels'] = $2 + else + finfo['points'] = $2 + end + else + finfo['points'] = '13' + end end font[2..-1].each{|style| - case (style) - when 'normal' - finfo['weight'] = style - when 'bold' - finfo['weight'] = style - when 'roman' - finfo['slant'] = 'r' - when 'italic' - finfo['slant'] = 'i' - end + case (style) + when 'normal' + finfo['weight'] = style + when 'bold' + finfo['weight'] = style + when 'roman' + finfo['slant'] = 'r' + when 'italic' + finfo['slant'] = 'i' + end } @kanjifont = '-' + _get_font_info_from_hash(finfo).join('-') + '-' @@ -478,42 +478,42 @@ class TkFont if JAPANIZED_TK if font.kind_of? Hash - if font[:charset] || font['charset'] - tk_call('font', 'create', @latinfont, *hash_kv(font)) - else - tk_call('font', 'create', @latinfont, + if font[:charset] || font['charset'] + tk_call('font', 'create', @latinfont, *hash_kv(font)) + else + tk_call('font', 'create', @latinfont, '-charset', 'iso8859', *hash_kv(font)) - end + end elsif font.kind_of? Array - tk_call('font', 'create', @latinfont, '-copy', array2tk_list(font)) + tk_call('font', 'create', @latinfont, '-copy', array2tk_list(font)) tk_call('font', 'configure', @latinfont, '-charset', 'iso8859') elsif font.kind_of? TkFont - tk_call('font', 'create', @latinfont, '-copy', font.latin_font) + tk_call('font', 'create', @latinfont, '-copy', font.latin_font) elsif font - tk_call('font', 'create', @latinfont, '-copy', font, + tk_call('font', 'create', @latinfont, '-copy', font, '-charset', 'iso8859') else - tk_call('font', 'create', @latinfont, '-charset', 'iso8859') + tk_call('font', 'create', @latinfont, '-charset', 'iso8859') end else if font.kind_of? Hash - tk_call('font', 'create', @latinfont, *hash_kv(font)) + tk_call('font', 'create', @latinfont, *hash_kv(font)) else - keys = {} - if font.kind_of? Array - actual_core(array2tk_list(font)).each{|key,val| keys[key] = val} - elsif font.kind_of? TkFont - actual_core(font.latin_font).each{|key,val| keys[key] = val} - elsif font - actual_core(font).each{|key,val| keys[key] = val} - end - tk_call('font', 'create', @latinfont, *hash_kv(keys)) + keys = {} + if font.kind_of? Array + actual_core(array2tk_list(font)).each{|key,val| keys[key] = val} + elsif font.kind_of? TkFont + actual_core(font.latin_font).each{|key,val| keys[key] = val} + elsif font + actual_core(font).each{|key,val| keys[key] = val} + end + tk_call('font', 'create', @latinfont, *hash_kv(keys)) end if font && @compoundfont keys = {} actual_core(@latinfont).each{|key,val| keys[key] = val} - tk_call('font', 'configure', @compoundfont, *hash_kv(keys)) + tk_call('font', 'configure', @compoundfont, *hash_kv(keys)) end end end @@ -524,10 +524,10 @@ class TkFont if JAPANIZED_TK if font.kind_of? Hash if font[:charset] || font['charset'] - tk_call('font', 'create', @kanjifont, *hash_kv(font)) + tk_call('font', 'create', @kanjifont, *hash_kv(font)) else - tk_call('font', 'create', @kanjifont, - '-charset', 'jisx0208.1983', *hash_kv(font)) + tk_call('font', 'create', @kanjifont, + '-charset', 'jisx0208.1983', *hash_kv(font)) end elsif font.kind_of? Array tk_call('font', 'create', @kanjifont, '-copy', array2tk_list(font)) @@ -536,7 +536,7 @@ class TkFont tk_call('font', 'create', @kanjifont, '-copy', font.kanji_font_id) elsif font tk_call('font', 'create', @kanjifont, '-copy', font, - '-charset', 'jisx0208.1983') + '-charset', 'jisx0208.1983') else tk_call('font', 'create', @kanjifont, '-charset', 'jisx0208.1983') end @@ -548,11 +548,11 @@ class TkFont else keys = {} if font.kind_of? Array - actual_core(array2tk_list(font)).each{|key,val| keys[key] = val} + actual_core(array2tk_list(font)).each{|key,val| keys[key] = val} elsif font.kind_of? TkFont - actual_core(font.kanji_font_id).each{|key,val| keys[key] = val} + actual_core(font.kanji_font_id).each{|key,val| keys[key] = val} elsif font - actual_core(font).each{|key,val| keys[key] = val} + actual_core(font).each{|key,val| keys[key] = val} end tk_call('font', 'create', @kanjifont, *hash_kv(keys)) end @@ -572,87 +572,87 @@ class TkFont @compoundfont = @id + 'c' if JAPANIZED_TK unless keys - keys = {} + keys = {} else - keys = keys.dup + keys = keys.dup end if (tk_call('font', 'configure', @latinfont, '-underline') == '1' && - tk_call('font', 'configure', @kanjifont, '-underline') == '1' && - !keys.key?('underline')) - keys['underline'] = true + tk_call('font', 'configure', @kanjifont, '-underline') == '1' && + !keys.key?('underline')) + keys['underline'] = true end if (tk_call('font', 'configure', @latinfont, '-overstrike') == '1' && - tk_call('font', 'configure', @kanjifont, '-overstrike') == '1' && - !keys.key?('overstrike')) - keys['overstrike'] = true + tk_call('font', 'configure', @kanjifont, '-overstrike') == '1' && + !keys.key?('overstrike')) + keys['overstrike'] = true end @fontslot = {'font'=>@compoundfont} begin - tk_call('font', 'create', @compoundfont, - '-compound', [@latinfont, @kanjifont], *hash_kv(keys)) + tk_call('font', 'create', @compoundfont, + '-compound', [@latinfont, @kanjifont], *hash_kv(keys)) rescue RuntimeError => e - if ltn == knj - if e.message =~ /kanji font .* specified/ - tk_call('font', 'delete', @latinfont) - create_latinfont(DEFAULT_LATIN_FONT_NAME) - opts = [] - Hash[*(tk_split_simplelist(tk_call('font', 'configure', - @kanjifont)))].each{|k,v| - case k - when '-size', '-weight', '-slant', '-underline', '-overstrike' - opts << k << v - end - } - tk_call('font', 'configure', @latinfont, *opts) - tk_call('font', 'create', @compoundfont, - '-compound', [@latinfont, @kanjifont], *hash_kv(keys)) - - elsif e.message =~ /ascii font .* specified/ - tk_call('font', 'delete', @kanjifont) - create_kanjifont(DEFAULT_KANJI_FONT_NAME) - opts = [] - Hash[*(tk_split_simplelist(tk_call('font', 'configure', - @latinfont)))].each{|k,v| - case k - when '-size', '-weight', '-slant', '-underline', '-overstrike' - opts << k << v - end - } - tk_call('font', 'configure', @kanjifont, *opts) - tk_call('font', 'create', @compoundfont, - '-compound', [@latinfont, @kanjifont], *hash_kv(keys)) - - else - raise e - end - else - raise e - end + if ltn == knj + if e.message =~ /kanji font .* specified/ + tk_call('font', 'delete', @latinfont) + create_latinfont(DEFAULT_LATIN_FONT_NAME) + opts = [] + Hash[*(tk_split_simplelist(tk_call('font', 'configure', + @kanjifont)))].each{|k,v| + case k + when '-size', '-weight', '-slant', '-underline', '-overstrike' + opts << k << v + end + } + tk_call('font', 'configure', @latinfont, *opts) + tk_call('font', 'create', @compoundfont, + '-compound', [@latinfont, @kanjifont], *hash_kv(keys)) + + elsif e.message =~ /ascii font .* specified/ + tk_call('font', 'delete', @kanjifont) + create_kanjifont(DEFAULT_KANJI_FONT_NAME) + opts = [] + Hash[*(tk_split_simplelist(tk_call('font', 'configure', + @latinfont)))].each{|k,v| + case k + when '-size', '-weight', '-slant', '-underline', '-overstrike' + opts << k << v + end + } + tk_call('font', 'configure', @kanjifont, *opts) + tk_call('font', 'create', @compoundfont, + '-compound', [@latinfont, @kanjifont], *hash_kv(keys)) + + else + raise e + end + else + raise e + end end else tk_call('font', 'create', @compoundfont) latinkeys = {} begin - actual_core(@latinfont).each{|key,val| latinkeys[key] = val} + actual_core(@latinfont).each{|key,val| latinkeys[key] = val} rescue - latinkeys {} + latinkeys {} end if latinkeys != {} - tk_call('font', 'configure', @compoundfont, *hash_kv(latinkeys)) + tk_call('font', 'configure', @compoundfont, *hash_kv(latinkeys)) end if knj - kanjikeys = {} - begin - actual_core(@kanjifont).each{|key,val| kanjikeys[key] = val} - rescue - kanjikeys {} - end - if kanjikeys != {} - tk_call('font', 'configure', @compoundfont, *hash_kv(kanjikeys)) - end + kanjikeys = {} + begin + actual_core(@kanjifont).each{|key,val| kanjikeys[key] = val} + rescue + kanjikeys {} + end + if kanjikeys != {} + tk_call('font', 'configure', @compoundfont, *hash_kv(kanjikeys)) + end end @fontslot = {'font'=>@compoundfont} @@ -666,8 +666,8 @@ class TkFont "" else [['family',[]], ['size',[]], ['weight',[]], ['slant',[]], - ['underline',[]], ['overstrike',[]], ['charset',[]], - ['pointadjust',[]]] + ['underline',[]], ['overstrike',[]], ['charset',[]], + ['pointadjust',[]]] end end @@ -676,24 +676,24 @@ class TkFont "" elsif option if window - tk_call('font', 'actual', font, "-displayof", window, "-#{option}") + tk_call('font', 'actual', font, "-displayof", window, "-#{option}") else - tk_call('font', 'actual', font, "-#{option}") + tk_call('font', 'actual', font, "-#{option}") end else l = tk_split_simplelist(if window - tk_call('font', 'actual', font, - "-displayof", window) - else - tk_call('font', 'actual', font) - end) + tk_call('font', 'actual', font, + "-displayof", window) + else + tk_call('font', 'actual', font) + end) r = [] while key=l.shift - if key == '-compound' - l.shift - else - r.push [key[1..-1], l.shift] - end + if key == '-compound' + l.shift + else + r.push [key[1..-1], l.shift] + end end r end @@ -708,11 +708,11 @@ class TkFont # dummy if TkComm::GET_CONFIGINFOwoRES_AS_ARRAY if option - "" + "" else - [['family',[]], ['size',[]], ['weight',[]], ['slant',[]], - ['underline',[]], ['overstrike',[]], ['charset',[]], - ['pointadjust',[]]] + [['family',[]], ['size',[]], ['weight',[]], ['slant',[]], + ['underline',[]], ['overstrike',[]], ['charset',[]], + ['pointadjust',[]]] end else # ! TkComm::GET_CONFIGINFOwoRES_AS_ARRAY current_configinfo_core_tk4x(font, option) @@ -724,69 +724,69 @@ class TkFont "" else {'family'=>'', 'size'=>'', 'weight'=>'', 'slant'=>'', - 'underline'=>'', 'overstrike'=>'', 'charset'=>'', 'pointadjust'=>''} + 'underline'=>'', 'overstrike'=>'', 'charset'=>'', 'pointadjust'=>''} end end def configure_core_tk8x(font, slot, value=None) if JAPANIZED_TK begin - padjust = tk_call('font', 'configure', font, '-pointadjust') + padjust = tk_call('font', 'configure', font, '-pointadjust') rescue - padjust = nil + padjust = nil end else padjust = nil end if slot.kind_of? Hash if JAPANIZED_TK && (slot.key?('family') || slot.key?(:family)) - slot = _symbolkey2str(slot) - configure_core_tk8x(font, 'family', slot.delete('family')) + slot = _symbolkey2str(slot) + configure_core_tk8x(font, 'family', slot.delete('family')) end if ((slot.key?('size') || slot.key?(:size)) && - padjust && !slot.key?('pointadjust') && !slot.key?(:pointadjust)) - tk_call('font', 'configure', font, - '-pointadjust', padjust, *hash_kv(slot)) + padjust && !slot.key?('pointadjust') && !slot.key?(:pointadjust)) + tk_call('font', 'configure', font, + '-pointadjust', padjust, *hash_kv(slot)) else - tk_call('font', 'configure', font, *hash_kv(slot)) + tk_call('font', 'configure', font, *hash_kv(slot)) end elsif (slot == 'size' || slot == :size) && padjust != nil tk_call('font', 'configure', font, - "-#{slot}", value, '-pointadjust', padjust) + "-#{slot}", value, '-pointadjust', padjust) elsif JAPANIZED_TK && (slot == 'family' || slot == :family) # coumpund font? begin - compound = tk_split_simplelist(tk_call('font', 'configure', - font, '-compound')) + compound = tk_split_simplelist(tk_call('font', 'configure', + font, '-compound')) rescue - tk_call('font', 'configure', font, '-family', value) - return self + tk_call('font', 'configure', font, '-family', value) + return self end if compound == [] - tk_call('font', 'configure', font, '-family', value) - return self + tk_call('font', 'configure', font, '-family', value) + return self end ltn, knj = compound lfnt = tk_call('font', 'create', '-copy', ltn) begin - tk_call('font', 'configure', lfnt, '-family', value) - latin_replace_core_tk8x(lfnt) + tk_call('font', 'configure', lfnt, '-family', value) + latin_replace_core_tk8x(lfnt) rescue RuntimeError => e - fail e if $DEBUG + fail e if $DEBUG ensure - tk_call('font', 'delete', lfnt) if lfnt != '' + tk_call('font', 'delete', lfnt) if lfnt != '' end kfnt = tk_call('font', 'create', '-copy', knj) begin - tk_call('font', 'configure', kfnt, '-family', value) - kanji_replace_core_tk8x(lfnt) + tk_call('font', 'configure', kfnt, '-family', value) + kanji_replace_core_tk8x(lfnt) rescue RuntimeError => e - fail e if $DEBUG + fail e if $DEBUG ensure - tk_call('font', 'delete', kfnt) if kfnt != '' + tk_call('font', 'delete', kfnt) if kfnt != '' end else @@ -798,20 +798,20 @@ class TkFont def configinfo_core_tk8x(font, option=nil) if TkComm::GET_CONFIGINFOwoRES_AS_ARRAY if option == 'compound' - "" + "" elsif option - tk_call('font', 'configure', font, "-#{option}") + tk_call('font', 'configure', font, "-#{option}") else - l = tk_split_simplelist(tk_call('font', 'configure', font)) - r = [] - while key=l.shift - if key == '-compound' - l.shift - else - r.push [key[1..-1], l.shift] - end - end - r + l = tk_split_simplelist(tk_call('font', 'configure', font)) + r = [] + while key=l.shift + if key == '-compound' + l.shift + else + r.push [key[1..-1], l.shift] + end + end + r end else # ! TkComm::GET_CONFIGINFOwoRES_AS_ARRAY current_configinfo_core_tk8x(font, option) @@ -827,11 +827,11 @@ class TkFont l = tk_split_simplelist(tk_call('font', 'configure', font)) r = {} while key=l.shift - if key == '-compound' - l.shift - else - r[key[1..-1]] = l.shift - end + if key == '-compound' + l.shift + else + r[key[1..-1]] = l.shift + end end r end @@ -865,28 +865,28 @@ class TkFont @fontslot['font'] = @latinfont Tk_FontUseTBL.dup.each{|w, fobj| if self == fobj - begin - if w.include?(';') - win, tag, optkey = w.split(';') - optkey = 'font' if optkey == nil || optkey == '' - winobj = tk_tcl2ruby(win) -# winobj.tagfont_configure(tag, {'font'=>@latinfont}) - if winobj.kind_of? TkText - tk_call(win, 'tag', 'configure', tag, "-#{optkey}", @latinfont) - elsif winobj.kind_of? TkCanvas - tk_call(win, 'itemconfigure', tag, "-#{optkey}", @latinfont) - elsif winobj.kind_of? TkMenu - tk_call(win, 'entryconfigure', tag, "-#{optkey}", @latinfont) - else - raise RuntimeError, "unknown widget type" - end - else -# tk_tcl2ruby(w).font_configure('font'=>@latinfont) - tk_call(w, 'configure', '-font', @latinfont) - end - rescue - Tk_FontUseTBL.delete(w) - end + begin + if w.include?(';') + win, tag, optkey = w.split(';') + optkey = 'font' if optkey == nil || optkey == '' + winobj = tk_tcl2ruby(win) +# winobj.tagfont_configure(tag, {'font'=>@latinfont}) + if winobj.kind_of? TkText + tk_call(win, 'tag', 'configure', tag, "-#{optkey}", @latinfont) + elsif winobj.kind_of? TkCanvas + tk_call(win, 'itemconfigure', tag, "-#{optkey}", @latinfont) + elsif winobj.kind_of? TkMenu + tk_call(win, 'entryconfigure', tag, "-#{optkey}", @latinfont) + else + raise RuntimeError, "unknown widget type" + end + else +# tk_tcl2ruby(w).font_configure('font'=>@latinfont) + tk_call(w, 'configure', '-font', @latinfont) + end + rescue + Tk_FontUseTBL.delete(w) + end end } self @@ -900,28 +900,28 @@ class TkFont @fontslot['kanjifont'] = @kanjifont Tk_FontUseTBL.dup.each{|w, fobj| if self == fobj - begin - if w.include?(';') - win, tag, optkey = w.split(';') - optkey = 'kanjifont' unless optkey - winobj = tk_tcl2ruby(win) -# winobj.tagfont_configure(tag, {'kanjifont'=>@kanjifont}) - if winobj.kind_of? TkText - tk_call(win, 'tag', 'configure', tag, "-#{optkey}", @kanjifont) - elsif winobj.kind_of? TkCanvas - tk_call(win, 'itemconfigure', tag, "-#{optkey}", @kanjifont) - elsif winobj.kind_of? TkMenu - tk_call(win, 'entryconfigure', tag, "-#{optkey}", @latinfont) - else - raise RuntimeError, "unknown widget type" - end - else -# tk_tcl2ruby(w).font_configure('kanjifont'=>@kanjifont) - tk_call(w, 'configure', '-kanjifont', @kanjifont) - end - rescue - Tk_FontUseTBL.delete(w) - end + begin + if w.include?(';') + win, tag, optkey = w.split(';') + optkey = 'kanjifont' unless optkey + winobj = tk_tcl2ruby(win) +# winobj.tagfont_configure(tag, {'kanjifont'=>@kanjifont}) + if winobj.kind_of? TkText + tk_call(win, 'tag', 'configure', tag, "-#{optkey}", @kanjifont) + elsif winobj.kind_of? TkCanvas + tk_call(win, 'itemconfigure', tag, "-#{optkey}", @kanjifont) + elsif winobj.kind_of? TkMenu + tk_call(win, 'entryconfigure', tag, "-#{optkey}", @latinfont) + else + raise RuntimeError, "unknown widget type" + end + else +# tk_tcl2ruby(w).font_configure('kanjifont'=>@kanjifont) + tk_call(w, 'configure', '-kanjifont', @kanjifont) + end + rescue + Tk_FontUseTBL.delete(w) + end end } self @@ -930,14 +930,14 @@ class TkFont def latin_replace_core_tk8x(ltn) if JAPANIZED_TK begin - tk_call('font', 'delete', '@font_tmp') + tk_call('font', 'delete', '@font_tmp') rescue end begin - fnt_bup = tk_call('font', 'create', '@font_tmp', '-copy', @latinfont) + fnt_bup = tk_call('font', 'create', '@font_tmp', '-copy', @latinfont) rescue - #fnt_bup = '' - fnt_bup = DEFAULT_LATIN_FONT_NAME + #fnt_bup = '' + fnt_bup = DEFAULT_LATIN_FONT_NAME end end @@ -951,40 +951,40 @@ class TkFont keys = self.configinfo tk_call('font', 'delete', @compoundfont) begin - tk_call('font', 'create', @compoundfont, - '-compound', [@latinfont, @kanjifont], *hash_kv(keys)) + tk_call('font', 'create', @compoundfont, + '-compound', [@latinfont, @kanjifont], *hash_kv(keys)) =begin - latinkeys = {} - begin - actual_core(@latinfont).each{|key,val| latinkeys[key] = val} - rescue - latinkeys {} - end - if latinkeys != {} - tk_call('font', 'configure', @compoundfont, *hash_kv(latinkeys)) - end + latinkeys = {} + begin + actual_core(@latinfont).each{|key,val| latinkeys[key] = val} + rescue + latinkeys {} + end + if latinkeys != {} + tk_call('font', 'configure', @compoundfont, *hash_kv(latinkeys)) + end =end rescue RuntimeError => e - tk_call('font', 'delete', @latinfont) - if fnt_bup && fnt_bup != '' - tk_call('font', 'create', @latinfont, '-copy', fnt_bup) - tk_call('font', 'create', @compoundfont, - '-compound', [@latinfont, @kanjifont], *hash_kv(keys)) - tk_call('font', 'delete', fnt_bup) - else - fail e - end + tk_call('font', 'delete', @latinfont) + if fnt_bup && fnt_bup != '' + tk_call('font', 'create', @latinfont, '-copy', fnt_bup) + tk_call('font', 'create', @compoundfont, + '-compound', [@latinfont, @kanjifont], *hash_kv(keys)) + tk_call('font', 'delete', fnt_bup) + else + fail e + end end else latinkeys = {} begin - actual_core(@latinfont).each{|key,val| latinkeys[key] = val} + actual_core(@latinfont).each{|key,val| latinkeys[key] = val} rescue - latinkeys {} + latinkeys {} end if latinkeys != {} - tk_call('font', 'configure', @compoundfont, *hash_kv(latinkeys)) + tk_call('font', 'configure', @compoundfont, *hash_kv(latinkeys)) end end self @@ -993,14 +993,14 @@ class TkFont def kanji_replace_core_tk8x(knj) if JAPANIZED_TK begin - tk_call('font', 'delete', '@font_tmp') + tk_call('font', 'delete', '@font_tmp') rescue end begin - fnt_bup = tk_call('font', 'create', '@font_tmp', '-copy', @kanjifont) + fnt_bup = tk_call('font', 'create', '@font_tmp', '-copy', @kanjifont) rescue - #fnt_bup = '' - fnt_bup = DEFAULT_KANJI_FONT_NAME + #fnt_bup = '' + fnt_bup = DEFAULT_KANJI_FONT_NAME end end @@ -1014,18 +1014,18 @@ class TkFont keys = self.configinfo tk_call('font', 'delete', @compoundfont) begin - tk_call('font', 'create', @compoundfont, - '-compound', [@latinfont, @kanjifont], *hash_kv(keys)) + tk_call('font', 'create', @compoundfont, + '-compound', [@latinfont, @kanjifont], *hash_kv(keys)) rescue RuntimeError => e - tk_call('font', 'delete', @kanjifont) - if fnt_bup && fnt_bup != '' - tk_call('font', 'create', @kanjifont, '-copy', fnt_bup) - tk_call('font', 'create', @compoundfont, - '-compound', [@latinfont, @kanjifont], *hash_kv(keys)) - tk_call('font', 'delete', fnt_bup) - else - fail e - end + tk_call('font', 'delete', @kanjifont) + if fnt_bup && fnt_bup != '' + tk_call('font', 'create', @kanjifont, '-copy', fnt_bup) + tk_call('font', 'create', @compoundfont, + '-compound', [@latinfont, @kanjifont], *hash_kv(keys)) + tk_call('font', 'delete', fnt_bup) + else + fail e + end end end self @@ -1038,7 +1038,7 @@ class TkFont def measure_core_tk8x(window, text) if window number(tk_call('font', 'measure', @compoundfont, - '-displayof', window, text)) + '-displayof', window, text)) else number(tk_call('font', 'measure', @compoundfont, text)) end @@ -1056,20 +1056,20 @@ class TkFont def metrics_core_tk8x(font, window, option=nil) if option if window - number(tk_call('font', 'metrics', font, - "-displayof", window, "-#{option}")) + number(tk_call('font', 'metrics', font, + "-displayof", window, "-#{option}")) else - number(tk_call('font', 'metrics', font, "-#{option}")) + number(tk_call('font', 'metrics', font, "-#{option}")) end else l = tk_split_list(if window - tk_call('font','metrics',font,"-displayof",window) - else - tk_call('font','metrics',font) - end) + tk_call('font','metrics',font,"-displayof",window) + else + tk_call('font','metrics',font) + end) r = [] while key=l.shift - r.push [key[1..-1], l.shift.to_i] + r.push [key[1..-1], l.shift.to_i] end r end @@ -1133,9 +1133,9 @@ class TkFont configure name, args[0] when 0 begin - configinfo name + configinfo name rescue - fail NameError, "undefined local variable or method `#{name}' for #{self.to_s}", error_at + fail NameError, "undefined local variable or method `#{name}' for #{self.to_s}", error_at end else fail NameError, "undefined method `#{name}' for #{self.to_s}", error_at @@ -1171,49 +1171,49 @@ class TkFont Tk_FontUseTBL.each{|key,value| next unless self == value if key.include?(';') - win, tag, optkey = key.split(';') - winobj = tk_tcl2ruby(win) - if winobj.kind_of? TkText - if optkey - ret.push([winobj, winobj.tagid2obj(tag), optkey]) - else - ret.push([winobj, winobj.tagid2obj(tag)]) - end - elsif winobj.kind_of? TkCanvas - if (tagobj = TkcTag.id2obj(winobj, tag)).kind_of? TkcTag - if optkey - ret.push([winobj, tagobj, optkey]) - else - ret.push([winobj, tagobj]) - end - elsif (tagobj = TkcItem.id2obj(winobj, tag)).kind_of? TkcItem - if optkey - ret.push([winobj, tagobj, optkey]) - else - ret.push([winobj, tagobj]) - end - else - if optkey - ret.push([winobj, tag, optkey]) - else - ret.push([winobj, tag]) - end - end - elsif winobj.kind_of? TkMenu - if optkey - ret.push([winobj, tag, optkey]) - else - ret.push([winobj, tag]) - end - else - if optkey - ret.push([win, tag, optkey]) - else - ret.push([win, tag]) - end - end + win, tag, optkey = key.split(';') + winobj = tk_tcl2ruby(win) + if winobj.kind_of? TkText + if optkey + ret.push([winobj, winobj.tagid2obj(tag), optkey]) + else + ret.push([winobj, winobj.tagid2obj(tag)]) + end + elsif winobj.kind_of? TkCanvas + if (tagobj = TkcTag.id2obj(winobj, tag)).kind_of? TkcTag + if optkey + ret.push([winobj, tagobj, optkey]) + else + ret.push([winobj, tagobj]) + end + elsif (tagobj = TkcItem.id2obj(winobj, tag)).kind_of? TkcItem + if optkey + ret.push([winobj, tagobj, optkey]) + else + ret.push([winobj, tagobj]) + end + else + if optkey + ret.push([winobj, tag, optkey]) + else + ret.push([winobj, tag]) + end + end + elsif winobj.kind_of? TkMenu + if optkey + ret.push([winobj, tag, optkey]) + else + ret.push([winobj, tag]) + end + else + if optkey + ret.push([win, tag, optkey]) + else + ret.push([win, tag]) + end + end else - ret.push(tk_tcl2ruby(key)) + ret.push(tk_tcl2ruby(key)) end } ret diff --git a/ext/tk/lib/tk/grid.rb b/ext/tk/lib/tk/grid.rb index c591eea187..74287d43bd 100644 --- a/ext/tk/lib/tk/grid.rb +++ b/ext/tk/lib/tk/grid.rb @@ -33,9 +33,9 @@ module TkGrid args.each{|win| case win when '-', 'x', '^' # RELATIVE PLACEMENT - params.push(win) + params.push(win) else - params.push(_epath(win)) + params.push(_epath(win)) end } opts.each{|k, v| @@ -50,7 +50,7 @@ module TkGrid # master = master.epath if master.kind_of?(TkObject) master = _epath(master) tk_call_without_enc("grid", 'columnconfigure', - master, index, *hash_kv(args)) + master, index, *hash_kv(args)) end def rowconfigure(master, index, args) @@ -65,24 +65,24 @@ module TkGrid if slot case slot when 'uniform', :uniform - tk_call_without_enc('grid', 'columnconfigure', - master, index, "-#{slot}") + tk_call_without_enc('grid', 'columnconfigure', + master, index, "-#{slot}") else - num_or_str(tk_call_without_enc('grid', 'columnconfigure', - master, index, "-#{slot}")) + num_or_str(tk_call_without_enc('grid', 'columnconfigure', + master, index, "-#{slot}")) end else #ilist = list(tk_call_without_enc('grid','columnconfigure',master,index)) ilist = simplelist(tk_call_without_enc('grid', 'columnconfigure', - master, index)) + master, index)) info = {} while key = ilist.shift - case key - when 'uniform' - info[key[1..-1]] = ilist.shift - else - info[key[1..-1]] = tk_tcl2ruby(ilist.shift) - end + case key + when 'uniform' + info[key[1..-1]] = ilist.shift + else + info[key[1..-1]] = tk_tcl2ruby(ilist.shift) + end end info end @@ -94,24 +94,24 @@ module TkGrid if slot case slot when 'uniform', :uniform - tk_call_without_enc('grid', 'rowconfigure', - master, index, "-#{slot}") + tk_call_without_enc('grid', 'rowconfigure', + master, index, "-#{slot}") else - num_or_str(tk_call_without_enc('grid', 'rowconfigure', - master, index, "-#{slot}")) + num_or_str(tk_call_without_enc('grid', 'rowconfigure', + master, index, "-#{slot}")) end else #ilist = list(tk_call_without_enc('grid', 'rowconfigure', master, index)) ilist = simplelist(tk_call_without_enc('grid', 'rowconfigure', - master, index)) + master, index)) info = {} while key = ilist.shift - case key - when 'uniform' - info[key[1..-1]] = ilist.shift - else - info[key[1..-1]] = tk_tcl2ruby(ilist.shift) - end + case key + when 'uniform' + info[key[1..-1]] = ilist.shift + else + info[key[1..-1]] = tk_tcl2ruby(ilist.shift) + end end info end diff --git a/ext/tk/lib/tk/image.rb b/ext/tk/lib/tk/image.rb index 7868ed0c8f..7fd61eff5d 100644 --- a/ext/tk/lib/tk/image.rb +++ b/ext/tk/lib/tk/image.rb @@ -65,9 +65,9 @@ class TkPhotoImage 0 - tk_call(*(__item_config_cmd(tagid(tagOrId)).concat(hash_kv(slot)))) + tk_call(*(__item_config_cmd(tagid(tagOrId)).concat(hash_kv(slot)))) end else slot = slot.to_s if ( conf = __item_keyonly_optkeys(tagid(tagOrId)).find{|k, v| k.to_s == slot } ) - defkey, undefkey = conf - if value - tk_call(*(__item_config_cmd(tagid(tagOrId)) << "-#{defkey}")) - elsif undefkey - tk_call(*(__item_config_cmd(tagid(tagOrId)) << "-#{undefkey}")) - end + defkey, undefkey = conf + if value + tk_call(*(__item_config_cmd(tagid(tagOrId)) << "-#{defkey}")) + elsif undefkey + tk_call(*(__item_config_cmd(tagid(tagOrId)) << "-#{undefkey}")) + end elsif ( method = _symbolkey2str(__item_methodcall_optkeys(tagid(tagOrId)))[slot] ) - self.__send__(method, tagOrId, value) + self.__send__(method, tagOrId, value) elsif (slot =~ /^(|latin|ascii|kanji)(#{__item_font_optkeys(tagid(tagOrId)).join('|')})$/) - if value == None - tagfontobj(tagid(tagOrId), $2) - else - tagfont_configure(tagid(tagOrId), {slot=>value}) - end + if value == None + tagfontobj(tagid(tagOrId), $2) + else + tagfont_configure(tagid(tagOrId), {slot=>value}) + end else - tk_call(*(__item_config_cmd(tagid(tagOrId)) << "-#{slot}" << value)) + tk_call(*(__item_config_cmd(tagid(tagOrId)) << "-#{slot}" << value)) end end self @@ -224,531 +224,531 @@ module TkItemConfigMethod def itemconfiginfo(tagOrId, slot = nil) if TkComm::GET_CONFIGINFO_AS_ARRAY if (slot.to_s =~ /^(|latin|ascii|kanji)(#{__item_font_optkeys(tagid(tagOrId)).join('|')})$/) - fontkey = $2 - conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_config_cmd(tagid(tagOrId)) << "-#{fontkey}")))) - conf[__item_configinfo_struct(tagid(tagOrId))[:key]] = - conf[__item_configinfo_struct(tagid(tagOrId))[:key]][1..-1] - if ( ! __item_configinfo_struct(tagid(tagOrId))[:alias] \ - || conf.size > __item_configinfo_struct(tagid(tagOrId))[:alias] + 1 ) - conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = tagfontobj(tagid(tagOrId), fontkey) - elsif ( __item_configinfo_struct(tagid(tagOrId))[:alias] \ - && conf.size == __item_configinfo_struct(tagid(tagOrId))[:alias] + 1 \ - && conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][0] == ?- ) - conf[__item_configinfo_struct(tagid(tagOrId))[:alias]] = - conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][1..-1] - end - conf + fontkey = $2 + conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_config_cmd(tagid(tagOrId)) << "-#{fontkey}")))) + conf[__item_configinfo_struct(tagid(tagOrId))[:key]] = + conf[__item_configinfo_struct(tagid(tagOrId))[:key]][1..-1] + if ( ! __item_configinfo_struct(tagid(tagOrId))[:alias] \ + || conf.size > __item_configinfo_struct(tagid(tagOrId))[:alias] + 1 ) + conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = tagfontobj(tagid(tagOrId), fontkey) + elsif ( __item_configinfo_struct(tagid(tagOrId))[:alias] \ + && conf.size == __item_configinfo_struct(tagid(tagOrId))[:alias] + 1 \ + && conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][0] == ?- ) + conf[__item_configinfo_struct(tagid(tagOrId))[:alias]] = + conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][1..-1] + end + conf else - if slot - slot = slot.to_s - case slot - when /^(#{__item_methodcall_optkeys(tagid(tagOrId)).keys.join('|')})$/ - method = _symbolkey2str(__item_methodcall_optkeys(tagid(tagOrId)))[slot] - return [slot, '', '', '', self.__send__(method, tagOrId)] - - when /^(#{__item_numval_optkeys(tagid(tagOrId)).join('|')})$/ - conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_config_cmd(tagid(tagOrId)) << "-#{slot}")))) - - if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ - && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] ) - begin - conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = - number(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) - rescue - conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = nil - end - end - if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] ) - begin - conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = - number(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) - rescue - conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = nil - end - end - - when /^(#{__item_numstrval_optkeys(tagid(tagOrId)).join('|')})$/ - conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_config_cmd(tagid(tagOrId)) << "-#{slot}")))) - - if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ - && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] ) - conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = - num_or_str(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) - end - if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] ) - conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = - num_or_str(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) - end - - when /^(#{__item_boolval_optkeys(tagid(tagOrId)).join('|')})$/ - conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_config_cmd(tagid(tagOrId)) << "-#{slot}")))) - - if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ - && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] ) - begin - conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = - bool(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) - rescue - conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = nil - end - end - if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] ) - begin - conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = - bool(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) - rescue - conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = nil - end - end - - when /^(#{__item_listval_optkeys(tagid(tagOrId)).join('|')})$/ - conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_config_cmd(tagid(tagOrId)) << "-#{slot}")))) - - if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ - && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] ) - conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = - simplelist(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) - end - if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] ) - conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = - simplelist(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) - end - - when /^(#{__item_numlistval_optkeys(tagid(tagOrId)).join('|')})$/ - conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_config_cmd(tagid(tagOrId)) << "-#{slot}")))) - - if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ - && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] \ - && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =~ /^[0-9]/ ) - conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = - list(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) - end - if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] \ - && conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =~ /^[0-9]/ ) - conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = - list(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) - end - - when /^(#{__item_strval_optkeys(tagid(tagOrId)).join('|')})$/ - conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_config_cmd(tagid(tagOrId)) << "-#{slot}")))) - - else - conf = tk_split_list(_fromUTF8(tk_call_without_enc(*(__item_config_cmd(tagid(tagOrId)) << "-#{slot}")))) - end - conf[__item_configinfo_struct(tagid(tagOrId))[:key]] = - conf[__item_configinfo_struct(tagid(tagOrId))[:key]][1..-1] - - if ( __item_configinfo_struct(tagid(tagOrId))[:alias] \ - && conf.size == __item_configinfo_struct(tagid(tagOrId))[:alias] + 1 \ - && conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][0] == ?- ) - conf[__item_configinfo_struct(tagid(tagOrId))[:alias]] = - conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][1..-1] - end - - conf - - else - ret = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_config_cmd(tagid(tagOrId)))))).collect{|conflist| - conf = tk_split_simplelist(conflist) - conf[__item_configinfo_struct(tagid(tagOrId))[:key]] = - conf[__item_configinfo_struct(tagid(tagOrId))[:key]][1..-1] - - case conf[__item_configinfo_struct(tagid(tagOrId))[:key]] - when /^(#{__item_strval_optkeys(tagid(tagOrId)).join('|')})$/ - # do nothing - - when /^(#{__item_numval_optkeys(tagid(tagOrId)).join('|')})$/ - if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ - && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] ) - begin - conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = - number(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) - rescue - conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = nil - end - end - if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] ) - begin - conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = - number(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) - rescue - conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = nil - end - end - - when /^(#{__item_numstrval_optkeys(tagid(tagOrId)).join('|')})$/ - if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ - && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] ) - conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = - num_or_str(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) - end - if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] ) - conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = - num_or_str(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) - end - - when /^(#{__item_boolval_optkeys(tagid(tagOrId)).join('|')})$/ - if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ - && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] ) - begin - conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = - bool(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) - rescue - conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = nil - end - end - if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] ) - begin - conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = - bool(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) - rescue - conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = nil - end - end - - when /^(#{__item_listval_optkeys(tagid(tagOrId)).join('|')})$/ - if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ - && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] ) - conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = - simplelist(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) - end - if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] ) - conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = - simplelist(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) - end - - when /^(#{__item_numlistval_optkeys(tagid(tagOrId)).join('|')})$/ - if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ - && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] \ - && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =~ /^[0-9]/ ) - conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = - list(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) - end - if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] \ - && conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =~ /^[0-9]/ ) - conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = - list(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) - end - - else - if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ - && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] ) - if conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]].index('{') - conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = - tk_split_list(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) - else - conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = - tk_tcl2ruby(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) - end - end - if conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] - if conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]].index('{') - conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = - tk_split_list(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) - else - conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = - tk_tcl2ruby(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) - end - end - end - - if ( __item_configinfo_struct(tagid(tagOrId))[:alias] \ - && conf.size == __item_configinfo_struct(tagid(tagOrId))[:alias] + 1 \ - && conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][0] == ?- ) - conf[__item_configinfo_struct(tagid(tagOrId))[:alias]] = - conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][1..-1] - end - - conf - } - - __item_font_optkeys(tagid(tagOrId)).each{|optkey| - optkey = optkey.to_s - fontconf = ret.assoc(optkey) - if fontconf && fontconf.size > 2 - ret.delete_if{|inf| inf[0] =~ /^(|latin|ascii|kanji)#{optkey}$/} - fontconf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = tagfontobj(tagid(tagOrId), optkey) - ret.push(fontconf) - end - } - - __item_methodcall_optkeys(tagid(tagOrId)).each{|optkey, method| - ret << [optkey.to_s, '', '', '', self.__send__(method, tagOrId)] - } - - ret - end + if slot + slot = slot.to_s + case slot + when /^(#{__item_methodcall_optkeys(tagid(tagOrId)).keys.join('|')})$/ + method = _symbolkey2str(__item_methodcall_optkeys(tagid(tagOrId)))[slot] + return [slot, '', '', '', self.__send__(method, tagOrId)] + + when /^(#{__item_numval_optkeys(tagid(tagOrId)).join('|')})$/ + conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_config_cmd(tagid(tagOrId)) << "-#{slot}")))) + + if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ + && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] ) + begin + conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = + number(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) + rescue + conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = nil + end + end + if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] ) + begin + conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = + number(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) + rescue + conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = nil + end + end + + when /^(#{__item_numstrval_optkeys(tagid(tagOrId)).join('|')})$/ + conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_config_cmd(tagid(tagOrId)) << "-#{slot}")))) + + if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ + && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] ) + conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = + num_or_str(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) + end + if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] ) + conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = + num_or_str(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) + end + + when /^(#{__item_boolval_optkeys(tagid(tagOrId)).join('|')})$/ + conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_config_cmd(tagid(tagOrId)) << "-#{slot}")))) + + if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ + && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] ) + begin + conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = + bool(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) + rescue + conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = nil + end + end + if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] ) + begin + conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = + bool(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) + rescue + conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = nil + end + end + + when /^(#{__item_listval_optkeys(tagid(tagOrId)).join('|')})$/ + conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_config_cmd(tagid(tagOrId)) << "-#{slot}")))) + + if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ + && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] ) + conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = + simplelist(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) + end + if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] ) + conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = + simplelist(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) + end + + when /^(#{__item_numlistval_optkeys(tagid(tagOrId)).join('|')})$/ + conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_config_cmd(tagid(tagOrId)) << "-#{slot}")))) + + if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ + && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] \ + && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =~ /^[0-9]/ ) + conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = + list(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) + end + if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] \ + && conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =~ /^[0-9]/ ) + conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = + list(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) + end + + when /^(#{__item_strval_optkeys(tagid(tagOrId)).join('|')})$/ + conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_config_cmd(tagid(tagOrId)) << "-#{slot}")))) + + else + conf = tk_split_list(_fromUTF8(tk_call_without_enc(*(__item_config_cmd(tagid(tagOrId)) << "-#{slot}")))) + end + conf[__item_configinfo_struct(tagid(tagOrId))[:key]] = + conf[__item_configinfo_struct(tagid(tagOrId))[:key]][1..-1] + + if ( __item_configinfo_struct(tagid(tagOrId))[:alias] \ + && conf.size == __item_configinfo_struct(tagid(tagOrId))[:alias] + 1 \ + && conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][0] == ?- ) + conf[__item_configinfo_struct(tagid(tagOrId))[:alias]] = + conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][1..-1] + end + + conf + + else + ret = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_config_cmd(tagid(tagOrId)))))).collect{|conflist| + conf = tk_split_simplelist(conflist) + conf[__item_configinfo_struct(tagid(tagOrId))[:key]] = + conf[__item_configinfo_struct(tagid(tagOrId))[:key]][1..-1] + + case conf[__item_configinfo_struct(tagid(tagOrId))[:key]] + when /^(#{__item_strval_optkeys(tagid(tagOrId)).join('|')})$/ + # do nothing + + when /^(#{__item_numval_optkeys(tagid(tagOrId)).join('|')})$/ + if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ + && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] ) + begin + conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = + number(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) + rescue + conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = nil + end + end + if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] ) + begin + conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = + number(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) + rescue + conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = nil + end + end + + when /^(#{__item_numstrval_optkeys(tagid(tagOrId)).join('|')})$/ + if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ + && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] ) + conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = + num_or_str(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) + end + if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] ) + conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = + num_or_str(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) + end + + when /^(#{__item_boolval_optkeys(tagid(tagOrId)).join('|')})$/ + if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ + && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] ) + begin + conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = + bool(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) + rescue + conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = nil + end + end + if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] ) + begin + conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = + bool(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) + rescue + conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = nil + end + end + + when /^(#{__item_listval_optkeys(tagid(tagOrId)).join('|')})$/ + if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ + && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] ) + conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = + simplelist(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) + end + if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] ) + conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = + simplelist(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) + end + + when /^(#{__item_numlistval_optkeys(tagid(tagOrId)).join('|')})$/ + if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ + && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] \ + && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =~ /^[0-9]/ ) + conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = + list(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) + end + if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] \ + && conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =~ /^[0-9]/ ) + conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = + list(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) + end + + else + if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ + && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] ) + if conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]].index('{') + conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = + tk_split_list(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) + else + conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = + tk_tcl2ruby(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) + end + end + if conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] + if conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]].index('{') + conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = + tk_split_list(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) + else + conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = + tk_tcl2ruby(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) + end + end + end + + if ( __item_configinfo_struct(tagid(tagOrId))[:alias] \ + && conf.size == __item_configinfo_struct(tagid(tagOrId))[:alias] + 1 \ + && conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][0] == ?- ) + conf[__item_configinfo_struct(tagid(tagOrId))[:alias]] = + conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][1..-1] + end + + conf + } + + __item_font_optkeys(tagid(tagOrId)).each{|optkey| + optkey = optkey.to_s + fontconf = ret.assoc(optkey) + if fontconf && fontconf.size > 2 + ret.delete_if{|inf| inf[0] =~ /^(|latin|ascii|kanji)#{optkey}$/} + fontconf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = tagfontobj(tagid(tagOrId), optkey) + ret.push(fontconf) + end + } + + __item_methodcall_optkeys(tagid(tagOrId)).each{|optkey, method| + ret << [optkey.to_s, '', '', '', self.__send__(method, tagOrId)] + } + + ret + end end else # ! TkComm::GET_CONFIGINFO_AS_ARRAY if (slot.to_s =~ /^(|latin|ascii|kanji)(#{__item_font_optkeys(tagid(tagOrId)).join('|')})$/) - fontkey = $2 - conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_config_cmd(tagid(tagOrId)) << "-#{fontkey}")))) - conf[__item_configinfo_struct(tagid(tagOrId))[:key]] = - conf[__item_configinfo_struct(tagid(tagOrId))[:key]][1..-1] - - if ( ! __item_configinfo_struct(tagid(tagOrId))[:alias] \ - || conf.size > __item_configinfo_struct(tagid(tagOrId))[:alias] + 1 ) - conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = fontobj(tagid(tagOrId), fontkey) - { conf.shift => conf } - elsif ( __item_configinfo_struct(tagid(tagOrId))[:alias] \ - && conf.size == __item_configinfo_struct(tagid(tagOrId))[:alias] + 1 ) - if conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][0] == ?- - conf[__item_configinfo_struct(tagid(tagOrId))[:alias]] = - conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][1..-1] - end - { conf[0] => conf[1] } - else - { conf.shift => conf } - end + fontkey = $2 + conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_config_cmd(tagid(tagOrId)) << "-#{fontkey}")))) + conf[__item_configinfo_struct(tagid(tagOrId))[:key]] = + conf[__item_configinfo_struct(tagid(tagOrId))[:key]][1..-1] + + if ( ! __item_configinfo_struct(tagid(tagOrId))[:alias] \ + || conf.size > __item_configinfo_struct(tagid(tagOrId))[:alias] + 1 ) + conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = fontobj(tagid(tagOrId), fontkey) + { conf.shift => conf } + elsif ( __item_configinfo_struct(tagid(tagOrId))[:alias] \ + && conf.size == __item_configinfo_struct(tagid(tagOrId))[:alias] + 1 ) + if conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][0] == ?- + conf[__item_configinfo_struct(tagid(tagOrId))[:alias]] = + conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][1..-1] + end + { conf[0] => conf[1] } + else + { conf.shift => conf } + end else - if slot - slot = slot.to_s - case slot - when /^(#{__item_methodcall_optkeys(tagid(tagOrId)).keys.join('|')})$/ - method = _symbolkey2str(__item_methodcall_optkeys(tagid(tagOrId)))[slot] - return {slot => ['', '', '', self.__send__(method, tagOrId)]} - - when /^(#{__item_numval_optkeys(tagid(tagOrId)).join('|')})$/ - conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_config_cmd(tagid(tagOrId)) << "-#{slot}")))) - - if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ - && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] ) - begin - conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = - number(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) - rescue - conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = nil - end - end - if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] ) - begin - conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = - number(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) - rescue - conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = nil - end - end - - when /^(#{__item_numstrval_optkeys(tagid(tagOrId)).join('|')})$/ - conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_config_cmd(tagid(tagOrId)) << "-#{slot}")))) - - if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ - && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] ) - conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = - num_or_stre(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) - end - if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] ) - conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = - num_or_str(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) - end - - when /^(#{__item_boolval_optkeys(tagid(tagOrId)).join('|')})$/ - conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_config_cmd(tagid(tagOrId)) << "-#{slot}")))) - - if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ - && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] ) - begin - conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = - bool(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) - rescue - conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = nil - end - end - if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] ) - begin - conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = - bool(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) - rescue - conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = nil - end - end - - when /^(#{__item_listval_optkeys(tagid(tagOrId)).join('|')})$/ - conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_config_cmd(tagid(tagOrId)) << "-#{slot}")))) - - if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ - && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] ) - conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = - simplelist(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) - end - if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] ) - conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = - simplelist(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) - end - - when /^(#{__item_numlistval_optkeys(tagid(tagOrId)).join('|')})$/ - conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_config_cmd(tagid(tagOrId)) << "-#{slot}")))) - - if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ - && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] \ - && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =~ /^[0-9]/ ) - conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = - list(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) - end - if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] \ - && conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =~ /^[0-9]/ ) - conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = - list(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) - end - - when /^(#{__item_strval_optkeys(tagid(tagOrId)).join('|')})$/ - conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_config_cmd(tagid(tagOrId)) << "-#{slot}")))) - - else - conf = tk_split_list(_fromUTF8(tk_call_without_enc(*(__item_config_cmd(tagid(tagOrId)) << "-#{slot}")))) - end - conf[__item_configinfo_struct(tagid(tagOrId))[:key]] = - conf[__item_configinfo_struct(tagid(tagOrId))[:key]][1..-1] - - if ( __item_configinfo_struct(tagid(tagOrId))[:alias] \ - && conf.size == __item_configinfo_struct(tagid(tagOrId))[:alias] + 1 ) - if conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][0] == ?- - conf[__item_configinfo_struct(tagid(tagOrId))[:alias]] = - conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][1..-1] - end - { conf[0] => conf[1] } - else - { conf.shift => conf } - end - - else - ret = {} - tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_config_cmd(tagid(tagOrId)))))).each{|conflist| - conf = tk_split_simplelist(conflist) - conf[__item_configinfo_struct(tagid(tagOrId))[:key]] = - conf[__item_configinfo_struct(tagid(tagOrId))[:key]][1..-1] - - case conf[__item_configinfo_struct(tagid(tagOrId))[:key]] - when /^(#{__item_strval_optkeys(tagid(tagOrId)).join('|')})$/ - # do nothing - - when /^(#{__item_numval_optkeys(tagid(tagOrId)).join('|')})$/ - if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ - && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] ) - begin - conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = - number(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) - rescue - conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = nil - end - end - if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] ) - begin - conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = - number(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) - rescue - conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = nil - end - end - - when /^(#{__item_numstrval_optkeys(tagid(tagOrId)).join('|')})$/ - if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ - && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] ) - conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = - num_or_str(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) - end - if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] ) - conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = - num_or_str(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) - end - - when /^(#{__item_boolval_optkeys(tagid(tagOrId)).join('|')})$/ - if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ - && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] ) - begin - conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = - bool(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) - rescue - conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = nil - end - end - if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] ) - begin - conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = - bool(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) - rescue - conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = nil - end - end - - when /^(#{__item_listval_optkeys(tagid(tagOrId)).join('|')})$/ - if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ - && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] ) - conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = - simplelist(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) - end - if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] ) - conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = - simplelist(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) - end - - when /^(#{__item_numlistval_optkeys(tagid(tagOrId)).join('|')})$/ - if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ - && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] \ - && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =~ /^[0-9]/ ) - conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = - list(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) - end - if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] \ - && conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =~ /^[0-9]/ ) - conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = - list(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) - end - - else - if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ - && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] ) - if conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]].index('{') - conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = - tk_split_list(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) - else - conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = - tk_tcl2ruby(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) - end - end - if conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] - if conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]].index('{') - conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = - tk_split_list(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) - else - conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = - tk_tcl2ruby(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) - end - end - end - - if ( __item_configinfo_struct(tagid(tagOrId))[:alias] \ - && conf.size == __item_configinfo_struct(tagid(tagOrId))[:alias] + 1 ) - if conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][0] == ?- - conf[__item_configinfo_struct(tagid(tagOrId))[:alias]] = - conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][1..-1] - end - ret[conf[0]] = conf[1] - else - ret[conf.shift] = conf - end - } - - __item_font_optkeys(tagid(tagOrId)).each{|optkey| - optkey = optkey.to_s - fontconf = ret[optkey] - if fontconf.kind_of?(Array) - ret.delete(optkey) - ret.delete('latin' << optkey) - ret.delete('ascii' << optkey) - ret.delete('kanji' << optkey) - fontconf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = tagfontobj(tagid(tagOrId), optkey) - ret[optkey] = fontconf - end - } - - __item_methodcall_optkeys(tagid(tagOrId)).each{|optkey, method| - ret[optkey.to_s] = ['', '', '', self.__send__(method, tagOrId)] - } - - ret - end + if slot + slot = slot.to_s + case slot + when /^(#{__item_methodcall_optkeys(tagid(tagOrId)).keys.join('|')})$/ + method = _symbolkey2str(__item_methodcall_optkeys(tagid(tagOrId)))[slot] + return {slot => ['', '', '', self.__send__(method, tagOrId)]} + + when /^(#{__item_numval_optkeys(tagid(tagOrId)).join('|')})$/ + conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_config_cmd(tagid(tagOrId)) << "-#{slot}")))) + + if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ + && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] ) + begin + conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = + number(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) + rescue + conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = nil + end + end + if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] ) + begin + conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = + number(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) + rescue + conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = nil + end + end + + when /^(#{__item_numstrval_optkeys(tagid(tagOrId)).join('|')})$/ + conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_config_cmd(tagid(tagOrId)) << "-#{slot}")))) + + if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ + && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] ) + conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = + num_or_stre(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) + end + if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] ) + conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = + num_or_str(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) + end + + when /^(#{__item_boolval_optkeys(tagid(tagOrId)).join('|')})$/ + conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_config_cmd(tagid(tagOrId)) << "-#{slot}")))) + + if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ + && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] ) + begin + conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = + bool(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) + rescue + conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = nil + end + end + if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] ) + begin + conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = + bool(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) + rescue + conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = nil + end + end + + when /^(#{__item_listval_optkeys(tagid(tagOrId)).join('|')})$/ + conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_config_cmd(tagid(tagOrId)) << "-#{slot}")))) + + if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ + && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] ) + conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = + simplelist(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) + end + if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] ) + conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = + simplelist(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) + end + + when /^(#{__item_numlistval_optkeys(tagid(tagOrId)).join('|')})$/ + conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_config_cmd(tagid(tagOrId)) << "-#{slot}")))) + + if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ + && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] \ + && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =~ /^[0-9]/ ) + conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = + list(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) + end + if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] \ + && conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =~ /^[0-9]/ ) + conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = + list(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) + end + + when /^(#{__item_strval_optkeys(tagid(tagOrId)).join('|')})$/ + conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_config_cmd(tagid(tagOrId)) << "-#{slot}")))) + + else + conf = tk_split_list(_fromUTF8(tk_call_without_enc(*(__item_config_cmd(tagid(tagOrId)) << "-#{slot}")))) + end + conf[__item_configinfo_struct(tagid(tagOrId))[:key]] = + conf[__item_configinfo_struct(tagid(tagOrId))[:key]][1..-1] + + if ( __item_configinfo_struct(tagid(tagOrId))[:alias] \ + && conf.size == __item_configinfo_struct(tagid(tagOrId))[:alias] + 1 ) + if conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][0] == ?- + conf[__item_configinfo_struct(tagid(tagOrId))[:alias]] = + conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][1..-1] + end + { conf[0] => conf[1] } + else + { conf.shift => conf } + end + + else + ret = {} + tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_config_cmd(tagid(tagOrId)))))).each{|conflist| + conf = tk_split_simplelist(conflist) + conf[__item_configinfo_struct(tagid(tagOrId))[:key]] = + conf[__item_configinfo_struct(tagid(tagOrId))[:key]][1..-1] + + case conf[__item_configinfo_struct(tagid(tagOrId))[:key]] + when /^(#{__item_strval_optkeys(tagid(tagOrId)).join('|')})$/ + # do nothing + + when /^(#{__item_numval_optkeys(tagid(tagOrId)).join('|')})$/ + if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ + && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] ) + begin + conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = + number(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) + rescue + conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = nil + end + end + if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] ) + begin + conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = + number(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) + rescue + conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = nil + end + end + + when /^(#{__item_numstrval_optkeys(tagid(tagOrId)).join('|')})$/ + if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ + && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] ) + conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = + num_or_str(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) + end + if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] ) + conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = + num_or_str(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) + end + + when /^(#{__item_boolval_optkeys(tagid(tagOrId)).join('|')})$/ + if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ + && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] ) + begin + conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = + bool(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) + rescue + conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = nil + end + end + if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] ) + begin + conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = + bool(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) + rescue + conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = nil + end + end + + when /^(#{__item_listval_optkeys(tagid(tagOrId)).join('|')})$/ + if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ + && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] ) + conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = + simplelist(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) + end + if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] ) + conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = + simplelist(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) + end + + when /^(#{__item_numlistval_optkeys(tagid(tagOrId)).join('|')})$/ + if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ + && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] \ + && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =~ /^[0-9]/ ) + conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = + list(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) + end + if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] \ + && conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =~ /^[0-9]/ ) + conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = + list(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) + end + + else + if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ + && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] ) + if conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]].index('{') + conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = + tk_split_list(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) + else + conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = + tk_tcl2ruby(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) + end + end + if conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] + if conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]].index('{') + conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = + tk_split_list(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) + else + conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = + tk_tcl2ruby(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) + end + end + end + + if ( __item_configinfo_struct(tagid(tagOrId))[:alias] \ + && conf.size == __item_configinfo_struct(tagid(tagOrId))[:alias] + 1 ) + if conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][0] == ?- + conf[__item_configinfo_struct(tagid(tagOrId))[:alias]] = + conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][1..-1] + end + ret[conf[0]] = conf[1] + else + ret[conf.shift] = conf + end + } + + __item_font_optkeys(tagid(tagOrId)).each{|optkey| + optkey = optkey.to_s + fontconf = ret[optkey] + if fontconf.kind_of?(Array) + ret.delete(optkey) + ret.delete('latin' << optkey) + ret.delete('ascii' << optkey) + ret.delete('kanji' << optkey) + fontconf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = tagfontobj(tagid(tagOrId), optkey) + ret[optkey] = fontconf + end + } + + __item_methodcall_optkeys(tagid(tagOrId)).each{|optkey, method| + ret[optkey.to_s] = ['', '', '', self.__send__(method, tagOrId)] + } + + ret + end end end end @@ -756,31 +756,31 @@ module TkItemConfigMethod def current_itemconfiginfo(tagOrId, slot = nil) if TkComm::GET_CONFIGINFO_AS_ARRAY if slot - org_slot = slot - begin - conf = itemconfiginfo(tagOrId, slot) - if ( ! __item_configinfo_struct(tagid(tagOrId))[:alias] \ - || conf.size > __item_configinfo_struct(tagid(tagOrId))[:alias] + 1 ) - return {conf[0] => conf[-1]} - end - slot = conf[__item_configinfo_struct(tagid(tagOrId))[:alias]] - end while(org_slot != slot) - fail RuntimeError, - "there is a configure alias loop about '#{org_slot}'" + org_slot = slot + begin + conf = itemconfiginfo(tagOrId, slot) + if ( ! __item_configinfo_struct(tagid(tagOrId))[:alias] \ + || conf.size > __item_configinfo_struct(tagid(tagOrId))[:alias] + 1 ) + return {conf[0] => conf[-1]} + end + slot = conf[__item_configinfo_struct(tagid(tagOrId))[:alias]] + end while(org_slot != slot) + fail RuntimeError, + "there is a configure alias loop about '#{org_slot}'" else - ret = {} - itemconfiginfo(tagOrId).each{|conf| - if ( ! __item_configinfo_struct(tagid(tagOrId))[:alias] \ - || conf.size > __item_configinfo_struct(tagid(tagOrId))[:alias] + 1 ) - ret[conf[0]] = conf[-1] - end - } - ret + ret = {} + itemconfiginfo(tagOrId).each{|conf| + if ( ! __item_configinfo_struct(tagid(tagOrId))[:alias] \ + || conf.size > __item_configinfo_struct(tagid(tagOrId))[:alias] + 1 ) + ret[conf[0]] = conf[-1] + end + } + ret end else # ! TkComm::GET_CONFIGINFO_AS_ARRAY ret = {} - itemconfiginfo(slot).each{|key, conf| - ret[key] = conf[-1] if conf.kind_of?(Array) + itemconfiginfo(slot).each{|key, conf| + ret[key] = conf[-1] if conf.kind_of?(Array) } ret end diff --git a/ext/tk/lib/tk/itemfont.rb b/ext/tk/lib/tk/itemfont.rb index f194595d57..1f77ad11e7 100644 --- a/ext/tk/lib/tk/itemfont.rb +++ b/ext/tk/lib/tk/itemfont.rb @@ -33,19 +33,19 @@ module TkTreatItemFont if key pathname = [win, tag, key].join(';') TkFont.used_on(pathname) || - TkFont.init_widget_font(pathname, *(__item_config_cmd(tagid(tagOrId)))) + TkFont.init_widget_font(pathname, *(__item_config_cmd(tagid(tagOrId)))) elsif optkeys.size == 1 pathname = [win, tag, optkeys[0]].join(';') TkFont.used_on(pathname) || - TkFont.init_widget_font(pathname, *(__item_config_cmd(tagid(tagOrId)))) + TkFont.init_widget_font(pathname, *(__item_config_cmd(tagid(tagOrId)))) else fonts = {} optkeys.each{|key| - key = key.to_s - pathname = [win, tag, key].join(';') - fonts[key] = - TkFont.used_on(pathname) || - TkFont.init_widget_font(pathname, *(__item_config_cmd(tagid(tagOrId)))) + key = key.to_s + pathname = [win, tag, key].join(';') + fonts[key] = + TkFont.used_on(pathname) || + TkFont.init_widget_font(pathname, *(__item_config_cmd(tagid(tagOrId)))) } fonts end @@ -64,38 +64,38 @@ module TkTreatItemFont k_optkey = 'kanji' << optkey if slot.key?(optkey) - fnt = slot.delete(optkey) - if fnt.kind_of?(TkFont) - slot.delete(l_optkey) - slot.delete(a_optkey) - slot.delete(k_optkey) - - fnt.call_font_configure([pathname, optkey], - *(__item_config_cmd(tagid(tagOrId)) << {})) - next - else - if fnt - if (slot.key?(l_optkey) || - slot.key?(a_optkey) || - slot.key?(k_optkey)) - fnt = TkFont.new(fnt) - - lfnt = slot.delete(l_optkey) - lfnt = slot.delete(a_optkey) if slot.key?(a_optkey) - kfnt = slot.delete(k_optkey) - - fnt.latin_replace(lfnt) if lfnt - fnt.kanji_replace(kfnt) if kfnt - - fnt.call_font_configure([pathname, optkey], - *(__item_config_cmd(tagid(tagOrId)) << {})) - next - else - tk_call(*(__item_config_cmd(tagid(tagOrId)) << "-#{optkey}" << fnt)) - end - end - next - end + fnt = slot.delete(optkey) + if fnt.kind_of?(TkFont) + slot.delete(l_optkey) + slot.delete(a_optkey) + slot.delete(k_optkey) + + fnt.call_font_configure([pathname, optkey], + *(__item_config_cmd(tagid(tagOrId)) << {})) + next + else + if fnt + if (slot.key?(l_optkey) || + slot.key?(a_optkey) || + slot.key?(k_optkey)) + fnt = TkFont.new(fnt) + + lfnt = slot.delete(l_optkey) + lfnt = slot.delete(a_optkey) if slot.key?(a_optkey) + kfnt = slot.delete(k_optkey) + + fnt.latin_replace(lfnt) if lfnt + fnt.kanji_replace(kfnt) if kfnt + + fnt.call_font_configure([pathname, optkey], + *(__item_config_cmd(tagid(tagOrId)) << {})) + next + else + tk_call(*(__item_config_cmd(tagid(tagOrId)) << "-#{optkey}" << fnt)) + end + end + next + end end lfnt = slot.delete(l_optkey) @@ -103,12 +103,12 @@ module TkTreatItemFont kfnt = slot.delete(k_optkey) if lfnt && kfnt - TkFont.new(lfnt, kfnt).call_font_configure([pathname, optkey], - *(__item_config_cmd(tagid(tagOrId)) << {})) + TkFont.new(lfnt, kfnt).call_font_configure([pathname, optkey], + *(__item_config_cmd(tagid(tagOrId)) << {})) elsif lfnt - latintagfont_configure([lfnt, optkey]) + latintagfont_configure([lfnt, optkey]) elsif kfnt - kanjitagfont_configure([kfnt, optkey]) + kanjitagfont_configure([kfnt, optkey]) end } @@ -140,26 +140,26 @@ module TkTreatItemFont pathname = [win, tag, optkey].join(';') if (fobj = TkFont.used_on(pathname)) - fobj = TkFont.new(fobj) # create a new TkFont object + fobj = TkFont.new(fobj) # create a new TkFont object elsif Tk::JAPANIZED_TK - fobj = fontobj # create a new TkFont object + fobj = fontobj # create a new TkFont object else - tk_call(*(__item_config_cmd(tagid(tagOrId)) << "-#{optkey}" << ltn)) - next + tk_call(*(__item_config_cmd(tagid(tagOrId)) << "-#{optkey}" << ltn)) + next end if fobj.kind_of?(TkFont) - if ltn.kind_of?(TkFont) - conf = {} - ltn.latin_configinfo.each{|key,val| conf[key] = val} - if keys - fobj.latin_configure(conf.update(keys)) - else - fobj.latin_configure(conf) - end - else - fobj.latin_replace(ltn) - end + if ltn.kind_of?(TkFont) + conf = {} + ltn.latin_configinfo.each{|key,val| conf[key] = val} + if keys + fobj.latin_configure(conf.update(keys)) + else + fobj.latin_configure(conf) + end + else + fobj.latin_replace(ltn) + end end fobj.call_font_configure([pathname, optkey], *(__item_config_cmd(tagid(tagOrId)) << {})) @@ -191,26 +191,26 @@ module TkTreatItemFont pathname = [win, tag, optkey].join(';') if (fobj = TkFont.used_on(pathname)) - fobj = TkFont.new(fobj) # create a new TkFont object + fobj = TkFont.new(fobj) # create a new TkFont object elsif Tk::JAPANIZED_TK - fobj = fontobj # create a new TkFont object + fobj = fontobj # create a new TkFont object else - tk_call(*(__item_config_cmd(tagid(tagOrId)) << "-#{optkey}" << knj)) - next + tk_call(*(__item_config_cmd(tagid(tagOrId)) << "-#{optkey}" << knj)) + next end if fobj.kind_of?(TkFont) - if knj.kind_of?(TkFont) - conf = {} - knj.kanji_configinfo.each{|key,val| conf[key] = val} - if keys - fobj.kanji_configure(conf.update(keys)) - else - fobj.kanji_configure(conf) - end - else - fobj.kanji_replace(knj) - end + if knj.kind_of?(TkFont) + conf = {} + knj.kanji_configinfo.each{|key,val| conf[key] = val} + if keys + fobj.kanji_configure(conf.update(keys)) + else + fobj.kanji_configure(conf) + end + else + fobj.kanji_replace(knj) + end end fobj.call_font_configure([pathname, optkey], *(__item_config_cmd(tagid(tagOrId)) << {})) @@ -221,24 +221,24 @@ module TkTreatItemFont def tagfont_copy(tagOrId, window, wintag=nil, winkey=nil, targetkey=nil) if wintag if winkey - fnt = window.tagfontobj(wintag, winkey).dup + fnt = window.tagfontobj(wintag, winkey).dup else - fnt = window.tagfontobj(wintag).dup + fnt = window.tagfontobj(wintag).dup end else if winkey - fnt = window.fontobj(winkey).dup + fnt = window.fontobj(winkey).dup else - fnt = window.fontobj.dup + fnt = window.fontobj.dup end end if targetkey fnt.call_font_configure([__item_pathname(tagid(tagOrId)), targetkey], - *(__item_config_cmd(tagid(tagOrId)) << {})) + *(__item_config_cmd(tagid(tagOrId)) << {})) else fnt.call_font_configure(__item_pathname(tagid(tagOrId)), - *(__item_config_cmd(tagid(tagOrId)) << {})) + *(__item_config_cmd(tagid(tagOrId)) << {})) end self end @@ -247,23 +247,23 @@ module TkTreatItemFont def latintagfont_copy(tagOrId, window, wintag=nil, winkey=nil, targetkey=nil) if targetkey fontobj(targetkey).dup.call_font_configure([__item_pathname(tagid(tagOrId)), targetkey], - *(__item_config_cmd(tagid(tagOrId)) << {})) + *(__item_config_cmd(tagid(tagOrId)) << {})) else fontobj.dup.call_font_configure(__item_pathname(tagid(tagOrId)), - *(__item_config_cmd(tagid(tagOrId)) << {})) + *(__item_config_cmd(tagid(tagOrId)) << {})) end if wintag if winkey - fontobj.latin_replace(window.tagfontobj(wintag, winkey).latin_font_id) + fontobj.latin_replace(window.tagfontobj(wintag, winkey).latin_font_id) else - fontobj.latin_replace(window.tagfontobj(wintag).latin_font_id) + fontobj.latin_replace(window.tagfontobj(wintag).latin_font_id) end else if winkey - fontobj.latin_replace(window.fontobj(winkey).latin_font_id) + fontobj.latin_replace(window.fontobj(winkey).latin_font_id) else - fontobj.latin_replace(window.fontobj.latin_font_id) + fontobj.latin_replace(window.fontobj.latin_font_id) end end self @@ -273,23 +273,23 @@ module TkTreatItemFont def kanjifont_copy(tagOrId, window, wintag=nil, winkey=nil, targetkey=nil) if targetkey fontobj(targetkey).dup.call_font_configure([__item_pathname(tagid(tagOrId)), targetkey], - *(__item_config_cmd(tagid(tagOrId)) << {})) + *(__item_config_cmd(tagid(tagOrId)) << {})) else - fontobj.dup.call_font_configure(__item_pathname(tagid(tagOrId)), - *(__item_config_cmd(tagid(tagOrId)) << {})) + fontobj.dup.call_font_configure(__item_pathname(tagid(tagOrId)), + *(__item_config_cmd(tagid(tagOrId)) << {})) end if wintag if winkey - fontobj.kanji_replace(window.tagfontobj(wintag, winkey).kanji_font_id) + fontobj.kanji_replace(window.tagfontobj(wintag, winkey).kanji_font_id) else - fontobj.kanji_replace(window.tagfontobj(wintag).kanji_font_id) + fontobj.kanji_replace(window.tagfontobj(wintag).kanji_font_id) end else if winkey - fontobj.kanji_replace(window.fontobj(winkey).kanji_font_id) + fontobj.kanji_replace(window.fontobj(winkey).kanji_font_id) else - fontobj.kanji_replace(window.fontobj.kanji_font_id) + fontobj.kanji_replace(window.fontobj.kanji_font_id) end end self diff --git a/ext/tk/lib/tk/kinput.rb b/ext/tk/lib/tk/kinput.rb index 418b3aec47..fc731b6569 100644 --- a/ext/tk/lib/tk/kinput.rb +++ b/ext/tk/lib/tk/kinput.rb @@ -48,13 +48,13 @@ module TkKinput def TkKinput.attribute_info(window, slot=nil) if slot conf = tk_split_list(tk_call('kanjiInput', 'attribute', - window, "-#{slot}")) + window, "-#{slot}")) conf[0] = conf[0][1..-1] conf else tk_split_list(tk_call('kanjiInput', 'attribute', window)).collect{|conf| - conf[0] = conf[0][1..-1] - conf + conf[0] = conf[0][1..-1] + conf } end end diff --git a/ext/tk/lib/tk/listbox.rb b/ext/tk/lib/tk/listbox.rb index d642ba2f09..f00db19239 100644 --- a/ext/tk/lib/tk/listbox.rb +++ b/ext/tk/lib/tk/listbox.rb @@ -105,15 +105,15 @@ class TkListboxval}) - end + if val == None + tagfontobj(index) + else + tagfont_configure(index, {key=>val}) + end else - tk_call('itemconfigure', index, "-#{key}", val) + tk_call('itemconfigure', index, "-#{key}", val) end end self @@ -150,101 +150,101 @@ class TkListbox conf } + case key.to_s + when 'text', 'label', 'show' + conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('itemconfigure',index,"-#{key}"))) + when 'font', 'kanjifont' + conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('itemconfigure',index,"-#{key}"))) + conf[4] = tagfont_configinfo(index, conf[4]) + else + conf = tk_split_list(_fromUTF8(tk_send_without_enc('itemconfigure',index,"-#{key}"))) + end + key = conf.shift[1..-1] + { key => conf } else - ret = {} - tk_split_simplelist(_fromUTF8(tk_send_without_enc('itemconfigure', index))).each{|conflist| - conf = tk_split_simplelist(conflist) - key = conf.shift[1..-1] - case key - when 'text', 'label', 'show' - else - if conf[2] - if conf[2].index('{') - conf[2] = tk_split_list(conf[2]) - else - conf[2] = tk_tcl2ruby(conf[2]) - end - end - if conf[3] - if conf[3].index('{') - conf[3] = tk_split_list(conf[3]) - else - conf[3] = tk_tcl2ruby(conf[3]) - end - end - end - if conf.size == 1 - ret[key] = conf[0][1..-1] # alias info - else - ret[key] = conf - end - } - fontconf = ret['font'] - if fontconf - ret.delete('font') - ret.delete('kanjifont') - fontconf[3] = tagfont_configinfo(index, fontconf[3]) - ret['font'] = fontconf - end - ret + ret = {} + tk_split_simplelist(_fromUTF8(tk_send_without_enc('itemconfigure', index))).each{|conflist| + conf = tk_split_simplelist(conflist) + key = conf.shift[1..-1] + case key + when 'text', 'label', 'show' + else + if conf[2] + if conf[2].index('{') + conf[2] = tk_split_list(conf[2]) + else + conf[2] = tk_tcl2ruby(conf[2]) + end + end + if conf[3] + if conf[3].index('{') + conf[3] = tk_split_list(conf[3]) + else + conf[3] = tk_tcl2ruby(conf[3]) + end + end + end + if conf.size == 1 + ret[key] = conf[0][1..-1] # alias info + else + ret[key] = conf + end + } + fontconf = ret['font'] + if fontconf + ret.delete('font') + ret.delete('kanjifont') + fontconf[3] = tagfont_configinfo(index, fontconf[3]) + ret['font'] = fontconf + end + ret end end end @@ -252,19 +252,19 @@ class TkListbox conf[4]} + conf = itemconfiginfo(index, key) + {conf[0] => conf[4]} else - ret = {} - itemconfiginfo(index).each{|conf| - ret[conf[0]] = conf[4] if conf.size > 2 - } - ret + ret = {} + itemconfiginfo(index).each{|conf| + ret[conf[0]] = conf[4] if conf.size > 2 + } + ret end else # ! TkComm::GET_CONFIGINFO_AS_ARRAY ret = {} itemconfiginfo(index, key).each{|k, conf| - ret[k] = conf[-1] if conf.kind_of?(Array) + ret[k] = conf[-1] if conf.kind_of?(Array) } ret end diff --git a/ext/tk/lib/tk/menu.rb b/ext/tk/lib/tk/menu.rb index f13a7c5a68..5014dea603 100644 --- a/ext/tk/lib/tk/menu.rb +++ b/ext/tk/lib/tk/menu.rb @@ -84,13 +84,13 @@ class TkMenuval}) - end + if val == None + tagfontobj(index) + else + tagfont_configure(index, {key=>val}) + end else - tk_call('entryconfigure', index, "-#{key}", val) + tk_call('entryconfigure', index, "-#{key}", val) end end self @@ -189,100 +189,100 @@ class TkMenu conf } + case key.to_s + when 'text', 'label', 'show' + conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('entryconfigure',_get_eval_enc_str(index),"-#{key}"))) + when 'font', 'kanjifont' + conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('entryconfigure',_get_eval_enc_str(index),"-#{key}"))) + conf[4] = tagfont_configinfo(index, conf[4]) + else + conf = tk_split_list(_fromUTF8(tk_send_without_enc('entryconfigure',_get_eval_enc_str(index),"-#{key}"))) + end + key = conf.shift[1..-1] + { key => conf } else - ret = {} - tk_split_simplelist(_fromUTF8(tk_send_without_enc('entryconfigure', _get_eval_enc_str(index)))).each{|conflist| - conf = tk_split_simplelist(conflist) - key = conf.shift[1..-1] - case key - when 'text', 'label', 'show' - else - if conf[2] - if conf[2].index('{') - conf[2] = tk_split_list(conf[2]) - else - conf[2] = tk_tcl2ruby(conf[2]) - end - end - if conf[3] - if conf[3].index('{') - conf[3] = tk_split_list(conf[3]) - else - conf[3] = tk_tcl2ruby(conf[3]) - end - end - end - if conf.size == 1 - ret[key] = conf[0][1..-1] # alias info - else - ret[key] = conf - end - } - fontconf = ret['font'] - if fontconf - ret.delete('font') - ret.delete('kanjifont') - fontconf[3] = tagfont_configinfo(index, fontconf[3]) - ret['font'] = fontconf - end - ret + ret = {} + tk_split_simplelist(_fromUTF8(tk_send_without_enc('entryconfigure', _get_eval_enc_str(index)))).each{|conflist| + conf = tk_split_simplelist(conflist) + key = conf.shift[1..-1] + case key + when 'text', 'label', 'show' + else + if conf[2] + if conf[2].index('{') + conf[2] = tk_split_list(conf[2]) + else + conf[2] = tk_tcl2ruby(conf[2]) + end + end + if conf[3] + if conf[3].index('{') + conf[3] = tk_split_list(conf[3]) + else + conf[3] = tk_tcl2ruby(conf[3]) + end + end + end + if conf.size == 1 + ret[key] = conf[0][1..-1] # alias info + else + ret[key] = conf + end + } + fontconf = ret['font'] + if fontconf + ret.delete('font') + ret.delete('kanjifont') + fontconf[3] = tagfont_configinfo(index, fontconf[3]) + ret['font'] = fontconf + end + ret end end end @@ -290,19 +290,19 @@ class TkMenu conf[4]} + conf = entryconfiginfo(index, key) + {conf[0] => conf[4]} else - ret = {} - entryconfiginfo(index).each{|conf| - ret[conf[0]] = conf[4] if conf.size > 2 - } - ret + ret = {} + entryconfiginfo(index).each{|conf| + ret[conf[0]] = conf[4] if conf.size > 2 + } + ret end else # ! TkComm::GET_CONFIGINFO_AS_ARRAY ret = {} entryconfiginfo(index, key).each{|k, conf| - ret[k] = conf[-1] if conf.kind_of?(Array) + ret[k] = conf[-1] if conf.kind_of?(Array) } ret end @@ -422,7 +422,7 @@ class TkOptionMenubutton@variable, - 'label'=>value, 'value'=>value) + 'label'=>value, 'value'=>value) self end def index(index) @@ -446,7 +446,7 @@ class TkOptionMenubutton@variable, - 'label'=>value, 'value'=>value) + 'label'=>value, 'value'=>value) self end def delete(index, last=None) diff --git a/ext/tk/lib/tk/menubar.rb b/ext/tk/lib/tk/menubar.rb index f29c40ff38..392b6fbd4e 100644 --- a/ext/tk/lib/tk/menubar.rb +++ b/ext/tk/lib/tk/menubar.rb @@ -18,10 +18,10 @@ # ['Paste', proc{puts('Paste clicked')}, 0]] # ] # menubar = TkMenubar.new(nil, menu_spec, -# 'tearoff'=>false, -# 'foreground'=>'grey40', -# 'activeforeground'=>'red', -# 'font'=>'-adobe-helvetica-bold-r-*--12-*-iso8859-1') +# 'tearoff'=>false, +# 'foreground'=>'grey40', +# 'activeforeground'=>'red', +# 'font'=>'-adobe-helvetica-bold-r-*--12-*-iso8859-1') # menubar.pack('side'=>'top', 'fill'=>'x') # # @@ -30,13 +30,13 @@ # # menubar = TkMenubar.new # menubar.add_menu([['File', 0], -# ['Open', proc{puts('Open clicked')}, 0], -# '---', -# ['Quit', proc{exit}, 0]]) +# ['Open', proc{puts('Open clicked')}, 0], +# '---', +# ['Quit', proc{exit}, 0]]) # menubar.add_menu([['Edit', 0], -# ['Cut', proc{puts('Cut clicked')}, 2], -# ['Copy', proc{puts('Copy clicked')}, 0], -# ['Paste', proc{puts('Paste clicked')}, 0]]) +# ['Cut', proc{puts('Cut clicked')}, 2], +# ['Copy', proc{puts('Copy clicked')}, 0], +# ['Paste', proc{puts('Paste clicked')}, 0]]) # menubar.configure('tearoff', false) # menubar.configure('foreground', 'grey40') # menubar.configure('activeforeground', 'red') diff --git a/ext/tk/lib/tk/menuspec.rb b/ext/tk/lib/tk/menuspec.rb index dfc1871ba9..c8819f8e41 100644 --- a/ext/tk/lib/tk/menuspec.rb +++ b/ext/tk/lib/tk/menuspec.rb @@ -36,7 +36,7 @@ module TkMenuSpec def _create_menu(parent, menu_info, menu_name = nil, - tearoff = false, default_opts = nil) + tearoff = false, default_opts = nil) if tearoff.kind_of?(Hash) default_opts = tearoff tearoff = false @@ -64,79 +64,79 @@ module TkMenuSpec for item_info in menu_info if item_info.kind_of?(Hash) - options = orig_opts.dup - options.update(_symbolkey2str(item_info)) - item_type = (options.delete('type') || 'command').to_s - menu_name = options.delete('menu_name') - menu_opts = orig_opts.dup - menu_opts.update(_symbolkey2str(options.delete('menu_config') || {})) - if item_type == 'cascade' && options['menu'].kind_of?(Array) - # create cascade menu - submenu = _create_menu(menu, options['menu'], menu_name, - tearoff, menu_opts) - options['menu'] = submenu - end - menu.add(item_type, options) + options = orig_opts.dup + options.update(_symbolkey2str(item_info)) + item_type = (options.delete('type') || 'command').to_s + menu_name = options.delete('menu_name') + menu_opts = orig_opts.dup + menu_opts.update(_symbolkey2str(options.delete('menu_config') || {})) + if item_type == 'cascade' && options['menu'].kind_of?(Array) + # create cascade menu + submenu = _create_menu(menu, options['menu'], menu_name, + tearoff, menu_opts) + options['menu'] = submenu + end + menu.add(item_type, options) elsif item_info.kind_of?(Array) - options = orig_opts.dup - - options['label'] = item_info[0] if item_info[0] - - case item_info[1] - when TkVariable - # checkbutton - item_type = 'checkbutton' - options['variable'] = item_info[1] - options['onvalue'] = true - options['offvalue'] = false - - when Array - # radiobutton or cascade - if item_info[1][0].kind_of?(TkVariable) - # radiobutton - item_type = 'radiobutton' - options['variable'] = item_info[1][0] - options['value'] = item_info[1][1] if item_info[1][1] - - else - # cascade - item_type = 'cascade' - menu_opts = orig_opts.dup - if item_info[4] && item_info[4].kind_of?(Hash) - opts = _symbolkey2str(item_info[4]) - menu_name = opts.delete('menu_name') - menu_config = opts.delete('menu_config') || {} - menu_opts.update(_symbolkey2str(menu_config)) - end - submenu = _create_menu(menu, item_info[1], menu_name, - tearoff, menu_opts) - options['menu'] = submenu - end - - else - # command - item_type = 'command' - options['command'] = item_info[1] if item_info[1] - end - - options['underline'] = item_info[2] if item_info[2] - options['accelerator'] = item_info[3] if item_info[3] - if item_info[4] && item_info[4].kind_of?(Hash) - opts = _symbolkey2str(item_info[4]) - if item_type == 'cascade' - opts.delete('menu_name') - opts.delete('menu_config') - end - options.update(opts) - end - menu.add(item_type, options) + options = orig_opts.dup + + options['label'] = item_info[0] if item_info[0] + + case item_info[1] + when TkVariable + # checkbutton + item_type = 'checkbutton' + options['variable'] = item_info[1] + options['onvalue'] = true + options['offvalue'] = false + + when Array + # radiobutton or cascade + if item_info[1][0].kind_of?(TkVariable) + # radiobutton + item_type = 'radiobutton' + options['variable'] = item_info[1][0] + options['value'] = item_info[1][1] if item_info[1][1] + + else + # cascade + item_type = 'cascade' + menu_opts = orig_opts.dup + if item_info[4] && item_info[4].kind_of?(Hash) + opts = _symbolkey2str(item_info[4]) + menu_name = opts.delete('menu_name') + menu_config = opts.delete('menu_config') || {} + menu_opts.update(_symbolkey2str(menu_config)) + end + submenu = _create_menu(menu, item_info[1], menu_name, + tearoff, menu_opts) + options['menu'] = submenu + end + + else + # command + item_type = 'command' + options['command'] = item_info[1] if item_info[1] + end + + options['underline'] = item_info[2] if item_info[2] + options['accelerator'] = item_info[3] if item_info[3] + if item_info[4] && item_info[4].kind_of?(Hash) + opts = _symbolkey2str(item_info[4]) + if item_type == 'cascade' + opts.delete('menu_name') + opts.delete('menu_config') + end + options.update(opts) + end + menu.add(item_type, options) elsif /^-+$/ =~ item_info - menu.add('separator') + menu.add('separator') else - menu.add('command', 'label' => item_info) + menu.add('command', 'label' => item_info) end end @@ -150,8 +150,8 @@ module TkMenuSpec return true else begin - parent.cget('menu') - return true + parent.cget('menu') + return true rescue end end @@ -192,22 +192,22 @@ module TkMenuSpec menu_name = nil if btn_info.kind_of?(Hash) - keys.update(_symbolkey2str(btn_info)) - menu_name = keys.delete('menu_name') - keys['label'] = keys.delete('text') if keys.key?('text') + keys.update(_symbolkey2str(btn_info)) + menu_name = keys.delete('menu_name') + keys['label'] = keys.delete('text') if keys.key?('text') elsif btn_info.kind_of?(Array) - keys['label'] = btn_info[0] if btn_info[0] - keys['underline'] = btn_info[1] if btn_info[1] - if btn_info[2]&&btn_info[2].kind_of?(Hash) - keys.update(_symbolkey2str(btn_info[2])) - menu_name = keys.delete('menu_name') - end + keys['label'] = btn_info[0] if btn_info[0] + keys['underline'] = btn_info[1] if btn_info[1] + if btn_info[2]&&btn_info[2].kind_of?(Hash) + keys.update(_symbolkey2str(btn_info[2])) + menu_name = keys.delete('menu_name') + end else - keys = {:label=>btn_info} + keys = {:label=>btn_info} end menu = _create_menu(mbar, menu_info[1..-1], menu_name, - tearoff, default_opts) + tearoff, default_opts) menu.tearoff(tearoff) keys['menu'] = menu @@ -222,27 +222,27 @@ module TkMenuSpec menu_name = nil if btn_info.kind_of?(Hash) - keys.update(_symbolkey2str(btn_info)) - menu_name = keys.delete('menu_name') - keys['text'] = keys.delete('label') if keys.key?('label') - mbtn.configure(keys) + keys.update(_symbolkey2str(btn_info)) + menu_name = keys.delete('menu_name') + keys['text'] = keys.delete('label') if keys.key?('label') + mbtn.configure(keys) elsif btn_info.kind_of?(Array) - mbtn.configure('text', btn_info[0]) if btn_info[0] - mbtn.configure('underline', btn_info[1]) if btn_info[1] - # mbtn.configure('accelerator', btn_info[2]) if btn_info[2] - if btn_info[2]&&btn_info[2].kind_of?(Hash) - keys.update(_symbolkey2str(btn_info[2])) - menu_name = keys.delete('menu_name') - mbtn.configure(keys) - end + mbtn.configure('text', btn_info[0]) if btn_info[0] + mbtn.configure('underline', btn_info[1]) if btn_info[1] + # mbtn.configure('accelerator', btn_info[2]) if btn_info[2] + if btn_info[2]&&btn_info[2].kind_of?(Hash) + keys.update(_symbolkey2str(btn_info[2])) + menu_name = keys.delete('menu_name') + mbtn.configure(keys) + end else - mbtn.configure('text', btn_info) + mbtn.configure('text', btn_info) end mbtn.pack('side' => 'left') menu = _create_menu(mbtn, menu_info[1..-1], menu_name, - tearoff, default_opts) + tearoff, default_opts) mbtn.menu(menu) @@ -255,8 +255,8 @@ module TkMenuSpec menus = [] (0..(menu.index('last'))).each{|idx| if menu.menutype(idx) == 'cascade' - submenu = menu.entrycget(idx, 'menu') - menus << [submenu, _get_cascade_menus(submenu)] + submenu = menu.entrycget(idx, 'menu') + menus << [submenu, _get_cascade_menus(submenu)] end } menus diff --git a/ext/tk/lib/tk/msgcat.rb b/ext/tk/lib/tk/msgcat.rb index e7a5499008..4e095c6fc0 100644 --- a/ext/tk/lib/tk/msgcat.rb +++ b/ext/tk/lib/tk/msgcat.rb @@ -46,7 +46,7 @@ class TkMsgCatalog < TkObject return -code $st $ret } } else { - return $ret + return $ret } EOL @@ -64,17 +64,17 @@ class TkMsgCatalog < TkObject exit!(1) rescue Exception => e begin - 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 >-------" - msg.instance_variable_set(:@encoding, 'utf-8') + 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 >-------" + msg.instance_variable_set(:@encoding, 'utf-8') rescue Exception - msg = e.class.inspect + ': ' + e.message + "\n" + - "\n---< backtrace of Ruby side >-----\n" + - e.backtrace.join("\n") + - "\n---< backtrace of Tk side >-------" + msg = e.class.inspect + ': ' + e.message + "\n" + + "\n---< backtrace of Ruby side >-----\n" + + e.backtrace.join("\n") + + "\n---< backtrace of Tk side >-------" end fail(e, msg) end @@ -103,22 +103,22 @@ class TkMsgCatalog < TkObject when 1 # src only, or trans_list if args[0].kind_of?(Array) - # trans_list - #list = args[0].collect{|src, trans| - # [ Tk::UTF8_String.new(src), Tk::UTF8_String.new(trans) ] - #} - self.set_translation_list(loc, args[0]) + # trans_list + #list = args[0].collect{|src, trans| + # [ Tk::UTF8_String.new(src), Tk::UTF8_String.new(trans) ] + #} + self.set_translation_list(loc, args[0]) else - # src - #self.set_translation(loc, Tk::UTF8_String.new(args[0])) - self.set_translation(loc, args[0]) + # src + #self.set_translation(loc, Tk::UTF8_String.new(args[0])) + self.set_translation(loc, args[0]) end when 2 # src and trans, or, trans_list and enc if args[0].kind_of?(Array) else - #self.set_translation(loc, args[0], Tk::UTF8_String.new(args[1])) - self.set_translation(loc, *args) + #self.set_translation(loc, args[0], Tk::UTF8_String.new(args[1])) + self.set_translation(loc, *args) end when 3 # src and trans and enc @@ -144,7 +144,7 @@ class TkMsgCatalog < TkObject def translate(*args) dst = args.collect{|src| @namespace.eval{tk_call_without_enc('::msgcat::mc', - _get_eval_string(src, true))} + _get_eval_string(src, true))} } Tk.UTF8_String(sprintf(*dst)) end @@ -188,8 +188,8 @@ class TkMsgCatalog < TkObject preferences().each{|loc| file = File.join(dir, loc + self::MSGCAT_EXT) if File.readable?(file) - count += 1 - eval(open(file){|f| f.read}) + count += 1 + eval(open(file){|f| f.read}) end } count @@ -204,8 +204,8 @@ class TkMsgCatalog < TkObject preferences().each{|loc| file = File.join(dir, loc + @msgcat_ext) if File.readable?(file) - count += 1 - @namespace.eval(open(file){|f| f.read}) + count += 1 + @namespace.eval(open(file){|f| f.read}) end } count @@ -220,29 +220,29 @@ class TkMsgCatalog < TkObject if trans_str && trans_str != None trans_str = Tk.UTF8_String(_toUTF8(trans_str, enc)) Tk.UTF8_String(tk_call_without_enc('::msgcat::mcset', - locale, - _get_eval_string(src_str, true), - trans_str)) + locale, + _get_eval_string(src_str, true), + trans_str)) else Tk.UTF8_String(tk_call_without_enc('::msgcat::mcset', - locale, - _get_eval_string(src_str, true))) + locale, + _get_eval_string(src_str, true))) end end def set_translation(locale, src_str, trans_str=None, enc='utf-8') if trans_str && trans_str != None trans_str = Tk.UTF8_String(_toUTF8(trans_str, enc)) Tk.UTF8_String(@namespace.eval{ - tk_call_without_enc('::msgcat::mcset', - locale, - _get_eval_string(src_str, true), - trans_str) - }) + tk_call_without_enc('::msgcat::mcset', + locale, + _get_eval_string(src_str, true), + trans_str) + }) else Tk.UTF8_String(@namespace.eval{ - tk_call_without_enc('::msgcat::mcset', - locale, - _get_eval_string(src_str, true))}) + tk_call_without_enc('::msgcat::mcset', + locale, + _get_eval_string(src_str, true))}) end end @@ -251,10 +251,10 @@ class TkMsgCatalog < TkObject list = [] trans_list.each{|src, trans| if trans && trans != None - list << _get_eval_string(src, true) - list << Tk.UTF8_Stirng(_toUTF8(trans, enc)) + list << _get_eval_string(src, true) + list << Tk.UTF8_Stirng(_toUTF8(trans, enc)) else - list << _get_eval_string(src, true) << '' + list << _get_eval_string(src, true) << '' end } number(tk_call_without_enc('::msgcat::mcmset', locale, list)) @@ -264,15 +264,15 @@ class TkMsgCatalog < TkObject list = [] trans_list.each{|src, trans| if trans && trans != None - list << _get_eval_string(src, true) - list << Tk.UTF8_String(_toUTF8(trans, enc)) + list << _get_eval_string(src, true) + list << Tk.UTF8_String(_toUTF8(trans, enc)) else - list << _get_eval_string(src, true) << '' + list << _get_eval_string(src, true) << '' end } number(@namespace.eval{ - tk_call_without_enc('::msgcat::mcmset', locale, list) - }) + tk_call_without_enc('::msgcat::mcmset', locale, list) + }) end def self.def_unknown_proc(cmd=Proc.new) diff --git a/ext/tk/lib/tk/namespace.rb b/ext/tk/lib/tk/namespace.rb index 912ed1b5d3..a236fb6a99 100644 --- a/ext/tk/lib/tk/namespace.rb +++ b/ext/tk/lib/tk/namespace.rb @@ -24,19 +24,19 @@ class TkNamespace < TkObject #super('namespace', 'eval', @namespace, *args) args = args.collect{|arg| (s = _get_eval_string(arg))? s: ''} super('namespace', 'eval', @namespace, - TkCore::INTERP._merge_tklist(*args)) + TkCore::INTERP._merge_tklist(*args)) end def tk_call_without_enc(*args) #super('namespace', 'eval', @namespace, *args) args = args.collect{|arg| (s = _get_eval_string(arg))? s: ''} super('namespace', 'eval', @namespace, - TkCore::INTERP._merge_tklist(*args)) + TkCore::INTERP._merge_tklist(*args)) end def tk_call_with_enc(*args) #super('namespace', 'eval', @namespace, *args) args = args.collect{|arg| (s = _get_eval_string(arg))? s: ''} super('namespace', 'eval', @namespace, - TkCore::INTERP._merge_tklist(*args)) + TkCore::INTERP._merge_tklist(*args)) end def initialize(namespace, *args) @@ -68,19 +68,19 @@ class TkNamespace < TkObject #super('namespace', 'eval', @fullname, *args) args = args.collect{|arg| (s = _get_eval_string(arg))? s: ''} super('namespace', 'eval', @fullname, - TkCore::INTERP._merge_tklist(*args)) + TkCore::INTERP._merge_tklist(*args)) end def tk_call_without_enc(*args) #super('namespace', 'eval', @fullname, *args) args = args.collect{|arg| (s = _get_eval_string(arg))? s: ''} super('namespace', 'eval', @fullname, - TkCore::INTERP._merge_tklist(*args)) + TkCore::INTERP._merge_tklist(*args)) end def tk_call_with_enc(*args) #super('namespace', 'eval', @fullname, *args) args = args.collect{|arg| (s = _get_eval_string(arg))? s: ''} super('namespace', 'eval', @fullname, - TkCore::INTERP._merge_tklist(*args)) + TkCore::INTERP._merge_tklist(*args)) end alias ns_tk_call tk_call alias ns_tk_call_without_enc tk_call_without_enc @@ -95,27 +95,27 @@ class TkNamespace < TkObject name = __tk_call('namespace', 'current') if name == '' if parent if parent =~ /^::/ - if name =~ /^::/ - @fullname = parent + name - else - @fullname = parent +'::'+ name - end + if name =~ /^::/ + @fullname = parent + name + else + @fullname = parent +'::'+ name + end else - ancestor = __tk_call('namespace', 'current') - ancestor = '' if ancestor == '::' - if name =~ /^::/ - @fullname = ancestor + '::' + parent + name - else - @fullname = ancestor + '::'+ parent +'::'+ name - end + ancestor = __tk_call('namespace', 'current') + ancestor = '' if ancestor == '::' + if name =~ /^::/ + @fullname = ancestor + '::' + parent + name + else + @fullname = ancestor + '::'+ parent +'::'+ name + end end else # parent == nil ancestor = __tk_call('namespace', 'current') ancestor = '' if ancestor == '::' if name =~ /^::/ - @fullname = name + @fullname = name else - @fullname = ancestor + '::' + name + @fullname = ancestor + '::' + name end end @path = @fullname @@ -134,9 +134,9 @@ class TkNamespace < TkObject tk_split_simplelist(tk_call('namespace', 'children', *args)).collect{|ns| # ns is fullname if Tk_Namespace_ID_TBL.key?(ns) - Tk_Namespace_ID_TBL[ns] + Tk_Namespace_ID_TBL[ns] else - ns + ns end } end @@ -156,7 +156,7 @@ class TkNamespace < TkObject fail ArgumentError, "String or Proc is expected" end TkNamespace::NsCode.new(tk_call_without_enc('namespace', 'code', - _get_eval_string(cmd, false))) + _get_eval_string(cmd, false))) end def self.current diff --git a/ext/tk/lib/tk/optiondb.rb b/ext/tk/lib/tk/optiondb.rb index d940f38769..1484671920 100644 --- a/ext/tk/lib/tk/optiondb.rb +++ b/ext/tk/lib/tk/optiondb.rb @@ -41,7 +41,7 @@ module TkOptionDB def read_entries(file, f_enc=nil) if TkCore::INTERP.safe? fail SecurityError, - "can't call 'TkOptionDB.read_entries' on a safe interpreter" + "can't call 'TkOptionDB.read_entries' on a safe interpreter" end i_enc = Tk.encoding() @@ -54,29 +54,29 @@ module TkOptionDB cline = '' open(file, 'r') {|f| while line = f.gets - #cline += line.chomp! - cline.concat(line.chomp!) - case cline - when /\\$/ # continue - cline.chop! - next - when /^\s*(!|#)/ # coment - cline = '' - next - when /^([^:]+):(.*)$/ - pat = $1.strip - val = $2.lstrip - p "ResourceDB: #{[pat, val].inspect}" if $DEBUG - pat = TkCore::INTERP._toUTF8(pat, f_enc) - pat = TkCore::INTERP._fromUTF8(pat, i_enc) - val = TkCore::INTERP._toUTF8(val, f_enc) - val = TkCore::INTERP._fromUTF8(val, i_enc) - ent << [pat, val] - cline = '' - else # unknown --> ignore - cline = '' - next - end + #cline += line.chomp! + cline.concat(line.chomp!) + case cline + when /\\$/ # continue + cline.chop! + next + when /^\s*(!|#)/ # coment + cline = '' + next + when /^([^:]+):(.*)$/ + pat = $1.strip + val = $2.lstrip + p "ResourceDB: #{[pat, val].inspect}" if $DEBUG + pat = TkCore::INTERP._toUTF8(pat, f_enc) + pat = TkCore::INTERP._fromUTF8(pat, i_enc) + val = TkCore::INTERP._toUTF8(val, f_enc) + val = TkCore::INTERP._fromUTF8(val, i_enc) + ent << [pat, val] + cline = '' + else # unknown --> ignore + cline = '' + next + end end } ent @@ -99,28 +99,28 @@ module TkOptionDB cline = '' open(file, 'r') {|f| while line = f.gets - cline += line.chomp! - case cline - when /\\$/ # continue - cline.chop! - next - when /^\s*!/ # coment - cline = '' - next - when /^([^:]+):\s(.*)$/ - pat = $1 - val = $2 - p "ResourceDB: #{[pat, val].inspect}" if $DEBUG - pat = TkCore::INTERP._toUTF8(pat, f_enc) - pat = TkCore::INTERP._fromUTF8(pat, i_enc) - val = TkCore::INTERP._toUTF8(val, f_enc) - val = TkCore::INTERP._fromUTF8(val, i_enc) - add(pat, val, pri) - cline = '' - else # unknown --> ignore - cline = '' - next - end + cline += line.chomp! + case cline + when /\\$/ # continue + cline.chop! + next + when /^\s*!/ # coment + cline = '' + next + when /^([^:]+):\s(.*)$/ + pat = $1 + val = $2 + p "ResourceDB: #{[pat, val].inspect}" if $DEBUG + pat = TkCore::INTERP._toUTF8(pat, f_enc) + pat = TkCore::INTERP._fromUTF8(pat, i_enc) + val = TkCore::INTERP._toUTF8(val, f_enc) + val = TkCore::INTERP._fromUTF8(val, i_enc) + add(pat, val, pri) + cline = '' + else # unknown --> ignore + cline = '' + next + end end } =end @@ -133,7 +133,7 @@ module TkOptionDB @@resource_proc_class.const_set(:CARRIER, '.'.freeze) @@resource_proc_class.instance_variable_set('@method_tbl', - TkCore::INTERP.create_table) + TkCore::INTERP.create_table) @@resource_proc_class.instance_variable_set('@add_method', false) @@resource_proc_class.instance_variable_set('@safe_mode', 4) @@ -151,14 +151,14 @@ module TkOptionDB def __closed_block_check__(str) depth = 0 str.scan(/[{}]/){|x| - if x == "{" - depth += 1 - elsif x == "}" - depth -= 1 - end - if depth <= 0 && !($' =~ /\A\s*\Z/) - fail RuntimeError, "bad string for procedure : #{str.inspect}" - end + if x == "{" + depth += 1 + elsif x == "}" + depth -= 1 + end + if depth <= 0 && !($' =~ /\A\s*\Z/) + fail RuntimeError, "bad string for procedure : #{str.inspect}" + end } str end @@ -184,20 +184,20 @@ module TkOptionDB raise NoMethodError, "not support resource-proc '#{id.id2name}' for #{self.name}" end - proc_str = proc_source + proc_str = proc_source proc_str = '{' + proc_str + '}' unless /\A\{.*\}\Z/ =~ proc_str - #proc_str = __closed_block_check__(proc_str) + #proc_str = __closed_block_check__(proc_str) proc_str = __check_proc_string__(proc_str) res_proc = proc{ - begin - #eval("$SAFE = #{self::SAFE_MODE};\nProc.new" + proc_str) - eval("$SAFE = #{@safe_mode};\nProc.new" + proc_str) - rescue SyntaxError=>err - raise SyntaxError, - TkCore::INTERP._toUTF8(err.message.gsub(/\(eval\):\d:/, - "(#{id.id2name}):")) - end - }.call + begin + #eval("$SAFE = #{self::SAFE_MODE};\nProc.new" + proc_str) + eval("$SAFE = #{@safe_mode};\nProc.new" + proc_str) + rescue SyntaxError=>err + raise SyntaxError, + TkCore::INTERP._toUTF8(err.message.gsub(/\(eval\):\d:/, + "(#{id.id2name}):")) + end + }.call #self::METHOD_TBL[id] = [res_proc, proc_source] @method_tbl[id] = [res_proc, proc_source] end @@ -255,16 +255,16 @@ module TkOptionDB else klass = klass.to_s if klass.kind_of? Symbol unless (?A..?Z) === klass[0] - fail ArgumentError, "bad string '#{klass}' for class name" + fail ArgumentError, "bad string '#{klass}' for class name" end if parent == nil - install_win(nil) + install_win(nil) elsif parent.kind_of?(TkWindow) - install_win(parent.path) + install_win(parent.path) elsif parent <= @@resource_proc_class - install_win(parent::CARRIER) + install_win(parent::CARRIER) else - fail ArgumentError, "parent must be Resource-Proc class" + fail ArgumentError, "parent must be Resource-Proc class" end carrier = Tk.tk_call_without_enc('frame', @path, '-class', klass) end @@ -304,16 +304,16 @@ module TkOptionDB class << klass def __null_method(*args); nil; end [ :class_eval, :name, :superclass, :clone, :dup, :autoload, :autoload?, - :ancestors, :const_defined?, :const_get, :const_set, :const_missing, - :class_variables, :constants, :included_modules, :instance_methods, - :method_defined?, :module_eval, :private_instance_methods, - :protected_instance_methods, :public_instance_methods, - :singleton_methods, :remove_const, :remove_method, :undef_method, - :to_s, :inspect, :display, :method, :methods, :respond_to?, + :ancestors, :const_defined?, :const_get, :const_set, :const_missing, + :class_variables, :constants, :included_modules, :instance_methods, + :method_defined?, :module_eval, :private_instance_methods, + :protected_instance_methods, :public_instance_methods, + :singleton_methods, :remove_const, :remove_method, :undef_method, + :to_s, :inspect, :display, :method, :methods, :respond_to?, :instance_variable_get, :instance_variable_set, :instance_method, - :instance_eval, :instance_variables, :kind_of?, :is_a?, - :private_methods, :protected_methods, :public_methods ].each{|m| - alias_method(m, :__null_method) + :instance_eval, :instance_variables, :kind_of?, :is_a?, + :private_methods, :protected_methods, :public_methods ].each{|m| + alias_method(m, :__null_method) } end end @@ -351,7 +351,7 @@ module TkOptionDB def eval_under_random_base(parent = nil, &b) new_klass = __create_new_class(__get_random_basename(), - [], 4, false, parent) + [], 4, false, parent) ret = new_klass.class_eval(&b) if block_given? __remove_methods_of_proc_class(new_klass) new_klass.freeze diff --git a/ext/tk/lib/tk/optionobj.rb b/ext/tk/lib/tk/optionobj.rb index 2c8a1efd5e..8fe7e0ee5a 100644 --- a/ext/tk/lib/tk/optionobj.rb +++ b/ext/tk/lib/tk/optionobj.rb @@ -25,32 +25,32 @@ module Tk def observs @observ.collect{|win| - if win.kind_of?(Array) - win[0] - else - win - end + if win.kind_of?(Array) + win[0] + else + win + end } end def _remove_win(win) if win.kind_of?(Array) - widget, method = win - @observ.delete_if{|x| - if x.kind_of?(Array) - x[0] == widget - else - x == widget - end - } + widget, method = win + @observ.delete_if{|x| + if x.kind_of?(Array) + x[0] == widget + else + x == widget + end + } else - @observ.delete_if{|x| - if x.kind_of?(Array) - x[0] == win - else - x == win - end - } + @observ.delete_if{|x| + if x.kind_of?(Array) + x[0] == win + else + x == win + end + } end end private :_remove_win @@ -81,27 +81,27 @@ module Tk # #==> set all of them # wins.each{|win| - _remove_win(win) - @observ << win - notify(win) + _remove_win(win) + @observ << win + notify(win) } self end def unassign(*wins) wins.each{|win| - _remove_win(win) + _remove_win(win) } self end def notify(target = nil) if target - targets = [target] + targets = [target] elsif @observ.empty? - return self + return self else - targets = @observ.dup + targets = @observ.dup end return self if empty? @@ -109,50 +109,50 @@ module Tk org_hash = _symbolkey2str(self) targets.each{|win| - widget = receiver = win - hash = org_hash - begin - if win.kind_of?(Array) - widget, method, conv_tbl = win - receiver = widget - - if conv_tbl - hash = {} - org_hash.each{|key, val| - key = conv_tbl[key] if conv_tbl.key?(key) - next unless key - if key.kind_of?(Array) - key.each{|k| hash[k] = val} - else - hash[key] = val - end - } - end - - if method.kind_of?(Array) - receiver, method, *args = method - receiver.__send__(method, *(args << hash)) - elsif method - widget.__send__(method, hash) - else - widget.configure(hash) - end - - else - widget.configure(self) - end - rescue => e - if ( ( widget.kind_of?(TkObject) \ - && widget.respond_to?('exist?') \ - && ! receiver.exist? ) \ - || ( receiver.kind_of?(TkObject) \ - && receiver.respond_to?('exist?') \ - && ! receiver.exist? ) ) - @observ.delete(win) - else - fail e - end - end + widget = receiver = win + hash = org_hash + begin + if win.kind_of?(Array) + widget, method, conv_tbl = win + receiver = widget + + if conv_tbl + hash = {} + org_hash.each{|key, val| + key = conv_tbl[key] if conv_tbl.key?(key) + next unless key + if key.kind_of?(Array) + key.each{|k| hash[k] = val} + else + hash[key] = val + end + } + end + + if method.kind_of?(Array) + receiver, method, *args = method + receiver.__send__(method, *(args << hash)) + elsif method + widget.__send__(method, hash) + else + widget.configure(hash) + end + + else + widget.configure(self) + end + rescue => e + if ( ( widget.kind_of?(TkObject) \ + && widget.respond_to?('exist?') \ + && ! receiver.exist? ) \ + || ( receiver.kind_of?(TkObject) \ + && receiver.respond_to?('exist?') \ + && ! receiver.exist? ) ) + @observ.delete(win) + else + fail e + end + end } self @@ -161,7 +161,7 @@ module Tk def +(hash) unless hash.kind_of?(Hash) - fail ArgumentError, "expect a Hash" + fail ArgumentError, "expect a Hash" end new_obj = self.dup new_obj.update_without_notify(_symbolkey2str(hash)) @@ -177,9 +177,9 @@ module Tk def configure(key, value=nil) if key.kind_of?(Hash) - update(key) + update(key) else - store(key,value) + store(key,value) end end diff --git a/ext/tk/lib/tk/package.rb b/ext/tk/lib/tk/package.rb index dbb0ca33e8..d1eb27674d 100644 --- a/ext/tk/lib/tk/package.rb +++ b/ext/tk/lib/tk/package.rb @@ -35,12 +35,12 @@ module TkPackage # set proc cmd = arg[0] if cmd - tk_call('package', 'ifneeded', pkg, ver, cmd) - cmd + tk_call('package', 'ifneeded', pkg, ver, cmd) + cmd else - # remove proc - tk_call('package', 'ifneeded', pkg, ver, '') - nil + # remove proc + tk_call('package', 'ifneeded', pkg, ver, '') + nil end else @@ -112,12 +112,12 @@ module TkPackage # set proc cmd = arg[0] if cmd - tk_call('package', 'unknown', cmd) - cmd + tk_call('package', 'unknown', cmd) + cmd else - # remove proc - tk_call('package', 'unknown', '') - nil + # remove proc + tk_call('package', 'unknown', '') + nil end else diff --git a/ext/tk/lib/tk/palette.rb b/ext/tk/lib/tk/palette.rb index abcafcfb3a..dfe46940f3 100644 --- a/ext/tk/lib/tk/palette.rb +++ b/ext/tk/lib/tk/palette.rb @@ -37,11 +37,11 @@ module TkPalette colors.each{|key, value| begin - if window.cget(key) == tk_call('set', "tkPalette(#{key})") - window[key] = colors[key] - end + if window.cget(key) == tk_call('set', "tkPalette(#{key})") + window[key] = colors[key] + end rescue - # ignore + # ignore end } diff --git a/ext/tk/lib/tk/panedwindow.rb b/ext/tk/lib/tk/panedwindow.rb index 1e0430b606..37be77508f 100644 --- a/ext/tk/lib/tk/panedwindow.rb +++ b/ext/tk/lib/tk/panedwindow.rb @@ -88,9 +88,9 @@ class TkPanedWindow conf } + conf = tk_split_list(tk_send_without_enc('paneconfigure', + win, "-#{key}")) + key = conf.shift[1..-1] + { key => conf } else - ret = {} - tk_split_simplelist(tk_send_without_enc('paneconfigure', - win)).each{|conflist| - conf = tk_split_simplelist(conflist) - key = conf.shift[1..-1] - if key - if conf[2].index('{') - conf[2] = tk_split_list(conf[2]) - else - conf[2] = tk_tcl2ruby(conf[2]) - end - end - if conf[3] - if conf[3].index('{') - conf[3] = tk_split_list(conf[3]) - else - conf[3] = tk_tcl2ruby(conf[3]) - end - end - if conf.size == 1 - ret[key] = conf[0][1..-1] # alias info - else - ret[key] = conf - end - } - ret + ret = {} + tk_split_simplelist(tk_send_without_enc('paneconfigure', + win)).each{|conflist| + conf = tk_split_simplelist(conflist) + key = conf.shift[1..-1] + if key + if conf[2].index('{') + conf[2] = tk_split_list(conf[2]) + else + conf[2] = tk_tcl2ruby(conf[2]) + end + end + if conf[3] + if conf[3].index('{') + conf[3] = tk_split_list(conf[3]) + else + conf[3] = tk_tcl2ruby(conf[3]) + end + end + if conf.size == 1 + ret[key] = conf[0][1..-1] # alias info + else + ret[key] = conf + end + } + ret end end end @@ -177,19 +177,19 @@ class TkPanedWindow conf[4]} + conf = paneconfiginfo(win, key) + {conf[0] => conf[4]} else - ret = {} - paneconfiginfo(win).each{|conf| - ret[conf[0]] = conf[4] if conf.size > 2 - } - ret + ret = {} + paneconfiginfo(win).each{|conf| + ret[conf[0]] = conf[4] if conf.size > 2 + } + ret end else # ! TkComm::GET_CONFIGINFO_AS_ARRAY ret = {} paneconfiginfo(win, key).each{|k, conf| - ret[k] = conf[-1] if conf.kind_of?(Array) + ret[k] = conf[-1] if conf.kind_of?(Array) } ret end diff --git a/ext/tk/lib/tk/place.rb b/ext/tk/lib/tk/place.rb index ea70a6bea0..f7ebdfcbd6 100644 --- a/ext/tk/lib/tk/place.rb +++ b/ext/tk/lib/tk/place.rb @@ -16,9 +16,9 @@ module TkPlace if slot.kind_of? Hash params = [] slot.each{|k, v| - params.push("-#{k}") - # params.push((v.kind_of?(TkObject))? v.epath: v) - params.push(_epath(v)) + params.push("-#{k}") + # params.push((v.kind_of?(TkObject))? v.epath: v) + params.push(_epath(v)) } tk_call_without_enc('place', 'configure', win, *params) else @@ -35,24 +35,24 @@ module TkPlace # win = win.epath if win.kind_of?(TkObject) win = _epath(win) if slot - #conf = tk_split_list(tk_call_without_enc('place', 'configure', - # win, "-#{slot}") ) - conf = tk_split_simplelist(tk_call_without_enc('place', 'configure', - win, "-#{slot}") ) - conf[0] = conf[0][1..-1] - conf[1] = tk_tcl2ruby(conf[1]) - conf[2] = tk_tcl2ruby(conf[1]) - conf[3] = tk_tcl2ruby(conf[1]) - conf[4] = tk_tcl2ruby(conf[1]) - conf + #conf = tk_split_list(tk_call_without_enc('place', 'configure', + # win, "-#{slot}") ) + conf = tk_split_simplelist(tk_call_without_enc('place', 'configure', + win, "-#{slot}") ) + conf[0] = conf[0][1..-1] + conf[1] = tk_tcl2ruby(conf[1]) + conf[2] = tk_tcl2ruby(conf[1]) + conf[3] = tk_tcl2ruby(conf[1]) + conf[4] = tk_tcl2ruby(conf[1]) + conf else - tk_split_simplelist(tk_call_without_enc('place', 'configure', - win)).collect{|conflist| - #conf = list(conflist) - conf = simplelist(conflist).collect!{|inf| tk_tcl2ruby(inf)} - conf[0] = conf[0][1..-1] - conf - } + tk_split_simplelist(tk_call_without_enc('place', 'configure', + win)).collect{|conflist| + #conf = list(conflist) + conf = simplelist(conflist).collect!{|inf| tk_tcl2ruby(inf)} + conf[0] = conf[0][1..-1] + conf + } end else # ! TkComm::GET_CONFIGINFOwoRES_AS_ARRAY current_configinfo(win, slot) @@ -66,17 +66,17 @@ module TkPlace #conf = tk_split_list(tk_call_without_enc('place', 'configure', # win, "-#{slot}") ) conf = tk_split_simplelist(tk_call_without_enc('place', 'configure', - win, "-#{slot}") ) + win, "-#{slot}") ) # { conf[0][1..-1] => conf[1] } { conf[0][1..-1] => tk_tcl2ruby(conf[4]) } else ret = {} #tk_split_list(tk_call_without_enc('place','configure',win)).each{|conf| tk_split_simplelist(tk_call_without_enc('place', 'configure', - win)).each{|conf_list| - #ret[conf[0][1..-1]] = conf[1] - conf = simplelist(conf_list) - ret[conf[0][1..-1]] = tk_tcl2ruby(conf[4]) + win)).each{|conf_list| + #ret[conf[0][1..-1]] = conf[1] + conf = simplelist(conf_list) + ret[conf[0][1..-1]] = tk_tcl2ruby(conf[4]) } ret end diff --git a/ext/tk/lib/tk/root.rb b/ext/tk/lib/tk/root.rb index 6e16fb1989..24a5cf1ea0 100644 --- a/ext/tk/lib/tk/root.rb +++ b/ext/tk/lib/tk/root.rb @@ -19,11 +19,11 @@ class TkRoottrue, :widgetname=>'.') if keys # wm commands keys.each{|k,v| - if v.kind_of? Array - new.send(k,*v) - else - new.send(k,v) - end + if v.kind_of? Array + new.send(k,*v) + else + new.send(k,v) + end } end ROOT[0] = new @@ -33,16 +33,16 @@ class TkRoottrue, :widgetname=>'.'){} + super(:without_creating=>true, :widgetname=>'.'){} end root = TkCore::INTERP.tk_windows['.'] if keys # wm commands keys.each{|k,v| - if v.kind_of? Array - root.__send__(k,*v) - else - root.__send__(k,v) - end + if v.kind_of? Array + root.__send__(k,*v) + else + root.__send__(k,v) + end } end root.instance_eval(&b) if block_given? diff --git a/ext/tk/lib/tk/scale.rb b/ext/tk/lib/tk/scale.rb index 135a0cf62d..7214c46f5e 100644 --- a/ext/tk/lib/tk/scale.rb +++ b/ext/tk/lib/tk/scale.rb @@ -11,12 +11,12 @@ class TkScalevalue) elsif slot.kind_of?(Hash) && - (slot.key?('command') || slot.key?(:command)) + (slot.key?('command') || slot.key?(:command)) slot = _symbolkey2str(slot) slot['command'] = _wrap_command_arg(slot.delete('command')) end diff --git a/ext/tk/lib/tk/scrollable.rb b/ext/tk/lib/tk/scrollable.rb index 6e10ef51a2..74816a9228 100644 --- a/ext/tk/lib/tk/scrollable.rb +++ b/ext/tk/lib/tk/scrollable.rb @@ -18,10 +18,10 @@ module Tk def xview(*index) if index.size == 0 - list(tk_send_without_enc('xview')) + list(tk_send_without_enc('xview')) else - tk_send_without_enc('xview', *index) - self + tk_send_without_enc('xview', *index) + self end end def xview_moveto(*index) @@ -33,10 +33,10 @@ module Tk def yview(*index) if index.size == 0 - list(tk_send_without_enc('yview')) + list(tk_send_without_enc('yview')) else - tk_send_without_enc('yview', *index) - self + tk_send_without_enc('yview', *index) + self end end def yview_moveto(*index) @@ -48,21 +48,21 @@ module Tk def xscrollbar(bar=nil) if bar - @xscrollbar = bar - @xscrollbar.orient 'horizontal' - self.xscrollcommand {|*arg| @xscrollbar.set(*arg)} - @xscrollbar.command {|*arg| self.xview(*arg)} - Tk.update # avoid scrollbar trouble + @xscrollbar = bar + @xscrollbar.orient 'horizontal' + self.xscrollcommand {|*arg| @xscrollbar.set(*arg)} + @xscrollbar.command {|*arg| self.xview(*arg)} + Tk.update # avoid scrollbar trouble end @xscrollbar end def yscrollbar(bar=nil) if bar - @yscrollbar = bar - @yscrollbar.orient 'vertical' - self.yscrollcommand {|*arg| @yscrollbar.set(*arg)} - @yscrollbar.command {|*arg| self.yview(*arg)} - Tk.update # avoid scrollbar trouble + @yscrollbar = bar + @yscrollbar.orient 'vertical' + self.yscrollcommand {|*arg| @yscrollbar.set(*arg)} + @yscrollbar.command {|*arg| self.yview(*arg)} + Tk.update # avoid scrollbar trouble end @yscrollbar end diff --git a/ext/tk/lib/tk/scrollbar.rb b/ext/tk/lib/tk/scrollbar.rb index c6591a1270..70aadfdd4c 100644 --- a/ext/tk/lib/tk/scrollbar.rb +++ b/ext/tk/lib/tk/scrollbar.rb @@ -12,16 +12,16 @@ class TkScrollbar +# $Date$ +# by Yukihiro Matsumoto # require 'tk' require 'tk/listbox' diff --git a/ext/tk/lib/tk/selection.rb b/ext/tk/lib/tk/selection.rb index 970c3faa80..5caa6ef8ef 100644 --- a/ext/tk/lib/tk/selection.rb +++ b/ext/tk/lib/tk/selection.rb @@ -19,7 +19,7 @@ module TkSelection def self.clear_on_display(win, sel=nil) if sel tk_call_without_enc('selection', 'clear', - '-displayof', win, '-selection', sel) + '-displayof', win, '-selection', sel) else tk_call_without_enc('selection', 'clear', '-displayof', win) end @@ -36,7 +36,7 @@ module TkSelection def self.get_on_display(win, keys=nil) #tk_call('selection', 'get', '-displayof', win, *hash_kv(keys)) _fromUTF8(tk_call_without_enc('selection', 'get', '-displayof', - win, *hash_kv(keys))) + win, *hash_kv(keys))) end def get(keys=nil) TkSelection.get_on_display(self, sel) @@ -66,7 +66,7 @@ module TkSelection def self.get_owner_on_display(win, sel=nil) if sel window(tk_call_without_enc('selection', 'own', - '-displayof', win, '-selection', sel)) + '-displayof', win, '-selection', sel)) else window(tk_call_without_enc('selection', 'own', '-displayof', win)) end diff --git a/ext/tk/lib/tk/spinbox.rb b/ext/tk/lib/tk/spinbox.rb index 06abb5fb3c..f4febb05b1 100644 --- a/ext/tk/lib/tk/spinbox.rb +++ b/ext/tk/lib/tk/spinbox.rb @@ -1,7 +1,7 @@ # -# tk/spinbox.rb - Tk spinbox classes -# $Date$ -# by Yukihiro Matsumoto +# tk/spinbox.rb - Tk spinbox classes +# $Date$ +# by Yukihiro Matsumoto # require 'tk' require 'tk/entry' diff --git a/ext/tk/lib/tk/text.rb b/ext/tk/lib/tk/text.rb index 123f49af03..a0af642376 100644 --- a/ext/tk/lib/tk/text.rb +++ b/ext/tk/lib/tk/text.rb @@ -1,7 +1,7 @@ # -# tk/text.rb - Tk text classes -# $Date$ -# by Yukihiro Matsumoto +# tk/text.rb - Tk text classes +# $Date$ +# by Yukihiro Matsumoto require 'tk' require 'tk/itemfont' require 'tk/itemconfig' @@ -91,7 +91,7 @@ class TkText conf } + case slot.to_s + when 'text', 'label', 'show', 'data', 'file' + conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index), "-#{slot}"))) + else + conf = tk_split_list(_fromUTF8(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index), "-#{slot}"))) + end + key = conf.shift[1..-1] + { key => conf } else - ret = {} - tk_split_simplelist(_fromUTF8(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index)))).each{|conflist| - conf = tk_split_simplelist(conflist) - key = conf.shift[1..-1] - case key - when 'text', 'label', 'show', 'data', 'file' - else - if conf[2] - if conf[2].index('{') - conf[2] = tk_split_list(conf[2]) - else - conf[2] = tk_tcl2ruby(conf[2]) - end - end - if conf[3] - if conf[3].index('{') - conf[3] = tk_split_list(conf[3]) - else - conf[3] = tk_tcl2ruby(conf[3]) - end - end - end - if conf.size == 1 - ret[key] = conf[0][1..-1] # alias info - else - ret[key] = conf - end - } - ret + ret = {} + tk_split_simplelist(_fromUTF8(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index)))).each{|conflist| + conf = tk_split_simplelist(conflist) + key = conf.shift[1..-1] + case key + when 'text', 'label', 'show', 'data', 'file' + else + if conf[2] + if conf[2].index('{') + conf[2] = tk_split_list(conf[2]) + else + conf[2] = tk_tcl2ruby(conf[2]) + end + end + if conf[3] + if conf[3].index('{') + conf[3] = tk_split_list(conf[3]) + else + conf[3] = tk_tcl2ruby(conf[3]) + end + end + end + if conf.size == 1 + ret[key] = conf[0][1..-1] # alias info + else + ret[key] = conf + end + } + ret end end end @@ -312,19 +312,19 @@ class TkText conf[4]} + conf = image_configinfo(index, slot) + {conf[0] => conf[4]} else - ret = {} - image_configinfo(index).each{|conf| - ret[conf[0]] = conf[4] if conf.size > 2 - } - ret + ret = {} + image_configinfo(index).each{|conf| + ret[conf[0]] = conf[4] if conf.size > 2 + } + ret end else # ! TkComm::GET_CONFIGINFO_AS_ARRAY ret = {} image_configinfo(index, slot).each{|k, conf| - ret[k] = conf[-1] if conf.kind_of?(Array) + ret[k] = conf[-1] if conf.kind_of?(Array) } ret end @@ -351,16 +351,16 @@ class TkText 0 - args << tags.shift.collect{|x|_get_eval_string(x)}.join(' ') # taglist - args << tags.shift if tags.size > 0 # chars + args << tags.shift.collect{|x|_get_eval_string(x)}.join(' ') # taglist + args << tags.shift if tags.size > 0 # chars end super index, *args else # single chars-taglist argument :: str, tag, tag, ... if tags.size == 0 - super index, chars + super index, chars else - super index, chars, tags.collect{|x|_get_eval_string(x)}.join(' ') + super index, chars, tags.collect{|x|_get_eval_string(x)}.join(' ') end end end @@ -383,7 +383,7 @@ class TkTextval}) - end + if val == None + tagfontobj(tag) + else + tagfont_configure(tag, {key=>val}) + end else - tk_send_without_enc('tag', 'configure', _get_eval_enc_str(tag), - "-#{key}", _get_eval_enc_str(val)) + tk_send_without_enc('tag', 'configure', _get_eval_enc_str(tag), + "-#{key}", _get_eval_enc_str(val)) end end self @@ -593,101 +593,101 @@ class TkText conf } + case key.to_s + when 'text', 'label', 'show', 'data', 'file' + conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('tag','configure',_get_eval_enc_str(tag),"-#{key}"))) + when 'font', 'kanjifont' + conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('tag','configure',_get_eval_enc_str(tag),"-#{key}"))) + conf[4] = tagfont_configinfo(tag, conf[4]) + else + conf = tk_split_list(_fromUTF8(tk_send_without_enc('tag','configure',_get_eval_enc_str(tag),"-#{key}"))) + end + key = conf.shift[1..-1] + { key => conf } else - ret = {} - tk_split_simplelist(_fromUTF8(tk_send('tag','configure',_get_eval_enc_str(tag)))).each{|conflist| - conf = tk_split_simplelist(conflist) - key = conf.shift[1..-1] - case key - when 'text', 'label', 'show', 'data', 'file' - else - if conf[2] - if conf[2].index('{') - conf[2] = tk_split_list(conf[2]) - else - conf[2] = tk_tcl2ruby(conf[2]) - end - end - if conf[3] - if conf[3].index('{') - conf[3] = tk_split_list(conf[3]) - else - conf[3] = tk_tcl2ruby(conf[3]) - end - end - end - if conf.size == 1 - ret[key] = conf[0][1..-1] # alias info - else - ret[key] = conf - end - } - fontconf = ret['font'] - if fontconf - ret.delete('font') - ret.delete('kanjifont') - fontconf[3] = tagfont_configinfo(tag, fontconf[3]) - ret['font'] = fontconf - end - ret + ret = {} + tk_split_simplelist(_fromUTF8(tk_send('tag','configure',_get_eval_enc_str(tag)))).each{|conflist| + conf = tk_split_simplelist(conflist) + key = conf.shift[1..-1] + case key + when 'text', 'label', 'show', 'data', 'file' + else + if conf[2] + if conf[2].index('{') + conf[2] = tk_split_list(conf[2]) + else + conf[2] = tk_tcl2ruby(conf[2]) + end + end + if conf[3] + if conf[3].index('{') + conf[3] = tk_split_list(conf[3]) + else + conf[3] = tk_tcl2ruby(conf[3]) + end + end + end + if conf.size == 1 + ret[key] = conf[0][1..-1] # alias info + else + ret[key] = conf + end + } + fontconf = ret['font'] + if fontconf + ret.delete('font') + ret.delete('kanjifont') + fontconf[3] = tagfont_configinfo(tag, fontconf[3]) + ret['font'] = fontconf + end + ret end end end @@ -695,19 +695,19 @@ class TkText conf[4]} + conf = tag_configinfo(tag, key) + {conf[0] => conf[4]} else - ret = {} - tag_configinfo(tag).each{|conf| - ret[conf[0]] = conf[4] if conf.size > 2 - } - ret + ret = {} + tag_configinfo(tag).each{|conf| + ret[conf[0]] = conf[4] if conf.size > 2 + } + ret end else # ! TkComm::GET_CONFIGINFO_AS_ARRAY ret = {} tag_configinfo(tag, key).each{|k, conf| - ret[k] = conf[-1] if conf.kind_of?(Array) + ret[k] = conf[-1] if conf.kind_of?(Array) } ret end @@ -716,25 +716,25 @@ class TkText conf } + case slot.to_s + when 'text', 'label', 'show', 'data', 'file' + conf = tk_split_simplelist(_fromUTF8(tk_send('window', 'configure', _get_eval_enc_str(win), "-#{slot}"))) + else + conf = tk_split_list(_fromUTF8(tk_send('window', 'configure', _get_eval_enc_str(win), "-#{slot}"))) + end + key = conf.shift[1..-1] + { key => conf } else - ret = {} - tk_split_simplelist(_fromUTF8(tk_send('window', 'configure', _get_eval_enc_str(win)))).each{|conflist| - conf = tk_split_simplelist(conflist) - key = conf.shift[1..-1] - case key - when 'text', 'label', 'show', 'data', 'file' - else - if conf[2] - if conf[2].index('{') - conf[2] = tk_split_list(conf[2]) - else - conf[2] = tk_tcl2ruby(conf[2]) - end - end - if conf[3] - if conf[3].index('{') - conf[3] = tk_split_list(conf[3]) - else - conf[3] = tk_tcl2ruby(conf[3]) - end - end - end - if conf.size == 1 - ret[key] = conf[0][1..-1] # alias info - else - ret[key] = conf - end - } - ret + ret = {} + tk_split_simplelist(_fromUTF8(tk_send('window', 'configure', _get_eval_enc_str(win)))).each{|conflist| + conf = tk_split_simplelist(conflist) + key = conf.shift[1..-1] + case key + when 'text', 'label', 'show', 'data', 'file' + else + if conf[2] + if conf[2].index('{') + conf[2] = tk_split_list(conf[2]) + else + conf[2] = tk_tcl2ruby(conf[2]) + end + end + if conf[3] + if conf[3].index('{') + conf[3] = tk_split_list(conf[3]) + else + conf[3] = tk_tcl2ruby(conf[3]) + end + end + end + if conf.size == 1 + ret[key] = conf[0][1..-1] # alias info + else + ret[key] = conf + end + } + ret end end end @@ -921,19 +921,19 @@ class TkText conf[4]} + conf = window_configinfo(win, slot) + {conf[0] => conf[4]} else - ret = {} - window_configinfo(win).each{|conf| - ret[conf[0]] = conf[4] if conf.size > 2 - } - ret + ret = {} + window_configinfo(win).each{|conf| + ret[conf[0]] = conf[4] if conf.size > 2 + } + ret end else # ! TkComm::GET_CONFIGINFO_AS_ARRAY ret = {} window_configinfo(win, slot).each{|k, conf| - ret[k] = conf[-1] if conf.kind_of?(Array) + ret[k] = conf[-1] if conf.kind_of?(Array) } ret end @@ -954,14 +954,14 @@ class TkText=',stop) txt = get(start,stop) if (pos = txt.index(pat)) - match = $& - #pos = txt[0..(pos-1)].split('').length if pos > 0 - pos = _ktext_length(txt[0..(pos-1)]) if pos > 0 - if pat.kind_of? String - #return [index(start + " + #{pos} chars"), pat.split('').length] - return [index(start + " + #{pos} chars"), - _ktext_length(pat), pat.dup] - else - #return [index(start + " + #{pos} chars"), $&.split('').length] - return [index(start + " + #{pos} chars"), - _ktext_length(match), match] - end + match = $& + #pos = txt[0..(pos-1)].split('').length if pos > 0 + pos = _ktext_length(txt[0..(pos-1)]) if pos > 0 + if pat.kind_of? String + #return [index(start + " + #{pos} chars"), pat.split('').length] + return [index(start + " + #{pos} chars"), + _ktext_length(pat), pat.dup] + else + #return [index(start + " + #{pos} chars"), $&.split('').length] + return [index(start + " + #{pos} chars"), + _ktext_length(match), match] + end else - return ["", 0] + return ["", 0] end else txt = get(start,'end - 1 char') if (pos = txt.index(pat)) - match = $& - #pos = txt[0..(pos-1)].split('').length if pos > 0 - pos = _ktext_length(txt[0..(pos-1)]) if pos > 0 - if pat.kind_of? String - #return [index(start + " + #{pos} chars"), pat.split('').length] - return [index(start + " + #{pos} chars"), - _ktext_length(pat), pat.dup] - else - #return [index(start + " + #{pos} chars"), $&.split('').length] - return [index(start + " + #{pos} chars"), - _ktext_length(match), match] - end + match = $& + #pos = txt[0..(pos-1)].split('').length if pos > 0 + pos = _ktext_length(txt[0..(pos-1)]) if pos > 0 + if pat.kind_of? String + #return [index(start + " + #{pos} chars"), pat.split('').length] + return [index(start + " + #{pos} chars"), + _ktext_length(pat), pat.dup] + else + #return [index(start + " + #{pos} chars"), $&.split('').length] + return [index(start + " + #{pos} chars"), + _ktext_length(match), match] + end else - txt = get('1.0','end - 1 char') - if (pos = txt.index(pat)) - match = $& - #pos = txt[0..(pos-1)].split('').length if pos > 0 - pos = _ktext_length(txt[0..(pos-1)]) if pos > 0 - if pat.kind_of? String - #return [index("1.0 + #{pos} chars"), pat.split('').length] - return [index("1.0 + #{pos} chars"), - _ktext_length(pat), pat.dup] - else - #return [index("1.0 + #{pos} chars"), $&.split('').length] - return [index("1.0 + #{pos} chars"), _ktext_length(match), match] - end - else - return ["", 0] - end + txt = get('1.0','end - 1 char') + if (pos = txt.index(pat)) + match = $& + #pos = txt[0..(pos-1)].split('').length if pos > 0 + pos = _ktext_length(txt[0..(pos-1)]) if pos > 0 + if pat.kind_of? String + #return [index("1.0 + #{pos} chars"), pat.split('').length] + return [index("1.0 + #{pos} chars"), + _ktext_length(pat), pat.dup] + else + #return [index("1.0 + #{pos} chars"), $&.split('').length] + return [index("1.0 + #{pos} chars"), _ktext_length(match), match] + end + else + return ["", 0] + end end end end @@ -1102,48 +1102,48 @@ class TkText 0 - pos = _ktext_length(txt[0..(pos-1)]) if pos > 0 - if pat.kind_of? String - #return [index(stop + " + #{pos} chars"), pat.split('').length] - return [index(stop + " + #{pos} chars"), _ktext_length(pat), pat.dup] - else - #return [index(stop + " + #{pos} chars"), $&.split('').length] - return [index(stop + " + #{pos} chars"), _ktext_length(match), match] - end + match = $& + #pos = txt[0..(pos-1)].split('').length if pos > 0 + pos = _ktext_length(txt[0..(pos-1)]) if pos > 0 + if pat.kind_of? String + #return [index(stop + " + #{pos} chars"), pat.split('').length] + return [index(stop + " + #{pos} chars"), _ktext_length(pat), pat.dup] + else + #return [index(stop + " + #{pos} chars"), $&.split('').length] + return [index(stop + " + #{pos} chars"), _ktext_length(match), match] + end else - return ["", 0] + return ["", 0] end else txt = get('1.0',start) if (pos = txt.rindex(pat)) - match = $& - #pos = txt[0..(pos-1)].split('').length if pos > 0 - pos = _ktext_length(txt[0..(pos-1)]) if pos > 0 - if pat.kind_of? String - #return [index("1.0 + #{pos} chars"), pat.split('').length] - return [index("1.0 + #{pos} chars"), _ktext_length(pat), pat.dup] - else - #return [index("1.0 + #{pos} chars"), $&.split('').length] - return [index("1.0 + #{pos} chars"), _ktext_length(match), match] - end + match = $& + #pos = txt[0..(pos-1)].split('').length if pos > 0 + pos = _ktext_length(txt[0..(pos-1)]) if pos > 0 + if pat.kind_of? String + #return [index("1.0 + #{pos} chars"), pat.split('').length] + return [index("1.0 + #{pos} chars"), _ktext_length(pat), pat.dup] + else + #return [index("1.0 + #{pos} chars"), $&.split('').length] + return [index("1.0 + #{pos} chars"), _ktext_length(match), match] + end else - txt = get('1.0','end - 1 char') - if (pos = txt.rindex(pat)) - match = $& - #pos = txt[0..(pos-1)].split('').length if pos > 0 - pos = _ktext_length(txt[0..(pos-1)]) if pos > 0 - if pat.kind_of? String - #return [index("1.0 + #{pos} chars"), pat.split('').length] - return [index("1.0 + #{pos} chars"), _ktext_length(pat), pat.dup] - else - #return [index("1.0 + #{pos} chars"), $&.split('').length] - return [index("1.0 + #{pos} chars"), _ktext_length(match), match] - end - else - return ["", 0] - end + txt = get('1.0','end - 1 char') + if (pos = txt.rindex(pat)) + match = $& + #pos = txt[0..(pos-1)].split('').length if pos > 0 + pos = _ktext_length(txt[0..(pos-1)]) if pos > 0 + if pat.kind_of? String + #return [index("1.0 + #{pos} chars"), pat.split('').length] + return [index("1.0 + #{pos} chars"), _ktext_length(pat), pat.dup] + else + #return [index("1.0 + #{pos} chars"), $&.split('').length] + return [index("1.0 + #{pos} chars"), _ktext_length(match), match] + end + else + return ["", 0] + end end end end @@ -1168,56 +1168,56 @@ class TkText 0 - tk_call_without_enc(@t.path, 'window', 'configure', @index, - *hash_kv(slot, true)) + tk_call_without_enc(@t.path, 'window', 'configure', @index, + *hash_kv(slot, true)) end else if slot == 'window' || slot == :window - @id = value - # value = @id.epath if @id.kind_of?(TkWindow) - value = _epath(@id) if @id + @id = value + # value = @id.epath if @id.kind_of?(TkWindow) + value = _epath(@id) if @id end if slot == 'create' || slot == :create - self.create=value + self.create=value else - tk_call_without_enc(@t.path, 'window', 'configure', @index, - "-#{slot}", _get_eval_enc_str(value)) + tk_call_without_enc(@t.path, 'window', 'configure', @index, + "-#{slot}", _get_eval_enc_str(value)) end end self @@ -110,7 +110,7 @@ class TkTextWindow e if @cancel_on_exception && - @cancel_on_exception.find{|exc| e.kind_of?(exc)} - cancel - @return_value = e - @in_callback = false - return e + @cancel_on_exception.find{|exc| e.kind_of?(exc)} + cancel + @return_value = e + @in_callback = false + return e else - fail e + fail e end end if @set_next @@ -106,12 +106,12 @@ class TkTimer end if @current_pos >= @proc_max if @do_loop < 0 || (@do_loop -= 1) > 0 - @current_pos = 0 + @current_pos = 0 else - Tk_CBTBL.delete(@id) ;# for GC - @running = false - @wait_var.value = 0 - return + Tk_CBTBL.delete(@id) ;# for GC + @running = false + @wait_var.value = 0 + return end end @@ -237,9 +237,9 @@ class TkTimer @loop_proc = [] procs.each{|e| if e.kind_of? Proc - @loop_proc.push([e]) + @loop_proc.push([e]) else - @loop_proc.push(e) + @loop_proc.push(e) end } @proc_max = @loop_proc.size @@ -248,14 +248,14 @@ class TkTimer @do_loop = 0 if loop_exec if loop_exec.kind_of?(Integer) && loop_exec < 0 - @loop_exec = -1 + @loop_exec = -1 elsif loop_exec == nil || loop_exec == false || loop_exec == 0 - @loop_exec = 1 + @loop_exec = 1 else - if not loop_exec.kind_of?(Integer) - fail ArguemntError, "expect Integer for 2nd argument" - end - @loop_exec = loop_exec + if not loop_exec.kind_of?(Integer) + fail ArguemntError, "expect Integer for 2nd argument" + end + @loop_exec = loop_exec end @do_loop = @loop_exec end @@ -266,9 +266,9 @@ class TkTimer def add_procs(*procs) procs.each{|e| if e.kind_of? Proc - @loop_proc.push([e]) + @loop_proc.push([e]) else - @loop_proc.push(e) + @loop_proc.push(e) end } @proc_max = @loop_proc.size @@ -279,9 +279,9 @@ class TkTimer def delete_procs(*procs) procs.each{|e| if e.kind_of? Proc - @loop_proc.delete([e]) + @loop_proc.delete([e]) else - @loop_proc.delete(e) + @loop_proc.delete(e) end } @proc_max = @loop_proc.size @@ -327,7 +327,7 @@ class TkTimer if argc > 0 sleep = init_args.shift if !sleep == 'idle' && !sleep.kind_of?(Integer) - fail ArguemntError, "expect Integer or 'idle' for 1st argument" + fail ArguemntError, "expect Integer or 'idle' for 1st argument" end @init_sleep = sleep end @@ -340,7 +340,7 @@ class TkTimer @running = true if @init_proc if not @init_proc.kind_of? Proc - fail ArgumentError, "Argument '#{@init_proc}' need to be Proc" + fail ArgumentError, "Argument '#{@init_proc}' need to be Proc" end @current_proc = @init_proc set_callback(@init_sleep, @init_args) @@ -393,7 +393,7 @@ class TkTimer fail RuntimeError, "no procedure to continue" unless cmd if wait unless wait.kind_of? Integer - fail ArguemntError, "expect Integer for 1st argument" + fail ArguemntError, "expect Integer for 1st argument" end sleep = wait end @@ -428,9 +428,9 @@ class TkTimer unless @running if @return_value.kind_of?(Exception) - fail @return_value + fail @return_value else - return @return_value + return @return_value end end diff --git a/ext/tk/lib/tk/toplevel.rb b/ext/tk/lib/tk/toplevel.rb index 1984952248..b96e184aab 100644 --- a/ext/tk/lib/tk/toplevel.rb +++ b/ext/tk/lib/tk/toplevel.rb @@ -51,19 +51,19 @@ class TkToplevelvalue)) + super(__conv_vcmd_on_hash_kv(slot=>value)) end self end @@ -76,28 +76,28 @@ module Tk key2class = __get_validate_key2class if slot.kind_of?(Hash) - slot = _symbolkey2str(slot) - key2class.each{|key, klass| - if slot[key].kind_of?(Array) - cmd, *args = slot[key] - slot[key] = klass.new(cmd, args.join(' ')) - elsif slot[key].kind_of?(Proc) || slot[key].kind_of?(Method) - slot[key] = klass.new(slot[key]) - end - } - super(slot) + slot = _symbolkey2str(slot) + key2class.each{|key, klass| + if slot[key].kind_of?(Array) + cmd, *args = slot[key] + slot[key] = klass.new(cmd, args.join(' ')) + elsif slot[key].kind_of?(Proc) || slot[key].kind_of?(Method) + slot[key] = klass.new(slot[key]) + end + } + super(slot) else - slot = slot.to_s - if (klass = key2class[slot]) - if value.kind_of?(Array) - cmd, *args = value - value = klass.new(cmd, args.join(' ')) - elsif value.kind_of?(Proc) || value.kind_of?(Method) - value = klass.new(value) - end - end - super(slot, value) + slot = slot.to_s + if (klass = key2class[slot]) + if value.kind_of?(Array) + cmd, *args = value + value = klass.new(cmd, args.join(' ')) + elsif value.kind_of?(Proc) || value.kind_of?(Method) + value = klass.new(value) + end + end + super(slot, value) end self @@ -109,7 +109,7 @@ module Tk def self.__def_validcmd(scope, klass, keys=nil) keys = klass._config_keys unless keys keys.each{|key| - eval("def item_#{key}(id, *args, &b) + eval("def item_#{key}(id, *args, &b) __item_validcmd_call(#{klass.name}, '#{key}', id, *args, &b) end", scope) } @@ -121,11 +121,11 @@ module Tk cmd = (b)? proc(&b) : args.shift if cmd.kind_of?(klass) - itemconfigure(tagid(tagOrId), key, cmd) + itemconfigure(tagid(tagOrId), key, cmd) elsif !args.empty? - itemconfigure(tagid(tagOrId), key, [cmd, args]) + itemconfigure(tagid(tagOrId), key, [cmd, args]) else - itemconfigure(tagid(tagOrId), key, cmd) + itemconfigure(tagid(tagOrId), key, cmd) end end @@ -137,9 +137,9 @@ module Tk def __get_item_validate_key2class(id) k2c = {} __item_validation_class_list(id).each{|klass| - klass._config_keys.each{|key| - k2c[key.to_s] = klass - } + klass._config_keys.each{|key| + k2c[key.to_s] = klass + } } end @@ -148,21 +148,21 @@ module Tk keys = _symbolkey2str(keys) key2class.each{|key, klass| - if keys[key].kind_of?(Array) - cmd, *args = keys[key] - keys[key] = klass.new(cmd, args.join(' ')) - elsif keys[key].kind_of?(Proc) || keys[key].kind_of?(Method) - keys[key] = klass.new(keys[key]) - end + if keys[key].kind_of?(Array) + cmd, *args = keys[key] + keys[key] = klass.new(cmd, args.join(' ')) + elsif keys[key].kind_of?(Proc) || keys[key].kind_of?(Method) + keys[key] = klass.new(keys[key]) + end } keys end def itemconfigure(tagOrId, slot, value=TkComm::None) if slot.kind_of?(Hash) - super(__conv_item_vcmd_on_hash_kv(slot)) + super(__conv_item_vcmd_on_hash_kv(slot)) else - super(__conv_item_vcmd_on_hash_kv(slot=>value)) + super(__conv_item_vcmd_on_hash_kv(slot=>value)) end self end @@ -171,28 +171,28 @@ module Tk key2class = __get_item_validate_key2class(tagid(tagOrId)) if slot.kind_of?(Hash) - slot = _symbolkey2str(slot) - key2class.each{|key, klass| - if slot[key].kind_of?(Array) - cmd, *args = slot[key] - slot[key] = klass.new(cmd, args.join(' ')) - elsif slot[key].kind_of?(Proc) || slot[key].kind_of?(Method) - slot[key] = klass.new(slot[key]) - end - } - super(slot) + slot = _symbolkey2str(slot) + key2class.each{|key, klass| + if slot[key].kind_of?(Array) + cmd, *args = slot[key] + slot[key] = klass.new(cmd, args.join(' ')) + elsif slot[key].kind_of?(Proc) || slot[key].kind_of?(Method) + slot[key] = klass.new(slot[key]) + end + } + super(slot) else - slot = slot.to_s - if (klass = key2class[slot]) - if value.kind_of?(Array) - cmd, *args = value - value = klass.new(cmd, args.join(' ')) - elsif value.kind_of?(Proc) || value.kind_of?(Method) - value = klass.new(value) - end - end - super(slot, value) + slot = slot.to_s + if (klass = key2class[slot]) + if value.kind_of?(Array) + cmd, *args = value + value = klass.new(cmd, args.join(' ')) + elsif value.kind_of?(Proc) || value.kind_of?(Method) + value = klass.new(value) + end + end + super(slot, value) end self @@ -224,23 +224,23 @@ class TkValidateCommand [ ?w, TkComm.method(:window) ], [ ?e, proc{|val| - enc = Tk.encoding - if enc - Tk.fromUTF8(TkComm::string(val), enc) - else - TkComm::string(val) - end - } + enc = Tk.encoding + if enc + Tk.fromUTF8(TkComm::string(val), enc) + else + TkComm::string(val) + end + } ], [ ?x, proc{|val| - idx = TkComm::number(val) - if idx < 0 - nil - else - idx - end - } + idx = TkComm::number(val) + if idx < 0 + nil + else + idx + end + } ], nil @@ -277,32 +277,32 @@ class TkValidateCommand args = args.join(' ') keys = klass._get_subst_key(args) if cmd.kind_of?(String) - id = cmd + id = cmd elsif cmd.kind_of?(TkCallbackEntry) - @id = install_cmd(cmd) + @id = install_cmd(cmd) else - @id = install_cmd(proc{|*arg| - ex_args = [] - extra_args_tbl.reverse_each{|conv| ex_args << conv.call(arg.pop)} - klass.ret_val(cmd.call( + @id = install_cmd(proc{|*arg| + ex_args = [] + extra_args_tbl.reverse_each{|conv| ex_args << conv.call(arg.pop)} + klass.ret_val(cmd.call( *(ex_args.concat(klass.scan_args(keys, arg))) )) - }) + ' ' + args + }) + ' ' + args end else keys, args = klass._get_all_subst_keys if cmd.kind_of?(String) - id = cmd + id = cmd elsif cmd.kind_of?(TkCallbackEntry) - @id = install_cmd(cmd) + @id = install_cmd(cmd) else - @id = install_cmd(proc{|*arg| - ex_args = [] - extra_args_tbl.reverse_each{|conv| ex_args << conv.call(arg.pop)} - klass.ret_val(cmd.call( + @id = install_cmd(proc{|*arg| + ex_args = [] + extra_args_tbl.reverse_each{|conv| ex_args << conv.call(arg.pop)} + klass.ret_val(cmd.call( *(ex_args << klass.new(*klass.scan_args(keys, arg))) - )) - }) + ' ' + args + )) + }) + ' ' + args end end end diff --git a/ext/tk/lib/tk/variable.rb b/ext/tk/lib/tk/variable.rb index 97d18e4a50..d5882fd649 100644 --- a/ext/tk/lib/tk/variable.rb +++ b/ext/tk/lib/tk/variable.rb @@ -19,24 +19,24 @@ class TkVariable Tk_VARIABLE_ID = ["v".freeze, "00000".taint].freeze #TkCore::INTERP.add_tk_procs('rb_var', 'args', - # "ruby [format \"TkVariable.callback %%Q!%s!\" $args]") + # "ruby [format \"TkVariable.callback %%Q!%s!\" $args]") TkCore::INTERP.add_tk_procs('rb_var', 'args', <<-'EOL') if {[set st [catch {eval {ruby_cmd TkVariable callback} $args} ret]] != 0} { set idx [string first "\n\n" $ret] if {$idx > 0} { - global errorInfo - set tcl_backtrace $errorInfo - set errorInfo [string range $ret [expr $idx + 2] \ + global errorInfo + set tcl_backtrace $errorInfo + set errorInfo [string range $ret [expr $idx + 2] \ [string length $ret]] append errorInfo "\n" $tcl_backtrace - bgerror [string range $ret 0 [expr $idx - 1]] + bgerror [string range $ret 0 [expr $idx - 1]] } else { bgerror $ret } return "" #return -code $st $ret } else { - return $ret + return $ret } EOL @@ -47,40 +47,40 @@ TkCore::INTERP.add_tk_procs('rb_var', 'args', <<-'EOL') if TkVar_CB_TBL[name1] #_get_eval_string(TkVar_CB_TBL[name1].trace_callback(name2,op)) begin - _get_eval_string(TkVar_CB_TBL[name1].trace_callback(name2, op)) + _get_eval_string(TkVar_CB_TBL[name1].trace_callback(name2, op)) rescue SystemExit - exit(0) + exit(0) rescue Interrupt - exit!(1) + exit!(1) rescue Exception => e - begin - 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 >-------" - msg.instance_variable_set(:@encoding, 'utf-8') - rescue Exception - msg = e.class.inspect + ': ' + e.message + "\n" + - "\n---< backtrace of Ruby side >-----\n" + - e.backtrace.join("\n") + - "\n---< backtrace of Tk side >-------" - end - fail(e, msg) + begin + 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 >-------" + msg.instance_variable_set(:@encoding, 'utf-8') + rescue Exception + msg = e.class.inspect + ': ' + e.message + "\n" + + "\n---< backtrace of Ruby side >-----\n" + + e.backtrace.join("\n") + + "\n---< backtrace of Tk side >-------" + end + fail(e, msg) end =begin begin - raise 'check backtrace' + raise 'check backtrace' rescue - # ignore backtrace before 'callback' - pos = -($!.backtrace.size) + # ignore backtrace before 'callback' + pos = -($!.backtrace.size) end begin - _get_eval_string(TkVar_CB_TBL[name1].trace_callback(name2,op)) + _get_eval_string(TkVar_CB_TBL[name1].trace_callback(name2,op)) rescue - trace = $!.backtrace - raise $!, "\n#{trace[0]}: #{$!.message} (#{$!.class})\n" + - "\tfrom #{trace[1..pos].join("\n\tfrom ")}" + trace = $!.backtrace + raise $!, "\n#{trace[0]}: #{$!.message} (#{$!.class})\n" + + "\tfrom #{trace[1..pos].join("\n\tfrom ")}" end =end else @@ -159,7 +159,7 @@ TkCore::INTERP.add_tk_procs('rb_var', 'args', <<-'EOL') =begin if val == [] # INTERP._eval(format('global %s; set %s(0) 0; unset %s(0)', - # @id, @id, @id)) + # @id, @id, @id)) elsif val.kind_of?(Array) a = [] # val.each_with_index{|e,i| a.push(i); a.push(array2tk_list(e))} @@ -202,15 +202,15 @@ TkCore::INTERP.add_tk_procs('rb_var', 'args', <<-'EOL') on_thread &= (Thread.list.size != 1) if on_thread if check_root - INTERP._thread_tkwait('variable', @id) + INTERP._thread_tkwait('variable', @id) else - INTERP._thread_vwait(@id) + INTERP._thread_vwait(@id) end else if check_root - INTERP._invoke_without_enc('tkwait', 'variable', @id) + INTERP._invoke_without_enc('tkwait', 'variable', @id) else - INTERP._invoke_without_enc('vwait', @id) + INTERP._invoke_without_enc('vwait', @id) end end end @@ -299,21 +299,21 @@ if USE_TCLs_SET_VARIABLE_FUNCTIONS if val.kind_of?(Hash) self.clear val.each{|k, v| - #INTERP._set_global_var2(@id, _toUTF8(_get_eval_string(k)), - # _toUTF8(_get_eval_string(v))) - INTERP._set_global_var2(@id, _get_eval_string(k, true), - _get_eval_string(v, true)) + #INTERP._set_global_var2(@id, _toUTF8(_get_eval_string(k)), + # _toUTF8(_get_eval_string(v))) + INTERP._set_global_var2(@id, _get_eval_string(k, true), + _get_eval_string(v, true)) } self.value elsif val.kind_of?(Array) INTERP._set_global_var(@id, '') val.each{|v| - #INTERP._set_variable(@id, _toUTF8(_get_eval_string(v)), - INTERP._set_variable(@id, _get_eval_string(v, true), - TclTkLib::VarAccessFlag::GLOBAL_ONLY | - TclTkLib::VarAccessFlag::LEAVE_ERR_MSG | - TclTkLib::VarAccessFlag::APPEND_VALUE | - TclTkLib::VarAccessFlag::LIST_ELEMENT) + #INTERP._set_variable(@id, _toUTF8(_get_eval_string(v)), + INTERP._set_variable(@id, _get_eval_string(v, true), + TclTkLib::VarAccessFlag::GLOBAL_ONLY | + TclTkLib::VarAccessFlag::LEAVE_ERR_MSG | + TclTkLib::VarAccessFlag::APPEND_VALUE | + TclTkLib::VarAccessFlag::LIST_ELEMENT) } self.value else @@ -329,11 +329,11 @@ if USE_TCLs_SET_VARIABLE_FUNCTIONS rescue => e case @def_default when :proc - @default_val.call(self, *idxs) + @default_val.call(self, *idxs) when :val - @default_val + @default_val else - fail e + fail e end end #_fromUTF8(INTERP._get_global_var2(@id, index)) @@ -346,9 +346,9 @@ if USE_TCLs_SET_VARIABLE_FUNCTIONS index = args.collect{|idx| _get_eval_string(idx, true)}.join(',') _fromUTF8(INTERP._set_global_var2(@id, index, _get_eval_string(val, true))) #_fromUTF8(INTERP._set_global_var2(@id, _toUTF8(_get_eval_string(index)), - # _toUTF8(_get_eval_string(val)))) + # _toUTF8(_get_eval_string(val)))) #_fromUTF8(INTERP._set_global_var2(@id, _get_eval_string(index, true), - # _get_eval_string(val, true))) + # _get_eval_string(val, true))) end def unset(elem=nil) @@ -372,13 +372,13 @@ else #INTERP._invoke_without_enc('set', @id) rescue if INTERP._eval(Kernel.format('global %s; array exists %s', - @id, @id)) != "1" + @id, @id)) != "1" #if INTERP._eval(Kernel.format('array exists %s', @id)) != "1" #if INTERP._invoke_without_enc('array', 'exists', @id) != "1" - fail + fail else - Hash[*tk_split_simplelist(INTERP._eval(Kernel.format('global %s; array get %s', @id, @id)))] - #Hash[*tk_split_simplelist(_fromUTF8(INTERP._invoke_without_enc('array', 'get', @id)))] + Hash[*tk_split_simplelist(INTERP._eval(Kernel.format('global %s; array get %s', @id, @id)))] + #Hash[*tk_split_simplelist(_fromUTF8(INTERP._invoke_without_enc('array', 'get', @id)))] end end end @@ -392,43 +392,43 @@ else #_fromUTF8(INTERP._invoke_without_enc('set', @id, _toUTF8(s))) rescue if INTERP._eval(Kernel.format('global %s; array exists %s', - @id, @id)) != "1" + @id, @id)) != "1" #if INTERP._eval(Kernel.format('array exists %s', @id)) != "1" #if INTERP._invoke_without_enc('array', 'exists', @id) != "1" - fail + fail else - if val == [] - INTERP._eval(Kernel.format('global %s; unset %s; set %s(0) 0; unset %s(0)', @id, @id, @id, @id)) - #INTERP._eval(Kernel.format('unset %s; set %s(0) 0; unset %s(0)', - # @id, @id, @id)) - #INTERP._invoke_without_enc('unset', @id) - #INTERP._invoke_without_enc('set', @id+'(0)', 0) - #INTERP._invoke_without_enc('unset', @id+'(0)') - elsif val.kind_of?(Array) - a = [] - val.each_with_index{|e,i| a.push(i); a.push(array2tk_list(e))} - #s = '"' + a.join(" ").gsub(/[\[\]$"]/, '\\\\\&') + '"' - s = '"' + a.join(" ").gsub(/[\[\]$"\\]/, '\\\\\&') + '"' - INTERP._eval(Kernel.format('global %s; unset %s; array set %s %s', - @id, @id, @id, s)) - #INTERP._eval(Kernel.format('unset %s; array set %s %s', - # @id, @id, s)) - #INTERP._invoke_without_enc('unset', @id) - #_fromUTF8(INTERP._invoke_without_enc('array','set', @id, _toUTF8(s))) - elsif val.kind_of?(Hash) - #s = '"' + val.to_a.collect{|e| array2tk_list(e)}.join(" ")\ - # .gsub(/[\[\]$"]/, '\\\\\&') + '"' - s = '"' + val.to_a.collect{|e| array2tk_list(e)}.join(" ")\ - .gsub(/[\[\]$\\"]/, '\\\\\&') + '"' - INTERP._eval(Kernel.format('global %s; unset %s; array set %s %s', - @id, @id, @id, s)) - #INTERP._eval(Kernel.format('unset %s; array set %s %s', - # @id, @id, s)) - #INTERP._invoke_without_enc('unset', @id) - #_fromUTF8(INTERP._invoke_without_enc('array','set', @id, _toUTF8(s))) - else - fail - end + if val == [] + INTERP._eval(Kernel.format('global %s; unset %s; set %s(0) 0; unset %s(0)', @id, @id, @id, @id)) + #INTERP._eval(Kernel.format('unset %s; set %s(0) 0; unset %s(0)', + # @id, @id, @id)) + #INTERP._invoke_without_enc('unset', @id) + #INTERP._invoke_without_enc('set', @id+'(0)', 0) + #INTERP._invoke_without_enc('unset', @id+'(0)') + elsif val.kind_of?(Array) + a = [] + val.each_with_index{|e,i| a.push(i); a.push(array2tk_list(e))} + #s = '"' + a.join(" ").gsub(/[\[\]$"]/, '\\\\\&') + '"' + s = '"' + a.join(" ").gsub(/[\[\]$"\\]/, '\\\\\&') + '"' + INTERP._eval(Kernel.format('global %s; unset %s; array set %s %s', + @id, @id, @id, s)) + #INTERP._eval(Kernel.format('unset %s; array set %s %s', + # @id, @id, s)) + #INTERP._invoke_without_enc('unset', @id) + #_fromUTF8(INTERP._invoke_without_enc('array','set', @id, _toUTF8(s))) + elsif val.kind_of?(Hash) + #s = '"' + val.to_a.collect{|e| array2tk_list(e)}.join(" ")\ + # .gsub(/[\[\]$"]/, '\\\\\&') + '"' + s = '"' + val.to_a.collect{|e| array2tk_list(e)}.join(" ")\ + .gsub(/[\[\]$\\"]/, '\\\\\&') + '"' + INTERP._eval(Kernel.format('global %s; unset %s; array set %s %s', + @id, @id, @id, s)) + #INTERP._eval(Kernel.format('unset %s; array set %s %s', + # @id, @id, s)) + #INTERP._invoke_without_enc('unset', @id) + #_fromUTF8(INTERP._invoke_without_enc('array','set', @id, _toUTF8(s))) + else + fail + end end end end @@ -440,11 +440,11 @@ else rescue => e case @def_default when :proc - @default_val.call(self, *idxs) + @default_val.call(self, *idxs) when :val - @default_val + @default_val else - fail e + fail e end end #INTERP._eval(Kernel.format('global %s; set %s(%s)', @id, @id, index)) @@ -462,9 +462,9 @@ else #INTERP._eval(Kernel.format('global %s; set %s(%s) %s', @id, @id, # _get_eval_string(index), _get_eval_string(val))) #INTERP._eval(Kernel.format('set %s(%s) %s', @id, - # _get_eval_string(index), _get_eval_string(val))) + # _get_eval_string(index), _get_eval_string(val))) #INTERP._eval('set ' + @id + '(' + _get_eval_string(index) + ') ' + - # _get_eval_string(val)) + # _get_eval_string(val)) end def unset(elem=nil) @@ -514,9 +514,9 @@ end else case val.to_s.downcase when 'false', '0', 'no', 'off' - self.value = '0' + self.value = '0' else - self.value = '1' + self.value = '1' end end end @@ -602,9 +602,9 @@ end self.value + other else begin - number(self.value) + other + number(self.value) + other rescue - self.value + other.to_s + self.value + other.to_s end end end @@ -670,17 +670,17 @@ end def <=>(other) if other.kind_of?(TkVariable) begin - val = other.numeric - other = val + val = other.numeric + other = val rescue - other = other.value + other = other.value end end if other.kind_of?(Numeric) begin - return self.numeric <=> other + return self.numeric <=> other rescue - return self.value <=> other.to_s + return self.value <=> other.to_s end else return self.value <=> other @@ -697,7 +697,7 @@ end end if elem.kind_of?(String) && elem != '' if @trace_elem.kind_of?(Hash) && @trace_elem[elem].kind_of?(Array) - @trace_elem[elem].each{|m,e| e.call(self,elem,op) if m.index(op)} + @trace_elem[elem].each{|m,e| e.call(self,elem,op) if m.index(op)} end end end @@ -713,12 +713,12 @@ end Tk.tk_call_without_enc('trace', 'variable', @id, @trace_opts, 'rb_var') =begin if /^(8\.([4-9]|[1-9][0-9])|9\.|[1-9][0-9])/ =~ Tk::TCL_VERSION - # TCL_VERSION >= 8.4 - Tk.tk_call_without_enc('trace', 'add', 'variable', - @id, @trace_opts, 'rb_var') + # TCL_VERSION >= 8.4 + Tk.tk_call_without_enc('trace', 'add', 'variable', + @id, @trace_opts, 'rb_var') else - # TCL_VERSION <= 8.3 - Tk.tk_call_without_enc('trace', 'variable', @id, @trace_opts, 'rb_var') + # TCL_VERSION <= 8.3 + Tk.tk_call_without_enc('trace', 'variable', @id, @trace_opts, 'rb_var') end =end else @@ -726,25 +726,25 @@ end #opts.each_byte{|c| newopts += c.chr unless newopts.index(c)} opts.each_byte{|c| newopts.concat(c.chr) unless newopts.index(c)} if newopts != @trace_opts - Tk.tk_call_without_enc('trace', 'vdelete', @id, @trace_opts, 'rb_var') - @trace_opts.replace(newopts) - Tk.tk_call_without_enc('trace', 'variable', @id, @trace_opts, 'rb_var') + Tk.tk_call_without_enc('trace', 'vdelete', @id, @trace_opts, 'rb_var') + @trace_opts.replace(newopts) + Tk.tk_call_without_enc('trace', 'variable', @id, @trace_opts, 'rb_var') =begin - if /^(8\.([4-9]|[1-9][0-9])|9\.|[1-9][0-9])/ =~ Tk::TCL_VERSION - # TCL_VERSION >= 8.4 - Tk.tk_call_without_enc('trace', 'remove', 'variable', - @id, @trace_opts, 'rb_var') - @trace_opts.replace(newopts) - Tk.tk_call_without_enc('trace', 'add', 'variable', - @id, @trace_opts, 'rb_var') - else - # TCL_VERSION <= 8.3 - Tk.tk_call_without_enc('trace', 'vdelete', - @id, @trace_opts, 'rb_var') - @trace_opts.replace(newopts) - Tk.tk_call_without_enc('trace', 'variable', - @id, @trace_opts, 'rb_var') - end + if /^(8\.([4-9]|[1-9][0-9])|9\.|[1-9][0-9])/ =~ Tk::TCL_VERSION + # TCL_VERSION >= 8.4 + Tk.tk_call_without_enc('trace', 'remove', 'variable', + @id, @trace_opts, 'rb_var') + @trace_opts.replace(newopts) + Tk.tk_call_without_enc('trace', 'add', 'variable', + @id, @trace_opts, 'rb_var') + else + # TCL_VERSION <= 8.3 + Tk.tk_call_without_enc('trace', 'vdelete', + @id, @trace_opts, 'rb_var') + @trace_opts.replace(newopts) + Tk.tk_call_without_enc('trace', 'variable', + @id, @trace_opts, 'rb_var') + end =end end end @@ -763,13 +763,13 @@ end Tk.tk_call_without_enc('trace', 'variable', @id, @trace_opts, 'rb_var') =begin if /^(8\.([4-9]|[1-9][0-9])|9\.|[1-9][0-9])/ =~ Tk::TCL_VERSION - # TCL_VERSION >= 8.4 - Tk.tk_call_without_enc('trace', 'add', 'variable', - @id, @trace_opts, 'rb_var') + # TCL_VERSION >= 8.4 + Tk.tk_call_without_enc('trace', 'add', 'variable', + @id, @trace_opts, 'rb_var') else - # TCL_VERSION <= 8.3 - Tk.tk_call_without_enc('trace', 'variable', - @id, @trace_opts, 'rb_var') + # TCL_VERSION <= 8.3 + Tk.tk_call_without_enc('trace', 'variable', + @id, @trace_opts, 'rb_var') end =end else @@ -777,25 +777,25 @@ end # opts.each_byte{|c| newopts += c.chr unless newopts.index(c)} opts.each_byte{|c| newopts.concat(c.chr) unless newopts.index(c)} if newopts != @trace_opts - Tk.tk_call_without_enc('trace', 'vdelete', @id, @trace_opts, 'rb_var') - @trace_opts.replace(newopts) - Tk.tk_call_without_enc('trace', 'variable', @id, @trace_opts, 'rb_var') + Tk.tk_call_without_enc('trace', 'vdelete', @id, @trace_opts, 'rb_var') + @trace_opts.replace(newopts) + Tk.tk_call_without_enc('trace', 'variable', @id, @trace_opts, 'rb_var') =begin - if /^(8\.([4-9]|[1-9][0-9])|9\.|[1-9][0-9])/ =~ Tk::TCL_VERSION - # TCL_VERSION >= 8.4 - Tk.tk_call_without_enc('trace', 'remove', 'variable', - @id, @trace_opts, 'rb_var') - @trace_opts.replace(newopts) - Tk.tk_call_without_enc('trace', 'add', 'variable', - @id, @trace_opts, 'rb_var') - else - # TCL_VERSION <= 8.3 - Tk.tk_call_without_enc('trace', 'vdelete', - @id, @trace_opts, 'rb_var') - @trace_opts.replace(newopts) - Tk.tk_call_without_enc('trace', 'variable', - @id, @trace_opts, 'rb_var') - end + if /^(8\.([4-9]|[1-9][0-9])|9\.|[1-9][0-9])/ =~ Tk::TCL_VERSION + # TCL_VERSION >= 8.4 + Tk.tk_call_without_enc('trace', 'remove', 'variable', + @id, @trace_opts, 'rb_var') + @trace_opts.replace(newopts) + Tk.tk_call_without_enc('trace', 'add', 'variable', + @id, @trace_opts, 'rb_var') + else + # TCL_VERSION <= 8.3 + Tk.tk_call_without_enc('trace', 'vdelete', + @id, @trace_opts, 'rb_var') + @trace_opts.replace(newopts) + Tk.tk_call_without_enc('trace', 'variable', + @id, @trace_opts, 'rb_var') + end =end end end @@ -820,8 +820,8 @@ end newopts = '' @trace_var.each_with_index{|e,i| if idx < 0 && e[0] == opts && e[1] == cmd - idx = i - next + idx = i + next end # e[0].each_byte{|c| newopts += c.chr unless newopts.index(c)} e[0].each_byte{|c| newopts.concat(c.chr) unless newopts.index(c)} @@ -834,8 +834,8 @@ end @trace_elem.each{|elem| @trace_elem[elem].each{|e| - # e[0].each_byte{|c| newopts += c.chr unless newopts.index(c)} - e[0].each_byte{|c| newopts.concat(c.chr) unless newopts.index(c)} + # e[0].each_byte{|c| newopts += c.chr unless newopts.index(c)} + e[0].each_byte{|c| newopts.concat(c.chr) unless newopts.index(c)} } } @@ -845,28 +845,28 @@ end Tk.tk_call_without_enc('trace', 'vdelete', @id, @trace_opts, 'rb_var') =begin if /^(8\.([4-9]|[1-9][0-9])|9\.|[1-9][0-9])/ =~ Tk::TCL_VERSION - # TCL_VERSION >= 8.4 - Tk.tk_call_without_enc('trace', 'remove', 'variable', - @id, @trace_opts, 'rb_var') + # TCL_VERSION >= 8.4 + Tk.tk_call_without_enc('trace', 'remove', 'variable', + @id, @trace_opts, 'rb_var') else - # TCL_VERSION <= 8.3 - Tk.tk_call_without_enc('trace', 'vdelete', - @id, @trace_opts, 'rb_var') + # TCL_VERSION <= 8.3 + Tk.tk_call_without_enc('trace', 'vdelete', + @id, @trace_opts, 'rb_var') end =end @trace_opts.replace(newopts) if @trace_opts != '' - Tk.tk_call_without_enc('trace', 'variable', @id, @trace_opts, 'rb_var') + Tk.tk_call_without_enc('trace', 'variable', @id, @trace_opts, 'rb_var') =begin - if /^(8\.([4-9]|[1-9][0-9])|9\.|[1-9][0-9])/ =~ Tk::TCL_VERSION - # TCL_VERSION >= 8.4 - Tk.tk_call_without_enc('trace', 'add', 'variable', - @id, @trace_opts, 'rb_var') - else - # TCL_VERSION <= 8.3 - Tk.tk_call_without_enc('trace', 'variable', - @id, @trace_opts, 'rb_var') - end + if /^(8\.([4-9]|[1-9][0-9])|9\.|[1-9][0-9])/ =~ Tk::TCL_VERSION + # TCL_VERSION >= 8.4 + Tk.tk_call_without_enc('trace', 'add', 'variable', + @id, @trace_opts, 'rb_var') + else + # TCL_VERSION <= 8.3 + Tk.tk_call_without_enc('trace', 'variable', + @id, @trace_opts, 'rb_var') + end =end end end @@ -882,8 +882,8 @@ end idx = -1 @trace_elem[elem].each_with_index{|e,i| if idx < 0 && e[0] == opts && e[1] == cmd - idx = i - next + idx = i + next end } if idx >= 0 @@ -899,8 +899,8 @@ end } @trace_elem.each{|elem| @trace_elem[elem].each{|e| - # e[0].each_byte{|c| newopts += c.chr unless newopts.index(c)} - e[0].each_byte{|c| newopts.concat(c.chr) unless newopts.index(c)} + # e[0].each_byte{|c| newopts += c.chr unless newopts.index(c)} + e[0].each_byte{|c| newopts.concat(c.chr) unless newopts.index(c)} } } @@ -910,28 +910,28 @@ end Tk.tk_call_without_enc('trace', 'vdelete', @id, @trace_opts, 'rb_var') =begin if /^(8\.([4-9]|[1-9][0-9])|9\.|[1-9][0-9])/ =~ Tk::TCL_VERSION - # TCL_VERSION >= 8.4 - Tk.tk_call_without_enc('trace', 'remove', 'variable', - @id, @trace_opts, 'rb_var') + # TCL_VERSION >= 8.4 + Tk.tk_call_without_enc('trace', 'remove', 'variable', + @id, @trace_opts, 'rb_var') else - # TCL_VERSION <= 8.3 - Tk.tk_call_without_enc('trace', 'vdelete', - @id, @trace_opts, 'rb_var') + # TCL_VERSION <= 8.3 + Tk.tk_call_without_enc('trace', 'vdelete', + @id, @trace_opts, 'rb_var') end =end @trace_opts.replace(newopts) if @trace_opts != '' - Tk.tk_call_without_enc('trace', 'variable', @id, @trace_opts, 'rb_var') + Tk.tk_call_without_enc('trace', 'variable', @id, @trace_opts, 'rb_var') =begin - if /^(8\.([4-9]|[1-9][0-9])|9\.|[1-9][0-9])/ =~ Tk::TCL_VERSION - # TCL_VERSION >= 8.4 - Tk.tk_call_without_enc('trace', 'add', 'variable', - @id, @trace_opts, 'rb_var') - else - # TCL_VERSION <= 8.3 - Tk.tk_call_without_enc('trace', 'variable', @id, - @trace_opts, 'rb_var') - end + if /^(8\.([4-9]|[1-9][0-9])|9\.|[1-9][0-9])/ =~ Tk::TCL_VERSION + # TCL_VERSION >= 8.4 + Tk.tk_call_without_enc('trace', 'add', 'variable', + @id, @trace_opts, 'rb_var') + else + # TCL_VERSION <= 8.3 + Tk.tk_call_without_enc('trace', 'variable', @id, + @trace_opts, 'rb_var') + end =end end end @@ -966,9 +966,9 @@ class TkVarAccess") - PreDefVirtEvent.new(event) + PreDefVirtEvent.new(event) else - fail ArgumentError, "undefined virtual event '<#{event}>'" + fail ArgumentError, "undefined virtual event '<#{event}>'" end end end @@ -50,9 +50,9 @@ class TkVirtualEvent", - *(sequences.collect{|seq| - "<#{tk_event_sequence(seq)}>" - }) ) + *(sequences.collect{|seq| + "<#{tk_event_sequence(seq)}>" + }) ) TkVirtualEventTBL[@id] = self end self @@ -64,9 +64,9 @@ class TkVirtualEvent", - *(sequences.collect{|seq| - "<#{tk_event_sequence(seq)}>" - }) ) + *(sequences.collect{|seq| + "<#{tk_event_sequence(seq)}>" + }) ) TkVirtualEventTBL.delete(@id) if info == [] end self @@ -75,14 +75,14 @@ class TkVirtualEvent").split(/\s+/).collect!{|seq| l = seq.scan(/<*[^<>]+>*/).collect!{|subseq| - case (subseq) - when /^<<[^<>]+>>$/ - TkVirtualEvent.getobj(subseq[1..-2]) - when /^<[^<>]+>$/ - subseq[1..-2] - else - subseq.split('') - end + case (subseq) + when /^<<[^<>]+>>$/ + TkVirtualEvent.getobj(subseq[1..-2]) + when /^<[^<>]+>$/ + subseq[1..-2] + else + subseq.split('') + end }.flatten (l.size == 1) ? l[0] : l } diff --git a/ext/tk/lib/tk/winfo.rb b/ext/tk/lib/tk/winfo.rb index b4cb79a29a..948042558d 100644 --- a/ext/tk/lib/tk/winfo.rb +++ b/ext/tk/lib/tk/winfo.rb @@ -15,7 +15,7 @@ module TkWinfo def TkWinfo.atom(name, win=nil) if win number(tk_call_without_enc('winfo', 'atom', '-displayof', win, - _get_eval_enc_str(name))) + _get_eval_enc_str(name))) else number(tk_call_without_enc('winfo', 'atom', _get_eval_enc_str(name))) end @@ -27,7 +27,7 @@ module TkWinfo def TkWinfo.atomname(id, win=nil) if win _fromUTF8(tk_call_without_enc('winfo', 'atomname', - '-displayof', win, id)) + '-displayof', win, id)) else _fromUTF8(tk_call_without_enc('winfo', 'atomname', id)) end @@ -68,7 +68,7 @@ module TkWinfo def TkWinfo.containing(rootX, rootY, win=nil) if win window(tk_call_without_enc('winfo', 'containing', - '-displayof', win, rootX, rootY)) + '-displayof', win, rootX, rootY)) else window(tk_call_without_enc('winfo', 'containing', rootX, rootY)) end @@ -122,7 +122,7 @@ module TkWinfo def TkWinfo.interps(window=nil) if window tk_split_simplelist(tk_call_without_enc('winfo', 'interps', - '-displayof', window)) + '-displayof', window)) else tk_split_simplelist(tk_call_without_enc('winfo', 'interps')) end @@ -299,7 +299,7 @@ module TkWinfo def TkWinfo.visualsavailable(window, includeids=false) if includeids list(tk_call_without_enc('winfo', 'visualsavailable', - window, "includeids")) + window, "includeids")) else list(tk_call_without_enc('winfo', 'visualsavailable', window)) end diff --git a/ext/tk/lib/tk/winpkg.rb b/ext/tk/lib/tk/winpkg.rb index 1d7d473387..d6f7a0e9d4 100644 --- a/ext/tk/lib/tk/winpkg.rb +++ b/ext/tk/lib/tk/winpkg.rb @@ -19,25 +19,27 @@ module TkWinDDE tk_call_without_enc('package', 'require', 'dde') end - def servername(topic=None) - tk_call('dde', 'servername', topic) - end + #def servername(topic=None) + # tk_call('dde', 'servername', topic) + #end def servername(*args) if args.size == 0 tk_call('dde', 'servername') else - if args[-1].kind_of?(Hash) - keys = _symbolkey2str(args.pop) - force = (keys.delete('force'))? '-force': None - exact = (keys.delete('exact'))? '-exact': None - if keys.size == 0 - tk_call('dde', 'servername', force, exact) - elsif args.size == 0 - tk_call('dde', 'servername', force, exact, *hash_kv(keys)) - else - tk_call('dde', 'servername', force, exact, - *((hash_kv(keys) << '--') + args)) - end + if args[-1].kind_of?(Hash) # dde 1.2 + + keys = _symbolkey2str(args.pop) + force = (keys.delete('force'))? '-force': None + exact = (keys.delete('exact'))? '-exact': None + if keys.size == 0 + tk_call('dde', 'servername', force, exact) + elsif args.size == 0 + tk_call('dde', 'servername', force, exact, *hash_kv(keys)) + else + tk_call('dde', 'servername', force, exact, + *((hash_kv(keys) << '--') + args)) + end + else + tk_call('dde', 'servername', *args) end end end diff --git a/ext/tk/lib/tk/wm.rb b/ext/tk/lib/tk/wm.rb index b5106adade..a1002f7b96 100644 --- a/ext/tk/lib/tk/wm.rb +++ b/ext/tk/lib/tk/wm.rb @@ -11,237 +11,267 @@ module Tk def aspect(*args) if args.length == 0 - list(tk_call_without_enc('wm', 'aspect', path)) + list(tk_call_without_enc('wm', 'aspect', path)) else - tk_call('wm', 'aspect', path, *args) - self + tk_call('wm', 'aspect', path, *args) + self end end + def attributes(slot=nil,value=None) if slot == nil - lst = tk_split_list(tk_call('wm', 'attributes', path)) - info = {} - while key = lst.shift - info[key[1..-1]] = lst.shift - end - info + lst = tk_split_list(tk_call('wm', 'attributes', path)) + info = {} + while key = lst.shift + info[key[1..-1]] = lst.shift + end + info elsif slot.kind_of? Hash - tk_call('wm', 'attributes', path, *hash_kv(slot)) - self + tk_call('wm', 'attributes', path, *hash_kv(slot)) + self elsif value == None - tk_call('wm', 'attributes', path, "-#{slot}") + tk_call('wm', 'attributes', path, "-#{slot}") else - tk_call('wm', 'attributes', path, "-#{slot}", value) - self + tk_call('wm', 'attributes', path, "-#{slot}", value) + self end end + def client(name=None) if name == None - tk_call('wm', 'client', path) + tk_call('wm', 'client', path) else name = '' if name == nil - tk_call('wm', 'client', path, name) - self + tk_call('wm', 'client', path, name) + self end end + def colormapwindows(*args) if args.size == 0 - list(tk_call_without_enc('wm', 'colormapwindows', path)) + list(tk_call_without_enc('wm', 'colormapwindows', path)) else - tk_call_without_enc('wm', 'colormapwindows', path, *args) - self + tk_call_without_enc('wm', 'colormapwindows', path, *args) + self end end + def wm_command(value=nil) if value - tk_call('wm', 'command', path, value) - self + tk_call('wm', 'command', path, value) + self else - #procedure(tk_call('wm', 'command', path)) - tk_call('wm', 'command', path) + #procedure(tk_call('wm', 'command', path)) + tk_call('wm', 'command', path) end end + def deiconify(ex = true) tk_call_without_enc('wm', 'deiconify', path) if ex self end + def focusmodel(mode = nil) if mode - tk_call_without_enc('wm', 'focusmodel', path, mode) - self + tk_call_without_enc('wm', 'focusmodel', path, mode) + self else - tk_call_without_enc('wm', 'focusmodel', path) + tk_call_without_enc('wm', 'focusmodel', path) end end + def frame tk_call_without_enc('wm', 'frame', path) end + def geometry(geom=nil) if geom - tk_call_without_enc('wm', 'geometry', path, geom) - self + tk_call_without_enc('wm', 'geometry', path, geom) + self else - tk_call_without_enc('wm', 'geometry', path) + tk_call_without_enc('wm', 'geometry', path) end end + def wm_grid(*args) if args.size == 0 - list(tk_call_without_enc('wm', 'grid', path)) + list(tk_call_without_enc('wm', 'grid', path)) else - tk_call_without_enc('wm', 'grid', path, *args) - self + tk_call_without_enc('wm', 'grid', path, *args) + self end end + def group(leader = nil) if leader - tk_call('wm', 'group', path, leader) - self + tk_call('wm', 'group', path, leader) + self else - window(tk_call('wm', 'group', path)) + window(tk_call('wm', 'group', path)) end end + def iconbitmap(bmp=nil) if bmp - tk_call_without_enc('wm', 'iconbitmap', path, bmp) - self + tk_call_without_enc('wm', 'iconbitmap', path, bmp) + self else - image_obj(tk_call_without_enc('wm', 'iconbitmap', path)) + image_obj(tk_call_without_enc('wm', 'iconbitmap', path)) end end + def iconify(ex = true) tk_call_without_enc('wm', 'iconify', path) if ex self end + def iconmask(bmp=nil) if bmp - tk_call_without_enc('wm', 'iconmask', path, bmp) - self + tk_call_without_enc('wm', 'iconmask', path, bmp) + self else - image_obj(tk_call_without_enc('wm', 'iconmask', path)) + image_obj(tk_call_without_enc('wm', 'iconmask', path)) end end + def iconname(name=nil) if name - tk_call('wm', 'iconname', path, name) - self + tk_call('wm', 'iconname', path, name) + self else - tk_call('wm', 'iconname', path) + tk_call('wm', 'iconname', path) end end + def iconposition(*args) if args.size == 0 - list(tk_call_without_enc('wm', 'iconposition', path)) + list(tk_call_without_enc('wm', 'iconposition', path)) else - tk_call_without_enc('wm', 'iconposition', path, *args) - self + tk_call_without_enc('wm', 'iconposition', path, *args) + self end end + def iconwindow(win = nil) if win - tk_call_without_enc('wm', 'iconwindow', path, win) - self + tk_call_without_enc('wm', 'iconwindow', path, win) + self else - w = tk_call_without_enc('wm', 'iconwindow', path) - (w == '')? nil: window(w) + w = tk_call_without_enc('wm', 'iconwindow', path) + (w == '')? nil: window(w) end end + def maxsize(*args) if args.size == 0 - list(tk_call_without_enc('wm', 'maxsize', path)) + list(tk_call_without_enc('wm', 'maxsize', path)) else - tk_call_without_enc('wm', 'maxsize', path, *args) - self + tk_call_without_enc('wm', 'maxsize', path, *args) + self end end + def minsize(*args) if args.size == 0 - list(tk_call_without_enc('wm', 'minsize', path)) + list(tk_call_without_enc('wm', 'minsize', path)) else - tk_call_without_enc('wm', 'minsize', path, *args) - self + tk_call_without_enc('wm', 'minsize', path, *args) + self end end + def overrideredirect(bool=None) if bool == None - bool(tk_call_without_enc('wm', 'overrideredirect', path)) + bool(tk_call_without_enc('wm', 'overrideredirect', path)) else - tk_call_without_enc('wm', 'overrideredirect', path, bool) - self + tk_call_without_enc('wm', 'overrideredirect', path, bool) + self end end + def positionfrom(who=None) if who == None - r = tk_call_without_enc('wm', 'positionfrom', path) - (r == "")? nil: r + r = tk_call_without_enc('wm', 'positionfrom', path) + (r == "")? nil: r else - tk_call_without_enc('wm', 'positionfrom', path, who) - self + tk_call_without_enc('wm', 'positionfrom', path, who) + self end end + def protocol(name=nil, cmd=nil, &b) if cmd - tk_call_without_enc('wm', 'protocol', path, name, cmd) - self + tk_call_without_enc('wm', 'protocol', path, name, cmd) + self elsif b - tk_call_without_enc('wm', 'protocol', path, name, proc(&b)) - self + tk_call_without_enc('wm', 'protocol', path, name, proc(&b)) + self elsif name - result = tk_call_without_enc('wm', 'protocol', path, name) - (result == "")? nil : tk_tcl2ruby(result) + result = tk_call_without_enc('wm', 'protocol', path, name) + (result == "")? nil : tk_tcl2ruby(result) else - tk_split_simplelist(tk_call_without_enc('wm', 'protocol', path)) + tk_split_simplelist(tk_call_without_enc('wm', 'protocol', path)) end end + def resizable(*args) if args.length == 0 - list(tk_call_without_enc('wm', 'resizable', path)).collect{|e| bool(e)} + list(tk_call_without_enc('wm', 'resizable', path)).collect{|e| bool(e)} else - tk_call_without_enc('wm', 'resizable', path, *args) - self + tk_call_without_enc('wm', 'resizable', path, *args) + self end end + def sizefrom(who=None) if who == None - r = tk_call_without_enc('wm', 'sizefrom', path) - (r == "")? nil: r + r = tk_call_without_enc('wm', 'sizefrom', path) + (r == "")? nil: r else - tk_call_without_enc('wm', 'sizefrom', path, who) - self + tk_call_without_enc('wm', 'sizefrom', path, who) + self end end + def stackorder list(tk_call('wm', 'stackorder', path)) end + def stackorder_isabove(win) bool(tk_call('wm', 'stackorder', path, 'isabove', win)) end + def stackorder_isbelow(win) bool(tk_call('wm', 'stackorder', path, 'isbelow', win)) end + def state(state=nil) if state - tk_call_without_enc('wm', 'state', path, state) - self + tk_call_without_enc('wm', 'state', path, state) + self else - tk_call_without_enc('wm', 'state', path) + tk_call_without_enc('wm', 'state', path) end end + def title(str=nil) if str - tk_call('wm', 'title', path, str) - self + tk_call('wm', 'title', path, str) + self else - tk_call('wm', 'title', path) + tk_call('wm', 'title', path) end end + def transient(master=nil) if master - tk_call_without_enc('wm', 'transient', path, master) - self + tk_call_without_enc('wm', 'transient', path, master) + self else - window(tk_call_without_enc('wm', 'transient', path)) + window(tk_call_without_enc('wm', 'transient', path)) end end + def withdraw(ex = true) tk_call_without_enc('wm', 'withdraw', path) if ex self diff --git a/ext/tk/lib/tk/xim.rb b/ext/tk/lib/tk/xim.rb index b4dacdc331..701cd7531c 100644 --- a/ext/tk/lib/tk/xim.rb +++ b/ext/tk/lib/tk/xim.rb @@ -13,14 +13,14 @@ module TkXIM if value == None if window bool(tk_call_without_enc('tk', 'useinputmethods', - '-displayof', window)) + '-displayof', window)) else bool(tk_call_without_enc('tk', 'useinputmethods')) end else if window - bool(tk_call_without_enc('tk', 'useinputmethods', - '-displayof', window, value)) + bool(tk_call_without_enc('tk', 'useinputmethods', + '-displayof', window, value)) else bool(tk_call_without_enc('tk', 'useinputmethods', value)) end @@ -39,7 +39,7 @@ module TkXIM lst = tk_split_list(tk_call_without_enc('tk', 'caret', window)) info = {} while key = lst.shift - info[key[1..-1]] = lst.shift + info[key[1..-1]] = lst.shift end info end @@ -61,22 +61,22 @@ module TkXIM def TkXIM.configinfo(window, slot=nil) if TkComm::GET_CONFIGINFOwoRES_AS_ARRAY begin - if /^8\.*/ === Tk::TK_VERSION && JAPANIZED_TK - if slot - conf = tk_split_list(tk_call('imconfigure', window, "-#{slot}")) - conf[0] = conf[0][1..-1] - conf - else - tk_split_list(tk_call('imconfigure', window)).collect{|conf| - conf[0] = conf[0][1..-1] - conf - } - end - else - [] - end + if /^8\.*/ === Tk::TK_VERSION && JAPANIZED_TK + if slot + conf = tk_split_list(tk_call('imconfigure', window, "-#{slot}")) + conf[0] = conf[0][1..-1] + conf + else + tk_split_list(tk_call('imconfigure', window)).collect{|conf| + conf[0] = conf[0][1..-1] + conf + } + end + else + [] + end rescue - [] + [] end else # ! TkComm::GET_CONFIGINFOwoRES_AS_ARRAY TkXIM.current_configinfo(window, slot) @@ -86,18 +86,18 @@ module TkXIM def TkXIM.current_configinfo(window, slot=nil) begin if /^8\.*/ === Tk::TK_VERSION && JAPANIZED_TK - if slot - conf = tk_split_list(tk_call('imconfigure', window, "-#{slot}")) - { conf[0][1..-1] => conf[1] } - else - ret = {} - tk_split_list(tk_call('imconfigure', window)).each{|conf| - ret[conf[0][1..-1]] = conf[1] - } - ret - end + if slot + conf = tk_split_list(tk_call('imconfigure', window, "-#{slot}")) + { conf[0][1..-1] => conf[1] } + else + ret = {} + tk_split_list(tk_call('imconfigure', window)).each{|conf| + ret[conf[0][1..-1]] = conf[1] + } + ret + end else - {} + {} end rescue {} diff --git a/ext/tk/lib/tkclass.rb b/ext/tk/lib/tkclass.rb index 9ea275e560..87f5acc453 100644 --- a/ext/tk/lib/tkclass.rb +++ b/ext/tk/lib/tkclass.rb @@ -1,9 +1,9 @@ # -# tkclass.rb - Tk classes -# Date: 2000/11/27 09:23:36 -# by Yukihiro Matsumoto +# tkclass.rb - Tk classes +# Date: 2000/11/27 09:23:36 +# by Yukihiro Matsumoto # -# $Id$ +# $Id$ require "tk" diff --git a/ext/tk/lib/tkextlib/ICONS/icons.rb b/ext/tk/lib/tkextlib/ICONS/icons.rb index 275903f302..20d706df65 100644 --- a/ext/tk/lib/tkextlib/ICONS/icons.rb +++ b/ext/tk/lib/tkextlib/ICONS/icons.rb @@ -20,20 +20,20 @@ module Tk def self.package_version begin - TkPackage.require('icons') + TkPackage.require('icons') rescue - '' + '' end end def self.create(*args) # icon, icon, ..., ?option=>value, ...? if args[-1].kind_of?(Hash) - keys = args.pop - icons = simplelist(tk_call('::icons::icons', 'create', - *(hash_kv(keys) << (args.flatten)))) + keys = args.pop + icons = simplelist(tk_call('::icons::icons', 'create', + *(hash_kv(keys) << (args.flatten)))) else - icons = simplelist(tk_call('::icons::icons', 'create', - args.flatten)) + icons = simplelist(tk_call('::icons::icons', 'create', + args.flatten)) end icons.collect{|icon| self.new(icon, :without_creating=>true)} @@ -43,28 +43,28 @@ module Tk icons = icons.flatten return if icons.empty? icons.map!{|icon| - if icon.kind_of?(Tk::ICONS) - Tk_IMGTBL.delete(icon.path) - icon.name - elsif icon.to_s =~ /^::icon::(.*)/ - name = $1 - Tk_IMGTBL.delete(icon) - name - else - Tk_IMGTBL.delete("::icon::#{icon}") - icon - end + if icon.kind_of?(Tk::ICONS) + Tk_IMGTBL.delete(icon.path) + icon.name + elsif icon.to_s =~ /^::icon::(.*)/ + name = $1 + Tk_IMGTBL.delete(icon) + name + else + Tk_IMGTBL.delete("::icon::#{icon}") + icon + end } tk_call('::icons::icons', 'delete', icons) end def self.query(*args) # icon, icon, ..., ?option=>value, ...? if args[-1].kind_of?(Hash) - keys = args.pop - simplelist(tk_call('::icons::icons', 'query', - *(hash_kv(keys) << (args.flatten)))) + keys = args.pop + simplelist(tk_call('::icons::icons', 'query', + *(hash_kv(keys) << (args.flatten)))) else - simplelist(tk_call('::icons::icons', 'query', args.flatten)) + simplelist(tk_call('::icons::icons', 'query', args.flatten)) end . map{|inf| list(inf) } end @@ -76,15 +76,15 @@ module Tk def initialize(name, keys=nil) if name.kind_of?(String) && name =~ /^::icon::(.+)$/ - @name = $1 - @path = name + @name = $1 + @path = name else - @name = name.to_s - @path = "::icon::#{@name}" + @name = name.to_s + @path = "::icon::#{@name}" end keys = _symbolkey2str(keys) unless keys.delete('without_creating') - tk_call('::icons::icons', 'create', *(hash_kv(keys) << @name)) + tk_call('::icons::icons', 'create', *(hash_kv(keys) << @name)) end Tk_IMGTBL[@path] = self end @@ -101,8 +101,8 @@ module Tk def query(keys={}) list(simplelist(tk_call('::icons::icons', 'query', - *(hash_kv(keys) << @name)) - )[0]) + *(hash_kv(keys) << @name)) + )[0]) end end end diff --git a/ext/tk/lib/tkextlib/bwidget.rb b/ext/tk/lib/tkextlib/bwidget.rb index 2fe0089765..56009f4694 100644 --- a/ext/tk/lib/tkextlib/bwidget.rb +++ b/ext/tk/lib/tkextlib/bwidget.rb @@ -25,16 +25,16 @@ module Tk def self.package_version begin - TkPackage.require('BWidget') + TkPackage.require('BWidget') rescue - '' + '' end end def self.XLFDfont(cmd, *args) if args[-1].kind_of?(Hash) - keys = args.pop - args.concat(hash_kv(keys)) + keys = args.pop + args.concat(hash_kv(keys)) end tk_call('BWidget::XLFDfont', cmd, *args) end @@ -93,8 +93,8 @@ module Tk def self.place(path, w, h, *args) if args[-1].kind_of?(Hash) - keys = args.pop - args.concat(hash_kv(keys)) + keys = args.pop + args.concat(hash_kv(keys)) end tk_call('BWidget::place', path, w, h, *(args.flatten)) end diff --git a/ext/tk/lib/tkextlib/bwidget/dialog.rb b/ext/tk/lib/tkextlib/bwidget/dialog.rb index 4a60a7ceb4..d175a2d8bb 100644 --- a/ext/tk/lib/tkextlib/bwidget/dialog.rb +++ b/ext/tk/lib/tkextlib/bwidget/dialog.rb @@ -43,7 +43,7 @@ class Tk::BWidget::Dialog cmd = self.class::TkCommandNames[0] if keys and keys != None tk_call_without_enc(cmd, @path, '-parent', @relative, - *hash_kv(keys, true)) + *hash_kv(keys, true)) else tk_call_without_enc(cmd, @path, '-parent', @relative) end @@ -64,9 +64,9 @@ class Tk::BWidget::Dialog super(slot) else if slot.to_s == 'relative' - super('parent', value) + super('parent', value) else - super(slot, value) + super(slot, value) end end end @@ -74,16 +74,16 @@ class Tk::BWidget::Dialog def configinfo(slot=nil) if slot if slot.to_s == 'relative' - super('parent') + super('parent') else - super(slot) + super(slot) end else ret = super() if TkComm::GET_CONFIGINFO_AS_ARRAY - ret << ['relative', 'parent'] + ret << ['relative', 'parent'] else - ret['relative'] = 'parent' + ret['relative'] = 'parent' end end end diff --git a/ext/tk/lib/tkextlib/bwidget/listbox.rb b/ext/tk/lib/tkextlib/bwidget/listbox.rb index 102be9a5fa..9f505703f2 100644 --- a/ext/tk/lib/tkextlib/bwidget/listbox.rb +++ b/ext/tk/lib/tkextlib/bwidget/listbox.rb @@ -30,7 +30,7 @@ class Tk::BWidget::ListBox class Event_for_Items < TkEvent::Event def self._get_extra_args_tbl [ - TkComm.method(:string) # item idenfier + TkComm.method(:string) # item idenfier ] end end @@ -135,19 +135,19 @@ class Tk::BWidget::ListBox def selection_set(*args) tk_send_without_enc('selection', 'set', - *(args.collect{|item| tagid(item)})) + *(args.collect{|item| tagid(item)})) self end def selection_add(*args) tk_send_without_enc('selection', 'add', - *(args.collect{|item| tagid(item)})) + *(args.collect{|item| tagid(item)})) self end def selection_remove(*args) tk_send_without_enc('selection', 'remove', - *(args.collect{|item| tagid(item)})) + *(args.collect{|item| tagid(item)})) self end @@ -177,7 +177,7 @@ class Tk::BWidget::ListBox::Item @listbox = lbox else fail RuntimeError, - "expect Tk::BWidget::ListBox or Tk::BWidget::ListBox::Item for 1st argument" + "expect Tk::BWidget::ListBox or Tk::BWidget::ListBox::Item for 1st argument" end if args[-1].kind_of?(Hash) diff --git a/ext/tk/lib/tkextlib/bwidget/messagedlg.rb b/ext/tk/lib/tkextlib/bwidget/messagedlg.rb index 55cc4ba0de..d7b2bbc32b 100644 --- a/ext/tk/lib/tkextlib/bwidget/messagedlg.rb +++ b/ext/tk/lib/tkextlib/bwidget/messagedlg.rb @@ -65,22 +65,22 @@ class Tk::BWidget::MessageDlg @keys.update(slot) if @info - # update @info - slot.each{|k, v| - if TkComm::GET_CONFIGINFO_AS_ARRAY - if (inf = @info.assoc(k)) - inf[-1] = v - else - @info << [k, '', '', '', v] - end - else - if (inf = @info[k]) - inf[-1] = v - else - @info[k] = ['', '', '', v] - end - end - } + # update @info + slot.each{|k, v| + if TkComm::GET_CONFIGINFO_AS_ARRAY + if (inf = @info.assoc(k)) + inf[-1] = v + else + @info << [k, '', '', '', v] + end + else + if (inf = @info[k]) + inf[-1] = v + else + @info[k] = ['', '', '', v] + end + end + } end else # ! Hash @@ -89,20 +89,20 @@ class Tk::BWidget::MessageDlg @keys[slot] = value if @info - # update @info - if TkComm::GET_CONFIGINFO_AS_ARRAY - if (inf = @info.assoc(slot)) - inf[-1] = value - else - @info << [slot, '', '', '', value] - end - else - if (inf = @info[slot]) - inf[-1] = value - else - @info[slot] = ['', '', '', value] - end - end + # update @info + if TkComm::GET_CONFIGINFO_AS_ARRAY + if (inf = @info.assoc(slot)) + inf[-1] = value + else + @info << [slot, '', '', '', value] + end + else + if (inf = @info[slot]) + inf[-1] = value + else + @info[slot] = ['', '', '', value] + end + end end end @@ -113,50 +113,50 @@ class Tk::BWidget::MessageDlg if winfo_exist? @info = super() if TkComm::GET_CONFIGINFO_AS_ARRAY - @info << ['relative', 'parent'] + @info << ['relative', 'parent'] else - @info['relative'] = 'parent' + @info['relative'] = 'parent' end end if TkComm::GET_CONFIGINFO_AS_ARRAY if @info - if winfo_exist? - # update @keys - @info.each{|inf| @keys[inf[0]] = inf[-1] if inf.size > 2 } - end + if winfo_exist? + # update @keys + @info.each{|inf| @keys[inf[0]] = inf[-1] if inf.size > 2 } + end else - @info = [] - @keys.each{|k, v| - @info << [k, '', '', '', v] - } - @info << ['relative', 'parent'] + @info = [] + @keys.each{|k, v| + @info << [k, '', '', '', v] + } + @info << ['relative', 'parent'] end if slot - @info.asoc(slot.to_s).dup + @info.asoc(slot.to_s).dup else - @info.dup + @info.dup end else # ! TkComm::GET_CONFIGINFO_AS_ARRAY if @info - if winfo_exist? - # update @keys - @info.each{|k, inf| @keys[k] = inf[-1] if inf.size > 2 } - end + if winfo_exist? + # update @keys + @info.each{|k, inf| @keys[k] = inf[-1] if inf.size > 2 } + end else - @info = {} - @keys.each{|k, v| - @info[k] = ['', '', '', v] - } - @info['relative'] = 'parent' + @info = {} + @keys.each{|k, v| + @info[k] = ['', '', '', v] + } + @info['relative'] = 'parent' end if slot - @info[slot.to_s].dup + @info[slot.to_s].dup else - @info.dup + @info.dup end end end diff --git a/ext/tk/lib/tkextlib/bwidget/notebook.rb b/ext/tk/lib/tkextlib/bwidget/notebook.rb index 26c11ac0dd..e0cc04d30e 100644 --- a/ext/tk/lib/tkextlib/bwidget/notebook.rb +++ b/ext/tk/lib/tkextlib/bwidget/notebook.rb @@ -24,7 +24,7 @@ class Tk::BWidget::NoteBook class Event_for_Tabs < TkEvent::Event def self._get_extra_args_tbl [ - TkComm.method(:string) # page idenfier + TkComm.method(:string) # page idenfier ] end end diff --git a/ext/tk/lib/tkextlib/bwidget/passwddlg.rb b/ext/tk/lib/tkextlib/bwidget/passwddlg.rb index 399353367c..7136ae8d72 100644 --- a/ext/tk/lib/tkextlib/bwidget/passwddlg.rb +++ b/ext/tk/lib/tkextlib/bwidget/passwddlg.rb @@ -21,7 +21,7 @@ class Tk::BWidget::PasswdDlg def create login, passwd = simplelist(tk_call(self.class::TkCommandNames[0], - @path, *hash_kv(@keys))) + @path, *hash_kv(@keys))) [login, passwd] end end diff --git a/ext/tk/lib/tkextlib/bwidget/tree.rb b/ext/tk/lib/tkextlib/bwidget/tree.rb index f657e7148e..9a49a96bb7 100644 --- a/ext/tk/lib/tkextlib/bwidget/tree.rb +++ b/ext/tk/lib/tkextlib/bwidget/tree.rb @@ -27,7 +27,7 @@ class Tk::BWidget::Tree class Event_for_Items < TkEvent::Event def self._get_extra_args_tbl [ - TkComm.method(:string) # item idenfier + TkComm.method(:string) # item idenfier ] end end @@ -147,7 +147,7 @@ class Tk::BWidget::Tree def selection_add(*args) tk_send_without_enc('selection', 'add', - *(args.collect{|node| tagid(node)})) + *(args.collect{|node| tagid(node)})) self end @@ -162,30 +162,30 @@ class Tk::BWidget::Tree def selection_include?(*args) bool(tk_send_without_enc('selection', 'get', - *(args.collect{|node| tagid(node)}))) + *(args.collect{|node| tagid(node)}))) end def selection_range(*args) tk_send_without_enc('selection', 'range', - *(args.collect{|node| tagid(node)})) + *(args.collect{|node| tagid(node)})) self end def selection_remove(*args) tk_send_without_enc('selection', 'remove', - *(args.collect{|node| tagid(node)})) + *(args.collect{|node| tagid(node)})) self end def selection_set(*args) tk_send_without_enc('selection', 'set', - *(args.collect{|node| tagid(node)})) + *(args.collect{|node| tagid(node)})) self end def selection_toggle(*args) tk_send_without_enc('selection', 'toggle', - *(args.collect{|node| tagid(node)})) + *(args.collect{|node| tagid(node)})) self end @@ -218,16 +218,16 @@ class Tk::BWidget::Tree::Node @tree = tree parent = args.shift if parent.kind_of?(Tk::BWidget::Tree::Node) - if parent.tree.path != @tree.path - fail RuntimeError, 'tree of parent node is not match' - end + if parent.tree.path != @tree.path + fail RuntimeError, 'tree of parent node is not match' + end end elsif tree.kind_of?(Tk::BWidget::Tree::Node) @tree = tree.tree parent = tree.parent else fail RuntimeError, - "expect Tk::BWidget::Tree or Tk::BWidget::Tree::Node for 1st argument" + "expect Tk::BWidget::Tree or Tk::BWidget::Tree::Node for 1st argument" end if args[-1].kind_of?(Hash) diff --git a/ext/tk/lib/tkextlib/itcl/incr_tcl.rb b/ext/tk/lib/tkextlib/itcl/incr_tcl.rb index 9e53a9be8b..c03f3c36cb 100644 --- a/ext/tk/lib/tkextlib/itcl/incr_tcl.rb +++ b/ext/tk/lib/tkextlib/itcl/incr_tcl.rb @@ -24,9 +24,9 @@ module Tk def self.package_version begin - TkPackage.require('Itcl') + TkPackage.require('Itcl') rescue - '' + '' end end @@ -39,59 +39,59 @@ module Tk ITCL_OBJ_TBL = {}.taint def initialize(*args) - if (@klass = self.class::ITCL_CLASSNAME).empty? - fail RuntimeError, 'unknown itcl class (abstract class?)' - end - @id = Tk::Itcl::ItclObject::TCL_OBJ_ID.join(TkCore::INTERP._ip_id_) - @path = @id - Tk::Itcl::ItclObject::ITCL_OBJ_ID[1].succ! + if (@klass = self.class::ITCL_CLASSNAME).empty? + fail RuntimeError, 'unknown itcl class (abstract class?)' + end + @id = Tk::Itcl::ItclObject::TCL_OBJ_ID.join(TkCore::INTERP._ip_id_) + @path = @id + Tk::Itcl::ItclObject::ITCL_OBJ_ID[1].succ! end def self.call_proc(name, *args) - tk_call("#{ITCL_CLASSNAME}::#{cmd}", *args) + tk_call("#{ITCL_CLASSNAME}::#{cmd}", *args) end def call_method(name, *args) - tk_call(@path, name, *args) + tk_call(@path, name, *args) end def isa(klass) - bool(tk_call(@path, 'isa', klass)) + bool(tk_call(@path, 'isa', klass)) end alias itcl_kind_of? isa def info_class - tk_call(@path, 'info', 'class') + tk_call(@path, 'info', 'class') end def info_inherit - simplelist(tk_call(@path, 'info', 'inherit')) + simplelist(tk_call(@path, 'info', 'inherit')) end def info_heritage - list(tk_call(@path, 'info', 'heritage')) + list(tk_call(@path, 'info', 'heritage')) end def info_function(*args) - if args[-1].kind_of?(Array) - params = args.pop - params.each{|param| - param = param.to_s - args << ( (param[0] == ?-)? param: "-#{param}" ) - } - end - list(tk_call(@path, 'info', 'function', *args)) + if args[-1].kind_of?(Array) + params = args.pop + params.each{|param| + param = param.to_s + args << ( (param[0] == ?-)? param: "-#{param}" ) + } + end + list(tk_call(@path, 'info', 'function', *args)) end def info_variable(*args) - if args[-1].kind_of?(Array) - params = args.pop - params.each{|param| - param = param.to_s - args << ( (param[0] == ?-)? param: "-#{param}" ) - } - end - list(tk_call(@path, 'info', 'variable', *args)) + if args[-1].kind_of?(Array) + params = args.pop + params.each{|param| + param = param.to_s + args << ( (param[0] == ?-)? param: "-#{param}" ) + } + end + list(tk_call(@path, 'info', 'variable', *args)) end end diff --git a/ext/tk/lib/tkextlib/itk/incr_tk.rb b/ext/tk/lib/tkextlib/itk/incr_tk.rb index 84143a3ea3..a52c43e518 100644 --- a/ext/tk/lib/tkextlib/itk/incr_tk.rb +++ b/ext/tk/lib/tkextlib/itk/incr_tk.rb @@ -22,9 +22,9 @@ module Tk def self.package_version begin - TkPackage.require('Itk') + TkPackage.require('Itk') rescue - '' + '' end end @@ -44,59 +44,59 @@ module Tk # WidgetClassNames[WidgetClassName] = self def self.to_eval - '::itk::' << self::WidgetClassName + '::itk::' << self::WidgetClassName end def __destroy_hook__ - Tk::Itk::Component::ComponentID_TBL.delete(self.path) + Tk::Itk::Component::ComponentID_TBL.delete(self.path) end #### [incr Tk] public methods def component - simplelist(tk_send('component')) + simplelist(tk_send('component')) end def component_path(name) - window(tk_send('component', name)) + window(tk_send('component', name)) end alias component_widget component_path def component_invoke(name, cmd, *args) - window(tk_send('component', name, cmd, *args)) + window(tk_send('component', name, cmd, *args)) end def component_obj(*names) - names = component if names.empty? - names.collect{|name| Tk::Itk::Component.new(self.path, name) } + names = component if names.empty? + names.collect{|name| Tk::Itk::Component.new(self.path, name) } end #### [incr Tk] protected methods =begin def itk_component_add(visibility, name, create_cmds, option_cmds=None) - args = [] - visibility.each{|v| v = v.to_s; args << ( (v[0] == ?-)? v: "-#{v}" )} - args << '--' << name << create_cmd << option_cmds - tk_call('itk_component', 'add', *args) + args = [] + visibility.each{|v| v = v.to_s; args << ( (v[0] == ?-)? v: "-#{v}" )} + args << '--' << name << create_cmd << option_cmds + tk_call('itk_component', 'add', *args) end def itk_component_delete(*names) - tk_call('itk_component', 'delete', *names) + tk_call('itk_component', 'delete', *names) end def itk_initialize(keys={}) - tk_call('itk_initialize', keys) + tk_call('itk_initialize', keys) end def itk_option_add(*args) - tk_call('itk_option', 'add', *args) + tk_call('itk_option', 'add', *args) end def itk_option_define(name, resource, klass, init, config=None) - tk_call('itk_option', 'define', name, resource, klass, init, config) + tk_call('itk_option', 'define', name, resource, klass, init, config) end def itk_option_remove(*args) - tk_call('itk_option', 'remove', *args) + tk_call('itk_option', 'remove', *args) end =end end @@ -125,11 +125,11 @@ module Tk class Component < TkObject def __cget_cmd - [self.master, 'component', self.name, 'cget'] + [self.master, 'component', self.name, 'cget'] end def __config_cmd - [self.master, 'component', self.name, 'configure'] + [self.master, 'component', self.name, 'configure'] end ComponentID_TBL = TkCore::INTERP.create_table @@ -138,242 +138,242 @@ module Tk TkCore::INTERP.init_ip_env{ ComponentID_TBL.clear } def self.id2obj(master, id) - if master.kind_of?(TkObject) - master = master.path - else - master = master.to_s - end - return id unless ComponentID_TBL.key?(master) - (ComponentID_TBL.key?(id))? ComponentID_TBL[master][id]: id + if master.kind_of?(TkObject) + master = master.path + else + master = master.to_s + end + return id unless ComponentID_TBL.key?(master) + (ComponentID_TBL.key?(id))? ComponentID_TBL[master][id]: id end def self.new(master, component=nil) - if master.kind_of?(TkObject) - master = master.path - else - master = master.to_s - end - - if component.kind_of?(Tk::Itk::Component) - component = component.name - elsif component - component = component.to_s - else - component = Itk_Component_ID.join(TkCore::INTERP._ip_id_) - Itk_Component_ID[1].succ! - end - - if ComponentID_TBL.key?(master) - if ComponentID_TBL[master].key?(component) - return ComponentID_TBL[master][component] - end - else - ComponentID_TBL[master] = {} - end - - super(master, component) + if master.kind_of?(TkObject) + master = master.path + else + master = master.to_s + end + + if component.kind_of?(Tk::Itk::Component) + component = component.name + elsif component + component = component.to_s + else + component = Itk_Component_ID.join(TkCore::INTERP._ip_id_) + Itk_Component_ID[1].succ! + end + + if ComponentID_TBL.key?(master) + if ComponentID_TBL[master].key?(component) + return ComponentID_TBL[master][component] + end + else + ComponentID_TBL[master] = {} + end + + super(master, component) end def initialize(master, component) - @master = master - @component = component + @master = master + @component = component - ComponentID_TBL[@master][@component] = self + ComponentID_TBL[@master][@component] = self - begin - @widget = window(tk_call(@master, 'component', @component)) - @path = @widget.path - rescue - @widget = nil - @path = nil - end + begin + @widget = window(tk_call(@master, 'component', @component)) + @path = @widget.path + rescue + @widget = nil + @path = nil + end end def path - unless @path - begin - @widget = window(tk_call(@master, 'component', @component)) - @path = @widget.path - rescue - fail RuntimeError, 'component is not assigned to a widget' - end - end - @path + unless @path + begin + @widget = window(tk_call(@master, 'component', @component)) + @path = @widget.path + rescue + fail RuntimeError, 'component is not assigned to a widget' + end + end + @path end def epath - path() + path() end def to_eval - path() + path() end def master - @master + @master end def name - @component + @component end def widget - unless @widget - begin - @widget = window(tk_call(@master, 'component', @component)) - @path = @widget.path - rescue - fail RuntimeError, 'component is not assigned to a widget' - end - end - @widget + unless @widget + begin + @widget = window(tk_call(@master, 'component', @component)) + @path = @widget.path + rescue + fail RuntimeError, 'component is not assigned to a widget' + end + end + @widget end def widget_class - unless @widget - begin - @widget = window(tk_call(@master, 'component', @component)) - @path = @widget.path - @widget.classname - rescue - nil - end - end + unless @widget + begin + @widget = window(tk_call(@master, 'component', @component)) + @path = @widget.path + @widget.classname + rescue + nil + end + end end def method_missing(id, *args) - name = id.id2name - - # try 1 : component command - begin - return tk_call(@master, 'component', @component, name, *args) - rescue - end - - # try 2 : component configure - len = args.length - begin - case len - when 1 - if name[-1] == ?= - return configure(name[0..-2], args[0]) - else - return configure(name, args[0]) - end - when 0 - return cget(name) - end - rescue - end - - # try 3 : widget method or widget configure - begin - unless @widget - @widget = window(tk_call(@master, 'component', @component)) - @path = @widget.path - end - @widget.__send__(id, *args) - rescue - end - - # unknown method - fail RuntimeError, "unknown method '#{name}' for #{self.inspect}" + name = id.id2name + + # try 1 : component command + begin + return tk_call(@master, 'component', @component, name, *args) + rescue + end + + # try 2 : component configure + len = args.length + begin + case len + when 1 + if name[-1] == ?= + return configure(name[0..-2], args[0]) + else + return configure(name, args[0]) + end + when 0 + return cget(name) + end + rescue + end + + # try 3 : widget method or widget configure + begin + unless @widget + @widget = window(tk_call(@master, 'component', @component)) + @path = @widget.path + end + @widget.__send__(id, *args) + rescue + end + + # unknown method + fail RuntimeError, "unknown method '#{name}' for #{self.inspect}" end def tk_send(cmd, *rest) - begin - tk_call(@master, 'component', @component, cmd, *rest) - rescue - unless @path - begin - @widget = window(tk_call(@master, 'component', @component)) - @path = @widget.path - rescue - fail RuntimeError, 'component is not assigned to a widget' - end - end - tk_call(@path, cmd, *rest) - end + begin + tk_call(@master, 'component', @component, cmd, *rest) + rescue + unless @path + begin + @widget = window(tk_call(@master, 'component', @component)) + @path = @widget.path + rescue + fail RuntimeError, 'component is not assigned to a widget' + end + end + tk_call(@path, cmd, *rest) + end end def tk_send_without_enc(cmd, *rest) - begin - tk_call_without_enc(@master, 'component', @component, cmd, *rest) - rescue - unless @path - begin - @widget = window(tk_call(@master, 'component', @component)) - @path = @widget.path - rescue - fail RuntimeError, 'component is not assigned to a widget' - end - end - tk_call_without_enc(@path, cmd, *rest) - end + begin + tk_call_without_enc(@master, 'component', @component, cmd, *rest) + rescue + unless @path + begin + @widget = window(tk_call(@master, 'component', @component)) + @path = @widget.path + rescue + fail RuntimeError, 'component is not assigned to a widget' + end + end + tk_call_without_enc(@path, cmd, *rest) + end end def tk_send_with_enc(cmd, *rest) - begin - tk_call_with_enc(@master, 'component', @component, cmd, *rest) - rescue - unless @path - begin - @widget = window(tk_call(@master, 'component', @component)) - @path = @widget.path - rescue - fail RuntimeError, 'component is not assigned to a widget' - end - end - tk_call_with_enc(@path, cmd, *rest) - end + begin + tk_call_with_enc(@master, 'component', @component, cmd, *rest) + rescue + unless @path + begin + @widget = window(tk_call(@master, 'component', @component)) + @path = @widget.path + rescue + fail RuntimeError, 'component is not assigned to a widget' + end + end + tk_call_with_enc(@path, cmd, *rest) + end end def bind(*args) - unless @widget - begin - @widget = window(tk_call(@master, 'component', @component)) - @path = @widget.path - rescue - fail RuntimeError, 'component is not assigned to a widget' - end - end - @widget.bind(*args) + unless @widget + begin + @widget = window(tk_call(@master, 'component', @component)) + @path = @widget.path + rescue + fail RuntimeError, 'component is not assigned to a widget' + end + end + @widget.bind(*args) end def bind_append(*args) - unless @widget - begin - @widget = window(tk_call(@master, 'component', @component)) - @path = @widget.path - rescue - fail RuntimeError, 'component is not assigned to a widget' - end - end - @widget.bind_append(*args) + unless @widget + begin + @widget = window(tk_call(@master, 'component', @component)) + @path = @widget.path + rescue + fail RuntimeError, 'component is not assigned to a widget' + end + end + @widget.bind_append(*args) end def bind_remove(*args) - unless @widget - begin - @widget = window(tk_call(@master, 'component', @component)) - @path = @widget.path - rescue - fail RuntimeError, 'component is not assigned to a widget' - end - end - @widget.bind_remove(*args) + unless @widget + begin + @widget = window(tk_call(@master, 'component', @component)) + @path = @widget.path + rescue + fail RuntimeError, 'component is not assigned to a widget' + end + end + @widget.bind_remove(*args) end def bindinfo(*args) - unless @widget - begin - @widget = window(tk_call(@master, 'component', @component)) - @path = @widget.path - rescue - fail RuntimeError, 'component is not assigned to a widget' - end - end - @widget.bindinfo(*args) + unless @widget + begin + @widget = window(tk_call(@master, 'component', @component)) + @path = @widget.path + rescue + fail RuntimeError, 'component is not assigned to a widget' + end + end + @widget.bindinfo(*args) end end diff --git a/ext/tk/lib/tkextlib/iwidgets.rb b/ext/tk/lib/tkextlib/iwidgets.rb index b76fb79cc1..5ef82f68ca 100644 --- a/ext/tk/lib/tkextlib/iwidgets.rb +++ b/ext/tk/lib/tkextlib/iwidgets.rb @@ -25,9 +25,9 @@ module Tk def self.package_version begin - TkPackage.require('Iwidgets') + TkPackage.require('Iwidgets') rescue - '' + '' end end diff --git a/ext/tk/lib/tkextlib/iwidgets/calendar.rb b/ext/tk/lib/tkextlib/iwidgets/calendar.rb index dab10b118b..f382cfd143 100644 --- a/ext/tk/lib/tkextlib/iwidgets/calendar.rb +++ b/ext/tk/lib/tkextlib/iwidgets/calendar.rb @@ -30,7 +30,7 @@ class Tk::Iwidgets::Calendar _setup_subst_table(KEY_TBL, PROC_TBL); def self.ret_val(val) - val + val end end diff --git a/ext/tk/lib/tkextlib/iwidgets/entryfield.rb b/ext/tk/lib/tkextlib/iwidgets/entryfield.rb index 300573bcec..ae7d63f3f3 100644 --- a/ext/tk/lib/tkextlib/iwidgets/entryfield.rb +++ b/ext/tk/lib/tkextlib/iwidgets/entryfield.rb @@ -26,16 +26,16 @@ class Tk::Iwidgets::Entryfield #class CalCmdArgs < TkUtil::CallbackSubst class ValidateArgs < TkUtil::CallbackSubst KEY_TBL = [ - [ ?c, ?s, :char ], - [ ?P, ?s, :post ], - [ ?S, ?s, :current ], - [ ?W, ?w, :widget ], - nil + [ ?c, ?s, :char ], + [ ?P, ?s, :post ], + [ ?S, ?s, :current ], + [ ?W, ?w, :widget ], + nil ] PROC_TBL = [ - [ ?s, TkComm.method(:string) ], - [ ?w, TkComm.method(:window) ], - nil + [ ?s, TkComm.method(:string) ], + [ ?w, TkComm.method(:window) ], + nil ] _setup_subst_table(KEY_TBL, PROC_TBL); end diff --git a/ext/tk/lib/tkextlib/iwidgets/hierarchy.rb b/ext/tk/lib/tkextlib/iwidgets/hierarchy.rb index a7024356ac..077d84c7a4 100644 --- a/ext/tk/lib/tkextlib/iwidgets/hierarchy.rb +++ b/ext/tk/lib/tkextlib/iwidgets/hierarchy.rb @@ -33,7 +33,7 @@ class Tk::Iwidgets::Hierarchy _setup_subst_table(KEY_TBL, PROC_TBL); def self.ret_val(val) - val + val end end @@ -46,21 +46,21 @@ class Tk::Iwidgets::Hierarchy class IndicatorCommand < TkValidateCommand class ValidateArgs < TkUtil::CallbackSubst KEY_TBL = [ - [ ?n, ?s, :node ], - [ ?s, ?b, :status ], - nil + [ ?n, ?s, :node ], + [ ?s, ?b, :status ], + nil ] PROC_TBL = [ - [ ?s, TkComm.method(:string) ], - [ ?b, TkComm.method(:bool) ], - nil + [ ?s, TkComm.method(:string) ], + [ ?b, TkComm.method(:bool) ], + nil ] _setup_subst_table(KEY_TBL, PROC_TBL); def self.ret_val(val) - val + val end end @@ -73,15 +73,15 @@ class Tk::Iwidgets::Hierarchy class IconCommand < TkValidateCommand class ValidateArgs < TkUtil::CallbackSubst KEY_TBL = [ - [ ?n, ?s, :node ], - [ ?i, ?s, :icon ], - nil + [ ?n, ?s, :node ], + [ ?i, ?s, :icon ], + nil ] PROC_TBL = [ [ ?s, TkComm.method(:string) ], nil ] _setup_subst_table(KEY_TBL, PROC_TBL); def self.ret_val(val) - val + val end end @@ -200,7 +200,7 @@ class Tk::Iwidgets::Hierarchy def compare(idx1, op, idx2) bool(tk_send_without_enc('compare', _get_eval_enc_str(idx1), - op, _get_eval_enc_str(idx2))) + op, _get_eval_enc_str(idx2))) end def debug @@ -234,16 +234,16 @@ class Tk::Iwidgets::Hierarchy # multiple chars-taglist argument :: str, [tag,...], str, [tag,...], ... args = [chars] while tags.size > 0 - args << tags.shift.collect{|x|_get_eval_string(x)}.join(' ') # taglist - args << tags.shift if tags.size > 0 # chars + args << tags.shift.collect{|x|_get_eval_string(x)}.join(' ') # taglist + args << tags.shift if tags.size > 0 # chars end super index, *args else # single chars-taglist argument :: str, tag, tag, ... if tags.size == 0 - super index, chars + super index, chars else - super index, chars, tags.collect{|x|_get_eval_string(x)}.join(' ') + super index, chars, tags.collect{|x|_get_eval_string(x)}.join(' ') end end end diff --git a/ext/tk/lib/tkextlib/iwidgets/menubar.rb b/ext/tk/lib/tkextlib/iwidgets/menubar.rb index b4c94ff564..b60349be17 100644 --- a/ext/tk/lib/tkextlib/iwidgets/menubar.rb +++ b/ext/tk/lib/tkextlib/iwidgets/menubar.rb @@ -70,41 +70,41 @@ class Tk::Iwidgets::Menubar next unless spec if spec.kind_of?(Hash) - args = [spec] - type = 'options' + args = [spec] + type = 'options' else - type, *args = spec + type, *args = spec end type = type.to_s case type when 'options' - keys = args[0] - ary = [type] - ary.concat(hash_kv(keys)) - ret << array2tk_list(ary) << "\n" + keys = args[0] + ary = [type] + ary.concat(hash_kv(keys)) + ret << array2tk_list(ary) << "\n" when 'menubutton', 'cascade' - name, keys = args - if keys - ary = [type, name] - keys = _symbolkey2str(keys) - keys['menu'] = _parse_menu_spec(keys['menu']) if keys.key?('menu') - ary.concat(hash_kv(keys)) - ret << array2tk_list(ary) << "\n" - else - ret << array2tk_list([type, name]) << "\n" - end + name, keys = args + if keys + ary = [type, name] + keys = _symbolkey2str(keys) + keys['menu'] = _parse_menu_spec(keys['menu']) if keys.key?('menu') + ary.concat(hash_kv(keys)) + ret << array2tk_list(ary) << "\n" + else + ret << array2tk_list([type, name]) << "\n" + end else - name, keys = args - if keys - ary = [type, name] - ary.concat(hash_kv(keys)) - ret << array2tk_list(ary) << "\n" - else - ret << array2tk_list([type, name]) << "\n" - end + name, keys = args + if keys + ary = [type, name] + ary.concat(hash_kv(keys)) + ret << array2tk_list(ary) << "\n" + else + ret << array2tk_list([type, name]) << "\n" + end end } ret diff --git a/ext/tk/lib/tkextlib/iwidgets/notebook.rb b/ext/tk/lib/tkextlib/iwidgets/notebook.rb index 511ee3dff3..d9abf1b02b 100644 --- a/ext/tk/lib/tkextlib/iwidgets/notebook.rb +++ b/ext/tk/lib/tkextlib/iwidgets/notebook.rb @@ -72,7 +72,7 @@ class Tk::Iwidgets::Notebook end if idx2 if (new_idx2 = self.index(idx2)) < 0 - new_idx2 = tagid(idx2) + new_idx2 = tagid(idx2) end tk_call(@path, 'delete', new_idx1, new_idx2) else diff --git a/ext/tk/lib/tkextlib/iwidgets/scrolledcanvas.rb b/ext/tk/lib/tkextlib/iwidgets/scrolledcanvas.rb index c5ed19c1f1..c26eda1586 100644 --- a/ext/tk/lib/tkextlib/iwidgets/scrolledcanvas.rb +++ b/ext/tk/lib/tkextlib/iwidgets/scrolledcanvas.rb @@ -94,7 +94,7 @@ class Tk::Iwidgets::Scrolledcanvas def bbox(tagOrId, *tags) list(tk_send_without_enc('bbox', tagid(tagOrId), - *tags.collect{|t| tagid(t)})) + *tags.collect{|t| tagid(t)})) end def itembind(tag, context, cmd=Proc.new, args=nil) @@ -136,14 +136,14 @@ class Tk::Iwidgets::Scrolledcanvas def dchars(tag, first, last=None) tk_send_without_enc('dchars', tagid(tag), - _get_eval_enc_str(first), _get_eval_enc_str(last)) + _get_eval_enc_str(first), _get_eval_enc_str(last)) self end def delete(*args) if TkcItem::CItemID_TBL[self.path] find('withtag', *args).each{|item| - TkcItem::CItemID_TBL[self.path].delete(item.id) + TkcItem::CItemID_TBL[self.path].delete(item.id) } end tk_send_without_enc('delete', *args.collect{|t| tagid(t)}) @@ -190,9 +190,9 @@ class Tk::Iwidgets::Scrolledcanvas else ret = tk_send_without_enc('focus') if ret == "" - nil + nil else - TkcItem.id2obj(self, ret) + TkcItem.id2obj(self, ret) end end end @@ -214,7 +214,7 @@ class Tk::Iwidgets::Scrolledcanvas def insert(tagOrId, index, string) tk_send_without_enc('insert', tagid(tagOrId), index, - _get_eval_enc_str(string)) + _get_eval_enc_str(string)) self end diff --git a/ext/tk/lib/tkextlib/iwidgets/scrolledtext.rb b/ext/tk/lib/tkextlib/iwidgets/scrolledtext.rb index 95d1034f16..39a9ed63c8 100644 --- a/ext/tk/lib/tkextlib/iwidgets/scrolledtext.rb +++ b/ext/tk/lib/tkextlib/iwidgets/scrolledtext.rb @@ -77,7 +77,7 @@ class Tk::Iwidgets::Scrolledtext end def compare(idx1, op, idx2) bool(tk_send_without_enc('compare', _get_eval_enc_str(idx1), - op, _get_eval_enc_str(idx2))) + op, _get_eval_enc_str(idx2))) end def debug @@ -110,24 +110,24 @@ class Tk::Iwidgets::Scrolledtext case slot.to_s when 'text', 'label', 'show', 'data', 'file' _fromUTF8(tk_send_without_enc('image', 'cget', - _get_eval_enc_str(index), "-#{slot}")) + _get_eval_enc_str(index), "-#{slot}")) else tk_tcl2ruby(_fromUTF8(tk_send_without_enc('image', 'cget', - _get_eval_enc_str(index), - "-#{slot}"))) + _get_eval_enc_str(index), + "-#{slot}"))) end end def image_configure(index, slot, value=None) if slot.kind_of? Hash _fromUTF8(tk_send_without_enc('image', 'configure', - _get_eval_enc_str(index), - *hash_kv(slot, true))) + _get_eval_enc_str(index), + *hash_kv(slot, true))) else _fromUTF8(tk_send_without_enc('image', 'configure', - _get_eval_enc_str(index), - "-#{slot}", - _get_eval_enc_str(value))) + _get_eval_enc_str(index), + "-#{slot}", + _get_eval_enc_str(value))) end self end @@ -135,80 +135,80 @@ class Tk::Iwidgets::Scrolledtext def image_configinfo(index, slot = nil) if TkComm::GET_CONFIGINFO_AS_ARRAY if slot - case slot.to_s - when 'text', 'label', 'show', 'data', 'file' - conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index), "-#{slot}"))) - else - conf = tk_split_list(_fromUTF8(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index), "-#{slot}"))) - end - conf[0] = conf[0][1..-1] - conf + case slot.to_s + when 'text', 'label', 'show', 'data', 'file' + conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index), "-#{slot}"))) + else + conf = tk_split_list(_fromUTF8(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index), "-#{slot}"))) + end + conf[0] = conf[0][1..-1] + conf else - tk_split_simplelist(_fromUTF8(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index)))).collect{|conflist| - conf = tk_split_simplelist(conflist) - conf[0] = conf[0][1..-1] - case conf[0] - when 'text', 'label', 'show', 'data', 'file' - else - if conf[3] - if conf[3].index('{') - conf[3] = tk_split_list(conf[3]) - else - conf[3] = tk_tcl2ruby(conf[3]) - end - end - if conf[4] - if conf[4].index('{') - conf[4] = tk_split_list(conf[4]) - else - conf[4] = tk_tcl2ruby(conf[4]) - end - end - end - conf[1] = conf[1][1..-1] if conf.size == 2 # alias info - conf - } + tk_split_simplelist(_fromUTF8(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index)))).collect{|conflist| + conf = tk_split_simplelist(conflist) + conf[0] = conf[0][1..-1] + case conf[0] + when 'text', 'label', 'show', 'data', 'file' + else + if conf[3] + if conf[3].index('{') + conf[3] = tk_split_list(conf[3]) + else + conf[3] = tk_tcl2ruby(conf[3]) + end + end + if conf[4] + if conf[4].index('{') + conf[4] = tk_split_list(conf[4]) + else + conf[4] = tk_tcl2ruby(conf[4]) + end + end + end + conf[1] = conf[1][1..-1] if conf.size == 2 # alias info + conf + } end else # ! TkComm::GET_CONFIGINFO_AS_ARRAY if slot - case slot.to_s - when 'text', 'label', 'show', 'data', 'file' - conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index), "-#{slot}"))) - else - conf = tk_split_list(_fromUTF8(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index), "-#{slot}"))) - end - key = conf.shift[1..-1] - { key => conf } + case slot.to_s + when 'text', 'label', 'show', 'data', 'file' + conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index), "-#{slot}"))) + else + conf = tk_split_list(_fromUTF8(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index), "-#{slot}"))) + end + key = conf.shift[1..-1] + { key => conf } else - ret = {} - tk_split_simplelist(_fromUTF8(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index)))).each{|conflist| - conf = tk_split_simplelist(conflist) - key = conf.shift[1..-1] - case key - when 'text', 'label', 'show', 'data', 'file' - else - if conf[2] - if conf[2].index('{') - conf[2] = tk_split_list(conf[2]) - else - conf[2] = tk_tcl2ruby(conf[2]) - end - end - if conf[3] - if conf[3].index('{') - conf[3] = tk_split_list(conf[3]) - else - conf[3] = tk_tcl2ruby(conf[3]) - end - end - end - if conf.size == 1 - ret[key] = conf[0][1..-1] # alias info - else - ret[key] = conf - end - } - ret + ret = {} + tk_split_simplelist(_fromUTF8(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index)))).each{|conflist| + conf = tk_split_simplelist(conflist) + key = conf.shift[1..-1] + case key + when 'text', 'label', 'show', 'data', 'file' + else + if conf[2] + if conf[2].index('{') + conf[2] = tk_split_list(conf[2]) + else + conf[2] = tk_tcl2ruby(conf[2]) + end + end + if conf[3] + if conf[3].index('{') + conf[3] = tk_split_list(conf[3]) + else + conf[3] = tk_tcl2ruby(conf[3]) + end + end + end + if conf.size == 1 + ret[key] = conf[0][1..-1] # alias info + else + ret[key] = conf + end + } + ret end end end @@ -216,19 +216,19 @@ class Tk::Iwidgets::Scrolledtext def current_image_configinfo(index, slot = nil) if TkComm::GET_CONFIGINFO_AS_ARRAY if slot - conf = image_configinfo(index, slot) - {conf[0] => conf[4]} + conf = image_configinfo(index, slot) + {conf[0] => conf[4]} else - ret = {} - image_configinfo(index).each{|conf| - ret[conf[0]] = conf[4] if conf.size > 2 - } - ret + ret = {} + image_configinfo(index).each{|conf| + ret[conf[0]] = conf[4] if conf.size > 2 + } + ret end else # ! TkComm::GET_CONFIGINFO_AS_ARRAY ret = {} image_configinfo(index, slot).each{|k, conf| - ret[k] = conf[-1] if conf.kind_of?(Array) + ret[k] = conf[-1] if conf.kind_of?(Array) } ret end @@ -258,7 +258,7 @@ class Tk::Iwidgets::Scrolledtext def mark_gravity(mark, direction=nil) if direction tk_send_without_enc('mark', 'gravity', - _get_eval_enc_str(mark), direction) + _get_eval_enc_str(mark), direction) self else tk_send_without_enc('mark', 'gravity', _get_eval_enc_str(mark)) @@ -267,27 +267,27 @@ class Tk::Iwidgets::Scrolledtext def mark_set(mark, index) tk_send_without_enc('mark', 'set', _get_eval_enc_str(mark), - _get_eval_enc_str(index)) + _get_eval_enc_str(index)) self end alias set_mark mark_set def mark_unset(*marks) tk_send_without_enc('mark', 'unset', - *(marks.collect{|mark| _get_eval_enc_str(mark)})) + *(marks.collect{|mark| _get_eval_enc_str(mark)})) self end alias unset_mark mark_unset def mark_next(index) tagid2obj(_fromUTF8(tk_send_without_enc('mark', 'next', - _get_eval_enc_str(index)))) + _get_eval_enc_str(index)))) end alias next_mark mark_next def mark_previous(index) tagid2obj(_fromUTF8(tk_send_without_enc('mark', 'previous', - _get_eval_enc_str(index)))) + _get_eval_enc_str(index)))) end alias previous_mark mark_previous @@ -309,14 +309,14 @@ class Tk::Iwidgets::Scrolledtext # $KCODE == 'NONE' if JAPANIZED_TK tk_call_without_enc('kstring', 'length', - _get_eval_enc_str(txt)).to_i + _get_eval_enc_str(txt)).to_i else begin - tk_call_without_enc('encoding', 'convertto', 'ascii', - _get_eval_enc_str(txt)).length + tk_call_without_enc('encoding', 'convertto', 'ascii', + _get_eval_enc_str(txt)).length rescue StandardError, NameError - # sorry, I have no plan - txt.length + # sorry, I have no plan + txt.length end end end @@ -368,53 +368,53 @@ class Tk::Iwidgets::Scrolledtext return ["", 0] if compare(start,'>=',stop) txt = get(start,stop) if (pos = txt.index(pat)) - match = $& - #pos = txt[0..(pos-1)].split('').length if pos > 0 - pos = _ktext_length(txt[0..(pos-1)]) if pos > 0 - if pat.kind_of? String - #return [index(start + " + #{pos} chars"), pat.split('').length] - return [index(start + " + #{pos} chars"), - _ktext_length(pat), pat.dup] - else - #return [index(start + " + #{pos} chars"), $&.split('').length] - return [index(start + " + #{pos} chars"), - _ktext_length(match), match] - end + match = $& + #pos = txt[0..(pos-1)].split('').length if pos > 0 + pos = _ktext_length(txt[0..(pos-1)]) if pos > 0 + if pat.kind_of? String + #return [index(start + " + #{pos} chars"), pat.split('').length] + return [index(start + " + #{pos} chars"), + _ktext_length(pat), pat.dup] + else + #return [index(start + " + #{pos} chars"), $&.split('').length] + return [index(start + " + #{pos} chars"), + _ktext_length(match), match] + end else - return ["", 0] + return ["", 0] end else txt = get(start,'end - 1 char') if (pos = txt.index(pat)) - match = $& - #pos = txt[0..(pos-1)].split('').length if pos > 0 - pos = _ktext_length(txt[0..(pos-1)]) if pos > 0 - if pat.kind_of? String - #return [index(start + " + #{pos} chars"), pat.split('').length] - return [index(start + " + #{pos} chars"), - _ktext_length(pat), pat.dup] - else - #return [index(start + " + #{pos} chars"), $&.split('').length] - return [index(start + " + #{pos} chars"), - _ktext_length(match), match] - end + match = $& + #pos = txt[0..(pos-1)].split('').length if pos > 0 + pos = _ktext_length(txt[0..(pos-1)]) if pos > 0 + if pat.kind_of? String + #return [index(start + " + #{pos} chars"), pat.split('').length] + return [index(start + " + #{pos} chars"), + _ktext_length(pat), pat.dup] + else + #return [index(start + " + #{pos} chars"), $&.split('').length] + return [index(start + " + #{pos} chars"), + _ktext_length(match), match] + end else - txt = get('1.0','end - 1 char') - if (pos = txt.index(pat)) - match = $& - #pos = txt[0..(pos-1)].split('').length if pos > 0 - pos = _ktext_length(txt[0..(pos-1)]) if pos > 0 - if pat.kind_of? String - #return [index("1.0 + #{pos} chars"), pat.split('').length] - return [index("1.0 + #{pos} chars"), - _ktext_length(pat), pat.dup] - else - #return [index("1.0 + #{pos} chars"), $&.split('').length] - return [index("1.0 + #{pos} chars"), _ktext_length(match), match] - end - else - return ["", 0] - end + txt = get('1.0','end - 1 char') + if (pos = txt.index(pat)) + match = $& + #pos = txt[0..(pos-1)].split('').length if pos > 0 + pos = _ktext_length(txt[0..(pos-1)]) if pos > 0 + if pat.kind_of? String + #return [index("1.0 + #{pos} chars"), pat.split('').length] + return [index("1.0 + #{pos} chars"), + _ktext_length(pat), pat.dup] + else + #return [index("1.0 + #{pos} chars"), $&.split('').length] + return [index("1.0 + #{pos} chars"), _ktext_length(match), match] + end + else + return ["", 0] + end end end end @@ -429,48 +429,48 @@ class Tk::Iwidgets::Scrolledtext return ["", 0] if compare(start,'<=',stop) txt = get(stop,start) if (pos = txt.rindex(pat)) - match = $& - #pos = txt[0..(pos-1)].split('').length if pos > 0 - pos = _ktext_length(txt[0..(pos-1)]) if pos > 0 - if pat.kind_of? String - #return [index(stop + " + #{pos} chars"), pat.split('').length] - return [index(stop + " + #{pos} chars"), _ktext_length(pat), pat.dup] - else - #return [index(stop + " + #{pos} chars"), $&.split('').length] - return [index(stop + " + #{pos} chars"), _ktext_length(match), match] - end + match = $& + #pos = txt[0..(pos-1)].split('').length if pos > 0 + pos = _ktext_length(txt[0..(pos-1)]) if pos > 0 + if pat.kind_of? String + #return [index(stop + " + #{pos} chars"), pat.split('').length] + return [index(stop + " + #{pos} chars"), _ktext_length(pat), pat.dup] + else + #return [index(stop + " + #{pos} chars"), $&.split('').length] + return [index(stop + " + #{pos} chars"), _ktext_length(match), match] + end else - return ["", 0] + return ["", 0] end else txt = get('1.0',start) if (pos = txt.rindex(pat)) - match = $& - #pos = txt[0..(pos-1)].split('').length if pos > 0 - pos = _ktext_length(txt[0..(pos-1)]) if pos > 0 - if pat.kind_of? String - #return [index("1.0 + #{pos} chars"), pat.split('').length] - return [index("1.0 + #{pos} chars"), _ktext_length(pat), pat.dup] - else - #return [index("1.0 + #{pos} chars"), $&.split('').length] - return [index("1.0 + #{pos} chars"), _ktext_length(match), match] - end + match = $& + #pos = txt[0..(pos-1)].split('').length if pos > 0 + pos = _ktext_length(txt[0..(pos-1)]) if pos > 0 + if pat.kind_of? String + #return [index("1.0 + #{pos} chars"), pat.split('').length] + return [index("1.0 + #{pos} chars"), _ktext_length(pat), pat.dup] + else + #return [index("1.0 + #{pos} chars"), $&.split('').length] + return [index("1.0 + #{pos} chars"), _ktext_length(match), match] + end else - txt = get('1.0','end - 1 char') - if (pos = txt.rindex(pat)) - match = $& - #pos = txt[0..(pos-1)].split('').length if pos > 0 - pos = _ktext_length(txt[0..(pos-1)]) if pos > 0 - if pat.kind_of? String - #return [index("1.0 + #{pos} chars"), pat.split('').length] - return [index("1.0 + #{pos} chars"), _ktext_length(pat), pat.dup] - else - #return [index("1.0 + #{pos} chars"), $&.split('').length] - return [index("1.0 + #{pos} chars"), _ktext_length(match), match] - end - else - return ["", 0] - end + txt = get('1.0','end - 1 char') + if (pos = txt.rindex(pat)) + match = $& + #pos = txt[0..(pos-1)].split('').length if pos > 0 + pos = _ktext_length(txt[0..(pos-1)]) if pos > 0 + if pat.kind_of? String + #return [index("1.0 + #{pos} chars"), pat.split('').length] + return [index("1.0 + #{pos} chars"), _ktext_length(pat), pat.dup] + else + #return [index("1.0 + #{pos} chars"), $&.split('').length] + return [index("1.0 + #{pos} chars"), _ktext_length(match), match] + end + else + return ["", 0] + end end end end diff --git a/ext/tk/lib/tkextlib/iwidgets/spinner.rb b/ext/tk/lib/tkextlib/iwidgets/spinner.rb index f4f0eb46c8..b5c72b4df8 100644 --- a/ext/tk/lib/tkextlib/iwidgets/spinner.rb +++ b/ext/tk/lib/tkextlib/iwidgets/spinner.rb @@ -26,16 +26,16 @@ class Tk::Iwidgets::Spinner #class CalCmdArgs < TkUtil::CallbackSubst class ValidateArgs < TkUtil::CallbackSubst KEY_TBL = [ - [ ?c, ?s, :char ], - [ ?P, ?s, :post ], - [ ?S, ?s, :current ], - [ ?W, ?w, :widget ], - nil + [ ?c, ?s, :char ], + [ ?P, ?s, :post ], + [ ?S, ?s, :current ], + [ ?W, ?w, :widget ], + nil ] PROC_TBL = [ - [ ?s, TkComm.method(:string) ], - [ ?w, TkComm.method(:window) ], - nil + [ ?s, TkComm.method(:string) ], + [ ?w, TkComm.method(:window) ], + nil ] _setup_subst_table(KEY_TBL, PROC_TBL); end diff --git a/ext/tk/lib/tkextlib/iwidgets/toolbar.rb b/ext/tk/lib/tkextlib/iwidgets/toolbar.rb index fffd5b388c..a2a7f31627 100644 --- a/ext/tk/lib/tkextlib/iwidgets/toolbar.rb +++ b/ext/tk/lib/tkextlib/iwidgets/toolbar.rb @@ -81,7 +81,7 @@ class Tk::Iwidgets::Toolbar tag = Tk::Itk::Component.new(self) end window(tk_call(@path, 'insert', index(idx), type, - tagid(tag), *hash_kv(keys))) + tagid(tag), *hash_kv(keys))) tag end end diff --git a/ext/tk/lib/tkextlib/pkg_checker.rb b/ext/tk/lib/tkextlib/pkg_checker.rb index 5ebf675189..5002ed7ff8 100755 --- a/ext/tk/lib/tkextlib/pkg_checker.rb +++ b/ext/tk/lib/tkextlib/pkg_checker.rb @@ -100,29 +100,29 @@ def check_pkg(file, verbose=false) begin case type when :package - ver = TkPackage.require(name) - success_list[name] = ver - error_list.delete_if{|n, t| n == name} + ver = TkPackage.require(name) + success_list[name] = ver + error_list.delete_if{|n, t| n == name} when :library - Tk.load_tcllibrary(name) - success_list[name] = :library - error_list.delete_if{|n, t| n == name} + Tk.load_tcllibrary(name) + success_list[name] = :library + error_list.delete_if{|n, t| n == name} when :script - Tk.load_tclscript(name) - success_list[name] = :script - error_list.delete_if{|n, t| n == name} + Tk.load_tclscript(name) + success_list[name] = :script + error_list.delete_if{|n, t| n == name} when :require_ruby_lib - require name + require name end rescue => e if verbose - error_list << [name, type, e.message] + error_list << [name, type, e.message] else - error_list << [name, type] + error_list << [name, type] end end } @@ -130,8 +130,8 @@ def check_pkg(file, verbose=false) success_list.dup.each{|name, ver| unless ver.kind_of?(String) begin - ver = TkPackage.require(name) - sccess_list[name] = ver + ver = TkPackage.require(name) + sccess_list[name] = ver rescue end end @@ -149,10 +149,10 @@ def subdir_check(dir, verbose=false) path = File.join(dir, f) suc, err = check_pkg(path, verbose) if err.empty? - print 'Ready : ', path, ' : require->', suc.inspect, "\n" + print 'Ready : ', path, ' : require->', suc.inspect, "\n" else - print '*LACK : ', path, ' : require->', suc.inspect, - ' FAIL->', err.inspect, "\n" + print '*LACK : ', path, ' : require->', suc.inspect, + ' FAIL->', err.inspect, "\n" end end } diff --git a/ext/tk/lib/tkextlib/tcllib/autoscroll.rb b/ext/tk/lib/tkextlib/tcllib/autoscroll.rb index d0cb2812cb..34e34046c6 100644 --- a/ext/tk/lib/tkextlib/tcllib/autoscroll.rb +++ b/ext/tk/lib/tkextlib/tcllib/autoscroll.rb @@ -32,23 +32,23 @@ module Tk module Tcllib module Autoscroll def self.package_version - begin - TkPackage.require('autoscroll') - rescue - '' - end + begin + TkPackage.require('autoscroll') + rescue + '' + end end def self.not_available - fail RuntimeError, "'tkextlib/tcllib/autoscroll' extension is not available on your current environment." + fail RuntimeError, "'tkextlib/tcllib/autoscroll' extension is not available on your current environment." end def self.autoscroll(win) - Tk::Tcllib::Autoscroll.not_available + Tk::Tcllib::Autoscroll.not_available end def self.unautoscroll(win) - Tk::Tcllib::Autoscroll.not_available + Tk::Tcllib::Autoscroll.not_available end end end @@ -59,44 +59,44 @@ module Tk def autoscroll(mode = nil) case mode when :x, 'x' - if @xscrollbar - Tk::Tcllib::Autoscroll.autoscroll(@xscrollbar) - end + if @xscrollbar + Tk::Tcllib::Autoscroll.autoscroll(@xscrollbar) + end when :y, 'y' - if @yscrollbar - Tk::Tcllib::Autoscroll.autoscroll(@yscrollbar) - end + if @yscrollbar + Tk::Tcllib::Autoscroll.autoscroll(@yscrollbar) + end when nil, :both, 'both' - if @xscrollbar - Tk::Tcllib::Autoscroll.autoscroll(@xscrollbar) - end - if @yscrollbar - Tk::Tcllib::Autoscroll.autoscroll(@yscrollbar) - end + if @xscrollbar + Tk::Tcllib::Autoscroll.autoscroll(@xscrollbar) + end + if @yscrollbar + Tk::Tcllib::Autoscroll.autoscroll(@yscrollbar) + end else - fail ArgumentError, "'x', 'y' or 'both' (String or Symbol) is expected" + fail ArgumentError, "'x', 'y' or 'both' (String or Symbol) is expected" end self end def unautoscroll(mode = nil) case mode when :x, 'x' - if @xscrollbar - Tk::Tcllib::Autoscroll.unautoscroll(@xscrollbar) - end + if @xscrollbar + Tk::Tcllib::Autoscroll.unautoscroll(@xscrollbar) + end when :y, 'y' - if @yscrollbar - Tk::Tcllib::Autoscroll.unautoscroll(@yscrollbar) - end + if @yscrollbar + Tk::Tcllib::Autoscroll.unautoscroll(@yscrollbar) + end when nil, :both, 'both' - if @xscrollbar - Tk::Tcllib::Autoscroll.unautoscroll(@xscrollbar) - end - if @yscrollbar - Tk::Tcllib::Autoscroll.unautoscroll(@yscrollbar) - end + if @xscrollbar + Tk::Tcllib::Autoscroll.unautoscroll(@xscrollbar) + end + if @yscrollbar + Tk::Tcllib::Autoscroll.unautoscroll(@yscrollbar) + end else - fail ArgumentError, "'x', 'y' or 'both' (String or Symbol) is expected" + fail ArgumentError, "'x', 'y' or 'both' (String or Symbol) is expected" end self end @@ -130,11 +130,11 @@ module Tk module Autoscroll def self.autoscroll(win) - tk_call_without_enc('::autoscroll::autoscroll', win.path) + tk_call_without_enc('::autoscroll::autoscroll', win.path) end def self.unautoscroll(win) - tk_call_without_enc('::autoscroll::unautoscroll', win.path) + tk_call_without_enc('::autoscroll::unautoscroll', win.path) end end end diff --git a/ext/tk/lib/tkextlib/tcllib/ctext.rb b/ext/tk/lib/tkextlib/tcllib/ctext.rb index 0a043b1730..89bfeff0f3 100644 --- a/ext/tk/lib/tkextlib/tcllib/ctext.rb +++ b/ext/tk/lib/tkextlib/tcllib/ctext.rb @@ -17,11 +17,11 @@ module Tk module Tcllib class CText < TkText def self.package_version - begin - TkPackage.require('ctext') - rescue - '' - end + begin + TkPackage.require('ctext') + rescue + '' + end end end end @@ -80,19 +80,19 @@ class Tk::Tcllib::CText def add_highlight_class_for_special_chars(klass, col, *chrs) tk_call('ctext::addHighlightClassForSpecialChars', - @path, klass, col, chrs.join('')) + @path, klass, col, chrs.join('')) self end def add_highlight_class_for_regexp(klass, col, tcl_regexp) tk_call('ctext::addHighlightClassForRegexp', - @path, klass, col, tcl_regexp) + @path, klass, col, tcl_regexp) self end def add_highlight_class_with_only_char_start(klass, col, chr) tk_call('ctext::addHighlightClassWithOnlyCharStart', - @path, klass, col, chr) + @path, klass, col, chr) self end diff --git a/ext/tk/lib/tkextlib/tcllib/cursor.rb b/ext/tk/lib/tkextlib/tcllib/cursor.rb index 8813aa05dd..cbe1e2f1be 100644 --- a/ext/tk/lib/tkextlib/tcllib/cursor.rb +++ b/ext/tk/lib/tkextlib/tcllib/cursor.rb @@ -13,27 +13,27 @@ module Tk module Tcllib module Cursor def self.package_version - begin - TkPackage.require('cursor') - rescue - '' - end + begin + TkPackage.require('cursor') + rescue + '' + end end def self.not_available - fail RuntimeError, "'tkextlib/tcllib/cursor' extension is not available on your current environment." + fail RuntimeError, "'tkextlib/tcllib/cursor' extension is not available on your current environment." end def self.cursor_display(win=None) - Tk::Tcllib::Cursor.not_available + Tk::Tcllib::Cursor.not_available end def self.cursor_propagate(win, cursor) - Tk::Tcllib::Cursor.not_available + Tk::Tcllib::Cursor.not_available end def self.cursor_restore(win, cursor = None) - Tk::Tcllib::Cursor.not_available + Tk::Tcllib::Cursor.not_available end end end @@ -74,15 +74,15 @@ module Tk module Cursor def self.cursor_display(win=None) - tk_call_without_enc('::cursor::display', win) + tk_call_without_enc('::cursor::display', win) end def self.cursor_propagate(win, cursor) - tk_call_without_enc('::cursor::propagate', win.path, cursor) + tk_call_without_enc('::cursor::propagate', win.path, cursor) end def self.cursor_restore(win, cursor = None) - tk_call_without_enc('::cursor::restore', win.path, cursor) + tk_call_without_enc('::cursor::restore', win.path, cursor) end end end diff --git a/ext/tk/lib/tkextlib/tcllib/datefield.rb b/ext/tk/lib/tkextlib/tcllib/datefield.rb index 4d80b06866..1d029e4569 100644 --- a/ext/tk/lib/tkextlib/tcllib/datefield.rb +++ b/ext/tk/lib/tkextlib/tcllib/datefield.rb @@ -26,11 +26,11 @@ module Tk module Tcllib class Datefield < TkEntry def self.package_version - begin - TkPackage.require('datefield') - rescue - '' - end + begin + TkPackage.require('datefield') + rescue + '' + end end end DateField = Datefield @@ -43,7 +43,7 @@ class Tk::Tcllib::Datefield def create_self(keys) if keys and keys != None tk_call_without_enc('::datefield::datefield', @path, - *hash_kv(keys, true)) + *hash_kv(keys, true)) else tk_call_without_enc('::datefield::datefield', @path) end diff --git a/ext/tk/lib/tkextlib/tcllib/ip_entry.rb b/ext/tk/lib/tkextlib/tcllib/ip_entry.rb index 977ef4e5c8..da9f1eb3a8 100644 --- a/ext/tk/lib/tkextlib/tcllib/ip_entry.rb +++ b/ext/tk/lib/tkextlib/tcllib/ip_entry.rb @@ -20,11 +20,11 @@ module Tk module Tcllib class IP_Entry < TkEntry def self.package_version - begin - TkPackage.require('ipentry') - rescue - '' - end + begin + TkPackage.require('ipentry') + rescue + '' + end end end IPEntry = IP_Entry diff --git a/ext/tk/lib/tkextlib/tcllib/plotchart.rb b/ext/tk/lib/tkextlib/tcllib/plotchart.rb index 65451a27a9..86327ceff0 100644 --- a/ext/tk/lib/tkextlib/tcllib/plotchart.rb +++ b/ext/tk/lib/tkextlib/tcllib/plotchart.rb @@ -67,11 +67,11 @@ module Tk module Tcllib module Plotchart def self.package_version - begin - TkPackage.require('Plotchart') - rescue - '' - end + begin + TkPackage.require('Plotchart') + rescue + '' + end end end end @@ -85,13 +85,13 @@ module Tk::Tcllib::Plotchart def self.world_coordinates(w, *args) # args := xmin, ymin, xmax, ymax tk_call_without_enc('::Plotchart::worldCoordinates', - w.path, *(args.flatten)) + w.path, *(args.flatten)) end def self.world_3D_coordinates(w, *args) # args := xmin, ymin, zmin, xmax, ymax, zmax tk_call_without_enc('::Plotchart::world3DCoordinates', - w.path, *(args.flatten)) + w.path, *(args.flatten)) end def self.coords_to_pixel(w, x, y) @@ -148,20 +148,20 @@ module Tk::Tcllib::Plotchart def xconfig(key, value=None) if key.kind_of?(Hash) - tk_call_without_enc(@chart, 'xconfig', *hash_kv(key, true)) + tk_call_without_enc(@chart, 'xconfig', *hash_kv(key, true)) else - tk_call_without_enc(@chart, 'xconfig', - "-#{key}", _get_eval_enc_str(value)) + tk_call_without_enc(@chart, 'xconfig', + "-#{key}", _get_eval_enc_str(value)) end self end def yconfig(key, value=None) if key.kind_of?(Hash) - tk_call_without_enc(@chart, 'yconfig', *hash_kv(key, true)) + tk_call_without_enc(@chart, 'yconfig', *hash_kv(key, true)) else - tk_call_without_enc(@chart, 'yconfig', - "-#{key}", _get_eval_enc_str(value)) + tk_call_without_enc(@chart, 'yconfig', + "-#{key}", _get_eval_enc_str(value)) end self end @@ -174,14 +174,14 @@ module Tk::Tcllib::Plotchart def world_coordinates(*args) # args := xmin, ymin, xmax, ymax tk_call_without_enc('::Plotchart::worldCoordinates', - @path, *(args.flatten)) + @path, *(args.flatten)) self end def world_3D_coordinates(*args) # args := xmin, ymin, zmin, xmax, ymax, zmax tk_call_without_enc('::Plotchart::world3DCoordinates', - @path, *(args.flatten)) + @path, *(args.flatten)) self end @@ -230,21 +230,21 @@ module Tk::Tcllib::Plotchart # xaxis := Array of [minimum, maximum, stepsize] # yaxis := Array of [minimum, maximum, stepsize] if args[0].kind_of?(Array) - @xaxis = args.shift - @yaxis = args.shift + @xaxis = args.shift + @yaxis = args.shift - super(*args) # create canvas widget + super(*args) # create canvas widget else - parent = args.shift + parent = args.shift - @xaxis = args.shift - @yaxis = args.shift + @xaxis = args.shift + @yaxis = args.shift - if parent.kind_of?(TkCanvas) - @path = parent.path - else - super(parent, *args) # create canvas widget - end + if parent.kind_of?(TkCanvas) + @path = parent.path + else + super(parent, *args) # create canvas widget + end end @chart = _create_chart @@ -253,7 +253,7 @@ module Tk::Tcllib::Plotchart def _create_chart p self.class::TkCommandNames[1] if $DEBUG tk_call_without_enc(self.class::TkCommandNames[1], @path, - array2tk_list(@xaxis), array2tk_list(@yaxis)) + array2tk_list(@xaxis), array2tk_list(@yaxis)) end private :_create_chart @@ -268,10 +268,10 @@ module Tk::Tcllib::Plotchart def dataconfig(series, key, value=None) if key.kind_of?(Hash) - tk_call_without_enc(@chart, 'dataconfig', series, *hash_kv(key, true)) + tk_call_without_enc(@chart, 'dataconfig', series, *hash_kv(key, true)) else - tk_call_without_enc(@chart, 'dataconfig', series, - "-#{key}", _get_eval_enc_str(value)) + tk_call_without_enc(@chart, 'dataconfig', series, + "-#{key}", _get_eval_enc_str(value)) end end end @@ -296,19 +296,19 @@ module Tk::Tcllib::Plotchart def initialize(*args) # args := ([parent,] radius_data [, keys]) # radius_data := Array of [maximum_radius, stepsize] if args[0].kind_of?(Array) - @radius_data = args.shift + @radius_data = args.shift - super(*args) # create canvas widget + super(*args) # create canvas widget else - parent = args.shift + parent = args.shift - @radius_data = args.shift + @radius_data = args.shift - if parent.kind_of?(TkCanvas) - @path = parent.path - else - super(parent, *args) # create canvas widget - end + if parent.kind_of?(TkCanvas) + @path = parent.path + else + super(parent, *args) # create canvas widget + end end @chart = _create_chart @@ -317,7 +317,7 @@ module Tk::Tcllib::Plotchart def _create_chart p self.class::TkCommandNames[1] if $DEBUG tk_call_without_enc(self.class::TkCommandNames[1], @path, - array2tk_list(@radius_data)) + array2tk_list(@radius_data)) end private :_create_chart @@ -327,16 +327,16 @@ module Tk::Tcllib::Plotchart def plot(series, radius, angle) tk_call_without_enc(@chart, 'plot', _get_eval_enc_str(series), - radius, angle) + radius, angle) self end def dataconfig(series, key, value=None) if key.kind_of?(Hash) - tk_call_without_enc(@chart, 'dataconfig', series, *hash_kv(key, true)) + tk_call_without_enc(@chart, 'dataconfig', series, *hash_kv(key, true)) else - tk_call_without_enc(@chart, 'dataconfig', series, - "-#{key}", _get_eval_enc_str(value)) + tk_call_without_enc(@chart, 'dataconfig', series, + "-#{key}", _get_eval_enc_str(value)) end end end @@ -356,33 +356,33 @@ module Tk::Tcllib::Plotchart # yaxis := Array of [minimum, maximum] # step := Float of stepsize | "noaxes" | :noaxes if args[0].kind_of?(Array) - @xaxis = args.shift - @yaxis = args.shift + @xaxis = args.shift + @yaxis = args.shift - if args[0].kind_of?(Hash) - @stepsize = :noaxes - else - @stepsize = args.shift - end + if args[0].kind_of?(Hash) + @stepsize = :noaxes + else + @stepsize = args.shift + end - super(*args) # create canvas widget + super(*args) # create canvas widget else - parent = args.shift - - @xaxis = args.shift - @yaxis = args.shift - - if args[0].kind_of?(Hash) - @stepsize = :noaxes - else - @stepsize = args.shift - end - - if parent.kind_of?(TkCanvas) - @path = parent.path - else - super(parent, *args) # create canvas widget - end + parent = args.shift + + @xaxis = args.shift + @yaxis = args.shift + + if args[0].kind_of?(Hash) + @stepsize = :noaxes + else + @stepsize = args.shift + end + + if parent.kind_of?(TkCanvas) + @path = parent.path + else + super(parent, *args) # create canvas widget + end end @chart = _create_chart @@ -391,8 +391,8 @@ module Tk::Tcllib::Plotchart def _create_chart p self.class::TkCommandNames[1] if $DEBUG tk_call_without_enc(self.class::TkCommandNames[1], @path, - array2tk_list(@xaxis), array2tk_list(@yaxis), - @stepsize) + array2tk_list(@xaxis), array2tk_list(@yaxis), + @stepsize) end private :_create_chart @@ -436,23 +436,23 @@ module Tk::Tcllib::Plotchart # yaxis := Array of [minimum, maximum, stepsize] # zaxis := Array of [minimum, maximum, stepsize] if args[0].kind_of?(Array) - @xaxis = args.shift - @yaxis = args.shift - @zaxis = args.shift + @xaxis = args.shift + @yaxis = args.shift + @zaxis = args.shift - super(*args) # create canvas widget + super(*args) # create canvas widget else - parent = args.shift + parent = args.shift - @xaxis = args.shift - @yaxis = args.shift - @zaxis = args.shift + @xaxis = args.shift + @yaxis = args.shift + @zaxis = args.shift - if parent.kind_of?(TkCanvas) - @path = parent.path - else - super(parent, *args) # create canvas widget - end + if parent.kind_of?(TkCanvas) + @path = parent.path + else + super(parent, *args) # create canvas widget + end end @chart = _create_chart @@ -461,9 +461,9 @@ module Tk::Tcllib::Plotchart def _create_chart p self.class::TkCommandNames[1] if $DEBUG tk_call_without_enc(self.class::TkCommandNames[1], @path, - array2tk_list(@xaxis), - array2tk_list(@yaxis), - array2tk_list(@zaxis)) + array2tk_list(@xaxis), + array2tk_list(@yaxis), + array2tk_list(@zaxis)) end private :_create_chart @@ -508,10 +508,10 @@ module Tk::Tcllib::Plotchart def initialize(*args) # args := ([parent] [, keys]) if args[0].kind_of?(TkCanvas) - parent = args.shift - @path = parent.path + parent = args.shift + @path = parent.path else - super(*args) # create canvas widget + super(*args) # create canvas widget end @chart = _create_chart end @@ -545,33 +545,33 @@ module Tk::Tcllib::Plotchart # axis := Array of [minimum, maximum, stepsize] # series := Integer number of data series | 'stacked' | :stacked if args[0].kind_of?(Array) - @xlabels = args.shift - @ylabels = args.shift + @xlabels = args.shift + @ylabels = args.shift - if args[0].kind_of?(Hash) - @series_size = :stacked - else - @series_size = args.shift - end + if args[0].kind_of?(Hash) + @series_size = :stacked + else + @series_size = args.shift + end - super(*args) # create canvas widget + super(*args) # create canvas widget else - parent = args.shift - - @xlabels = args.shift - @ylabels = args.shift - - if args[0].kind_of?(Hash) - @series_size = :stacked - else - @series_size = args.shift - end - - if parent.kind_of?(TkCanvas) - @path = parent.path - else - super(parent, *args) # create canvas widget - end + parent = args.shift + + @xlabels = args.shift + @ylabels = args.shift + + if args[0].kind_of?(Hash) + @series_size = :stacked + else + @series_size = args.shift + end + + if parent.kind_of?(TkCanvas) + @path = parent.path + else + super(parent, *args) # create canvas widget + end end @chart = _create_chart @@ -580,8 +580,8 @@ module Tk::Tcllib::Plotchart def _create_chart p self.class::TkCommandNames[1] if $DEBUG tk_call_without_enc(self.class::TkCommandNames[1], @path, - array2tk_list(@xlabels), array2tk_list(@ylabels), - @series_size) + array2tk_list(@xlabels), array2tk_list(@ylabels), + @series_size) end private :_create_chart @@ -628,23 +628,23 @@ module Tk::Tcllib::Plotchart # items := Expected/maximum number of items # ( This determines the vertical spacing. ) if args[0].kind_of?(Array) - @time_begin = args.shift - @time_end = args.shift - @items = args.shift + @time_begin = args.shift + @time_end = args.shift + @items = args.shift - super(*args) # create canvas widget + super(*args) # create canvas widget else - parent = args.shift + parent = args.shift - @time_begin = args.shift - @time_end = args.shift - @items = args.shift + @time_begin = args.shift + @time_end = args.shift + @items = args.shift - if parent.kind_of?(TkCanvas) - @path = parent.path - else - super(parent, *args) # create canvas widget - end + if parent.kind_of?(TkCanvas) + @path = parent.path + else + super(parent, *args) # create canvas widget + end end @chart = _create_chart @@ -653,7 +653,7 @@ module Tk::Tcllib::Plotchart def _create_chart p self.class::TkCommandNames[1] if $DEBUG tk_call_without_enc(self.class::TkCommandNames[1], @path, - @time_begin, @time_end, @items) + @time_begin, @time_end, @items) end private :_create_chart diff --git a/ext/tk/lib/tkextlib/tcllib/style.rb b/ext/tk/lib/tkextlib/tcllib/style.rb index 17fc834ccb..9fc4e92329 100644 --- a/ext/tk/lib/tkextlib/tcllib/style.rb +++ b/ext/tk/lib/tkextlib/tcllib/style.rb @@ -13,9 +13,9 @@ module Tk::Tcllib module Style def self.package_version begin - TkPackage.require('style') + TkPackage.require('style') rescue - '' + '' end end diff --git a/ext/tk/lib/tkextlib/tcllib/tkpiechart.rb b/ext/tk/lib/tkextlib/tcllib/tkpiechart.rb index 4665edca7e..4e6008bb3b 100644 --- a/ext/tk/lib/tkextlib/tcllib/tkpiechart.rb +++ b/ext/tk/lib/tkextlib/tcllib/tkpiechart.rb @@ -48,7 +48,7 @@ module Tk::Tcllib::Tkpiechart def __configinfo_struct {:key=>0, :alias=>nil, :db_name=>nil, :db_class=>nil, - :default_value=>1, :current_value=>2} + :default_value=>1, :current_value=>2} end private :__configinfo_struct end @@ -69,10 +69,10 @@ module Tk::Tcllib::Tkpiechart def create_self(x, y, width, height, keys=None) if keys and keys != None - @tag_key = tk_call_without_enc('::stooop::new', 'pie', - @c, x, y, *hash_kv(keys, true)) + @tag_key = tk_call_without_enc('::stooop::new', 'pie', + @c, x, y, *hash_kv(keys, true)) else - @tag_key = tk_call_without_enc('::stooop::new', 'pie', @c, x, y) + @tag_key = tk_call_without_enc('::stooop::new', 'pie', @c, x, y) end @slice_tbl = {} @@ -114,20 +114,20 @@ module Tk::Tcllib::Tkpiechart def delete_slice(slice) unless slice.kind_of?(Slice) - unless (slice = @slice_tbl[slice]) - return tk_call_without_enc('pie::deleteSlice', @tag_key, slice) - end + unless (slice = @slice_tbl[slice]) + return tk_call_without_enc('pie::deleteSlice', @tag_key, slice) + end end unless slice.kind_of?(Slice) && slice.pie == self - fail ArgumentError, "argument is not a slice of self" + fail ArgumentError, "argument is not a slice of self" end slice.delete end def selected_slices tk_split_simplelist(tk_call_without_enc('pie::selectedSlices', - @tag_key)).collect{|slice| - @slice_tbl[slice] || Slice.new(:no_create, self, slice) + @tag_key)).collect{|slice| + @slice_tbl[slice] || Slice.new(:no_create, self, slice) } end end @@ -145,15 +145,15 @@ module Tk::Tcllib::Tkpiechart def initialize(pie, *args) unless pie.kind_of?(Pie) && pie != :no_create - fail ArgumentError, "expects TkPiechart::Pie for 1st argument" + fail ArgumentError, "expects TkPiechart::Pie for 1st argument" end if pie == :no_create - @pie, @tag_key = args + @pie, @tag_key = args else - text = args[0] || None - @pie = pie - @tag_key = tk_call_without_enc('pie::newSlice', @pie.tag_key, text) + text = args[0] || None + @pie = pie + @tag_key = tk_call_without_enc('pie::newSlice', @pie.tag_key, text) end @parent = @c = @pie.canvas @path = @parent.path @@ -186,7 +186,7 @@ module Tk::Tcllib::Tkpiechart def size(share, disp=None) tk_call_without_enc('pie::sizeSlice', - @pie.tag_key, @tag_key, share, disp) + @pie.tag_key, @tag_key, share, disp) self end @@ -209,10 +209,10 @@ module Tk::Tcllib::Tkpiechart def create_self(keys=None) if keys and keys != None - @tag_key = tk_call_without_enc('::stooop::new', 'pieBoxLabeler', - *hash_kv(keys, true)) + @tag_key = tk_call_without_enc('::stooop::new', 'pieBoxLabeler', + *hash_kv(keys, true)) else - @tag_key = tk_call_without_enc('::stooop::new', 'pieBoxLabeler') + @tag_key = tk_call_without_enc('::stooop::new', 'pieBoxLabeler') end id = "pieBoxLabeler(#{@tag_key})" @@ -241,11 +241,11 @@ module Tk::Tcllib::Tkpiechart def create_self(keys=None) if keys and keys != None - @tag_key = tk_call_without_enc('::stooop::new', - 'piePeripheralLabeler', - *hash_kv(keys, true)) + @tag_key = tk_call_without_enc('::stooop::new', + 'piePeripheralLabeler', + *hash_kv(keys, true)) else - @tag_key = tk_call_without_enc('::stooop::new', 'piePeripheralLabeler') + @tag_key = tk_call_without_enc('::stooop::new', 'piePeripheralLabeler') end id = "piePeripheralLabeler(#{@tag_key})" @@ -269,12 +269,12 @@ module Tk::Tcllib::Tkpiechart def create_self(x, y, keys=None) if keys and keys != None - @tag_key = tk_call_without_enc('::stooop::new', 'canvasLabel', - @c, x, y, width, height, - *hash_kv(keys, true)) + @tag_key = tk_call_without_enc('::stooop::new', 'canvasLabel', + @c, x, y, width, height, + *hash_kv(keys, true)) else - @tag_key = tk_call_without_enc('::stooop::new', 'canvasLabel', - @c, x, y, width, height) + @tag_key = tk_call_without_enc('::stooop::new', 'canvasLabel', + @c, x, y, width, height) end id = "canvasLabel(#{@tag_key})" diff --git a/ext/tk/lib/tkextlib/tclx/tclx.rb b/ext/tk/lib/tkextlib/tclx/tclx.rb index d10689d209..760ebd92b1 100644 --- a/ext/tk/lib/tkextlib/tclx/tclx.rb +++ b/ext/tk/lib/tkextlib/tclx/tclx.rb @@ -17,9 +17,9 @@ module Tk module TclX def self.package_version begin - TkPackage.require('Tclx') + TkPackage.require('Tclx') rescue - '' + '' end end @@ -31,28 +31,28 @@ module Tk class XPG3_MsgCat class << self - alias open new + alias open new end def initialize(catname, fail_mode=false) - if fail_mode - @msgcat_id = Tk.tk_call('catopen', '-fail', catname) - else - @msgcat_id = Tk.tk_call('catopen', '-nofail', catname) - end + if fail_mode + @msgcat_id = Tk.tk_call('catopen', '-fail', catname) + else + @msgcat_id = Tk.tk_call('catopen', '-nofail', catname) + end end def close(fail_mode=false) - if fail_mode - Tk.tk_call('catclose', '-fail', @msgcat_id) - else - Tk.tk_call('catclose', '-nofail', @msgcat_id) - end - self + if fail_mode + Tk.tk_call('catclose', '-fail', @msgcat_id) + else + Tk.tk_call('catclose', '-nofail', @msgcat_id) + end + self end def get(setnum, msgnum, defaultstr) - Tk.tk_call('catgets', @msgcat_id, setnum, msgnum, defaultstr) + Tk.tk_call('catgets', @msgcat_id, setnum, msgnum, defaultstr) end end end diff --git a/ext/tk/lib/tkextlib/tile.rb b/ext/tk/lib/tkextlib/tile.rb index 91c01ca736..80a9083694 100644 --- a/ext/tk/lib/tkextlib/tile.rb +++ b/ext/tk/lib/tkextlib/tile.rb @@ -22,29 +22,29 @@ module Tk def self.package_version begin - TkPackage.require('tile') + TkPackage.require('tile') rescue - '' + '' end end module TileWidget def instate(state, script=nil, &b) - if script - tk_send('instate', state, script) - elsif b - tk_send('instate', state, Proc.new(&b)) - else - bool(tk_send('instate', state)) - end + if script + tk_send('instate', state, script) + elsif b + tk_send('instate', state, Proc.new(&b)) + else + bool(tk_send('instate', state)) + end end def state(state=nil) - if state - tk_send('state', state) - else - list(tk_send('state')) - end + if state + tk_send('state', state) + else + list(tk_send('state')) + end end end diff --git a/ext/tk/lib/tkextlib/tkDND/shape.rb b/ext/tk/lib/tkextlib/tkDND/shape.rb index 8f4716ceea..7187f0a3b3 100644 --- a/ext/tk/lib/tkextlib/tkDND/shape.rb +++ b/ext/tk/lib/tkextlib/tkDND/shape.rb @@ -19,93 +19,93 @@ module Tk module Shape =begin def self.package_version - begin - TkPackage.require('shape') - rescue - '' - end + begin + TkPackage.require('shape') + rescue + '' + end end =end def self.package_version - Tk.tk_call('set', 'shape_version') + Tk.tk_call('set', 'shape_version') end alias shape_version package_version def self.package_patchlevel - Tk.tk_call('set', 'shape_patchlevel') + Tk.tk_call('set', 'shape_patchlevel') end alias shape_patchlevel package_patchlevel def self.version - tk_call('shape', 'version') + tk_call('shape', 'version') end alias xshape_version version ############################ def shape_bounds(kind=nil) - if kind - ret = tk_call('shape', 'bounds', @path, "-#{kind}") - else - ret = tk_call('shape', 'bounds', @path) - end - if ret == "" - nil - else - list(ret) - end + if kind + ret = tk_call('shape', 'bounds', @path, "-#{kind}") + else + ret = tk_call('shape', 'bounds', @path) + end + if ret == "" + nil + else + list(ret) + end end def shape_get(kind=nil) - if kind - list(tk_call('shape', 'get', @path, "-#{kind}")) - else - list(tk_call('shape', 'get', @path)) - end + if kind + list(tk_call('shape', 'get', @path, "-#{kind}")) + else + list(tk_call('shape', 'get', @path)) + end end def shape_offset(x, y, kind=nil) - if kind - tk_call('shape', 'get', @path, "-#{kind}", x, y) - else - tk_call('shape', 'get', @path, x, y) - end - self + if kind + tk_call('shape', 'get', @path, "-#{kind}", x, y) + else + tk_call('shape', 'get', @path, x, y) + end + self end def _parse_shapespec_param(args) - cmd = [] + cmd = [] - kind_keys = ['bounding', 'clip', 'both'] - offset_keys = ['offset'] - srckind_keys = ['bitmap', 'rectangles', 'reset', 'test', 'window'] + kind_keys = ['bounding', 'clip', 'both'] + offset_keys = ['offset'] + srckind_keys = ['bitmap', 'rectangles', 'reset', 'test', 'window'] - cmd << "-#{args.shift}" if kind_keys.member?(args[0].to_s) + cmd << "-#{args.shift}" if kind_keys.member?(args[0].to_s) - if offset_keys.member?(args[0].to_s) - cmd << "-#{args.shift}" - cmd << args.shift # xOffset - cmd << args.shift # yOffset - end + if offset_keys.member?(args[0].to_s) + cmd << "-#{args.shift}" + cmd << args.shift # xOffset + cmd << args.shift # yOffset + end - if srckind_keys.member?(args[0].to_s) - cmd << "-#{args.shift}" - end + if srckind_keys.member?(args[0].to_s) + cmd << "-#{args.shift}" + end - cmd.concat(args) + cmd.concat(args) - cmd + cmd end private :_parse_shapespec_param def shape_set(*args) # ?kind? ?offset ? srckind ?arg ...? - tk_call('shape', 'set', @path, *(_parse_shapespec_param(args))) - self + tk_call('shape', 'set', @path, *(_parse_shapespec_param(args))) + self end def shape_update(op, *args) # ?kind? ?offset ? srckind ?arg ...? - tk_call('shape', 'update', @path, op, *(_parse_shapespec_param(args))) - self + tk_call('shape', 'update', @path, op, *(_parse_shapespec_param(args))) + self end end end diff --git a/ext/tk/lib/tkextlib/tkDND/tkdnd.rb b/ext/tk/lib/tkextlib/tkDND/tkdnd.rb index d0895c2afd..78381f8df0 100644 --- a/ext/tk/lib/tkextlib/tkDND/tkdnd.rb +++ b/ext/tk/lib/tkextlib/tkDND/tkdnd.rb @@ -17,39 +17,39 @@ module Tk module TkDND def self.package_version begin - TkPackage.require('tkdnd') + TkPackage.require('tkdnd') rescue - '' + '' end end class DND_Subst < TkUtil::CallbackSubst KEY_TBL = [ - [ ?a, ?l, :actions ], - [ ?A, ?s, :action ], - [ ?b, ?L, :codes ], - [ ?c, ?s, :code ], - [ ?d, ?l, :descriptions ], - [ ?D, ?l, :data ], - [ ?L, ?l, :source_types ], - [ ?m, ?l, :modifiers ], - [ ?t, ?l, :types ], - [ ?T, ?s, :type ], - [ ?W, ?w, :widget ], - [ ?x, ?n, :x ], - [ ?X, ?n, :x_root ], - [ ?y, ?n, :y ], - [ ?Y, ?n, :y_root ], - nil + [ ?a, ?l, :actions ], + [ ?A, ?s, :action ], + [ ?b, ?L, :codes ], + [ ?c, ?s, :code ], + [ ?d, ?l, :descriptions ], + [ ?D, ?l, :data ], + [ ?L, ?l, :source_types ], + [ ?m, ?l, :modifiers ], + [ ?t, ?l, :types ], + [ ?T, ?s, :type ], + [ ?W, ?w, :widget ], + [ ?x, ?n, :x ], + [ ?X, ?n, :x_root ], + [ ?y, ?n, :y ], + [ ?Y, ?n, :y_root ], + nil ] PROC_TBL = [ - [ ?n, TkComm.method(:num_or_str) ], - [ ?s, TkComm.method(:string) ], - [ ?l, TkComm.method(:list) ], - [ ?L, TkComm.method(:simplelist) ], - [ ?w, TkComm.method(:window) ], - nil + [ ?n, TkComm.method(:num_or_str) ], + [ ?s, TkComm.method(:string) ], + [ ?l, TkComm.method(:list) ], + [ ?L, TkComm.method(:simplelist) ], + [ ?w, TkComm.method(:window) ], + nil ] # setup tables @@ -58,62 +58,62 @@ module Tk module DND def self.version - begin - TkPackage.require('tkdnd') - rescue - '' - end + begin + TkPackage.require('tkdnd') + rescue + '' + end end def dnd_bindtarget_info(type=nil, event=nil) - if event - procedure(tk_call('dnd', 'bindtarget', @path, type, event)) - elsif type - procedure(tk_call('dnd', 'bindtarget', @path, type)) - else - simplelist(tk_call('dnd', 'bindtarget', @path)) - end + if event + procedure(tk_call('dnd', 'bindtarget', @path, type, event)) + elsif type + procedure(tk_call('dnd', 'bindtarget', @path, type)) + else + simplelist(tk_call('dnd', 'bindtarget', @path)) + end end def dnd_bindtarget(type, event, cmd=Proc.new, prior=50, *args) - event = tk_event_sequence(event) - if prior.kind_of?(Numeric) - tk_call('dnd', 'bindtarget', @path, type, event, - install_bind_for_event_class(DND_Subst, cmd, *args), - prior) - else - tk_call('dnd', 'bindtarget', @path, type, event, - install_bind_for_event_class(DND_Subst, cmd, prior, *args)) - end - self + event = tk_event_sequence(event) + if prior.kind_of?(Numeric) + tk_call('dnd', 'bindtarget', @path, type, event, + install_bind_for_event_class(DND_Subst, cmd, *args), + prior) + else + tk_call('dnd', 'bindtarget', @path, type, event, + install_bind_for_event_class(DND_Subst, cmd, prior, *args)) + end + self end def dnd_cleartarget - tk_call('dnd', 'cleartarget', @path) - self + tk_call('dnd', 'cleartarget', @path) + self end def dnd_bindsource_info(type=nil) - if type - procedure(tk_call('dnd', 'bindsource', @path, type)) - else - simplelist(tk_call('dnd', 'bindsource', @path)) - end + if type + procedure(tk_call('dnd', 'bindsource', @path, type)) + else + simplelist(tk_call('dnd', 'bindsource', @path)) + end end def dnd_bindsource(type, cmd=Proc.new, prior=None) - tk_call('dnd', 'bindsource', @path, type, cmd, prior) - self + tk_call('dnd', 'bindsource', @path, type, cmd, prior) + self end def dnd_clearsource() - tk_call('dnd', 'clearsource', @path) - self + tk_call('dnd', 'clearsource', @path) + self end def dnd_drag(keys=nil) - tk_call('dnd', 'drag', @path, *hash_kv(keys)) - self + tk_call('dnd', 'drag', @path, *hash_kv(keys)) + self end end end diff --git a/ext/tk/lib/tkextlib/tkHTML/htmlwidget.rb b/ext/tk/lib/tkextlib/tkHTML/htmlwidget.rb index 0c900cdb85..b9a203575a 100644 --- a/ext/tk/lib/tkextlib/tkHTML/htmlwidget.rb +++ b/ext/tk/lib/tkextlib/tkHTML/htmlwidget.rb @@ -18,9 +18,9 @@ module Tk class HTML_Widget < TkWindow def self.package_version begin - TkPackage.require('Tkhtml') + TkPackage.require('Tkhtml') rescue - '' + '' end end @@ -55,7 +55,7 @@ class Tk::HTML_Widget::ClippingWindow if widgetname =~ /^(.*)\.[^.]+$/ ppath2 = $1 if ppath2[0] != ?. - ppath2 = ppath + '.' + ppath2 + ppath2 = ppath + '.' + ppath2 end return HtmlClip_TBL[ppath2] if HtmlClip_TBL[ppath2] diff --git a/ext/tk/lib/tkextlib/tkimg.rb b/ext/tk/lib/tkextlib/tkimg.rb index f70d76c9d1..ffeafbb58e 100644 --- a/ext/tk/lib/tkextlib/tkimg.rb +++ b/ext/tk/lib/tkextlib/tkimg.rb @@ -19,9 +19,9 @@ module Tk module Img def self.package_version begin - TkPackage.require('Img') + TkPackage.require('Img') rescue - '' + '' end end end diff --git a/ext/tk/lib/tkextlib/tkimg/bmp.rb b/ext/tk/lib/tkextlib/tkimg/bmp.rb index e6031a43ea..581483f8f4 100644 --- a/ext/tk/lib/tkextlib/tkimg/bmp.rb +++ b/ext/tk/lib/tkextlib/tkimg/bmp.rb @@ -17,11 +17,11 @@ module Tk module Img module BMP def self.package_version - begin - TkPackage.require('img::bmp') - rescue - '' - end + begin + TkPackage.require('img::bmp') + rescue + '' + end end end end diff --git a/ext/tk/lib/tkextlib/tkimg/gif.rb b/ext/tk/lib/tkextlib/tkimg/gif.rb index b464434498..6ef18f8e90 100644 --- a/ext/tk/lib/tkextlib/tkimg/gif.rb +++ b/ext/tk/lib/tkextlib/tkimg/gif.rb @@ -17,11 +17,11 @@ module Tk module Img module GIF def self.package_version - begin - TkPackage.require('img::gif') - rescue - '' - end + begin + TkPackage.require('img::gif') + rescue + '' + end end end end diff --git a/ext/tk/lib/tkextlib/tkimg/ico.rb b/ext/tk/lib/tkextlib/tkimg/ico.rb index 2872a621ad..1e3cb5f497 100644 --- a/ext/tk/lib/tkextlib/tkimg/ico.rb +++ b/ext/tk/lib/tkextlib/tkimg/ico.rb @@ -17,11 +17,11 @@ module Tk module Img module ICO def self.package_version - begin - TkPackage.require('img::ico') - rescue - '' - end + begin + TkPackage.require('img::ico') + rescue + '' + end end end end diff --git a/ext/tk/lib/tkextlib/tkimg/jpeg.rb b/ext/tk/lib/tkextlib/tkimg/jpeg.rb index eac39083bc..017c93ee0e 100644 --- a/ext/tk/lib/tkextlib/tkimg/jpeg.rb +++ b/ext/tk/lib/tkextlib/tkimg/jpeg.rb @@ -17,11 +17,11 @@ module Tk module Img module JPEG def self.package_version - begin - TkPackage.require('img::jpeg') - rescue - '' - end + begin + TkPackage.require('img::jpeg') + rescue + '' + end end end end diff --git a/ext/tk/lib/tkextlib/tkimg/pcx.rb b/ext/tk/lib/tkextlib/tkimg/pcx.rb index 26311e5984..e924d48869 100644 --- a/ext/tk/lib/tkextlib/tkimg/pcx.rb +++ b/ext/tk/lib/tkextlib/tkimg/pcx.rb @@ -17,11 +17,11 @@ module Tk module Img module PCX def self.package_version - begin - TkPackage.require('img::pcx') - rescue - '' - end + begin + TkPackage.require('img::pcx') + rescue + '' + end end end end diff --git a/ext/tk/lib/tkextlib/tkimg/pixmap.rb b/ext/tk/lib/tkextlib/tkimg/pixmap.rb index ae8d3201cb..f9aaa65a9b 100644 --- a/ext/tk/lib/tkextlib/tkimg/pixmap.rb +++ b/ext/tk/lib/tkextlib/tkimg/pixmap.rb @@ -17,11 +17,11 @@ module Tk module Img module PIXMAP def self.package_version - begin - TkPackage.require('img::pixmap') - rescue - '' - end + begin + TkPackage.require('img::pixmap') + rescue + '' + end end end end diff --git a/ext/tk/lib/tkextlib/tkimg/png.rb b/ext/tk/lib/tkextlib/tkimg/png.rb index acdd8c536f..b155836395 100644 --- a/ext/tk/lib/tkextlib/tkimg/png.rb +++ b/ext/tk/lib/tkextlib/tkimg/png.rb @@ -17,11 +17,11 @@ module Tk module Img module PNG def self.package_version - begin - TkPackage.require('img::png') - rescue - '' - end + begin + TkPackage.require('img::png') + rescue + '' + end end end end diff --git a/ext/tk/lib/tkextlib/tkimg/ppm.rb b/ext/tk/lib/tkextlib/tkimg/ppm.rb index f15bdb9f18..df56baee4a 100644 --- a/ext/tk/lib/tkextlib/tkimg/ppm.rb +++ b/ext/tk/lib/tkextlib/tkimg/ppm.rb @@ -17,11 +17,11 @@ module Tk module Img module PPM def self.package_version - begin - TkPackage.require('img::ppm') - rescue - '' - end + begin + TkPackage.require('img::ppm') + rescue + '' + end end end end diff --git a/ext/tk/lib/tkextlib/tkimg/ps.rb b/ext/tk/lib/tkextlib/tkimg/ps.rb index 7c5cab2a4f..3025066eb4 100644 --- a/ext/tk/lib/tkextlib/tkimg/ps.rb +++ b/ext/tk/lib/tkextlib/tkimg/ps.rb @@ -17,11 +17,11 @@ module Tk module Img module PS def self.package_version - begin - TkPackage.require('img::ps') - rescue - '' - end + begin + TkPackage.require('img::ps') + rescue + '' + end end end end diff --git a/ext/tk/lib/tkextlib/tkimg/sgi.rb b/ext/tk/lib/tkextlib/tkimg/sgi.rb index 1cdf60e64c..e505c87e8b 100644 --- a/ext/tk/lib/tkextlib/tkimg/sgi.rb +++ b/ext/tk/lib/tkextlib/tkimg/sgi.rb @@ -17,11 +17,11 @@ module Tk module Img module SGI def self.package_version - begin - TkPackage.require('img::sgi') - rescue - '' - end + begin + TkPackage.require('img::sgi') + rescue + '' + end end end end diff --git a/ext/tk/lib/tkextlib/tkimg/sun.rb b/ext/tk/lib/tkextlib/tkimg/sun.rb index 88f9a44656..25bfea8fb7 100644 --- a/ext/tk/lib/tkextlib/tkimg/sun.rb +++ b/ext/tk/lib/tkextlib/tkimg/sun.rb @@ -17,11 +17,11 @@ module Tk module Img module SUN def self.package_version - begin - TkPackage.require('img::sun') - rescue - '' - end + begin + TkPackage.require('img::sun') + rescue + '' + end end end end diff --git a/ext/tk/lib/tkextlib/tkimg/tga.rb b/ext/tk/lib/tkextlib/tkimg/tga.rb index c4068a729c..e3f84c3714 100644 --- a/ext/tk/lib/tkextlib/tkimg/tga.rb +++ b/ext/tk/lib/tkextlib/tkimg/tga.rb @@ -17,11 +17,11 @@ module Tk module Img module TGA def self.package_version - begin - TkPackage.require('img::tga') - rescue - '' - end + begin + TkPackage.require('img::tga') + rescue + '' + end end end end diff --git a/ext/tk/lib/tkextlib/tkimg/tiff.rb b/ext/tk/lib/tkextlib/tkimg/tiff.rb index 529999ef2d..e7e12406ac 100644 --- a/ext/tk/lib/tkextlib/tkimg/tiff.rb +++ b/ext/tk/lib/tkextlib/tkimg/tiff.rb @@ -17,11 +17,11 @@ module Tk module Img module TIFF def self.package_version - begin - TkPackage.require('img::tiff') - rescue - '' - end + begin + TkPackage.require('img::tiff') + rescue + '' + end end end end diff --git a/ext/tk/lib/tkextlib/tkimg/window.rb b/ext/tk/lib/tkextlib/tkimg/window.rb index 229445dd46..00ed7d1b86 100644 --- a/ext/tk/lib/tkextlib/tkimg/window.rb +++ b/ext/tk/lib/tkextlib/tkimg/window.rb @@ -17,11 +17,11 @@ module Tk module Img module WINDOW def self.package_version - begin - TkPackage.require('img::window') - rescue - '' - end + begin + TkPackage.require('img::window') + rescue + '' + end end end end diff --git a/ext/tk/lib/tkextlib/tkimg/xbm.rb b/ext/tk/lib/tkextlib/tkimg/xbm.rb index 3b680d9b59..08b1b9876b 100644 --- a/ext/tk/lib/tkextlib/tkimg/xbm.rb +++ b/ext/tk/lib/tkextlib/tkimg/xbm.rb @@ -17,11 +17,11 @@ module Tk module Img module XBM def self.package_version - begin - TkPackage.require('img::xbm') - rescue - '' - end + begin + TkPackage.require('img::xbm') + rescue + '' + end end end end diff --git a/ext/tk/lib/tkextlib/tkimg/xpm.rb b/ext/tk/lib/tkextlib/tkimg/xpm.rb index eff1e3c2b6..e29c1d554f 100644 --- a/ext/tk/lib/tkextlib/tkimg/xpm.rb +++ b/ext/tk/lib/tkextlib/tkimg/xpm.rb @@ -17,11 +17,11 @@ module Tk module Img module XPM def self.package_version - begin - TkPackage.require('img::xpm') - rescue - '' - end + begin + TkPackage.require('img::xpm') + rescue + '' + end end end end diff --git a/ext/tk/lib/tkextlib/tktable/tktable.rb b/ext/tk/lib/tkextlib/tktable/tktable.rb index 18751fca6c..2f2b14a69f 100644 --- a/ext/tk/lib/tkextlib/tktable/tktable.rb +++ b/ext/tk/lib/tkextlib/tktable/tktable.rb @@ -19,9 +19,9 @@ module Tk class TkTable < TkWindow def self.package_version begin - TkPackage.require('Tktable') + TkPackage.require('Tktable') rescue - '' + '' end end @@ -200,28 +200,28 @@ class Tk::TkTable class BrowseCommand < TkValidateCommand class ValidateArgs < TkUtil::CallbackSubst KEY_TBL = [ - [ ?c, ?n, :column ], - [ ?C, ?s, :index ], - [ ?i, ?x, :cursor ], - [ ?r, ?n, :row ], - [ ?s, ?s, :last_index ], - [ ?S, ?s, :new_index ], - [ ?W, ?w, :widget ], - nil + [ ?c, ?n, :column ], + [ ?C, ?s, :index ], + [ ?i, ?x, :cursor ], + [ ?r, ?n, :row ], + [ ?s, ?s, :last_index ], + [ ?S, ?s, :new_index ], + [ ?W, ?w, :widget ], + nil ] PROC_TBL = [ - [ ?n, TkComm.method(:number) ], - [ ?x, TkComm.method(:num_or_str) ], - [ ?s, TkComm.method(:string) ], - [ ?w, TkComm.method(:window) ], - nil + [ ?n, TkComm.method(:number) ], + [ ?x, TkComm.method(:num_or_str) ], + [ ?s, TkComm.method(:string) ], + [ ?w, TkComm.method(:window) ], + nil ] _setup_subst_table(KEY_TBL, PROC_TBL); def self.ret_val(val) - val + val end end @@ -233,28 +233,28 @@ class Tk::TkTable class CellCommand < TkValidateCommand class ValidateArgs < TkUtil::CallbackSubst KEY_TBL = [ - [ ?c, ?n, :column ], - [ ?C, ?s, :index ], - [ ?i, ?m, :rw_mode ], - [ ?r, ?n, :row ], - [ ?s, ?v, :value ], - [ ?W, ?w, :widget ], - nil + [ ?c, ?n, :column ], + [ ?C, ?s, :index ], + [ ?i, ?m, :rw_mode ], + [ ?r, ?n, :row ], + [ ?s, ?v, :value ], + [ ?W, ?w, :widget ], + nil ] PROC_TBL = [ - [ ?n, TkComm.method(:number) ], - [ ?s, TkComm.method(:string) ], - [ ?w, TkComm.method(:window) ], - [ ?m, proc{|val| (val == '0')? (:r) : (:w)} ], - [ ?v, proc{|val| TkComm.tk_tcl2ruby(val, true, false)} ], - nil + [ ?n, TkComm.method(:number) ], + [ ?s, TkComm.method(:string) ], + [ ?w, TkComm.method(:window) ], + [ ?m, proc{|val| (val == '0')? (:r) : (:w)} ], + [ ?v, proc{|val| TkComm.tk_tcl2ruby(val, true, false)} ], + nil ] _setup_subst_table(KEY_TBL, PROC_TBL); def self.ret_val(val) - TkComm._get_eval_string(val) + TkComm._get_eval_string(val) end end @@ -266,26 +266,26 @@ class Tk::TkTable class SelectionCommand < TkValidateCommand class ValidateArgs < TkUtil::CallbackSubst KEY_TBL = [ - [ ?c, ?n, :sel_columns ], - [ ?C, ?s, :sel_area ], - [ ?i, ?n, :total ], - [ ?r, ?n, :sel_rows ], - [ ?s, ?s, :value ], - [ ?W, ?w, :widget ], - nil + [ ?c, ?n, :sel_columns ], + [ ?C, ?s, :sel_area ], + [ ?i, ?n, :total ], + [ ?r, ?n, :sel_rows ], + [ ?s, ?s, :value ], + [ ?W, ?w, :widget ], + nil ] PROC_TBL = [ - [ ?n, TkComm.method(:number) ], - [ ?s, TkComm.method(:string) ], - [ ?w, TkComm.method(:window) ], - nil + [ ?n, TkComm.method(:number) ], + [ ?s, TkComm.method(:string) ], + [ ?w, TkComm.method(:window) ], + nil ] _setup_subst_table(KEY_TBL, PROC_TBL); def self.ret_val(val) - val.to_s + val.to_s end end @@ -297,23 +297,23 @@ class Tk::TkTable class ValidateCommand < TkValidateCommand class ValidateArgs < TkUtil::CallbackSubst KEY_TBL = [ - [ ?c, ?n, :column ], - [ ?C, ?s, :index ], - [ ?i, ?x, :cursor ], - [ ?r, ?n, :row ], - [ ?s, ?v, :current_value ], - [ ?S, ?v, :new_value ], - [ ?W, ?w, :widget ], - nil + [ ?c, ?n, :column ], + [ ?C, ?s, :index ], + [ ?i, ?x, :cursor ], + [ ?r, ?n, :row ], + [ ?s, ?v, :current_value ], + [ ?S, ?v, :new_value ], + [ ?W, ?w, :widget ], + nil ] PROC_TBL = [ - [ ?n, TkComm.method(:number) ], - [ ?x, TkComm.method(:num_or_str) ], - [ ?s, TkComm.method(:string) ], - [ ?w, TkComm.method(:window) ], - [ ?v, proc{|val| TkComm.tk_tcl2ruby(val, true, false)} ], - nil + [ ?n, TkComm.method(:number) ], + [ ?x, TkComm.method(:num_or_str) ], + [ ?s, TkComm.method(:string) ], + [ ?w, TkComm.method(:window) ], + [ ?v, proc{|val| TkComm.tk_tcl2ruby(val, true, false)} ], + nil ] _setup_subst_table(KEY_TBL, PROC_TBL); @@ -447,9 +447,9 @@ class Tk::TkTable def hidden?(idx, *args) if args.empty? if (ret = tk_send('hidden', tagid(idx))) == '' - false + false else - ret + ret end else bool(tk_send('hidden', tagid(idx), *(args.collect{|i| tagid(i)}))) @@ -582,8 +582,8 @@ class Tk::TkTable # idx, val, idx, val, ... args = [] 0.step(pairs.size-1, 2){|i| - args << tagid(pairs[i]) - args << pairs[i+1] + args << tagid(pairs[i]) + args << pairs[i+1] } tk_send('set', *args) end @@ -599,8 +599,8 @@ class Tk::TkTable # idx, val, idx, val, ... args = [] 0.step(pairs.size-1, 2){|i| - args << tagid(pairs[i]) - args << pairs[i+1] + args << tagid(pairs[i]) + args << pairs[i+1] } tk_send('set', 'row', *args) end @@ -616,8 +616,8 @@ class Tk::TkTable # idx, val, idx, val, ... args = [] 0.step(pairs.size-1, 2){|i| - args << tagid(pairs[i]) - args << pairs[i+1] + args << tagid(pairs[i]) + args << pairs[i+1] } tk_send('set', 'col', *args) end @@ -647,9 +647,9 @@ class Tk::TkTable args << tagid(pairs[i]) val = pairs[i+1] if val.kind_of?(Array) - args << val.join(',') + args << val.join(',') else - args << val + args << val end } tk_send('spans', *args) @@ -661,25 +661,25 @@ class Tk::TkTable # [idx, val], [idx, val], ... args = [] pairs.each{|idx, val| - args << tagid(idx) - if val.kind_of?(Array) - args << val.join(',') - else - args << val - end + args << tagid(idx) + if val.kind_of?(Array) + args << val.join(',') + else + args << val + end } tk_send('spans', *args) else # idx, val, idx, val, ... args = [] 0.step(pairs.size-1, 2){|i| - args << tagid(pairs[i]) - val = pairs[i+1] - if val.kind_of?(Array) - args << val.join(',') - else - args << val - end + args << tagid(pairs[i]) + val = pairs[i+1] + if val.kind_of?(Array) + args << val.join(',') + else + args << val + end } tk_send('spans', *args) end @@ -692,10 +692,10 @@ class Tk::TkTable tag.id elsif tag.kind_of?(Array) if tag[0].kind_of?(Integer) && tag[1].kind_of?(Integer) - # [row, col] - tag.join(',') + # [row, col] + tag.join(',') else - tag + tag end else tag @@ -705,9 +705,9 @@ class Tk::TkTable def tagid2obj(tagid) if Tk::TkTable::CellTag::CellTagID_TBL.key?(@path) if Tk::TkTable::CellTag::CellTagID_TBL[@path].key?(tagid) - Tk::TkTable::CellTag::CellTagID_TBL[@path][tagid] + Tk::TkTable::CellTag::CellTagID_TBL[@path][tagid] else - tagid + tagid end else tagid @@ -734,9 +734,9 @@ class Tk::TkTable tk_send('tag', 'delete', tagid(tag)) if Tk::TkTable::CellTag::CellTagID_TBL[@path] if tag.kind_of? Tk::TkTable::CellTag - Tk::TkTable::CellTag::CellTagID_TBL[@path].delete(tag.id) + Tk::TkTable::CellTag::CellTagID_TBL[@path].delete(tag.id) else - Tk::TkTable::CellTag::CellTagID_TBL[@path].delete(tag) + Tk::TkTable::CellTag::CellTagID_TBL[@path].delete(tag) end end self diff --git a/ext/tk/lib/tkextlib/tktrans/tktrans.rb b/ext/tk/lib/tkextlib/tktrans/tktrans.rb index 2acdac7217..55ac03e563 100644 --- a/ext/tk/lib/tkextlib/tktrans/tktrans.rb +++ b/ext/tk/lib/tkextlib/tktrans/tktrans.rb @@ -16,9 +16,9 @@ module Tk module TkTrans def self.package_version begin - TkPackage.require('tktrans') + TkPackage.require('tktrans') rescue - '' + '' end end end diff --git a/ext/tk/lib/tkextlib/treectrl/tktreectrl.rb b/ext/tk/lib/tkextlib/treectrl/tktreectrl.rb index 3ea1a324cb..cc23857c5f 100644 --- a/ext/tk/lib/tkextlib/treectrl/tktreectrl.rb +++ b/ext/tk/lib/tkextlib/treectrl/tktreectrl.rb @@ -18,9 +18,9 @@ module Tk class TreeCtrl < TkWindow def self.package_version begin - TkPackage.require('treectrl') + TkPackage.require('treectrl') rescue - '' + '' end end @@ -81,14 +81,14 @@ class Tk::TreeCtrl::NotifyEvent [ ?b, proc{|val| list(val)} ], [ ?e, proc{|val| - case val - when /^<<[^<>]+>>$/ - TkVirtualEvent.getobj(val[1..-2]) - when /^<[^<>]+>$/ - val[1..-2] - else - val - end + case val + when /^<<[^<>]+>>$/ + TkVirtualEvent.getobj(val[1..-2]) + when /^<[^<>]+>$/ + val[1..-2] + else + val + end } ], @@ -194,12 +194,12 @@ module Tk::TreeCtrl::ConfigMethod if id.kind_of?(Array) key = id[0] if key.kind_of?(Array) - key = key.join(' ') + key = key.join(' ') end tag = id[1] if tag.kind_of?(Array) - tag = tag.join(' ') + tag = tag.join(' ') end id = [key, tag].join(':') @@ -211,10 +211,10 @@ module Tk::TreeCtrl::ConfigMethod def __item_configinfo_struct(id) if id.kind_of?(Array) && id[0].to_s == 'notify' {:key=>0, :alias=>nil, :db_name=>nil, :db_class=>nil, - :default_value=>nil, :current_value=>1} + :default_value=>nil, :current_value=>1} else {:key=>0, :alias=>1, :db_name=>1, :db_class=>2, - :default_value=>3, :current_value=>4} + :default_value=>3, :current_value=>4} end end private :__item_configinfo_struct @@ -621,13 +621,13 @@ class Tk::TreeCtrl opts = opts.collect{|opt| if opt.kind_of?(Array) - key = "-#{opt[0]}" - flag = true if key == '-notreally' - ["-#{opt[0]}", opt[1]] + key = "-#{opt[0]}" + flag = true if key == '-notreally' + ["-#{opt[0]}", opt[1]] else - key = "-#{opt}" - flag = true if key == '-notreally' - key + key = "-#{opt}" + flag = true if key == '-notreally' + key end }.flatten @@ -664,9 +664,9 @@ class Tk::TreeCtrl def item_style_set(item, column=nil, *args) if args.empty? if column - tk_send('item', 'style', 'set', item, column) + tk_send('item', 'style', 'set', item, column) else - list(tk_send('item', 'style', 'set', item)) + list(tk_send('item', 'style', 'set', item)) end else tk_send('item', 'style', 'set', item, *(args.flatten)) @@ -677,10 +677,10 @@ class Tk::TreeCtrl def item_text(item, column, txt=nil, *args) if args.empty? if txt - tk_send('item', 'text', item, column, txt) - self + tk_send('item', 'text', item, column, txt) + self else - tk_send('item', 'text', item, column) + tk_send('item', 'text', item, column) end else tk_send('item', 'text', item, txt, *args) @@ -897,10 +897,10 @@ class Tk::TreeCtrl def style_layout(style, elem, keys=None) if keys && keys != None if keys.kind_of?(Hash) - tk_send('style', 'layout', style, elem, *hash_kv(keys)) - self + tk_send('style', 'layout', style, elem, *hash_kv(keys)) + self else - tk_send('style', 'layout', style, elem, "-#{keys}") + tk_send('style', 'layout', style, elem, "-#{keys}") end else list(tk_send('style', 'layout', style, elem)) diff --git a/ext/tk/lib/tkextlib/vu.rb b/ext/tk/lib/tkextlib/vu.rb index d3809f05b7..c4ea1b86e6 100644 --- a/ext/tk/lib/tkextlib/vu.rb +++ b/ext/tk/lib/tkextlib/vu.rb @@ -22,9 +22,9 @@ module Tk def self.package_version begin - TkPackage.require('vu') + TkPackage.require('vu') rescue - '' + '' end end diff --git a/ext/tk/lib/tkextlib/vu/charts.rb b/ext/tk/lib/tkextlib/vu/charts.rb index 594582d69b..a578c6979b 100644 --- a/ext/tk/lib/tkextlib/vu/charts.rb +++ b/ext/tk/lib/tkextlib/vu/charts.rb @@ -13,12 +13,12 @@ module Tk module ChartsConfig include TkItemConfigOptkeys def __item_boolval_optkeys(id) - super(id) << 'lefttrunc' << 'autocolor' + super(id) << 'lefttrunc' << 'autocolor' end private :__item_boolval_optkeys def __item_listval_optkeys(id) - super(id) << 'values' << 'tags' + super(id) << 'values' << 'tags' end private :__item_listval_optkeys end diff --git a/ext/tk/lib/tkextlib/vu/dial.rb b/ext/tk/lib/tkextlib/vu/dial.rb index e675ceb2de..e27a38ae42 100644 --- a/ext/tk/lib/tkextlib/vu/dial.rb +++ b/ext/tk/lib/tkextlib/vu/dial.rb @@ -58,7 +58,7 @@ class Tk::Vu::Dial < TkWindow ret = [] lst = simplelist(tk_call(@path, 'label')) while lst.size > 0 - ret << ([num_or_str(lst.shift)] << lst.shift) + ret << ([num_or_str(lst.shift)] << lst.shift) end end end @@ -80,7 +80,7 @@ class Tk::Vu::Dial < TkWindow ret = [] lst = simplelist(tk_call(@path, 'tag')) while lst.size > 0 - ret << ([num_or_str(lst.shift)] << lst.shift) + ret << ([num_or_str(lst.shift)] << lst.shift) end end end diff --git a/ext/tk/lib/tkextlib/winico/winico.rb b/ext/tk/lib/tkextlib/winico/winico.rb index 959f05ec79..8a71cbb401 100644 --- a/ext/tk/lib/tkextlib/winico/winico.rb +++ b/ext/tk/lib/tkextlib/winico/winico.rb @@ -18,9 +18,9 @@ module Tk class Winico < TkObject def self.package_version begin - TkPackage.require('winico') + TkPackage.require('winico') rescue - '' + '' end end end @@ -61,9 +61,9 @@ class Tk::Winico if resource_name # from resource if file_name - @id = Tk.tk_call('winico', 'load', resource_name, file_name) + @id = Tk.tk_call('winico', 'load', resource_name, file_name) else - @id = Tk.tk_call('winico', 'load', resource_name) + @id = Tk.tk_call('winico', 'load', resource_name) end elsif file_name # from .ico file @@ -72,7 +72,7 @@ class Tk::Winico @id = winico_id else fail ArgumentError, - "must be given proper information from where loading icons" + "must be given proper information from where loading icons" end @path = @id WinicoID_TBL[@id] = self @@ -104,35 +104,35 @@ class Tk::Winico class Winico_callback < TkValidateCommand class ValidateArgs < TkUtil::CallbackSubst KEY_TBL = [ - [ ?m, ?s, :message ], - [ ?i, ?x, :icon ], - [ ?x, ?n, :x ], - [ ?y, ?n, :y ], - [ ?X, ?n, :last_x ], - [ ?Y, ?n, :last_y ], - [ ?t, ?n, :tickcount ], - [ ?w, ?n, :icon_idnum ], - [ ?l, ?n, :msg_idnum ], - nil + [ ?m, ?s, :message ], + [ ?i, ?x, :icon ], + [ ?x, ?n, :x ], + [ ?y, ?n, :y ], + [ ?X, ?n, :last_x ], + [ ?Y, ?n, :last_y ], + [ ?t, ?n, :tickcount ], + [ ?w, ?n, :icon_idnum ], + [ ?l, ?n, :msg_idnum ], + nil ] PROC_TBL = [ - [ ?n, TkComm.method(:number) ], - [ ?s, TkComm.method(:string) ], - [ ?x, proc{|id| - if Tk::Winico::WinicoID_TBL.key?(id) - Tk::Winico::WinicoID_TBL[id] - else - Tk::Winico.new(nil, nil, id) - end - } ], - nil + [ ?n, TkComm.method(:number) ], + [ ?s, TkComm.method(:string) ], + [ ?x, proc{|id| + if Tk::Winico::WinicoID_TBL.key?(id) + Tk::Winico::WinicoID_TBL[id] + else + Tk::Winico.new(nil, nil, id) + end + } ], + nil ] _setup_subst_table(KEY_TBL, PROC_TBL); def self.ret_val(val) - val + val end end @@ -147,10 +147,10 @@ class Tk::Winico keys = _symbolkey2str(keys) Winico_callback._config_keys.each{|k| if keys[k].kind_of?(Array) - cmd, *args = keys[k] - keys[k] = Winico_callback.new(cmd, args.join(' ')) + cmd, *args = keys[k] + keys[k] = Winico_callback.new(cmd, args.join(' ')) elsif keys[k].kind_of?(Proc) - keys[k] = Winico_callback.new(keys[k]) + keys[k] = Winico_callback.new(keys[k]) end } tk_call('winico', 'taskbar', 'add', @id, *(hash_kv(keys))) @@ -162,10 +162,10 @@ class Tk::Winico keys = _symbolkey2str(keys) Winico_callback._config_keys.each{|k| if keys[k].kind_of?(Array) - cmd, *args = keys[k] - keys[k] = Winico_callback.new(cmd, args.join(' ')) + cmd, *args = keys[k] + keys[k] = Winico_callback.new(cmd, args.join(' ')) elsif keys[k].kind_of?(Proc) - keys[k] = Winico_callback.new(keys[k]) + keys[k] = Winico_callback.new(keys[k]) end } tk_call('winico', 'taskbar', 'modify', @id, *(hash_kv(keys))) -- cgit v1.2.3