Class: Umbra::Textbox

Inherits:
Multiline show all
Defined in:
lib/umbra/textbox.rb

Instance Attribute Summary collapse

Attributes inherited from Multiline

#current_index, #list, #panned_cols, #search_offset

Attributes inherited from Widget

#col, #col_offset, #curpos, #focusable, #graphic, #handler, #key_label, #modified, #name, #repaint_required, #row, #row_offset, #state

Instance Method Summary collapse

Methods inherited from Multiline

#_truncate_to_width, #ask_search, #color_of_row, #command, #cursor_backward, #cursor_down, #cursor_end, #cursor_forward, #cursor_home, #cursor_up, #delete_at, #ensure_visible, #find_more, #fire_action_event, #getvalue, #goto_end, #goto_line, #goto_start, #insert, #is_visible?, #map_keys, #next_match, #on_enter, #on_enter_row, #on_leave, #on_leave_row, #page_backward, #page_forward, #paint_row, #print_row, #repaint, #row_count, #scroll_down, #scroll_left, #scroll_right, #scroll_up, #state_of_row, #to_searchable, #value_of_row

Methods inherited from Widget

#_form=, #color_pair, #command, #getvalue, #getvalue_for_paint, #height, #highlight_attr, #init_vars, #modified?, #on_enter, #on_leave, #repaint, #repaint_all, #rowcol, #set_form_col, #set_form_row, #text, #touch, #variable_set, #visible, #width

Methods included from KeyMappingHandler

#_process_key, #bind_key, #bind_keys, #process_key, #unbind_key

Methods included from EventHandler

#bind_event, #event?, #fire_handler, #fire_property_change, #register_events

Constructor Details

#initialize(config = {}, &block) ⇒ Textbox

attr_accessor :cursor # position of cursor in line ??



23
24
25
26
27
28
29
30
31
32
# File 'lib/umbra/textbox.rb', line 23

def initialize config={}, &block
  @highlight_attr     = FFI::NCurses::A_BOLD
  @row_offset         = 0
  @col_offset         = 0
  @curpos             = 0                  # current cursor position in buffer (NOT screen/window/field)

  register_events([:CURSOR_MOVE]) # movement of cursor left or right, up down or panning.
  super

end

Instance Attribute Details

#file_nameObject

filename passed in for reading



20
21
22
# File 'lib/umbra/textbox.rb', line 20

def file_name
  @file_name
end

Instance Method Details

#current_rowObject

returns current row



66
67
68
# File 'lib/umbra/textbox.rb', line 66

def current_row
  @list[@current_index]
end

#handle_key(ch) ⇒ Object

textbox key handling

Textbox varies from multiline in that it fires a cursor_move event whrease the parent

fires a cursor_move event which is mostly used for testing out


74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/umbra/textbox.rb', line 74

def handle_key ch
  begin 
    ret = super
    return ret
  ensure
    if @repaint_required
      ## this could get fired even if color changed or something not related to cursor moving. FIXME
      ## Should this fire if users scrolls but does not change cursor position
      #fire_handler(:CURSOR_MOVE, [@col_offset, @current_index, @curpos, @panned_cols, ch ])     # 2018-03-25 - improve this
      fire_handler(:CURSOR_MOVE, self)          ## 2018-05-30 - made this like most others yielding self
    end
  end
end