all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Akib Azmain Turja <akib@disroot.org>
Cc: gerd.moellmann@gmail.com, 57607@debbugs.gnu.org
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	[thread overview]
Message-ID: <83a66cvwob.fsf@gnu.org> (raw)
In-Reply-To: <87edvohx2s.fsf@disroot.org> (message from Akib Azmain Turja on Tue, 04 Oct 2022 13:22:51 +0600)

> From: Akib Azmain Turja <akib@disroot.org>
> 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.





  reply	other threads:[~2022-10-04  8:07 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-03 17:39 Why Emacs doesn't touch the bottom-right corner of terminal Akib Azmain Turja
2022-09-06  6:59 ` bug#57607: Feature request: Use the character cell on bottom-right corner of a terminal Akib Azmain Turja via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-09-06  8:03   ` Gerd Möllmann
2022-09-06 10:07     ` Akib Azmain Turja via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-09-06 12:00       ` Gerd Möllmann
2022-09-06 15:10         ` Akib Azmain Turja via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-09-07  4:58           ` Gerd Möllmann
2022-09-07 12:46             ` Akib Azmain Turja via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-09-07 12:58               ` Gerd Möllmann
2022-09-07 15:39             ` Akib Azmain Turja via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-09-07 17:26             ` Akib Azmain Turja via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-09-08  5:49               ` Gerd Möllmann
2022-09-08 11:28                 ` Akib Azmain Turja via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-09-08 12:35                   ` Gerd Möllmann
2022-09-08 14:47                     ` Akib Azmain Turja via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-09-11  9:00                       ` Akib Azmain Turja via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-09-11 10:08                         ` Gerd Möllmann
2022-09-11 10:39                           ` Akib Azmain Turja via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-10-03  8:31                   ` Akib Azmain Turja via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-10-03 19:41                     ` Eli Zaretskii
2022-10-04  7:22                       ` Akib Azmain Turja via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-10-04  8:07                         ` Eli Zaretskii [this message]
2022-10-04 12:00                           ` Akib Azmain Turja via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-10-04 12:54                             ` Eli Zaretskii
2022-10-07 13:10                               ` Akib Azmain Turja via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-10-07 19:30                                 ` Eli Zaretskii
2022-10-04 13:05                             ` Akib Azmain Turja via Bug reports for GNU Emacs, the Swiss army knife of text editors

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=83a66cvwob.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=57607@debbugs.gnu.org \
    --cc=akib@disroot.org \
    --cc=gerd.moellmann@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.