Skip to content

API turboframe.ui.compat

rafageist edited this page Dec 4, 2026 · 5 revisions

turboframe.ui.compat

Source: turboframe/ui/compat.py. Generated from the code of TurboFrame 0.3.0 by tools/wiki_api.py.

Terminal compatibility fixes: Textual's key parser, and its scroll bars' thumbs.

Alt+letter must open a menu or reach a dialog's control. A terminal sends it as ESC followed by the letter, and Textual's parser (textual._xterm_parser) does two things with that which break the Turbo Vision model:

  • ESC f and ESC b are in its table of sequences as iTerm's word moves (Ctrl+Right, Ctrl+Left), so Alt+F and Alt+B never arrive as Alt keys;
  • ESC 0 to ESC 9 are in it as the characters macOS types with Option and a digit (ESC 4 is ¢), so Alt+1..9 never select a window;
  • every Alt+letter key carries its letter as a character, so the focused input line types it before the menus see it.

These are private Textual APIs. The application applies it when its TUI starts, so a CLI or a core never touch them; tests/test_compat.py fails if a Textual upgrade makes it stop working.

Textual's own scroll bars (an editor's, a scrolling view's) draw the thumb's ends in eighths of a cell (▁▂▃ and ▉▊▋), which are not CP437 (see turboframe.text): a font without them draws something else, or two cells. install_cell_scrollbars() makes every one of them draw the thumb in whole cells, as Turbo Vision's, the way Textual documents (ScrollBar.renderer). It changes Textual's class for the whole process; DesktopApp calls it unless its CELL_SCROLLBARS is False.

Contents

CellScrollBarRender, fix_alt_keys, install_cell_scrollbars

class CellScrollBarRender

class CellScrollBarRender(ScrollBarRender)

Thumbs in whole cells, as Turbo Vision's: Textual's eighths (U+2581.., U+2589..) are not CP437.

fix_alt_keys

def fix_alt_keys() -> bool

Make Alt+letter arrive as alt+<letter> with no character. Returns True when applied now.

install_cell_scrollbars

def install_cell_scrollbars() -> bool

Make every Textual scroll bar draw its thumb in whole cells. Returns True when installed now.

Clone this wiki locally