comparison src/xdisp.c @ 90428:a8190f7e546e

Merge from emacs--devo--0 Patches applied: * emacs--devo--0 (patch 285-296) - Update from CVS - Merge from gnus--rel--5.10 - Update from CVS: admin/FOR-RELEASE: Update refcard section. * gnus--rel--5.10 (patch 102-104) - Update from CVS Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-64
author Miles Bader <miles@gnu.org>
date Wed, 07 Jun 2006 18:05:10 +0000
parents 4ee003f8531c 938915517680
children 138027c8c982
comparison
equal deleted inserted replaced
90427:ddb25860d044 90428:a8190f7e546e
1993 /* EXPORT: 1993 /* EXPORT:
1994 Return the position and height of the phys cursor in window W. 1994 Return the position and height of the phys cursor in window W.
1995 Set w->phys_cursor_width to width of phys cursor. 1995 Set w->phys_cursor_width to width of phys cursor.
1996 */ 1996 */
1997 1997
1998 int 1998 void
1999 get_phys_cursor_geometry (w, row, glyph, heightp) 1999 get_phys_cursor_geometry (w, row, glyph, xp, yp, heightp)
2000 struct window *w; 2000 struct window *w;
2001 struct glyph_row *row; 2001 struct glyph_row *row;
2002 struct glyph *glyph; 2002 struct glyph *glyph;
2003 int *heightp; 2003 int *xp, *yp, *heightp;
2004 { 2004 {
2005 struct frame *f = XFRAME (WINDOW_FRAME (w)); 2005 struct frame *f = XFRAME (WINDOW_FRAME (w));
2006 int y, wd, h, h0, y0; 2006 int x, y, wd, h, h0, y0;
2007 2007
2008 /* Compute the width of the rectangle to draw. If on a stretch 2008 /* Compute the width of the rectangle to draw. If on a stretch
2009 glyph, and `x-stretch-block-cursor' is nil, don't draw a 2009 glyph, and `x-stretch-block-cursor' is nil, don't draw a
2010 rectangle as wide as the glyph, but use a canonical character 2010 rectangle as wide as the glyph, but use a canonical character
2011 width instead. */ 2011 width instead. */
2012 wd = glyph->pixel_width - 1; 2012 wd = glyph->pixel_width - 1;
2013 #ifdef HAVE_NTGUI 2013 #ifdef HAVE_NTGUI
2014 wd++; /* Why? */ 2014 wd++; /* Why? */
2015 #endif 2015 #endif
2016
2017 x = w->phys_cursor.x;
2018 if (x < 0)
2019 {
2020 wd += x;
2021 x = 0;
2022 }
2023
2016 if (glyph->type == STRETCH_GLYPH 2024 if (glyph->type == STRETCH_GLYPH
2017 && !x_stretch_cursor_p) 2025 && !x_stretch_cursor_p)
2018 wd = min (FRAME_COLUMN_WIDTH (f), wd); 2026 wd = min (FRAME_COLUMN_WIDTH (f), wd);
2019 w->phys_cursor_width = wd; 2027 w->phys_cursor_width = wd;
2020 2028
2040 h += y - y0; 2048 h += y - y0;
2041 y = y0; 2049 y = y0;
2042 } 2050 }
2043 } 2051 }
2044 2052
2053 *xp = WINDOW_TEXT_TO_FRAME_PIXEL_X (w, x);
2054 *yp = WINDOW_TO_FRAME_PIXEL_Y (w, y);
2045 *heightp = h; 2055 *heightp = h;
2046 return WINDOW_TO_FRAME_PIXEL_Y (w, y);
2047 } 2056 }
2048 2057
2049 /* 2058 /*
2050 * Remember which glyph the mouse is over. 2059 * Remember which glyph the mouse is over.
2051 */ 2060 */
6332 { 6341 {
6333 it->what = IT_COMPOSITION; 6342 it->what = IT_COMPOSITION;
6334 it->position = (STRINGP (it->string) 6343 it->position = (STRINGP (it->string)
6335 ? it->current.string_pos 6344 ? it->current.string_pos
6336 : it->current.pos); 6345 : it->current.pos);
6346 if (STRINGP (it->string))
6347 it->object = it->string;
6337 return 1; 6348 return 1;
6338 } 6349 }
6339 6350
6340 6351
6341 6352
9606 so there's no need to check the face here. */ 9617 so there's no need to check the face here. */
9607 it->start_of_box_run_p = 1; 9618 it->start_of_box_run_p = 1;
9608 9619
9609 while (it->current_x < max_x) 9620 while (it->current_x < max_x)
9610 { 9621 {
9611 int x_before, x, n_glyphs_before, i, nglyphs; 9622 int x, n_glyphs_before, i, nglyphs;
9623 struct it it_before;
9612 9624
9613 /* Get the next display element. */ 9625 /* Get the next display element. */
9614 if (!get_next_display_element (it)) 9626 if (!get_next_display_element (it))
9615 { 9627 {
9616 /* Don't count empty row if we are counting needed tool-bar lines. */ 9628 /* Don't count empty row if we are counting needed tool-bar lines. */
9618 return; 9630 return;
9619 break; 9631 break;
9620 } 9632 }
9621 9633
9622 /* Produce glyphs. */ 9634 /* Produce glyphs. */
9623 x_before = it->current_x; 9635 n_glyphs_before = row->used[TEXT_AREA];
9624 n_glyphs_before = it->glyph_row->used[TEXT_AREA]; 9636 it_before = *it;
9637
9625 PRODUCE_GLYPHS (it); 9638 PRODUCE_GLYPHS (it);
9626 9639
9627 nglyphs = it->glyph_row->used[TEXT_AREA] - n_glyphs_before; 9640 nglyphs = row->used[TEXT_AREA] - n_glyphs_before;
9628 i = 0; 9641 i = 0;
9629 x = x_before; 9642 x = it_before.current_x;
9630 while (i < nglyphs) 9643 while (i < nglyphs)
9631 { 9644 {
9632 struct glyph *glyph = row->glyphs[TEXT_AREA] + n_glyphs_before + i; 9645 struct glyph *glyph = row->glyphs[TEXT_AREA] + n_glyphs_before + i;
9633 9646
9634 if (x + glyph->pixel_width > max_x) 9647 if (x + glyph->pixel_width > max_x)
9635 { 9648 {
9636 /* Glyph doesn't fit on line. */ 9649 /* Glyph doesn't fit on line. Backtrack. */
9637 it->glyph_row->used[TEXT_AREA] = n_glyphs_before + i; 9650 row->used[TEXT_AREA] = n_glyphs_before;
9638 it->current_x = x; 9651 *it = it_before;
9639 goto out; 9652 goto out;
9640 } 9653 }
9641 9654
9642 ++it->hpos; 9655 ++it->hpos;
9643 x += glyph->pixel_width; 9656 x += glyph->pixel_width;
9664 last->left_box_line_p = 1; 9677 last->left_box_line_p = 1;
9665 9678
9666 /* Make line the desired height and center it vertically. */ 9679 /* Make line the desired height and center it vertically. */
9667 if ((height -= it->max_ascent + it->max_descent) > 0) 9680 if ((height -= it->max_ascent + it->max_descent) > 0)
9668 { 9681 {
9682 /* Don't add more than one line height. */
9683 height %= FRAME_LINE_HEIGHT (it->f);
9669 it->max_ascent += height / 2; 9684 it->max_ascent += height / 2;
9670 it->max_descent += (height + 1) / 2; 9685 it->max_descent += (height + 1) / 2;
9671 } 9686 }
9672 9687
9673 compute_line_metrics (it); 9688 compute_line_metrics (it);
11711 while ((glyph) < (end) && (condition)) 11726 while ((glyph) < (end) && (condition))
11712 11727
11713 11728
11714 /* Set cursor position of W. PT is assumed to be displayed in ROW. 11729 /* Set cursor position of W. PT is assumed to be displayed in ROW.
11715 DELTA is the number of bytes by which positions recorded in ROW 11730 DELTA is the number of bytes by which positions recorded in ROW
11716 differ from current buffer positions. */ 11731 differ from current buffer positions.
11717 11732
11718 void 11733 Return 0 if cursor is not on this row. 1 otherwise. */
11734
11735 int
11719 set_cursor_from_row (w, row, matrix, delta, delta_bytes, dy, dvpos) 11736 set_cursor_from_row (w, row, matrix, delta, delta_bytes, dy, dvpos)
11720 struct window *w; 11737 struct window *w;
11721 struct glyph_row *row; 11738 struct glyph_row *row;
11722 struct glyph_matrix *matrix; 11739 struct glyph_matrix *matrix;
11723 int delta, delta_bytes, dy, dvpos; 11740 int delta, delta_bytes, dy, dvpos;
11863 { 11880 {
11864 string = glyph->object; 11881 string = glyph->object;
11865 SKIP_GLYPHS (glyph, end, x, EQ (glyph->object, string)); 11882 SKIP_GLYPHS (glyph, end, x, EQ (glyph->object, string));
11866 } 11883 }
11867 } 11884 }
11885
11886 /* If we reached the end of the line, and end was from a string,
11887 cursor is not on this line. */
11888 if (glyph == end && row->continued_p)
11889 return 0;
11868 } 11890 }
11869 11891
11870 w->cursor.hpos = glyph - row->glyphs[TEXT_AREA]; 11892 w->cursor.hpos = glyph - row->glyphs[TEXT_AREA];
11871 w->cursor.x = x; 11893 w->cursor.x = x;
11872 w->cursor.vpos = MATRIX_ROW_VPOS (row, matrix) + dvpos; 11894 w->cursor.vpos = MATRIX_ROW_VPOS (row, matrix) + dvpos;
11896 this_line_start_x = row->x; 11918 this_line_start_x = row->x;
11897 } 11919 }
11898 else 11920 else
11899 CHARPOS (this_line_start_pos) = 0; 11921 CHARPOS (this_line_start_pos) = 0;
11900 } 11922 }
11923
11924 return 1;
11901 } 11925 }
11902 11926
11903 11927
11904 /* Run window scroll functions, if any, for WINDOW with new window 11928 /* Run window scroll functions, if any, for WINDOW with new window
11905 start STARTP. Sets the window start of WINDOW to that position. 11929 start STARTP. Sets the window start of WINDOW to that position.
12579 } 12603 }
12580 else if (scroll_p) 12604 else if (scroll_p)
12581 rc = CURSOR_MOVEMENT_MUST_SCROLL; 12605 rc = CURSOR_MOVEMENT_MUST_SCROLL;
12582 else 12606 else
12583 { 12607 {
12584 set_cursor_from_row (w, row, w->current_matrix, 0, 0, 0, 0); 12608 do
12585 rc = CURSOR_MOVEMENT_SUCCESS; 12609 {
12610 if (set_cursor_from_row (w, row, w->current_matrix, 0, 0, 0, 0))
12611 {
12612 rc = CURSOR_MOVEMENT_SUCCESS;
12613 break;
12614 }
12615 ++row;
12616 }
12617 while (MATRIX_ROW_BOTTOM_Y (row) < last_y
12618 && MATRIX_ROW_START_CHARPOS (row) == PT
12619 && cursor_row_p (w, row));
12586 } 12620 }
12587 } 12621 }
12588 } 12622 }
12589 12623
12590 return rc; 12624 return rc;
15028 : (STRINGP (glyph->object) 15062 : (STRINGP (glyph->object)
15029 ? 'S' 15063 ? 'S'
15030 : '-')), 15064 : '-')),
15031 glyph->pixel_width, 15065 glyph->pixel_width,
15032 glyph->u.img_id, 15066 glyph->u.img_id,
15067 '.',
15068 glyph->face_id,
15069 glyph->left_box_line_p,
15070 glyph->right_box_line_p);
15071 }
15072 else if (glyph->type == COMPOSITE_GLYPH)
15073 {
15074 fprintf (stderr,
15075 " %5d %4c %6d %c %3d 0x%05x %c %4d %1.1d%1.1d\n",
15076 glyph - row->glyphs[TEXT_AREA],
15077 '+',
15078 glyph->charpos,
15079 (BUFFERP (glyph->object)
15080 ? 'B'
15081 : (STRINGP (glyph->object)
15082 ? 'S'
15083 : '-')),
15084 glyph->pixel_width,
15085 glyph->u.cmp_id,
15033 '.', 15086 '.',
15034 glyph->face_id, 15087 glyph->face_id,
15035 glyph->left_box_line_p, 15088 glyph->left_box_line_p,
15036 glyph->right_box_line_p); 15089 glyph->right_box_line_p);
15037 } 15090 }
21601 mouse_face_here_p = 1; 21654 mouse_face_here_p = 1;
21602 21655
21603 /* Maybe clear the display under the cursor. */ 21656 /* Maybe clear the display under the cursor. */
21604 if (w->phys_cursor_type == HOLLOW_BOX_CURSOR) 21657 if (w->phys_cursor_type == HOLLOW_BOX_CURSOR)
21605 { 21658 {
21606 int x, y; 21659 int x, y, left_x;
21607 int header_line_height = WINDOW_HEADER_LINE_HEIGHT (w); 21660 int header_line_height = WINDOW_HEADER_LINE_HEIGHT (w);
21608 int width; 21661 int width;
21609 21662
21610 cursor_glyph = get_phys_cursor_glyph (w); 21663 cursor_glyph = get_phys_cursor_glyph (w);
21611 if (cursor_glyph == NULL) 21664 if (cursor_glyph == NULL)
21612 goto mark_cursor_off; 21665 goto mark_cursor_off;
21613 21666
21614 x = WINDOW_TEXT_TO_FRAME_PIXEL_X (w, w->phys_cursor.x); 21667 width = cursor_glyph->pixel_width;
21668 left_x = window_box_left_offset (w, TEXT_AREA);
21669 x = w->phys_cursor.x;
21670 if (x < left_x)
21671 width -= left_x - x;
21672 width = min (width, window_box_width (w, TEXT_AREA) - x);
21615 y = WINDOW_TO_FRAME_PIXEL_Y (w, max (header_line_height, cursor_row->y)); 21673 y = WINDOW_TO_FRAME_PIXEL_Y (w, max (header_line_height, cursor_row->y));
21616 width = min (cursor_glyph->pixel_width, 21674 x = WINDOW_TEXT_TO_FRAME_PIXEL_X (w, max (x, left_x));
21617 window_box_width (w, TEXT_AREA) - w->phys_cursor.x); 21675
21618 21676 if (width > 0)
21619 rif->clear_frame_area (f, x, y, width, cursor_row->visible_height); 21677 rif->clear_frame_area (f, x, y, width, cursor_row->visible_height);
21620 } 21678 }
21621 21679
21622 /* Erase the cursor by redrawing the character underneath it. */ 21680 /* Erase the cursor by redrawing the character underneath it. */
21623 if (mouse_face_here_p) 21681 if (mouse_face_here_p)