lib/ffi-tk/widget/text.rb in ffi-tk-2009.12.14 vs lib/ffi-tk/widget/text.rb in ffi-tk-2010.01
- old
+ new
@@ -199,22 +199,26 @@
arguments = arguments.dup
invocation = []
indices = [given_index]
while arg = arguments.shift
- case arg.to_tcl
- when '-command'
- command = arguments.shift
- invocation << ['-command', command]
- when /^-(all|image|mark|tag|text|window)$/
- invocation << tcl_option(arg)
+ if arg.respond_to?(:to_tcl_option)
+ case tcl_option = arg.to_tcl_option
+ when '-command'
+ command = arguments.shift
+ invocation << ['-command', command]
+ when /^-(?:all|image|mark|tag|text|window)$/
+ invocation << tcl_option
+ else
+ indices.unshift(arg)
+ end
else
indices.unshift(arg)
end
end
- execute('dump', *invocation, *indices)
+ execute('dump', *invocation, *indices).to_a.each_slice(3).to_a
end
# If boolean is not specified, returns the modified flag of the widget.
# The insert, delete, edit undo and edit redo commands or the user can set
# or clear the modified flag.
@@ -328,11 +332,11 @@
# Returns the position corresponding to index in the form line.char where
# line is the line number and char is the character number. Index may have
# any of the forms described under INDICES above.
def index(index)
- execute('index', index)
+ execute('index', index).to_s
end
# Inserts all of the chars arguments just before the character at index.
#
# If index refers to the end of the text (the character after the last
@@ -653,11 +657,11 @@
# operates on characters in a text rather than entire widgets.
# See the bind manual entry for complete details on the syntax of sequence
# and the substitutions performed on script before invoking it.
# If all arguments are specified then a new binding is created, replacing
# any existing binding for the same sequence and tagName (if the first
- # character of script is “+” then script augments an existing binding
+ # character of script is "+" then script augments an existing binding
# rather than replacing it).
# In this case the return value is an empty string.
# If script is omitted then the command returns the script associated
# with tagName and sequence (an error occurs if there is no such binding).
# If both script and sequence are omitted then the command returns a list
@@ -763,12 +767,12 @@
# Returns a list whose elements are the names of all the tags that are
# active at the character position given by index.
# If index is omitted, then the return value will describe all of the tags
# that exist for the text (this includes all tags that have been named in a
- # “pathName tag” widget command but have not been deleted by a “pathName
- # tag delete” widget command, even if no characters are currently marked
+ # "pathName tag" widget command but have not been deleted by a "pathName
+ # tag delete" widget command, even if no characters are currently marked
# with the tag).
# The list will be sorted in order from lowest priority to highest
# priority.
def tag_names(index = None)
execute(:tag, :names, index).to_a
@@ -886,8 +890,36 @@
Tk.execute(:tk_textCut, self)
end
def paste
Tk.execute(:tk_textPaste, self)
+ end
+
+ def tk_prev_word_pos(start)
+ Tk.execute('tk::TextPrevPos', self, start, 'tcl_startOfPreviousWord').to_s
+ end
+
+ def tk_next_word_pos(start)
+ Tk.execute('tk::TextNextPos', self, start, 'tcl_startOfNextWord').to_s
+ end
+
+ def tk_next_word_pos_end(start)
+ Tk.execute('tk::TextNextWord', self, start).to_s
+ end
+
+ def tk_prev_line_pos(count)
+ Tk.execute('tk::TextUpDownLine', self, -count.abs).to_s
+ end
+
+ def tk_next_line_pos(count)
+ Tk.execute('tk::TextUpDownLine', self, count).to_s
+ end
+
+ def tk_prev_page_pos(count)
+ Tk.execute('tk::TextScrollPages', self, -count.abs).to_s
+ end
+
+ def tk_next_page_pos(count)
+ Tk.execute('tk::TextScrollPages', self, count).to_s
end
end
end