comparison src/xterm.c @ 40303:a725c601ef70

(show_mouse_face): Clean up. Recognize overwritten cursor differently.
author Gerd Moellmann <gerd@gnu.org>
date Thu, 25 Oct 2001 12:58:15 +0000
parents 44df655be97a
children c1762ce8905b
comparison
equal deleted inserted replaced
40302:c96b651c8c8e 40303:a725c601ef70
7720 struct x_display_info *dpyinfo; 7720 struct x_display_info *dpyinfo;
7721 enum draw_glyphs_face draw; 7721 enum draw_glyphs_face draw;
7722 { 7722 {
7723 struct window *w = XWINDOW (dpyinfo->mouse_face_window); 7723 struct window *w = XWINDOW (dpyinfo->mouse_face_window);
7724 struct frame *f = XFRAME (WINDOW_FRAME (w)); 7724 struct frame *f = XFRAME (WINDOW_FRAME (w));
7725 int i; 7725
7726 int cursor_off_p = 0; 7726 if (/* If window is in the process of being destroyed, don't bother
7727 struct cursor_pos saved_cursor; 7727 to do anything. */
7728 7728 w->current_matrix != NULL
7729 saved_cursor = output_cursor; 7729 /* Recognize when we are called to operate on rows that don't exist
7730 7730 anymore. This can happen when a window is split. */
7731 /* If window is in the process of being destroyed, don't bother 7731 && dpyinfo->mouse_face_end_row < w->current_matrix->nrows)
7732 to do anything. */ 7732 {
7733 if (w->current_matrix == NULL) 7733 int phys_cursor_on_p = w->phys_cursor_on_p;
7734 goto set_x_cursor; 7734 struct glyph_row *row, *first, *last;
7735 7735
7736 /* Recognize when we are called to operate on rows that don't exist 7736 first = MATRIX_ROW (w->current_matrix, dpyinfo->mouse_face_beg_row);
7737 anymore. This can happen when a window is split. */ 7737 last = MATRIX_ROW (w->current_matrix, dpyinfo->mouse_face_end_row);
7738 if (dpyinfo->mouse_face_end_row >= w->current_matrix->nrows) 7738
7739 goto set_x_cursor; 7739 for (row = first; row <= last && row->enabled_p; ++row)
7740
7741 set_output_cursor (&w->phys_cursor);
7742
7743 /* Note that mouse_face_beg_row etc. are window relative. */
7744 for (i = dpyinfo->mouse_face_beg_row;
7745 i <= dpyinfo->mouse_face_end_row;
7746 i++)
7747 {
7748 int start_hpos, end_hpos, start_x;
7749 struct glyph_row *row = MATRIX_ROW (w->current_matrix, i);
7750
7751 /* Don't do anything if row doesn't have valid contents. */
7752 if (!row->enabled_p)
7753 continue;
7754
7755 /* For all but the first row, the highlight starts at column 0. */
7756 if (i == dpyinfo->mouse_face_beg_row)
7757 { 7740 {
7758 start_hpos = dpyinfo->mouse_face_beg_col; 7741 int start_hpos, end_hpos, start_x;
7759 start_x = dpyinfo->mouse_face_beg_x; 7742
7743 /* For all but the first row, the highlight starts at column 0. */
7744 if (row == first)
7745 {
7746 start_hpos = dpyinfo->mouse_face_beg_col;
7747 start_x = dpyinfo->mouse_face_beg_x;
7748 }
7749 else
7750 {
7751 start_hpos = 0;
7752 start_x = 0;
7753 }
7754
7755 if (row == last)
7756 end_hpos = dpyinfo->mouse_face_end_col;
7757 else
7758 end_hpos = row->used[TEXT_AREA];
7759
7760 if (end_hpos > start_hpos)
7761 {
7762 x_draw_glyphs (w, start_x, row, TEXT_AREA,
7763 start_hpos, end_hpos, draw, 0);
7764
7765 row->mouse_face_p = draw == DRAW_MOUSE_FACE || DRAW_IMAGE_RAISED;
7766 }
7760 } 7767 }
7761 else 7768
7762 { 7769 /* When we've written over the cursor, arrange for it to
7763 start_hpos = 0; 7770 be displayed again. */
7764 start_x = 0; 7771 if (phys_cursor_on_p && !w->phys_cursor_on_p)
7765 } 7772 x_display_cursor (w, 1,
7766 7773 w->phys_cursor.hpos, w->phys_cursor.vpos,
7767 if (i == dpyinfo->mouse_face_end_row) 7774 w->phys_cursor.x, w->phys_cursor.y);
7768 end_hpos = dpyinfo->mouse_face_end_col; 7775 }
7769 else 7776
7770 end_hpos = row->used[TEXT_AREA];
7771
7772 /* If the cursor's in the text we are about to rewrite, turn the
7773 cursor off. */
7774 if (!w->pseudo_window_p
7775 && i == output_cursor.vpos
7776 && output_cursor.hpos >= start_hpos - 1
7777 && output_cursor.hpos <= end_hpos)
7778 {
7779 x_update_window_cursor (w, 0);
7780 cursor_off_p = 1;
7781 }
7782
7783 if (end_hpos > start_hpos)
7784 {
7785 x_draw_glyphs (w, start_x, row, TEXT_AREA,
7786 start_hpos, end_hpos, draw, 0);
7787 row->mouse_face_p = draw == DRAW_MOUSE_FACE || DRAW_IMAGE_RAISED;
7788 }
7789 }
7790
7791 /* If we turned the cursor off, turn it back on. */
7792 if (cursor_off_p)
7793 x_display_cursor (w, 1,
7794 output_cursor.hpos, output_cursor.vpos,
7795 output_cursor.x, output_cursor.y);
7796
7797 output_cursor = saved_cursor;
7798
7799 set_x_cursor:
7800
7801 /* Change the mouse cursor. */ 7777 /* Change the mouse cursor. */
7802 if (draw == DRAW_NORMAL_TEXT) 7778 if (draw == DRAW_NORMAL_TEXT)
7803 XDefineCursor (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), 7779 XDefineCursor (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
7804 f->output_data.x->text_cursor); 7780 f->output_data.x->text_cursor);
7805 else if (draw == DRAW_MOUSE_FACE) 7781 else if (draw == DRAW_MOUSE_FACE)