Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,16 @@ returned by {meth}`~libvt.snapshot.Snapshot.to_dict`.

### Fixes

#### Keep retained live regions aligned across scroll and reflow (#197)

A live {class}`~libvt.views.RegionView` and its nested crops resolve viewport
coordinates from the live {class}`~libvt.screen.Screen` on each read, clipping
to current dimensions after scrolls, reflows, and resizes. Live
{class}`~libvt.views.RowView` instances track their viewport row coordinate and
read as empty while out of bounds after a vertical shrink, while regions from a
{class}`~libvt.snapshot.Snapshot` or {meth}`~libvt.snapshot.Snapshot.viewport`
keep their captured rows.

#### Include `examples/` in source distributions (#196)

`pyproject.toml` source distribution builds include `examples/` files
Expand Down
23 changes: 21 additions & 2 deletions docs/topics/snapshots.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,10 @@ styles:

A region accepts the same row and column indices as its source. Nested indices
are relative to the crop. Read `columns` to locate it in the source grid. A
live region clips to its retained rows after a resize. A snapshot region keeps
its captured dimensions.
live region resolves its selected viewport coordinates from the live screen on
each read, staying aligned across scrolls, reflows, and resizes while clipping
to the current dimensions. A snapshot region keeps its captured rows and
dimensions.

```python
>>> from libvt import Terminal
Expand All @@ -173,6 +175,23 @@ its captured dimensions.
'ABCDEF'
```

Retaining a live region alongside a snapshot region shows how each behaves
across scrolling and reflow:

```python
>>> from libvt import Terminal
>>> term = Terminal(rows=2, cols=6)
>>> term.feed(b"012345\r\nabcdef")
>>> live = term[:, 1:5]
>>> frozen = term.committed[:, 1:5]
>>> term.feed(b"\r\nghijkl")
>>> live.lines, frozen.lines
(('bcde', 'hijk'), ('1234', 'bcde'))
>>> term.resize(rows=2, cols=4, reflow=True)
>>> live.lines, live.columns, frozen.lines
(('hij', 'l'), range(1, 4), ('1234', 'bcde'))
```

A row's `used` extent includes written background-only cells. Its `text_used`
extent ends with the text. Both are measured from the start of the row view.

Expand Down
2 changes: 1 addition & 1 deletion src/libvt/screen.py
Original file line number Diff line number Diff line change
Expand Up @@ -919,7 +919,7 @@ def blit(
src_col_base = 0
src_cols = source._cols
elif isinstance(source, RegionView):
src_rows = source._rows
src_rows = source._current_rows()
cols_range = source.columns
src_col_base = cols_range.start
src_cols = len(cols_range)
Expand Down
Loading
Loading