aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEli Zaretskii2009-10-06 18:20:22 +0000
committerEli Zaretskii2009-10-06 18:20:22 +0000
commit8a02ff62681c593eced1a020ed5fca6730365d04 (patch)
tree1db85f6b607850d5ce5200dbb3f9ad762f7d4e64 /src
parentbde79dc0588421062674c97a8c75e529aff4c762 (diff)
downloademacs-8a02ff62681c593eced1a020ed5fca6730365d04.tar.gz
emacs-8a02ff62681c593eced1a020ed5fca6730365d04.zip
(set_cursor_from_row): Fix and improve comments.
Diffstat (limited to 'src')
-rw-r--r--src/xdisp.c39
1 files changed, 22 insertions, 17 deletions
diff --git a/src/xdisp.c b/src/xdisp.c
index 8bef5204ee9..c9f9862bcb1 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -12316,16 +12316,18 @@ set_cursor_from_row (w, row, matrix, delta, delta_bytes, dy, dvpos)
12316 struct glyph *glyph = row->glyphs[TEXT_AREA]; 12316 struct glyph *glyph = row->glyphs[TEXT_AREA];
12317 struct glyph *end = glyph + row->used[TEXT_AREA]; 12317 struct glyph *end = glyph + row->used[TEXT_AREA];
12318 struct glyph *cursor = NULL; 12318 struct glyph *cursor = NULL;
12319 /* The first glyph that starts a sequence of glyphs from string. */ 12319 /* The first glyph that starts a sequence of glyphs from a string
12320 that is a value of a display property. */
12320 struct glyph *string_start; 12321 struct glyph *string_start;
12321 /* The X coordinate of string_start. */ 12322 /* The X coordinate of string_start. */
12322 int string_start_x; 12323 int string_start_x;
12323 /* The last known character position. */ 12324 /* The last known character position in row. */
12324 int last_pos = MATRIX_ROW_START_CHARPOS (row) + delta; 12325 int last_pos = MATRIX_ROW_START_CHARPOS (row) + delta;
12325 /* The last known character position before string_start. */ 12326 /* The last known character position before string_start. */
12326 int string_before_pos; 12327 int string_before_pos;
12327 int x = row->x; 12328 int x = row->x;
12328 int cursor_x = x; 12329 int cursor_x = x;
12330 /* Last buffer position covered by an overlay. */
12329 int cursor_from_overlay_pos = 0; 12331 int cursor_from_overlay_pos = 0;
12330 int pt_old = PT - delta; 12332 int pt_old = PT - delta;
12331 12333
@@ -12353,11 +12355,15 @@ set_cursor_from_row (w, row, matrix, delta, delta_bytes, dy, dvpos)
12353 string_start = NULL; 12355 string_start = NULL;
12354 x += glyph->pixel_width; 12356 x += glyph->pixel_width;
12355 ++glyph; 12357 ++glyph;
12358 /* If we are beyond the cursor position computed from the
12359 last overlay seen, that overlay is not in effect for
12360 current cursor position. Reset the cursor information
12361 computed from that overlay. */
12356 if (cursor_from_overlay_pos 12362 if (cursor_from_overlay_pos
12357 && last_pos >= cursor_from_overlay_pos) 12363 && last_pos >= cursor_from_overlay_pos)
12358 { 12364 {
12359 cursor_from_overlay_pos = 0; 12365 cursor_from_overlay_pos = 0;
12360 cursor = 0; 12366 cursor = NULL;
12361 } 12367 }
12362 } 12368 }
12363 else 12369 else
@@ -12368,7 +12374,7 @@ set_cursor_from_row (w, row, matrix, delta, delta_bytes, dy, dvpos)
12368 string_start = glyph; 12374 string_start = glyph;
12369 string_start_x = x; 12375 string_start_x = x;
12370 } 12376 }
12371 /* Skip all glyphs from string. */ 12377 /* Skip all glyphs from a string. */
12372 do 12378 do
12373 { 12379 {
12374 Lisp_Object cprop; 12380 Lisp_Object cprop;
@@ -12379,14 +12385,14 @@ set_cursor_from_row (w, row, matrix, delta, delta_bytes, dy, dvpos)
12379 !NILP (cprop)) 12385 !NILP (cprop))
12380 && (pos = string_buffer_position (w, glyph->object, 12386 && (pos = string_buffer_position (w, glyph->object,
12381 string_before_pos), 12387 string_before_pos),
12382 (pos == 0 /* From overlay */ 12388 (pos == 0 /* from overlay */
12383 || pos == pt_old))) 12389 || pos == pt_old)))
12384 { 12390 {
12385 /* Estimate overlay buffer position from the buffer 12391 /* Compute the first buffer position after the overlay.
12386 positions of the glyphs before and after the overlay. 12392 If the `cursor' property tells us how many positions
12387 Add 1 to last_pos so that if point corresponds to the 12393 are associated with the overlay, use that. Otherwise,
12388 glyph right after the overlay, we still use a 'cursor' 12394 estimate from the buffer positions of the glyphs
12389 property found in that overlay. */ 12395 before and after the overlay. */
12390 cursor_from_overlay_pos = (pos ? 0 : last_pos 12396 cursor_from_overlay_pos = (pos ? 0 : last_pos
12391 + (INTEGERP (cprop) ? XINT (cprop) : 0)); 12397 + (INTEGERP (cprop) ? XINT (cprop) : 0));
12392 cursor = glyph; 12398 cursor = glyph;
@@ -12410,9 +12416,8 @@ set_cursor_from_row (w, row, matrix, delta, delta_bytes, dy, dvpos)
12410 while (glyph > row->glyphs[TEXT_AREA] 12416 while (glyph > row->glyphs[TEXT_AREA]
12411 && (glyph - 1)->charpos == last_pos) 12417 && (glyph - 1)->charpos == last_pos)
12412 glyph--, x -= glyph->pixel_width; 12418 glyph--, x -= glyph->pixel_width;
12413 /* That loop always goes one position too far, 12419 /* That loop always goes one position too far, including the
12414 including the glyph before the ellipsis. 12420 glyph before the ellipsis. So scan forward over that one. */
12415 So scan forward over that one. */
12416 x += glyph->pixel_width; 12421 x += glyph->pixel_width;
12417 glyph++; 12422 glyph++;
12418 } 12423 }
@@ -12433,8 +12438,8 @@ set_cursor_from_row (w, row, matrix, delta, delta_bytes, dy, dvpos)
12433 x = string_start_x; 12438 x = string_start_x;
12434 string = glyph->object; 12439 string = glyph->object;
12435 pos = string_buffer_position (w, string, string_before_pos); 12440 pos = string_buffer_position (w, string, string_before_pos);
12436 /* If STRING is from overlay, LAST_POS == 0. We skip such glyphs 12441 /* If POS == 0, STRING is from overlay. We skip such glyphs
12437 because we always put cursor after overlay strings. */ 12442 because we always put the cursor after overlay strings. */
12438 while (pos == 0 && glyph < stop) 12443 while (pos == 0 && glyph < stop)
12439 { 12444 {
12440 string = glyph->object; 12445 string = glyph->object;
@@ -12461,8 +12466,8 @@ set_cursor_from_row (w, row, matrix, delta, delta_bytes, dy, dvpos)
12461 } 12466 }
12462 } 12467 }
12463 12468
12464 /* If we reached the end of the line, and end was from a string, 12469 /* If we reached the end of the line, and END was from a string,
12465 cursor is not on this line. */ 12470 the cursor is not on this line. */
12466 if (glyph == end && row->continued_p) 12471 if (glyph == end && row->continued_p)
12467 return 0; 12472 return 0;
12468 } 12473 }