Class: Llv::Tui::App
- Inherits:
-
Object
- Object
- Llv::Tui::App
- Includes:
- Bubbletea::Model
- Defined in:
- lib/llv/tui.rb
Overview
Bubbletea model: master/detail over Llv::GroupStore. Subscribes from a background thread that turns store events into messages on the runner.
Constant Summary collapse
- KIND_GLYPHS =
{ http: "▶", job: "⚙", cable: "≋", untagged: "·" }.freeze
- TOGGLEABLE_KINDS =
%i[http job cable].freeze
- ListStyle =
No padding here — each row already builds itself to the full list_width. Padding would shrink the content area and force lipgloss to wrap every row to two visual lines, which destroys the highlight.
Lipgloss::Style.new
- DetailStyle =
Lipgloss::Style.new.padding(0, 1)
- HeaderStyle =
Lipgloss::Style.new.bold(true).foreground("#6cbcff")
- SubheaderStyle =
Lipgloss::Style.new.foreground("#7b8190")
- RowActiveStyle =
Lipgloss::Style.new.foreground("#ffffff").background("#1d4ed8").bold(true)
- RowActiveMarker =
Lipgloss::Style.new.foreground("#6cbcff").bold(true)
- RowStyle =
Lipgloss::Style.new
- RowInactiveMarker =
Lipgloss::Style.new.foreground("#262b3a")
- MutedStyle =
Lipgloss::Style.new.foreground("#7b8190")
- HelpStyle =
Lipgloss::Style.new.foreground("#7b8190").italic(true)
- DividerStyle =
Lipgloss::Style.new.foreground("#262b3a")
- VerbStyles =
{ "GET" => Lipgloss::Style.new.foreground("#6fcf97"), "POST" => Lipgloss::Style.new.foreground("#6cbcff"), "PUT" => Lipgloss::Style.new.foreground("#f2c14e"), "PATCH" => Lipgloss::Style.new.foreground("#f2c14e"), "DELETE" => Lipgloss::Style.new.foreground("#ef6c6c"), "HEAD" => Lipgloss::Style.new.foreground("#7b8190"), "OPTIONS" => Lipgloss::Style.new.foreground("#7b8190") }.freeze
- StatusOkStyle =
Lipgloss::Style.new.foreground("#6fcf97").bold(true)
- StatusRedirStyle =
Lipgloss::Style.new.foreground("#56b6c2")
- StatusWarnStyle =
Lipgloss::Style.new.foreground("#f2c14e")
- StatusErrStyle =
Lipgloss::Style.new.foreground("#ef6c6c").bold(true)
Instance Method Summary collapse
- #height=(h) ⇒ Object
- #init ⇒ Object
-
#initialize(store:) ⇒ App
constructor
A new instance of App.
- #update(message) ⇒ Object
- #view ⇒ Object
- #width=(w) ⇒ Object
Constructor Details
#initialize(store:) ⇒ App
Returns a new instance of App.
66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/llv/tui.rb', line 66 def initialize(store:) @store = store @order = [] @summaries = {} @details = {} @selected = nil @width = 100 @height = 30 @show_sql_source = true @focus = :left @detail_scroll = 0 @enabled_kinds = TOGGLEABLE_KINDS.to_set seed_from_store end |
Instance Method Details
#height=(h) ⇒ Object
82 |
# File 'lib/llv/tui.rb', line 82 def height=(h); @height = h; end |
#init ⇒ Object
84 85 86 |
# File 'lib/llv/tui.rb', line 84 def init [self, nil] end |
#update(message) ⇒ Object
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/llv/tui.rb', line 88 def update() case when Bubbletea::WindowSizeMessage @width = .width @height = .height [self, nil] when Bubbletea::KeyMessage handle_key() when GroupChangeMessage apply_change() [self, nil] when GroupBodyMessage @details[.group[:id]] = .group [self, nil] else [self, nil] end end |
#view ⇒ Object
107 108 109 110 111 112 |
# File 'lib/llv/tui.rb', line 107 def view list = render_list detail = render_detail body = Lipgloss.join_horizontal(Lipgloss::TOP, list, divider, detail) [header, body, ].join("\n") end |
#width=(w) ⇒ Object
81 |
# File 'lib/llv/tui.rb', line 81 def width=(w); @width = w; end |