Class: TUI::App
- Inherits:
-
Object
- Object
- TUI::App
- Defined in:
- lib/tui/app.rb
Constant Summary collapse
- SCREENS =
%i[chat settings anthropic].freeze
- COMMAND_KEYS =
{ "n" => :new_session, "s" => :settings, "a" => :anthropic, "q" => :quit }.freeze
- MENU_LABELS =
COMMAND_KEYS.map { |key, action| "[#{key}] #{action.capitalize}" }.freeze
- SIDEBAR_WIDTH =
28- STATUS_STYLES =
Connection status display styles
{ disconnected: {label: " DISCONNECTED ", fg: "white", bg: "red"}, connecting: {label: " CONNECTING ", fg: "black", bg: "yellow"}, connected: {label: " CONNECTED ", fg: "black", bg: "yellow"}, subscribed: {label: " CONNECTED ", fg: "black", bg: "green"}, reconnecting: {label: " RECONNECTING ", fg: "black", bg: "yellow"} }.freeze
Instance Attribute Summary collapse
-
#command_mode ⇒ Object
readonly
Returns the value of attribute command_mode.
-
#current_screen ⇒ Object
readonly
Returns the value of attribute current_screen.
Instance Method Summary collapse
-
#initialize(cable_client:) ⇒ App
constructor
A new instance of App.
- #run ⇒ Object
Constructor Details
#initialize(cable_client:) ⇒ App
Returns a new instance of App.
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/tui/app.rb', line 36 def initialize(cable_client:) @cable_client = cable_client @current_screen = :chat @command_mode = false @screens = { chat: Screens::Chat.new(cable_client: cable_client), settings: Screens::Settings.new, anthropic: Screens::Anthropic.new } end |
Instance Attribute Details
#command_mode ⇒ Object (readonly)
Returns the value of attribute command_mode.
33 34 35 |
# File 'lib/tui/app.rb', line 33 def command_mode @command_mode end |
#current_screen ⇒ Object (readonly)
Returns the value of attribute current_screen.
33 34 35 |
# File 'lib/tui/app.rb', line 33 def current_screen @current_screen end |
Instance Method Details
#run ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/tui/app.rb', line 47 def run RatatuiRuby.run do |tui| loop do tui.draw { |frame| render(frame, tui) } event = tui.poll_event(timeout: 0.1) next if event.nil? || event.none? break if handle_event(event) == :quit end end ensure @cable_client.disconnect end |