Class: Redwood::LabelSearchResultsMode

Inherits:
ThreadIndexMode show all
Defined in:
lib/sup/modes/label-search-results-mode.rb

Constant Summary

Constant Summary

Constants inherited from ThreadIndexMode

ThreadIndexMode::DATE_WIDTH, ThreadIndexMode::LOAD_MORE_THREAD_NUM, ThreadIndexMode::MIN_FROM_WIDTH

Constants inherited from ScrollMode

ScrollMode::COL_JUMP

Instance Attribute Summary

Attributes inherited from LineCursorMode

#curpos

Attributes inherited from ScrollMode

#botline, #leftcol, #status, #topline

Attributes inherited from Mode

#buffer

Class Method Summary (collapse)

Instance Method Summary (collapse)

Methods inherited from ThreadIndexMode

#[], #actually_save, #actually_toggle_archived, #actually_toggle_deleted, #actually_toggle_spammed, #actually_toggle_starred, #apply_to_tagged, #cancel_search, #cleanup, #contains_thread?, #edit_labels, #edit_message, #forward, #handle_added_update, #handle_deleted_update, #handle_labeled_update, #handle_simple_update, #handle_single_message_deleted_update, #handle_single_message_labeled_update, #handle_spammed_update, #handle_undeleted_update, #join_threads, #jump_to_next_new, #kill, #launch_another_thread, #launch_next_thread_after, #launch_prev_thread_before, #lines, #load_all_threads, #load_n_threads, #load_n_threads_background, #load_threads, #multi_edit_labels, #multi_join_threads, #multi_kill, #multi_select, #multi_toggle_archived, #multi_toggle_deleted, #multi_toggle_new, #multi_toggle_spam, #multi_toggle_starred, #multi_toggle_tagged, #reload, #reply, #resize, #save, #select, #status, #tag_matching, #toggle_archived, #toggle_deleted, #toggle_new, #toggle_spam, #toggle_starred, #toggle_tagged, #toggle_tagged_all, #update

Methods inherited from LineCursorMode

#draw

Methods inherited from ScrollMode

#at_bottom?, #at_top?, #cancel_search!, #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!, #cleanup, #draw, #focus, #handle_input, #help_text, #in_search?, #killable?, load_all_modes, make_name, #name, #pipe_to_process, register_keymap, #resize, #resolve_input, #save_to_file, #status

Constructor Details

- (LabelSearchResultsMode) initialize(labels)



4
5
6
7
8
9
10
# File 'lib/sup/modes/label-search-results-mode.rb', line 4

def initialize labels
  @labels = labels
  opts = { :labels => @labels }
  opts[:load_deleted] = true if labels.include? :deleted
  opts[:load_spam] = true if labels.include? :spam
  super [], opts
end

Class Method Details

+ (Object) spawn_nicely(label)



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/sup/modes/label-search-results-mode.rb', line 25

def self.spawn_nicely label
  label = LabelManager.label_for(label) unless label.is_a?(Symbol)
  case label
  when nil
  when :inbox
    BufferManager.raise_to_front InboxMode.instance.buffer
  else
    b, new = BufferManager.spawn_unless_exists("All threads with label '#{label}'") { LabelSearchResultsMode.new [label] }
    b.mode.load_threads :num => b.content_height if new
  end
end

Instance Method Details

- (Boolean) is_relevant?(m)



23
# File 'lib/sup/modes/label-search-results-mode.rb', line 23

def is_relevant? m; @labels.all? { |l| m.has_label? l } end

- (Object) refine_search



16
17
18
19
20
21
# File 'lib/sup/modes/label-search-results-mode.rb', line 16

def refine_search
  label_query = @labels.size > 1 ? "(#{@labels.join('||')})" : @labels.first
  query = BufferManager.ask :search, "refine query: ", "+label:#{label_query} "
  return unless query && query !~ /^\s*$/
  SearchResultsMode.spawn_from_query query
end