Class: Redwood::SearchResultsMode
- Inherits:
-
ThreadIndexMode
- Object
- Mode
- ScrollMode
- LineCursorMode
- ThreadIndexMode
- Redwood::SearchResultsMode
- Defined in:
- lib/sup/modes/search-results-mode.rb
Constant Summary
Constants inherited from ThreadIndexMode
ThreadIndexMode::DATE_WIDTH, ThreadIndexMode::LOAD_MORE_THREAD_NUM, ThreadIndexMode::MIN_FROM_WIDTH
Constants inherited from ScrollMode
Instance Attribute Summary
Attributes inherited from LineCursorMode
Attributes inherited from ScrollMode
#botline, #leftcol, #status, #topline
Attributes inherited from Mode
Class Method Summary collapse
-
.spawn_from_query(text) ⇒ Object
a proper is_relevant? method requires some way of asking ferret if an in-memory object satisfies a query.
Instance Method Summary collapse
-
#initialize(qobj) ⇒ SearchResultsMode
constructor
A new instance of SearchResultsMode.
- #refine_search ⇒ Object
Methods inherited from ThreadIndexMode
#[], #actually_toggle_archived, #actually_toggle_deleted, #actually_toggle_spammed, #actually_toggle_starred, #apply_to_tagged, #cleanup, #contains_thread?, #edit_labels, #edit_message, #forward, #handle_add_update, #handle_archived_update, #handle_delete_update, #handle_deleted_update, #handle_label_thread_update, #handle_label_update, #handle_read_update, #is_relevant?, #jump_to_next_new, #kill, #lines, #load_n_threads, #load_n_threads_background, #load_threads, #multi_edit_labels, #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, #toggle_archived, #toggle_deleted, #toggle_new, #toggle_spam, #toggle_starred, #toggle_tagged, #toggle_tagged_all, #update
Methods inherited from LineCursorMode
Methods inherited from ScrollMode
#at_bottom?, #at_top?, #cancel_search!, #col_left, #col_right, #continue_search_in_buffer, #draw, #ensure_mode_validity, #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_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, register_keymap, #resize, #resolve_input, #save_to_file, #status
Constructor Details
#initialize(qobj) ⇒ SearchResultsMode
Returns a new instance of SearchResultsMode.
4 5 6 7 |
# File 'lib/sup/modes/search-results-mode.rb', line 4 def initialize qobj @qobj = qobj super [], { :qobj => @qobj } end |
Class Method Details
.spawn_from_query(text) ⇒ Object
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.
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/sup/modes/search-results-mode.rb', line 25 def self.spawn_from_query text begin qobj = Index.parse_user_query_string(text) or return short_text = text.length < 20 ? text : text[0 ... 20] + "..." mode = SearchResultsMode.new qobj 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
#refine_search ⇒ Object
13 14 15 16 17 |
# File 'lib/sup/modes/search-results-mode.rb', line 13 def refine_search query = BufferManager.ask :search, "query: ", (@qobj.to_s + " ") return unless query && query !~ /^\s*$/ SearchResultsMode.spawn_from_query query end |