Class: Twterm::Tab::KeyAssignmentsCheatsheet
- Inherits:
-
AbstractTab
- Object
- AbstractTab
- Twterm::Tab::KeyAssignmentsCheatsheet
- Includes:
- Scrollable
- Defined in:
- lib/twterm/tab/key_assignments_cheatsheet.rb
Constant Summary collapse
- SHORTCUTS =
{ ['General', :general] => { page_down: 'Page down', top: 'Move to top', bottom: 'Move to bottom', down: 'Move down', up: 'Move up', page_up: 'Page up', left: 'Left', right: 'Right', }, ['Tabs', :tab] => { new: 'New tab', reload: 'Reload', close: 'Close tab', search_down: 'Search down', search_up: 'Search up', find_next: 'Find next', find_previous: 'Find previous', }, ['Tweets', :status] => { compose: 'New tweet', conversation: 'Conversation', destroy: 'Delete', like: 'Like', open_link: 'Open URLs', reply: 'Reply', retweet: 'Retweet', quote: 'Quote', user: 'User', }, ['Cursor', :cursor] => { top_of_window: 'Top of window', middle_of_window: 'Middle of window', bottom_of_window: 'Bottom of window' }, ['Others', :app] => { me: 'My profile', cheatsheet: 'Key assignments cheatsheet', quit: 'Quit', } }
Instance Method Summary collapse
- #==(other) ⇒ Object
- #drawable_item_count ⇒ Object
- #image ⇒ Object
-
#initialize(app, client) ⇒ KeyAssignmentsCheatsheet
constructor
A new instance of KeyAssignmentsCheatsheet.
- #respond_to_key(key) ⇒ Object
- #title ⇒ Object
- #total_item_count ⇒ Object
Methods included from Scrollable
Methods inherited from AbstractTab
#close, #find_or_fetch_list, #find_or_fetch_status, #find_or_fetch_user, #render
Methods included from Subscriber
included, #subscribe, #unsubscribe
Constructor Details
#initialize(app, client) ⇒ KeyAssignmentsCheatsheet
Returns a new instance of KeyAssignmentsCheatsheet.
80 81 82 83 |
# File 'lib/twterm/tab/key_assignments_cheatsheet.rb', line 80 def initialize(app, client) super(app, client) scroller.set_no_cursor_mode! end |
Instance Method Details
#==(other) ⇒ Object
10 11 12 |
# File 'lib/twterm/tab/key_assignments_cheatsheet.rb', line 10 def ==(other) other.is_a?(self.class) end |
#drawable_item_count ⇒ Object
57 58 59 |
# File 'lib/twterm/tab/key_assignments_cheatsheet.rb', line 57 def drawable_item_count window.maxy - 3 end |
#image ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/twterm/tab/key_assignments_cheatsheet.rb', line 61 def image k = KeyMapper.instance SHORTCUTS .flat_map { |(cat_str, cat_sym), shortcuts| [ !Image.string(cat_str).color(:green), Image.blank_line, *shortcuts.map { |cmd, desc| Image.string(' ') - !Image.string(k.as_string(cat_sym, cmd).center(3)).color(:cyan) - Image.whitespace - Image.string(desc) }, Image.blank_line, ] } .drop(scroller.offset) .take(drawable_item_count) .reduce(Image.empty, :|) end |
#respond_to_key(key) ⇒ Object
85 86 87 88 89 |
# File 'lib/twterm/tab/key_assignments_cheatsheet.rb', line 85 def respond_to_key(key) return true if scroller.respond_to_key(key) false end |
#title ⇒ Object
91 92 93 |
# File 'lib/twterm/tab/key_assignments_cheatsheet.rb', line 91 def title 'Key assignments'.freeze end |