Class: Twterm::Tab::New::Search
- Inherits:
-
Object
- Object
- Twterm::Tab::New::Search
- Includes:
- Readline, Base
- Defined in:
- lib/twterm/tab/new/search.rb
Instance Attribute Summary
Attributes included from Base
Instance Method Summary collapse
-
#initialize ⇒ Search
constructor
A new instance of Search.
- #invoke_input ⇒ Object
- #respond_to_key(_) ⇒ Object
Methods included from Base
Constructor Details
#initialize ⇒ Search
Returns a new instance of Search.
8 9 10 11 12 13 |
# File 'lib/twterm/tab/new/search.rb', line 8 def initialize super @title = 'New tab' @window.refresh end |
Instance Method Details
#invoke_input ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/twterm/tab/new/search.rb', line 19 def invoke_input resetter = proc do reset_prog_mode sleep 0.1 Screen.instance.refresh end input_thread = Thread.new do close_screen puts "\ninput search query" query = readline('input query > ').strip resetter.call tab = query.nil? || query.empty? ? Tab::New::Start.new : Tab::SearchTab.new(query) TabManager.instance.switch(tab) end App.instance.register_interruption_handler do input_thread.kill resetter.call tab = Tab::New::Start.new TabManager.instance.switch(tab) end input_thread.join end |
#respond_to_key(_) ⇒ Object
15 16 17 |
# File 'lib/twterm/tab/new/search.rb', line 15 def respond_to_key(_) false end |