summaryrefslogtreecommitdiff
path: root/ext/tk/lib/tk/textmark.rb
diff options
context:
space:
mode:
Diffstat (limited to 'ext/tk/lib/tk/textmark.rb')
-rw-r--r--ext/tk/lib/tk/textmark.rb32
1 files changed, 30 insertions, 2 deletions
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)