summaryrefslogtreecommitdiff
path: root/ext/tk/lib/tk
diff options
context:
space:
mode:
Diffstat (limited to 'ext/tk/lib/tk')
-rw-r--r--ext/tk/lib/tk/autoload.rb1
-rw-r--r--ext/tk/lib/tk/canvas.rb4
-rw-r--r--ext/tk/lib/tk/canvastag.rb4
-rw-r--r--ext/tk/lib/tk/entry.rb4
-rw-r--r--ext/tk/lib/tk/font.rb84
-rw-r--r--ext/tk/lib/tk/grid.rb6
-rw-r--r--ext/tk/lib/tk/itemfont.rb30
-rw-r--r--ext/tk/lib/tk/kinput.rb28
-rw-r--r--ext/tk/lib/tk/listbox.rb4
-rw-r--r--ext/tk/lib/tk/menu.rb4
-rw-r--r--ext/tk/lib/tk/mngfocus.rb8
-rw-r--r--ext/tk/lib/tk/pack.rb6
-rw-r--r--ext/tk/lib/tk/palette.rb8
-rw-r--r--ext/tk/lib/tk/tagfont.rb12
-rw-r--r--ext/tk/lib/tk/text.rb44
-rw-r--r--ext/tk/lib/tk/textmark.rb32
-rw-r--r--ext/tk/lib/tk/timer.rb98
-rw-r--r--ext/tk/lib/tk/winfo.rb184
-rw-r--r--ext/tk/lib/tk/wm.rb12
-rw-r--r--ext/tk/lib/tk/xim.rb40
20 files changed, 382 insertions, 231 deletions
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<TkWindow
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/tk/canvastag.rb b/ext/tk/lib/tk/canvastag.rb
index b1ac10ba43..0075a60a14 100644
--- a/ext/tk/lib/tk/canvastag.rb
+++ b/ext/tk/lib/tk/canvastag.rb
@@ -112,8 +112,8 @@ module TkcTagAccess
self
end
- def index(index)
- @c.index(@id, index)
+ def index(idx)
+ @c.index(@id, idx)
end
def insert(beforethis, string)
diff --git a/ext/tk/lib/tk/entry.rb b/ext/tk/lib/tk/entry.rb
index a3c0e51cdd..0fe553d55c 100644
--- a/ext/tk/lib/tk/entry.rb
+++ b/ext/tk/lib/tk/entry.rb
@@ -32,8 +32,8 @@ class TkEntry<TkLabel
#self
index
end
- 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)
tk_send_without_enc('insert', pos, _get_eval_enc_str(text))
diff --git a/ext/tk/lib/tk/font.rb b/ext/tk/lib/tk/font.rb
index 790537ef8d..92f3a82434 100644
--- a/ext/tk/lib/tk/font.rb
+++ b/ext/tk/lib/tk/font.rb
@@ -163,14 +163,14 @@ class TkFont
###################################
# class methods
###################################
- def TkFont.families(window=nil)
+ def TkFont.families(win=nil)
case (Tk::TK_VERSION)
when /^4\.*/
['fixed']
when /^8\.*/
- if window
- tk_split_simplelist(tk_call('font', 'families', '-displayof', window))
+ if win
+ tk_split_simplelist(tk_call('font', 'families', '-displayof', win))
else
tk_split_simplelist(tk_call('font', 'families'))
end
@@ -675,7 +675,7 @@ class TkFont
end
end
- def actual_core_tk4x(font, window=nil, option=nil)
+ def actual_core_tk4x(font, win=nil, option=nil)
# dummy
if option == 'pointadjust' || option == :pointadjust
1.0
@@ -695,13 +695,13 @@ class TkFont
end
end
- def actual_core_tk8x(font, window=nil, option=nil)
+ def actual_core_tk8x(font, win=nil, option=nil)
if option == 'compound' || option == :compound
""
elsif option
- if window
+ if win
val = tk_call('font', 'actual', font,
- "-displayof", window, "-#{option}")
+ "-displayof", win, "-#{option}")
else
val = tk_call('font', 'actual', font, "-#{option}")
end
@@ -714,9 +714,9 @@ class TkFont
val
end
else
- l = tk_split_simplelist(if window
+ l = tk_split_simplelist(if win
tk_call('font', 'actual', font,
- "-displayof", window)
+ "-displayof", win)
else
tk_call('font', 'actual', font)
end)
@@ -1124,20 +1124,20 @@ class TkFont
self
end
- def measure_core_tk4x(window, text)
+ def measure_core_tk4x(win, text)
0
end
- def measure_core_tk8x(window, text)
- if window
+ def measure_core_tk8x(win, text)
+ if win
number(tk_call('font', 'measure', @compoundfont,
- '-displayof', window, text))
+ '-displayof', win, text))
else
number(tk_call('font', 'measure', @compoundfont, text))
end
end
- def metrics_core_tk4x(font, window, option=nil)
+ def metrics_core_tk4x(font, win, option=nil)
# dummy
if option
""
@@ -1146,17 +1146,17 @@ class TkFont
end
end
- def metrics_core_tk8x(font, window, option=nil)
+ def metrics_core_tk8x(font, win, option=nil)
if option
- if window
+ if win
number(tk_call('font', 'metrics', font,
- "-displayof", window, "-#{option}"))
+ "-displayof", win, "-#{option}"))
else
number(tk_call('font', 'metrics', font, "-#{option}"))
end
else
- l = tk_split_list(if window
- tk_call('font','metrics',font,"-displayof",window)
+ l = tk_split_list(if win
+ tk_call('font','metrics',font,"-displayof",win)
else
tk_call('font','metrics',font)
end)
@@ -1357,18 +1357,18 @@ class TkFont
actual_core(@compoundfont, nil, option)
end
- def actual_displayof(window, option=nil)
- window = '.' unless window
- actual_core(@compoundfont, window, option)
+ def actual_displayof(win, option=nil)
+ win = '.' unless win
+ actual_core(@compoundfont, win, option)
end
def latin_actual(option=nil)
actual_core(@latinfont, nil, option)
end
- def latin_actual_displayof(window, option=nil)
- window = '.' unless window
- actual_core(@latinfont, window, option)
+ def latin_actual_displayof(win, option=nil)
+ win = '.' unless win
+ actual_core(@latinfont, win, option)
end
def kanji_actual(option=nil)
@@ -1380,13 +1380,13 @@ class TkFont
end
end
- def kanji_actual_displayof(window, option=nil)
+ def kanji_actual_displayof(win, option=nil)
#if JAPANIZED_TK
if @kanjifont != ""
- window = '.' unless window
- actual_core(@kanjifont, window, option)
+ win = '.' unless win
+ actual_core(@kanjifont, win, option)
else
- actual_core_tk4x(nil, window, option)
+ actual_core_tk4x(nil, win, option)
end
end
@@ -1478,27 +1478,27 @@ class TkFont
measure_core(nil, text)
end
- def measure_displayof(window, text)
- window = '.' unless window
- measure_core(window, text)
+ def measure_displayof(win, text)
+ win = '.' unless win
+ measure_core(win, text)
end
def metrics(option=nil)
metrics_core(@compoundfont, nil, option)
end
- def metrics_displayof(window, option=nil)
- window = '.' unless window
- metrics_core(@compoundfont, window, option)
+ def metrics_displayof(win, option=nil)
+ win = '.' unless win
+ metrics_core(@compoundfont, win, option)
end
def latin_metrics(option=nil)
metrics_core(@latinfont, nil, option)
end
- def latin_metrics_displayof(window, option=nil)
- window = '.' unless window
- metrics_core(@latinfont, window, option)
+ def latin_metrics_displayof(win, option=nil)
+ win = '.' unless win
+ metrics_core(@latinfont, win, option)
end
def kanji_metrics(option=nil)
@@ -1509,12 +1509,12 @@ class TkFont
end
end
- def kanji_metrics_displayof(window, option=nil)
+ def kanji_metrics_displayof(win, option=nil)
if JAPANIZED_TK
- window = '.' unless window
- metrics_core(@kanjifont, window, option)
+ win = '.' unless win
+ metrics_core(@kanjifont, win, option)
else
- metrics_core_tk4x(nil, window, option)
+ metrics_core_tk4x(nil, win, option)
end
end
diff --git a/ext/tk/lib/tk/grid.rb b/ext/tk/lib/tk/grid.rb
index 499101f1bb..10fdf3569b 100644
--- a/ext/tk/lib/tk/grid.rb
+++ b/ext/tk/lib/tk/grid.rb
@@ -158,13 +158,13 @@ module TkGrid
list(tk_call_without_enc('grid', 'location', master, x, y))
end
- def propagate(master, bool=None)
+ def propagate(master, mode=None)
# master = master.epath if master.kind_of?(TkObject)
master = _epath(master)
- if bool == None
+ if mode == None
bool(tk_call_without_enc('grid', 'propagate', master))
else
- tk_call_without_enc('grid', 'propagate', master, bool)
+ tk_call_without_enc('grid', 'propagate', master, mode)
end
end
diff --git a/ext/tk/lib/tk/itemfont.rb b/ext/tk/lib/tk/itemfont.rb
index e4a1a50912..ab9e3ff6c9 100644
--- a/ext/tk/lib/tk/itemfont.rb
+++ b/ext/tk/lib/tk/itemfont.rb
@@ -221,18 +221,18 @@ module TkTreatItemFont
self
end
- def tagfont_copy(tagOrId, window, wintag=nil, winkey=nil, targetkey=nil)
+ def tagfont_copy(tagOrId, 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
@@ -247,7 +247,7 @@ module TkTreatItemFont
end
- def latintagfont_copy(tagOrId, window, wintag=nil, winkey=nil, targetkey=nil)
+ def latintagfont_copy(tagOrId, win, wintag=nil, winkey=nil, targetkey=nil)
if targetkey
fontobj(targetkey).dup.call_font_configure([__item_pathname(tagid(tagOrId)), targetkey],
*(__item_config_cmd(tagid(tagOrId)) << {}))
@@ -258,22 +258,22 @@ module TkTreatItemFont
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 asciitagfont_copy latintagfont_copy
- def kanjifont_copy(tagOrId, window, wintag=nil, winkey=nil, targetkey=nil)
+ def kanjifont_copy(tagOrId, win, wintag=nil, winkey=nil, targetkey=nil)
if targetkey
fontobj(targetkey).dup.call_font_configure([__item_pathname(tagid(tagOrId)), targetkey],
*(__item_config_cmd(tagid(tagOrId)) << {}))
@@ -284,15 +284,15 @@ module TkTreatItemFont
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
diff --git a/ext/tk/lib/tk/kinput.rb b/ext/tk/lib/tk/kinput.rb
index fc731b6569..a29dbcdb72 100644
--- a/ext/tk/lib/tk/kinput.rb
+++ b/ext/tk/lib/tk/kinput.rb
@@ -13,46 +13,46 @@ module TkKinput
'kanjiInput'.freeze
].freeze
- def TkKinput.start(window, style=None)
- tk_call('kinput_start', window, style)
+ def TkKinput.start(win, style=None)
+ tk_call('kinput_start', win, style)
end
def kinput_start(style=None)
TkKinput.start(self, style)
end
- def TkKinput.send_spot(window)
- tk_call('kinput_send_spot', window)
+ def TkKinput.send_spot(win)
+ tk_call('kinput_send_spot', win)
end
def kinput_send_spot
TkKinput.send_spot(self)
end
- def TkKinput.input_start(window, keys=nil)
- tk_call('kanjiInput', 'start', window, *hash_kv(keys))
+ def TkKinput.input_start(win, keys=nil)
+ tk_call('kanjiInput', 'start', win, *hash_kv(keys))
end
def kanji_input_start(keys=nil)
TkKinput.input_start(self, keys)
end
- def TkKinput.attribute_config(window, slot, value=None)
+ def TkKinput.attribute_config(win, slot, value=None)
if slot.kind_of? Hash
- tk_call('kanjiInput', 'attribute', window, *hash_kv(slot))
+ tk_call('kanjiInput', 'attribute', win, *hash_kv(slot))
else
- tk_call('kanjiInput', 'attribute', window, "-#{slot}", value)
+ tk_call('kanjiInput', 'attribute', win, "-#{slot}", value)
end
end
def kinput_attribute_config(slot, value=None)
TkKinput.attribute_config(self, slot, value)
end
- def TkKinput.attribute_info(window, slot=nil)
+ def TkKinput.attribute_info(win, slot=nil)
if slot
conf = tk_split_list(tk_call('kanjiInput', 'attribute',
- window, "-#{slot}"))
+ win, "-#{slot}"))
conf[0] = conf[0][1..-1]
conf
else
- tk_split_list(tk_call('kanjiInput', 'attribute', window)).collect{|conf|
+ tk_split_list(tk_call('kanjiInput', 'attribute', win)).collect{|conf|
conf[0] = conf[0][1..-1]
conf
}
@@ -62,8 +62,8 @@ module TkKinput
TkKinput.attribute_info(self, slot)
end
- def TkKinput.input_end(window)
- tk_call('kanjiInput', 'end', window)
+ def TkKinput.input_end(win)
+ tk_call('kanjiInput', 'end', win)
end
def kanji_input_end
TkKinput.input_end(self)
diff --git a/ext/tk/lib/tk/listbox.rb b/ext/tk/lib/tk/listbox.rb
index f00db19239..8a24202d6c 100644
--- a/ext/tk/lib/tk/listbox.rb
+++ b/ext/tk/lib/tk/listbox.rb
@@ -73,8 +73,8 @@ class TkListbox<TkTextWin
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 value
diff --git a/ext/tk/lib/tk/menu.rb b/ext/tk/lib/tk/menu.rb
index e646d56246..a0b0a80b14 100644
--- a/ext/tk/lib/tk/menu.rb
+++ b/ext/tk/lib/tk/menu.rb
@@ -95,8 +95,8 @@ class TkMenu<TkWindow
def add_separator(keys=nil)
add('separator', keys)
end
- def index(index)
- ret = tk_send_without_enc('index', _get_eval_enc_str(index))
+ def index(idx)
+ ret = tk_send_without_enc('index', _get_eval_enc_str(idx))
(ret == 'none')? nil: number(ret)
end
def invoke(index)
diff --git a/ext/tk/lib/tk/mngfocus.rb b/ext/tk/lib/tk/mngfocus.rb
index a0f18233be..1a2049c8a8 100644
--- a/ext/tk/lib/tk/mngfocus.rb
+++ b/ext/tk/lib/tk/mngfocus.rb
@@ -17,15 +17,15 @@ module TkManageFocus
tk_call_without_enc('tk_focusFollowsMouse')
end
- def TkManageFocus.next(window)
- tk_tcl2ruby(tk_call('tk_focusNext', window))
+ def TkManageFocus.next(win)
+ tk_tcl2ruby(tk_call('tk_focusNext', win))
end
def focusNext
TkManageFocus.next(self)
end
- def TkManageFocus.prev(window)
- tk_tcl2ruby(tk_call('tk_focusPrev', window))
+ def TkManageFocus.prev(win)
+ tk_tcl2ruby(tk_call('tk_focusPrev', win))
end
def focusPrev
TkManageFocus.prev(self)
diff --git a/ext/tk/lib/tk/pack.rb b/ext/tk/lib/tk/pack.rb
index d592fa1c80..8fab363121 100644
--- a/ext/tk/lib/tk/pack.rb
+++ b/ext/tk/lib/tk/pack.rb
@@ -51,13 +51,13 @@ module TkPack
return info
end
- def propagate(master, bool=None)
+ def propagate(master, mode=None)
# master = master.epath if master.kind_of?(TkObject)
master = _epath(master)
- if bool == None
+ if mode == None
bool(tk_call_without_enc('pack', 'propagate', master))
else
- tk_call_without_enc('pack', 'propagate', master, bool)
+ tk_call_without_enc('pack', 'propagate', master, mode)
end
end
diff --git a/ext/tk/lib/tk/palette.rb b/ext/tk/lib/tk/palette.rb
index dfe46940f3..f419822e4c 100644
--- a/ext/tk/lib/tk/palette.rb
+++ b/ext/tk/lib/tk/palette.rb
@@ -30,22 +30,22 @@ module TkPalette
tk_call('tkDarken', color, percent)
end
- def TkPalette.recolorTree(window, colors)
+ def TkPalette.recolorTree(win, colors)
if not colors.kind_of?(Hash)
fail "2nd arg need to be Hash"
end
colors.each{|key, value|
begin
- if window.cget(key) == tk_call('set', "tkPalette(#{key})")
- window[key] = colors[key]
+ if win.cget(key) == tk_call('set', "tkPalette(#{key})")
+ win[key] = colors[key]
end
rescue
# ignore
end
}
- TkWinfo.children(window).each{|w| TkPalette.recolorTree(w, colors)}
+ TkWinfo.children(win).each{|w| TkPalette.recolorTree(w, colors)}
end
def recolorTree(colors)
diff --git a/ext/tk/lib/tk/tagfont.rb b/ext/tk/lib/tk/tagfont.rb
index a106f814be..a1807395d2 100644
--- a/ext/tk/lib/tk/tagfont.rb
+++ b/ext/tk/lib/tk/tagfont.rb
@@ -25,19 +25,19 @@ module TkTreatTagFont
self
end
- def font_copy(window, wintag=nil)
- @parent.tagfont_copy(@id, window, wintag)
+ def font_copy(win, wintag=nil)
+ @parent.tagfont_copy(@id, win, wintag)
self
end
- def latinfont_copy(window, wintag=nil)
- @parent.latintagfont_copy(@id, window, wintag)
+ def latinfont_copy(win, wintag=nil)
+ @parent.latintagfont_copy(@id, win, wintag)
self
end
alias asciifont_copy latinfont_copy
- def kanjifont_copy(window, wintag=nil)
- @parent.kanjitagfont_copy(@id, window, wintag)
+ def kanjifont_copy(win, wintag=nil)
+ @parent.kanjitagfont_copy(@id, win, wintag)
self
end
end
diff --git a/ext/tk/lib/tk/text.rb b/ext/tk/lib/tk/text.rb
index 355153ea07..d294de9fd9 100644
--- a/ext/tk/lib/tk/text.rb
+++ b/ext/tk/lib/tk/text.rb
@@ -69,12 +69,36 @@ class TkText<TkTextWin
#######################################
module IndexModMethods
+ def +(mod)
+ return chars(mod) if mod.kind_of?(Numeric)
+
+ mod = mod.to_s
+ if mod =~ /^\s*[+-]?\d/
+ TkText::IndexString.new(String.new(id) << ' + ' << mod)
+ else
+ TkText::IndexString.new(String.new(id) << ' ' << mod)
+ end
+ end
+
+ def -(mod)
+ return chars(-mod) if mod.kind_of?(Numeric)
+
+ mod = mod.to_s
+ if mod =~ /^\s*[+-]?\d/
+ TkText::IndexString.new(String.new(id) << ' - ' << mod)
+ elsif mod =~ /^\s*[-]\s+(\d.*)$/
+ TkText::IndexString.new(String.new(id) << ' - -' << $1)
+ else
+ TkText::IndexString.new(String.new(id) << ' ' << mod)
+ end
+ end
+
def chars(mod)
fail ArgumentError, 'expect Integer' unless mod.kind_of?(Integer)
if mod < 0
- TkText::IndexString.new(id + ' ' << mod.to_s << ' chars')
+ TkText::IndexString.new(String.new(id) << ' ' << mod.to_s << ' chars')
else
- TkText::IndexString.new(id + ' + ' << mod.to_s << ' chars')
+ TkText::IndexString.new(String.new(id) << ' + ' << mod.to_s << ' chars')
end
end
alias char chars
@@ -82,25 +106,25 @@ class TkText<TkTextWin
def lines(mod)
fail ArgumentError, 'expect Integer' unless mod.kind_of?(Integer)
if mod < 0
- TkText::IndexString.new(id + ' ' << mod.to_s << ' lines')
+ TkText::IndexString.new(String.new(id) << ' ' << mod.to_s << ' lines')
else
- TkText::IndexString.new(id + ' + ' << mod.to_s << ' lines')
+ TkText::IndexString.new(String.new(id) << ' + ' << mod.to_s << ' lines')
end
end
alias line lines
def linestart
- TkText::IndexString.new(id + ' linestart')
+ TkText::IndexString.new(String.new(id) << ' linestart')
end
def lineend
- TkText::IndexString.new(id + ' lineend')
+ TkText::IndexString.new(String.new(id) << ' lineend')
end
def wordstart
- TkText::IndexString.new(id + ' wordstart')
+ TkText::IndexString.new(String.new(id) << ' wordstart')
end
def wordend
- TkText::IndexString.new(id + ' wordend')
+ TkText::IndexString.new(String.new(id) << ' wordend')
end
end
@@ -159,9 +183,9 @@ class TkText<TkTextWin
end
private :create_self
- def index(index)
+ def index(idx)
TkText::IndexString.new(tk_send_without_enc('index',
- _get_eval_enc_str(index)))
+ _get_eval_enc_str(idx)))
end
def get_displaychars(*index)
diff --git a/ext/tk/lib/tk/textmark.rb b/ext/tk/lib/tk/textmark.rb
index 9dff764eca..dccde38d7f 100644
--- a/ext/tk/lib/tk/textmark.rb
+++ b/ext/tk/lib/tk/textmark.rb
@@ -47,11 +47,39 @@ class TkTextMark<TkObject
end
end
+=begin
+ # move to TkText::IndexModMethods module
def +(mod)
- TkText::IndexString.new(@id + ' + ' + mod)
+ return chars(mod) if mod.kind_of?(Numeric)
+
+ mod = mod.to_s
+ if mod =~ /^\s*[+-]?\d/
+ TkText::IndexString.new(@id + ' + ' + mod)
+ else
+ TkText::IndexString.new(@id + ' ' + mod)
+ end
end
+
def -(mod)
- TkText::IndexString.new(@id + ' - ' + mod)
+ return chars(-mod) if mod.kind_of?(Numeric)
+
+ mod = mod.to_s
+ if mod =~ /^\s*[+-]?\d/
+ TkText::IndexString.new(@id + ' - ' + mod)
+ elsif mod =~ /^\s*[-]\s+(\d.*)$/
+ TkText::IndexString.new(@id + ' - -' + $1)
+ else
+ TkText::IndexString.new(@id + ' ' + mod)
+ end
+ end
+=end
+
+ def pos
+ @t.index(@id)
+ end
+
+ def pos=(where)
+ set(where)
end
def set(where)
diff --git a/ext/tk/lib/tk/timer.rb b/ext/tk/lib/tk/timer.rb
index b399bd8b97..f78d54a5c6 100644
--- a/ext/tk/lib/tk/timer.rb
+++ b/ext/tk/lib/tk/timer.rb
@@ -401,6 +401,8 @@ class TkTimer
@current_pos = 0
@current_args = @init_args
+ @current_script = []
+
@set_next = false if @in_callback
self
@@ -428,6 +430,7 @@ class TkTimer
def continue(wait=nil)
fail RuntimeError, "is already running" if @running
+ return restart() if @current_script.empty?
sleep, cmd = @current_script
fail RuntimeError, "no procedure to continue" unless cmd
if wait
@@ -498,3 +501,98 @@ class TkTimer
end
TkAfter = TkTimer
+
+
+class TkRTTimer < TkTimer
+ DEFAULT_OFFSET_LIST_SIZE = 5
+
+ def initialize(*args, &b)
+ super(*args, &b)
+
+ @offset_list = Array.new(DEFAULT_OFFSET_LIST_SIZE, 0.0)
+ @est_time = nil
+ end
+
+ def start(*args, &b)
+ return nil if @running
+ @est_time = nil
+ @cb_start_time = Time.now
+ super(*args, &b)
+ end
+
+ def cancel
+ super()
+ @est_time = nil
+ self
+ end
+ alias stop cancel
+
+ def set_interval(interval)
+ super(interval)
+ @est_time = nil
+ end
+
+ def _offset_ave
+ size = @offset_list.size.to_f
+ s = 0.0
+ @offset_list.each{|n| s + n}
+ s / size
+ end
+ private :_offset_ave
+
+ def set_next_callback(args)
+ if @running == false || @proc_max == 0 || @do_loop == 0
+ Tk_CBTBL.delete(@id) ;# for GC
+ @running = false
+ @wait_var.value = 0
+ return
+ end
+ if @current_pos >= @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