Class: Redwood::SearchListMode

Inherits:
LineCursorMode show all
Defined in:
lib/sup/modes/search_list_mode.rb

Instance Attribute Summary

Attributes inherited from LineCursorMode

#curpos

Attributes inherited from ScrollMode

#botline, #leftcol, #status, #topline

Attributes inherited from Mode

#buffer

Instance Method Summary collapse

Methods inherited from LineCursorMode

#draw

Methods inherited from ScrollMode

#at_bottom?, #at_top?, #cancel_search!, #col_jump, #col_left, #col_right, #continue_search_in_buffer, #draw, #ensure_mode_validity, #half_page_down, #half_page_up, #in_search?, #jump_to_col, #jump_to_end, #jump_to_left, #jump_to_line, #jump_to_start, #line_down, #line_up, #page_down, #page_up, #resize, #rightcol, #search_goto_line, #search_goto_pos, #search_in_buffer, #search_start_line

Methods inherited from Mode

#blur, #cancel_search!, #draw, #handle_input, #help_text, #in_search?, keymap, keymaps, #killable?, load_all_modes, make_name, #name, #pipe_to_process, register_keymap, #resize, #resolve_input, #save_to_file, #status, #unsaved?

Constructor Details

#initializeSearchListMode

Returns a new instance of SearchListMode.



34
35
36
37
38
39
40
41
# File 'lib/sup/modes/search_list_mode.rb', line 34

def initialize
  @searches = []
  @text = []
  @unread_only = false
  super
  UpdateManager.register self
  regen_text
end

Instance Method Details

#[](i) ⇒ Object



49
# File 'lib/sup/modes/search_list_mode.rb', line 49

def [] i; @text[i] end

#cleanupObject



43
44
45
46
# File 'lib/sup/modes/search_list_mode.rb', line 43

def cleanup
  UpdateManager.unregister self
  super
end

#focusObject



62
63
64
# File 'lib/sup/modes/search_list_mode.rb', line 62

def focus
  reload # make sure unread message counts are up-to-date
end

#handle_added_update(sender, m) ⇒ Object



66
67
68
# File 'lib/sup/modes/search_list_mode.rb', line 66

def handle_added_update sender, m
  reload
end

#jump_to_next_newObject



51
52
53
54
55
56
57
58
59
60
# File 'lib/sup/modes/search_list_mode.rb', line 51

def jump_to_next_new
  n = ((curpos + 1) ... lines).find { |i| @searches[i][1] > 0 } || (0 ... curpos).find { |i| @searches[i][1] > 0 }
  if n
    ## jump there if necessary
    jump_to_line n unless n >= topline && n < botline
    set_cursor_pos n
  else
    BufferManager.flash "No saved searches with unread messages."
  end
end

#linesObject



48
# File 'lib/sup/modes/search_list_mode.rb', line 48

def lines; @text.length end