The full-screen image shows the message's im3: string under its caption

The ^U view now shows the text the sender transmitted, as a centred block
under the caption, so it can be examined or copied. The string never
shrinks the image below its own size: when both cannot fit, the image
keeps the rows and the string goes a page down, as a large QR code's URL
does. A test now pins that ^U opens the view with images shown too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Jean-Pierre MartineauandClaude Opus 5.5 committed 2026-11-19 23:37:23 -05:00
1 parent 24b7690870
commit 2f2225b8bb
4 files changed
+95 -13

No files matched your search

+29
View File
@@ -991,6 +991,35 @@ def test_a_pixel_image_shows_a_short_line_not_its_text() -> None:
assert lines[1].strip() and set(lines[1].strip()) <= set("▀▄█")
def test_with_show_mcoimg_on_ctrl_u_still_opens_the_full_screen(monkeypatch) -> None:
"""With the image in the transcript, ^U on the picked image opens the full screen too."""
from meshterm.core import preferences
from meshterm.ui.pixelart import ImageScreen
prefs = preferences.Preferences()
monkeypatch.setattr(preferences, "current", lambda: prefs)
text = "im3:g/5WjAL`NA"
session = _StubSession()
opened = []
async def run_screen(screen): # noqa: ANN001, ANN202
opened.append(screen)
session.run_screen = run_screen
screen = _screen(session, send=None, messages=[ChatMessage(text=text, peer="d4e5f6a7")])
screen._render_grouped(60)
screen._selected = 0
assert "^U image" in screen.footer_hint
async def press() -> None:
screen.handle("url_code")
await asyncio.sleep(0)
asyncio.run(press())
assert len(opened) == 1 and isinstance(opened[0], ImageScreen)
assert opened[0].raw == text
def test_with_show_mcoimg_off_the_image_is_behind_ctrl_u(monkeypatch) -> None:
"""With ``show_mcoimg`` off, only the line shows, and ^U on the picked image opens it."""
from meshterm.core import preferences
+17
View File
@@ -343,3 +343,20 @@ def test_the_image_screen_centres_the_image_with_a_margin(text: str, cols: int,
left, right = len(art) - len(art.lstrip()), cols - len(art.rstrip())
assert left >= 2 and right >= 2
assert abs(left - right) <= 1
def test_the_image_screen_shows_the_text_of_the_message_under_the_caption() -> None:
"""Under the image and its caption, the full screen shows the ``im3:`` string itself."""
import re
from meshterm.ui.pixelart import ImageScreen
from meshterm.ui.tui.frame import compose_bare
from meshterm.ui.widgets import pixel_image_text
text = "im3:TAYL>iBNGbA"
screen = ImageScreen(decode(text), pixel_image_text(recognize(text)), text)
for _ in range(2):
frame = compose_bare(screen, 72, 24)
lines = [re.sub(r"\x1b\[[0-9;]*m", "", line).strip() for line in frame.split("\n")]
caption = next(i for i, line in enumerate(lines) if "image · 9×7 · 2 colours" in line)
assert text in lines[caption + 1 :]