emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] scratch/line-numbers dfe1c82 5/9: Fix TAB display when the


From: Eli Zaretskii
Subject: [Emacs-diffs] scratch/line-numbers dfe1c82 5/9: Fix TAB display when the line-number face uses a smaller/larger font
Date: Fri, 30 Jun 2017 10:41:20 -0400 (EDT)

branch: scratch/line-numbers
commit dfe1c820d3dca6673aba911a4a37969bbabd0486
Author: Eli Zaretskii <address@hidden>
Commit: Eli Zaretskii <address@hidden>

    Fix TAB display when the line-number face uses a smaller/larger font
    
    * src/dispextern.h (struct it): New member lnum_pixel_width.
    * src/xdisp.c (maybe_produce_line_number): Compute the width of
    the line-number display in pixels.
    (x_produce_glyphs): Use it->lnum_pixel_width instead of a kludge
    that used it->lnum_width and made assumptions about pixel width.
---
 src/dispextern.h | 5 +++--
 src/xdisp.c      | 9 +++++----
 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/src/dispextern.h b/src/dispextern.h
index 08e5caa..84a2716 100644
--- a/src/dispextern.h
+++ b/src/dispextern.h
@@ -2667,9 +2667,10 @@ struct it
   /* The byte position corresponding to lnum.  */
   ptrdiff_t lnum_bytepos;
 
-  /* The width in columns needed for display of the line numbers, or
-     zero if not computed.  */
+  /* The width, in columns and in pixels, needed for display of the
+     line numbers, or zero if not computed.  */
   int lnum_width;
+  int lnum_pixel_width;
 
   /* The line number of point's line, or zero if not computed yet.  */
   ptrdiff_t pt_lnum;
diff --git a/src/xdisp.c b/src/xdisp.c
index bbf3050..3fc5f29 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -20938,6 +20938,8 @@ maybe_produce_line_number (struct it *it)
        }
     }
 
+  /* Record the width in pixels we need for the line number display.  */
+  it->lnum_pixel_width = tem_it.current_x;
   /* Copy the produced glyphs into IT's glyph_row.  */
   struct glyph *g = scratch_glyph_row.glyphs[TEXT_AREA];
   struct glyph *e = g + scratch_glyph_row.used[TEXT_AREA];
@@ -27997,13 +27999,12 @@ x_produce_glyphs (struct it *it)
              int tab_width = it->tab_width * font->space_width;
              int x = it->current_x + it->continuation_lines_width;
              int x0 = x;
-             /* Adjust for line numbers.  Kludge alert: the "2" below
-                is because we add 2 blanks to the actual line number.  */
+             /* Adjust for line numbers, if needed.   */
              if (!NILP (Vdisplay_line_numbers))
-               x -= (it->lnum_width + 2) * font->space_width;
+               x -= it->lnum_pixel_width;
              int next_tab_x = ((1 + x + tab_width - 1) / tab_width) * 
tab_width;
              if (!NILP (Vdisplay_line_numbers))
-               next_tab_x += (it->lnum_width + 2) * font->space_width;
+               next_tab_x += it->lnum_pixel_width;
 
              /* If the distance from the current position to the next tab
                 stop is less than a space character width, use the



reply via email to

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