diff options
| author | Gerd Moellmann | 2001-10-25 12:58:15 +0000 |
|---|---|---|
| committer | Gerd Moellmann | 2001-10-25 12:58:15 +0000 |
| commit | b2bbd50940527352aed8ee636350b7b3a71e808b (patch) | |
| tree | b93989eadbe983d79f7908d326ca663121598fd5 | |
| parent | a56adac533a3ba198b5e56ed48d1273747e146e0 (diff) | |
| download | emacs-b2bbd50940527352aed8ee636350b7b3a71e808b.tar.gz emacs-b2bbd50940527352aed8ee636350b7b3a71e808b.zip | |
(show_mouse_face): Clean up. Recognize overwritten
cursor differently.
| -rw-r--r-- | src/xterm.c | 108 |
1 files changed, 42 insertions, 66 deletions
diff --git a/src/xterm.c b/src/xterm.c index 11a8e07bc4a..d23593e3d2a 100644 --- a/src/xterm.c +++ b/src/xterm.c | |||
| @@ -7722,82 +7722,58 @@ show_mouse_face (dpyinfo, 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; | ||
| 7726 | int cursor_off_p = 0; | ||
| 7727 | struct cursor_pos saved_cursor; | ||
| 7728 | |||
| 7729 | saved_cursor = output_cursor; | ||
| 7730 | |||
| 7731 | /* If window is in the process of being destroyed, don't bother | ||
| 7732 | to do anything. */ | ||
| 7733 | if (w->current_matrix == NULL) | ||
| 7734 | goto set_x_cursor; | ||
| 7735 | 7725 | ||
| 7736 | /* Recognize when we are called to operate on rows that don't exist | 7726 | if (/* If window is in the process of being destroyed, don't bother |
| 7737 | anymore. This can happen when a window is split. */ | 7727 | to do anything. */ |
| 7738 | if (dpyinfo->mouse_face_end_row >= w->current_matrix->nrows) | 7728 | w->current_matrix != NULL |
| 7739 | goto set_x_cursor; | 7729 | /* Recognize when we are called to operate on rows that don't exist |
| 7740 | 7730 | anymore. This can happen when a window is split. */ | |
| 7741 | set_output_cursor (&w->phys_cursor); | 7731 | && dpyinfo->mouse_face_end_row < w->current_matrix->nrows) |
| 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 | { | 7732 | { |
| 7748 | int start_hpos, end_hpos, start_x; | 7733 | int phys_cursor_on_p = w->phys_cursor_on_p; |
| 7749 | struct glyph_row *row = MATRIX_ROW (w->current_matrix, i); | 7734 | struct glyph_row *row, *first, *last; |
| 7750 | |||
| 7751 | /* Don't do anything if row doesn't have valid contents. */ | ||
| 7752 | if (!row->enabled_p) | ||
| 7753 | continue; | ||
| 7754 | 7735 | ||
| 7755 | /* For all but the first row, the highlight starts at column 0. */ | 7736 | first = MATRIX_ROW (w->current_matrix, dpyinfo->mouse_face_beg_row); |
| 7756 | if (i == dpyinfo->mouse_face_beg_row) | 7737 | last = MATRIX_ROW (w->current_matrix, dpyinfo->mouse_face_end_row); |
| 7757 | { | 7738 | |
| 7758 | start_hpos = dpyinfo->mouse_face_beg_col; | 7739 | for (row = first; row <= last && row->enabled_p; ++row) |
| 7759 | start_x = dpyinfo->mouse_face_beg_x; | ||
| 7760 | } | ||
| 7761 | else | ||
| 7762 | { | 7740 | { |
| 7763 | start_hpos = 0; | 7741 | int start_hpos, end_hpos, start_x; |
| 7764 | start_x = 0; | ||
| 7765 | } | ||
| 7766 | 7742 | ||
| 7767 | if (i == dpyinfo->mouse_face_end_row) | 7743 | /* For all but the first row, the highlight starts at column 0. */ |
| 7768 | end_hpos = dpyinfo->mouse_face_end_col; | 7744 | if (row == first) |
| 7769 | else | 7745 | { |
| 7770 | end_hpos = row->used[TEXT_AREA]; | 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 | } | ||
| 7771 | 7754 | ||
| 7772 | /* If the cursor's in the text we are about to rewrite, turn the | 7755 | if (row == last) |
| 7773 | cursor off. */ | 7756 | end_hpos = dpyinfo->mouse_face_end_col; |
| 7774 | if (!w->pseudo_window_p | 7757 | else |
| 7775 | && i == output_cursor.vpos | 7758 | end_hpos = row->used[TEXT_AREA]; |
| 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 | 7759 | ||
| 7783 | if (end_hpos > start_hpos) | 7760 | if (end_hpos > start_hpos) |
| 7784 | { | 7761 | { |
| 7785 | x_draw_glyphs (w, start_x, row, TEXT_AREA, | 7762 | x_draw_glyphs (w, start_x, row, TEXT_AREA, |
| 7786 | start_hpos, end_hpos, draw, 0); | 7763 | start_hpos, end_hpos, draw, 0); |
| 7787 | row->mouse_face_p = draw == DRAW_MOUSE_FACE || DRAW_IMAGE_RAISED; | ||
| 7788 | } | ||
| 7789 | } | ||
| 7790 | 7764 | ||
| 7791 | /* If we turned the cursor off, turn it back on. */ | 7765 | row->mouse_face_p = draw == DRAW_MOUSE_FACE || DRAW_IMAGE_RAISED; |
| 7792 | if (cursor_off_p) | 7766 | } |
| 7793 | x_display_cursor (w, 1, | 7767 | } |
| 7794 | output_cursor.hpos, output_cursor.vpos, | ||
| 7795 | output_cursor.x, output_cursor.y); | ||
| 7796 | 7768 | ||
| 7797 | output_cursor = saved_cursor; | 7769 | /* When we've written over the cursor, arrange for it to |
| 7770 | be displayed again. */ | ||
| 7771 | if (phys_cursor_on_p && !w->phys_cursor_on_p) | ||
| 7772 | x_display_cursor (w, 1, | ||
| 7773 | w->phys_cursor.hpos, w->phys_cursor.vpos, | ||
| 7774 | w->phys_cursor.x, w->phys_cursor.y); | ||
| 7775 | } | ||
| 7798 | 7776 | ||
| 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), |