Repository navigation
Description
Summary
A string search for a button label returns code-point offsets. A clickable cell following three wide characters is at column 7 while the string match begins at index 4.
Motivation
Expose every exact match as a row and a half-open range of terminal columns on an immutable snapshot.
From the tagged libvt checkout, install the locked development dependencies with uv sync --frozen --python 3.14 --all-groups --all-extras. Use the checkout root as the working directory.
Save the following as case.py at the checkout root and run uv run --no-sync python case.py.
from libvt import Terminal
term = Terminal(rows=2, cols=24)
term.feed("界界界·Go Go".encode())
view = term.committed
text_column = view.lines[0].index("Go")
cell_columns = [col for col, cell in enumerate(view[0]) if cell.text == "G"]
print("string index", text_column, "actual G cells", cell_columns)
assert text_column == 4 and cell_columns == [7, 10]Evidence
CPython 3.14.6 on Linux ARM64 under WSL2. The example produced the reported result against both v0.0.1a4 and the tested trunk revision.
Observed output
string index 4 actual G cells [7, 10]
Proposal
Start with complete grapheme matches within a single viewport row. Return all matching spans in row order and define missing, duplicate and clipped-glyph behavior.
- Developer experience — Downstream TUIs can reuse one locator for clicking, assertions and highlighting.
- Immediate benefit — A click lands on the intended label regardless of the width of its prefix.
- Longer-term benefit — A cell-aware query surface can support multiple input transports and screen profiles.
- End-user experience — Clicking a translated or emoji-prefixed label reaches the visible choice.
Activity
tony commentedon Dec 3, 2026
The local PTY replay searched
界界界·Go Go. It found the twoGospans at display columns 7 and 10. Clicking with the returned cell span chose Ferry. Replacing it with a Python string index chose Harbor. Related PR #133snapshot(feat): Locate text by cell coordinates