Mercurial > hg > xemacs-beta
comparison src/menubar.c @ 412:697ef44129c6 r21-2-14
Import from CVS: tag r21-2-14
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:20:41 +0200 |
parents | 2f8bb876ab1d |
children | e804706bfb8c |
comparison
equal
deleted
inserted
replaced
411:12e008d41344 | 412:697ef44129c6 |
---|---|
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
20 Boston, MA 02111-1307, USA. */ | 20 Boston, MA 02111-1307, USA. */ |
21 | 21 |
22 /* Synched up with: Not in FSF. */ | 22 /* Synched up with: Not in FSF. */ |
23 | 23 |
24 /* Authorship: | 24 /* #### There ain't much here because menubars have not been |
25 | 25 properly abstracted yet. */ |
26 Created by Ben Wing as part of device-abstraction work for 19.12. | |
27 Menu filters and many other keywords added by Stig for 19.12. | |
28 Menu accelerators c. 1997? by ??. Moved here from event-stream.c. | |
29 Much other work post-1996 by ??. | |
30 */ | |
31 | 26 |
32 #include <config.h> | 27 #include <config.h> |
33 #include "lisp.h" | 28 #include "lisp.h" |
34 | 29 |
35 #include "buffer.h" | 30 #include "buffer.h" |
36 #include "device.h" | 31 #include "device.h" |
37 #include "frame.h" | 32 #include "frame.h" |
38 #include "gui.h" | 33 #include "gui.h" |
39 #include "keymap.h" | |
40 #include "menubar.h" | 34 #include "menubar.h" |
41 #include "redisplay.h" | 35 #include "redisplay.h" |
42 #include "window.h" | 36 #include "window.h" |
43 | 37 |
44 int menubar_show_keybindings; | 38 int menubar_show_keybindings; |
58 | 52 |
59 int popup_menu_titles; | 53 int popup_menu_titles; |
60 | 54 |
61 Lisp_Object Vmenubar_pointer_glyph; | 55 Lisp_Object Vmenubar_pointer_glyph; |
62 | 56 |
63 /* prefix key(s) that must match in order to activate menu. | |
64 This is ugly. fix me. | |
65 */ | |
66 Lisp_Object Vmenu_accelerator_prefix; | |
67 | |
68 /* list of modifier keys to match accelerator for top level menus */ | |
69 Lisp_Object Vmenu_accelerator_modifiers; | |
70 | |
71 /* whether menu accelerators are enabled */ | |
72 Lisp_Object Vmenu_accelerator_enabled; | |
73 | |
74 /* keymap for auxiliary menu accelerator functions */ | |
75 Lisp_Object Vmenu_accelerator_map; | |
76 | |
77 Lisp_Object Qmenu_force; | |
78 Lisp_Object Qmenu_fallback; | |
79 Lisp_Object Qmenu_quit; | |
80 Lisp_Object Qmenu_up; | |
81 Lisp_Object Qmenu_down; | |
82 Lisp_Object Qmenu_left; | |
83 Lisp_Object Qmenu_right; | |
84 Lisp_Object Qmenu_select; | |
85 Lisp_Object Qmenu_escape; | |
86 | |
87 static int | 57 static int |
88 menubar_variable_changed (Lisp_Object sym, Lisp_Object *val, | 58 menubar_variable_changed (Lisp_Object sym, Lisp_Object *val, |
89 Lisp_Object in_object, int flags) | 59 Lisp_Object in_object, int flags) |
90 { | 60 { |
91 MARK_MENUBAR_CHANGED; | 61 MARK_MENUBAR_CHANGED; |
123 { | 93 { |
124 update_frame_menubars (f); | 94 update_frame_menubars (f); |
125 } | 95 } |
126 | 96 |
127 Lisp_Object | 97 Lisp_Object |
128 current_frame_menubar (const struct frame* f) | 98 current_frame_menubar (CONST struct frame* f) |
129 { | 99 { |
130 struct window *w = XWINDOW (FRAME_LAST_NONMINIBUF_WINDOW (f)); | 100 struct window *w = XWINDOW (FRAME_LAST_NONMINIBUF_WINDOW (f)); |
131 return symbol_value_in_buffer (Qcurrent_menubar, w->buffer); | 101 return symbol_value_in_buffer (Qcurrent_menubar, w->buffer); |
132 } | 102 } |
133 | 103 |
134 Lisp_Object | 104 Lisp_Object |
135 menu_parse_submenu_keywords (Lisp_Object desc, Lisp_Object gui_item) | 105 menu_parse_submenu_keywords (Lisp_Object desc, struct gui_item* pgui_item) |
136 { | 106 { |
137 Lisp_Gui_Item *pgui_item = XGUI_ITEM (gui_item); | |
138 | |
139 /* Menu descriptor should be a list */ | 107 /* Menu descriptor should be a list */ |
140 CHECK_CONS (desc); | 108 CHECK_CONS (desc); |
141 | 109 |
142 /* First element may be menu name, although can be omitted. | 110 /* First element may be menu name, although can be omitted. |
143 Let's think that if stuff begins with anything than a keyword | 111 Let's think that if stuff begins with anything than a keyword |
160 CHECK_CONS (desc); | 128 CHECK_CONS (desc); |
161 val = XCAR (desc); | 129 val = XCAR (desc); |
162 desc = XCDR (desc); | 130 desc = XCDR (desc); |
163 if (!NILP (desc)) | 131 if (!NILP (desc)) |
164 CHECK_CONS (desc); | 132 CHECK_CONS (desc); |
165 gui_item_add_keyval_pair (gui_item, key, val, ERROR_ME); | 133 gui_item_add_keyval_pair (pgui_item, key, val, ERROR_ME); |
166 } | 134 } |
167 | 135 |
168 /* Return the rest - supposed to be a list of items */ | 136 /* Return the rest - supposed to be a list of items */ |
169 return desc; | 137 return desc; |
170 } | 138 } |
181 See also 'find-menu-item'. | 149 See also 'find-menu-item'. |
182 */ | 150 */ |
183 (desc, path)) | 151 (desc, path)) |
184 { | 152 { |
185 Lisp_Object path_entry, submenu_desc, submenu; | 153 Lisp_Object path_entry, submenu_desc, submenu; |
186 struct gcpro gcpro1, gcpro2; | 154 struct gcpro gcpro1; |
187 Lisp_Object gui_item = allocate_gui_item (); | 155 struct gui_item gui_item; |
188 Lisp_Gui_Item* pgui_item = XGUI_ITEM (gui_item); | 156 |
189 | 157 gui_item_init (&gui_item); |
190 GCPRO2 (gui_item, desc); | 158 GCPRO_GUI_ITEM (&gui_item); |
191 | 159 |
192 EXTERNAL_LIST_LOOP (path_entry, path) | 160 EXTERNAL_LIST_LOOP (path_entry, path) |
193 { | 161 { |
194 /* Verify that DESC describes a menu, not single item */ | 162 /* Verify that DESC describes a menu, not single item */ |
195 if (!CONSP (desc)) | 163 if (!CONSP (desc)) |
196 RETURN_UNGCPRO (Qnil); | 164 RETURN_UNGCPRO (Qnil); |
197 | 165 |
198 /* Parse this menu */ | 166 /* Parse this menu */ |
199 desc = menu_parse_submenu_keywords (desc, gui_item); | 167 desc = menu_parse_submenu_keywords (desc, &gui_item); |
200 | 168 |
201 /* Check that this (sub)menu is active */ | 169 /* Check that this (sub)menu is active */ |
202 if (!gui_item_active_p (gui_item)) | 170 if (!gui_item_active_p (&gui_item)) |
203 RETURN_UNGCPRO (Qnil); | 171 RETURN_UNGCPRO (Qnil); |
204 | 172 |
205 /* Apply :filter */ | 173 /* Apply :filter */ |
206 if (!NILP (pgui_item->filter)) | 174 if (!NILP (gui_item.filter)) |
207 desc = call1 (pgui_item->filter, desc); | 175 desc = call1 (gui_item.filter, desc); |
208 | 176 |
209 /* Find the next menu on the path inside this one */ | 177 /* Find the next menu on the path inside this one */ |
210 EXTERNAL_LIST_LOOP (submenu_desc, desc) | 178 EXTERNAL_LIST_LOOP (submenu_desc, desc) |
211 { | 179 { |
212 submenu = XCAR (submenu_desc); | 180 submenu = XCAR (submenu_desc); |
221 /* Submenu not found */ | 189 /* Submenu not found */ |
222 RETURN_UNGCPRO (Qnil); | 190 RETURN_UNGCPRO (Qnil); |
223 | 191 |
224 descend: | 192 descend: |
225 /* Prepare for the next iteration */ | 193 /* Prepare for the next iteration */ |
226 gui_item_init (gui_item); | 194 gui_item_init (&gui_item); |
227 } | 195 } |
228 | 196 |
229 /* We have successfully descended down the end of the path */ | 197 /* We have successfully descended down the end of the path */ |
230 UNGCPRO; | 198 UNGCPRO; |
231 return desc; | 199 return desc; |
320 } | 288 } |
321 | 289 |
322 DEFUN ("normalize-menu-item-name", Fnormalize_menu_item_name, 1, 2, 0, /* | 290 DEFUN ("normalize-menu-item-name", Fnormalize_menu_item_name, 1, 2, 0, /* |
323 Convert a menu item name string into normal form, and return the new string. | 291 Convert a menu item name string into normal form, and return the new string. |
324 Menu item names should be converted to normal form before being compared. | 292 Menu item names should be converted to normal form before being compared. |
325 This removes %_'s (accelerator indications) and converts %% to %. | |
326 */ | 293 */ |
327 (name, buffer)) | 294 (name, buffer)) |
328 { | 295 { |
329 struct buffer *buf = decode_buffer (buffer, 0); | 296 struct buffer *buf = decode_buffer (buffer, 0); |
330 Lisp_String *n; | 297 struct Lisp_String *n; |
331 Charcount end; | 298 Charcount end; |
332 int i; | 299 int i; |
333 Bufbyte *name_data; | 300 Bufbyte *name_data; |
334 Bufbyte *string_result; | 301 Bufbyte *string_result; |
335 Bufbyte *string_result_ptr; | 302 Bufbyte *string_result_ptr; |
376 | 343 |
377 void | 344 void |
378 syms_of_menubar (void) | 345 syms_of_menubar (void) |
379 { | 346 { |
380 defsymbol (&Qcurrent_menubar, "current-menubar"); | 347 defsymbol (&Qcurrent_menubar, "current-menubar"); |
381 | |
382 defsymbol (&Qmenu_force, "menu-force"); | |
383 defsymbol (&Qmenu_fallback, "menu-fallback"); | |
384 | |
385 defsymbol (&Qmenu_quit, "menu-quit"); | |
386 defsymbol (&Qmenu_up, "menu-up"); | |
387 defsymbol (&Qmenu_down, "menu-down"); | |
388 defsymbol (&Qmenu_left, "menu-left"); | |
389 defsymbol (&Qmenu_right, "menu-right"); | |
390 defsymbol (&Qmenu_select, "menu-select"); | |
391 defsymbol (&Qmenu_escape, "menu-escape"); | |
392 | |
393 DEFSUBR (Fpopup_menu); | 348 DEFSUBR (Fpopup_menu); |
394 DEFSUBR (Fnormalize_menu_item_name); | 349 DEFSUBR (Fnormalize_menu_item_name); |
395 DEFSUBR (Fmenu_find_real_submenu); | 350 DEFSUBR (Fmenu_find_real_submenu); |
396 } | 351 } |
397 | 352 |
398 void | 353 void |
399 vars_of_menubar (void) | 354 vars_of_menubar (void) |
400 { | 355 { |
401 /* put in Vblank_menubar a menubar value which has no visible | 356 { |
402 * items. This is a bit tricky due to various quirks. We | 357 /* put in Vblank_menubar a menubar value which has no visible |
403 * could use '(["" nil nil]), but this is apparently equivalent | 358 * items. This is a bit tricky due to various quirks. We |
404 * to '(nil), and a new frame created with this menubar will | 359 * could use '(["" nil nil]), but this is apparently equivalent |
405 * get a vertically-squished menubar. If we use " " as the | 360 * to '(nil), and a new frame created with this menubar will |
406 * button title instead of "", we get an etched button border. | 361 * get a vertically-squished menubar. If we use " " as the |
407 * So we use | 362 * button title instead of "", we get an etched button border. |
408 * '(("No active menubar" ["" nil nil])) | 363 * So we use |
409 * which creates a menu whose title is "No active menubar", | 364 * '(("No active menubar" ["" nil nil])) |
410 * and this works fine. | 365 * which creates a menu whose title is "No active menubar", |
411 */ | 366 * and this works fine. |
412 | 367 */ |
413 Vblank_menubar = list1 (list2 (build_string ("No active menubar"), | 368 |
414 vector3 (build_string (""), Qnil, Qnil))); | 369 Lisp_Object menu_item[3]; |
415 staticpro (&Vblank_menubar); | 370 static CONST char *blank_msg = "No active menubar"; |
371 | |
372 menu_item[0] = build_string (""); | |
373 menu_item[1] = Qnil; | |
374 menu_item[2] = Qnil; | |
375 Vblank_menubar = Fcons (Fcons (build_string (blank_msg), | |
376 Fcons (Fvector (3, &menu_item[0]), | |
377 Qnil)), | |
378 Qnil); | |
379 Vblank_menubar = Fpurecopy (Vblank_menubar); | |
380 staticpro (&Vblank_menubar); | |
381 } | |
416 | 382 |
417 DEFVAR_BOOL ("popup-menu-titles", &popup_menu_titles /* | 383 DEFVAR_BOOL ("popup-menu-titles", &popup_menu_titles /* |
418 If true, popup menus will have title bars at the top. | 384 If true, popup menus will have title bars at the top. |
419 */ ); | 385 */ ); |
420 popup_menu_titles = 1; | 386 popup_menu_titles = 1; |
438 The first element of a menu must be a string, which is the name of the menu. | 404 The first element of a menu must be a string, which is the name of the menu. |
439 This is the string that will be displayed in the parent menu, if any. For | 405 This is the string that will be displayed in the parent menu, if any. For |
440 toplevel menus, it is ignored. This string is not displayed in the menu | 406 toplevel menus, it is ignored. This string is not displayed in the menu |
441 itself. | 407 itself. |
442 | 408 |
443 Menu accelerators can be indicated in the string by putting the | 409 Immediately following the name string of the menu, any of three |
444 sequence "%_" before the character corresponding to the key that will | 410 optional keyword-value pairs is permitted. |
445 invoke the menu or menu item. Uppercase and lowercase accelerators | |
446 are equivalent. The sequence "%%" is also special, and is translated | |
447 into a single %. | |
448 | |
449 If no menu accelerator is present in the string, XEmacs will act as if | |
450 the first character has been tagged as an accelerator. | |
451 | |
452 Immediately following the name string of the menu, various optional | |
453 keyword-value pairs are permitted: currently, :filter, :active, :included, | |
454 and :config. (See below.) | |
455 | 411 |
456 If an element of a menu (or menubar) is a string, then that string will be | 412 If an element of a menu (or menubar) is a string, then that string will be |
457 presented as unselectable text. | 413 presented as unselectable text. |
458 | 414 |
459 If an element of a menu is a string consisting solely of hyphens, then that | 415 If an element of a menu is a string consisting solely of hyphens, then that |
460 item will be presented as a solid horizontal line. | 416 item will be presented as a solid horizontal line. |
461 | |
462 If an element of a menu is a string beginning with "--:", it will be | |
463 presented as a line whose appearance is controlled by the rest of the | |
464 text in the string. The allowed line specs are system-dependent, and | |
465 currently work only under X Windows (with Lucid and Motif menubars); | |
466 otherwise, a solid horizontal line is presented, as if the string were | |
467 all hyphens. | |
468 | |
469 The possibilities are: | |
470 | |
471 "--:singleLine" | |
472 "--:doubleLine" | |
473 "--:singleDashedLine" | |
474 "--:doubleDashedLine" | |
475 "--:noLine" | |
476 "--:shadowEtchedIn" | |
477 "--:shadowEtchedOut" | |
478 "--:shadowEtchedInDash" | |
479 "--:shadowEtchedOutDash" | |
480 "--:shadowDoubleEtchedIn" (Lucid menubars only) | |
481 "--:shadowDoubleEtchedOut" (Lucid menubars only) | |
482 "--:shadowDoubleEtchedInDash" (Lucid menubars only) | |
483 "--:shadowDoubleEtchedOutDash" (Lucid menubars only) | |
484 | 417 |
485 If an element of a menu is a list, it is treated as a submenu. The name of | 418 If an element of a menu is a list, it is treated as a submenu. The name of |
486 that submenu (the first element in the list) will be used as the name of the | 419 that submenu (the first element in the list) will be used as the name of the |
487 item representing this menu on the parent. | 420 item representing this menu on the parent. |
488 | 421 |
489 If an element of a menubar is `nil', then it is used to represent the | 422 If an element of a menubar is `nil', then it is used to represent the |
490 division between the set of menubar-items which are flushleft and those | 423 division between the set of menubar-items which are flushleft and those |
491 which are flushright. | 424 which are flushright. |
492 | 425 |
493 Otherwise, the element must be a vector, which describes a menu item. | 426 Otherwise, the element must be a vector, which describes a menu item. |
494 A menu item is of the following form: | 427 A menu item can have any of the following forms: |
495 | |
496 [ "name" callback :<keyword> <value> :<keyword> <value> ... ] | |
497 | |
498 The following forms are also accepted for compatibility, but deprecated: | |
499 | 428 |
500 [ "name" callback <active-p> ] | 429 [ "name" callback <active-p> ] |
501 [ "name" callback <active-p> <suffix> ] | 430 [ "name" callback <active-p> <suffix> ] |
431 [ "name" callback :<keyword> <value> :<keyword> <value> ... ] | |
502 | 432 |
503 The name is the string to display on the menu; it is filtered through the | 433 The name is the string to display on the menu; it is filtered through the |
504 resource database, so it is possible for resources to override what string | 434 resource database, so it is possible for resources to override what string |
505 is actually displayed. Menu accelerator indicators (the sequence `%_') are | 435 is actually displayed. |
506 also processed; see above. If the name is not a string, it will be | |
507 evaluated with `eval', and the result should be a string. | |
508 | 436 |
509 If the `callback' of a menu item is a symbol, then it must name a command. | 437 If the `callback' of a menu item is a symbol, then it must name a command. |
510 It will be invoked with `call-interactively'. If it is a list, then it is | 438 It will be invoked with `call-interactively'. If it is a list, then it is |
511 evaluated with `eval'. | 439 evaluated with `eval'. |
512 | 440 |
513 In the deprecated forms, <active-p> is equivalent to using the :active | 441 The possible keywords are this: |
514 keyword, and <suffix> is equivalent to using the :suffix keyword. | 442 |
515 | 443 :active <form> Same as <active-p> in the first two forms: the |
516 The possible keywords are: | 444 expression is evaluated just before the menu is |
517 | |
518 :active <form> The expression is evaluated just before the menu is | |
519 displayed, and the menu will be selectable only if | 445 displayed, and the menu will be selectable only if |
520 the result is non-nil. | 446 the result is non-nil. |
521 | 447 |
522 :suffix <form> The expression is evaluated just before the menu is | 448 :suffix <form> Same as <suffix> in the second form: the expression |
523 displayed and the resulting string is appended to | 449 is evaluated just before the menu is displayed and |
524 the displayed name, providing a convenient way of | 450 resulting string is appended to the displayed name, |
525 adding the name of a command's ``argument'' to the | 451 providing a convenient way of adding the name of a |
526 menu, like ``Kill Buffer NAME''. | 452 command's ``argument'' to the menu, like |
453 ``Kill Buffer NAME''. | |
527 | 454 |
528 :keys "string" Normally, the keyboard equivalents of commands in | 455 :keys "string" Normally, the keyboard equivalents of commands in |
529 menus are displayed when the `callback' is a symbol. | 456 menus are displayed when the `callback' is a symbol. |
530 This can be used to specify keys for more complex menu | 457 This can be used to specify keys for more complex menu |
531 items. It is passed through `substitute-command-keys' | 458 items. It is passed through `substitute-command-keys' |
558 :config <symbol> This is an efficient shorthand for | 485 :config <symbol> This is an efficient shorthand for |
559 :included (memq symbol menubar-configuration) | 486 :included (memq symbol menubar-configuration) |
560 See the variable `menubar-configuration'. | 487 See the variable `menubar-configuration'. |
561 | 488 |
562 :filter <function> A menu filter can only be used in a menu item list. | 489 :filter <function> A menu filter can only be used in a menu item list. |
563 (i.e. not in a menu item itself). It is used to | 490 (i.e.: not in a menu item itself). It is used to |
564 incrementally create a submenu only when it is selected | 491 sensitize or incrementally create a submenu only when |
565 by the user and not every time the menubar is activated. | 492 it is selected by the user and not every time the |
566 The filter function is passed the list of menu items in | 493 menubar is activated. The filter function is passed |
567 the submenu and must return a list of menu items to be | 494 the list of menu items in the submenu and must return a |
568 used for the menu. It must not destructively modify | 495 list of menu items to be used for the menu. It is |
569 the list of menu items passed to it. It is called only | 496 called only when the menu is about to be displayed, so |
570 when the menu is about to be displayed, so other menus | 497 other menus may already be displayed. Vile and |
571 may already be displayed. Vile and terrible things will | 498 terrible things will happen if a menu filter function |
572 happen if a menu filter function changes the current | 499 changes the current buffer, window, or frame. It |
573 buffer, window, or frame. It also should not raise, | 500 also should not raise, lower, or iconify any frames. |
574 lower, or iconify any frames. Basically, the filter | 501 Basically, the filter function should have no |
575 function should have no side-effects. | 502 side-effects. |
576 | 503 |
577 :key-sequence keys Used in FSF Emacs as an hint to an equivalent keybinding. | 504 :key-sequence keys Used in FSF Emacs as an hint to an equivalent keybinding. |
578 Ignored by XEmacs for easymenu.el compatibility. | 505 Ignored by XEnacs for easymenu.el compatability. |
506 | |
507 :label <form> (unimplemented!) Like :suffix, but replaces label | |
508 completely. | |
509 (might be added in 21.2). | |
579 | 510 |
580 For example: | 511 For example: |
581 | 512 |
582 ("%_File" | 513 ("File" |
583 :filter file-menu-filter ; file-menu-filter is a function that takes | 514 :filter file-menu-filter ; file-menu-filter is a function that takes |
584 ; one argument (a list of menu items) and | 515 ; one argument (a list of menu items) and |
585 ; returns a list of menu items | 516 ; returns a list of menu items |
586 [ "Save %_As..." write-file t ] | 517 [ "Save As..." write-file t ] |
587 [ "%_Revert Buffer" revert-buffer (buffer-modified-p) ] | 518 [ "Revert Buffer" revert-buffer (buffer-modified-p) ] |
588 [ "R%_ead Only" toggle-read-only :style toggle | 519 [ "Read Only" toggle-read-only :style toggle |
589 :selected buffer-read-only ] | 520 :selected buffer-read-only ] |
590 ) | 521 ) |
591 | 522 |
592 See menubar-items.el for many more examples. | 523 See x-menubar.el for many more examples. |
593 | 524 |
594 After the menubar is clicked upon, but before any menus are popped up, | 525 After the menubar is clicked upon, but before any menus are popped up, |
595 the functions on the `activate-menubar-hook' are invoked to make top-level | 526 the functions on the `activate-menubar-hook' are invoked to make top-level |
596 changes to the menus and menubar. Note, however, that the use of menu | 527 changes to the menus and menubar. Note, however, that the use of menu |
597 filters (using the :filter keyword) is usually a more efficient way to | 528 filters (using the :filter keyword) is usually a more efficient way to |
598 dynamically alter or sensitize menus. */, menubar_variable_changed); | 529 dynamically alter or sensitize menus. |
530 */, menubar_variable_changed); | |
599 | 531 |
600 Vcurrent_menubar = Qnil; | 532 Vcurrent_menubar = Qnil; |
601 | 533 |
602 DEFVAR_LISP ("activate-menubar-hook", &Vactivate_menubar_hook /* | 534 DEFVAR_LISP ("activate-menubar-hook", &Vactivate_menubar_hook /* |
603 Function or functions called before a menubar menu is pulled down. | 535 Function or functions called before a menubar menu is pulled down. |
639 This is a glyph; use `set-glyph-image' to change it. | 571 This is a glyph; use `set-glyph-image' to change it. |
640 If unspecified in a particular domain, the window-system-provided | 572 If unspecified in a particular domain, the window-system-provided |
641 default pointer is used. | 573 default pointer is used. |
642 */ ); | 574 */ ); |
643 | 575 |
644 DEFVAR_LISP ("menu-accelerator-prefix", &Vmenu_accelerator_prefix /* | |
645 Prefix key(s) that must be typed before menu accelerators will be activated. | |
646 Set this to a value acceptable by define-key. | |
647 | |
648 NOTE: This currently only has any effect under X Windows. | |
649 */ ); | |
650 Vmenu_accelerator_prefix = Qnil; | |
651 | |
652 DEFVAR_LISP ("menu-accelerator-modifiers", &Vmenu_accelerator_modifiers /* | |
653 Modifier keys which must be pressed to get to the top level menu accelerators. | |
654 This is a list of modifier key symbols. All modifier keys must be held down | |
655 while a valid menu accelerator key is pressed in order for the top level | |
656 menu to become active. | |
657 | |
658 NOTE: This currently only has any effect under X Windows. | |
659 | |
660 See also menu-accelerator-enabled and menu-accelerator-prefix. | |
661 */ ); | |
662 Vmenu_accelerator_modifiers = list1 (Qmeta); | |
663 | |
664 DEFVAR_LISP ("menu-accelerator-enabled", &Vmenu_accelerator_enabled /* | |
665 Whether menu accelerator keys can cause the menubar to become active. | |
666 If 'menu-force or 'menu-fallback, then menu accelerator keys can | |
667 be used to activate the top level menu. Once the menubar becomes active, the | |
668 accelerator keys can be used regardless of the value of this variable. | |
669 | |
670 menu-force is used to indicate that the menu accelerator key takes | |
671 precedence over bindings in the current keymap(s). menu-fallback means | |
672 that bindings in the current keymap take precedence over menu accelerator keys. | |
673 Thus a top level menu with an accelerator of "T" would be activated on a | |
674 keypress of Meta-t if menu-accelerator-enabled is menu-force. | |
675 However, if menu-accelerator-enabled is menu-fallback, then | |
676 Meta-t will not activate the menubar and will instead run the function | |
677 transpose-words, to which it is normally bound. | |
678 | |
679 See also menu-accelerator-modifiers and menu-accelerator-prefix. | |
680 */ ); | |
681 Vmenu_accelerator_enabled = Qnil; | |
682 | |
683 DEFVAR_LISP ("menu-accelerator-map", &Vmenu_accelerator_map /* | |
684 Keymap for use when the menubar is active. | |
685 The actions menu-quit, menu-up, menu-down, menu-left, menu-right, | |
686 menu-select and menu-escape can be mapped to keys in this map. | |
687 NOTE: This currently only has any effect under X Windows. | |
688 | |
689 menu-quit Immediately deactivate the menubar and any open submenus without | |
690 selecting an item. | |
691 menu-up Move the menu cursor up one row in the current menu. If the | |
692 move extends past the top of the menu, wrap around to the bottom. | |
693 menu-down Move the menu cursor down one row in the current menu. If the | |
694 move extends past the bottom of the menu, wrap around to the top. | |
695 If executed while the cursor is in the top level menu, move down | |
696 into the selected menu. | |
697 menu-left Move the cursor from a submenu into the parent menu. If executed | |
698 while the cursor is in the top level menu, move the cursor to the | |
699 left. If the move extends past the left edge of the menu, wrap | |
700 around to the right edge. | |
701 menu-right Move the cursor into a submenu. If the cursor is located in the | |
702 top level menu or is not currently on a submenu heading, then move | |
703 the cursor to the next top level menu entry. If the move extends | |
704 past the right edge of the menu, wrap around to the left edge. | |
705 menu-select Activate the item under the cursor. If the cursor is located on | |
706 a submenu heading, then move the cursor into the submenu. | |
707 menu-escape Pop up to the next level of menus. Moves from a submenu into its | |
708 parent menu. From the top level menu, this deactivates the | |
709 menubar. | |
710 | |
711 This keymap can also contain normal key-command bindings, in which case the | |
712 menubar is deactivated and the corresponding command is executed. | |
713 | |
714 The action bindings used by the menu accelerator code are designed to mimic | |
715 the actions of menu traversal keys in a commonly used PC operating system. | |
716 */ ); | |
717 | |
718 Fprovide (intern ("menubar")); | 576 Fprovide (intern ("menubar")); |
719 } | 577 } |
720 | 578 |
721 void | 579 void |
722 specifier_vars_of_menubar (void) | 580 specifier_vars_of_menubar (void) |
727 */ ); | 585 */ ); |
728 Vmenubar_visible_p = Fmake_specifier (Qboolean); | 586 Vmenubar_visible_p = Fmake_specifier (Qboolean); |
729 | 587 |
730 set_specifier_fallback (Vmenubar_visible_p, list1 (Fcons (Qnil, Qt))); | 588 set_specifier_fallback (Vmenubar_visible_p, list1 (Fcons (Qnil, Qt))); |
731 set_specifier_caching (Vmenubar_visible_p, | 589 set_specifier_caching (Vmenubar_visible_p, |
732 offsetof (struct window, menubar_visible_p), | 590 slot_offset (struct window, |
591 menubar_visible_p), | |
733 menubar_visible_p_changed, | 592 menubar_visible_p_changed, |
734 offsetof (struct frame, menubar_visible_p), | 593 slot_offset (struct frame, |
594 menubar_visible_p), | |
735 menubar_visible_p_changed_in_frame); | 595 menubar_visible_p_changed_in_frame); |
736 } | 596 } |
737 | 597 |
738 void | 598 void |
739 complex_vars_of_menubar (void) | 599 complex_vars_of_menubar (void) |
740 { | 600 { |
741 Vmenubar_pointer_glyph = Fmake_glyph_internal (Qpointer); | 601 Vmenubar_pointer_glyph = Fmake_glyph_internal (Qpointer); |
742 | 602 } |
743 Vmenu_accelerator_map = Fmake_keymap (Qnil); | |
744 } |