diff options
Diffstat (limited to 'src/menu.c')
| -rw-r--r-- | src/menu.c | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/src/menu.c b/src/menu.c index 2c787e00b6f..f741d686cd1 100644 --- a/src/menu.c +++ b/src/menu.c | |||
| @@ -1036,8 +1036,8 @@ find_and_return_menu_selection (struct frame *f, bool keymaps, void *client_data | |||
| 1036 | } | 1036 | } |
| 1037 | #endif /* HAVE_NS */ | 1037 | #endif /* HAVE_NS */ |
| 1038 | 1038 | ||
| 1039 | static int | 1039 | int |
| 1040 | item_width (const char *str) | 1040 | menu_item_width (const char *str) |
| 1041 | { | 1041 | { |
| 1042 | int len; | 1042 | int len; |
| 1043 | const char *p; | 1043 | const char *p; |
| @@ -1104,7 +1104,7 @@ into menu items. */) | |||
| 1104 | if (XINT (pos) <= col | 1104 | if (XINT (pos) <= col |
| 1105 | /* We use <= so the blank between 2 items on a TTY is | 1105 | /* We use <= so the blank between 2 items on a TTY is |
| 1106 | considered part of the previous item. */ | 1106 | considered part of the previous item. */ |
| 1107 | && col <= XINT (pos) + item_width (SSDATA (str))) | 1107 | && col <= XINT (pos) + menu_item_width (SSDATA (str))) |
| 1108 | { | 1108 | { |
| 1109 | item = AREF (items, i); | 1109 | item = AREF (items, i); |
| 1110 | return item; | 1110 | return item; |
| @@ -1160,7 +1160,7 @@ event (indicating that the user invoked the menu with the mouse) then | |||
| 1160 | no quit occurs and `x-popup-menu' returns nil. */) | 1160 | no quit occurs and `x-popup-menu' returns nil. */) |
| 1161 | (Lisp_Object position, Lisp_Object menu) | 1161 | (Lisp_Object position, Lisp_Object menu) |
| 1162 | { | 1162 | { |
| 1163 | Lisp_Object keymap, tem; | 1163 | Lisp_Object keymap, tem, tem2; |
| 1164 | int xpos = 0, ypos = 0; | 1164 | int xpos = 0, ypos = 0; |
| 1165 | Lisp_Object title; | 1165 | Lisp_Object title; |
| 1166 | const char *error_name = NULL; | 1166 | const char *error_name = NULL; |
| @@ -1169,6 +1169,7 @@ no quit occurs and `x-popup-menu' returns nil. */) | |||
| 1169 | Lisp_Object x, y, window; | 1169 | Lisp_Object x, y, window; |
| 1170 | bool keymaps = 0; | 1170 | bool keymaps = 0; |
| 1171 | bool for_click = 0; | 1171 | bool for_click = 0; |
| 1172 | bool kbd_menu_navigation = 0; | ||
| 1172 | ptrdiff_t specpdl_count = SPECPDL_INDEX (); | 1173 | ptrdiff_t specpdl_count = SPECPDL_INDEX (); |
| 1173 | struct gcpro gcpro1; | 1174 | struct gcpro gcpro1; |
| 1174 | 1175 | ||
| @@ -1202,6 +1203,22 @@ no quit occurs and `x-popup-menu' returns nil. */) | |||
| 1202 | for_click = 1; | 1203 | for_click = 1; |
| 1203 | tem = Fcar (Fcdr (position)); /* EVENT_START (position) */ | 1204 | tem = Fcar (Fcdr (position)); /* EVENT_START (position) */ |
| 1204 | window = Fcar (tem); /* POSN_WINDOW (tem) */ | 1205 | window = Fcar (tem); /* POSN_WINDOW (tem) */ |
| 1206 | tem2 = Fcar (Fcdr (tem)); /* POSN_POSN (tem) */ | ||
| 1207 | /* The kbd_menu_navigation flag is set when the menu was | ||
| 1208 | invoked by F10, which probably means they have no | ||
| 1209 | mouse. In that case, we let them switch between | ||
| 1210 | top-level menu-bar menus by using C-f/C-b and | ||
| 1211 | horizontal arrow keys, since they cannot click the | ||
| 1212 | mouse to open a different submenu. This flag is only | ||
| 1213 | supported by tty_menu_show. We set it when POSITION | ||
| 1214 | and last_nonmenu_event are different, which means we | ||
| 1215 | constructed POSITION by hand (in popup-menu, see | ||
| 1216 | menu-bar.el) to look like a mouse click on the menu bar | ||
| 1217 | event. */ | ||
| 1218 | if (!EQ (POSN_POSN (last_nonmenu_event), | ||
| 1219 | POSN_POSN (position)) | ||
| 1220 | && CONSP (tem2) && EQ (Fcar (tem2), Qmenu_bar)) | ||
| 1221 | kbd_menu_navigation = 1; | ||
| 1205 | tem = Fcar (Fcdr (Fcdr (tem))); /* POSN_WINDOW_POSN (tem) */ | 1222 | tem = Fcar (Fcdr (Fcdr (tem))); /* POSN_WINDOW_POSN (tem) */ |
| 1206 | x = Fcar (tem); | 1223 | x = Fcar (tem); |
| 1207 | y = Fcdr (tem); | 1224 | y = Fcdr (tem); |
| @@ -1434,8 +1451,8 @@ no quit occurs and `x-popup-menu' returns nil. */) | |||
| 1434 | else | 1451 | else |
| 1435 | #endif | 1452 | #endif |
| 1436 | if (FRAME_TERMCAP_P (f)) | 1453 | if (FRAME_TERMCAP_P (f)) |
| 1437 | selection = tty_menu_show (f, xpos, ypos, for_click, | 1454 | selection = tty_menu_show (f, xpos, ypos, for_click, keymaps, title, |
| 1438 | keymaps, title, &error_name); | 1455 | kbd_menu_navigation, &error_name); |
| 1439 | 1456 | ||
| 1440 | #ifdef HAVE_NS | 1457 | #ifdef HAVE_NS |
| 1441 | unbind_to (specpdl_count, Qnil); | 1458 | unbind_to (specpdl_count, Qnil); |