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:41:55 +0300 Message-ID: <837d2fgef0.fsf@gnu.org> References: <87v8pz18wf.fsf@mail.jao.io> <83o7vrgimc.fsf@gnu.org> <87fsh3yq81.fsf@mail.jao.io> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="26660"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Jose A Ortega Ruiz Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Sep 07 21:43:23 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 1oW0xG-0006oV-RE for ged-emacs-devel@m.gmane-mx.org; Wed, 07 Sep 2022 21:43:22 +0200 Original-Received: from localhost ([::1]:48860 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oW0xF-0004Q4-JX for ged-emacs-devel@m.gmane-mx.org; Wed, 07 Sep 2022 15:43:21 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:56728) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oW0w9-0003aW-EJ for emacs-devel@gnu.org; Wed, 07 Sep 2022 15:42:13 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:58862) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oW0w8-0007MK-Cq; Wed, 07 Sep 2022 15:42:12 -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=QS4z014PZzg1ylnqY5XzDCYxdwKsfwPldOq8HSJwJzg=; b=DBd9LeMfdrnU NswBgYapDgrvEMezodWWIfNwL8FDjVOSYANFBINuBIpIs+D/K/Tl61iPYXEjaJQzdDy/g/vbg9phL fugt0hCfTK4I9PTUtOO/b2JMDHPYm0FbSc53gHhpxe2a6kC4+dKZzTQ/S85u3GRxmR2NZGjlF3z3Y qwcExZ493i1zTqTM9+7Q+sUxKv/C+vz7y5syjoZbGALQoH2omNSH2LNHfMexzzCoQ+3dAAuOI9isf P227SDFCsP45lDg0dYmcjz0V8xJwVtFsNh7tV/Uqkt22TwsEMomZXp2auwoH+6Ug+dc5YNsseWHzF 5ZW2O9qYtC+jszqr2IbrLg==; Original-Received: from [87.69.77.57] (port=2115 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 1oW0w8-0005uJ-0h; Wed, 07 Sep 2022 15:42:12 -0400 In-Reply-To: <87fsh3yq81.fsf@mail.jao.io> (message from Jose A Ortega Ruiz on Wed, 07 Sep 2022 19:49:34 +0100) 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:294872 Archived-At: > From: Jose A Ortega Ruiz > Cc: emacs-devel@gnu.org > Date: Wed, 07 Sep 2022 19:49:34 +0100 > > > It's hard to tell, because you haven't described your ideas of > > implementing that. 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. > > Would it be possible to keep that model and only alter it when the > display actually draws the character in the underlying terminal? > > For an image-enhanced tty that'd mean that when we are going to write > this "single very large character" (whose data can be either an array of > bytes or simply a path in the filesystem, stored in an associated text > property perhaps) what we do is write a ESC character sequence starting > with _G, as the one shown above, and specifying not only the data to > draw, but also its size in rows and columns. Then, according to the > kitty API promises, the image will be rendered in that rectangle for us. This is a different level: the level of actually delivering the stuff to the glass. I think it's much easier than what was bothering me. I was talking about the level of layout: the one that knows how much space each "display element" (character, image, stretch of white space, etc.) takes on display. On TTY frames, there's a built-in assumption that every display element takes just one pixel in the vertical direction, and each screen line takes one pixel on display. That will have to change for image support, I presume. > I am assuming here that the display engine (for a tty) knows somehow > that it's printing a very lage "character" that is going to spawn > several rows and columns, and also that we can always tell how wide and > tall the window around point is when we display this "character". That's exactly the problem: it currently assumes that no display element takes more than one row, and that each row is exactly one pixel (= one character height) tall. > We > could then decide to tell kitty to either scale the image if it doesn't > fit or display only part of it. That's done by passing x,y,w,h in the > escape sequence instead or r,c... something like > > _Gf=100,t=f,x=0,y=0,w=100,h=20;\ I think that's the easy part.