diff options
| author | Dmitry Antipov | 2014-06-04 08:58:31 +0400 |
|---|---|---|
| committer | Dmitry Antipov | 2014-06-04 08:58:31 +0400 |
| commit | cfd794af4214ae0e5587ab8b1f4e5fcb355a0f12 (patch) | |
| tree | c45be02b5b568e7534eb91e03ba46899dc42dff5 /src/term.c | |
| parent | 39ec03147e88bb7a12d2e42edfa0206f6b7d546b (diff) | |
| download | emacs-cfd794af4214ae0e5587ab8b1f4e5fcb355a0f12.tar.gz emacs-cfd794af4214ae0e5587ab8b1f4e5fcb355a0f12.zip | |
Use terminal-specific hooks to display menus.
* termhooks.h (struct terminal): New field menu_show_hook.
* menu.h (<anonymous enum>): Bit flags for menu hooks.
(x_menu_show, w32_menu_show, ns_menu_show, tty_menu_show):
Adjust prototypes.
* menu.c (Fx_popup_menu): Use bit flags and menu_show_hook.
* nsmenu.m (ns_menu_show):
* w32menu.c (w32_menu_show):
* xmenu.c (x_menu_show):
* term.c (tty_menu_show): Adjust to use bit flags.
(set_tty_hooks): Set menu_show_hook.
* xterm.c (x_create_terminal):
* nsterm.m (ns_create_terminal):
* msdos.c (initialize_msdos_display):
* w32term.c (w32_create_terminal): Likewise.
Diffstat (limited to 'src/term.c')
| -rw-r--r-- | src/term.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/src/term.c b/src/term.c index 379c94e54a1..aa0be9871c8 100644 --- a/src/term.c +++ b/src/term.c | |||
| @@ -3583,8 +3583,8 @@ tty_menu_new_item_coords (struct frame *f, int which, int *x, int *y) | |||
| 3583 | } | 3583 | } |
| 3584 | 3584 | ||
| 3585 | Lisp_Object | 3585 | Lisp_Object |
| 3586 | tty_menu_show (struct frame *f, int x, int y, bool for_click, bool keymaps, | 3586 | tty_menu_show (struct frame *f, int x, int y, int menuflags, |
| 3587 | Lisp_Object title, bool kbd_navigation, const char **error_name) | 3587 | Lisp_Object title, const char **error_name) |
| 3588 | { | 3588 | { |
| 3589 | tty_menu *menu; | 3589 | tty_menu *menu; |
| 3590 | int pane, selidx, lpane, status; | 3590 | int pane, selidx, lpane, status; |
| @@ -3621,6 +3621,10 @@ tty_menu_show (struct frame *f, int x, int y, bool for_click, bool keymaps, | |||
| 3621 | menu functions pointers to the contents of strings. */ | 3621 | menu functions pointers to the contents of strings. */ |
| 3622 | specpdl_count = inhibit_garbage_collection (); | 3622 | specpdl_count = inhibit_garbage_collection (); |
| 3623 | 3623 | ||
| 3624 | /* Avoid crashes if, e.g., another client will connect while we | ||
| 3625 | are in a menu. */ | ||
| 3626 | temporarily_switch_to_single_kboard (f); | ||
| 3627 | |||
| 3624 | /* Adjust coordinates to be root-window-relative. */ | 3628 | /* Adjust coordinates to be root-window-relative. */ |
| 3625 | item_x = x += f->left_pos; | 3629 | item_x = x += f->left_pos; |
| 3626 | item_y = y += f->top_pos; | 3630 | item_y = y += f->top_pos; |
| @@ -3642,7 +3646,7 @@ tty_menu_show (struct frame *f, int x, int y, bool for_click, bool keymaps, | |||
| 3642 | prefix = AREF (menu_items, i + MENU_ITEMS_PANE_PREFIX); | 3646 | prefix = AREF (menu_items, i + MENU_ITEMS_PANE_PREFIX); |
| 3643 | pane_string = (NILP (pane_name) | 3647 | pane_string = (NILP (pane_name) |
| 3644 | ? "" : SSDATA (pane_name)); | 3648 | ? "" : SSDATA (pane_name)); |
| 3645 | if (keymaps && !NILP (prefix)) | 3649 | if ((menuflags & MENU_KEYMAPS) && !NILP (prefix)) |
| 3646 | pane_string++; | 3650 | pane_string++; |
| 3647 | 3651 | ||
| 3648 | lpane = tty_menu_add_pane (menu, pane_string); | 3652 | lpane = tty_menu_add_pane (menu, pane_string); |
| @@ -3782,7 +3786,8 @@ tty_menu_show (struct frame *f, int x, int y, bool for_click, bool keymaps, | |||
| 3782 | specbind (Qoverriding_terminal_local_map, | 3786 | specbind (Qoverriding_terminal_local_map, |
| 3783 | Fsymbol_value (Qtty_menu_navigation_map)); | 3787 | Fsymbol_value (Qtty_menu_navigation_map)); |
| 3784 | status = tty_menu_activate (menu, &pane, &selidx, x, y, &datap, | 3788 | status = tty_menu_activate (menu, &pane, &selidx, x, y, &datap, |
| 3785 | tty_menu_help_callback, kbd_navigation); | 3789 | tty_menu_help_callback, |
| 3790 | menuflags & MENU_KBD_NAVIGATION); | ||
| 3786 | entry = pane_prefix = Qnil; | 3791 | entry = pane_prefix = Qnil; |
| 3787 | 3792 | ||
| 3788 | switch (status) | 3793 | switch (status) |
| @@ -3808,7 +3813,7 @@ tty_menu_show (struct frame *f, int x, int y, bool for_click, bool keymaps, | |||
| 3808 | { | 3813 | { |
| 3809 | entry | 3814 | entry |
| 3810 | = AREF (menu_items, i + MENU_ITEMS_ITEM_VALUE); | 3815 | = AREF (menu_items, i + MENU_ITEMS_ITEM_VALUE); |
| 3811 | if (keymaps != 0) | 3816 | if (menuflags & MENU_KEYMAPS) |
| 3812 | { | 3817 | { |
| 3813 | entry = Fcons (entry, Qnil); | 3818 | entry = Fcons (entry, Qnil); |
| 3814 | if (!NILP (pane_prefix)) | 3819 | if (!NILP (pane_prefix)) |
| @@ -3841,7 +3846,7 @@ tty_menu_show (struct frame *f, int x, int y, bool for_click, bool keymaps, | |||
| 3841 | Ftop_level (); | 3846 | Ftop_level (); |
| 3842 | /* Make "Cancel" equivalent to C-g unless FOR_CLICK (which means | 3847 | /* Make "Cancel" equivalent to C-g unless FOR_CLICK (which means |
| 3843 | the menu was invoked with a mouse event as POSITION). */ | 3848 | the menu was invoked with a mouse event as POSITION). */ |
| 3844 | if (! for_click) | 3849 | if (!(menuflags & MENU_FOR_CLICK)) |
| 3845 | Fsignal (Qquit, Qnil); | 3850 | Fsignal (Qquit, Qnil); |
| 3846 | break; | 3851 | break; |
| 3847 | } | 3852 | } |
| @@ -3922,6 +3927,7 @@ clear_tty_hooks (struct terminal *terminal) | |||
| 3922 | terminal->frame_rehighlight_hook = 0; | 3927 | terminal->frame_rehighlight_hook = 0; |
| 3923 | terminal->frame_raise_lower_hook = 0; | 3928 | terminal->frame_raise_lower_hook = 0; |
| 3924 | terminal->fullscreen_hook = 0; | 3929 | terminal->fullscreen_hook = 0; |
| 3930 | terminal->menu_show_hook = 0; | ||
| 3925 | terminal->set_vertical_scroll_bar_hook = 0; | 3931 | terminal->set_vertical_scroll_bar_hook = 0; |
| 3926 | terminal->condemn_scroll_bars_hook = 0; | 3932 | terminal->condemn_scroll_bars_hook = 0; |
| 3927 | terminal->redeem_scroll_bar_hook = 0; | 3933 | terminal->redeem_scroll_bar_hook = 0; |
| @@ -3953,6 +3959,7 @@ set_tty_hooks (struct terminal *terminal) | |||
| 3953 | terminal->reset_terminal_modes_hook = &tty_reset_terminal_modes; | 3959 | terminal->reset_terminal_modes_hook = &tty_reset_terminal_modes; |
| 3954 | terminal->set_terminal_modes_hook = &tty_set_terminal_modes; | 3960 | terminal->set_terminal_modes_hook = &tty_set_terminal_modes; |
| 3955 | terminal->update_end_hook = &tty_update_end; | 3961 | terminal->update_end_hook = &tty_update_end; |
| 3962 | terminal->menu_show_hook = &tty_menu_show; | ||
| 3956 | terminal->set_terminal_window_hook = &tty_set_terminal_window; | 3963 | terminal->set_terminal_window_hook = &tty_set_terminal_window; |
| 3957 | terminal->read_socket_hook = &tty_read_avail_input; /* keyboard.c */ | 3964 | terminal->read_socket_hook = &tty_read_avail_input; /* keyboard.c */ |
| 3958 | terminal->delete_frame_hook = &tty_free_frame_resources; | 3965 | terminal->delete_frame_hook = &tty_free_frame_resources; |