aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEli Zaretskii2010-02-13 12:41:13 -0500
committerEli Zaretskii2010-02-13 12:41:13 -0500
commitae9784892b7c9005b792b026d466af105bcb655f (patch)
tree62391eb0a64105986f4e1cd21c49750433fba02c /src
parent36447e8d1f292611ce4db90e8fda8f3e25333747 (diff)
downloademacs-ae9784892b7c9005b792b026d466af105bcb655f.tar.gz
emacs-ae9784892b7c9005b792b026d466af105bcb655f.zip
Continue work on continuation lines. Some progress with cursor motion.
xdisp.c (set_cursor_from_row): Don't overwrite cursor position if it is not a better candidate than what we already have. (display_line): Keep calling set_cursor_from_row for bidi-reordered rows even if we already have a possible candidate for cursor position. Undo the row_end setting throughout the code, and instead do it after all the row's glyphs have been produced, by looping over the glyphs.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog.bidi10
-rw-r--r--src/xdisp.c95
2 files changed, 81 insertions, 24 deletions
diff --git a/src/ChangeLog.bidi b/src/ChangeLog.bidi
index 73fd6bf8da2..22a19c66300 100644
--- a/src/ChangeLog.bidi
+++ b/src/ChangeLog.bidi
@@ -1,3 +1,13 @@
12010-02-13 Eli Zaretskii <eliz@gnu.org>
2
3 * xdisp.c (set_cursor_from_row): Don't overwrite cursor position
4 if it is not a better candidate than what we already have.
5 (display_line): Keep calling set_cursor_from_row for
6 bidi-reordered rows even if we already have a possible candidate
7 for cursor position. Undo the row_end setting throughout the
8 code, and instead do it after all the row's glyphs have been
9 produced, by looping over the glyphs.
10
12010-02-06 Eli Zaretskii <eliz@gnu.org> 112010-02-06 Eli Zaretskii <eliz@gnu.org>
2 12
3 Start working on cursor movement in continuation lines. 13 Start working on cursor movement in continuation lines.
diff --git a/src/xdisp.c b/src/xdisp.c
index 8f366134cea..e8a77af8935 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -13008,6 +13008,32 @@ set_cursor_from_row (w, row, matrix, delta, delta_bytes, dy, dvpos)
13008 } 13008 }
13009 } 13009 }
13010 13010
13011 /* ROW could be part of a continued line, which might have other
13012 rows whose start and end charpos occlude point. Only set
13013 w->cursor if we found a better approximation to the cursor
13014 position than we have from previously examined rows. */
13015 if (w->cursor.vpos >= 0)
13016 {
13017 struct glyph *g1 =
13018 MATRIX_ROW_GLYPH_START (matrix, w->cursor.vpos) + w->cursor.hpos;
13019
13020 /* Keep the candidate whose buffer position is the closest to
13021 point. */
13022 if (BUFFERP (g1->object)
13023 && (g1->charpos == pt_old /* an exact match always wins */
13024 || (BUFFERP (glyph->object)
13025 && eabs (g1->charpos - pt_old)
13026 < eabs (glyph->charpos - pt_old))))
13027 return 0;
13028 /* Keep the candidate that comes from a row spanning less buffer
13029 positions. This may win when one or both candidate positions
13030 are on glyphs that came from display strings, for which we
13031 cannot compare buffer positions. */
13032 if (MATRIX_ROW_END_CHARPOS (MATRIX_ROW (matrix, w->cursor.vpos))
13033 - MATRIX_ROW_START_CHARPOS (MATRIX_ROW (matrix, w->cursor.vpos))
13034 < MATRIX_ROW_END_CHARPOS (row) - MATRIX_ROW_START_CHARPOS (row))
13035 return 0;
13036 }
13011 w->cursor.hpos = glyph - row->glyphs[TEXT_AREA]; 13037 w->cursor.hpos = glyph - row->glyphs[TEXT_AREA];
13012 w->cursor.x = x; 13038 w->cursor.x = x;
13013 w->cursor.vpos = MATRIX_ROW_VPOS (row, matrix) + dvpos; 13039 w->cursor.vpos = MATRIX_ROW_VPOS (row, matrix) + dvpos;
@@ -17160,7 +17186,6 @@ display_line (it)
17160 even if this row ends in ZV. */ 17186 even if this row ends in ZV. */
17161 if (row->reversed_p) 17187 if (row->reversed_p)
17162 extend_face_to_end_of_line (it); 17188 extend_face_to_end_of_line (it);
17163 row_end = it->current;
17164 break; 17189 break;
17165 } 17190 }
17166 17191
@@ -17395,7 +17420,6 @@ display_line (it)
17395 it->max_phys_descent = phys_descent; 17420 it->max_phys_descent = phys_descent;
17396 } 17421 }
17397 17422
17398 row_end = it->current;
17399 break; 17423 break;
17400 } 17424 }
17401 else if (new_x > it->first_visible_x) 17425 else if (new_x > it->first_visible_x)
@@ -17429,10 +17453,7 @@ display_line (it)
17429 17453
17430 /* End of this display line if row is continued. */ 17454 /* End of this display line if row is continued. */
17431 if (row->continued_p || row->ends_at_zv_p) 17455 if (row->continued_p || row->ends_at_zv_p)
17432 { 17456 break;
17433 row_end = it->current;
17434 break;
17435 }
17436 } 17457 }
17437 17458
17438 at_end_of_line: 17459 at_end_of_line:
@@ -17458,22 +17479,8 @@ display_line (it)
17458 row->glyphs[TEXT_AREA]->charpos = CHARPOS (it->position); 17479 row->glyphs[TEXT_AREA]->charpos = CHARPOS (it->position);
17459 17480
17460 /* Consume the line end. This skips over invisible lines. */ 17481 /* Consume the line end. This skips over invisible lines. */
17461 if (it->bidi_p)
17462 {
17463 /* When we are reordering bidi text, we still need the
17464 next character in logical order, to set row->end
17465 correctly below. */
17466 push_it (it);
17467 it->bidi_p = 0;
17468 set_iterator_to_next (it, 1);
17469 row_end = it->current;
17470 pop_it (it);
17471 it->bidi_p = 1;
17472 }
17473 set_iterator_to_next (it, 1); 17482 set_iterator_to_next (it, 1);
17474 it->continuation_lines_width = 0; 17483 it->continuation_lines_width = 0;
17475 if (!it->bidi_p)
17476 row_end = it->current;
17477 break; 17484 break;
17478 } 17485 }
17479 17486
@@ -17511,7 +17518,6 @@ display_line (it)
17511 it->continuation_lines_width = 0; 17518 it->continuation_lines_width = 0;
17512 row->ends_at_zv_p = 1; 17519 row->ends_at_zv_p = 1;
17513 row->exact_window_width_line_p = 1; 17520 row->exact_window_width_line_p = 1;
17514 row_end = it->current;
17515 break; 17521 break;
17516 } 17522 }
17517 if (ITERATOR_AT_END_OF_LINE_P (it)) 17523 if (ITERATOR_AT_END_OF_LINE_P (it))
@@ -17527,7 +17533,6 @@ display_line (it)
17527 row->ends_at_zv_p = FETCH_BYTE (IT_BYTEPOS (*it) - 1) != '\n'; 17533 row->ends_at_zv_p = FETCH_BYTE (IT_BYTEPOS (*it) - 1) != '\n';
17528 it->hpos = hpos_before; 17534 it->hpos = hpos_before;
17529 it->current_x = x_before; 17535 it->current_x = x_before;
17530 row_end = it->current;
17531 break; 17536 break;
17532 } 17537 }
17533 } 17538 }
@@ -17588,7 +17593,44 @@ display_line (it)
17588 compute_line_metrics (it); 17593 compute_line_metrics (it);
17589 17594
17590 /* Remember the position at which this line ends. */ 17595 /* Remember the position at which this line ends. */
17591 row->end = row_end; 17596 if (!it->bidi_p)
17597 row->end = row_end = it->current;
17598 else
17599 {
17600 EMACS_INT min_pos = ZV, max_pos = BEGV;
17601 struct glyph *g;
17602 struct it save_it;
17603 struct text_pos tpos;
17604
17605 /* ROW->start and ROW->end must be the smallest and largest
17606 buffer positions in ROW. But if ROW was bidi-reordered,
17607 these two positions can be anywhere in the row, so we must
17608 rescan all of the ROW's glyphs to find them. */
17609 for (g = row->glyphs[TEXT_AREA];
17610 g < row->glyphs[TEXT_AREA] + row->used[TEXT_AREA];
17611 g++)
17612 {
17613 if (BUFFERP (g->object))
17614 {
17615 if (g->charpos < min_pos)
17616 min_pos = g->charpos;
17617 if (g->charpos > max_pos)
17618 max_pos = g->charpos;
17619 }
17620 }
17621 row->start.pos.charpos = min_pos;
17622 row->start.pos.bytepos = CHAR_TO_BYTE (min_pos);
17623 /* For ROW->end, we need the display element that is _after_
17624 max_pos, in the logical order. Note that this may be after
17625 skipping some invisible text. */
17626 save_it = *it;
17627 it->bidi_p = 0;
17628 SET_TEXT_POS (tpos, max_pos, CHAR_TO_BYTE (max_pos));
17629 reseat_1 (it, tpos, 0);
17630 set_iterator_to_next (it, 1);
17631 row->end = row_end = it->current;
17632 *it = save_it;
17633 }
17592 17634
17593 /* Record whether this row ends inside an ellipsis. */ 17635 /* Record whether this row ends inside an ellipsis. */
17594 row->ends_in_ellipsis_p 17636 row->ends_in_ellipsis_p
@@ -17607,7 +17649,12 @@ display_line (it)
17607 it->right_user_fringe_face_id = 0; 17649 it->right_user_fringe_face_id = 0;
17608 17650
17609 /* Maybe set the cursor. */ 17651 /* Maybe set the cursor. */
17610 if (it->w->cursor.vpos < 0 17652 if ((it->w->cursor.vpos < 0
17653 /* In bidi-reordered rows, keep checking for proper cursor
17654 position even if one has been found already, because buffer
17655 positions in such rows change non-linearly with ROW->VPOS,
17656 when a line is continued. */
17657 || it->bidi_p)
17611 && PT >= MATRIX_ROW_START_CHARPOS (row) 17658 && PT >= MATRIX_ROW_START_CHARPOS (row)
17612 && PT <= MATRIX_ROW_END_CHARPOS (row) 17659 && PT <= MATRIX_ROW_END_CHARPOS (row)
17613 && cursor_row_p (it->w, row)) 17660 && cursor_row_p (it->w, row))