Files
dssc/vendor/textual/widgets/_help_panel.py
T
lucioandClaude Opus 5.5 60532a4043 Rebuild the UI on vendored Textual; make the checkout self-contained
The internal servers have no access to outside package repositories and
run Python 3.8/3.9, so the UI moves from hand-drawn curses to Textual
6.2.1 (the last release supporting 3.8.1), vendored with its pure-Python
dependencies in vendor/. The launcher puts vendor/ first on sys.path, so a
plain checkout runs with no pip and no network.

- dsflow/: the single script split into a package (pure moves of the
  backend sections); action rules moved to ops.py, free of Textual
- dsflow/ui/: tabs, detail pane, live sanity-run panel, log viewer,
  modal dialogs, filter, themes, mouse support
- tests/test_ui.py: headless UI tests through Textual's pilot
- tools/vendor.py (refresh vendor/), tools/screenshots.py (README images)
- README, CLAUDE.md, TODO and the feature doc updated for the new layout,
  the Python 3.8.1 floor and the vendoring rules

Verified: 11 tests green on Python 3.12 and 3.8.20; the shipped file set
runs under `python -I -S` on both.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-09-24 03:24:21 -07:00

110 lines
2.7 KiB
Python
Vendored

from __future__ import annotations
from textwrap import dedent
from textual.app import ComposeResult
from textual.css.query import NoMatches
from textual.widget import Widget
from textual.widgets import KeyPanel, Markdown
class HelpPanel(Widget):
"""
Shows context sensitive help for the currently focused widget.
"""
DEFAULT_CSS = """
HelpPanel {
split: right;
width: 33%;
min-width: 30;
max-width: 60;
border-left: vkey $foreground 30%;
padding: 0 1;
height: 1fr;
padding-right: 1;
layout: vertical;
height: 100%;
&:ansi {
background: ansi_default;
border-left: vkey ansi_black;
Markdown, KeyPanel {
background: ansi_default;
}
.bindings-table--divide {
color: transparent;
}
}
#widget-help {
height: auto;
max-height: 50%;
width: 1fr;
padding: 0;
margin: 0;
padding: 1 0;
margin-top: 1;
display: none;
background: $panel;
&:ansi {
background: ansi_default;
}
MarkdownBlock {
padding-left: 2;
padding-right: 2;
}
}
&.-show-help #widget-help {
display: block;
}
KeyPanel#keys-help {
width: 1fr;
height: 1fr;
min-width: initial;
split: initial;
border-left: none;
padding: 0;
}
}
"""
DEFAULT_CLASSES = "-textual-system"
def on_mount(self):
def update_help(focused_widget: Widget | None):
self.update_help(focused_widget)
self.watch(self.screen, "focused", update_help)
def update_help(self, focused_widget: Widget | None) -> None:
"""Update the help for the focused widget.
Args:
focused_widget: The currently focused widget, or `None` if no widget was focused.
"""
if not self.app.app_focus:
return
if not self.screen.is_active:
return
self.set_class(focused_widget is not None, "-show-help")
if focused_widget is not None:
help = focused_widget.HELP or ""
if not help:
self.remove_class("-show-help")
try:
self.query_one(Markdown).update(dedent(help.rstrip()))
except NoMatches:
pass
def compose(self) -> ComposeResult:
yield Markdown(id="widget-help")
yield KeyPanel(id="keys-help")