mirror of
https://github.com/tmux/tmux.git
synced 2026-10-16 00:14:23 +00:00
Merge image_merge into 4902-image-support
Keep retained indexed SIXEL data and the bounded per-terminal output cache. Use the cleaned-up decoder and RGBA encoder from image_merge, including parser memory limits, pixel-size handling and references for pending output. Match retained SIXEL scaling to the shared image cell footprint and emit black definitions for undefined colour registers. Keep Kitty input, output, layers and placeholders. Adapt backend selection, flags, drawing and cleanup to the callbacks and Iscrl capability. Keep the pane-status repaint with the requested XXX comment. Replace the elaborate fallback with image_merge's implementation, removing its caches, sample structures, quadrant/sextant features and ACS additions. Keep the image_merge regressions and adapt the Kitty tests to the simpler fallback. Use skip status 101 and disable Python bytecode for image tests. Small changes still outside image_merge: - Guard zero-height synchronized redraws before bit_nset. - Select the image backend when the tty opens. - Enable imagescroll by default for Kitty and Ghostty. - Keep the explanatory manual-window pixel-size comment (comment only). - Keep the additional SIXEL fixtures and visual test tools. Validation: image-enabled and disabled builds; 31 image and 13 related regressions pass normally and under ASAN. All image tests skip without images. Focused palette, parser, scaling, transparency and Kitty layer tests also pass after the retained-output adjustments. Diff checks clean.
This commit is contained in:
@@ -1,39 +1,49 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Widening a pane restores clipped columns for every image placement.
|
||||
# Adapt the PR's many-placement recovery test to SIXEL: place images on
|
||||
# separate rows so they remain live, then recover every clipped column.
|
||||
|
||||
PATH=/bin:/usr/bin
|
||||
TERM=screen
|
||||
LC_ALL=C
|
||||
export TERM LC_ALL
|
||||
|
||||
export TERM
|
||||
[ -z "$TEST_TMUX" ] && TEST_TMUX=$(readlink -f ../tmux)
|
||||
TMUX="$TEST_TMUX -Limage-resize-outer$$ -f/dev/null"
|
||||
TMUX2="env -u TMUX LC_ALL=C $TEST_TMUX -Limage-resize-inner$$ -f/dev/null"
|
||||
TMP=$(mktemp)
|
||||
trap "$TMUX kill-server 2>/dev/null; $TMUX2 kill-server 2>/dev/null; rm -f $TMP" 0 1 15
|
||||
|
||||
# White placements stay behind the final red placement.
|
||||
# An 8:1 source fills 16 columns by one row without letterboxing.
|
||||
$TMUX2 new-session -d -x 8 -y 4 "
|
||||
i=0
|
||||
while [ \$i -lt 64 ]; do
|
||||
printf '\\033_Ga=T,q=2,C=1,f=32,s=8,v=1,c=16,r=1;//////////////////////////////////////////8=\\033\\\\'
|
||||
i=\$((i + 1))
|
||||
done
|
||||
printf '\\033_Ga=T,q=2,C=1,f=32,s=8,v=1,c=16,r=1;/wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP8=\\033\\\\'
|
||||
sleep 30" || exit 1
|
||||
[ "$($TMUX2 display-message -p '#{image_support}')" = 0 ] && exit 0
|
||||
$TMUX2 set -g status off || exit 1
|
||||
$TMUX new-session -d -x 8 -y 4 "$TMUX2 attach-session" || exit 1
|
||||
$TMUX set -g status off || exit 1
|
||||
sleep 1
|
||||
python3 -B - "$TEST_TMUX" <<'PY'
|
||||
import sys
|
||||
from image_test import image_test, sixel, check_image
|
||||
|
||||
$TMUX capture-pane -pS0 -E0 >$TMP || exit 1
|
||||
[ "$(cat $TMP)" = '........' ] || exit 1
|
||||
$TMUX resize-window -x 16 -y 4 || exit 1
|
||||
sleep 1
|
||||
$TMUX capture-pane -pS0 -E0 >$TMP || exit 1
|
||||
[ "$(cat $TMP)" = '................' ] || exit 1
|
||||
def check_rows(images, width):
|
||||
"""Each placement has two coloured halves; rows may use several rasters."""
|
||||
row = x = 0
|
||||
for image in images:
|
||||
assert row < 64 and x + image[0] <= width, (row, x, image[:2])
|
||||
expected = [rgb[(row + (xx >= 64)) % 3]
|
||||
for xx in range(x, x + image[0])]
|
||||
check_image(image, image[0], 1, expected)
|
||||
x += image[0]
|
||||
if x == width:
|
||||
row += 1
|
||||
x = 0
|
||||
assert (row, x) == (64, 0), (row, x)
|
||||
|
||||
exit 0
|
||||
|
||||
palette = [(100, 0, 0), (0, 100, 0), (0, 0, 100)]
|
||||
rgb = [(255, 0, 0), (0, 255, 0), (0, 0, 255)]
|
||||
with image_test(sys.argv[1], sx=8, sy=80) as test:
|
||||
client = test.attach()
|
||||
wire = b''
|
||||
for y in range(64):
|
||||
wire += ('\033[%d;1H' % (y + 1)).encode()
|
||||
wire += sixel(128, 1, palette,
|
||||
[y % 3] * 64 + [(y + 1) % 3] * 64)
|
||||
test.emit(wire)
|
||||
test.redraw()
|
||||
check_rows(client.images(), 64)
|
||||
|
||||
test.resize(client, 16, 80)
|
||||
test.redraw()
|
||||
check_rows(client.images(), 128)
|
||||
test.redraw()
|
||||
check_rows(client.images(), 128)
|
||||
|
||||
PY
|
||||
|
||||
Reference in New Issue
Block a user