fix(art): keep iTerm2 inline images on screen
iTerm2 images live in the cell grid, unlike Kitty placements: repainting the mosaic behind them erases the picture. Re-emit the image whenever the mosaic identity (station + track) changes, even if the artwork bytes are the same. Also send doNotMoveCursor=1 to iTerm2 itself so the terminal does not scroll or jump the cursor out from under Textual's compositor; WezTerm keeps the previous payload since it is pickier about parameters.
This commit is contained in:
1 parent
6eb0c6b6fe
commit
06386d3e1e
2 files changed
+52
-6
No files matched your search
+13
-1
@@ -5,6 +5,7 @@ from PIL import Image
|
||||
|
||||
from somafm_tui import artwork
|
||||
from somafm_tui.app import SomaFMApp
|
||||
from somafm_tui.widgets import art as art_widgets
|
||||
from somafm_tui.widgets.art import ArtPane, ITerm2Image, KittyImage
|
||||
from somafm_tui.widgets.stage import StagePanel
|
||||
|
||||
@@ -45,12 +46,23 @@ async def test_art_pane_switches_between_image_and_mosaic(monkeypatch) -> None:
|
||||
assert pane.render() is not None
|
||||
|
||||
|
||||
def test_iterm2_sequence_uses_cell_units() -> None:
|
||||
def test_iterm2_sequence_uses_cell_units(monkeypatch) -> None:
|
||||
monkeypatch.setattr(art_widgets, "_iterm2_native", lambda: False)
|
||||
widget = ITerm2Image(Image.new("RGBA", (32, 32), (10, 20, 30, 255)))
|
||||
sequence = widget._sequence(13, 8)
|
||||
assert sequence.startswith(
|
||||
"\x1b]1337;File=inline=1;width=13;height=8;"
|
||||
)
|
||||
# WezTerm shares the protocol but not every iTerm2-only parameter.
|
||||
assert "doNotMoveCursor" not in sequence
|
||||
|
||||
|
||||
def test_iterm2_native_keeps_the_cursor_put(monkeypatch) -> None:
|
||||
monkeypatch.setattr(art_widgets, "_iterm2_native", lambda: True)
|
||||
widget = ITerm2Image(Image.new("RGBA", (32, 32), (10, 20, 30, 255)))
|
||||
sequence = widget._sequence(13, 8)
|
||||
assert sequence.startswith("\x1b]1337;File=inline=1;doNotMoveCursor=1;")
|
||||
assert "width=13;height=8;" in sequence
|
||||
|
||||
|
||||
def test_kitty_direct_placement_sequences() -> None:
|
||||
|
||||
Reference in new issue
Block a user