Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Images/graphics are not cleared up inside tmux #2457

Closed
wookayin opened this issue Mar 21, 2020 · 7 comments
Closed

Images/graphics are not cleared up inside tmux #2457

wookayin opened this issue Mar 21, 2020 · 7 comments

Comments

@wookayin
Copy link

I know tmux is a big headache when it comes to implement features involving escaping sequence. Somehow I managed to prototype the image preview feature in tmux (#413) work on kitty, via tmux passthrough sequence. Yay!

image

However there is a problem with images: it does not get cleared up after <Ctrl-L> (clear).

The clear screen escape code (usually [2J) should also clear all images. This is so that the clear command works.

image

So it either stacks up:
image

or after reattach/deattach/split panes/or whenever re-rendering happens:

image

a black image hides everything.

It seems that there is something weird happening in dealing with clear sequence. Any ideas for workaround?

FYI, iTerm2 simply clears up all rendered images whenever the graphics gets out of the screen (e.g., scrolled up, detach, redraw, clear, etc.). Another workaround is to have a feature to manually clean up the rendered graphics (via mouse pop-up menu or some command lines).

@kovidgoyal
Copy link
Owner

clear clears all images. If it does not work with tmux that will be
because tmux is screwing things up, as usual. If you want to manually
clear images, use kitty + kitten icat --clear

@wookayin
Copy link
Author

wookayin commented Mar 22, 2020

I know. As I said, tmux is a big trouble. But why closing this issue? Could you please reopen it or discuss some workaround or about adding more batteries?

kitty +kitten icat --clear does not work inside tmux because the lack of TIOCGWINSZ support (#413). I think we can use other ways to get the screen size, e.g. stty size though. We should have at least some manual way --- either with mouse clicks or some command lines --- to clear up all graphics despite the tmux messup.

Anyway, what kitty +kitten icat --clear does is to emit the following control sequence:

\x1b_Ga=d,d=A\x1b\\

It has no effect inside tmux. Still the "ghost" graphics are not cleared up.

@kovidgoyal
Copy link
Owner

There's nothing I can do about issues tmux creates. If you wish to discuss workarounds for tmux, feel free to do so, but this is not a kitty issue. Using clear and icat --clear both work without tmux. That's more than enough ways to clear images, as provided by kitty.

@wookayin
Copy link
Author

tmux says that it is not a problem of theirs and so does kitty. But thanks for letting me know the clear sequence used in kitty. Although this is a tmux create, I think kitty is fully responsible of cleaning up all graphics garbages created by whatever reason.

So the following sequence -- must be wrapped by tmux passthrough sequence protocol -- works for clearing all graphics:

>>> sys.stdout.buffer.write(b'\033Ptmux;\033' + b'\033_Ga=d,d=A\033\033\\' + b'\033\\')

but only if the graphics are in display. In other words, in the presence of the "ghost" black graphics (where the actual images are gone) for some reason (e.g. deattach and reattach, or scroll a lot), the control sequence would not clear up them. I think this is just a small bug, but do you think it would be fixable?

@kovidgoyal
Copy link
Owner

kovidgoyal commented Mar 22, 2020 via email

@wookayin
Copy link
Author

wookayin commented Mar 22, 2020

Thanks Kovid. With due respect, I would say I don't think terminal multiplexer is a bad idea. But I understand why you believe so. This is beyond this issue's scope, so let's stop the argument here.

I tried the latest master as of 3/21 and yes, the bug is no more present (all graphics are cleared). Seems fixed in #2449. For the v0.16.0 release I can always confirm the bug exists, so we can say everything is okay from v0.17. Now I think I have all toolsets I needed. Thank you for your help again!

@AnonymouX47
Copy link
Contributor

AnonymouX47 commented Jul 8, 2022

@wookayin Display an image, then try scrolling in tmux and see what happens... or display an image with a height greater than the tmux pane's height.

My point is... it's mostly futile trying to make the graphics protocol work in tmux if its maintainers decide not to do something about it (which would actually be quite a hell of work for them).

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants