Commit Graph

12110 Commits

Author SHA1 Message Date
Michael Grant
047308b156 image: retain ordered placements in the grid
Replace the per-cell image marker with sparse placement spans attached to
grid lines. A placement owns all of its spans and records the input
protocol, application image and placement IDs, z-index, and creation order.

This retains overlapping image layers without storing a list in every grid
cell. Grid operations move, split, clip, and remove only the affected spans.

Use the input protocol to determine image/text interaction: later text
damages SIXEL spans, while Kitty placements remain and are ordered by their
z-index. Rendering then adapts that one logical scene for each client,
rather than changing its semantics according to whether the outer terminal
uses Kitty or SIXEL.
2026-08-25 11:23:52 +01:00
Michael Grant
cf80845be7 Change some names of things for clarity. 2026-08-25 11:23:52 +01:00
Michael Grant
b6dbf10057 Redraw SIXEL images before or after text depending on which was placed first in the cell. 2026-08-25 11:23:52 +01:00
Michael Grant
54d3f77c2c The implementation now distinguishes a newly placed image cell from one later overwritten by text. On a SIXEL terminal, damaged cells are omitted from image output; on Kitty they remain ordinary positional placements. 2026-08-25 11:22:26 +01:00
Michael Grant
ed63826b15 Cleanup. 2026-08-25 11:22:26 +01:00
Michael Grant
b89f8b0624 Update Kitty image names 2026-08-25 11:22:26 +01:00
Michael Grant
c1cab6ea34 More cleanup of "histogram" name. 2026-08-25 11:22:26 +01:00
Michael Grant
89a7dcc8ab Shorten image and SIXEL names 2026-08-25 11:22:26 +01:00
Michael Grant
48b6641d97 Avoid overflow in image cell size calculation 2026-08-25 11:22:26 +01:00
Michael Grant
37b71800b5 Move image cell drawing into image.c 2026-08-25 11:22:26 +01:00
Michael Grant
5c9ae058bf Expose image backend flags 2026-08-25 11:22:26 +01:00
Michael Grant
db7ec915ea Do not enable sync for SIXEL 2026-08-25 11:22:26 +01:00
Michael Grant
04644c7267 Comment sixel_from_image(). 2026-08-25 11:22:26 +01:00
Michael Grant
d53f8eff9e Add comments to image functions 2026-08-25 11:22:26 +01:00
Michael Grant
03efb5e293 Preserve text behind transparent Kitty images. 2026-08-25 11:22:26 +01:00
Michael Grant
2603f84b0a Revert "Clear text beneath SIXEL image placements."
This reverts commit 64cea48f91.
2026-08-25 11:22:26 +01:00
Michael Grant
e5bcf59768 Clear text beneath SIXEL image placements. 2026-08-25 11:22:26 +01:00
Michael Grant
69ee9cf7f4 Ordinary text writes replaced the entire grid cell, dropping GRID_FLAG_IMAGE and releasing the
mage reference. Deferred pane redraws explain the intermittent “image never appears” behavior.

Fixed:
  - Preserves image metadata while updating the text underlay in the collected ASCII path: grid.c:779
  - Handles the single-cell/non-ASCII path and schedules an image redraw: screen-write.c:2631
  - Uses the requested if/else for new_id.
  - Adds a deterministic regression reproducing point (2): regress/image-support.sh:240

  This matches Kitty’s requirement that normal text operations must not affect graphics; graphics require
  explicit deletion. Kitty graphics protocol
2026-08-25 11:22:26 +01:00
Michael Grant
ae0fa8068c Preserve Kitty image crop width after cell rounding. 2026-08-25 11:22:26 +01:00
Michael Grant
3442c1f26f Fix underlay bookkeeping bug. 2026-08-25 11:22:26 +01:00
Michael Grant
b6c709307e Dither alpha in SIXEL output 2026-08-25 11:22:26 +01:00
Michael Grant
002d38cb6b Revert "Clear text beneath graphical images"
This reverts commit fb589fd9f9.
2026-08-25 11:22:26 +01:00
Michael Grant
fb931f1676 Use compact image references in grid cells 2026-08-25 11:22:26 +01:00
Michael Grant
ba2dc2cfb6 Clear text beneath graphical images 2026-08-25 11:22:26 +01:00
Michael Grant
628acfd802 Pass through wrapped Kitty graphics 2026-08-25 11:22:26 +01:00
Michael Grant
95b6adbd61 Simplify image support terminology 2026-08-25 11:22:26 +01:00
Michael Grant
0b2739c62c Use one image support switch 2026-08-25 11:22:26 +01:00
Michael Grant
596de59d11 Make image types opaque 2026-08-25 11:22:26 +01:00
Michael Grant
7d2d187db4 Inline basic image fallback renderer 2026-08-25 11:22:26 +01:00
Michael Grant
674cdd94f5 Add bptato's test to the regression test script. 2026-08-25 11:22:26 +01:00
Michael Grant
75b606c3df The two Chawan symptoms now have matching fixes:
- Layout corruption: C=1 is respected.
  - Lingering remnants: tmux now tracks Kitty’s (image ID, placement ID) identity, replaces moved placements, and honors
    placement-specific d=i,...,p=... deletion.
