From b12fcec3213fdaa1a56edf550f994ec349140588 Mon Sep 17 00:00:00 2001 From: nagai Date: Thu, 10 Mar 2005 10:14:13 +0000 Subject: * ext/tcltklib/tcltklib.c (lib_eventloop_ensure): mis-delete a timer handler when exit from a recursive called eventloop * ext/tk/lib/tk/timer.rb: new TkRTTimer class, which can works for a realtime operation * ext/tk/sample/tkrttimer.rb: sample of TkRTTimer class * ext/tk/lib/tk/textmark.rb: move TkTextMark#+ and TkTextMark#- to TkText::IndexModMethods * ext/tk/lib/tk/text.rb: improve TkTextMark#+ and TkTextMark#-, and add them to TkText::IndexModMethods module * ext/tk/sample/tktextio.rb: add test part of "seek by text index modifiers" git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@8135 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/tcltklib/tcltklib.c | 18 +-- ext/tk/lib/tk.rb | 44 +++--- ext/tk/lib/tk/autoload.rb | 1 + ext/tk/lib/tk/canvas.rb | 4 +- ext/tk/lib/tk/canvastag.rb | 4 +- ext/tk/lib/tk/entry.rb | 4 +- ext/tk/lib/tk/font.rb | 84 +++++------ ext/tk/lib/tk/grid.rb | 6 +- ext/tk/lib/tk/itemfont.rb | 30 ++-- ext/tk/lib/tk/kinput.rb | 28 ++-- ext/tk/lib/tk/listbox.rb | 4 +- ext/tk/lib/tk/menu.rb | 4 +- ext/tk/lib/tk/mngfocus.rb | 8 +- ext/tk/lib/tk/pack.rb | 6 +- ext/tk/lib/tk/palette.rb | 8 +- ext/tk/lib/tk/tagfont.rb | 12 +- ext/tk/lib/tk/text.rb | 44 ++++-- ext/tk/lib/tk/textmark.rb | 32 ++++- ext/tk/lib/tk/timer.rb | 98 +++++++++++++ ext/tk/lib/tk/winfo.rb | 184 ++++++++++++------------ ext/tk/lib/tk/wm.rb | 12 +- ext/tk/lib/tk/xim.rb | 40 +++--- ext/tk/lib/tkextlib/iwidgets/notebook.rb | 14 +- ext/tk/lib/tkextlib/iwidgets/promptdialog.rb | 4 +- ext/tk/lib/tkextlib/iwidgets/scrolledcanvas.rb | 4 +- ext/tk/lib/tkextlib/iwidgets/scrolledlistbox.rb | 4 +- ext/tk/lib/tkextlib/iwidgets/scrolledtext.rb | 4 +- ext/tk/lib/tkextlib/iwidgets/selectionbox.rb | 4 +- ext/tk/lib/tkextlib/iwidgets/selectiondialog.rb | 4 +- ext/tk/lib/tkextlib/iwidgets/spinner.rb | 4 +- ext/tk/sample/demos-en/widget | 12 +- ext/tk/sample/demos-jp/widget | 12 +- ext/tk/sample/tktextio.rb | 18 +++ 33 files changed, 465 insertions(+), 294 deletions(-) (limited to 'ext') diff --git a/ext/tcltklib/tcltklib.c b/ext/tcltklib/tcltklib.c index aae7ac5486..8756d54252 100644 --- a/ext/tcltklib/tcltklib.c +++ b/ext/tcltklib/tcltklib.c @@ -4,7 +4,7 @@ * Oct. 24, 1997 Y. Matsumoto */ -#define TCLTKLIB_RELEASE_DATE "2005-03-02" +#define TCLTKLIB_RELEASE_DATE "2005-03-10" #include "ruby.h" #include "rubysig.h" @@ -652,7 +652,7 @@ _timer_for_tcl(clientData) /* struct invoke_queue *q, *tmp; */ /* VALUE thread; */ - DUMP1("called timer_for_tcl"); + DUMP1("call _timer_for_tcl"); thr_crit_bup = rb_thread_critical; rb_thread_critical = Qtrue; @@ -1402,9 +1402,6 @@ lib_eventloop_ensure(args) struct evloop_params *ptr = (struct evloop_params *)args; volatile VALUE current_evloop = rb_thread_current(); - Tk_DeleteTimerHandler(timer_token); - timer_token = (Tcl_TimerToken)NULL; - DUMP2("eventloop_ensure: current-thread : %lx", current_evloop); DUMP2("eventloop_ensure: eventloop-thread : %lx", eventloop_thread); if (eventloop_thread != current_evloop) { @@ -1422,7 +1419,12 @@ lib_eventloop_ensure(args) break; } - if (NIL_P(eventloop_thread)) break; + if (NIL_P(eventloop_thread)) { + Tk_DeleteTimerHandler(timer_token); + timer_token = (Tcl_TimerToken)NULL; + + break; + } if (RTEST(rb_funcall(eventloop_thread, ID_alive_p, 0, 0))) { DUMP2("eventloop-enshure: wake up parent %lx", eventloop_thread); @@ -7889,7 +7891,7 @@ lib_split_tklist_core(ip_obj, list_str) if (result == TCL_ERROR) { Tcl_DecrRefCount(listobj); if (interp == (Tcl_Interp*)NULL) { - rb_raise(rb_eRuntimeError, "cannot get elements from list"); + rb_raise(rb_eRuntimeError, "can't get elements from list"); } else { #if TCL_MAJOR_VERSION >= 8 rb_raise(rb_eRuntimeError, "%s", Tcl_GetStringResult(interp)); @@ -7961,7 +7963,7 @@ lib_split_tklist_core(ip_obj, list_str) if (Tcl_SplitList(interp, RSTRING(list_str)->ptr, &argc, &argv) == TCL_ERROR) { if (interp == (Tcl_Interp*)NULL) { - rb_raise(rb_eRuntimeError, "cannot get elements from list"); + rb_raise(rb_eRuntimeError, "can't get elements from list"); } else { rb_raise(rb_eRuntimeError, "%s", interp->result); } diff --git a/ext/tk/lib/tk.rb b/ext/tk/lib/tk.rb index 349529f9b4..b643616f78 100644 --- a/ext/tk/lib/tk.rb +++ b/ext/tk/lib/tk.rb @@ -1470,14 +1470,14 @@ module TkCore nil end - def event_generate(window, context, keys=nil) - #window = window.path if window.kind_of?(TkObject) + def event_generate(win, context, keys=nil) + #win = win.path if win.kind_of?(TkObject) if keys - tk_call_without_enc('event', 'generate', window, + tk_call_without_enc('event', 'generate', win, "<#{tk_event_sequence(context)}>", *hash_kv(keys, true)) else - tk_call_without_enc('event', 'generate', window, + tk_call_without_enc('event', 'generate', win, "<#{tk_event_sequence(context)}>") end nil @@ -1874,8 +1874,8 @@ module Tk TkManageFocus.prev(win) end - def Tk.strictMotif(bool=None) - bool(tk_call_without_enc('set', 'tk_strictMotif', bool)) + def Tk.strictMotif(mode=None) + bool(tk_call_without_enc('set', 'tk_strictMotif', mode)) end def Tk.show_kinsoku(mode='both') @@ -2435,18 +2435,18 @@ module TkTreatFont self end - def font_copy(window, wintag=nil, winkey=nil, targetkey=nil) + def font_copy(win, wintag=nil, winkey=nil, targetkey=nil) if wintag if winkey - fnt = window.tagfontobj(wintag, winkey).dup + fnt = win.tagfontobj(wintag, winkey).dup else - fnt = window.tagfontobj(wintag).dup + fnt = win.tagfontobj(wintag).dup end else if winkey - fnt = window.fontobj(winkey).dup + fnt = win.fontobj(winkey).dup else - fnt = window.fontobj.dup + fnt = win.fontobj.dup end end @@ -2458,7 +2458,7 @@ module TkTreatFont self end - def latinfont_copy(window, wintag=nil, winkey=nil, targetkey=nil) + def latinfont_copy(win, wintag=nil, winkey=nil, targetkey=nil) if targetkey fontobj(targetkey).dup.call_font_configure([__pathname, targetkey], *(__config_cmd << {})) @@ -2468,22 +2468,22 @@ module TkTreatFont if wintag if winkey - fontobj.latin_replace(window.tagfontobj(wintag, winkey).latin_font_id) + fontobj.latin_replace(win.tagfontobj(wintag, winkey).latin_font_id) else - fontobj.latin_replace(window.tagfontobj(wintag).latin_font_id) + fontobj.latin_replace(win.tagfontobj(wintag).latin_font_id) end else if winkey - fontobj.latin_replace(window.fontobj(winkey).latin_font_id) + fontobj.latin_replace(win.fontobj(winkey).latin_font_id) else - fontobj.latin_replace(window.fontobj.latin_font_id) + fontobj.latin_replace(win.fontobj.latin_font_id) end end self end alias asciifont_copy latinfont_copy - def kanjifont_copy(window, wintag=nil, winkey=nil, targetkey=nil) + def kanjifont_copy(win, wintag=nil, winkey=nil, targetkey=nil) if targetkey fontobj(targetkey).dup.call_font_configure([__pathname, targetkey], *(__config_cmd << {})) @@ -2493,15 +2493,15 @@ module TkTreatFont if wintag if winkey - fontobj.kanji_replace(window.tagfontobj(wintag, winkey).kanji_font_id) + fontobj.kanji_replace(win.tagfontobj(wintag, winkey).kanji_font_id) else - fontobj.kanji_replace(window.tagfontobj(wintag).kanji_font_id) + fontobj.kanji_replace(win.tagfontobj(wintag).kanji_font_id) end else if winkey - fontobj.kanji_replace(window.fontobj(winkey).kanji_font_id) + fontobj.kanji_replace(win.fontobj(winkey).kanji_font_id) else - fontobj.kanji_replace(window.fontobj.kanji_font_id) + fontobj.kanji_replace(win.fontobj.kanji_font_id) end end self @@ -4002,7 +4002,7 @@ end #Tk.freeze module Tk - RELEASE_DATE = '2005-03-05'.freeze + RELEASE_DATE = '2005-03-10'.freeze autoload :AUTO_PATH, 'tk/variable' autoload :TCL_PACKAGE_PATH, 'tk/variable' diff --git a/ext/tk/lib/tk/autoload.rb b/ext/tk/lib/tk/autoload.rb index 3006b559d6..df884a0a30 100644 --- a/ext/tk/lib/tk/autoload.rb +++ b/ext/tk/lib/tk/autoload.rb @@ -148,6 +148,7 @@ autoload :TkTextWindow, 'tk/textwindow' autoload :TkAfter, 'tk/timer' autoload :TkTimer, 'tk/timer' +autoload :TkRTTimer, 'tk/timer' autoload :TkToplevel, 'tk/toplevel' diff --git a/ext/tk/lib/tk/canvas.rb b/ext/tk/lib/tk/canvas.rb index 0a2bcad9f1..6651819c03 100644 --- a/ext/tk/lib/tk/canvas.rb +++ b/ext/tk/lib/tk/canvas.rb @@ -227,8 +227,8 @@ class TkCanvas= @proc_max + if @do_loop < 0 || (@do_loop -= 1) > 0 + @current_pos = 0 + else + Tk_CBTBL.delete(@id) ;# for GC + @running = false + @wait_var.value = 0 + return + end + end + + @current_args = args + + cmd, *cmd_args = @loop_proc[@current_pos] + @current_pos += 1 + @current_proc = cmd + + if TkComm._callback_entry?(@sleep_time) + sleep = @sleep_time.call(self) + else + sleep = @sleep_time + end + + if @est_time + @est_time = Time.at(@est_time.to_f + sleep / 1000.0) + else + @est_time = Time.at(@cb_start_time.to_f + sleep / 1000.0) + end + + offset = _offset_ave + + real_sleep = ((@est_time - Time.now)*1000.0 + offset).round + real_sleep = 0 if real_sleep < 0 + @current_sleep = real_sleep + + set_callback(real_sleep, cmd_args) + end + + def cb_call + @cb_start_time = Time.now + + if @est_time + @offset_list.shift + @offset_list.push((@est_time - @cb_start_time) * 1000.0) + end + + @cb_cmd.call + end +end diff --git a/ext/tk/lib/tk/winfo.rb b/ext/tk/lib/tk/winfo.rb index 948042558d..0f58f74a8c 100644 --- a/ext/tk/lib/tk/winfo.rb +++ b/ext/tk/lib/tk/winfo.rb @@ -36,30 +36,30 @@ module TkWinfo TkWinfo.atomname(id, self) end - def TkWinfo.cells(window) - number(tk_call_without_enc('winfo', 'cells', window)) + def TkWinfo.cells(win) + number(tk_call_without_enc('winfo', 'cells', win)) end def winfo_cells TkWinfo.cells self end - def TkWinfo.children(window) - list(tk_call_without_enc('winfo', 'children', window)) + def TkWinfo.children(win) + list(tk_call_without_enc('winfo', 'children', win)) end def winfo_children TkWinfo.children self end - def TkWinfo.classname(window) - tk_call_without_enc('winfo', 'class', window) + def TkWinfo.classname(win) + tk_call_without_enc('winfo', 'class', win) end def winfo_classname TkWinfo.classname self end alias winfo_class winfo_classname - def TkWinfo.colormapfull(window) - bool(tk_call_without_enc('winfo', 'colormapfull', window)) + def TkWinfo.colormapfull(win) + bool(tk_call_without_enc('winfo', 'colormapfull', win)) end def winfo_colormapfull TkWinfo.colormapfull self @@ -77,52 +77,52 @@ module TkWinfo TkWinfo.containing(x, y, self) end - def TkWinfo.depth(window) - number(tk_call_without_enc('winfo', 'depth', window)) + def TkWinfo.depth(win) + number(tk_call_without_enc('winfo', 'depth', win)) end def winfo_depth TkWinfo.depth self end - def TkWinfo.exist?(window) - bool(tk_call_without_enc('winfo', 'exists', window)) + def TkWinfo.exist?(win) + bool(tk_call_without_enc('winfo', 'exists', win)) end def winfo_exist? TkWinfo.exist? self end - def TkWinfo.fpixels(window, dist) - number(tk_call_without_enc('winfo', 'fpixels', window, dist)) + def TkWinfo.fpixels(win, dist) + number(tk_call_without_enc('winfo', 'fpixels', win, dist)) end def winfo_fpixels(dist) TkWinfo.fpixels self, dist end - def TkWinfo.geometry(window) - tk_call_without_enc('winfo', 'geometry', window) + def TkWinfo.geometry(win) + tk_call_without_enc('winfo', 'geometry', win) end def winfo_geometry TkWinfo.geometry self end - def TkWinfo.height(window) - number(tk_call_without_enc('winfo', 'height', window)) + def TkWinfo.height(win) + number(tk_call_without_enc('winfo', 'height', win)) end def winfo_height TkWinfo.height self end - def TkWinfo.id(window) - tk_call_without_enc('winfo', 'id', window) + def TkWinfo.id(win) + tk_call_without_enc('winfo', 'id', win) end def winfo_id TkWinfo.id self end - def TkWinfo.interps(window=nil) - if window + def TkWinfo.interps(win=nil) + if win tk_split_simplelist(tk_call_without_enc('winfo', 'interps', - '-displayof', window)) + '-displayof', win)) else tk_split_simplelist(tk_call_without_enc('winfo', 'interps')) end @@ -131,29 +131,29 @@ module TkWinfo TkWinfo.interps self end - def TkWinfo.mapped?(window) - bool(tk_call_without_enc('winfo', 'ismapped', window)) + def TkWinfo.mapped?(win) + bool(tk_call_without_enc('winfo', 'ismapped', win)) end def winfo_mapped? TkWinfo.mapped? self end - def TkWinfo.manager(window) - tk_call_without_enc('winfo', 'manager', window) + def TkWinfo.manager(win) + tk_call_without_enc('winfo', 'manager', win) end def winfo_manager TkWinfo.manager self end - def TkWinfo.appname(window) - tk_call('winfo', 'name', window) + def TkWinfo.appname(win) + tk_call('winfo', 'name', win) end def winfo_appname TkWinfo.appname self end - def TkWinfo.parent(window) - window(tk_call_without_enc('winfo', 'parent', window)) + def TkWinfo.parent(win) + window(tk_call_without_enc('winfo', 'parent', win)) end def winfo_parent TkWinfo.parent self @@ -170,216 +170,216 @@ module TkWinfo TkWinfo.widget id, self end - def TkWinfo.pixels(window, dist) - number(tk_call_without_enc('winfo', 'pixels', window, dist)) + def TkWinfo.pixels(win, dist) + number(tk_call_without_enc('winfo', 'pixels', win, dist)) end def winfo_pixels(dist) TkWinfo.pixels self, dist end - def TkWinfo.reqheight(window) - number(tk_call_without_enc('winfo', 'reqheight', window)) + def TkWinfo.reqheight(win) + number(tk_call_without_enc('winfo', 'reqheight', win)) end def winfo_reqheight TkWinfo.reqheight self end - def TkWinfo.reqwidth(window) - number(tk_call_without_enc('winfo', 'reqwidth', window)) + def TkWinfo.reqwidth(win) + number(tk_call_without_enc('winfo', 'reqwidth', win)) end def winfo_reqwidth TkWinfo.reqwidth self end - def TkWinfo.rgb(window, color) - list(tk_call_without_enc('winfo', 'rgb', window, color)) + def TkWinfo.rgb(win, color) + list(tk_call_without_enc('winfo', 'rgb', win, color)) end def winfo_rgb(color) TkWinfo.rgb self, color end - def TkWinfo.rootx(window) - number(tk_call_without_enc('winfo', 'rootx', window)) + def TkWinfo.rootx(win) + number(tk_call_without_enc('winfo', 'rootx', win)) end def winfo_rootx TkWinfo.rootx self end - def TkWinfo.rooty(window) - number(tk_call_without_enc('winfo', 'rooty', window)) + def TkWinfo.rooty(win) + number(tk_call_without_enc('winfo', 'rooty', win)) end def winfo_rooty TkWinfo.rooty self end - def TkWinfo.screen(window) - tk_call('winfo', 'screen', window) + def TkWinfo.screen(win) + tk_call('winfo', 'screen', win) end def winfo_screen TkWinfo.screen self end - def TkWinfo.screencells(window) - number(tk_call_without_enc('winfo', 'screencells', window)) + def TkWinfo.screencells(win) + number(tk_call_without_enc('winfo', 'screencells', win)) end def winfo_screencells TkWinfo.screencells self end - def TkWinfo.screendepth(window) - number(tk_call_without_enc('winfo', 'screendepth', window)) + def TkWinfo.screendepth(win) + number(tk_call_without_enc('winfo', 'screendepth', win)) end def winfo_screendepth TkWinfo.screendepth self end - def TkWinfo.screenheight (window) - number(tk_call_without_enc('winfo', 'screenheight', window)) + def TkWinfo.screenheight (win) + number(tk_call_without_enc('winfo', 'screenheight', win)) end def winfo_screenheight TkWinfo.screenheight self end - def TkWinfo.screenmmheight(window) - number(tk_call_without_enc('winfo', 'screenmmheight', window)) + def TkWinfo.screenmmheight(win) + number(tk_call_without_enc('winfo', 'screenmmheight', win)) end def winfo_screenmmheight TkWinfo.screenmmheight self end - def TkWinfo.screenmmwidth(window) - number(tk_call_without_enc('winfo', 'screenmmwidth', window)) + def TkWinfo.screenmmwidth(win) + number(tk_call_without_enc('winfo', 'screenmmwidth', win)) end def winfo_screenmmwidth TkWinfo.screenmmwidth self end - def TkWinfo.screenvisual(window) - tk_call_without_enc('winfo', 'screenvisual', window) + def TkWinfo.screenvisual(win) + tk_call_without_enc('winfo', 'screenvisual', win) end def winfo_screenvisual TkWinfo.screenvisual self end - def TkWinfo.screenwidth(window) - number(tk_call_without_enc('winfo', 'screenwidth', window)) + def TkWinfo.screenwidth(win) + number(tk_call_without_enc('winfo', 'screenwidth', win)) end def winfo_screenwidth TkWinfo.screenwidth self end - def TkWinfo.server(window) - tk_call('winfo', 'server', window) + def TkWinfo.server(win) + tk_call('winfo', 'server', win) end def winfo_server TkWinfo.server self end - def TkWinfo.toplevel(window) - window(tk_call_without_enc('winfo', 'toplevel', window)) + def TkWinfo.toplevel(win) + window(tk_call_without_enc('winfo', 'toplevel', win)) end def winfo_toplevel TkWinfo.toplevel self end - def TkWinfo.visual(window) - tk_call_without_enc('winfo', 'visual', window) + def TkWinfo.visual(win) + tk_call_without_enc('winfo', 'visual', win) end def winfo_visual TkWinfo.visual self end - def TkWinfo.visualid(window) - tk_call_without_enc('winfo', 'visualid', window) + def TkWinfo.visualid(win) + tk_call_without_enc('winfo', 'visualid', win) end def winfo_visualid TkWinfo.visualid self end - def TkWinfo.visualsavailable(window, includeids=false) + def TkWinfo.visualsavailable(win, includeids=false) if includeids list(tk_call_without_enc('winfo', 'visualsavailable', - window, "includeids")) + win, "includeids")) else - list(tk_call_without_enc('winfo', 'visualsavailable', window)) + list(tk_call_without_enc('winfo', 'visualsavailable', win)) end end def winfo_visualsavailable(includeids=false) TkWinfo.visualsavailable self, includeids end - def TkWinfo.vrootheight(window) - number(tk_call_without_enc('winfo', 'vrootheight', window)) + def TkWinfo.vrootheight(win) + number(tk_call_without_enc('winfo', 'vrootheight', win)) end def winfo_vrootheight TkWinfo.vrootheight self end - def TkWinfo.vrootwidth(window) - number(tk_call_without_enc('winfo', 'vrootwidth', window)) + def TkWinfo.vrootwidth(win) + number(tk_call_without_enc('winfo', 'vrootwidth', win)) end def winfo_vrootwidth TkWinfo.vrootwidth self end - def TkWinfo.vrootx(window) - number(tk_call_without_enc('winfo', 'vrootx', window)) + def TkWinfo.vrootx(win) + number(tk_call_without_enc('winfo', 'vrootx', win)) end def winfo_vrootx TkWinfo.vrootx self end - def TkWinfo.vrooty(window) - number(tk_call_without_enc('winfo', 'vrooty', window)) + def TkWinfo.vrooty(win) + number(tk_call_without_enc('winfo', 'vrooty', win)) end def winfo_vrooty TkWinfo.vrooty self end - def TkWinfo.width(window) - number(tk_call_without_enc('winfo', 'width', window)) + def TkWinfo.width(win) + number(tk_call_without_enc('winfo', 'width', win)) end def winfo_width TkWinfo.width self end - def TkWinfo.x(window) - number(tk_call_without_enc('winfo', 'x', window)) + def TkWinfo.x(win) + number(tk_call_without_enc('winfo', 'x', win)) end def winfo_x TkWinfo.x self end - def TkWinfo.y(window) - number(tk_call_without_enc('winfo', 'y', window)) + def TkWinfo.y(win) + number(tk_call_without_enc('winfo', 'y', win)) end def winfo_y TkWinfo.y self end - def TkWinfo.viewable(window) - bool(tk_call_without_enc('winfo', 'viewable', window)) + def TkWinfo.viewable(win) + bool(tk_call_without_enc('winfo', 'viewable', win)) end def winfo_viewable TkWinfo.viewable self end - def TkWinfo.pointerx(window) - number(tk_call_without_enc('winfo', 'pointerx', window)) + def TkWinfo.pointerx(win) + number(tk_call_without_enc('winfo', 'pointerx', win)) end def winfo_pointerx TkWinfo.pointerx self end - def TkWinfo.pointery(window) - number(tk_call_without_enc('winfo', 'pointery', window)) + def TkWinfo.pointery(win) + number(tk_call_without_enc('winfo', 'pointery', win)) end def winfo_pointery TkWinfo.pointery self end - def TkWinfo.pointerxy(window) - list(tk_call_without_enc('winfo', 'pointerxy', window)) + def TkWinfo.pointerxy(win) + list(tk_call_without_enc('winfo', 'pointerxy', win)) end def winfo_pointerxy TkWinfo.pointerxy self diff --git a/ext/tk/lib/tk/wm.rb b/ext/tk/lib/tk/wm.rb index a2be51248d..f3cfb0afb1 100644 --- a/ext/tk/lib/tk/wm.rb +++ b/ext/tk/lib/tk/wm.rb @@ -192,11 +192,11 @@ module Tk end end - def overrideredirect(bool=None) - if bool == None + def overrideredirect(mode=None) + if mode == None bool(tk_call_without_enc('wm', 'overrideredirect', path)) else - tk_call_without_enc('wm', 'overrideredirect', path, bool) + tk_call_without_enc('wm', 'overrideredirect', path, mode) self end end @@ -257,9 +257,9 @@ module Tk bool(tk_call('wm', 'stackorder', path, 'isbelow', win)) end - def state(state=nil) - if state - tk_call_without_enc('wm', 'state', path, state) + def state(st=nil) + if st + tk_call_without_enc('wm', 'state', path, st) self else tk_call_without_enc('wm', 'state', path) diff --git a/ext/tk/lib/tk/xim.rb b/ext/tk/lib/tk/xim.rb index 701cd7531c..0ac8559bb9 100644 --- a/ext/tk/lib/tk/xim.rb +++ b/ext/tk/lib/tk/xim.rb @@ -9,34 +9,34 @@ module TkXIM TkCommandNames = ['imconfigure'.freeze].freeze - def TkXIM.useinputmethods(value = None, window = nil) + def TkXIM.useinputmethods(value = None, win = nil) if value == None - if window + if win bool(tk_call_without_enc('tk', 'useinputmethods', - '-displayof', window)) + '-displayof', win)) else bool(tk_call_without_enc('tk', 'useinputmethods')) end else - if window + if win bool(tk_call_without_enc('tk', 'useinputmethods', - '-displayof', window, value)) + '-displayof', win, value)) else bool(tk_call_without_enc('tk', 'useinputmethods', value)) end end end - def TkXIM.useinputmethods_displayof(window, value = None) - TkXIM.useinputmethods(value, window) + def TkXIM.useinputmethods_displayof(win, value = None) + TkXIM.useinputmethods(value, win) end - def TkXIM.caret(window, keys=nil) + def TkXIM.caret(win, keys=nil) if keys - tk_call_without_enc('tk', 'caret', window, *hash_kv(keys)) + tk_call_without_enc('tk', 'caret', win, *hash_kv(keys)) self else - lst = tk_split_list(tk_call_without_enc('tk', 'caret', window)) + lst = tk_split_list(tk_call_without_enc('tk', 'caret', win)) info = {} while key = lst.shift info[key[1..-1]] = lst.shift @@ -45,29 +45,29 @@ module TkXIM end end - def TkXIM.configure(window, slot, value=None) + def TkXIM.configure(win, slot, value=None) begin if /^8\.*/ === Tk::TK_VERSION && JAPANIZED_TK if slot.kind_of? Hash - tk_call('imconfigure', window, *hash_kv(slot)) + tk_call('imconfigure', win, *hash_kv(slot)) else - tk_call('imconfigure', window, "-#{slot}", value) + tk_call('imconfigure', win, "-#{slot}", value) end end rescue end end - def TkXIM.configinfo(window, slot=nil) + def TkXIM.configinfo(win, 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 = tk_split_list(tk_call('imconfigure', win, "-#{slot}")) conf[0] = conf[0][1..-1] conf else - tk_split_list(tk_call('imconfigure', window)).collect{|conf| + tk_split_list(tk_call('imconfigure', win)).collect{|conf| conf[0] = conf[0][1..-1] conf } @@ -79,19 +79,19 @@ module TkXIM [] end else # ! TkComm::GET_CONFIGINFOwoRES_AS_ARRAY - TkXIM.current_configinfo(window, slot) + TkXIM.current_configinfo(win, slot) end end - def TkXIM.current_configinfo(window, slot=nil) + def TkXIM.current_configinfo(win, slot=nil) begin if /^8\.*/ === Tk::TK_VERSION && JAPANIZED_TK if slot - conf = tk_split_list(tk_call('imconfigure', window, "-#{slot}")) + conf = tk_split_list(tk_call('imconfigure', win, "-#{slot}")) { conf[0][1..-1] => conf[1] } else ret = {} - tk_split_list(tk_call('imconfigure', window)).each{|conf| + tk_split_list(tk_call('imconfigure', win)).each{|conf| ret[conf[0][1..-1]] = conf[1] } ret diff --git a/ext/tk/lib/tkextlib/iwidgets/notebook.rb b/ext/tk/lib/tkextlib/iwidgets/notebook.rb index d9abf1b02b..c0897b884f 100644 --- a/ext/tk/lib/tkextlib/iwidgets/notebook.rb +++ b/ext/tk/lib/tkextlib/iwidgets/notebook.rb @@ -139,24 +139,24 @@ class Tk::Iwidgets::Notebook end alias scrollbar yscrollbar - def view(*index) - if index.size == 0 + def view(*idxs) + if idxss.size == 0 window(tk_send_without_enc('view')) else - tk_send_without_enc('view', *index) + tk_send_without_enc('view', *idxs) self end end alias xview view alias yview view - def view_moveto(*index) - view('moveto', *index) + def view_moveto(*idxs) + view('moveto', *idxs) end alias xview_moveto view_moveto alias yview_moveto view_moveto - def view_scroll(*index) - view('scroll', *index) + def view_scroll(*idxs) + view('scroll', *idxs) end alias xview_scroll view_scroll alias yview_scroll view_scroll diff --git a/ext/tk/lib/tkextlib/iwidgets/promptdialog.rb b/ext/tk/lib/tkextlib/iwidgets/promptdialog.rb index ec18647511..620b14b5d5 100644 --- a/ext/tk/lib/tkextlib/iwidgets/promptdialog.rb +++ b/ext/tk/lib/tkextlib/iwidgets/promptdialog.rb @@ -73,8 +73,8 @@ class Tk::Iwidgets::Promptdialog end alias icursor cursor= - def index(index) - number(tk_send_without_enc('index', index)) + def index(idx) + number(tk_send_without_enc('index', idx)) end def insert(pos,text) diff --git a/ext/tk/lib/tkextlib/iwidgets/scrolledcanvas.rb b/ext/tk/lib/tkextlib/iwidgets/scrolledcanvas.rb index d4b9b48fe0..e949955a31 100644 --- a/ext/tk/lib/tkextlib/iwidgets/scrolledcanvas.rb +++ b/ext/tk/lib/tkextlib/iwidgets/scrolledcanvas.rb @@ -228,8 +228,8 @@ class Tk::Iwidgets::Scrolledcanvas self end - def index(tagOrId, index) - number(tk_send_without_enc('index', tagid(tagOrId), index)) + def index(tagOrId, idx) + number(tk_send_without_enc('index', tagid(tagOrId), idx)) end def insert(tagOrId, index, string) diff --git a/ext/tk/lib/tkextlib/iwidgets/scrolledlistbox.rb b/ext/tk/lib/tkextlib/iwidgets/scrolledlistbox.rb index 9fe23b4edc..ef98979aed 100644 --- a/ext/tk/lib/tkextlib/iwidgets/scrolledlistbox.rb +++ b/ext/tk/lib/tkextlib/iwidgets/scrolledlistbox.rb @@ -152,8 +152,8 @@ class Tk::Iwidgets::Scrolledlistbox self end - def index(index) - tk_send_without_enc('index', index).to_i + def index(idx) + tk_send_without_enc('index', idx).to_i end ##################################### diff --git a/ext/tk/lib/tkextlib/iwidgets/scrolledtext.rb b/ext/tk/lib/tkextlib/iwidgets/scrolledtext.rb index 39a9ed63c8..bfff6804d2 100644 --- a/ext/tk/lib/tkextlib/iwidgets/scrolledtext.rb +++ b/ext/tk/lib/tkextlib/iwidgets/scrolledtext.rb @@ -240,8 +240,8 @@ class Tk::Iwidgets::Scrolledtext } end - def index(index) - tk_send_without_enc('index', _get_eval_enc_str(index)) + def index(idx) + tk_send_without_enc('index', _get_eval_enc_str(idx)) end def insert(index, *args) diff --git a/ext/tk/lib/tkextlib/iwidgets/selectionbox.rb b/ext/tk/lib/tkextlib/iwidgets/selectionbox.rb index 91ba9248e1..154a9792da 100644 --- a/ext/tk/lib/tkextlib/iwidgets/selectionbox.rb +++ b/ext/tk/lib/tkextlib/iwidgets/selectionbox.rb @@ -57,8 +57,8 @@ class Tk::Iwidgets::Selectionbox tk_send_without_enc('delete', first, last) self end - def index(index) - tk_send_without_enc('index', index).to_i + def index(idx) + tk_send_without_enc('index', idx).to_i end def nearest(y) tk_send_without_enc('nearest', y).to_i diff --git a/ext/tk/lib/tkextlib/iwidgets/selectiondialog.rb b/ext/tk/lib/tkextlib/iwidgets/selectiondialog.rb index 794da5d61c..ab790e97a6 100644 --- a/ext/tk/lib/tkextlib/iwidgets/selectiondialog.rb +++ b/ext/tk/lib/tkextlib/iwidgets/selectiondialog.rb @@ -57,8 +57,8 @@ class Tk::Iwidgets::Selectiondialog tk_send_without_enc('delete', first, last) self end - def index(index) - tk_send_without_enc('index', index).to_i + def index(idx) + tk_send_without_enc('index', idx).to_i end def nearest(y) tk_send_without_enc('nearest', y).to_i diff --git a/ext/tk/lib/tkextlib/iwidgets/spinner.rb b/ext/tk/lib/tkextlib/iwidgets/spinner.rb index b5c72b4df8..4dac4ed582 100644 --- a/ext/tk/lib/tkextlib/iwidgets/spinner.rb +++ b/ext/tk/lib/tkextlib/iwidgets/spinner.rb @@ -91,8 +91,8 @@ class Tk::Iwidgets::Spinner end alias icursor cursor= - def index(index) - number(tk_send_without_enc('index', index)) + def index(idx) + number(tk_send_without_enc('index', idx)) end def insert(pos,text) diff --git a/ext/tk/sample/demos-en/widget b/ext/tk/sample/demos-en/widget index b8073a05da..43880e6d23 100644 --- a/ext/tk/sample/demos-en/widget +++ b/ext/tk/sample/demos-en/widget @@ -517,10 +517,10 @@ end # txt - Name of text widget # index - The index of the character that the user clicked on. -def invoke (txt, index) - tag = txt.tag_names(index).find{|t| t.kind_of?(String) && t =~ /^demo-/} +def invoke (txt, idx) + tag = txt.tag_names(idx).find{|t| t.kind_of?(String) && t =~ /^demo-/} return unless tag - cursor = txt.cget('cursor') + current_cursor = txt.cget('cursor') txt.cursor('watch') Tk.update # eval `cat #{tag[5..-1]}.rb` @@ -528,9 +528,9 @@ def invoke (txt, index) eval IO.readlines("#{[$demo_dir, tag[5..-1]].join(File::Separator)}.rb").join Tk.update # txt.cursor('xterm') - txt.cursor(cursor) + txt.cursor(current_cursor) - $tag_visited.add("#{index} linestart +1 chars", "#{index} lineend +1 chars") + $tag_visited.add("#{idx} linestart +1 chars", "#{idx} lineend +1 chars") end # showStatus -- @@ -791,7 +791,7 @@ end # def aboutBox Tk.messageBox('icon'=>'info', 'type'=>'ok', 'title'=>'About Widget Demo', - 'message'=>"Ruby/Tk widget demonstration Ver.1.5.2-en\n\n" + + 'message'=>"Ruby/Tk widget demonstration Ver.1.5.3-en\n\n" + "based on demos of Tk8.1 -- 8.5 " + "( Copyright:: " + "(c) 1996-1997 Sun Microsystems, Inc. / " + diff --git a/ext/tk/sample/demos-jp/widget b/ext/tk/sample/demos-jp/widget index 59d6309d56..7c559d2a09 100644 --- a/ext/tk/sample/demos-jp/widget +++ b/ext/tk/sample/demos-jp/widget @@ -552,10 +552,10 @@ else # ver >= 8.4 end # テキスト上での click に対する動作 -def invoke (txt, index) - tag = txt.tag_names(index).find{|t| t.kind_of?(String) && t =~ /^demo-/} +def invoke (txt, idx) + tag = txt.tag_names(idx).find{|t| t.kind_of?(String) && t =~ /^demo-/} return unless tag - cursor = txt.cget('cursor') + current_cursor = txt.cget('cursor') txt.cursor('watch') Tk.update # eval `cat #{tag[5..-1]}.rb` @@ -563,9 +563,9 @@ def invoke (txt, index) eval IO.readlines("#{[$demo_dir, tag[5..-1]].join(File::Separator)}.rb").join Tk.update # txt.cursor('xterm') - txt.cursor(cursor) + txt.cursor(current_cursor) - $tag_visited.add("#{index} linestart +1 chars", "#{index} lineend +1 chars") + $tag_visited.add("#{idx} linestart +1 chars", "#{idx} lineend +1 chars") end # 状態表示 @@ -819,7 +819,7 @@ end # def aboutBox Tk.messageBox('icon'=>'info', 'type'=>'ok', 'title'=>'About Widget Demo', - 'message'=>"Ruby/Tk ウィジェットデモ Ver.1.5.2-jp\n\n" + + 'message'=>"Ruby/Tk ウィジェットデモ Ver.1.5.3-jp\n\n" + "based on demos of Tk8.1 -- 8.5 " + "( Copyright:: " + "(c) 1996-1997 Sun Microsystems, Inc. / " + diff --git a/ext/tk/sample/tktextio.rb b/ext/tk/sample/tktextio.rb index fecedf6ee1..cb59c2d9d6 100644 --- a/ext/tk/sample/tktextio.rb +++ b/ext/tk/sample/tktextio.rb @@ -581,5 +581,23 @@ if __FILE__ == $0 STDOUT.print("\n================================================\n\n") + STDOUT.print("\n========= reverse order (seek by lines) ========\n\n") + + tio.seek(-1, IO::SEEK_END) + begin + begin + tio.seek(:linestart, IO::SEEK_CUR) + rescue + # maybe use old version of tk/textmark.rb + tio.seek('0 char linestart', IO::SEEK_CUR) + end + STDOUT.print(gets) + tio.seek('-1 char linestart -1 char', IO::SEEK_CUR) + end while(tio.pos > 0) + + STDOUT.print("\n================================================\n\n") + + tio.seek(0, IO::SEEK_END) + Tk.mainloop end -- cgit v1.2.3