diff options
| author | Eli Zaretskii | 2017-06-24 19:03:39 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2017-06-24 19:03:39 +0300 |
| commit | 13cc19a0a3685ceade4a5a560475ee47165f3bbc (patch) | |
| tree | 66641dcca207c14e093d7b3933f0b7090b32953e /src | |
| parent | 6e18841b17c9b7ca9f38b923db4195cade05da2e (diff) | |
| download | emacs-13cc19a0a3685ceade4a5a560475ee47165f3bbc.tar.gz emacs-13cc19a0a3685ceade4a5a560475ee47165f3bbc.zip | |
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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/term.c | 2 | ||||
| -rw-r--r-- | src/xdisp.c | 34 |
2 files changed, 31 insertions, 5 deletions
diff --git a/src/term.c b/src/term.c index b0e7e052e51..46d8bff73cc 100644 --- a/src/term.c +++ b/src/term.c | |||
| @@ -1587,7 +1587,7 @@ produce_glyphs (struct it *it) | |||
| 1587 | /* Adjust for line numbers. Kludge alert: the "2" below is | 1587 | /* Adjust for line numbers. Kludge alert: the "2" below is |
| 1588 | because we add 2 blanks to the actual line number. */ | 1588 | because we add 2 blanks to the actual line number. */ |
| 1589 | if (!NILP (Vdisplay_line_numbers)) | 1589 | if (!NILP (Vdisplay_line_numbers)) |
| 1590 | absolute_x -= it->lnum_width + 2; | 1590 | absolute_x -= it->lnum_width + 2 - it->w->hscroll; |
| 1591 | int next_tab_x | 1591 | int next_tab_x |
| 1592 | = (((1 + absolute_x + it->tab_width - 1) | 1592 | = (((1 + absolute_x + it->tab_width - 1) |
| 1593 | / it->tab_width) | 1593 | / it->tab_width) |
diff --git a/src/xdisp.c b/src/xdisp.c index d35170ed43e..d0673595390 100644 --- a/src/xdisp.c +++ b/src/xdisp.c | |||
| @@ -834,6 +834,7 @@ static bool update_menu_bar (struct frame *, bool, bool); | |||
| 834 | static bool try_window_reusing_current_matrix (struct window *); | 834 | static bool try_window_reusing_current_matrix (struct window *); |
| 835 | static int try_window_id (struct window *); | 835 | static int try_window_id (struct window *); |
| 836 | static void maybe_produce_line_number (struct it *); | 836 | static void maybe_produce_line_number (struct it *); |
| 837 | static bool should_produce_line_number (struct it *); | ||
| 837 | static bool display_line (struct it *, int); | 838 | static bool display_line (struct it *, int); |
| 838 | static int display_mode_lines (struct window *); | 839 | static int display_mode_lines (struct window *); |
| 839 | static int display_mode_line (struct window *, enum face_id, Lisp_Object); | 840 | 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, | |||
| 8656 | if (it->hpos == 0) | 8657 | if (it->hpos == 0) |
| 8657 | { | 8658 | { |
| 8658 | /* If line numbers are being displayed, produce a line number. */ | 8659 | /* If line numbers are being displayed, produce a line number. */ |
| 8659 | if (!NILP (Vdisplay_line_numbers) | 8660 | if (should_produce_line_number (it) |
| 8660 | && it->current_x == it->first_visible_x) | 8661 | && it->current_x == it->first_visible_x) |
| 8661 | maybe_produce_line_number (it); | 8662 | maybe_produce_line_number (it); |
| 8662 | /* If there's a line-/wrap-prefix, handle it. */ | 8663 | /* If there's a line-/wrap-prefix, handle it. */ |
| @@ -13068,6 +13069,30 @@ hscroll_window_tree (Lisp_Object window) | |||
| 13068 | } | 13069 | } |
| 13069 | bool row_r2l_p = cursor_row->reversed_p; | 13070 | bool row_r2l_p = cursor_row->reversed_p; |
| 13070 | bool hscl = hscrolling_current_line_p (w); | 13071 | bool hscl = hscrolling_current_line_p (w); |
| 13072 | int x_offset = 0; | ||
| 13073 | struct glyph *g; | ||
| 13074 | if (!row_r2l_p) | ||
| 13075 | { | ||
| 13076 | for (g = cursor_row->glyphs[TEXT_AREA]; | ||
| 13077 | g < cursor_row->glyphs[TEXT_AREA] + cursor_row->used[TEXT_AREA]; | ||
| 13078 | g++) | ||
| 13079 | { | ||
| 13080 | if (!(NILP (g->object) && g->charpos < 0)) | ||
| 13081 | break; | ||
| 13082 | x_offset += g->pixel_width; | ||
| 13083 | } | ||
| 13084 | } | ||
| 13085 | else | ||
| 13086 | { | ||
| 13087 | for (g = cursor_row->glyphs[TEXT_AREA] + cursor_row->used[TEXT_AREA]; | ||
| 13088 | g > cursor_row->glyphs[TEXT_AREA]; | ||
| 13089 | g--) | ||
| 13090 | { | ||
| 13091 | if (!(NILP ((g - 1)->object) && (g - 1)->charpos < 0)) | ||
| 13092 | break; | ||
| 13093 | x_offset += (g - 1)->pixel_width; | ||
| 13094 | } | ||
| 13095 | } | ||
| 13071 | 13096 | ||
| 13072 | text_area_width = window_box_width (w, TEXT_AREA); | 13097 | text_area_width = window_box_width (w, TEXT_AREA); |
| 13073 | 13098 | ||
| @@ -13100,7 +13125,7 @@ hscroll_window_tree (Lisp_Object window) | |||
| 13100 | inside the left margin and the window is already | 13125 | inside the left margin and the window is already |
| 13101 | hscrolled. */ | 13126 | hscrolled. */ |
| 13102 | && ((!row_r2l_p | 13127 | && ((!row_r2l_p |
| 13103 | && ((w->hscroll && w->cursor.x <= h_margin) | 13128 | && ((w->hscroll && w->cursor.x <= h_margin + x_offset) |
| 13104 | || (cursor_row->enabled_p | 13129 | || (cursor_row->enabled_p |
| 13105 | && cursor_row->truncated_on_right_p | 13130 | && cursor_row->truncated_on_right_p |
| 13106 | && (w->cursor.x >= text_area_width - h_margin)))) | 13131 | && (w->cursor.x >= text_area_width - h_margin)))) |
| @@ -13118,7 +13143,8 @@ hscroll_window_tree (Lisp_Object window) | |||
| 13118 | && cursor_row->truncated_on_right_p | 13143 | && cursor_row->truncated_on_right_p |
| 13119 | && w->cursor.x <= h_margin) | 13144 | && w->cursor.x <= h_margin) |
| 13120 | || (w->hscroll | 13145 | || (w->hscroll |
| 13121 | && (w->cursor.x >= text_area_width - h_margin)))) | 13146 | && (w->cursor.x >= (text_area_width - h_margin |
| 13147 | - x_offset))))) | ||
| 13122 | /* This last condition is needed when moving | 13148 | /* This last condition is needed when moving |
| 13123 | vertically from an hscrolled line to a short line | 13149 | vertically from an hscrolled line to a short line |
| 13124 | that doesn't need to be hscrolled. If we omit | 13150 | that doesn't need to be hscrolled. If we omit |
| @@ -27898,7 +27924,7 @@ x_produce_glyphs (struct it *it) | |||
| 27898 | /* Adjust for line numbers. Kludge alert: the "2" below | 27924 | /* Adjust for line numbers. Kludge alert: the "2" below |
| 27899 | is because we add 2 blanks to the actual line number. */ | 27925 | is because we add 2 blanks to the actual line number. */ |
| 27900 | if (!NILP (Vdisplay_line_numbers)) | 27926 | if (!NILP (Vdisplay_line_numbers)) |
| 27901 | x -= (it->lnum_width + 2) * font->space_width; | 27927 | x -= (it->lnum_width + 2 - it->w->hscroll) * font->space_width; |
| 27902 | int next_tab_x = ((1 + x + tab_width - 1) / tab_width) * tab_width; | 27928 | int next_tab_x = ((1 + x + tab_width - 1) / tab_width) * tab_width; |
| 27903 | 27929 | ||
| 27904 | /* If the distance from the current position to the next tab | 27930 | /* If the distance from the current position to the next tab |