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: Eli Zaretskii
Subject: Re: Implementing image support for kitty terminal
Date: Fri, 09 Sep 2022 08:43:45 +0300

> From: Tomas Hlavaty <tom@logand.com>
> Cc: jao@gnu.org, emacs-devel@gnu.org
> Date: Thu, 08 Sep 2022 22:03:41 +0200
> 
> On Thu 08 Sep 2022 at 22:30, Eli Zaretskii <eliz@gnu.org> wrote:
> >> From: Tomas Hlavaty <tom@logand.com>
> >> Cc: emacs-devel@gnu.org
> >> Date: Thu, 08 Sep 2022 21:15:37 +0200
> >> 
> >> The problem is, that that capability is not available in tty emacs:
> >
> > Yes, it _is_ available.  We just suppress it.
> 
> Interesting, is it possible to somehow "un-suppress" it?

Yes, by changing the C code not to do that.

> >>    (image-size (create-image "/tmp/a.jpg"))
> >>    => (error "Window system frame should be used")
> >
> > This is us deliberately failing image-size early on, because we don't
> > want complications down the road, and because we know images cannot be
> > displayed on TTY frames.
> 
> I am asking emacs to tell me the size of the image.
> I am not asking emacs to display it.

But the code involved reuses some subroutines that are used for
display as well, and those signal an error.

It is never a problem with the current code because only GUI frames
can display images.  To get TTY frames be capable of some of that
functionality, we need changes on the C level (and perhaps also in
Lisp), but those changes are rather mechanical -- find out which code
signals the error and modify it to do that on some new condition, or
not at all.

> >> Would it be possible to fix that?
> >
> > I don't see why it would be hard.  E.g., this works just fine in a -nw
> > session:
> >
> >   (create-image "/tmp/a.jpg")
> 
> Why does create-image work and image-size does not?

See above.

> Also this returns:
> 
>    (image :type jpeg :file "/tmp/a.jpg" :scale 1 :transform-smoothing t)
> 
> which does not tell me image width and height that I'd like to know.

Of course.  create-image isn't supposed to return the size.  It was
just an example to show to you that some image-related functionality
does work on TTY frames; I didn't say that create-image is enough to
get the size.

> > Emacs already knows how to compute the size of an image.
> 
> So how do I get the size of an image?
> 
> My tty emacs does not know that, I get this error:
> 
>    (image-size (create-image "/tmp/a.jpg"))
>    => (error "Window system frame should be used")

See above.

> Maybe tty emacs already knows how to compute the size of an image, but I
> have not figured a way of asking my tty emacs to share that information
> with me.  Is there a way?

See above: you need changes on the C level.



reply via email to

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