claudewheel v0.15.1 /claudewheel.renderer
Edit
On this page

Renderer class for drawing the segment bar TUI.

#claudewheel.renderer

#claudewheel.renderer

Draw the segment bar, fan-out options, minimap, and scroll arrows.

#Renderer

Renders the segment bar centered, with fan-out options and themed colors.

#render

python
def render(self, bar: SegmentBar, flash: str='', *, show_provenance: bool=False) -> None

#_seg_colors

python
def _seg_colors(self, key: str) -> dict[str, str]

Get per-segment color dict, falling back to empty strings.

#_compute_bar_layout

python
def _compute_bar_layout(self, bar: SegmentBar) -> tuple[list[dict], int]

Compute column positions and widths for each segment without rendering.

Returns (layout, total_width) where layout is a list of dicts with keys: key, col, label_str, label_width, display_value, value_width, has_cursor, is_focused.

#_compute_viewport

python
def _compute_viewport(self, layout: list[dict], total_width: int) -> int

Compute horizontal viewport start offset for narrow terminals.

When the bar fits in the terminal, returns 0. Otherwise, centers the viewport on the focused segment and reserves ARROW_MARGIN on each side for scroll indicators.

#_count_offscreen

python
def _count_offscreen(self) -> tuple[int, int]

Count segments fully off-screen to the left and right of the viewport.

#_render_arrows

python
def _render_arrows(self, buf: list[str], center_row: int) -> None

Render edge arrows with off-screen segment counts when scrolling.

#_render_fan_out

python
def _render_fan_out(self, buf: list[str], bar: SegmentBar, center_row: int) -> None

Render non-selected options vertically above/below the focused segment.

#_render_option

python
def _render_option(self, buf: list[str], seg: Segment, opt_text: str, display: str, option_fg: str, unavail_fg: str) -> None

Render a single fan-out option, applying per-char match highlighting when a search buffer is active and the option is a normal (non-special) entry. Special entries ("+" sentinel, empty placeholder, unavailable, uninstalled) keep their dedicated color and are not highlighted.

When the provenance overlay is active, a dim single-character glyph is prepended to indicate the option's source collection.

#_render_highlighted_option

python
def _render_highlighted_option(self, buf: list[str], query: str, opt_text: str, display: str, base_fg: str) -> None

Append display to buf with chars at fuzzy-matched positions rendered in search_match_fg, others in base_fg. Positions are computed against opt_text but applied to display (which may be truncated/padded); positions outside display's range are dropped, and we exclude the final ellipsis char if the value was truncated.

#_render_minimap

python
def _render_minimap(self, buf: list[str], bar: SegmentBar) -> None

Render a minimap of colored blocks in the top-right corner.

Each segment is one block character. Focused segment gets a highlight background; segments with no value are muted; others use their accent color.

#_fit_value

python
def _fit_value(self, value: str, min_w: int, max_w: int) -> str

Truncate with ellipsis or pad with spaces to fit width constraints.