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.bugs Subject: bug#57607: Feature request: Use the character cell on bottom-right corner of a terminal Date: Tue, 04 Oct 2022 11:07:48 +0300 Message-ID: <83a66cvwob.fsf@gnu.org> References: <87wnakl5md.fsf@disroot.org> <87o7vt3s58.fsf@disroot.org> <87ilm04xzl.fsf@disroot.org> <875yi0v8r6.fsf@disroot.org> <874jxjhz9l.fsf@disroot.org> <87tu5i9kbg.fsf@disroot.org> <87r0zpi9za.fsf@disroot.org> <83y1twwv7w.fsf@gnu.org> <87edvohx2s.fsf@disroot.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="5219"; mail-complaints-to="usenet@ciao.gmane.io" Cc: gerd.moellmann@gmail.com, 57607@debbugs.gnu.org To: Akib Azmain Turja Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Oct 04 10:48:27 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1ofdbH-0001Gj-Mq for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 04 Oct 2022 10:48:27 +0200 Original-Received: from localhost ([::1]:56914 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ofdbG-0004Mr-LJ for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 04 Oct 2022 04:48:26 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:59054) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ofcyA-00089B-Uy for bug-gnu-emacs@gnu.org; Tue, 04 Oct 2022 04:08:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:53291) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ofcyA-00069M-L1 for bug-gnu-emacs@gnu.org; Tue, 04 Oct 2022 04:08:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ofcyA-0005p6-Fr for bug-gnu-emacs@gnu.org; Tue, 04 Oct 2022 04:08:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 04 Oct 2022 08:08:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 57607 X-GNU-PR-Package: emacs Original-Received: via spool by 57607-submit@debbugs.gnu.org id=B57607.166487088022376 (code B ref 57607); Tue, 04 Oct 2022 08:08:02 +0000 Original-Received: (at 57607) by debbugs.gnu.org; 4 Oct 2022 08:08:00 +0000 Original-Received: from localhost ([127.0.0.1]:52369 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ofcy7-0005oq-V5 for submit@debbugs.gnu.org; Tue, 04 Oct 2022 04:08:00 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:45678) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ofcy6-0005od-QY for 57607@debbugs.gnu.org; Tue, 04 Oct 2022 04:07:59 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:40374) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ofcy1-000692-IA; Tue, 04 Oct 2022 04:07:53 -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=Yij1z8lYqDxuHGvy6OAkoOoVDZ1TJaNt3Xz1Oj1zAW8=; b=pMnPsXvo3LsD jP8BOySQzIiykmuGRQaafcZOzRDj8gY4i8kFujfHy6ePIGG4ZKGiNjUY2CE09pc5ap6iXCdBThRV/ 5xbas3jgRzLWxENmJcDeFWR6wR5xJdEnumuQuvYOxwaL+929PG+Kfw7gl3kf7fDPEqNUNNfF6/Yul 22xalRGF5LpZ4Oe5zhdHnLisuz5A4YRjPhdTokp+s+tjZDtP5E5xKf4qYHajav3YvnVFO1/fdON3a U1oefdk3TYrZjRrMXZfOJF++r3Jg+qevIy7fx15enOxxuri9etdBeqFtaxy3eKIjE6e1u7YcayRkG 8xlVMvbyUIo2D+27dKxNRw==; Original-Received: from [87.69.77.57] (port=3719 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 1ofcy1-0004kD-1n; Tue, 04 Oct 2022 04:07:53 -0400 In-Reply-To: <87edvohx2s.fsf@disroot.org> (message from Akib Azmain Turja on Tue, 04 Oct 2022 13:22:51 +0600) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:244376 Archived-At: > From: Akib Azmain Turja > Cc: 57607@debbugs.gnu.org, gerd.moellmann@gmail.com > Date: Tue, 04 Oct 2022 13:22:51 +0600 > > > Thanks. But could you please describe the idea of the patch in some > > comment? It is hard to follow the code, especially since the diff has > > many pure whitespace changes. > > The idea is that you write the string just like before (for example, you > want to write "hello" in a five columns width terminal, so you write > only "hell", so that the line shows "hell "), then move a character > backward and write the last glyph (write "o", so that the line shows > "helo "), move a character backward again and arrange that after writing > the next glyph, the character on the current position will be pushed > towards right and write the glyph before the last one (write "l", now > the line shows "hello"). > > Should I add the explanation to the function as comment? Yes, please. It would also help if the respective parts of the code were annotated with comments that explain their role in the algorithm. > > Also, this: > > > >> + /* Go to the previous position. */ > >> + cmgoto (tty, curY (tty), curX (tty) - 1); > >> + cmplus (tty, 1); > > > > Seem to assume the last character takes just one column? What about > > characters whose width is 2 columns? > > Yes, I assume that. I don't think any multi-char width glyph reach this > function (I think they are converted to single column width glyphs, for > example "^L" is converted to "^" and "L"). The reason of the assumption > is the following code: > > --8<---------------cut here---------------start------------->8--- > if (AutoWrap (tty) > && curY (tty) + 1 == FRAME_TOTAL_LINES (f) > && (curX (tty) + len) == FRAME_COLS (f)) > len --; > --8<---------------cut here---------------end--------------->8--- > > Which also assumes the same. Please try with some 2-column CJK characters, I'm not sure the example with ^L is relevant here. You can find the list of wide characters in characters.el (search for "width"); for example, characters in the U+FF00 block can be useful. (And the existing code could have bugs, no need to assume it is always correct.) > > And finally, it would be nice to avoid so much code duplication > > between tty_write_glyphs and tty_write_glyphs_with_face. Is that > > feasible? > > Yes, I think so. I think it possible to just add a new argument > "face_id" to tty_write_glyphs would the trick. tty_write_glyph will try > to use "face_id" if it is specified, otherwise fallback to the face_id > in the string. But how to "not" specify a face_id? Would a NULL work? face_id is an integer, and zero is a valid value (it means the default face), so NULL won't do. But you can use -1 to mean "no face ID". Just make sure you never pass it to FACE_FROM_ID etc. Thanks.