class Canis::TextActionEvent
a derivative of Action
Event for textviews We allow a user to press ENTER on a row and use that for processing. We are basically using TextView
as a list in which user can scroll around and move cursor at will.
Attributes
curpos[RW]
cursor position on the line
current_index[RW]
current_index
or line number starting 0
Public Class Methods
new(source, event, action_command, current_index, curpos)
click to toggle source
Calls superclass method
# File lib/canis/core/include/ractionevent.rb, line 46 def initialize source, event, action_command, current_index, curpos super source, event, action_command @current_index = current_index @curpos = curpos end
Public Instance Methods
text()
click to toggle source
the text of the line on which the user is
# File lib/canis/core/include/ractionevent.rb, line 52 def text source.current_value.to_s end
word_under_cursor(line=text(), pos=@curpos, delim=" ")
click to toggle source
the word under the cursor TODO if its a text with pipe delim, then ??
# File lib/canis/core/include/ractionevent.rb, line 57 def word_under_cursor line=text(), pos=@curpos, delim=" " line ||= text() pos ||= @curpos # if pressed on a space, try to go to next word to make easier 2013-03-24 if line[pos,1] == delim while line[pos,1] == delim pos += 1 end end finish = line.index(delim, pos) start = line.rindex(delim,pos) finish = -1 if finish.nil? start = 0 if start.nil? return line[start..finish] end