emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Implementing image support for kitty terminal


From: Jose A Ortega Ruiz
Subject: Re: Implementing image support for kitty terminal
Date: Wed, 07 Sep 2022 20:59:55 +0100

On Wed, Sep 07 2022, Tomas Hlavaty wrote:

> On Wed 07 Sep 2022 at 21:11, Eli Zaretskii <eliz@gnu.org> wrote:
>> In particular, the current model of image display
>> in the Emacs display engine is that an image is basically considered a
>> single very large character, from the screen layout POV.
>
> Are you talking about GUI emacs?
> Is that not different in tty emacs?
> I thought that the tty emacs has no concept of image (so far?).
>
>> I guess
>> that's not what you have in mind for the above, so IMO it's important
>> to come up with an alternative model that would somehow fit with the
>> current display code with only minor changes, if we want this not to
>> be too complex.
>
> For example, the tty based w3m web browser optionally supports images.
> It reserves space w*h chars on the tty and then uses external program
> to draw the image in the right place.
>
> I guess tty emacs would also need to reserve a w*h chars rectangle on
> the tty and then send the right escape code to fill that gap with the
> image.
>
> First, tty emacs would need to understand images instead of throwing
> error.  At least their dimensions.  Maybe using some library or even in
> elisp, for example like this
> https://logand.com/sw/emacs-framebuffer/file/emacs-framebuffer.el.html#l286
> I have not figured out, how to actually plug it into upstream emacs, as
> this seems to require a lot of changes to C code.

fwiw, in the kitty case, image libraries are going to be almost for sure
available, it being an x11/wayland application.  so an emacs compiled
with image support (but not necessarily linking against any x libs)
doesn't seem like a strong requirement.  in that scenario, determining
the size of an image wouldn't needed a lot of C code, would it? and, if
those libraries are not available, a call to "file foo.png" is (at least
in my system) telling me the size of foo.png... kind of hacky, of
course, but as a first step maybe good enough.

> Second, tty emacs would need to somehow reserve rectangle for the image.
> This might be lots of work I guess.

i was hoping this wouldn't be the case... at least when running inside
terminal emulators, emacs nox seems pretty dexterous lying out windows
and filly them with content, and i reckoned it must have a pretty good
idea of their sizes.  but maybe i'm too optimistic :)

> Third, there would have to be a piece of code which actually draws the
> image.  In case of kitty terminal, the image path and coordinates would
> be sent to the tty using the kitty terminal protocol.

(as an aside, this would also work for other terminals like konsole or
wayst, which support the protocol).

cheers,
jao
-- 
If we all think alike then nobody’s thinking at all.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]