Class: Redwood::SearchResultsMode

Inherits:
ThreadIndexMode show all
Defined in:
lib/sup/modes/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

Redwood::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, #is_relevant?, #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

- (SearchResultsMode) initialize(qobj, qopts = nil)

Returns a new instance of SearchResultsMode



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

def initialize qobj, qopts = nil
  @qobj = qobj
  @qopts = qopts

  super [], { :qobj => @qobj }.merge(@qopts)
end

Class Method Details

+ (Object) spawn_from_query(text)

a proper is_relevant? method requires some way of asking ferret if an in-memory object satisfies a query. i'm not sure how to do that yet. in the worst case i can make an in-memory index, add the message, and search against it to see if i have > 0 results, but that seems pretty insane.



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

def self.spawn_from_query text
  begin
    qobj, extraopts = Index.parse_user_query_string(text)
    return unless qobj
    short_text = text.length < 20 ? text : text[0 ... 20] + "..."
    mode = SearchResultsMode.new qobj, extraopts
    BufferManager.spawn "search: \"#{short_text}\"", mode
    mode.load_threads :num => mode.buffer.content_height
  rescue Ferret::QueryParser::QueryParseException => e
    BufferManager.flash "Couldn't parse query."
  end
end

Instance Method Details

- (Object) refine_search



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

def refine_search
  query = BufferManager.ask :search, "refine query: ", (@qobj.to_s + " ")
  return unless query && query !~ /^\s*$/
  SearchResultsMode.spawn_from_query query
end