comparison src/xdisp.c @ 89381:eaf61dbe44af

(SKIP_GLYPHS): New macro. (set_cursor_from_row): Pay attention to string display properties.
author Kenichi Handa <handa@m17n.org>
date Fri, 31 Jan 2003 06:11:01 +0000
parents 8ee5fad31b16
children 2f877ed80fa6
comparison
equal deleted inserted replaced
89380:9320c2f4f351 89381:eaf61dbe44af
9354 if (displayed_buffer->display_error_modiff < BUF_MODIFF (displayed_buffer)) 9354 if (displayed_buffer->display_error_modiff < BUF_MODIFF (displayed_buffer))
9355 redisplay_window (window, 1); 9355 redisplay_window (window, 1);
9356 return Qnil; 9356 return Qnil;
9357 } 9357 }
9358 9358
9359
9360 /* Increment GLYPH until it reaches END or CONDITION fails while
9361 adding (GLYPH)->pixel_width to X. */
9362
9363 #define SKIP_GLYPHS(glyph, end, x, condition) \
9364 do \
9365 { \
9366 (x) += (glyph)->pixel_width; \
9367 ++(glyph); \
9368 } \
9369 while ((glyph) < (end) && (condition))
9370
9371
9359 /* Set cursor position of W. PT is assumed to be displayed in ROW. 9372 /* Set cursor position of W. PT is assumed to be displayed in ROW.
9360 DELTA is the number of bytes by which positions recorded in ROW 9373 DELTA is the number of bytes by which positions recorded in ROW
9361 differ from current buffer positions. */ 9374 differ from current buffer positions. */
9362 9375
9363 void 9376 void
9367 struct glyph_matrix *matrix; 9380 struct glyph_matrix *matrix;
9368 int delta, delta_bytes, dy, dvpos; 9381 int delta, delta_bytes, dy, dvpos;
9369 { 9382 {
9370 struct glyph *glyph = row->glyphs[TEXT_AREA]; 9383 struct glyph *glyph = row->glyphs[TEXT_AREA];
9371 struct glyph *end = glyph + row->used[TEXT_AREA]; 9384 struct glyph *end = glyph + row->used[TEXT_AREA];
9385 /* The first glyph that starts a sequence of glyphs from string. */
9386 struct glyph *string_start;
9387 /* The X coordinate of string_start. */
9388 int string_start_x;
9389 /* The last known character position. */
9390 int last_pos = MATRIX_ROW_START_CHARPOS (row) + delta;
9391 /* The last known character position before string_start. */
9392 int string_before_pos;
9372 int x = row->x; 9393 int x = row->x;
9373 int pt_old = PT - delta; 9394 int pt_old = PT - delta;
9374 9395
9375 /* Skip over glyphs not having an object at the start of the row. 9396 /* Skip over glyphs not having an object at the start of the row.
9376 These are special glyphs like truncation marks on terminal 9397 These are special glyphs like truncation marks on terminal
9382 { 9403 {
9383 x += glyph->pixel_width; 9404 x += glyph->pixel_width;
9384 ++glyph; 9405 ++glyph;
9385 } 9406 }
9386 9407
9408 string_start = NULL;
9387 while (glyph < end 9409 while (glyph < end
9388 && !INTEGERP (glyph->object) 9410 && !INTEGERP (glyph->object)
9389 && (!BUFFERP (glyph->object) 9411 && (!BUFFERP (glyph->object)
9390 || glyph->charpos < pt_old)) 9412 || (last_pos = glyph->charpos) < pt_old))
9391 { 9413 {
9392 x += glyph->pixel_width; 9414 if (! STRINGP (glyph->object))
9393 ++glyph; 9415 {
9416 string_start = NULL;
9417 x += glyph->pixel_width;
9418 ++glyph;
9419 }
9420 else
9421 {
9422 string_before_pos = last_pos;
9423 string_start = glyph;
9424 string_start_x = x;
9425 /* Skip all glyphs from string. */
9426 SKIP_GLYPHS (glyph, end, x, STRINGP (glyph->object));
9427 }
9428 }
9429
9430 if (string_start
9431 && (glyph == end || !BUFFERP (glyph->object) || last_pos > pt_old))
9432 {
9433 /* We may have skipped over point because the previous glyphs
9434 are from string. As there's no easy way to know the
9435 character position of the current glyph, find the correct
9436 glyph on point by scanning from string_start again. */
9437 Lisp_Object limit;
9438 Lisp_Object string;
9439 int pos;
9440
9441 limit = make_number (pt_old + 1);
9442 end = glyph;
9443 glyph = string_start;
9444 x = string_start_x;
9445 string = glyph->object;
9446 pos = string_buffer_position (w, string, string_before_pos);
9447 /* If STRING is from overlay, LAST_POS == 0. We skip such glyphs
9448 because we always put cursor after overlay strings. */
9449 while (pos == 0 && glyph < end)
9450 {
9451 string = glyph->object;
9452 SKIP_GLYPHS (glyph, end, x, EQ (glyph->object, string));
9453 if (glyph < end)
9454 pos = string_buffer_position (w, glyph->object, string_before_pos);
9455 }
9456
9457 while (glyph < end)
9458 {
9459 pos = XINT (Fnext_single_char_property_change
9460 (make_number (pos), Qdisplay, Qnil, limit));
9461 if (pos > pt_old)
9462 break;
9463 /* Skip glyphs from the same string. */
9464 string = glyph->object;
9465 SKIP_GLYPHS (glyph, end, x, EQ (glyph->object, string));
9466 /* Skip glyphs from an overlay. */
9467 while (glyph < end
9468 && ! string_buffer_position (w, glyph->object, pos))
9469 {
9470 string = glyph->object;
9471 SKIP_GLYPHS (glyph, end, x, EQ (glyph->object, string));
9472 }
9473 }
9394 } 9474 }
9395 9475
9396 w->cursor.hpos = glyph - row->glyphs[TEXT_AREA]; 9476 w->cursor.hpos = glyph - row->glyphs[TEXT_AREA];
9397 w->cursor.x = x; 9477 w->cursor.x = x;
9398 w->cursor.vpos = MATRIX_ROW_VPOS (row, matrix) + dvpos; 9478 w->cursor.vpos = MATRIX_ROW_VPOS (row, matrix) + dvpos;