diff options
| author | Eli Zaretskii | 2010-11-06 10:28:31 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2010-11-06 10:28:31 +0200 |
| commit | c1fc2d3a9c511d6893dfb919f543d747913d1539 (patch) | |
| tree | 26330a31c1cf115f35c919c17ee3309d36fb9ce5 /src/term.c | |
| parent | 6e373c1afbf1d95475bc9cbc191f0bf646c30360 (diff) | |
| parent | 0a56722656b17dd7ef87009d646be9304c8ef83e (diff) | |
| download | emacs-c1fc2d3a9c511d6893dfb919f543d747913d1539.tar.gz emacs-c1fc2d3a9c511d6893dfb919f543d747913d1539.zip | |
Unify mouse-highlight code for all GUI and TTY sessions.
term.c: Remove static mouse_face_* variables. All users
changed.
(term_show_mouse_face, term_clear_mouse_face)
(fast_find_position, term_mouse_highlight): Functions deleted.
(tty_draw_row_with_mouse_face): New function.
(term_mouse_movement): Call note_mouse_highlight instead of
term_mouse_highlight.
nsterm.m (ns_update_window_begin, ns_update_window_end)
(ns_update_end, x_destroy_window, ns_frame_up_to_date)
(ns_dumpglyphs_box_or_relief, ns_maybe_dumpglyphs_background)
(ns_dumpglyphs_image, ns_dumpglyphs_stretch)
(ns_initialize_display_info, keyDown, mouseMoved, mouseExited):
Replace Display_Info with Mouse_HLInfo everywhere where
mouse_face_* members were accessed for mouse highlight purposes.
xterm.c (x_update_window_begin, x_update_window_end)
(x_update_end, XTframe_up_to_date, x_set_mouse_face_gc)
(handle_one_xevent, x_free_frame_resources, x_term_init): Replace
Display_Info with Mouse_HLInfo everywhere where mouse_face_*
members were accessed for mouse highlight purposes.
w32term.c (x_update_window_begin, x_update_window_end)
(x_update_end, w32_read_socket, x_free_frame_resources)
(w32_initialize_display_info): Replace Display_Info with
Mouse_HLInfo everywhere where mouse_face_* members were accessed
for mouse highlight purposes.
xdisp.c (show_mouse_face, note_mode_line_or_margin_highlight)
(note_mouse_highlight) [HAVE_WINDOW_SYSTEM]: Don't run GUI code
unless the frame is on a window-system.
(get_tool_bar_item, handle_tool_bar_click)
(note_tool_bar_highlight, draw_glyphs, erase_phys_cursor)
(show_mouse_face, clear_mouse_face, coords_in_mouse_face_p)
(note_mode_line_or_margin_highlight, note_mouse_highlight)
(x_clear_window_mouse_face, cancel_mouse_face, expose_frame):
Replace Display_Info with Mouse_HLInfo everywhere where
mouse_face_* members were accessed for mouse highlight purposes.
(coords_in_mouse_face_p): Move prototype out of the
HAVE_WINDOW_SYSTEM conditional.
(x_y_to_hpos_vpos, frame_to_window_pixel_xy): Move out of the
HAVE_WINDOW_SYSTEM block.
(try_window_id) [HAVE_GPM || MSDOS]: Call
x_clear_window_mouse_face.
(draw_row_with_mouse_face): Implementation for HAVE_WINDOW_SYSTEM
systems. Call tty_draw_row_with_mouse_face for TTY systems.
(show_mouse_face): Call draw_row_with_mouse_face, instead of
calling draw_glyphs directly.
(show_mouse_face, clear_mouse_face, coords_in_mouse_face_p)
(cursor_in_mouse_face_p, rows_from_pos_range)
(mouse_face_from_buffer_pos, mouse_face_from_string_pos)
(note_mode_line_or_margin_highlight, note_mouse_highlight)
(x_clear_window_mouse_face, cancel_mouse_face): Move out of the
HAVE_WINDOW_SYSTEM block. Ifdef away window-system specific
fragments.
(note_mouse_highlight): Call popup_activated for MSDOS as well.
Clear mouse highlight if pointer is over glyphs whose OBJECT is an
integer.
(mouse_face_from_buffer_pos): Add parentheses around && within ||.
(x_consider_frame_title, tool_bar_lines_needed): Move
prototypes to HAVE_WINDOW_SYSTEM-only part.
(get_window_cursor_type): Move inside a HAVE_WINDOW_SYSTEM-only
part. Remove "#ifdef HAVE_WINDOW_SYSTEM" from body of function.
(null_glyph_slice): Move declaration into HAVE_WINDOW_SYSTEM-only
part.
dispnew.c (mirror_make_current): Set Y coordinate of the
mode-line and header-line rows.
(init_display): Setup initial frame's output_data for text
terminal frames.
xmenu.c (popup_activated): Don't define on MSDOS, which now has
its own definition on msdos.c.
msdos.c (show_mouse_face, clear_mouse_face)
(fast_find_position, IT_note_mode_line_highlight)
(IT_note_mouse_highlight): Functions deleted.
(IT_frame_up_to_date, dos_rawgetc): Call note_mouse_highlight
instead of IT_note_mouse_highlight.
(draw_row_with_mouse_face, popup_activated): New functions.
(dos_set_window_size, draw_row_with_mouse_face, IT_update_begin)
(IT_update_end, IT_frame_up_to_date, internal_terminal_init)
(dos_rawgetc): Replace Display_Info with Mouse_HLInfo everywhere
where mouse_face_* members were accessed for mouse highlight
purposes.
msdos.h (initialize_msdos_display): Add prototype.
frame.h (MOUSE_HL_INFO): New macro.
lisp.h (Mouse_HLInfo): New data type.
xterm.h (struct x_display_info):
w32term.h (struct w32_display_info):
nsterm.h (struct ns_display_info):
termchar.h (struct tty_display_info): Use it instead of
mouse_face_* members.
dispextern.h (show_mouse_face, clear_mouse_face): Update type of
1st argument.
(frame_to_window_pixel_xy, note_mouse_highlight)
(x_clear_window_mouse_face, cancel_mouse_face, clear_mouse_face)
(show_mouse_face, cursor_in_mouse_face_p): Move prototypes out of
HAVE_WINDOW_SYSTEM conditional.
(draw_row_with_mouse_face): Declare prototype.
(tty_draw_row_with_mouse_face): Declare prototype.
Diffstat (limited to 'src/term.c')
| -rw-r--r-- | src/term.c | 448 |
1 files changed, 26 insertions, 422 deletions
diff --git a/src/term.c b/src/term.c index 9bc980a4aa8..dbbdc03f190 100644 --- a/src/term.c +++ b/src/term.c | |||
| @@ -184,24 +184,10 @@ extern char *tgetstr (char *, char **); | |||
| 184 | #ifdef HAVE_GPM | 184 | #ifdef HAVE_GPM |
| 185 | #include <sys/fcntl.h> | 185 | #include <sys/fcntl.h> |
| 186 | 186 | ||
| 187 | static void term_clear_mouse_face (void); | ||
| 188 | static void term_mouse_highlight (struct frame *f, int x, int y); | ||
| 189 | |||
| 190 | /* The device for which we have enabled gpm support (or NULL). */ | 187 | /* The device for which we have enabled gpm support (or NULL). */ |
| 191 | struct tty_display_info *gpm_tty = NULL; | 188 | struct tty_display_info *gpm_tty = NULL; |
| 192 | 189 | ||
| 193 | /* These variables describe the range of text currently shown in its | 190 | /* Last recorded mouse coordinates. */ |
| 194 | mouse-face, together with the window they apply to. As long as | ||
| 195 | the mouse stays within this range, we need not redraw anything on | ||
| 196 | its account. Rows and columns are glyph matrix positions in | ||
| 197 | MOUSE_FACE_WINDOW. */ | ||
| 198 | static int mouse_face_beg_row, mouse_face_beg_col; | ||
| 199 | static int mouse_face_end_row, mouse_face_end_col; | ||
| 200 | static int mouse_face_past_end; | ||
| 201 | static Lisp_Object mouse_face_window; | ||
| 202 | static int mouse_face_face_id; | ||
| 203 | |||
| 204 | static int pos_x, pos_y; | ||
| 205 | static int last_mouse_x, last_mouse_y; | 191 | static int last_mouse_x, last_mouse_y; |
| 206 | #endif /* HAVE_GPM */ | 192 | #endif /* HAVE_GPM */ |
| 207 | 193 | ||
| @@ -2686,416 +2672,36 @@ term_mouse_moveto (int x, int y) | |||
| 2686 | last_mouse_y = y; */ | 2672 | last_mouse_y = y; */ |
| 2687 | } | 2673 | } |
| 2688 | 2674 | ||
| 2689 | static void | 2675 | /* Implementation of draw_row_with_mouse_face for TTY/GPM. */ |
| 2690 | term_show_mouse_face (enum draw_glyphs_face draw) | 2676 | void |
| 2677 | tty_draw_row_with_mouse_face (struct window *w, struct glyph_row *row, | ||
| 2678 | int start_hpos, int end_hpos, | ||
| 2679 | enum draw_glyphs_face draw) | ||
| 2691 | { | 2680 | { |
| 2692 | struct window *w = XWINDOW (mouse_face_window); | 2681 | int nglyphs = end_hpos - start_hpos; |
| 2693 | int save_x, save_y; | 2682 | struct frame *f = XFRAME (WINDOW_FRAME (w)); |
| 2694 | int i; | ||
| 2695 | |||
| 2696 | struct frame *f = XFRAME (w->frame); | ||
| 2697 | struct tty_display_info *tty = FRAME_TTY (f); | 2683 | struct tty_display_info *tty = FRAME_TTY (f); |
| 2684 | int face_id = tty->mouse_highlight.mouse_face_face_id; | ||
| 2685 | int save_x, save_y, pos_x, pos_y; | ||
| 2698 | 2686 | ||
| 2699 | if (/* If window is in the process of being destroyed, don't bother | 2687 | if (end_hpos >= row->used[TEXT_AREA]) |
| 2700 | to do anything. */ | 2688 | nglyphs = row->used[TEXT_AREA] - start_hpos; |
| 2701 | w->current_matrix != NULL | ||
| 2702 | /* Recognize when we are called to operate on rows that don't exist | ||
| 2703 | anymore. This can happen when a window is split. */ | ||
| 2704 | && mouse_face_end_row < w->current_matrix->nrows) | ||
| 2705 | { | ||
| 2706 | /* write_glyphs writes at cursor position, so we need to | ||
| 2707 | temporarily move cursor coordinates to the beginning of | ||
| 2708 | the highlight region. */ | ||
| 2709 | |||
| 2710 | /* Save current cursor co-ordinates */ | ||
| 2711 | save_y = curY (tty); | ||
| 2712 | save_x = curX (tty); | ||
| 2713 | |||
| 2714 | /* Note that mouse_face_beg_row etc. are window relative. */ | ||
| 2715 | for (i = mouse_face_beg_row; i <= mouse_face_end_row; i++) | ||
| 2716 | { | ||
| 2717 | int start_hpos, end_hpos, nglyphs; | ||
| 2718 | struct glyph_row *row = MATRIX_ROW (w->current_matrix, i); | ||
| 2719 | |||
| 2720 | /* Don't do anything if row doesn't have valid contents. */ | ||
| 2721 | if (!row->enabled_p) | ||
| 2722 | continue; | ||
| 2723 | |||
| 2724 | /* For all but the first row, the highlight starts at column 0. */ | ||
| 2725 | if (i == mouse_face_beg_row) | ||
| 2726 | start_hpos = mouse_face_beg_col; | ||
| 2727 | else | ||
| 2728 | start_hpos = 0; | ||
| 2729 | |||
| 2730 | if (i == mouse_face_end_row) | ||
| 2731 | end_hpos = mouse_face_end_col; | ||
| 2732 | else | ||
| 2733 | { | ||
| 2734 | end_hpos = row->used[TEXT_AREA]; | ||
| 2735 | if (draw == DRAW_NORMAL_TEXT) | ||
| 2736 | row->fill_line_p = 1; /* Clear to end of line */ | ||
| 2737 | } | ||
| 2738 | |||
| 2739 | if (end_hpos <= start_hpos) | ||
| 2740 | continue; | ||
| 2741 | /* Record that some glyphs of this row are displayed in | ||
| 2742 | mouse-face. */ | ||
| 2743 | row->mouse_face_p = draw > 0; | ||
| 2744 | |||
| 2745 | nglyphs = end_hpos - start_hpos; | ||
| 2746 | 2689 | ||
| 2747 | if (end_hpos >= row->used[TEXT_AREA]) | 2690 | pos_y = row->y + WINDOW_TOP_EDGE_Y (w); |
| 2748 | nglyphs = row->used[TEXT_AREA] - start_hpos; | 2691 | pos_x = row->used[LEFT_MARGIN_AREA] + start_hpos + WINDOW_LEFT_EDGE_X (w); |
| 2749 | 2692 | ||
| 2750 | pos_y = row->y + WINDOW_TOP_EDGE_Y (w); | 2693 | /* Save current cursor co-ordinates. */ |
| 2751 | pos_x = row->used[LEFT_MARGIN_AREA] + start_hpos | 2694 | save_y = curY (tty); |
| 2752 | + WINDOW_LEFT_EDGE_X (w); | 2695 | save_x = curX (tty); |
| 2753 | 2696 | cursor_to (f, pos_y, pos_x); | |
| 2754 | cursor_to (f, pos_y, pos_x); | ||
| 2755 | |||
| 2756 | if (draw == DRAW_MOUSE_FACE) | ||
| 2757 | { | ||
| 2758 | tty_write_glyphs_with_face (f, row->glyphs[TEXT_AREA] + start_hpos, | ||
| 2759 | nglyphs, mouse_face_face_id); | ||
| 2760 | } | ||
| 2761 | else /* draw == DRAW_NORMAL_TEXT */ | ||
| 2762 | write_glyphs (f, row->glyphs[TEXT_AREA] + start_hpos, nglyphs); | ||
| 2763 | } | ||
| 2764 | cursor_to (f, save_y, save_x); | ||
| 2765 | } | ||
| 2766 | } | ||
| 2767 | 2697 | ||
| 2768 | static void | 2698 | if (draw == DRAW_MOUSE_FACE) |
| 2769 | term_clear_mouse_face (void) | 2699 | tty_write_glyphs_with_face (f, row->glyphs[TEXT_AREA] + start_hpos, |
| 2770 | { | 2700 | nglyphs, face_id); |
| 2771 | if (!NILP (mouse_face_window)) | 2701 | else if (draw == DRAW_NORMAL_TEXT) |
| 2772 | term_show_mouse_face (DRAW_NORMAL_TEXT); | 2702 | write_glyphs (f, row->glyphs[TEXT_AREA] + start_hpos, nglyphs); |
| 2773 | 2703 | ||
| 2774 | mouse_face_beg_row = mouse_face_beg_col = -1; | 2704 | cursor_to (f, save_y, save_x); |
| 2775 | mouse_face_end_row = mouse_face_end_col = -1; | ||
| 2776 | mouse_face_window = Qnil; | ||
| 2777 | } | ||
| 2778 | |||
| 2779 | /* Find the glyph matrix position of buffer position POS in window W. | ||
| 2780 | *HPOS and *VPOS are set to the positions found. W's current glyphs | ||
| 2781 | must be up to date. If POS is above window start return (0, 0). | ||
| 2782 | If POS is after end of W, return end of last line in W. | ||
| 2783 | - taken from msdos.c */ | ||
| 2784 | static int | ||
| 2785 | fast_find_position (struct window *w, EMACS_INT pos, int *hpos, int *vpos) | ||
| 2786 | { | ||
| 2787 | int i, lastcol, maybe_next_line_p = 0; | ||
| 2788 | EMACS_INT line_start_position; | ||
| 2789 | int yb = window_text_bottom_y (w); | ||
| 2790 | struct glyph_row *row = MATRIX_ROW (w->current_matrix, 0), *best_row = row; | ||
| 2791 | |||
| 2792 | while (row->y < yb) | ||
| 2793 | { | ||
| 2794 | if (row->used[TEXT_AREA]) | ||
| 2795 | line_start_position = row->glyphs[TEXT_AREA]->charpos; | ||
| 2796 | else | ||
| 2797 | line_start_position = 0; | ||
| 2798 | |||
| 2799 | if (line_start_position > pos) | ||
| 2800 | break; | ||
| 2801 | /* If the position sought is the end of the buffer, | ||
| 2802 | don't include the blank lines at the bottom of the window. */ | ||
| 2803 | else if (line_start_position == pos | ||
| 2804 | && pos == BUF_ZV (XBUFFER (w->buffer))) | ||
| 2805 | { | ||
| 2806 | maybe_next_line_p = 1; | ||
| 2807 | break; | ||
| 2808 | } | ||
| 2809 | else if (line_start_position > 0) | ||
| 2810 | best_row = row; | ||
| 2811 | |||
| 2812 | /* Don't overstep the last matrix row, lest we get into the | ||
| 2813 | never-never land... */ | ||
| 2814 | if (row->y + 1 >= yb) | ||
| 2815 | break; | ||
| 2816 | |||
| 2817 | ++row; | ||
| 2818 | } | ||
| 2819 | |||
| 2820 | /* Find the right column within BEST_ROW. */ | ||
| 2821 | lastcol = 0; | ||
| 2822 | row = best_row; | ||
| 2823 | for (i = 0; i < row->used[TEXT_AREA]; i++) | ||
| 2824 | { | ||
| 2825 | struct glyph *glyph = row->glyphs[TEXT_AREA] + i; | ||
| 2826 | EMACS_INT charpos; | ||
| 2827 | |||
| 2828 | charpos = glyph->charpos; | ||
| 2829 | if (charpos == pos) | ||
| 2830 | { | ||
| 2831 | *hpos = i; | ||
| 2832 | *vpos = row->y; | ||
| 2833 | return 1; | ||
| 2834 | } | ||
| 2835 | else if (charpos > pos) | ||
| 2836 | break; | ||
| 2837 | else if (charpos > 0) | ||
| 2838 | lastcol = i; | ||
| 2839 | } | ||
| 2840 | |||
| 2841 | /* If we're looking for the end of the buffer, | ||
| 2842 | and we didn't find it in the line we scanned, | ||
| 2843 | use the start of the following line. */ | ||
| 2844 | if (maybe_next_line_p) | ||
| 2845 | { | ||
| 2846 | ++row; | ||
| 2847 | lastcol = 0; | ||
| 2848 | } | ||
| 2849 | |||
| 2850 | *vpos = row->y; | ||
| 2851 | *hpos = lastcol + 1; | ||
| 2852 | return 0; | ||
| 2853 | } | ||
| 2854 | |||
| 2855 | static void | ||
| 2856 | term_mouse_highlight (struct frame *f, int x, int y) | ||
| 2857 | { | ||
| 2858 | enum window_part part; | ||
| 2859 | Lisp_Object window; | ||
| 2860 | struct window *w; | ||
| 2861 | struct buffer *b; | ||
| 2862 | |||
| 2863 | if (NILP (Vmouse_highlight) | ||
| 2864 | || !f->glyphs_initialized_p) | ||
| 2865 | return; | ||
| 2866 | |||
| 2867 | /* Which window is that in? */ | ||
| 2868 | window = window_from_coordinates (f, x, y, &part, &x, &y, 0); | ||
| 2869 | |||
| 2870 | /* Not on a window -> return. */ | ||
| 2871 | if (!WINDOWP (window)) | ||
| 2872 | return; | ||
| 2873 | |||
| 2874 | if (!EQ (window, mouse_face_window)) | ||
| 2875 | term_clear_mouse_face (); | ||
| 2876 | |||
| 2877 | w = XWINDOW (window); | ||
| 2878 | |||
| 2879 | /* Are we in a window whose display is up to date? | ||
| 2880 | And verify the buffer's text has not changed. */ | ||
| 2881 | b = XBUFFER (w->buffer); | ||
| 2882 | if (part == ON_TEXT | ||
| 2883 | && EQ (w->window_end_valid, w->buffer) | ||
| 2884 | && XFASTINT (w->last_modified) == BUF_MODIFF (b) | ||
| 2885 | && XFASTINT (w->last_overlay_modified) == BUF_OVERLAY_MODIFF (b)) | ||
| 2886 | { | ||
| 2887 | int i, nrows = w->current_matrix->nrows; | ||
| 2888 | EMACS_INT pos; | ||
| 2889 | struct glyph_row *row; | ||
| 2890 | struct glyph *glyph; | ||
| 2891 | |||
| 2892 | /* Find the glyph under X/Y. */ | ||
| 2893 | glyph = NULL; | ||
| 2894 | if (y >= 0 && y < nrows) | ||
| 2895 | { | ||
| 2896 | row = MATRIX_ROW (w->current_matrix, y); | ||
| 2897 | /* Give up if some row before the one we are looking for is | ||
| 2898 | not enabled. */ | ||
| 2899 | for (i = 0; i <= y; i++) | ||
| 2900 | if (!MATRIX_ROW (w->current_matrix, i)->enabled_p) | ||
| 2901 | break; | ||
| 2902 | if (i > y /* all rows upto and including the one at Y are enabled */ | ||
| 2903 | && row->displays_text_p | ||
| 2904 | && x < window_box_width (w, TEXT_AREA)) | ||
| 2905 | { | ||
| 2906 | glyph = row->glyphs[TEXT_AREA]; | ||
| 2907 | if (x >= row->used[TEXT_AREA]) | ||
| 2908 | glyph = NULL; | ||
| 2909 | else | ||
| 2910 | { | ||
| 2911 | glyph += x; | ||
| 2912 | if (!BUFFERP (glyph->object)) | ||
| 2913 | glyph = NULL; | ||
| 2914 | } | ||
| 2915 | } | ||
| 2916 | } | ||
| 2917 | |||
| 2918 | /* Clear mouse face if X/Y not over text. */ | ||
| 2919 | if (glyph == NULL) | ||
| 2920 | { | ||
| 2921 | term_clear_mouse_face (); | ||
| 2922 | return; | ||
| 2923 | } | ||
| 2924 | |||
| 2925 | if (!BUFFERP (glyph->object)) | ||
| 2926 | abort (); | ||
| 2927 | pos = glyph->charpos; | ||
| 2928 | |||
| 2929 | /* Check for mouse-face. */ | ||
| 2930 | { | ||
| 2931 | Lisp_Object mouse_face, overlay, position, *overlay_vec; | ||
| 2932 | int noverlays; | ||
| 2933 | EMACS_INT obegv, ozv; | ||
| 2934 | struct buffer *obuf; | ||
| 2935 | |||
| 2936 | /* If we get an out-of-range value, return now; avoid an error. */ | ||
| 2937 | if (pos > BUF_Z (b)) | ||
| 2938 | return; | ||
| 2939 | |||
| 2940 | /* Make the window's buffer temporarily current for | ||
| 2941 | overlays_at and compute_char_face. */ | ||
| 2942 | obuf = current_buffer; | ||
| 2943 | current_buffer = b; | ||
| 2944 | obegv = BEGV; | ||
| 2945 | ozv = ZV; | ||
| 2946 | BEGV = BEG; | ||
| 2947 | ZV = Z; | ||
| 2948 | |||
| 2949 | /* Is this char mouse-active? */ | ||
| 2950 | XSETINT (position, pos); | ||
| 2951 | |||
| 2952 | /* Put all the overlays we want in a vector in overlay_vec. */ | ||
| 2953 | GET_OVERLAYS_AT (pos, overlay_vec, noverlays, NULL, 0); | ||
| 2954 | /* Sort overlays into increasing priority order. */ | ||
| 2955 | noverlays = sort_overlays (overlay_vec, noverlays, w); | ||
| 2956 | |||
| 2957 | /* Check mouse-face highlighting. */ | ||
| 2958 | if (!(EQ (window, mouse_face_window) | ||
| 2959 | && y >= mouse_face_beg_row | ||
| 2960 | && y <= mouse_face_end_row | ||
| 2961 | && (y > mouse_face_beg_row | ||
| 2962 | || x >= mouse_face_beg_col) | ||
| 2963 | && (y < mouse_face_end_row | ||
| 2964 | || x < mouse_face_end_col | ||
| 2965 | || mouse_face_past_end))) | ||
| 2966 | { | ||
| 2967 | /* Clear the display of the old active region, if any. */ | ||
| 2968 | term_clear_mouse_face (); | ||
| 2969 | |||
| 2970 | /* Find the highest priority overlay that has a mouse-face | ||
| 2971 | property. */ | ||
| 2972 | overlay = Qnil; | ||
| 2973 | for (i = noverlays - 1; i >= 0; --i) | ||
| 2974 | { | ||
| 2975 | mouse_face = Foverlay_get (overlay_vec[i], Qmouse_face); | ||
| 2976 | if (!NILP (mouse_face)) | ||
| 2977 | { | ||
| 2978 | overlay = overlay_vec[i]; | ||
| 2979 | break; | ||
| 2980 | } | ||
| 2981 | } | ||
| 2982 | |||
| 2983 | /* If no overlay applies, get a text property. */ | ||
| 2984 | if (NILP (overlay)) | ||
| 2985 | mouse_face = Fget_text_property (position, Qmouse_face, | ||
| 2986 | w->buffer); | ||
| 2987 | |||
| 2988 | /* Handle the overlay case. */ | ||
| 2989 | if (!NILP (overlay)) | ||
| 2990 | { | ||
| 2991 | /* Find the range of text around this char that | ||
| 2992 | should be active. */ | ||
| 2993 | Lisp_Object before, after; | ||
| 2994 | EMACS_INT ignore; | ||
| 2995 | |||
| 2996 | |||
| 2997 | before = Foverlay_start (overlay); | ||
| 2998 | after = Foverlay_end (overlay); | ||
| 2999 | /* Record this as the current active region. */ | ||
| 3000 | fast_find_position (w, XFASTINT (before), | ||
| 3001 | &mouse_face_beg_col, | ||
| 3002 | &mouse_face_beg_row); | ||
| 3003 | |||
| 3004 | mouse_face_past_end | ||
| 3005 | = !fast_find_position (w, XFASTINT (after), | ||
| 3006 | &mouse_face_end_col, | ||
| 3007 | &mouse_face_end_row); | ||
| 3008 | mouse_face_window = window; | ||
| 3009 | |||
| 3010 | mouse_face_face_id | ||
| 3011 | = face_at_buffer_position (w, pos, 0, 0, | ||
| 3012 | &ignore, pos + 1, 1, -1); | ||
| 3013 | |||
| 3014 | /* Display it as active. */ | ||
| 3015 | term_show_mouse_face (DRAW_MOUSE_FACE); | ||
| 3016 | } | ||
| 3017 | /* Handle the text property case. */ | ||
| 3018 | else if (!NILP (mouse_face)) | ||
| 3019 | { | ||
| 3020 | /* Find the range of text around this char that | ||
| 3021 | should be active. */ | ||
| 3022 | Lisp_Object before, after, beginning, end; | ||
| 3023 | EMACS_INT ignore; | ||
| 3024 | |||
| 3025 | beginning = Fmarker_position (w->start); | ||
| 3026 | XSETINT (end, (BUF_Z (b) - XFASTINT (w->window_end_pos))); | ||
| 3027 | before | ||
| 3028 | = Fprevious_single_property_change (make_number (pos + 1), | ||
| 3029 | Qmouse_face, | ||
| 3030 | w->buffer, beginning); | ||
| 3031 | after | ||
| 3032 | = Fnext_single_property_change (position, Qmouse_face, | ||
| 3033 | w->buffer, end); | ||
| 3034 | |||
| 3035 | /* Record this as the current active region. */ | ||
| 3036 | fast_find_position (w, XFASTINT (before), | ||
| 3037 | &mouse_face_beg_col, | ||
| 3038 | &mouse_face_beg_row); | ||
| 3039 | mouse_face_past_end | ||
| 3040 | = !fast_find_position (w, XFASTINT (after), | ||
| 3041 | &mouse_face_end_col, | ||
| 3042 | &mouse_face_end_row); | ||
| 3043 | mouse_face_window = window; | ||
| 3044 | |||
| 3045 | mouse_face_face_id | ||
| 3046 | = face_at_buffer_position (w, pos, 0, 0, | ||
| 3047 | &ignore, pos + 1, 1, -1); | ||
| 3048 | |||
| 3049 | /* Display it as active. */ | ||
| 3050 | term_show_mouse_face (DRAW_MOUSE_FACE); | ||
| 3051 | } | ||
| 3052 | } | ||
| 3053 | |||
| 3054 | /* Look for a `help-echo' property. */ | ||
| 3055 | { | ||
| 3056 | Lisp_Object help; | ||
| 3057 | |||
| 3058 | /* Check overlays first. */ | ||
| 3059 | help = Qnil; | ||
| 3060 | for (i = noverlays - 1; i >= 0 && NILP (help); --i) | ||
| 3061 | { | ||
| 3062 | overlay = overlay_vec[i]; | ||
| 3063 | help = Foverlay_get (overlay, Qhelp_echo); | ||
| 3064 | } | ||
| 3065 | |||
| 3066 | if (!NILP (help)) | ||
| 3067 | { | ||
| 3068 | help_echo_string = help; | ||
| 3069 | help_echo_window = window; | ||
| 3070 | help_echo_object = overlay; | ||
| 3071 | help_echo_pos = pos; | ||
| 3072 | } | ||
| 3073 | /* Try text properties. */ | ||
| 3074 | else if (NILP (help) | ||
| 3075 | && ((STRINGP (glyph->object) | ||
| 3076 | && glyph->charpos >= 0 | ||
| 3077 | && glyph->charpos < SCHARS (glyph->object)) | ||
| 3078 | || (BUFFERP (glyph->object) | ||
| 3079 | && glyph->charpos >= BEGV | ||
| 3080 | && glyph->charpos < ZV))) | ||
| 3081 | { | ||
| 3082 | help = Fget_text_property (make_number (glyph->charpos), | ||
| 3083 | Qhelp_echo, glyph->object); | ||
| 3084 | if (!NILP (help)) | ||
| 3085 | { | ||
| 3086 | help_echo_string = help; | ||
| 3087 | help_echo_window = window; | ||
| 3088 | help_echo_object = glyph->object; | ||
| 3089 | help_echo_pos = glyph->charpos; | ||
| 3090 | } | ||
| 3091 | } | ||
| 3092 | } | ||
| 3093 | |||
| 3094 | BEGV = obegv; | ||
| 3095 | ZV = ozv; | ||
| 3096 | current_buffer = obuf; | ||
| 3097 | } | ||
| 3098 | } | ||
| 3099 | } | 2705 | } |
| 3100 | 2706 | ||
| 3101 | static int | 2707 | static int |
| @@ -3105,7 +2711,7 @@ term_mouse_movement (FRAME_PTR frame, Gpm_Event *event) | |||
| 3105 | if (event->x != last_mouse_x || event->y != last_mouse_y) | 2711 | if (event->x != last_mouse_x || event->y != last_mouse_y) |
| 3106 | { | 2712 | { |
| 3107 | frame->mouse_moved = 1; | 2713 | frame->mouse_moved = 1; |
| 3108 | term_mouse_highlight (frame, event->x, event->y); | 2714 | note_mouse_highlight (frame, event->x, event->y); |
| 3109 | /* Remember which glyph we're now on. */ | 2715 | /* Remember which glyph we're now on. */ |
| 3110 | last_mouse_x = event->x; | 2716 | last_mouse_x = event->x; |
| 3111 | last_mouse_y = event->y; | 2717 | last_mouse_y = event->y; |
| @@ -3576,7 +3182,7 @@ init_tty (const char *name, const char *terminal_type, int must_succeed) | |||
| 3576 | 3182 | ||
| 3577 | #ifdef HAVE_GPM | 3183 | #ifdef HAVE_GPM |
| 3578 | terminal->mouse_position_hook = term_mouse_position; | 3184 | terminal->mouse_position_hook = term_mouse_position; |
| 3579 | mouse_face_window = Qnil; | 3185 | tty->mouse_highlight.mouse_face_window = Qnil; |
| 3580 | #endif | 3186 | #endif |
| 3581 | 3187 | ||
| 3582 | 3188 | ||
| @@ -4211,8 +3817,6 @@ bigger, or it may make it blink, or it may do nothing at all. */); | |||
| 4211 | #ifdef HAVE_GPM | 3817 | #ifdef HAVE_GPM |
| 4212 | defsubr (&Sgpm_mouse_start); | 3818 | defsubr (&Sgpm_mouse_start); |
| 4213 | defsubr (&Sgpm_mouse_stop); | 3819 | defsubr (&Sgpm_mouse_stop); |
| 4214 | |||
| 4215 | staticpro (&mouse_face_window); | ||
| 4216 | #endif /* HAVE_GPM */ | 3820 | #endif /* HAVE_GPM */ |
| 4217 | 3821 | ||
| 4218 | #ifndef DOS_NT | 3822 | #ifndef DOS_NT |