[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
- [Emacs-diffs] scratch/line-numbers updated (33073d5 -> e83b128), Eli Zaretskii, 2017/06/30
- [Emacs-diffs] scratch/line-numbers 5b9b494 4/9: Minor fixes, Eli Zaretskii, 2017/06/30
- [Emacs-diffs] scratch/line-numbers dfe1c82 5/9: Fix TAB display when the line-number face uses a smaller/larger font,
Eli Zaretskii <=
- [Emacs-diffs] scratch/line-numbers a06dd3b 6/9: Fix hscrolling with line numbers on TTY frames, Eli Zaretskii, 2017/06/30
- [Emacs-diffs] scratch/line-numbers beb95a8 2/9: Initial support for visually-relative line numbers, Eli Zaretskii, 2017/06/30
- [Emacs-diffs] scratch/line-numbers 67c8a21 1/9: Update IT's metrics while simulating display, Eli Zaretskii, 2017/06/30
- [Emacs-diffs] scratch/line-numbers 71e31ac 3/9: Support default-text-properties, Eli Zaretskii, 2017/06/30
- [Emacs-diffs] scratch/line-numbers 0e4f2e0 7/9: Speed up the visual-mode relative line numbers, Eli Zaretskii, 2017/06/30
- [Emacs-diffs] scratch/line-numbers 7a762fb 8/9: Support displaying zero as the number of the current line, Eli Zaretskii, 2017/06/30
- [Emacs-diffs] scratch/line-numbers e83b128 9/9: Add documentation for display-line-numbers, Eli Zaretskii, 2017/06/30