Repository navigation
Done
Labels
bugSomething isn't working
Description
Summary
GraphicsTracker.on_region_scroll() in src/libvt/graphics.py (#14) increments p.abs_row += history_advanced before computing ir0 = max(p_top, abs_top + history_advanced) - p.abs_row, raising ValueError: negative shift count when a SIXEL placement straddles a DECSTBM scroll margin that saves into history. Meanwhile, Screen._reflow_primary() in src/libvt/screen.py (#2, #4) calls self._gfx.reset() (wiping all stored images and placements on any column resize), thaws every FrozenRow in scrollback even when not fr.wrapped and fr.used <= cols, resets _scrolled_total = len(self._history), and leaves PromptZone and cell-anchored Kitty placement (abs_row, col) pins unmapped.
Reproduction
- Place a
4-rowSIXELstarting at row2(1-based row3) and scrollDECSTBM1..4upward by2lines:
uv run python -c 'from libvt import Terminal; vt = Terminal(rows=6, cols=10, scrollback=10); vt.feed(b"\x1b[3;1H\x1bPq\"1;1;20;64#0~\x1b\\\x1b[1;4r\x1b[4;1H\n\n")'
- Place a
SIXELgraphic and widen the terminal from10to12columns:
uv run python -c 'from libvt import Terminal; vt = Terminal(rows=6, cols=10, scrollback=10); vt.feed(b"\x1bPq\"1;1;20;20#0~\x1b\\"); vt.resize(rows=6, cols=12); print("placements:", len(vt.snapshot().placements))'
Expected
- Step 1 clips the straddling
SIXELbitmask cleanly without raisingValueError. - Step 2 retains the image and placement across
resize(rows=6, cols=12). - Primary-screen
resize()streams logical lines without thawing unwrappedFrozenRowentries whoseused <= cols, preserves monotonicscrolled_totalcontinuity (evicted_total + len(history)), and remapsPromptZoneand non-virtual Kitty placement(abs_row, col)anchors through reflow.
Actual
- Step 1 raises
ValueError: negative shift count. - Step 2 prints
placements: 0.
Environment
Versions
libvt:#2(0.1.0a0)- Python:
3.15.1 - OS: Linux
x86_64
Proposal
Invariants
The invariants below are load-bearing; everything under Intent is open.
Terminal.feed()andScreen.scroll_up()never raiseValueErrorfor any combination ofDECSTBMmargins,history_advanced, andSIXELor Kitty placement bounds.Terminal.resize()retainsGraphicsTrackerimage metadata and placements across both reflow and non-reflow resizes, remapping cell-anchored placements andPromptZonepins on primary reflow and clipping/evicting only placements scrolled past retained history.- Unwrapped
FrozenRowlines withused <= new_colspass through primary reflow as sealedFrozenRowobjects withoutthaw()/freeze()round-tripping.
Intent (non-binding)
- Compute
ir0andir1against pre-advancep_top(oreff_top - p.abs_rowafter consistent coordinate translation) inGraphicsTracker.on_region_scroll(). - Build a streaming pin-mapping table for active
PromptZoneand placement(abs_row, col)coordinates during_reflow_primary(), adjusting_evicted_totaland_scrolled_totalso monotonic row anchors never regress.
Not doing
- Scaling
SIXELpixel bitmaps in software during column resize.
References
Metadata
Metadata
Assignees
Labels
bugSomething isn't working
Activity