Dialogs: reflush the frame on scroll so a braille body can't leave a smear
A dialog that draws a route graph (message paths, the trophy case, the packet viewer) paints braille and node-type marks. On a terminal whose font lacks a glyph, the double-width fallback shoves that row right and smears a static cell — a box border — that prompt_toolkit's differential renderer never rewrites (it only redraws each row up to its new content and only erases a shortened tail), so the fragment lingers once a scroll slides the offending row away. The map fixes its own case by scrubbing two right-edge columns after a pan, but that only works for a full-frame panel whose border sits at the terminal edge; a route-graph dialog is a centred box (or, on an empty stack, a full-frame base) whose smear can land anywhere, so edge geometry can't target it reliably. Instead: a screen opts in with `smears = True`, and on a scroll key the session reflushes — fills pt's remembered frame with a sentinel so the next diff rewrites every cell *in place* and erase-to-end-of-lines each tail, scrubbing the leftover wherever it sits. Because the cached frame is kept (not dropped), pt overwrites rather than erasing first, so there's no blank-flash flicker. Plain dialogs keep the efficient differential paint untouched; the map/atlas keep their own edge scrub. Functionality is unchanged — only the smear is cleaned. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
1 parent
583be7c4f7
commit
82ed64ffcd
6 files changed
+124
-10
No files matched your search
@@ -1480,6 +1480,60 @@ def test_session_background_is_the_topmost_full_frame_screen() -> None:
|
||||
assert session._float_layers() == [dialog]
|
||||
|
||||
|
||||
def test_scrolling_a_smear_prone_screen_reflushes_the_whole_frame() -> None:
|
||||
"""A braille screen force-rewrites every cell on scroll, so a wide-glyph smear on any
|
||||
static cell (a dialog border) is scrubbed — where a plain screen keeps the fast diff."""
|
||||
import types
|
||||
|
||||
from prompt_toolkit.data_structures import Size
|
||||
from prompt_toolkit.layout.screen import Char
|
||||
from prompt_toolkit.layout.screen import Screen as PtScreen
|
||||
|
||||
def _fake_app(last: PtScreen) -> types.SimpleNamespace:
|
||||
return types.SimpleNamespace(
|
||||
renderer=types.SimpleNamespace(_last_screen=last),
|
||||
output=types.SimpleNamespace(get_size=lambda: Size(rows=10, columns=60)),
|
||||
invalidate=lambda: None,
|
||||
)
|
||||
|
||||
class _Braille(ScrollScreen):
|
||||
smears = True
|
||||
|
||||
def _filled() -> PtScreen:
|
||||
screen = PtScreen()
|
||||
for row in range(10):
|
||||
for x in range(60):
|
||||
screen.data_buffer[row][x] = Char("A")
|
||||
return screen
|
||||
|
||||
# A smear-prone screen: a scroll fills the remembered frame with the scrub sentinel, so
|
||||
# the next diff rewrites every cell in place (no cell is left for the smear to hide in).
|
||||
session = TuiSession()
|
||||
last = _filled()
|
||||
session._app = _fake_app(last)
|
||||
session.push(_Braille(Text("x")))
|
||||
session._dispatch("down")
|
||||
assert all(last.data_buffer[r][x].char == "" for r in range(10) for x in range(60))
|
||||
|
||||
# A plain screen keeps the efficient differential paint — the frame is left untouched.
|
||||
session = TuiSession()
|
||||
last = _filled()
|
||||
session._app = _fake_app(last)
|
||||
session.push(ScrollScreen(Text("x"))) # smears defaults False
|
||||
session._dispatch("down")
|
||||
assert last.data_buffer[0][0].char == "A"
|
||||
|
||||
|
||||
def test_smear_prone_route_graph_dialogs_opt_into_the_reflush() -> None:
|
||||
"""The braille route-graph dialogs declare ``smears`` so a scroll scrubs their borders."""
|
||||
from meshterm.ui.message_paths_screen import MessagePathsScreen
|
||||
from meshterm.ui.packet_viewer import PacketViewer
|
||||
from meshterm.ui.records_screen import RecordDialog
|
||||
|
||||
assert PacketViewer.smears and MessagePathsScreen.smears and RecordDialog.smears
|
||||
assert Screen.smears is False # the default: plain screens keep the fast diff
|
||||
|
||||
|
||||
def test_floating_text_prompt_is_a_popup_over_a_blank_base() -> None:
|
||||
"""``text(floating=True)`` floats as a centered popup even on an empty stack.
|
||||
|
||||
|
||||
Reference in new issue
Block a user