From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Akib Azmain Turja via "Bug reports for GNU Emacs, the Swiss army knife of text editors" 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 18:00:57 +0600 Message-ID: <87lepver2e.fsf@disroot.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> <83a66cvwob.fsf@gnu.org> Reply-To: Akib Azmain Turja Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="39886"; mail-complaints-to="usenet@ciao.gmane.io" Cc: gerd.moellmann@gmail.com, 57607@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Oct 04 14:07:10 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 1ofghZ-000ACV-Lo for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 04 Oct 2022 14:07:09 +0200 Original-Received: from localhost ([::1]:40668 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ofghY-0007OR-3Y for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 04 Oct 2022 08:07:08 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:45382) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ofgfZ-0006ZJ-Fh for bug-gnu-emacs@gnu.org; Tue, 04 Oct 2022 08:05:10 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:53708) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ofgfW-0000Vl-Qh for bug-gnu-emacs@gnu.org; Tue, 04 Oct 2022 08:05:05 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ofgfW-0006H5-Cj for bug-gnu-emacs@gnu.org; Tue, 04 Oct 2022 08:05:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Akib Azmain Turja Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 04 Oct 2022 12:05: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.166488504424048 (code B ref 57607); Tue, 04 Oct 2022 12:05:02 +0000 Original-Received: (at 57607) by debbugs.gnu.org; 4 Oct 2022 12:04:04 +0000 Original-Received: from localhost ([127.0.0.1]:52785 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ofgea-0006Fo-8w for submit@debbugs.gnu.org; Tue, 04 Oct 2022 08:04:04 -0400 Original-Received: from knopi.disroot.org ([178.21.23.139]:53118) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ofgeX-0006FN-Md for 57607@debbugs.gnu.org; Tue, 04 Oct 2022 08:04:03 -0400 Original-Received: from localhost (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id 611D34C795; Tue, 4 Oct 2022 14:04:00 +0200 (CEST) X-Virus-Scanned: SPAM Filter at disroot.org Original-Received: from knopi.disroot.org ([127.0.0.1]) by localhost (disroot.org [127.0.0.1]) (amavisd-new, port 10024) with UTF8SMTP id 3bP6PsgANieI; Tue, 4 Oct 2022 14:03:59 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1664884971; bh=FwOhoRQYG1Rb/1Y/+ql0YKgGAelDd7i48++PU2Fjy1s=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=YaoikeMM7NJCqZtkHNn76q9AUip7zpgFEHyVv9WKD2kLJI2gRCIvboehe6CLE5ZEX nniyZqqq6p49CgPMv8UddgHQLIE0OESQLe8+91aKFIa9vZvzlXWdIBbMK2VOZfKncP wubZYxvNF+W99qXWCr4EbEDWYdMGIaEDt7z8qL61Nil+viLAMjnGUhHiu/cid+SUkQ fElQbFanqcY07tF7aAbsJW/rAtMFrHMkgLE58brnwLzW+x0C3peYbkKKsGXVroYqqf Cpt7W6GzHK5x5J44kQhR2CVYlWICIKD3HB4ahK6AhqSQBr+8xqnRMIJdFMLVTM1PKx 5j0XUxkRhkBkg== In-Reply-To: <83a66cvwob.fsf@gnu.org> (Eli Zaretskii's message of "Tue, 04 Oct 2022 11:07:48 +0300") 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:244415 Archived-At: --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Eli Zaretskii writes: >> From: Akib Azmain Turja >> Cc: 57607@debbugs.gnu.org, gerd.moellmann@gmail.com >> Date: Tue, 04 Oct 2022 13:22:51 +0600 >>=20 >> > 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. >>=20 >> 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"). >>=20 >> 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. OK. > >> > 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? >>=20 >> 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: >>=20 >> --8<---------------cut here---------------start------------->8--- >> if (AutoWrap (tty) >> && curY (tty) + 1 =3D=3D FRAME_TOTAL_LINES (f) >> && (curX (tty) + len) =3D=3D FRAME_COLS (f)) >> len --; >> --8<---------------cut here---------------end--------------->8--- >>=20 >> 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. Thanks, "CJK STROKE D" doesn't work as expected, and the result depends on terminal in use. How can I determine the width of a glyph? > (And the existing code could have bugs, > no need to assume it is always correct.) Yes, it can, but in most cases, my brain has more bugs. > >> > 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? >>=20 >> 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. OK, I'll try that. Thanks. =2D-=20 Akib Azmain Turja Find me on Mastodon at @akib@hostux.social. This message is signed by me with my GnuPG key. Its fingerprint is: 7001 8CE5 819F 17A3 BBA6 66AF E74F 0EFA 922A E7F5 --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEyVTKmrtL6kNBe3FRVTX89U2IYWsFAmM8IHkACgkQVTX89U2I YWv2DQ//QW4mpgZE35s0WuBv4h0n4laiCnG2MK0OY6Hg1LKXBPzadjtK6yKVd9nh Qc8e7xaTDxhY3ggCnc1dURBkU1OhaSGT1Y5Nu4kUgEOo3nqrbR0VOhbUFD+sh8Om bz+127SyhHepZCbqS54+SWyGIcUlg8dFN9ow5vc3tHLZ2SDQTbR8FYXPoDzDvn48 q/gHsqzsrN9SHS9FugE2GXP7HJzhhui832ZY8swcFIY+J3OIZL58cQ2V8P29qV9T u9g+s0SSkkxbZwF3qBFbKgOcG1bd6P07IYTpWZkSfI+gdXvvSSm68i8uLaEUTvY2 7M5YO67m/rJwAtbQkGo+z4Dp43tjrEvGqx+42Ak3T8ccoE364v3fM4gLLVV93Tor MZZVLbOXBE0+fPyxy7+2lznYfcVHuk2aCqcvfOHtzk3rKs2j7StgwoD1TuX70ZmE kgS7GkKm74kTU7G4DZutlFWe1E+fC6RZBjwHYm8MTkXymZtQs4cKBX0pj7Dqw+1Z aUeiaz03lbTIRriH/AUSvjfl8f/bJiPBLYtP1VfvCXTlEHT4Ud09o3pNUoTYAo1X RsM+g2emgvBE+tauwypog4TuFAUHC3uKutmKwzyOCeKENkheEkq1laJ/PIrkB6Qo JvbN1UV6L2D12yxcVmYl72QdCMzkmxXayjAsS0GIzA+V+nTr7aM= =szh2 -----END PGP SIGNATURE----- --=-=-=--