diff options
Diffstat (limited to 'src/menu.c')
| -rw-r--r-- | src/menu.c | 96 |
1 files changed, 51 insertions, 45 deletions
diff --git a/src/menu.c b/src/menu.c index d569b4b29b5..b40c2c04ce7 100644 --- a/src/menu.c +++ b/src/menu.c | |||
| @@ -1112,51 +1112,8 @@ into menu items. */) | |||
| 1112 | return Qnil; | 1112 | return Qnil; |
| 1113 | } | 1113 | } |
| 1114 | 1114 | ||
| 1115 | 1115 | Lisp_Object | |
| 1116 | DEFUN ("x-popup-menu", Fx_popup_menu, Sx_popup_menu, 2, 2, 0, | 1116 | x_popup_menu_1 (Lisp_Object position, Lisp_Object menu) |
| 1117 | doc: /* Pop up a deck-of-cards menu and return user's selection. | ||
| 1118 | POSITION is a position specification. This is either a mouse button event | ||
| 1119 | or a list ((XOFFSET YOFFSET) WINDOW) | ||
| 1120 | where XOFFSET and YOFFSET are positions in pixels from the top left | ||
| 1121 | corner of WINDOW. (WINDOW may be a window or a frame object.) | ||
| 1122 | This controls the position of the top left of the menu as a whole. | ||
| 1123 | If POSITION is t, it means to use the current mouse position. | ||
| 1124 | |||
| 1125 | MENU is a specifier for a menu. For the simplest case, MENU is a keymap. | ||
| 1126 | The menu items come from key bindings that have a menu string as well as | ||
| 1127 | a definition; actually, the "definition" in such a key binding looks like | ||
| 1128 | \(STRING . REAL-DEFINITION). To give the menu a title, put a string into | ||
| 1129 | the keymap as a top-level element. | ||
| 1130 | |||
| 1131 | If REAL-DEFINITION is nil, that puts a nonselectable string in the menu. | ||
| 1132 | Otherwise, REAL-DEFINITION should be a valid key binding definition. | ||
| 1133 | |||
| 1134 | You can also use a list of keymaps as MENU. | ||
| 1135 | Then each keymap makes a separate pane. | ||
| 1136 | |||
| 1137 | When MENU is a keymap or a list of keymaps, the return value is the | ||
| 1138 | list of events corresponding to the user's choice. Note that | ||
| 1139 | `x-popup-menu' does not actually execute the command bound to that | ||
| 1140 | sequence of events. | ||
| 1141 | |||
| 1142 | Alternatively, you can specify a menu of multiple panes | ||
| 1143 | with a list of the form (TITLE PANE1 PANE2...), | ||
| 1144 | where each pane is a list of form (TITLE ITEM1 ITEM2...). | ||
| 1145 | Each ITEM is normally a cons cell (STRING . VALUE); | ||
| 1146 | but a string can appear as an item--that makes a nonselectable line | ||
| 1147 | in the menu. | ||
| 1148 | With this form of menu, the return value is VALUE from the chosen item. | ||
| 1149 | |||
| 1150 | If POSITION is nil, don't display the menu at all, just precalculate the | ||
| 1151 | cached information about equivalent key sequences. | ||
| 1152 | |||
| 1153 | If the user gets rid of the menu without making a valid choice, for | ||
| 1154 | instance by clicking the mouse away from a valid choice or by typing | ||
| 1155 | keyboard input, then this normally results in a quit and | ||
| 1156 | `x-popup-menu' does not return. But if POSITION is a mouse button | ||
| 1157 | event (indicating that the user invoked the menu with the mouse) then | ||
| 1158 | no quit occurs and `x-popup-menu' returns nil. */) | ||
| 1159 | (Lisp_Object position, Lisp_Object menu) | ||
| 1160 | { | 1117 | { |
| 1161 | Lisp_Object keymap, tem, tem2; | 1118 | Lisp_Object keymap, tem, tem2; |
| 1162 | int xpos = 0, ypos = 0; | 1119 | int xpos = 0, ypos = 0; |
| @@ -1443,6 +1400,55 @@ no quit occurs and `x-popup-menu' returns nil. */) | |||
| 1443 | return selection; | 1400 | return selection; |
| 1444 | } | 1401 | } |
| 1445 | 1402 | ||
| 1403 | DEFUN ("x-popup-menu", Fx_popup_menu, Sx_popup_menu, 2, 2, 0, | ||
| 1404 | doc: /* Pop up a deck-of-cards menu and return user's selection. | ||
| 1405 | POSITION is a position specification. This is either a mouse button event | ||
| 1406 | or a list ((XOFFSET YOFFSET) WINDOW) | ||
| 1407 | where XOFFSET and YOFFSET are positions in pixels from the top left | ||
| 1408 | corner of WINDOW. (WINDOW may be a window or a frame object.) | ||
| 1409 | This controls the position of the top left of the menu as a whole. | ||
| 1410 | If POSITION is t, it means to use the current mouse position. | ||
| 1411 | |||
| 1412 | MENU is a specifier for a menu. For the simplest case, MENU is a keymap. | ||
| 1413 | The menu items come from key bindings that have a menu string as well as | ||
| 1414 | a definition; actually, the "definition" in such a key binding looks like | ||
| 1415 | \(STRING . REAL-DEFINITION). To give the menu a title, put a string into | ||
| 1416 | the keymap as a top-level element. | ||
| 1417 | |||
| 1418 | If REAL-DEFINITION is nil, that puts a nonselectable string in the menu. | ||
| 1419 | Otherwise, REAL-DEFINITION should be a valid key binding definition. | ||
| 1420 | |||
| 1421 | You can also use a list of keymaps as MENU. | ||
| 1422 | Then each keymap makes a separate pane. | ||
| 1423 | |||
| 1424 | When MENU is a keymap or a list of keymaps, the return value is the | ||
| 1425 | list of events corresponding to the user's choice. Note that | ||
| 1426 | `x-popup-menu' does not actually execute the command bound to that | ||
| 1427 | sequence of events. | ||
| 1428 | |||
| 1429 | Alternatively, you can specify a menu of multiple panes | ||
| 1430 | with a list of the form (TITLE PANE1 PANE2...), | ||
| 1431 | where each pane is a list of form (TITLE ITEM1 ITEM2...). | ||
| 1432 | Each ITEM is normally a cons cell (STRING . VALUE); | ||
| 1433 | but a string can appear as an item--that makes a nonselectable line | ||
| 1434 | in the menu. | ||
| 1435 | With this form of menu, the return value is VALUE from the chosen item. | ||
| 1436 | |||
| 1437 | If POSITION is nil, don't display the menu at all, just precalculate the | ||
| 1438 | cached information about equivalent key sequences. | ||
| 1439 | |||
| 1440 | If the user gets rid of the menu without making a valid choice, for | ||
| 1441 | instance by clicking the mouse away from a valid choice or by typing | ||
| 1442 | keyboard input, then this normally results in a quit and | ||
| 1443 | `x-popup-menu' does not return. But if POSITION is a mouse button | ||
| 1444 | event (indicating that the user invoked the menu with the mouse) then | ||
| 1445 | no quit occurs and `x-popup-menu' returns nil. */) | ||
| 1446 | (Lisp_Object position, Lisp_Object menu) | ||
| 1447 | { | ||
| 1448 | init_raw_keybuf_count (); | ||
| 1449 | return x_popup_menu_1 (position, menu); | ||
| 1450 | } | ||
| 1451 | |||
| 1446 | /* If F's terminal is not capable of displaying a popup dialog, | 1452 | /* If F's terminal is not capable of displaying a popup dialog, |
| 1447 | emulate it with a menu. */ | 1453 | emulate it with a menu. */ |
| 1448 | 1454 | ||