unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Michael Gallagher - NOAA Affiliate <michael.r.gallagher@noaa.gov>
Cc: 50506@debbugs.gnu.org, larsi@gnus.org
Subject: bug#50506: 28.0.50; display-line-numbers equivalent for linum-format?
Date: Wed, 15 Sep 2021 21:10:39 +0300	[thread overview]
Message-ID: <837dfhbtgg.fsf@gnu.org> (raw)
In-Reply-To: <CA+e+kb1qnajUNfsyXWzY86a2zL=+crFWaw+akpJ_B3kzkpPg-A@mail.gmail.com> (message from Michael Gallagher - NOAA Affiliate on Wed, 15 Sep 2021 11:32:17 -0600)

> From: Michael Gallagher - NOAA Affiliate <michael.r.gallagher@noaa.gov>
> Date: Wed, 15 Sep 2021 11:32:17 -0600
> Cc: Lars Ingebrigtsen <larsi@gnus.org>, 50506@debbugs.gnu.org
> 
> Ok. Correct me if I'm wrong, but this is extremely ugly in that it requires a deep knowledge of how the glyphs
> are drawn and how move_it_by_lines operates on the glyphs.

move_it_by_lines is not relevant here.  The code to look at is
display_line and the few of the functions it calls.  display_line is
where the display engine generates screen lines, called "glyph rows".
A glyph row is just an array of 'struct glyph', or "glyphs" for short.
Each one of these glyphs describes a single "display element": a
character, an image, a stretch of whitespace, etc.  We are interested
in character glyphs here.

> Because, as it appears to me, once the line
> number glyphs are sent to what I will call the "glyph queue" via PRODUCE_GLYPHS you have very little
> (no?) information about what is responsible for those glyphs?

PRODUCE_GLYPHS is a macro that (on GUI frames) calls
gui_produce_glyphs.  It generates one glyph and adds it to the array
of glyphs of the glyph row.  At any point during the time display_line
works on a single glyph row (a.k.a. "screen line"), you can reach all
the glyphs produced upto that point by looking at the glyphs in the
it->glyph_row array indexed by their horizontal position.

A glyph row has 3 areas: 2 areas for the left and right margins, and
one area called TEXT_AREA, which is where the line numbers and the
text of the line are laid out.  So the i-th glyph in the text area of
the glyph row is it->glyph_row->glyphs[TEXT_AREA][i-1], and the last
glyph produced so far has its index in it->glyph_row->used[TEXT_AREA]-1.

> Actually. I don't fully understand where in the
> code the line numbers get moved to the right side. Because it should be, conceptually, easy to swap the last
> glyph to the first glyph if there is a separator character at that point in the code. But when I "M-s o" for
> occurences of R2L and then look for the place where the lnum glyphs are moved to the right side, I can't find
> it.  

When gui_produce_glyphs and its subroutines realize that the glyph row
has its reversed_p flag set, they start pushing (prepending) glyphs to
the glyphs already there, instead of appending them.  That's how the
line number winds up at the right edge of the screen line: it is
pushed there by the following glyphs when those are prepended.  Look
in append_glyph to see how this is done.

If what I told above and the code I pointed to leave something
unclear, please ask specific questions.





      reply	other threads:[~2021-09-15 18:10 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-10  7:40 bug#50506: 28.0.50; display-line-numbers equivalent for linum-format? Michael Gallagher (CIRES/NOAA) via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-09-10 12:30 ` Eli Zaretskii
2021-09-10 16:00   ` Michael Gallagher - NOAA Affiliate via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-09-11 11:53     ` Eli Zaretskii
2021-09-11 12:03     ` Lars Ingebrigtsen
2021-09-13 17:54       ` Michael Gallagher - NOAA Affiliate via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-09-13 18:05         ` Eli Zaretskii
2021-09-13 18:17           ` Michael Gallagher - NOAA Affiliate via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-09-13 18:27             ` Eli Zaretskii
2021-09-14 16:17               ` Michael Gallagher - NOAA Affiliate via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-09-14 17:24                 ` Michael Gallagher - NOAA Affiliate via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-09-14 17:35                 ` Eli Zaretskii
2021-09-15 15:22                   ` Michael Gallagher - NOAA Affiliate via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-09-15 15:49                     ` Eli Zaretskii
2021-09-15 16:08                       ` Michael Gallagher - NOAA Affiliate via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-09-15 16:26                         ` Eli Zaretskii
2021-09-15 16:45                           ` Michael Gallagher - NOAA Affiliate via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-09-15 16:53                             ` Eli Zaretskii
2021-09-15 17:32                               ` Michael Gallagher - NOAA Affiliate via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-09-15 18:10                                 ` Eli Zaretskii [this message]

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=837dfhbtgg.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=50506@debbugs.gnu.org \
    --cc=larsi@gnus.org \
    --cc=michael.r.gallagher@noaa.gov \
    /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 public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).