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]>
45 lines
1.4 KiB
Python
Vendored
45 lines
1.4 KiB
Python
Vendored
from typing import Callable
|
|
|
|
from textual.expand_tabs import get_tab_widths
|
|
|
|
__all__ = ["cell_len", "cell_width_to_column_index"]
|
|
|
|
|
|
cell_len: Callable[[str], int]
|
|
try:
|
|
from rich.cells import cached_cell_len as cell_len
|
|
except ImportError:
|
|
from rich.cells import cell_len
|
|
|
|
|
|
def cell_width_to_column_index(line: str, cell_width: int, tab_width: int) -> int:
|
|
"""Retrieve the column index corresponding to the given cell width.
|
|
|
|
Args:
|
|
line: The line of text to search within.
|
|
cell_width: The cell width to convert to column index.
|
|
tab_width: The tab stop width to expand tabs contained within the line.
|
|
|
|
Returns:
|
|
The column corresponding to the cell width.
|
|
"""
|
|
column_index = 0
|
|
total_cell_offset = 0
|
|
for part, expanded_tab_width in get_tab_widths(line, tab_width):
|
|
# Check if the click landed on a character within this part.
|
|
for character in part:
|
|
total_cell_offset += cell_len(character)
|
|
if total_cell_offset > cell_width:
|
|
return column_index
|
|
column_index += 1
|
|
|
|
# Account for the appearance of the tab character for this part
|
|
total_cell_offset += expanded_tab_width
|
|
# Check if the click falls within the boundary of the expanded tab.
|
|
if total_cell_offset > cell_width:
|
|
return column_index
|
|
|
|
column_index += 1
|
|
|
|
return len(line)
|