[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] scratch/line-numbers 13cc19a 12/14: Partial fix of hscroll
From: |
Eli Zaretskii |
Subject: |
[Emacs-diffs] scratch/line-numbers 13cc19a 12/14: Partial fix of hscroll of truncated lines with line numbers |
Date: |
Sat, 24 Jun 2017 13:12:54 -0400 (EDT) |
branch: scratch/line-numbers
commit 13cc19a0a3685ceade4a5a560475ee47165f3bbc
Author: Eli Zaretskii <address@hidden>
Commit: Eli Zaretskii <address@hidden>
Partial fix of hscroll of truncated lines with line numbers
* src/xdisp.c (x_produce_glyphs, hscroll_window_tree): Adjust
hscroll calculations to line-number display.
* src/term.c (produce_glyphs): Adjust tab stop to window's
hscroll. These two changes fix horizontal scrolling when line
numbers are displayed. But there's still a bug: the horizontal
shift of lines that begin with a TAB is different from the rest.
* src/xdisp.c (move_it_in_display_line_to): Call
should_produce_line_number to determine whether a line number
should be produced for this screen line.
---
src/term.c | 2 +-
src/xdisp.c | 34 ++++++++++++++++++++++++++++++----
2 files changed, 31 insertions(+), 5 deletions(-)
diff --git a/src/term.c b/src/term.c
index b0e7e05..46d8bff 100644
--- a/src/term.c
+++ b/src/term.c
@@ -1587,7 +1587,7 @@ produce_glyphs (struct it *it)
/* Adjust for line numbers. Kludge alert: the "2" below is
because we add 2 blanks to the actual line number. */
if (!NILP (Vdisplay_line_numbers))
- absolute_x -= it->lnum_width + 2;
+ absolute_x -= it->lnum_width + 2 - it->w->hscroll;
int next_tab_x
= (((1 + absolute_x + it->tab_width - 1)
/ it->tab_width)
diff --git a/src/xdisp.c b/src/xdisp.c
index d35170e..d067359 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -834,6 +834,7 @@ static bool update_menu_bar (struct frame *, bool, bool);
static bool try_window_reusing_current_matrix (struct window *);
static int try_window_id (struct window *);
static void maybe_produce_line_number (struct it *);
+static bool should_produce_line_number (struct it *);
static bool display_line (struct it *, int);
static int display_mode_lines (struct window *);
static int display_mode_line (struct window *, enum face_id, Lisp_Object);
@@ -8656,7 +8657,7 @@ move_it_in_display_line_to (struct it *it,
if (it->hpos == 0)
{
/* If line numbers are being displayed, produce a line number. */
- if (!NILP (Vdisplay_line_numbers)
+ if (should_produce_line_number (it)
&& it->current_x == it->first_visible_x)
maybe_produce_line_number (it);
/* If there's a line-/wrap-prefix, handle it. */
@@ -13068,6 +13069,30 @@ hscroll_window_tree (Lisp_Object window)
}
bool row_r2l_p = cursor_row->reversed_p;
bool hscl = hscrolling_current_line_p (w);
+ int x_offset = 0;
+ struct glyph *g;
+ if (!row_r2l_p)
+ {
+ for (g = cursor_row->glyphs[TEXT_AREA];
+ g < cursor_row->glyphs[TEXT_AREA] +
cursor_row->used[TEXT_AREA];
+ g++)
+ {
+ if (!(NILP (g->object) && g->charpos < 0))
+ break;
+ x_offset += g->pixel_width;
+ }
+ }
+ else
+ {
+ for (g = cursor_row->glyphs[TEXT_AREA] +
cursor_row->used[TEXT_AREA];
+ g > cursor_row->glyphs[TEXT_AREA];
+ g--)
+ {
+ if (!(NILP ((g - 1)->object) && (g - 1)->charpos < 0))
+ break;
+ x_offset += (g - 1)->pixel_width;
+ }
+ }
text_area_width = window_box_width (w, TEXT_AREA);
@@ -13100,7 +13125,7 @@ hscroll_window_tree (Lisp_Object window)
inside the left margin and the window is already
hscrolled. */
&& ((!row_r2l_p
- && ((w->hscroll && w->cursor.x <= h_margin)
+ && ((w->hscroll && w->cursor.x <= h_margin + x_offset)
|| (cursor_row->enabled_p
&& cursor_row->truncated_on_right_p
&& (w->cursor.x >= text_area_width - h_margin))))
@@ -13118,7 +13143,8 @@ hscroll_window_tree (Lisp_Object window)
&& cursor_row->truncated_on_right_p
&& w->cursor.x <= h_margin)
|| (w->hscroll
- && (w->cursor.x >= text_area_width - h_margin))))
+ && (w->cursor.x >= (text_area_width - h_margin
+ - x_offset)))))
/* This last condition is needed when moving
vertically from an hscrolled line to a short line
that doesn't need to be hscrolled. If we omit
@@ -27898,7 +27924,7 @@ x_produce_glyphs (struct it *it)
/* Adjust for line numbers. Kludge alert: the "2" below
is because we add 2 blanks to the actual line number. */
if (!NILP (Vdisplay_line_numbers))
- x -= (it->lnum_width + 2) * font->space_width;
+ x -= (it->lnum_width + 2 - it->w->hscroll) * font->space_width;
int next_tab_x = ((1 + x + tab_width - 1) / tab_width) *
tab_width;
/* If the distance from the current position to the next tab
- [Emacs-diffs] scratch/line-numbers updated (7277c0f -> ead4ab6), Eli Zaretskii, 2017/06/24
- [Emacs-diffs] scratch/line-numbers 5b648ac 04/14: Fix problems with line-number updates in Follow mode, Eli Zaretskii, 2017/06/24
- [Emacs-diffs] scratch/line-numbers 77f8b86 03/14: Fix display of line numbers with fonts larger than the default, Eli Zaretskii, 2017/06/24
- [Emacs-diffs] scratch/line-numbers bbaf2f3 02/14: Fix background color beyond EOB and cursor display, Eli Zaretskii, 2017/06/24
- [Emacs-diffs] scratch/line-numbers 9776d7b 05/14: Don't display line numbers in the minibuffer and in tooltip frames., Eli Zaretskii, 2017/06/24
- [Emacs-diffs] scratch/line-numbers ead4ab6 14/14: Improve documentation in NEWS., Eli Zaretskii, 2017/06/24
- [Emacs-diffs] scratch/line-numbers efedb66 08/14: Rename display-line-width, Eli Zaretskii, 2017/06/24
- [Emacs-diffs] scratch/line-numbers 13cc19a 12/14: Partial fix of hscroll of truncated lines with line numbers,
Eli Zaretskii <=
- [Emacs-diffs] scratch/line-numbers 7d7602c 06/14: Fix crashes on TTY frames due to negative lnum_width., Eli Zaretskii, 2017/06/24
- [Emacs-diffs] scratch/line-numbers 55a9298 07/14: Fix tab stops when line numbers are displayed, Eli Zaretskii, 2017/06/24
- [Emacs-diffs] scratch/line-numbers 71a7294 10/14: Support a separate face for displaying the current line's number, Eli Zaretskii, 2017/06/24
- [Emacs-diffs] scratch/line-numbers d4eddb0 01/14: Fix display of indicate-empty-lines when line numbers are displayed, Eli Zaretskii, 2017/06/24
- [Emacs-diffs] scratch/line-numbers 0d5c713 13/14: Move additional hscrolling code into a suitable 'if', Eli Zaretskii, 2017/06/24
- [Emacs-diffs] scratch/line-numbers fa5e84c 09/14: Change display of current line in relative mode, Eli Zaretskii, 2017/06/24
- [Emacs-diffs] scratch/line-numbers 6e18841 11/14: Allow Lisp program to disable line-number display for specific lines, Eli Zaretskii, 2017/06/24