Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

icat without TIOCGWINSZ ioctl #413

Closed
Adryd opened this issue Mar 21, 2018 · 17 comments
Closed

icat without TIOCGWINSZ ioctl #413

Adryd opened this issue Mar 21, 2018 · 17 comments

Comments

@Adryd
Copy link

Adryd commented Mar 21, 2018

A possible solution to making icat work without exact pixel size would be to find the width and height of the block in pixels and multiplying rows by width and columns by height. this would allow for icat to work within tmux.

@kovidgoyal
Copy link
Owner

kovidgoyal commented Mar 21, 2018

As far as I know, there is no reason why tmux should not be able to pass on pixel sizes via TIOCGWINSZ, all it has to do is get the size from the parent terminal, calculate the size of a block, do the multiplication to get the window size in pixels for each window it is displaying and set the pixel sizes when it is calling TIOCSWINSZ. That is does not do so is a bug in tmux.

While I can certainly add escape codes to the graphics protocol to query block sizes, doing so is unnecessarily slow compared to using the IOCTL and also leads to code duplication/complication just to work around a bug in other software.

@rodrijuarez
Copy link

@kovidgoyal Given that in the tmux repo this issue was closed, is kitty going to change the approach taken? Given that this looks like an issue that will go back and forth between tmux and kitty otherwise

@kovidgoyal
Copy link
Owner

Nope, tmux has said it does not want to support the display of images. I am not going to complicate kitty's code to try to work around that. Indeed, one of my goals with kitty is to remove the need for hacks like terminal multiplexers completely, as they just act as a drag on the entire terminal ecosystem, and waste CPU cycles. Every byte between the application and the terminal emulator has to be parsed by an extra multiplexer middleman. And every new feature a terminal tries to implement now has to be implemented in multiple places.

kitty is already pretty close to the goal of completely replacing a terminal multiplexer, the only missing piece is #391. Someday if I get annoyed enough, I might just implement it.

@kutsan
Copy link

kutsan commented Jul 19, 2018

@kovidgoyal Although you don't have any plans on that topic and although this is a tmux-wise problem, I still suggest you to implement a workaround. I don't think kitty's tab/window system is featureful enough to replace with tmux, so we can't just get rid off tmux completely at this stage.

@kovidgoyal
Copy link
Owner

As far as I know kitty's tab/window system is a strict superset of tmux's. If there is some feature you are missing, feel free to request it. I am much more likely to implement that.

@kovidgoyal
Copy link
Owner

kovidgoyal commented Jul 20, 2018

Oh and I should note simply working around tmux's stubbornness for the TIOCGWINSZ issue wont make it magically support images. There will still be lots of other problems when using multiple windows in tmux. This is because images have to be placed, just like the cursor. tmux has to intercept and rewrite cursor positioning escape codes to implement windows, it would have to do the same for image escape codes. And its devs have said they dont want to do that. Unlike TIOCGWINSZ, that is not an issue that can be worked around in kitty.

@rosshadden
Copy link

@kovidgoyal I don't understand what you mean by it not being a problem that can be worked around in kitty. I use termite and images render perfectly well through tmux. For example in my file browser ranger I see image previews. This is probably the last feature that keeps me from switching to Kitty, and I'm curious why it's such a big deal for Kitty to do what other terminals seem to do. Is it just a lot of work? If so maybe I can work on it.

@kovidgoyal
Copy link
Owner

Image display works via a protocol https://sw.kovidgoyal.net/kitty/graphics-protocol.html this protocol specifies where and how to display images inside terminal windows. tmux splits up terminal windows into multiple panels. Therefore it will need to intercept and re-write those escape codes to move the images around, at a minimum. Just like is to does for escape codes that position the cursor. tmux developers have said they dont want to do that.

Once again, terminal multiplexers are an awful idea.

@rosshadden
Copy link

rosshadden commented Mar 10, 2019

I'm saying displaying images works as expected in other terminals, even in tmux sessions. It has worked for me in termite, urxvt, terminator, terminology, and xterm, all while within tmux sessions.

I guess I just don't understand why it's something you are against supporting but many other terminal developers are fine with it.

@kovidgoyal
Copy link
Owner

Sigh. Feel free to come up with a patch that makes images magically work
in tmux. I obviously have no idea what I am talking about.

Just FYI, ranger on those terminals bypasses the terminal and displays
images by showing the image in an overlaid X11 window. Which is an awful
hack that relies on the insecure nature of X11. Google w3m-img mode for
more information.

@rosshadden
Copy link

My apologios @kovidgoyal, ranger actually does render images inside tmux while using Kitty. My issue ended up being a non-issue, and just something I had going on in my environment at the time. Thanks for all of your great work on this incredible project.

@ywpkwon
Copy link

ywpkwon commented Feb 21, 2020

Hi, @kovidgoyal, have you made ranger render images inside tmux while using KItty? May I ask what was the key?
image
I was about to give up since image preview works well on Kitty without tmux. However, I am curious how you solve this and I hope I could do so if possible.

@kovidgoyal
Copy link
Owner

I dont solve it and no it is not possible as long as tmux does not add
support for the image protocol.

@ywpkwon
Copy link

ywpkwon commented Feb 21, 2020

I dont solve it and no it is not possible as long as tmux does not add
support for the image protocol.

Ah! Sorry. (+ Thanks for the incredible terminal) I was going to ask to @rodrijuarez, but confused. @rodrijuarez Could you answer my question above?

@dankamongmen
Copy link
Contributor

dankamongmen commented Jul 6, 2021

for what it's worth, TIOCGWINSZ seems to be properly filled in by my tmux 3.1c as packaged in Debian Unstable (released 2020-10-30). kitty escapes still seem to be consumed, though, so it won't do you much good.

@kovidgoyal
Copy link
Owner

Once could get hacky single window support for images by using tmux's passthrough escape codes wookayin/python-imgcat#4 but it will ofcourse fil if using more than single tmux window.

@AnonymouX47
Copy link
Contributor

AnonymouX47 commented Jul 8, 2022

Even with the passthrough... the following still won't work:

  • image scrolling
  • row and column positions for deletion

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

No branches or pull requests

8 participants