Class: TUI::Screens::Settings
- Inherits:
-
Object
- Object
- TUI::Screens::Settings
- Defined in:
- lib/tui/screens/settings.rb
Constant Summary collapse
- MENU_ITEMS =
[ "General", "Appearance", "Keybindings" ].freeze
Instance Method Summary collapse
- #handle_event(event) ⇒ Object
-
#initialize ⇒ Settings
constructor
A new instance of Settings.
- #render(frame, area, tui) ⇒ Object
Constructor Details
#initialize ⇒ Settings
Returns a new instance of Settings.
12 13 14 15 |
# File 'lib/tui/screens/settings.rb', line 12 def initialize # Initialized on first render — requires tui context from RatatuiRuby.run block @list_state = nil end |
Instance Method Details
#handle_event(event) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/tui/screens/settings.rb', line 37 def handle_event(event) return false unless @list_state if event.down? || event.j? @list_state.select_next true elsif event.up? || event.k? @list_state.select_previous true else false end end |
#render(frame, area, tui) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/tui/screens/settings.rb', line 17 def render(frame, area, tui) @list_state ||= tui.list_state(0) list = tui.list( items: MENU_ITEMS, highlight_style: {fg: "yellow", bold: true}, highlight_symbol: "> ", block: tui.block( title: "Settings", titles: [ {content: "↑/↓ navigate • Esc back", position: :bottom, alignment: :center} ], borders: [:all], border_type: :rounded, border_style: {fg: "green"} ) ) frame.(list, area, @list_state) end |