From 72ce9ea06b64551f3a99147695c29631022ded8f Mon Sep 17 00:00:00 2001 From: cashmere Date: Sun, 26 Apr 2026 20:41:21 +0200 Subject: fix(sixel): detect Windows Terminal and route GIFs through image pipeline Windows Terminal does not expose a stable `TERM' value, so the previous sixel-detect check missed it. Accept the `WT_SESSION', `WT_PROFILE_ID' and `WT_WINDOWID' environment markers it injects into every session. Also add `gif' to `kitty-gfx--image-file-p' so GIF files are routed through the image pipeline. Animation is still not supported -- only the first frame is rendered -- but that is better than dropping them on the floor. AGENTS.md: list Windows Terminal under supported sixel terminals and soften the GIF wording from "not supported" to "first frame only". Closes #6. Co-authored-by: Tim Felgentreff --- kitty-graphics.el | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'kitty-graphics.el') diff --git a/kitty-graphics.el b/kitty-graphics.el index adfe6b7..430818a 100644 --- a/kitty-graphics.el +++ b/kitty-graphics.el @@ -642,17 +642,24 @@ Sixel because they drop the DCS payload." (in-tmux (getenv "TMUX")) (tmux-ver (and in-tmux (kitty-gfx--tmux-version))) (tmux-ok (kitty-gfx--tmux-sixel-supported-p)) + ;; Windows Terminal's TERM value is not stable enough to rely on + ;; alone, so accept its session markers when present. + (windows-terminal (or (getenv "WT_SESSION") + (getenv "WT_PROFILE_ID") + (getenv "WT_WINDOWID"))) (supported (and term (or (not in-tmux) tmux-ok) (or (string-match-p "xterm\\|vt[0-9]\\|foot\\|contour" term) (member term-prog '("foot" "Konsole" "mintty" "mlterm" - "contour" "WezTerm"))) + "contour" "WezTerm")) + windows-terminal) t))) (kitty-gfx--log - "sixel-detect: %s (TERM=%s TERM_PROGRAM=%s TMUX=%s tmux-ver=%s tmux-ok=%s)" + "sixel-detect: %s (TERM=%s TERM_PROGRAM=%s TMUX=%s tmux-ver=%s tmux-ok=%s WT=%s)" supported term term-prog (if in-tmux "yes" "no") (if tmux-ver (format "%d.%d" (car tmux-ver) (cadr tmux-ver)) "n/a") - (if tmux-ok "yes" "no")) + (if tmux-ok "yes" "no") + (if windows-terminal "yes" "no")) supported)) (defun kitty-gfx--sixel-cache-path (file cols rows) @@ -2289,11 +2296,13 @@ then let the refresh cycle re-emit the visible ones." (kitty-gfx--schedule-refresh))) (defun kitty-gfx--image-file-p (file) - "Return non-nil if FILE has an image extension." + "Return non-nil if FILE has an image extension. +GIF files are detected so they get routed through the image pipeline, +but only the first frame is rendered (no animation in terminal)." (let ((ext (file-name-extension file))) (and ext (member (downcase ext) '("png" "jpg" "jpeg" "bmp" "svg" - "webp" "tiff" "tif"))))) + "webp" "tiff" "tif" "gif"))))) (defun kitty-gfx--org-display-inline-images-tty (&optional _include-linked beg end) "Display inline images in org buffer via Kitty graphics. -- cgit v1.3.1