class

Phosphor::TabsMock

Inherits Phosphor::MockWidget < Reference < Object

A tab bar that communicates which content panel is currently active.

Generic and app-agnostic: no knowledge of AppState, Msg, or the application theme. The Widget wrapper resolves theme → Style values and sets them in Props before each render.

active_index lives in Props, not WidgetState: the owning Widget drives it from AppState via sync, so TabsMock never maintains its own notion of which tab is active — it renders whatever Props says. Distinct from MenuMock because one tab is always visually active.

Constructors

new(props : Props, state : MockWidget::WidgetState = MockWidget::WidgetState.new)

Initialises the tab bar with props and an optional state. No extra render state is needed beyond the base WidgetState.

Source

Instance methods

handle_cmd(cmd : Cmd) : CmdResult

Responds to tab-navigation commands.

  • Cmd::TabNextprops.active_index + 1, wrapping to 0.
  • Cmd::TabPrevprops.active_index − 1, wrapping to the last tab.
  • Any other command, or navigation on an empty props.tabs — returns CmdResult::None.
Source
props
Source
props=(props : Props)
Source
render_content(frame : Frame, buf : Buffer) : Void

Renders every tab label in a single row at frame.y, separated by props.separator (written in props.inactive_style). The tab at props.active_index is written in props.active_style; every other tab in props.inactive_style. Stops as soon as the row would exceed frame.width — trailing tabs are truncated, not the row itself.

Source

Nested types