Skip to content

preview-tui: clear sixel graphics when switching previews - #2152

Draft
JWWTSL wants to merge 1 commit into
jarun:masterfrom
JWWTSL:fix/issue-2134-preview-tui-sixel-clear
Draft

preview-tui: clear sixel graphics when switching previews#2152
JWWTSL wants to merge 1 commit into
jarun:masterfrom
JWWTSL:fix/issue-2134-preview-tui-sixel-clear

Conversation

@JWWTSL

@JWWTSL JWWTSL commented Jul 30, 2026

Copy link
Copy Markdown

Summary

  • Clear sixel graphics layer when switching between file previews in preview-tui, fixing the issue where img2sixel/chafa/timg previews stack on top of each other in tmux

Changes

File Change
plugins/preview-tui Added DECSDM reset (\033[?8015l/\033[?8015h) in preview_fifo() and winch_handler() to clear sixel graphics before rendering new previews

Root Cause

The existing cleanup in preview_fifo() handles kitty icat (kitty +kitten icat --clear) and ueberzug (ueberzug_remove), but has no equivalent for sixel-based image previewers. The terminal clear command only clears the text layer, leaving sixel graphics from the previous preview visible.

This follows the same pattern established in PR #2116 which added kitty graphics cleanup.

Test Plan

  • shellcheck passes on modified plugin
  • Manual: set NNN_PREVIEWIMGPROG=img2sixel, open nnn with preview-tui in tmux, navigate between image files and verify previous preview is cleared
  • Manual: same test with chafa as previewer
  • Manual: verify non-sixel previewers (kitty icat, ueberzug) are unaffected

Fixes #2134

When using sixel-based image previewers (img2sixel, chafa, timg),
switching between files causes previews to stack on top of each
other because the terminal clear command only clears the text
layer, not the sixel graphics layer.

Send DECSDM reset (\033[?8015l) followed by re-enable (\033[?8015h)
to clear sixel graphics before rendering a new preview, matching
the existing cleanup pattern for kitty icat and ueberzug.

Fixes jarun#2134
@jarun

jarun commented Jul 30, 2026

Copy link
Copy Markdown
Owner

Why is this in draft state?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[img2sixel/chafa] Preview-tui does not clear output before display

2 participants