comparison src/xterm.c @ 39434:a6b7de61a863

(fast_find_position) [0]: Add a presumably more correct version for after 21.1.
author Gerd Moellmann <gerd@gnu.org>
date Tue, 25 Sep 2001 10:12:34 +0000
parents 25e3c643b1f2
children 5f9f7d59fd79
comparison
equal deleted inserted replaced
39433:65168fc5a6f5 39434:a6b7de61a863
7491 help_echo = AREF (f->tool_bar_items, prop_idx + TOOL_BAR_ITEM_CAPTION); 7491 help_echo = AREF (f->tool_bar_items, prop_idx + TOOL_BAR_ITEM_CAPTION);
7492 } 7492 }
7493 7493
7494 7494
7495 7495
7496 /* Find the glyph matrix position of buffer position POS in window W. 7496 /* Find the glyph matrix position of buffer position CHARPOS in window
7497 *HPOS, *VPOS, *X, and *Y are set to the positions found. W's 7497 *W. HPOS, *VPOS, *X, and *Y are set to the positions found. W's
7498 current glyphs must be up to date. If POS is above window start 7498 current glyphs must be up to date. If CHARPOS is above window
7499 return (0, 0, 0, 0). If POS is after end of W, return end of 7499 start return (0, 0, 0, 0). If CHARPOS is after end of W, return end
7500 last line in W. In the row containing POS, stop before glyphs 7500 of last line in W. In the row containing CHARPOS, stop before glyphs
7501 having STOP as object. */ 7501 having STOP as object. */
7502
7503 #if 0 /* This is a version of fast_find_position that's more correct
7504 in the presence of hscrolling, for example. I didn't install
7505 it right away because the problem fixed is minor, it failed
7506 in 20.x as well, and I think it's too risky to install
7507 so near the release of 21.1. 2001-09-25 gerd. */
7508
7509 static int
7510 fast_find_position (w, charpos, hpos, vpos, x, y, stop)
7511 struct window *w;
7512 int charpos;
7513 int *hpos, *vpos, *x, *y;
7514 Lisp_Object stop;
7515 {
7516 struct glyph_row *row, *first;
7517 struct glyph *glyph, *end;
7518 int i, past_end = 0;
7519
7520 first = MATRIX_FIRST_TEXT_ROW (w->current_matrix);
7521 row = row_containing_pos (w, charpos, first, NULL);
7522 if (row == NULL)
7523 {
7524 if (charpos < MATRIX_ROW_START_CHARPOS (first))
7525 {
7526 *x = *y = *hpos = *vpos = 0;
7527 return 0;
7528 }
7529 else
7530 {
7531 row = MATRIX_ROW (w->current_matrix, XFASTINT (w->window_end_vpos));
7532 past_end = 1;
7533 }
7534 }
7535
7536 *x = row->x;
7537 *y = row->y;
7538 *vpos = MATRIX_ROW_VPOS (row, w->current_matrix);
7539
7540 glyph = row->glyphs[TEXT_AREA];
7541 end = glyph + row->used[TEXT_AREA];
7542
7543 /* Skip over glyphs not having an object at the start of the row.
7544 These are special glyphs like truncation marks on terminal
7545 frames. */
7546 if (row->displays_text_p)
7547 while (glyph < end
7548 && INTEGERP (glyph->object)
7549 && !EQ (stop, glyph->object)
7550 && glyph->charpos < 0)
7551 {
7552 *x += glyph->pixel_width;
7553 ++glyph;
7554 }
7555
7556 while (glyph < end
7557 && !INTEGERP (glyph->object)
7558 && !EQ (stop, glyph->object)
7559 && (!BUFFERP (glyph->object)
7560 || glyph->charpos < charpos))
7561 {
7562 *x += glyph->pixel_width;
7563 ++glyph;
7564 }
7565
7566 *hpos = glyph - row->glyphs[TEXT_AREA];
7567 return past_end;
7568 }
7569
7570 #else /* not 0 */
7502 7571
7503 static int 7572 static int
7504 fast_find_position (w, pos, hpos, vpos, x, y, stop) 7573 fast_find_position (w, pos, hpos, vpos, x, y, stop)
7505 struct window *w; 7574 struct window *w;
7506 int pos; 7575 int pos;
7593 *hpos = lastcol + 1; 7662 *hpos = lastcol + 1;
7594 *x = current_x; 7663 *x = current_x;
7595 *y = best_row->y; 7664 *y = best_row->y;
7596 return 0; 7665 return 0;
7597 } 7666 }
7667
7668 #endif /* not 0 */
7598 7669
7599 7670
7600 /* Find the position of the the glyph for position POS in OBJECT in 7671 /* Find the position of the the glyph for position POS in OBJECT in
7601 window W's current matrix, and return in *X/*Y the pixel 7672 window W's current matrix, and return in *X/*Y the pixel
7602 coordinates, and return in *HPOS/*VPOS the column/row of the glyph. 7673 coordinates, and return in *HPOS/*VPOS the column/row of the glyph.