Commit 2084152a authored by Dmitry Antipov's avatar Dmitry Antipov
Browse files

* xdisp.c (adjust_window_ends): Move duplicated code to new function.

(try_window, try_window_reusing_current_matrix, try_window_id): Use it.
parent 02455cb6
2013-08-14 Dmitry Antipov <dmantipov@yandex.ru>
* xdisp.c (adjust_window_ends): Move duplicated code to new function.
(try_window, try_window_reusing_current_matrix, try_window_id): Use it.
2013-08-14 Dmitry Antipov <dmantipov@yandex.ru> 2013-08-14 Dmitry Antipov <dmantipov@yandex.ru>
* window.h (struct window): Convert window_end_pos and * window.h (struct window): Convert window_end_pos and
......
...@@ -2461,7 +2461,16 @@ remember_mouse_glyph (struct frame *f, int gx, int gy, NativeRectangle *rect) ...@@ -2461,7 +2461,16 @@ remember_mouse_glyph (struct frame *f, int gx, int gy, NativeRectangle *rect)
   
#endif /* HAVE_WINDOW_SYSTEM */ #endif /* HAVE_WINDOW_SYSTEM */
   
static void
adjust_window_ends (struct window *w, struct glyph_row *row, bool current)
{
eassert (w);
w->window_end_pos = Z - MATRIX_ROW_END_CHARPOS (row);
w->window_end_bytepos = Z_BYTE - MATRIX_ROW_END_BYTEPOS (row);
w->window_end_vpos
= MATRIX_ROW_VPOS (row, current ? w->current_matrix : w->desired_matrix);
}
/*********************************************************************** /***********************************************************************
Lisp form evaluation Lisp form evaluation
***********************************************************************/ ***********************************************************************/
...@@ -16291,9 +16300,7 @@ try_window (Lisp_Object window, struct text_pos pos, int flags) ...@@ -16291,9 +16300,7 @@ try_window (Lisp_Object window, struct text_pos pos, int flags)
if (last_text_row) if (last_text_row)
{ {
eassert (MATRIX_ROW_DISPLAYS_TEXT_P (last_text_row)); eassert (MATRIX_ROW_DISPLAYS_TEXT_P (last_text_row));
w->window_end_bytepos = Z_BYTE - MATRIX_ROW_END_BYTEPOS (last_text_row); adjust_window_ends (w, last_text_row, 0);
w->window_end_pos = Z - MATRIX_ROW_END_CHARPOS (last_text_row);
w->window_end_vpos = MATRIX_ROW_VPOS (last_text_row, w->desired_matrix);
eassert eassert
(MATRIX_ROW_DISPLAYS_TEXT_P (MATRIX_ROW (w->desired_matrix, (MATRIX_ROW_DISPLAYS_TEXT_P (MATRIX_ROW (w->desired_matrix,
w->window_end_vpos))); w->window_end_vpos)));
...@@ -16526,23 +16533,9 @@ try_window_reusing_current_matrix (struct window *w) ...@@ -16526,23 +16533,9 @@ try_window_reusing_current_matrix (struct window *w)
The value of last_text_row is the last displayed line The value of last_text_row is the last displayed line
containing text. */ containing text. */
if (last_reused_text_row) if (last_reused_text_row)
{ adjust_window_ends (w, last_reused_text_row, 1);
w->window_end_bytepos
= Z_BYTE - MATRIX_ROW_END_BYTEPOS (last_reused_text_row);
w->window_end_pos
= Z - MATRIX_ROW_END_CHARPOS (last_reused_text_row);
w->window_end_vpos
= MATRIX_ROW_VPOS (last_reused_text_row, w->current_matrix);
}
else if (last_text_row) else if (last_text_row)
{ adjust_window_ends (w, last_text_row, 0);
w->window_end_bytepos
= Z_BYTE - MATRIX_ROW_END_BYTEPOS (last_text_row);
w->window_end_pos
= Z - MATRIX_ROW_END_CHARPOS (last_text_row);
w->window_end_vpos
= MATRIX_ROW_VPOS (last_text_row, w->desired_matrix);
}
else else
{ {
/* This window must be completely empty. */ /* This window must be completely empty. */
...@@ -16733,14 +16726,7 @@ try_window_reusing_current_matrix (struct window *w) ...@@ -16733,14 +16726,7 @@ try_window_reusing_current_matrix (struct window *w)
the window end is in reused rows which in turn means that the window end is in reused rows which in turn means that
only its vpos can have changed. */ only its vpos can have changed. */
if (last_text_row) if (last_text_row)
{ adjust_window_ends (w, last_text_row, 0);
w->window_end_bytepos
= Z_BYTE - MATRIX_ROW_END_BYTEPOS (last_text_row);
w->window_end_pos
= Z - MATRIX_ROW_END_CHARPOS (last_text_row);
w->window_end_vpos
= MATRIX_ROW_VPOS (last_text_row, w->desired_matrix);
}
else else
w->window_end_vpos -= nrows_scrolled; w->window_end_vpos -= nrows_scrolled;
   
...@@ -17748,21 +17734,13 @@ try_window_id (struct window *w) ...@@ -17748,21 +17734,13 @@ try_window_id (struct window *w)
row = find_last_row_displaying_text (w->current_matrix, &it, row = find_last_row_displaying_text (w->current_matrix, &it,
first_unchanged_at_end_row); first_unchanged_at_end_row);
eassert (row && MATRIX_ROW_DISPLAYS_TEXT_P (row)); eassert (row && MATRIX_ROW_DISPLAYS_TEXT_P (row));
adjust_window_ends (w, row, 1);
w->window_end_pos = Z - MATRIX_ROW_END_CHARPOS (row);
w->window_end_bytepos = Z_BYTE - MATRIX_ROW_END_BYTEPOS (row);
w->window_end_vpos = MATRIX_ROW_VPOS (row, w->current_matrix);
eassert (w->window_end_bytepos >= 0); eassert (w->window_end_bytepos >= 0);
IF_DEBUG (debug_method_add (w, "A")); IF_DEBUG (debug_method_add (w, "A"));
} }
else if (last_text_row_at_end) else if (last_text_row_at_end)
{ {
w->window_end_pos adjust_window_ends (w, last_text_row_at_end, 0);
= Z - MATRIX_ROW_END_CHARPOS (last_text_row_at_end);
w->window_end_bytepos
= Z_BYTE - MATRIX_ROW_END_BYTEPOS (last_text_row_at_end);
w->window_end_vpos
= MATRIX_ROW_VPOS (last_text_row_at_end, desired_matrix);
eassert (w->window_end_bytepos >= 0); eassert (w->window_end_bytepos >= 0);
IF_DEBUG (debug_method_add (w, "B")); IF_DEBUG (debug_method_add (w, "B"));
} }
...@@ -17771,11 +17749,7 @@ try_window_id (struct window *w) ...@@ -17771,11 +17749,7 @@ try_window_id (struct window *w)
/* We have displayed either to the end of the window or at the /* We have displayed either to the end of the window or at the
end of the window, i.e. the last row with text is to be found end of the window, i.e. the last row with text is to be found
in the desired matrix. */ in the desired matrix. */
w->window_end_pos adjust_window_ends (w, last_text_row, 0);
= Z - MATRIX_ROW_END_CHARPOS (last_text_row);
w->window_end_bytepos
= Z_BYTE - MATRIX_ROW_END_BYTEPOS (last_text_row);
w->window_end_vpos = MATRIX_ROW_VPOS (last_text_row, desired_matrix);
eassert (w->window_end_bytepos >= 0); eassert (w->window_end_bytepos >= 0);
} }
else if (first_unchanged_at_end_row == NULL else if (first_unchanged_at_end_row == NULL
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment