863 |
Lisp_Object)); |
Lisp_Object)); |
864 |
static void extend_face_to_end_of_line P_ ((struct it *)); |
static void extend_face_to_end_of_line P_ ((struct it *)); |
865 |
static int append_space_for_newline P_ ((struct it *, int)); |
static int append_space_for_newline P_ ((struct it *, int)); |
866 |
static int make_cursor_line_fully_visible P_ ((struct window *, int)); |
static int cursor_row_fully_visible_p P_ ((struct window *, int, int)); |
867 |
static int try_scrolling P_ ((Lisp_Object, int, EMACS_INT, EMACS_INT, int, int)); |
static int try_scrolling P_ ((Lisp_Object, int, EMACS_INT, EMACS_INT, int, int)); |
868 |
static int try_cursor_movement P_ ((Lisp_Object, struct text_pos, int *)); |
static int try_cursor_movement P_ ((Lisp_Object, struct text_pos, int *)); |
869 |
static int trailing_whitespace_p P_ ((int)); |
static int trailing_whitespace_p P_ ((int)); |
1285 |
} |
} |
1286 |
|
|
1287 |
start_display (&it, w, top); |
start_display (&it, w, top); |
1288 |
move_it_to (&it, charpos, 0, it.last_visible_y, -1, |
move_it_to (&it, charpos, -1, it.last_visible_y, -1, |
1289 |
MOVE_TO_POS | MOVE_TO_X | MOVE_TO_Y); |
MOVE_TO_POS | MOVE_TO_Y); |
1290 |
|
|
1291 |
/* Note that we may overshoot because of invisible text. */ |
/* Note that we may overshoot because of invisible text. */ |
1292 |
if (IT_CHARPOS (it) >= charpos) |
if (IT_CHARPOS (it) >= charpos) |
1310 |
} |
} |
1311 |
} |
} |
1312 |
} |
} |
1313 |
else if (it.current_y + it.max_ascent + it.max_descent > it.last_visible_y) |
else |
1314 |
{ |
{ |
1315 |
struct it it2; |
struct it it2; |
1316 |
|
|
1317 |
it2 = it; |
it2 = it; |
1318 |
move_it_by_lines (&it, 1, 0); |
if (IT_CHARPOS (it) < ZV && FETCH_BYTE (IT_BYTEPOS (it)) != '\n') |
1319 |
|
move_it_by_lines (&it, 1, 0); |
1320 |
if (charpos < IT_CHARPOS (it)) |
if (charpos < IT_CHARPOS (it)) |
1321 |
{ |
{ |
1322 |
visible_p = 1; |
visible_p = 1; |
1327 |
*y = it2.current_y + it2.max_ascent - it2.ascent; |
*y = it2.current_y + it2.max_ascent - it2.ascent; |
1328 |
if (rtop) |
if (rtop) |
1329 |
{ |
{ |
1330 |
*rtop = 0; |
*rtop = max (0, -it2.current_y); |
1331 |
*rbot = max (0, (it2.current_y + it2.max_ascent + it2.max_descent) - it.last_visible_y); |
*rbot = max (0, ((it2.current_y + it2.max_ascent + it2.max_descent) |
1332 |
|
- it.last_visible_y)); |
1333 |
} |
} |
1334 |
} |
} |
1335 |
} |
} |
4699 |
/* If newline has a display property that replaces the newline with something |
/* If newline has a display property that replaces the newline with something |
4700 |
else (image or text), find start of overlay or interval and continue search |
else (image or text), find start of overlay or interval and continue search |
4701 |
from that point. */ |
from that point. */ |
4702 |
{ |
if (IT_CHARPOS (*it) > BEGV) |
4703 |
struct it it2 = *it; |
{ |
4704 |
int pos = IT_CHARPOS (*it); |
struct it it2 = *it; |
4705 |
int beg, end; |
int pos; |
4706 |
Lisp_Object val, overlay; |
int beg, end; |
4707 |
|
Lisp_Object val, overlay; |
4708 |
it2.sp = 0; |
|
4709 |
if (handle_display_prop (&it2) == HANDLED_RETURN |
pos = --IT_CHARPOS (it2); |
4710 |
&& !NILP (val = get_char_property_and_overlay |
--IT_BYTEPOS (it2); |
4711 |
(make_number (pos), Qdisplay, Qnil, &overlay)) |
it2.sp = 0; |
4712 |
&& (OVERLAYP (overlay) |
if (handle_display_prop (&it2) == HANDLED_RETURN |
4713 |
? (beg = OVERLAY_POSITION (OVERLAY_START (overlay))) |
&& !NILP (val = get_char_property_and_overlay |
4714 |
: get_property_and_range (pos, Qdisplay, &val, &beg, &end, Qnil))) |
(make_number (pos), Qdisplay, Qnil, &overlay)) |
4715 |
{ |
&& (OVERLAYP (overlay) |
4716 |
if (beg < BEGV) |
? (beg = OVERLAY_POSITION (OVERLAY_START (overlay))) |
4717 |
beg = BEGV; |
: get_property_and_range (pos, Qdisplay, &val, &beg, &end, Qnil))) |
4718 |
IT_CHARPOS (*it) = beg; |
{ |
4719 |
IT_BYTEPOS (*it) = buf_charpos_to_bytepos (current_buffer, beg); |
if (beg < BEGV) |
4720 |
continue; |
beg = BEGV; |
4721 |
} |
IT_CHARPOS (*it) = beg; |
4722 |
} |
IT_BYTEPOS (*it) = buf_charpos_to_bytepos (current_buffer, beg); |
4723 |
|
continue; |
4724 |
|
} |
4725 |
|
} |
4726 |
|
|
4727 |
break; |
break; |
4728 |
} |
} |
4729 |
|
|
6336 |
a line height of 13 pixels each, recentering with point |
a line height of 13 pixels each, recentering with point |
6337 |
on the bottom line will try to move -39/2 = 19 pixels |
on the bottom line will try to move -39/2 = 19 pixels |
6338 |
backward. Try to avoid moving into the first line. */ |
backward. Try to avoid moving into the first line. */ |
6339 |
&& it->current_y - target_y > line_height * 2 / 3 |
&& (it->current_y - target_y |
6340 |
|
> min (window_box_height (it->w), line_height * 2 / 3)) |
6341 |
&& IT_CHARPOS (*it) > BEGV) |
&& IT_CHARPOS (*it) > BEGV) |
6342 |
{ |
{ |
6343 |
TRACE_MOVE ((stderr, " not far enough -> move_vert %d\n", |
TRACE_MOVE ((stderr, " not far enough -> move_vert %d\n", |
11095 |
as if point had gone off the screen. */ |
as if point had gone off the screen. */ |
11096 |
|
|
11097 |
static int |
static int |
11098 |
make_cursor_line_fully_visible (w, force_p) |
cursor_row_fully_visible_p (w, force_p, current_matrix_p) |
11099 |
struct window *w; |
struct window *w; |
11100 |
int force_p; |
int force_p; |
11101 |
{ |
{ |
11111 |
if (w->cursor.vpos < 0) |
if (w->cursor.vpos < 0) |
11112 |
return 1; |
return 1; |
11113 |
|
|
11114 |
matrix = w->desired_matrix; |
matrix = current_matrix_p ? w->current_matrix : w->desired_matrix; |
11115 |
row = MATRIX_ROW (matrix, w->cursor.vpos); |
row = MATRIX_ROW (matrix, w->cursor.vpos); |
11116 |
|
|
11117 |
/* If the cursor row is not partially visible, there's nothing to do. */ |
/* If the cursor row is not partially visible, there's nothing to do. */ |
11416 |
|
|
11417 |
/* If cursor ends up on a partially visible line, |
/* If cursor ends up on a partially visible line, |
11418 |
treat that as being off the bottom of the screen. */ |
treat that as being off the bottom of the screen. */ |
11419 |
if (! make_cursor_line_fully_visible (w, extra_scroll_margin_lines <= 1)) |
if (! cursor_row_fully_visible_p (w, extra_scroll_margin_lines <= 1, 0)) |
11420 |
{ |
{ |
11421 |
clear_glyph_matrix (w->desired_matrix); |
clear_glyph_matrix (w->desired_matrix); |
11422 |
++extra_scroll_margin_lines; |
++extra_scroll_margin_lines; |
11686 |
&& CHARPOS (startp) != BEGV) |
&& CHARPOS (startp) != BEGV) |
11687 |
scroll_p = 1; |
scroll_p = 1; |
11688 |
} |
} |
11689 |
|
else |
11690 |
|
{ |
11691 |
|
/* Cursor did not move. So don't scroll even if cursor line |
11692 |
|
is partially visible, as it was so before. */ |
11693 |
|
rc = CURSOR_MOVEMENT_SUCCESS; |
11694 |
|
} |
11695 |
|
|
11696 |
if (PT < MATRIX_ROW_START_CHARPOS (row) |
if (PT < MATRIX_ROW_START_CHARPOS (row) |
11697 |
|| PT > MATRIX_ROW_END_CHARPOS (row)) |
|| PT > MATRIX_ROW_END_CHARPOS (row)) |
11699 |
/* if PT is not in the glyph row, give up. */ |
/* if PT is not in the glyph row, give up. */ |
11700 |
rc = CURSOR_MOVEMENT_MUST_SCROLL; |
rc = CURSOR_MOVEMENT_MUST_SCROLL; |
11701 |
} |
} |
11702 |
else if (MATRIX_ROW_PARTIALLY_VISIBLE_P (w, row) |
else if (rc != CURSOR_MOVEMENT_SUCCESS |
11703 |
|
&& MATRIX_ROW_PARTIALLY_VISIBLE_P (w, row) |
11704 |
&& make_cursor_line_fully_visible_p) |
&& make_cursor_line_fully_visible_p) |
11705 |
{ |
{ |
11706 |
if (PT == MATRIX_ROW_END_CHARPOS (row) |
if (PT == MATRIX_ROW_END_CHARPOS (row) |
11719 |
else |
else |
11720 |
{ |
{ |
11721 |
set_cursor_from_row (w, row, w->current_matrix, 0, 0, 0, 0); |
set_cursor_from_row (w, row, w->current_matrix, 0, 0, 0, 0); |
11722 |
if (!make_cursor_line_fully_visible (w, 0)) |
if (!cursor_row_fully_visible_p (w, 0, 1)) |
11723 |
rc = CURSOR_MOVEMENT_MUST_SCROLL; |
rc = CURSOR_MOVEMENT_MUST_SCROLL; |
11724 |
else |
else |
11725 |
rc = CURSOR_MOVEMENT_SUCCESS; |
rc = CURSOR_MOVEMENT_SUCCESS; |
11804 |
int temp_scroll_step = 0; |
int temp_scroll_step = 0; |
11805 |
int count = SPECPDL_INDEX (); |
int count = SPECPDL_INDEX (); |
11806 |
int rc; |
int rc; |
11807 |
int centering_position; |
int centering_position = -1; |
11808 |
int last_line_misfit = 0; |
int last_line_misfit = 0; |
11809 |
|
|
11810 |
SET_TEXT_POS (lpoint, PT, PT_BYTE); |
SET_TEXT_POS (lpoint, PT, PT_BYTE); |
12050 |
new_vpos = window_box_height (w) / 2; |
new_vpos = window_box_height (w) / 2; |
12051 |
} |
} |
12052 |
|
|
12053 |
if (!make_cursor_line_fully_visible (w, 0)) |
if (!cursor_row_fully_visible_p (w, 0, 0)) |
12054 |
{ |
{ |
12055 |
/* Point does appear, but on a line partly visible at end of window. |
/* Point does appear, but on a line partly visible at end of window. |
12056 |
Move it back to a fully-visible line. */ |
Move it back to a fully-visible line. */ |
12187 |
/* Forget any recorded base line for line number display. */ |
/* Forget any recorded base line for line number display. */ |
12188 |
w->base_line_number = Qnil; |
w->base_line_number = Qnil; |
12189 |
|
|
12190 |
if (!make_cursor_line_fully_visible (w, 1)) |
if (!cursor_row_fully_visible_p (w, 1, 0)) |
12191 |
{ |
{ |
12192 |
clear_glyph_matrix (w->desired_matrix); |
clear_glyph_matrix (w->desired_matrix); |
12193 |
last_line_misfit = 1; |
last_line_misfit = 1; |
12247 |
/* Finally, just choose place to start which centers point */ |
/* Finally, just choose place to start which centers point */ |
12248 |
|
|
12249 |
recenter: |
recenter: |
12250 |
centering_position = window_box_height (w) / 2; |
if (centering_position < 0) |
12251 |
|
centering_position = window_box_height (w) / 2; |
|
point_at_top: |
|
|
/* Jump here with centering_position already set to 0. */ |
|
12252 |
|
|
12253 |
#if GLYPH_DEBUG |
#if GLYPH_DEBUG |
12254 |
debug_method_add (w, "recenter"); |
debug_method_add (w, "recenter"); |
12345 |
set_cursor_from_row (w, row, w->current_matrix, 0, 0, 0, 0); |
set_cursor_from_row (w, row, w->current_matrix, 0, 0, 0, 0); |
12346 |
} |
} |
12347 |
|
|
12348 |
if (!make_cursor_line_fully_visible (w, centering_position > 0)) |
if (!cursor_row_fully_visible_p (w, 0, 0)) |
12349 |
{ |
{ |
12350 |
/* If vscroll is enabled, disable it and try again. */ |
/* If vscroll is enabled, disable it and try again. */ |
12351 |
if (w->vscroll) |
if (w->vscroll) |
12360 |
visible, if it can be done. */ |
visible, if it can be done. */ |
12361 |
if (centering_position == 0) |
if (centering_position == 0) |
12362 |
goto done; |
goto done; |
12363 |
|
|
12364 |
clear_glyph_matrix (w->desired_matrix); |
clear_glyph_matrix (w->desired_matrix); |
12365 |
centering_position = 0; |
centering_position = 0; |
12366 |
goto point_at_top; |
goto recenter; |
12367 |
} |
} |
12368 |
|
|
12369 |
done: |
done: |
13148 |
starts at a minimum position >= last_unchanged_pos_old. */ |
starts at a minimum position >= last_unchanged_pos_old. */ |
13149 |
for (; row > first_text_row; --row) |
for (; row > first_text_row; --row) |
13150 |
{ |
{ |
13151 |
|
/* This used to abort, but it can happen. |
13152 |
|
It is ok to just stop the search instead here. KFS. */ |
13153 |
if (!row->enabled_p || !MATRIX_ROW_DISPLAYS_TEXT_P (row)) |
if (!row->enabled_p || !MATRIX_ROW_DISPLAYS_TEXT_P (row)) |
13154 |
abort (); |
break; |
13155 |
|
|
13156 |
if (MATRIX_ROW_START_CHARPOS (row) >= last_unchanged_pos_old) |
if (MATRIX_ROW_START_CHARPOS (row) >= last_unchanged_pos_old) |
13157 |
row_found = row; |
row_found = row; |