From 03669ccbad9fcaf6c29003d23f3e8bdecaab21b1 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Sat, 8 Oct 2011 14:15:08 +0200 Subject: [PATCH] src/xdisp.c (hscroll_window_tree): Support hscroll in right-to-left lines. --- src/ChangeLog | 3 +++ src/xdisp.c | 35 +++++++++++++++++++++++++++++------ 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index edfecaa0930..3f93987c0f1 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,8 @@ 2011-10-08 Eli Zaretskii + * xdisp.c (hscroll_window_tree): Support hscroll in right-to-left + lines. + * dispnew.c (buffer_posn_from_coords): Account for a possible presence of header-line. (Bug#4426) diff --git a/src/xdisp.c b/src/xdisp.c index a072ff2c171..2fff6d9518c 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -12065,6 +12065,7 @@ hscroll_window_tree (Lisp_Object window) = (desired_cursor_row->enabled_p ? desired_cursor_row : current_cursor_row); + int row_r2l_p = cursor_row->reversed_p; text_area_width = window_box_width (w, TEXT_AREA); @@ -12072,11 +12073,31 @@ hscroll_window_tree (Lisp_Object window) h_margin = hscroll_margin * WINDOW_FRAME_COLUMN_WIDTH (w); if (!NILP (Fbuffer_local_value (Qauto_hscroll_mode, w->buffer)) - && ((XFASTINT (w->hscroll) - && w->cursor.x <= h_margin) - || (cursor_row->enabled_p - && cursor_row->truncated_on_right_p - && (w->cursor.x >= text_area_width - h_margin)))) + /* For left-to-right rows, hscroll when cursor is either + (i) inside the right hscroll margin, or (ii) if it is + inside the left margin and the window is already + hscrolled. */ + && ((!row_r2l_p + && ((XFASTINT (w->hscroll) + && w->cursor.x <= h_margin) + || (cursor_row->enabled_p + && cursor_row->truncated_on_right_p + && (w->cursor.x >= text_area_width - h_margin)))) + /* For right-to-left rows, the logic is similar, + except that rules for scrolling to left and right + are reversed. E.g., if cursor.x <= h_margin, we + need to hscroll "to the right" unconditionally, + and that will scroll the screen to the left so as + to reveal the next portion of the row. */ + || (row_r2l_p + && ((cursor_row->enabled_p + /* FIXME: It is confusing to set the + truncated_on_right_p flag when R2L rows + are actually truncated on the left. */ + && cursor_row->truncated_on_right_p + && w->cursor.x <= h_margin) + || (XFASTINT (w->hscroll) + && (w->cursor.x >= text_area_width - h_margin)))))) { struct it it; int hscroll; @@ -12111,7 +12132,9 @@ hscroll_window_tree (Lisp_Object window) ? (text_area_width - 4 * FRAME_COLUMN_WIDTH (it.f)) : (text_area_width / 2)))) / FRAME_COLUMN_WIDTH (it.f); - else if (w->cursor.x >= text_area_width - h_margin) + else if ((!row_r2l_p + && w->cursor.x >= text_area_width - h_margin) + || (row_r2l_p && w->cursor.x <= h_margin)) { if (hscroll_relative_p) wanted_x = text_area_width * (1 - hscroll_step_rel) -- 2.11.4.GIT