bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#34476: fluffy whitespace in the mode-line, despite it running off th


From: Eli Zaretskii
Subject: bug#34476: fluffy whitespace in the mode-line, despite it running off the screen
Date: Fri, 07 Aug 2020 14:59:52 +0300

> From: Lars Ingebrigtsen <larsi@gnus.org>
> Cc: contovob@tcd.ie,  34476@debbugs.gnu.org,  jidanni@jidanni.org
> Date: Fri, 07 Aug 2020 13:41:15 +0200
> 
> > And it formats the mode-line twice: once in format-mode-line, then
> > again in display_string, right?
> 
> No, display_string just displays the string, I think?

Which is a non-trivial amount of work: loading all the font glyphs
again and accounting for their metrics, considering the faces, etc.
All of which was already done.

> > You don't need all this inelegance.  After display_mode_element
> > returns, you have all the glyphs it produced in it.glyph_row, so you
> > can simply remove the unneeded space glyphs from the glyph row (and
> > adjust the metrics accordingly).  Let me know if you need more
> > detailed help in how to do that.
> 
> That seems like a lot more work, I think?

Why a lot more work?  It's basically the same loop as you do on
characters of the string produced by Fformat_mode_line, just done on
elements of it.glyph_row->glyphs[TEXT_AREA], which is a linear array
of 'struct glyph'.  Each glyph tells you what character it displays
(and much more).  There are gobs of similar code in xdisp.c.  For
example, here's how we make space in a glyph row for prepending a
character (needed when displaying R2L lines):

          struct glyph *g;

          /* Make room for the additional glyph.  */
          for (g = glyph - 1; g >= it->glyph_row->glyphs[area]; g--)
            g[1] = *g;
          glyph = it->glyph_row->glyphs[area];

IOW, it's just an array of simple objects, not unlike array of
characters, a.k.a. "a string".

If this still sounds complicated, I can volunteer to write the code
myself, if you promise to write tests for the feature ;-)

Thanks.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]