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: Wed, 07 Sep 2022 22:51:49 +0300 Message-ID: <835yhzgdyi.fsf@gnu.org> References: <87v8pz18wf.fsf@mail.jao.io> <83o7vrgimc.fsf@gnu.org> <87wnafdnee.fsf@logand.com> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="36339"; 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 Wed Sep 07 21:53:22 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 1oW16v-0009J4-ST for ged-emacs-devel@m.gmane-mx.org; Wed, 07 Sep 2022 21:53:22 +0200 Original-Received: from localhost ([::1]:36118 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oW16u-0007hy-O7 for ged-emacs-devel@m.gmane-mx.org; Wed, 07 Sep 2022 15:53:20 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:37448) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oW15i-0006zC-PS for emacs-devel@gnu.org; Wed, 07 Sep 2022 15:52:09 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:58730) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oW15h-0000KZ-Om; Wed, 07 Sep 2022 15:52:05 -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=A1TyUAiSNS+9jC/5ICMcyjCbH2qzk/aOKobMzYT+QAU=; b=SujEHvO0t0vH OwDXN3NxNcO5yJv7JI3JO2qBDtKqyRZTYEWZw6NruMKEMuKFAEGGS8Nbja2WhO5VUujzQ0pNBIQew AuETbLXXRXVzcjNBatq7QOfxQ7CyFGUpUU9t/907ovEbSX3Jnf3pTHKjKtIvCUgpsiv6/SZJw7CN+ GtcZoEwh8yHFxDReQx9j6RlCXD2TXbYjm7LgoAI0CjPzVyFugP7mhNxF5bON9oRW7Ftf2o2uLc70R MaY1VD5qh2wyoEXFHPXnZTr6Z2GqF80SrYefpourxmBj676RX1VmooIVonTMTzOkv57J78QbwxZQe /pLiEWKJE63hPkgM+fZOLg==; Original-Received: from [87.69.77.57] (port=2715 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 1oW15g-0006mG-VS; Wed, 07 Sep 2022 15:52:05 -0400 In-Reply-To: <87wnafdnee.fsf@logand.com> (message from Tomas Hlavaty on Wed, 07 Sep 2022 20:56:09 +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:294874 Archived-At: > From: Tomas Hlavaty > Cc: emacs-devel@gnu.org > Date: Wed, 07 Sep 2022 20:56:09 +0200 > > On Wed 07 Sep 2022 at 21:11, Eli Zaretskii 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? Yes. That's the only kind of frame where we currently support images. > Is that not different in tty emacs? Not in principle, no. The only difference -- and that is important for this discussion -- is that on TTY frames we assume that all the screen lines have the same height. Which contradicts the basic requirement for displaying images. > I thought that the tty emacs has no concept of image (so far?). It indeed doesn't support image display, but the layout level, which is what I'm talking about, doesn't care _how_ to display stuff, it only cares about the dimensions on the screen. > 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 have no doubt that this is possible. We are not talking about how to display images on text-mode screens _in_principle_, we are talking about how to add that to the existing Emacs TTY display with minimum cost and complexity. > 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. The first part is the main problem to solve. Currently, TTY display cannot do that, it's outside its basic design, which assumes that each screen line has the same height, no display element can be split between screen lines (the latter design assumption is common to the GUI display). > 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. > > Second, tty emacs would need to somehow reserve rectangle for the image. > This might be lots of work I guess. > > 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. In case of Linux > console, the image path and coordinates would be sent to an external > program like w3mimgdisplay. The second part is the problem I'm talking about. The other two are much simpler to add, I think.