Class: TUI::App

Inherits:
Object
  • Object
show all
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
COMMAND_KEYS.map { |key, action| "[#{key}] #{action.capitalize}" }.freeze
28

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeApp

Returns a new instance of App.



24
25
26
27
28
29
30
31
32
# File 'lib/tui/app.rb', line 24

def initialize
  @current_screen = :chat
  @command_mode = false
  @screens = {
    chat: Screens::Chat.new,
    settings: Screens::Settings.new,
    anthropic: Screens::Anthropic.new
  }
end

Instance Attribute Details

#command_modeObject (readonly)

Returns the value of attribute command_mode.



22
23
24
# File 'lib/tui/app.rb', line 22

def command_mode
  @command_mode
end

#current_screenObject (readonly)

Returns the value of attribute current_screen.



22
23
24
# File 'lib/tui/app.rb', line 22

def current_screen
  @current_screen
end

Instance Method Details

#runObject



34
35
36
37
38
39
40
41
42
# File 'lib/tui/app.rb', line 34

def run
  RatatuiRuby.run do |tui|
    loop do
      tui.draw { |frame| render(frame, tui) }

      break if handle_event(tui.poll_event) == :quit
    end
  end
end