build_tools.tui_common.controls.selects

Custom Select widget with j/k keybindings.

This module provides a JKSelect widget that extends Textual’s Select widget to support vim-style j/k navigation in addition to arrow keys.

Classes

JKSelectOverlay

Select overlay with j/k keybinding support.

JKSelect

Select widget with vim-style j/k navigation support.

Module Contents

class build_tools.tui_common.controls.selects.JKSelectOverlay(type_to_search=True)[source]

Bases: textual.widgets._select.SelectOverlay

Select overlay with j/k keybinding support.

Handles j/k directly in key event processing to provide vim-style navigation in addition to arrow keys.

Initialize an OptionList.

Parameters:
  • *content – Positional arguments become the options.

  • name – Name of the OptionList.

  • id – The ID of the OptionList in the DOM.

  • classes – Initial CSS classes.

  • disabled – Disable the widget?

  • markup – Strips should be rendered as content markup if True, or plain text if False.

  • compact – Enable compact style?

class build_tools.tui_common.controls.selects.JKSelect(options, *, prompt='Select', allow_blank=True, value=NULL, type_to_search=True, name=None, id=None, classes=None, disabled=False, tooltip=None, compact=False)[source]

Bases: textual.widgets.Select

Select widget with vim-style j/k navigation support.

Extends the standard Textual Select widget to respond to j/k keys in addition to the standard up/down arrow keys when the dropdown is open.

Usage is identical to the standard Select widget:

yield JKSelect(
    [("Option 1", "opt1"), ("Option 2", "opt2")],
    value="opt1",
    id="my-select",
)

Initialize the Select control.

Parameters:
  • options (Iterable[tuple[rich.console.RenderableType, SelectType]]) – Options to select from. If no options are provided then allow_blank must be set to True.

  • prompt (str) – Text to show in the control when no option is selected.

  • allow_blank (bool) – Enables or disables the ability to have the widget in a state with no selection made, in which case its value is set to the constant [Select.NULL][textual.widgets.Select.NULL].

  • value (SelectType | NoSelection) – Initial value selected. Should be one of the values in options. If no initial value is set and allow_blank is False, the widget will auto-select the first available option.

  • type_to_search (bool) – If True, typing will search for options.

  • name (str | None) – The name of the select control.

  • id (str | None) – The ID of the control in the DOM.

  • classes (str | None) – The CSS classes of the control.

  • disabled (bool) – Whether the control is disabled or not.

  • tooltip (rich.console.RenderableType | None) – Optional tooltip.

  • compact (bool) – Enable compact select (without borders).

Raises:

EmptySelectError – If no options are provided and allow_blank is False.

compose()[source]

Compose Select with JKSelectOverlay for j/k navigation.