From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: Implementing image support for kitty terminal Date: Fri, 09 Sep 2022 08:43:45 +0300 Message-ID: <835yhxdrvy.fsf@gnu.org> References: <87v8pz18wf.fsf@mail.jao.io> <83o7vrgimc.fsf@gnu.org> <87wnafdnee.fsf@logand.com> <87a67bymys.fsf@mail.jao.io> <87h71hekyu.fsf@logand.com> <837d2dekao.fsf@gnu.org> <875yhxeiqq.fsf@logand.com> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="4142"; mail-complaints-to="usenet@ciao.gmane.io" Cc: jao@gnu.org, emacs-devel@gnu.org To: Tomas Hlavaty Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Sep 09 07:46:49 2022 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oWWqm-0000vm-UG for ged-emacs-devel@m.gmane-mx.org; Fri, 09 Sep 2022 07:46:49 +0200 Original-Received: from localhost ([::1]:40384 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oWWql-0003FL-GS for ged-emacs-devel@m.gmane-mx.org; Fri, 09 Sep 2022 01:46:47 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:49722) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oWWo5-0002QL-C7 for emacs-devel@gnu.org; Fri, 09 Sep 2022 01:44:02 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:54160) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oWWo3-0006W7-8a; Fri, 09 Sep 2022 01:44:00 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=mzAZxO/iEWbMB/kcgA0aKNOenspl/aKlStpsicTcV0s=; b=d9lOtgVenUnL SNNBcxXGJgWkoK3jrR5o7vwLJP/698AZbXas9IdjhVHIpFrO76TqycoDBWkKeg1spcVvYG5CJMo7g HFDWmnjENHfviFpjLUDg2R/fZ9OnLiyw8Q754PxNLZhOkWlsJKLBh14mer0yqquhjBuJ1pNAjM/+T 3EHZT0zbu+xVLF5xuV58jUAMvcURc0aPAxhINat3U5xsTUBV7TdueHVTWE/l647/WkcvltvExVkF2 U6VgxYSh3mz8epxSuaW0Myqac7l4+tprUD6JIc3W+qIBaqGj64Z6r4CxfRXN4adFh40/3UeaayKXu FpKgCvrqCtF4jCtfiU9uyA==; Original-Received: from [87.69.77.57] (port=3713 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oWWo1-0006zU-S0; Fri, 09 Sep 2022 01:43:58 -0400 In-Reply-To: <875yhxeiqq.fsf@logand.com> (message from Tomas Hlavaty on Thu, 08 Sep 2022 22:03:41 +0200) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:295032 Archived-At: > From: Tomas Hlavaty > 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 wrote: > >> From: Tomas Hlavaty > >> 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.