2026-08-25 11:22:26 +01:00
Michael Grant
d674f34f25 Support Kitty Unicode placeholder image transmission
- Parse Kitty graphics commands wrapped in tmux passthrough sequences.
  - Accept unpadded base64 payloads emitted by icat.
  - Handle chunked transfers whose final chunk omits m.
  - Track virtual image placements.
  - Convert Unicode placeholders into shared image cells for Kitty and SIXEL clients.
  - Add regression coverage for wrapped, chunked, unpadded input.
2026-08-25 11:22:26 +01:00
Michael Grant
8b44703b41 Fix SIXEL median-cut palette generation 2026-08-25 11:22:26 +01:00
Michael Grant
c0ab9b7b3f Revert "Removed unconditional Floyd–Steinberg dithering from image-sixel.c:1077. Kitty images now use the adaptive 256-colour median-cut palette with direct nearest-colour mapping."
This reverts commit ab591ae430.
2026-08-25 11:22:26 +01:00
Michael Grant
f81c41929b Fix kitty image resize issue when the kitty image resized smaller than the image, the image was overflowing lines and banding. 2026-08-25 11:22:26 +01:00
Michael Grant
cc4a76d0be Removed unconditional Floyd–Steinberg dithering from image-sixel.c:1077. Kitty images now use the adaptive 256-colour median-cut palette with direct nearest-colour mapping. 2026-08-25 11:22:26 +01:00
Michael Grant
52e2e2b0c0 C=1 is parsed and stored as an image-placement flag, suppressing cursor movement and scrolling as required by the Kitty protocol. 2026-08-25 11:22:26 +01:00
Michael Grant
e602dfa771 Keep SIXEL palettes across redraw spans 2026-08-25 11:22:26 +01:00
Michael Grant
5fc24e373a Rename image damage functions to redraw 2026-08-25 11:22:26 +01:00
Michael Grant
a4d6004d40 Correct image copyrights 2026-08-25 11:22:26 +01:00
Michael Grant
260cde9f48 Remove obsolete Kitty diacritics comment 2026-08-25 11:22:26 +01:00
Michael Grant
c8fe307682 Support Kitty source rectangle placements 2026-08-25 11:22:26 +01:00
Michael Grant
2c7a5f73c4 Improve SIXEL colour quantization
Build an adaptive 256-colour palette with median cut instead of using a fixed colour cube. Apply Floyd-Steinberg error diffusion while mapping pixels to reduce banding and preserve image detail.
2026-08-25 11:22:26 +01:00
Michael Grant
643bb662a0 Preserve SIXEL pixel dimensions
Retain the padded canonical pixel canvas separately from the image content. Scale only the populated portion of partial edge cells so an image keeps its exact raster size on the originating terminal while retaining its cell footprint.
2026-08-25 11:22:26 +01:00
Michael Grant
9731adb300 Correct SIXEL HLS colour conversion
Use the DEC hue origin and channel order, and round percentage and HLS conversions to the nearest byte value.
2026-08-25 11:22:26 +01:00
Michael Grant
52863f0fe9 Redraw images after pixel geometry changes
A resize may temporarily leave the terminal cell pixel dimensions unknown while tmux queries the terminal. Schedule another client redraw when the pixel geometry response arrives so the graphical backend replaces the temporary text fallback.
2026-08-25 11:22:26 +01:00
Michael Grant
4e7f3d5520 Use sixel images for WezTerm
Enable the sixel feature when WezTerm is detected and clarify that the kitty terminal feature requires Unicode placeholder support rather than only the basic graphics protocol.
2026-08-25 11:22:26 +01:00
Michael Grant
4e379f38d6 Remove local image ASCII test tool references 2026-08-25 11:22:26 +01:00
Michael Grant
d8da527882 Refactor to centralize image-specific rendering and lifecycle code in image.c and the image-* backends. 2026-08-25 11:22:26 +01:00
Michael Grant
5432f2ef0a Add tool to generate the kitty diacritics directly from the public UnicodeData.txt file. 2026-08-25 11:22:26 +01:00