kovidgoyal / kitty

Cross-platform, fast, feature-rich, GPU based terminal
https://sw.kovidgoyal.net/kitty/
GNU General Public License v3.0
23.74k stars 958 forks source link

icat without TIOCGWINSZ ioctl #413

Closed Adryd closed 6 years ago

Adryd commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

@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 commented 6 years ago

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 commented 6 years ago

@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 commented 6 years ago

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 commented 6 years ago

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 commented 5 years ago

@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 commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

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 commented 4 years ago

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 commented 4 years ago

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

ywpkwon commented 4 years ago

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 commented 3 years ago

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 commented 3 years ago

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

AnonymouX47 commented 2 years ago

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