diff options
| author | Eli Zaretskii | 2013-09-25 17:51:39 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2013-09-25 17:51:39 +0300 |
| commit | e648f6997511f3a4cabc338783e61ad076074859 (patch) | |
| tree | 6852858ba974f0a2a047b59782d7bae660cbe395 /src | |
| parent | aa36c6d0c478a756cc0a9aca796cbf431be773ee (diff) | |
| download | emacs-e648f6997511f3a4cabc338783e61ad076074859.tar.gz emacs-e648f6997511f3a4cabc338783e61ad076074859.zip | |
Read mouse movement via read_menu_command.
Diffstat (limited to 'src')
| -rw-r--r-- | src/term.c | 48 |
1 files changed, 39 insertions, 9 deletions
diff --git a/src/term.c b/src/term.c index 00ef53d5c94..a7c111f46ef 100644 --- a/src/term.c +++ b/src/term.c | |||
| @@ -2819,6 +2819,7 @@ static Lisp_Object Qtty_menu_navigation_map, Qtty_menu_exit; | |||
| 2819 | static Lisp_Object Qtty_menu_prev_item, Qtty_menu_next_item; | 2819 | static Lisp_Object Qtty_menu_prev_item, Qtty_menu_next_item; |
| 2820 | static Lisp_Object Qtty_menu_next_menu, Qtty_menu_prev_menu; | 2820 | static Lisp_Object Qtty_menu_next_menu, Qtty_menu_prev_menu; |
| 2821 | static Lisp_Object Qtty_menu_select, Qtty_menu_ignore; | 2821 | static Lisp_Object Qtty_menu_select, Qtty_menu_ignore; |
| 2822 | static Lisp_Object Qtty_menu_mouse_movement; | ||
| 2822 | 2823 | ||
| 2823 | typedef struct tty_menu_struct | 2824 | typedef struct tty_menu_struct |
| 2824 | { | 2825 | { |
| @@ -2913,6 +2914,26 @@ tty_menu_calc_size (tty_menu *menu, int *width, int *height) | |||
| 2913 | *height = maxheight; | 2914 | *height = maxheight; |
| 2914 | } | 2915 | } |
| 2915 | 2916 | ||
| 2917 | static void | ||
| 2918 | mouse_get_xy (int *x, int *y) | ||
| 2919 | { | ||
| 2920 | struct frame *sf = SELECTED_FRAME (); | ||
| 2921 | Lisp_Object lmx, lmy, lisp_dummy; | ||
| 2922 | enum scroll_bar_part part_dummy; | ||
| 2923 | Time time_dummy; | ||
| 2924 | |||
| 2925 | if (FRAME_TERMINAL (sf)->mouse_position_hook) | ||
| 2926 | (*FRAME_TERMINAL (sf)->mouse_position_hook) (&sf, -1, | ||
| 2927 | &lisp_dummy, &part_dummy, | ||
| 2928 | &lmx, &lmy, | ||
| 2929 | &time_dummy); | ||
| 2930 | if (!NILP (lmx)) | ||
| 2931 | { | ||
| 2932 | *x = XINT (lmx); | ||
| 2933 | *y = XINT (lmy); | ||
| 2934 | } | ||
| 2935 | } | ||
| 2936 | |||
| 2916 | /* Display MENU at (X,Y) using FACES. */ | 2937 | /* Display MENU at (X,Y) using FACES. */ |
| 2917 | 2938 | ||
| 2918 | static void | 2939 | static void |
| @@ -3199,13 +3220,12 @@ screen_update (struct frame *f, struct glyph_matrix *mtx) | |||
| 3199 | puts us. We only consider mouse movement and click events and | 3220 | puts us. We only consider mouse movement and click events and |
| 3200 | keyboard movement commands; the rest are ignored. | 3221 | keyboard movement commands; the rest are ignored. |
| 3201 | 3222 | ||
| 3202 | Value is -1 if C-g was pressed, zero otherwise. */ | 3223 | Value is -1 if C-g was pressed, 1 if an item was selected, zero |
| 3224 | otherwise. */ | ||
| 3203 | static int | 3225 | static int |
| 3204 | read_menu_input (struct frame *sf, int *x, int *y, int min_y, int max_y, | 3226 | read_menu_input (struct frame *sf, int *x, int *y, int min_y, int max_y, |
| 3205 | bool *first_time) | 3227 | bool *first_time) |
| 3206 | { | 3228 | { |
| 3207 | Lisp_Object c; | ||
| 3208 | |||
| 3209 | if (*first_time) | 3229 | if (*first_time) |
| 3210 | { | 3230 | { |
| 3211 | *first_time = false; | 3231 | *first_time = false; |
| @@ -3224,18 +3244,30 @@ read_menu_input (struct frame *sf, int *x, int *y, int min_y, int max_y, | |||
| 3224 | int usable_input = 1; | 3244 | int usable_input = 1; |
| 3225 | int st = 0; | 3245 | int st = 0; |
| 3226 | struct tty_display_info *tty = FRAME_TTY (sf); | 3246 | struct tty_display_info *tty = FRAME_TTY (sf); |
| 3247 | Lisp_Object saved_mouse_tracking = do_mouse_tracking; | ||
| 3227 | 3248 | ||
| 3228 | /* Signal the keyboard reading routines we are displaying a menu | 3249 | /* Signal the keyboard reading routines we are displaying a menu |
| 3229 | on this terminal. */ | 3250 | on this terminal. */ |
| 3230 | tty->showing_menu = 1; | 3251 | tty->showing_menu = 1; |
| 3252 | /* We want mouse movements be reported by read_menu_command. */ | ||
| 3253 | do_mouse_tracking = Qt; | ||
| 3231 | do { | 3254 | do { |
| 3232 | cmd = read_menu_command (); | 3255 | cmd = read_menu_command (); |
| 3233 | } while NILP (cmd); | 3256 | } while (NILP (cmd)); |
| 3234 | tty->showing_menu = 0; | 3257 | tty->showing_menu = 0; |
| 3258 | do_mouse_tracking = saved_mouse_tracking; | ||
| 3235 | 3259 | ||
| 3236 | if (EQ (cmd, Qt) || EQ (cmd, Qtty_menu_exit)) | 3260 | if (EQ (cmd, Qt) || EQ (cmd, Qtty_menu_exit)) |
| 3237 | return -1; | 3261 | return -1; |
| 3238 | if (EQ (cmd, Qtty_menu_next_menu)) | 3262 | if (EQ (cmd, Qtty_menu_mouse_movement)) |
| 3263 | { | ||
| 3264 | int mx, my; | ||
| 3265 | |||
| 3266 | mouse_get_xy (&mx, &my); | ||
| 3267 | *x = mx; | ||
| 3268 | *y = my; | ||
| 3269 | } | ||
| 3270 | else if (EQ (cmd, Qtty_menu_next_menu)) | ||
| 3239 | *x += 1; | 3271 | *x += 1; |
| 3240 | else if (EQ (cmd, Qtty_menu_prev_menu)) | 3272 | else if (EQ (cmd, Qtty_menu_prev_menu)) |
| 3241 | *x -= 1; | 3273 | *x -= 1; |
| @@ -3252,10 +3284,7 @@ read_menu_input (struct frame *sf, int *x, int *y, int min_y, int max_y, | |||
| 3252 | else if (EQ (cmd, Qtty_menu_select)) | 3284 | else if (EQ (cmd, Qtty_menu_select)) |
| 3253 | st = 1; | 3285 | st = 1; |
| 3254 | else if (!EQ (cmd, Qtty_menu_ignore)) | 3286 | else if (!EQ (cmd, Qtty_menu_ignore)) |
| 3255 | { | 3287 | usable_input = 0; |
| 3256 | usable_input = 0; | ||
| 3257 | st = -1; | ||
| 3258 | } | ||
| 3259 | if (usable_input) | 3288 | if (usable_input) |
| 3260 | sf->mouse_moved = 1; | 3289 | sf->mouse_moved = 1; |
| 3261 | #else | 3290 | #else |
| @@ -4671,5 +4700,6 @@ bigger, or it may make it blink, or it may do nothing at all. */); | |||
| 4671 | DEFSYM (Qtty_menu_select, "tty-menu-select"); | 4700 | DEFSYM (Qtty_menu_select, "tty-menu-select"); |
| 4672 | DEFSYM (Qtty_menu_ignore, "tty-menu-ignore"); | 4701 | DEFSYM (Qtty_menu_ignore, "tty-menu-ignore"); |
| 4673 | DEFSYM (Qtty_menu_exit, "tty-menu-exit"); | 4702 | DEFSYM (Qtty_menu_exit, "tty-menu-exit"); |
| 4703 | DEFSYM (Qtty_menu_mouse_movement, "tty-menu-mouse-movement"); | ||
| 4674 | DEFSYM (Qtty_menu_navigation_map, "tty-menu-navigation-map"); | 4704 | DEFSYM (Qtty_menu_navigation_map, "tty-menu-navigation-map"); |
| 4675 | } | 4705 | } |