Class: Charming::Components::StatusBar
- Inherits:
-
Charming::Component
- Object
- View
- Charming::Component
- Charming::Components::StatusBar
- Defined in:
- lib/charming/presentation/components/status_bar.rb
Overview
StatusBar renders a single fixed-width row with left/center/right segments —the classic TUI bottom bar for mode indicators, hints, and app state.
StatusBar.new(width: screen.width, left: "NORMAL", right: "main ⎇")
When hints is given (an array of [key, description] pairs), the center segment renders them as ‘key description` pairs — pass a controller’s key bindings to get an automatic hint line.
Instance Method Summary collapse
-
#initialize(width:, left: "", center: "", right: "", hints: nil, style: nil, theme: nil) ⇒ StatusBar
constructor
width is the total bar width.
-
#render ⇒ Object
Renders the bar: left-aligned, centered, and right-aligned segments on one row, padded to the full width and wrapped in the bar style.
Methods inherited from Charming::Component
Methods inherited from View
Constructor Details
#initialize(width:, left: "", center: "", right: "", hints: nil, style: nil, theme: nil) ⇒ StatusBar
width is the total bar width. left/center/right are the segment contents. hints renders key-hint pairs in the center when no explicit center is given. style overrides the default bar background style.
17 18 19 20 21 22 23 24 25 |
# File 'lib/charming/presentation/components/status_bar.rb', line 17 def initialize(width:, left: "", center: "", right: "", hints: nil, style: nil, theme: nil) super(theme: theme) @width = width @left = left.to_s @center = center.to_s @right = right.to_s @hints = hints @bar_style = style end |
Instance Method Details
#render ⇒ Object
Renders the bar: left-aligned, centered, and right-aligned segments on one row, padded to the full width and wrapped in the bar style.
29 30 31 |
# File 'lib/charming/presentation/components/status_bar.rb', line 29 def render resolved_style.render(compose_segments) end |