3 class SearchResultsMode < ThreadIndexMode
6 super [], { :qobj => @qobj }
10 k.add :refine_search, "Refine search", '.'
14 query = BufferManager.ask :search, "query: ", (@qobj.to_s + " ")
15 return unless query && query !~ /^\s*$/
16 SearchResultsMode.spawn_from_query query
19 ## a proper is_relevant? method requires some way of asking ferret
20 ## if an in-memory object satisfies a query. i'm not sure how to do
21 ## that yet. in the worst case i can make an in-memory index, add
22 ## the message, and search against it to see if i have > 0 results,
23 ## but that seems pretty insane.
25 def self.spawn_from_query text
27 qobj = Index.parse_user_query_string(text) or return
28 short_text = text.length < 20 ? text : text[0 ... 20] + "..."
29 mode = SearchResultsMode.new qobj
30 BufferManager.spawn "search: \"#{short_text}\"", mode
31 mode.load_threads :num => mode.buffer.content_height
32 rescue Ferret::QueryParser::QueryParseException => e
33 BufferManager.flash "Couldn't parse query."