diff options
| author | Eli Zaretskii | 2013-09-23 16:15:29 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2013-09-23 16:15:29 +0300 |
| commit | df78230943690aa2d95e22f947615c09d2c676e8 (patch) | |
| tree | b5f532ce7ffe84cdb4a177cfab3ef0bcc433673b /src | |
| parent | 7ace926507379e836df263c4a0310eed285181c6 (diff) | |
| download | emacs-df78230943690aa2d95e22f947615c09d2c676e8.tar.gz emacs-df78230943690aa2d95e22f947615c09d2c676e8.zip | |
Use overriding-terminal-local-map for menu navigation.
Diffstat (limited to 'src')
| -rw-r--r-- | src/term.c | 67 |
1 files changed, 39 insertions, 28 deletions
diff --git a/src/term.c b/src/term.c index 26fa64da62d..4da5fd13905 100644 --- a/src/term.c +++ b/src/term.c | |||
| @@ -2815,8 +2815,10 @@ static int menu_help_paneno, menu_help_itemno; | |||
| 2815 | 2815 | ||
| 2816 | static int menu_x, menu_y; | 2816 | static int menu_x, menu_y; |
| 2817 | 2817 | ||
| 2818 | static Lisp_Object Qright_char, Qleft_char, Qforward_char, Qbackward_char; | 2818 | static Lisp_Object Qtty_menu_navigation_map, Qtty_menu_exit; |
| 2819 | static Lisp_Object Qnext_line, Qprevious_line, Qnewline; | 2819 | static Lisp_Object Qtty_menu_prev_item, Qtty_menu_next_item; |
| 2820 | static Lisp_Object Qtty_menu_next_menu, Qtty_menu_prev_menu; | ||
| 2821 | static Lisp_Object Qtty_menu_select, Qtty_menu_ignore; | ||
| 2820 | 2822 | ||
| 2821 | typedef struct tty_menu_struct | 2823 | typedef struct tty_menu_struct |
| 2822 | { | 2824 | { |
| @@ -3158,7 +3160,8 @@ screen_update (struct frame *f, struct glyph_matrix *mtx) | |||
| 3158 | 3160 | ||
| 3159 | Value is -1 if C-g was pressed, zero otherwise. */ | 3161 | Value is -1 if C-g was pressed, zero otherwise. */ |
| 3160 | static int | 3162 | static int |
| 3161 | read_menu_input (struct frame *sf, int *x, int *y, bool *first_time) | 3163 | read_menu_input (struct frame *sf, int *x, int *y, int min_y, int max_y, |
| 3164 | bool *first_time) | ||
| 3162 | { | 3165 | { |
| 3163 | Lisp_Object c; | 3166 | Lisp_Object c; |
| 3164 | 3167 | ||
| @@ -3184,19 +3187,25 @@ read_menu_input (struct frame *sf, int *x, int *y, bool *first_time) | |||
| 3184 | cmd = read_menu_command (); | 3187 | cmd = read_menu_command (); |
| 3185 | } while NILP (cmd); | 3188 | } while NILP (cmd); |
| 3186 | 3189 | ||
| 3187 | if (EQ (cmd, Qt)) | 3190 | if (EQ (cmd, Qt) || EQ (cmd, Qtty_menu_exit)) |
| 3188 | return -1; | 3191 | return -1; |
| 3189 | if (EQ (cmd, Qright_char) || EQ (cmd, Qforward_char)) | 3192 | if (EQ (cmd, Qtty_menu_next_menu)) |
| 3190 | *x += 1; | 3193 | *x += 1; |
| 3191 | else if (EQ (cmd, Qleft_char) || EQ (cmd, Qbackward_char)) | 3194 | else if (EQ (cmd, Qtty_menu_prev_menu)) |
| 3192 | *x -= 1; | 3195 | *x -= 1; |
| 3193 | else if (EQ (cmd, Qnext_line)) | 3196 | else if (EQ (cmd, Qtty_menu_next_item)) |
| 3194 | *y += 1; | 3197 | { |
| 3195 | else if (EQ (cmd, Qprevious_line)) | 3198 | if (*y < max_y) |
| 3196 | *y -= 1; | 3199 | *y += 1; |
| 3197 | else if (EQ (cmd, Qnewline)) | 3200 | } |
| 3201 | else if (EQ (cmd, Qtty_menu_prev_item)) | ||
| 3202 | { | ||
| 3203 | if (*y > min_y) | ||
| 3204 | *y -= 1; | ||
| 3205 | } | ||
| 3206 | else if (EQ (cmd, Qtty_menu_select)) | ||
| 3198 | st = 1; | 3207 | st = 1; |
| 3199 | else | 3208 | else if (!EQ (cmd, Qtty_menu_ignore)) |
| 3200 | { | 3209 | { |
| 3201 | usable_input = 0; | 3210 | usable_input = 0; |
| 3202 | st = -1; | 3211 | st = -1; |
| @@ -3359,9 +3368,10 @@ tty_menu_activate (tty_menu *menu, int *pane, int *selidx, | |||
| 3359 | { | 3368 | { |
| 3360 | int mouse_button_count = 3; /* FIXME */ | 3369 | int mouse_button_count = 3; /* FIXME */ |
| 3361 | int input_status; | 3370 | int input_status; |
| 3371 | int min_y = state[0].y, max_y = min_y + state[0].menu->count - 1; | ||
| 3362 | 3372 | ||
| 3363 | if (!mouse_visible) mouse_on (); | 3373 | if (!mouse_visible) mouse_on (); |
| 3364 | input_status = read_menu_input (sf, &x, &y, &first_time); | 3374 | input_status = read_menu_input (sf, &x, &y, min_y, max_y, &first_time); |
| 3365 | if (input_status) | 3375 | if (input_status) |
| 3366 | { | 3376 | { |
| 3367 | if (input_status == -1) | 3377 | if (input_status == -1) |
| @@ -3737,19 +3747,19 @@ tty_menu_show (struct frame *f, int x, int y, int for_click, int keymaps, | |||
| 3737 | uly = dispheight - height; | 3747 | uly = dispheight - height; |
| 3738 | } | 3748 | } |
| 3739 | 3749 | ||
| 3740 | if (FRAME_HAS_MINIBUF_P (f) && uly+height > dispheight - 1) | 3750 | if (FRAME_HAS_MINIBUF_P (f) && uly+height > dispheight - 2) |
| 3741 | { | 3751 | { |
| 3742 | /* Move the menu away of the echo area, to avoid overwriting the | 3752 | /* Move the menu away of the echo area, to avoid overwriting the |
| 3743 | menu with help echo messages or vice versa. */ | 3753 | menu with help echo messages or vice versa. */ |
| 3744 | if (BUFFERP (echo_area_buffer[0]) && WINDOWP (echo_area_window)) | 3754 | if (BUFFERP (echo_area_buffer[0]) && WINDOWP (echo_area_window)) |
| 3745 | { | 3755 | { |
| 3746 | y -= WINDOW_TOTAL_LINES (XWINDOW (echo_area_window)); | 3756 | y -= WINDOW_TOTAL_LINES (XWINDOW (echo_area_window)) + 1; |
| 3747 | uly -= WINDOW_TOTAL_LINES (XWINDOW (echo_area_window)); | 3757 | uly -= WINDOW_TOTAL_LINES (XWINDOW (echo_area_window)) + 1; |
| 3748 | } | 3758 | } |
| 3749 | else | 3759 | else |
| 3750 | { | 3760 | { |
| 3751 | y--; | 3761 | y -= 2; |
| 3752 | uly--; | 3762 | uly -= 2; |
| 3753 | } | 3763 | } |
| 3754 | } | 3764 | } |
| 3755 | 3765 | ||
| @@ -3774,9 +3784,9 @@ tty_menu_show (struct frame *f, int x, int y, int for_click, int keymaps, | |||
| 3774 | 3784 | ||
| 3775 | record_unwind_protect (tty_pop_down_menu, make_save_ptr (menu)); | 3785 | record_unwind_protect (tty_pop_down_menu, make_save_ptr (menu)); |
| 3776 | 3786 | ||
| 3777 | /* Help display under X won't work because XMenuActivate contains | 3787 | tty_menu_help_frame = f; /* FIXME: This seems unused. */ |
| 3778 | a loop that doesn't give Emacs a chance to process it. FIXME. */ | 3788 | specbind (Qoverriding_terminal_local_map, |
| 3779 | tty_menu_help_frame = f; | 3789 | Fsymbol_value (Qtty_menu_navigation_map)); |
| 3780 | status = tty_menu_activate (menu, &pane, &selidx, x, y, &datap, | 3790 | status = tty_menu_activate (menu, &pane, &selidx, x, y, &datap, |
| 3781 | tty_menu_help_callback); | 3791 | tty_menu_help_callback); |
| 3782 | entry = pane_prefix = Qnil; | 3792 | entry = pane_prefix = Qnil; |
| @@ -4609,11 +4619,12 @@ bigger, or it may make it blink, or it may do nothing at all. */); | |||
| 4609 | encode_terminal_src = NULL; | 4619 | encode_terminal_src = NULL; |
| 4610 | encode_terminal_dst = NULL; | 4620 | encode_terminal_dst = NULL; |
| 4611 | 4621 | ||
| 4612 | DEFSYM (Qright_char, "right-char"); | 4622 | DEFSYM (Qtty_menu_next_item, "tty-menu-next-item"); |
| 4613 | DEFSYM (Qleft_char, "left-char"); | 4623 | DEFSYM (Qtty_menu_prev_item, "tty-menu-prev-item"); |
| 4614 | DEFSYM (Qforward_char, "forward-char"); | 4624 | DEFSYM (Qtty_menu_next_menu, "tty-menu-next-menu"); |
| 4615 | DEFSYM (Qbackward_char, "backward-char"); | 4625 | DEFSYM (Qtty_menu_prev_menu, "tty-menu-prev-menu"); |
| 4616 | DEFSYM (Qprevious_line, "previous-line"); | 4626 | DEFSYM (Qtty_menu_select, "tty-menu-select"); |
| 4617 | DEFSYM (Qnext_line, "next-line"); | 4627 | DEFSYM (Qtty_menu_ignore, "tty-menu-ignore"); |
| 4618 | DEFSYM (Qnewline, "newline"); | 4628 | DEFSYM (Qtty_menu_exit, "tty-menu-exit"); |
| 4629 | DEFSYM (Qtty_menu_navigation_map, "tty-menu-navigation-map"); | ||
| 4619 | } | 4630 | } |