Files
dssc/vendor/textual/pad.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

80 lines
2.3 KiB
Python
Vendored

from typing import cast
from rich.align import Align, AlignMethod
from rich.console import (
Console,
ConsoleOptions,
JustifyMethod,
RenderableType,
RenderResult,
)
from rich.measure import Measurement
from rich.segment import Segment, Segments
from rich.style import Style
class HorizontalPad:
"""Rich renderable to add padding on the left and right of a renderable.
Note that unlike Rich's Padding class this align each line independently.
"""
def __init__(
self,
renderable: RenderableType,
left: int,
right: int,
pad_style: Style,
justify: JustifyMethod,
) -> None:
"""
Initialize HorizontalPad.
Args:
renderable: A Rich renderable.
left: Left padding.
right: Right padding.
pad_style: Style of padding.
justify: Justify method.
"""
self.renderable = renderable
self.left = left
self.right = right
self.pad_style = pad_style
self.justify = justify
def __rich_console__(
self, console: Console, options: ConsoleOptions
) -> RenderResult:
options = options.update(
width=options.max_width - self.left - self.right, height=None
)
lines = console.render_lines(self.renderable, options, pad=False)
left_pad = Segment(" " * self.left, self.pad_style)
right_pad = Segment(" " * self.right, self.pad_style)
align: AlignMethod = cast(
AlignMethod,
self.justify if self.justify in {"left", "right", "center"} else "left",
)
for line in lines:
pad_line = line
if self.left:
pad_line = [left_pad, *line]
if self.right:
pad_line.append(right_pad)
segments = Segments(pad_line)
yield Align(segments, align=align)
def __rich_measure__(
self, console: "Console", options: "ConsoleOptions"
) -> Measurement:
measurement = Measurement.get(console, options, self.renderable)
total_padding = self.left + self.right
return Measurement(
measurement.minimum + total_padding,
measurement.maximum + total_padding,
)