Class: Twterm::Tab::New::Search
Constant Summary
collapse
- @@queries =
[]
Instance Attribute Summary
Attributes included from Scrollable
#scroller
Attributes included from Base
#window
Instance Method Summary
collapse
#filter, #filter_query, #reset_filter
Methods included from Base
#close, #refresh, #resize
Constructor Details
#initialize ⇒ Search
Returns a new instance of Search.
20
21
22
23
24
|
# File 'lib/twterm/tab/new/search.rb', line 20
def initialize
super
update_saved_search
end
|
Instance Method Details
#==(other) ⇒ Object
12
13
14
|
# File 'lib/twterm/tab/new/search.rb', line 12
def ==(other)
other.is_a?(self.class)
end
|
#drawable_item_count ⇒ Object
16
17
18
|
# File 'lib/twterm/tab/new/search.rb', line 16
def drawable_item_count
(window.maxy - 6).div(3)
end
|
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
# File 'lib/twterm/tab/new/search.rb', line 26
def invoke_input
resetter = proc do
reset_prog_mode
sleep 0.1
Screen.instance.refresh
end
input_thread = Thread.new do
close_screen
CompletionManager.instance.set_default_mode!
puts "\ninput search query"
query = (readline('> ') || '').strip
resetter.call
tab = query.nil? || query.empty? ? Tab::New::Search.new : Tab::Statuses::Search.new(query)
TabManager.instance.switch(tab)
end
App.instance.register_interruption_handler do
input_thread.kill
resetter.call
tab = Tab::New::Search.new
TabManager.instance.switch(tab)
end
input_thread.join
end
|
#items ⇒ Object
54
55
56
57
58
59
60
|
# File 'lib/twterm/tab/new/search.rb', line 54
def items
if filter_query.empty?
['<Input search query>'] + @@queries
else
@@queries.select { |q| q.matches?(filter_query) }
end
end
|
#respond_to_key(key) ⇒ Object
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
# File 'lib/twterm/tab/new/search.rb', line 62
def respond_to_key(key)
return true if scroller.respond_to_key(key)
case key
when 10
open_search_tab_with_current_query
when ?q
reset_filter
when ?/
filter
else
return false
end
true
end
|
#title ⇒ Object
79
80
81
|
# File 'lib/twterm/tab/new/search.rb', line 79
def title
'New tab'.freeze
end
|
#total_item_count ⇒ Object
Also known as:
count
83
84
85
|
# File 'lib/twterm/tab/new/search.rb', line 83
def total_item_count
items.count
end
|