annotate src/menubar.c @ 2367:ecf1ebac70d8

[xemacs-hg @ 2004-11-04 23:05:23 by ben] commit mega-patch configure.in: Turn off -Winline and -Wchar-subscripts. Use the right set of cflags when compiling modules. Rewrite ldap configuration to separate the inclusion of lber (needed in recent Cygwin) from the basic checks for the needed libraries. add a function for MAKE_JUNK_C; initially code was added to generate xemacs.def using this, but it will need to be rewritten. add an rm -f for junk.c to avoid weird Cygwin bug with cp -f onto an existing file. Sort list of auto-detected functions and eliminate unused checks for stpcpy, setlocale and getwd. Add autodetection of Cygwin scanf problems BETA: Rewrite section on configure to indicate what flags are important and what not. digest-doc.c, make-dump-id.c, profile.c, sorted-doc.c: Add proper decls for main(). make-msgfile.c: Document that this is old junk. Move proposal to text.c. make-msgfile.lex: Move proposal to text.c. make-mswin-unicode.pl: Convert error-generating code so that the entire message will be seen as a single unrecognized token. mule/mule-ccl.el: Update docs. lispref/mule.texi: Update CCL docs. ldap/eldap.c: Mule-ize. Use EXTERNAL_LIST_LOOP_2 instead of deleted EXTERNAL_LIST_LOOP. * XEmacs 21.5.18 "chestnut" is released. --------------------------------------------------------------- MULE-RELATED WORK: --------------------------------------------------------------- --------------------------- byte-char conversion --------------------------- buffer.c, buffer.h, insdel.c, text.c: Port FSF algorithm for byte-char conversion, replacing broken previous version. Track the char position of the gap. Add functions to do char-byte conversion downwards as well as upwards. Move comments about algorithm workings to internals manual. --------------------------- work on types --------------------------- alloc.c, console-x-impl.h, dump-data.c, dump-data.h, dumper.c, dialog-msw.c, dired-msw.c, doc.c, editfns.c, esd.c, event-gtk.h, event-msw.c, events.c, file-coding.c, file-coding.h, fns.c, glyphs-eimage.c, glyphs-gtk.c, glyphs-msw.c, glyphs-shared.c, glyphs-x.c, glyphs.c, glyphs.h, gui.c, hpplay.c, imgproc.c, intl-win32.c, lrecord.h, lstream.c, keymap.c, lisp.h, libsst.c, linuxplay.c, miscplay.c, miscplay.h, mule-coding.c, nas.c, nt.c, ntheap.c, ntplay.c, objects-msw.c, objects-tty.c, objects-x.c, print.c, process-nt.c, process.c, redisplay.h, select-common.h, select-gtk.c, select-x.c, sgiplay.c, sound.c, sound.h, sunplay.c, sysfile.h, sysdep.c, syswindows.h, text.c, unexnt.c, win32.c, xgccache.c: Further work on types. This creates a full set of types for all the basic semantics of `char' that I have so far identified, so that its semantics can always be identified for the purposes of proper Mule-safe code, and the raw use of `char' always avoided. (1) More type renaming, for consistency of naming. Char_ASCII -> Ascbyte UChar_ASCII -> UAscbyte Char_Binary -> CBinbyte UChar_Binary -> Binbyte SChar_Binary -> SBinbyte (2) Introduce Rawbyte, CRawbyte, Boolbyte, Chbyte, UChbyte, and Bitbyte and use them. (3) New types Itext, Wexttext and Textcount for separating out the concepts of bytes and textual units (different under UTF-16 and UTF-32, which are potential internal encodings). (4) qxestr*_c -> qxestr*_ascii. lisp.h: New; goes with other qxe() functions. #### Maybe goes in a different section. lisp.h: Group generic int-type defs together with EMACS_INT defs. lisp.h: * lisp.h (WEXTTEXT_IS_WIDE) New defns. lisp.h: New type to replace places where int occurs as a boolean. It's signed because occasionally people may want to use -1 as an error value, and because unsigned ints are viral -- see comments in the internals manual against using them. dynarr.c: int -> Bytecount. --------------------------- Mule-izing --------------------------- device-x.c: Partially Mule-ize. dumper.c, dumper.h: Mule-ize. Use Rawbyte. Use stderr_out not printf. Use wext_*(). sysdep.c, syswindows.h, text.c: New Wexttext API for manipulation of external text that may be Unicode (e.g. startup code under Windows). emacs.c: Mule-ize. Properly deal with argv in external encoding. Use wext_*() and Wexttext. Use Rawbyte. #if 0 some old junk on SCO that is unlikely to be correct. Rewrite allocation code in run-temacs. emacs.c, symsinit.h, win32.c: Rename win32 init function and call it even earlier, to initialize mswindows_9x_p even earlier, for use in startup code (XEUNICODE_P). process.c: Use _wenviron not environ under Windows, to get Unicode environment variables. event-Xt.c: Mule-ize drag-n-drop related stuff. dragdrop.c, dragdrop.h, frame-x.c: Mule-ize. text.h: Add some more stand-in defines for particular kinds of conversion; use in Mule-ization work in frame-x.c etc. --------------------------- Freshening --------------------------- intl-auto-encap-win32.c, intl-auto-encap-win32.h: Regenerate. --------------------------- Unicode-work --------------------------- intl-win32.c, syswindows.h: Factor out common options to MultiByteToWideChar and WideCharToMultiByte. Add convert_unicode_to_multibyte_malloc() and convert_unicode_to_multibyte_dynarr() and use. Add stuff for alloca() conversion of multibyte/unicode. alloc.c: Use dfc_external_data_len() in case of unicode coding system. alloc.c, mule-charset.c: Don't zero out and reinit charset Unicode tables. This fucks up dump-time loading. Anyway, either we load them at dump time or run time, never both. unicode.c: Dump the blank tables as well. --------------------------------------------------------------- DOCUMENTATION, MOSTLY MULE-RELATED: --------------------------------------------------------------- EmacsFrame.c, emodules.c, event-Xt.c, fileio.c, input-method-xlib.c, mule-wnnfns.c, redisplay-gtk.c, redisplay-tty.c, redisplay-x.c, regex.c, sysdep.c: Add comment about Mule work needed. text.h: Add more documentation describing why DFC routines were not written to return their value. Add some other DFC documentation. console-msw.c, console-msw.h: Add pointer to docs in win32.c. emacs.c: Add comments on sources of doc info. text.c, charset.h, unicode.c, intl-win32.c, intl-encap-win32.c, text.h, file-coding.c, mule-coding.c: Collect background comments and related to text matters and internationalization, and proposals for work to be done, in text.c or Internals manual, stuff related to specific textual API's in text.h, and stuff related to internal implementation of Unicode conversion in unicode.c. Put lots of pointers to the comments to make them easier to find. s/mingw32.h, s/win32-common.h, s/win32-native.h, s/windowsnt.h, win32.c: Add bunches of new documentation on the different kinds of builds and environments under Windows and how they work. Collect this info in win32.c. Add pointers to these docs in the relevant s/* files. emacs.c: Document places with long comments. Remove comment about exiting, move to internals manual, put in pointer. event-stream.c: Move docs about event queues and focus to internals manual, put in pointer. events.h: Move docs about event stream callbacks to internals manual, put in pointer. profile.c, redisplay.c, signal.c: Move documentation to the Internals manual. process-nt.c: Add pointer to comment in win32-native.el. lisp.h: Add comments about some comment conventions. lisp.h: Add comment about the second argument. device-msw.c, redisplay-msw.c: @@#### comments are out-of-date. --------------------------------------------------------------- PDUMP WORK (MOTIVATED BY UNICODE CHANGES) --------------------------------------------------------------- alloc.c, buffer.c, bytecode.c, console-impl.h, console.c, device.c, dumper.c, lrecord.h, elhash.c, emodules.h, events.c, extents.c, frame.c, glyphs.c, glyphs.h, mule-charset.c, mule-coding.c, objects.c, profile.c, rangetab.c, redisplay.c, specifier.c, specifier.h, window.c, lstream.c, file-coding.h, file-coding.c: PDUMP: Properly implement dump_add_root_block(), which never worked before, and is necessary for dumping Unicode tables. Pdump name changes for accuracy: XD_STRUCT_PTR -> XD_BLOCK_PTR. XD_STRUCT_ARRAY -> XD_BLOCK_ARRAY. XD_C_STRING -> XD_ASCII_STRING. *_structure_* -> *_block_*. lrecord.h: some comments added about dump_add_root_block() vs dump_add_root_block_ptr(). extents.c: remove incorrect comment about pdump problems with gap array. --------------------------------------------------------------- ALLOCATION --------------------------------------------------------------- abbrev.c, alloc.c, bytecode.c, casefiddle.c, device-msw.c, device-x.c, dired-msw.c, doc.c, doprnt.c, dragdrop.c, editfns.c, emodules.c, file-coding.c, fileio.c, filelock.c, fns.c, glyphs-eimage.c, glyphs-gtk.c, glyphs-msw.c, glyphs-x.c, gui-msw.c, gui-x.c, imgproc.c, intl-win32.c, lread.c, menubar-gtk.c, menubar.c, nt.c, objects-msw.c, objects-x.c, print.c, process-nt.c, process-unix.c, process.c, realpath.c, redisplay.c, search.c, select-common.c, symbols.c, sysdep.c, syswindows.h, text.c, text.h, ui-byhand.c: New macros {alloca,xnew}_{itext,{i,ext,raw,bin,asc}bytes} for more convenient allocation of these commonly requested items. Modify functions to use alloca_ibytes, alloca_array, alloca_extbytes, xnew_ibytes, etc. also XREALLOC_ARRAY, xnew. alloc.c: Rewrite the allocation functions to factor out repeated code. Add assertions for freeing dumped data. lisp.h: Moved down and consolidated with other allocation stuff. lisp.h, dynarr.c: New functions for allocation that's very efficient when mostly in LIFO order. lisp.h, text.c, text.h: Factor out some stuff for general use by alloca()-conversion funs. text.h, lisp.h: Fill out convenience routines for allocating various kinds of bytes and put them in lisp.h. Use them in place of xmalloc(), ALLOCA(). text.h: Fill out the convenience functions so the _MALLOC() kinds match the alloca() kinds. --------------------------------------------------------------- ERROR-CHECKING --------------------------------------------------------------- text.h: Create ASSERT_ASCTEXT_ASCII() and ASSERT_ASCTEXT_ASCII_LEN() from similar Eistring checkers and change the Eistring checkers to use them instead. --------------------------------------------------------------- MACROS IN LISP.H --------------------------------------------------------------- lisp.h: Redo GCPRO declarations. Create a "base" set of functions that can be used to generate any kind of gcpro sets -- regular, ngcpro, nngcpro, private ones used in GC_EXTERNAL_LIST_LOOP_2. buffer.c, callint.c, chartab.c, console-msw.c, device-x.c, dialog-msw.c, dired.c, extents.c, ui-gtk.c, rangetab.c, nt.c, mule-coding.c, minibuf.c, menubar-msw.c, menubar.c, menubar-gtk.c, lread.c, lisp.h, gutter.c, glyphs.c, glyphs-widget.c, fns.c, fileio.c, file-coding.c, specifier.c: Eliminate EXTERNAL_LIST_LOOP, which does not check for circularities. Use EXTERNAL_LIST_LOOP_2 instead or EXTERNAL_LIST_LOOP_3 or EXTERNAL_PROPERTY_LIST_LOOP_3 or GC_EXTERNAL_LIST_LOOP_2 (new macro). Removed/redid comments on EXTERNAL_LIST_LOOP. --------------------------------------------------------------- SPACING FIXES --------------------------------------------------------------- callint.c, hftctl.c, number-gmp.c, process-unix.c: Spacing fixes. --------------------------------------------------------------- FIX FOR GEOMETRY PROBLEM IN FIRST FRAME --------------------------------------------------------------- unicode.c: Add workaround for newlib bug in sscanf() [should be fixed by release 1.5.12 of Cygwin]. toolbar.c: bug fix for problem of initial frame being 77 chars wide on Windows. will be overridden by my other ws. --------------------------------------------------------------- FIX FOR LEAKING PROCESS HANDLES: --------------------------------------------------------------- process-nt.c: Fixes for leaking handles. Inspired by work done by Adrian Aichner <adrian@xemacs.org>. --------------------------------------------------------------- FIX FOR CYGWIN BUG (Unicode-related): --------------------------------------------------------------- unicode.c: Add workaround for newlib bug in sscanf() [should be fixed by release 1.5.12 of Cygwin]. --------------------------------------------------------------- WARNING FIXES: --------------------------------------------------------------- console-stream.c: `reinit' is unused. compiler.h, event-msw.c, frame-msw.c, intl-encap-win32.c, text.h: Add stuff to deal with ANSI-aliasing warnings I got. regex.c: Gather includes together to avoid warning. --------------------------------------------------------------- CHANGES TO INITIALIZATION ROUTINES: --------------------------------------------------------------- buffer.c, emacs.c, console.c, debug.c, device-x.c, device.c, dragdrop.c, emodules.c, eval.c, event-Xt.c, event-gtk.c, event-msw.c, event-stream.c, event-tty.c, events.c, extents.c, faces.c, file-coding.c, fileio.c, font-lock.c, frame-msw.c, glyphs-widget.c, glyphs.c, gui-x.c, insdel.c, lread.c, lstream.c, menubar-gtk.c, menubar-x.c, minibuf.c, mule-wnnfns.c, objects-msw.c, objects.c, print.c, scrollbar-x.c, search.c, select-x.c, text.c, undo.c, unicode.c, window.c, symsinit.h: Call reinit_*() functions directly from emacs.c, for clarity. Factor out some redundant init code. Move disallowed stuff that had crept into vars_of_glyphs() into complex_vars_of_glyphs(). Call init_eval_semi_early() from eval.c not in the middle of vars_of_() in emacs.c since there should be no order dependency in the latter calls. --------------------------------------------------------------- ARMAGEDDON: --------------------------------------------------------------- alloc.c, emacs.c, lisp.h, print.c: Rename inhibit_non_essential_printing_operations to inhibit_non_essential_conversion_operations. text.c: Assert on !inhibit_non_essential_conversion_operations. console-msw.c, print.c: Don't do conversion in SetConsoleTitle or FindWindow to avoid problems during armageddon. Put #errors for NON_ASCII_INTERNAL_FORMAT in places where problems would arise. --------------------------------------------------------------- CHANGES TO THE BUILD PROCEDURE: --------------------------------------------------------------- config.h.in, s/cxux.h, s/usg5-4-2.h, m/powerpc.h: Add comment about correct ordering of this file. Rearrange everything to follow this -- put all #undefs together and before the s&m files. Add undefs for HAVE_ALLOCA, C_ALLOCA, BROKEN_ALLOCA_IN_FUNCTION_CALLS, STACK_DIRECTION. Remove unused HAVE_STPCPY, HAVE_GETWD, HAVE_SETLOCALE. m/gec63.h: Deleted; totally broken, not used at all, not in FSF. m/7300.h, m/acorn.h, m/alliant-2800.h, m/alliant.h, m/altos.h, m/amdahl.h, m/apollo.h, m/att3b.h, m/aviion.h, m/celerity.h, m/clipper.h, m/cnvrgnt.h, m/convex.h, m/cydra5.h, m/delta.h, m/delta88k.h, m/dpx2.h, m/elxsi.h, m/ews4800r.h, m/gould.h, m/hp300bsd.h, m/hp800.h, m/hp9000s300.h, m/i860.h, m/ibmps2-aix.h, m/ibmrs6000.h, m/ibmrt-aix.h, m/ibmrt.h, m/intel386.h, m/iris4d.h, m/iris5d.h, m/iris6d.h, m/irist.h, m/isi-ov.h, m/luna88k.h, m/m68k.h, m/masscomp.h, m/mg1.h, m/mips-nec.h, m/mips-siemens.h, m/mips.h, m/news.h, m/nh3000.h, m/nh4000.h, m/ns32000.h, m/orion105.h, m/pfa50.h, m/plexus.h, m/pmax.h, m/powerpc.h, m/pyrmips.h, m/sequent-ptx.h, m/sequent.h, m/sgi-challenge.h, m/symmetry.h, m/tad68k.h, m/tahoe.h, m/targon31.h, m/tekxd88.h, m/template.h, m/tower32.h, m/tower32v3.h, m/ustation.h, m/vax.h, m/wicat.h, m/xps100.h: Delete C_ALLOCA, HAVE_ALLOCA, STACK_DIRECTION, BROKEN_ALLOCA_IN_FUNCTION_CALLS. All of this is auto-detected. When in doubt, I followed recent FSF sources, which also have these things deleted.
author ben
date Thu, 04 Nov 2004 23:08:28 +0000
parents 04bc9d2f42c7
children 9caf26dd924f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1 /* Implements an elisp-programmable menubar.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2 Copyright (C) 1993, 1994 Free Software Foundation, Inc.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3 Copyright (C) 1995 Tinker Systems and INS Engineering Corp.
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 800
diff changeset
4 Copyright (C) 2001, 2002 Ben Wing.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6 This file is part of XEmacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
7
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
8 XEmacs is free software; you can redistribute it and/or modify it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
9 under the terms of the GNU General Public License as published by the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
10 Free Software Foundation; either version 2, or (at your option) any
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
11 later version.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
12
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
13 XEmacs is distributed in the hope that it will be useful, but WITHOUT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
16 for more details.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
17
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
18 You should have received a copy of the GNU General Public License
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
19 along with XEmacs; see the file COPYING. If not, write to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
21 Boston, MA 02111-1307, USA. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
22
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
23 /* Synched up with: Not in FSF. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
24
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
25 /* Authorship:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
26
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
27 Created by Ben Wing as part of device-abstraction work for 19.12.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
28 Menu filters and many other keywords added by Stig for 19.12.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
29 Menu accelerators c. 1997? by ??. Moved here from event-stream.c.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
30 Much other work post-1996 by ??.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
31 */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
32
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
33 #include <config.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
34 #include "lisp.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
35
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
36 #include "buffer.h"
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
37 #include "device-impl.h"
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
38 #include "frame-impl.h"
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
39 #include "gui.h"
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
40 #include "keymap.h"
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
41 #include "menubar.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
42 #include "redisplay.h"
800
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 793
diff changeset
43 #include "specifier.h"
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
44 #include "window-impl.h"
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
45
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
46 int menubar_show_keybindings;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
47 Lisp_Object Vmenubar_configuration;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
48
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
49 Lisp_Object Qcurrent_menubar;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
50
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
51 Lisp_Object Qactivate_menubar_hook, Vactivate_menubar_hook;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
52
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
53 Lisp_Object Vmenubar_visible_p;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
54
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
55 static Lisp_Object Vcurrent_menubar; /* DO NOT ever reference this.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
56 Always go through Qcurrent_menubar.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
57 See below. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
58
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
59 Lisp_Object Vblank_menubar;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
60
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
61 int popup_menu_titles;
1279
cd0abfdb9e9d [xemacs-hg @ 2003-02-09 09:33:42 by ben]
ben
parents: 872
diff changeset
62 int in_menu_callback;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
63
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
64 Lisp_Object Vmenubar_pointer_glyph;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
65
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
66 /* prefix key(s) that must match in order to activate menu.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
67 This is ugly. fix me.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
68 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
69 Lisp_Object Vmenu_accelerator_prefix;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
70
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
71 /* list of modifier keys to match accelerator for top level menus */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
72 Lisp_Object Vmenu_accelerator_modifiers;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
73
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
74 /* whether menu accelerators are enabled */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
75 Lisp_Object Vmenu_accelerator_enabled;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
76
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
77 /* keymap for auxiliary menu accelerator functions */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
78 Lisp_Object Vmenu_accelerator_map;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
79
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
80 Lisp_Object Qmenu_force;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
81 Lisp_Object Qmenu_fallback;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
82 Lisp_Object Qmenu_quit;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
83 Lisp_Object Qmenu_up;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
84 Lisp_Object Qmenu_down;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
85 Lisp_Object Qmenu_left;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
86 Lisp_Object Qmenu_right;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
87 Lisp_Object Qmenu_select;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
88 Lisp_Object Qmenu_escape;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
89
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
90 static int
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1913
diff changeset
91 menubar_variable_changed (Lisp_Object UNUSED (sym), Lisp_Object *UNUSED (val),
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1913
diff changeset
92 Lisp_Object UNUSED (in_object), int UNUSED (flags))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
93 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
94 MARK_MENUBAR_CHANGED;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
95 return 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
96 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
97
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
98 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
99 update_frame_menubars (struct frame *f)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
100 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
101 if (f->menubar_changed || f->windows_changed)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
102 MAYBE_FRAMEMETH (f, update_frame_menubars, (f));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
103
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
104 f->menubar_changed = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
105 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
106
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
107 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
108 free_frame_menubars (struct frame *f)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
109 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
110 /* If we had directly allocated any memory for the menubars instead
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
111 of using all Lisp_Objects this is where we would now free it. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
112
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
113 MAYBE_FRAMEMETH (f, free_frame_menubars, (f));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
114 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
115
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
116 static void
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1913
diff changeset
117 menubar_visible_p_changed (Lisp_Object UNUSED (specifier),
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1913
diff changeset
118 struct window *UNUSED (w),
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1913
diff changeset
119 Lisp_Object UNUSED (oldval))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
120 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
121 MARK_MENUBAR_CHANGED;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
122 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
123
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
124 static void
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1913
diff changeset
125 menubar_visible_p_changed_in_frame (Lisp_Object UNUSED (specifier),
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1913
diff changeset
126 struct frame *f,
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 1913
diff changeset
127 Lisp_Object UNUSED (oldval))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
128 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
129 update_frame_menubars (f);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
130 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
131
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
132 Lisp_Object
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
133 current_frame_menubar (const struct frame* f)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
134 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
135 struct window *w = XWINDOW (FRAME_LAST_NONMINIBUF_WINDOW (f));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
136 return symbol_value_in_buffer (Qcurrent_menubar, w->buffer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
137 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
138
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
139 Lisp_Object
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
140 menu_parse_submenu_keywords (Lisp_Object desc, Lisp_Object gui_item)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
141 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
142 Lisp_Gui_Item *pgui_item = XGUI_ITEM (gui_item);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
143
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
144 /* Menu descriptor should be a list */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
145 CHECK_CONS (desc);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
146
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
147 /* First element may be menu name, although can be omitted.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
148 Let's think that if stuff begins with anything than a keyword
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
149 or a list (submenu), this is a menu name, expected to be a string */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
150 if (!KEYWORDP (XCAR (desc)) && !CONSP (XCAR (desc)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
151 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
152 CHECK_STRING (XCAR (desc));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
153 pgui_item->name = XCAR (desc);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
154 desc = XCDR (desc);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
155 if (!NILP (desc))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
156 CHECK_CONS (desc);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
157 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
158
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
159 /* Walk along all key-value pairs */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
160 while (!NILP(desc) && KEYWORDP (XCAR (desc)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
161 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
162 Lisp_Object key, val;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
163 key = XCAR (desc);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
164 desc = XCDR (desc);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
165 CHECK_CONS (desc);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
166 val = XCAR (desc);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
167 desc = XCDR (desc);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
168 if (!NILP (desc))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
169 CHECK_CONS (desc);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
170 gui_item_add_keyval_pair (gui_item, key, val, ERROR_ME);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
171 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
172
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
173 /* Return the rest - supposed to be a list of items */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
174 return desc;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
175 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
176
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
177 DEFUN ("menu-find-real-submenu", Fmenu_find_real_submenu, 2, 2, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
178 Find a submenu descriptor within DESC by following PATH.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
179 This function finds a submenu descriptor, either from the description
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
180 DESC or generated by a filter within DESC. The function regards :config
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
181 and :included keywords in the DESC, and expands submenus along the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
182 PATH using :filter functions. Return value is a descriptor for the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
183 submenu, NOT expanded and NOT checked against :config and :included.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
184 Also, individual menu items are not looked for, only submenus.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
185
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
186 See also 'find-menu-item'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
187 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
188 (desc, path))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
189 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
190 struct gcpro gcpro1, gcpro2;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
191 Lisp_Object gui_item = allocate_gui_item ();
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
192 Lisp_Gui_Item* pgui_item = XGUI_ITEM (gui_item);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
193
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
194 GCPRO2 (gui_item, desc);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
195
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
196 {
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
197 EXTERNAL_LIST_LOOP_2 (elt, path)
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
198 {
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
199 /* Verify that DESC describes a menu, not single item */
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
200 if (!CONSP (desc))
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
201 RETURN_UNGCPRO (Qnil);
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
202
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
203 /* Parse this menu */
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
204 desc = menu_parse_submenu_keywords (desc, gui_item);
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
205
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
206 /* Check that this (sub)menu is active */
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
207 if (!gui_item_active_p (gui_item))
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
208 RETURN_UNGCPRO (Qnil);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
209
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
210 /* Apply :filter */
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
211 if (!NILP (pgui_item->filter))
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
212 desc = call1 (pgui_item->filter, desc);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
213
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
214 /* Find the next menu on the path inside this one */
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
215 {
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
216 EXTERNAL_LIST_LOOP_2 (submenu, desc)
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
217 {
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
218 if (CONSP (submenu)
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
219 && STRINGP (XCAR (submenu))
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
220 && !NILP (Fstring_equal (XCAR (submenu), elt)))
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
221 {
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
222 desc = submenu;
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
223 goto descend;
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
224 }
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
225 }
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
226 }
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
227 /* Submenu not found */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
228 RETURN_UNGCPRO (Qnil);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
229
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
230 descend:
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
231 /* Prepare for the next iteration */
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
232 gui_item_init (gui_item);
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
233 }
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
234 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
235
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
236 /* We have successfully descended down the end of the path */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
237 UNGCPRO;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
238 return desc;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
239 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
240
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
241 DEFUN ("popup-menu", Fpopup_menu, 1, 2, 0, /*
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
242 Pop up the menu described by MENU-DESCRIPTION.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
243 A menu description is a list of menu items, strings, and submenus.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
244
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
245 The first element of a menu must be a string, which is the name of the menu.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
246 This is the string that will be displayed in the parent menu, if any. For
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
247 toplevel menus, it is ignored. This string is not displayed in the menu
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
248 itself.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
249
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
250 If an element of a menu is a string, then that string will be presented in
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
251 the menu as unselectable text.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
252
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
253 If an element of a menu is a string consisting solely of hyphens, then that
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
254 item will be presented as a solid horizontal line.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
255
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
256 If an element of a menu is a list, it is treated as a submenu. The name of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
257 that submenu (the first element in the list) will be used as the name of the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
258 item representing this menu on the parent.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
259
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
260 Otherwise, the element must be a vector, which describes a menu item.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
261 A menu item can have any of the following forms:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
262
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
263 [ "name" callback <active-p> ]
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
264 [ "name" callback <active-p> <suffix> ]
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
265 [ "name" callback :<keyword> <value> :<keyword> <value> ... ]
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
266
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
267 The name is the string to display on the menu; it is filtered through the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
268 resource database, so it is possible for resources to override what string
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
269 is actually displayed.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
270
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
271 If the `callback' of a menu item is a symbol, then it must name a command.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
272 It will be invoked with `call-interactively'. If it is a list, then it is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
273 evaluated with `eval'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
274
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
275 The possible keywords are this:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
276
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
277 :active <form> Same as <active-p> in the first two forms: the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
278 expression is evaluated just before the menu is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
279 displayed, and the menu will be selectable only if
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
280 the result is non-nil.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
281
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
282 :suffix <form> Same as <suffix> in the second form: the expression
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
283 is evaluated just before the menu is displayed and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
284 resulting string is appended to the displayed name,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
285 providing a convenient way of adding the name of a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
286 command's ``argument'' to the menu, like
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
287 ``Kill Buffer NAME''.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
288
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
289 :keys "string" Normally, the keyboard equivalents of commands in
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
290 menus are displayed when the `callback' is a symbol.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
291 This can be used to specify keys for more complex menu
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
292 items. It is passed through `substitute-command-keys'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
293 first.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
294
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
295 :style <style> Specifies what kind of object this menu item is:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
296
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
297 nil A normal menu item.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
298 toggle A toggle button.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
299 radio A radio button.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
300
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
301 The only difference between toggle and radio buttons is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
302 how they are displayed. But for consistency, a toggle
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
303 button should be used when there is one option whose
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
304 value can be turned on or off, and radio buttons should
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
305 be used when there is a set of mutually exclusive
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
306 options. When using a group of radio buttons, you
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
307 should arrange for no more than one to be marked as
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
308 selected at a time.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
309
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
310 :selected <form> Meaningful only when STYLE is `toggle' or `radio'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
311 This specifies whether the button will be in the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
312 selected or unselected state.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
313
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
314 For example:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
315
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
316 [ "Save As..." write-file t ]
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
317 [ "Revert Buffer" revert-buffer (buffer-modified-p) ]
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
318 [ "Read Only" toggle-read-only :style toggle :selected buffer-read-only ]
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
319
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
320 See menubar.el for many more examples.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
321 */
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
322 (menu_description, event))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
323 {
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
324 struct frame *f = decode_frame (Qnil);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
325 MAYBE_FRAMEMETH (f, popup_menu, (menu_description, event));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
326 return Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
327 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
328
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
329 DEFUN ("normalize-menu-item-name", Fnormalize_menu_item_name, 1, 2, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
330 Convert a menu item name string into normal form, and return the new string.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
331 Menu item names should be converted to normal form before being compared.
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
332 This removes %_'s (accelerator indications) and converts %% to %.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
333 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
334 (name, buffer))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
335 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
336 struct buffer *buf = decode_buffer (buffer, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
337 Charcount end;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
338 int i;
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 851
diff changeset
339 Ibyte *name_data;
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 851
diff changeset
340 Ibyte *string_result;
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 851
diff changeset
341 Ibyte *string_result_ptr;
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 851
diff changeset
342 Ichar elt;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
343 int expecting_underscore = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
344
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
345 CHECK_STRING (name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
346
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 800
diff changeset
347 end = string_char_length (name);
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 771
diff changeset
348 name_data = XSTRING_DATA (name);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
349
2367
ecf1ebac70d8 [xemacs-hg @ 2004-11-04 23:05:23 by ben]
ben
parents: 2286
diff changeset
350 string_result = alloca_ibytes (end * MAX_ICHAR_LEN);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
351 string_result_ptr = string_result;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
352 for (i = 0; i < end; i++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
353 {
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 851
diff changeset
354 elt = itext_ichar (name_data);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
355 elt = DOWNCASE (buf, elt);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
356 if (expecting_underscore)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
357 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
358 expecting_underscore = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
359 switch (elt)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
360 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
361 case '%':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
362 /* Allow `%%' to mean `%'. */
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 851
diff changeset
363 string_result_ptr += set_itext_ichar (string_result_ptr, '%');
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
364 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
365 case '_':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
366 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
367 default:
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 851
diff changeset
368 string_result_ptr += set_itext_ichar (string_result_ptr, '%');
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 851
diff changeset
369 string_result_ptr += set_itext_ichar (string_result_ptr, elt);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
370 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
371 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
372 else if (elt == '%')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
373 expecting_underscore = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
374 else
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 851
diff changeset
375 string_result_ptr += set_itext_ichar (string_result_ptr, elt);
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 851
diff changeset
376 INC_IBYTEPTR (name_data);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
377 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
378
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
379 if (string_result_ptr - string_result == XSTRING_LENGTH (name)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
380 && !memcmp (string_result, XSTRING_DATA (name), XSTRING_LENGTH (name)))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
381 return name;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
382
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
383 return make_string (string_result, string_result_ptr - string_result);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
384 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
385
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
386 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
387 syms_of_menubar (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
388 {
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 464
diff changeset
389 DEFSYMBOL (Qcurrent_menubar);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
390
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 464
diff changeset
391 DEFSYMBOL (Qmenu_force);
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 464
diff changeset
392 DEFSYMBOL (Qmenu_fallback);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
393
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 464
diff changeset
394 DEFSYMBOL (Qmenu_quit);
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 464
diff changeset
395 DEFSYMBOL (Qmenu_up);
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 464
diff changeset
396 DEFSYMBOL (Qmenu_down);
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 464
diff changeset
397 DEFSYMBOL (Qmenu_left);
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 464
diff changeset
398 DEFSYMBOL (Qmenu_right);
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 464
diff changeset
399 DEFSYMBOL (Qmenu_select);
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 464
diff changeset
400 DEFSYMBOL (Qmenu_escape);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
401
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
402 DEFSUBR (Fpopup_menu);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
403 DEFSUBR (Fnormalize_menu_item_name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
404 DEFSUBR (Fmenu_find_real_submenu);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
405 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
406
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
407 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
408 vars_of_menubar (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
409 {
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
410 /* put in Vblank_menubar a menubar value which has no visible
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
411 * items. This is a bit tricky due to various quirks. We
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
412 * could use '(["" nil nil]), but this is apparently equivalent
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
413 * to '(nil), and a new frame created with this menubar will
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
414 * get a vertically-squished menubar. If we use " " as the
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
415 * button title instead of "", we get an etched button border.
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
416 * So we use
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
417 * '(("No active menubar" ["" nil nil]))
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
418 * which creates a menu whose title is "No active menubar",
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
419 * and this works fine.
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
420 */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
421
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 665
diff changeset
422 Vblank_menubar = list1 (list2 (build_msg_string ("No active menubar"),
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
423 vector3 (build_string (""), Qnil, Qnil)));
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
424 staticpro (&Vblank_menubar);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
425
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
426 DEFVAR_BOOL ("popup-menu-titles", &popup_menu_titles /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
427 If true, popup menus will have title bars at the top.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
428 */ );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
429 popup_menu_titles = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
430
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
431 /* #### Replace current menubar with a specifier. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
432
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
433 /* All C code must access the menubar via Qcurrent_menubar
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
434 because it can be buffer-local. Note that Vcurrent_menubar
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
435 doesn't need to exist at all, except for the magic function. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
436
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
437 DEFVAR_LISP_MAGIC ("current-menubar", &Vcurrent_menubar /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
438 The current menubar. This may be buffer-local.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
439
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
440 When the menubar is changed, the function `set-menubar-dirty-flag' has to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
441 be called for the menubar to be updated on the frame. See `set-menubar'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
442 and `set-buffer-menubar'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
443
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
444 A menubar is a list of menus and menu-items.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
445 A menu is a list of menu items, keyword-value pairs, strings, and submenus.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
446
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
447 The first element of a menu must be a string, which is the name of the menu.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
448 This is the string that will be displayed in the parent menu, if any. For
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
449 toplevel menus, it is ignored. This string is not displayed in the menu
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
450 itself.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
451
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
452 Menu accelerators can be indicated in the string by putting the
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
453 sequence "%_" before the character corresponding to the key that will
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
454 invoke the menu or menu item. Uppercase and lowercase accelerators
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
455 are equivalent. The sequence "%%" is also special, and is translated
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
456 into a single %.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
457
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
458 If no menu accelerator is present in the string, XEmacs will act as if
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
459 the first character has been tagged as an accelerator.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
460
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
461 Immediately following the name string of the menu, various optional
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
462 keyword-value pairs are permitted: currently, :filter, :active, :included,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
463 and :config. (See below.)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
464
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
465 If an element of a menu (or menubar) is a string, then that string will be
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
466 presented as unselectable text.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
467
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
468 If an element of a menu is a string consisting solely of hyphens, then that
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
469 item will be presented as a solid horizontal line.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
470
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
471 If an element of a menu is a string beginning with "--:", it will be
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
472 presented as a line whose appearance is controlled by the rest of the
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
473 text in the string. The allowed line specs are system-dependent, and
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
474 currently work only under X Windows (with Lucid and Motif menubars);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
475 otherwise, a solid horizontal line is presented, as if the string were
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
476 all hyphens.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
477
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
478 The possibilities are:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
479
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
480 "--:singleLine"
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
481 "--:doubleLine"
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
482 "--:singleDashedLine"
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
483 "--:doubleDashedLine"
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
484 "--:noLine"
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
485 "--:shadowEtchedIn"
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
486 "--:shadowEtchedOut"
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
487 "--:shadowEtchedInDash"
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
488 "--:shadowEtchedOutDash"
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
489 "--:shadowDoubleEtchedIn" (Lucid menubars only)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
490 "--:shadowDoubleEtchedOut" (Lucid menubars only)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
491 "--:shadowDoubleEtchedInDash" (Lucid menubars only)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
492 "--:shadowDoubleEtchedOutDash" (Lucid menubars only)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
493
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
494 If an element of a menu is a list, it is treated as a submenu. The name of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
495 that submenu (the first element in the list) will be used as the name of the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
496 item representing this menu on the parent.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
497
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
498 If an element of a menubar is `nil', then it is used to represent the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
499 division between the set of menubar-items which are flushleft and those
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
500 which are flushright.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
501
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
502 Otherwise, the element must be a vector, which describes a menu item.
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
503 A menu item is of the following form:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
504
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
505 [ "name" callback :<keyword> <value> :<keyword> <value> ... ]
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
506
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
507 The following forms are also accepted for compatibility, but deprecated:
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
508
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
509 [ "name" callback <active-p> ]
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
510 [ "name" callback <active-p> <suffix> ]
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
511
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
512 The name is the string to display on the menu; it is filtered through the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
513 resource database, so it is possible for resources to override what string
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
514 is actually displayed. Menu accelerator indicators (the sequence `%_') are
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
515 also processed; see above. If the name is not a string, it will be
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
516 evaluated with `eval', and the result should be a string.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
517
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
518 If the `callback' of a menu item is a symbol, then it must name a command.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
519 It will be invoked with `call-interactively'. If it is a list, then it is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
520 evaluated with `eval'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
521
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
522 In the deprecated forms, <active-p> is equivalent to using the :active
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
523 keyword, and <suffix> is equivalent to using the :suffix keyword.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
524
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
525 The possible keywords are:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
526
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
527 :active <form> The expression is evaluated just before the menu is
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
528 displayed, and the menu will be selectable only if
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
529 the result is non-nil.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
530
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
531 :suffix <form> The expression is evaluated just before the menu is
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
532 displayed and the resulting string is appended to
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
533 the displayed name, providing a convenient way of
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
534 adding the name of a command's ``argument'' to the
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
535 menu, like ``Kill Buffer NAME''.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
536
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
537 :keys "string" Normally, the keyboard equivalents of commands in
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
538 menus are displayed when the `callback' is a symbol.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
539 This can be used to specify keys for more complex menu
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
540 items. It is passed through `substitute-command-keys'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
541 first.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
542
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
543 :style <style> Specifies what kind of object this menu item is:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
544
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
545 nil A normal menu item.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
546 toggle A toggle button.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
547 radio A radio button.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
548 button A menubar button.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
549
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
550 The only difference between toggle and radio buttons is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
551 how they are displayed. But for consistency, a toggle
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
552 button should be used when there is one option whose
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
553 value can be turned on or off, and radio buttons should
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
554 be used when there is a set of mutually exclusive
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
555 options. When using a group of radio buttons, you
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
556 should arrange for no more than one to be marked as
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
557 selected at a time.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
558
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
559 :selected <form> Meaningful only when STYLE is `toggle', `radio' or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
560 `button'. This specifies whether the button will be in
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
561 the selected or unselected state.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
562
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
563 :included <form> This can be used to control the visibility of a menu or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
564 menu item. The form is evaluated and the menu or menu
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
565 item is only displayed if the result is non-nil.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
566
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
567 :config <symbol> This is an efficient shorthand for
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
568 :included (memq symbol menubar-configuration)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
569 See the variable `menubar-configuration'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
570
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
571 :filter <function> A menu filter can only be used at the beginning of a
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
572 submenu description (i.e. not in a menu item itself).
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
573 (Remember that most of the keywords can take evaluated
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
574 expressions as well as constants.) The filter is used to
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
575 incrementally create a submenu only when it is selected
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
576 by the user and not every time the menubar is activated.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
577 The filter function is passed the list of menu items in
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
578 the submenu and must return the modified list to be
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
579 actually used. The filter MUST NOT destructively modify
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
580 the list of menu items passed to it. It is called only
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
581 when the menu is about to be displayed, so other menus
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
582 may already be displayed. Vile and terrible things will
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
583 happen if a menu filter function changes the current
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
584 buffer, window, or frame. It also should not raise,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
585 lower, or iconify any frames. Basically, the filter
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
586 function should have no side-effects.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
587
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
588 :key-sequence keys Used in FSF Emacs as an hint to an equivalent keybinding.
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
589 Ignored by XEmacs for easymenu.el compatibility.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
590 (XEmacs computes this information automatically.)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
591
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
592 For example:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
593
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
594 ("%_File"
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
595 :filter file-menu-filter ; file-menu-filter is a function that takes
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
596 ; one argument (a list of menu items) and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
597 ; returns a list of menu items
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
598 [ "Save %_As..." write-file t ]
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
599 [ "%_Revert Buffer" revert-buffer (buffer-modified-p) ]
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
600 [ "R%_ead Only" toggle-read-only :style toggle
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
601 :selected buffer-read-only ]
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
602 )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
603
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
604 See menubar-items.el for many more examples.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
605
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
606 After the menubar is clicked upon, but before any menus are popped up,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
607 the functions on the `activate-menubar-hook' are invoked to make top-level
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
608 changes to the menus and menubar. Note, however, that the use of menu
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
609 filters (using the :filter keyword) is usually a more efficient way to
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
610 dynamically alter or sensitize menus. */, menubar_variable_changed);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
611
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
612 Vcurrent_menubar = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
613
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
614 DEFVAR_LISP ("activate-menubar-hook", &Vactivate_menubar_hook /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
615 Function or functions called before a menubar menu is pulled down.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
616 These functions are called with no arguments, and should interrogate and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
617 modify the value of `current-menubar' as desired.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
618
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
619 The functions on this hook are invoked after the mouse goes down, but before
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
620 the menu is mapped, and may be used to activate, deactivate, add, or delete
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
621 items from the menus. However, it is probably the case that using a :filter
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
622 keyword in a submenu would be a more efficient way of updating menus. See
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
623 the documentation of `current-menubar'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
624
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
625 These functions may return the symbol `t' to assert that they have made
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
626 no changes to the menubar. If any other value is returned, the menubar is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
627 recomputed. If `t' is returned but the menubar has been changed, then the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
628 changes may not show up right away. Returning `nil' when the menubar has
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
629 not changed is not so bad; more computation will be done, but redisplay of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
630 the menubar will still be performed optimally.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
631 */ );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
632 Vactivate_menubar_hook = Qnil;
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 464
diff changeset
633 DEFSYMBOL (Qactivate_menubar_hook);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
634
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
635 DEFVAR_BOOL ("menubar-show-keybindings", &menubar_show_keybindings /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
636 If true, the menubar will display keyboard equivalents.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
637 If false, only the command names will be displayed.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
638 */ );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
639 menubar_show_keybindings = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
640
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
641 DEFVAR_LISP_MAGIC ("menubar-configuration", &Vmenubar_configuration /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
642 A list of symbols, against which the value of the :config tag for each
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
643 menubar item will be compared. If a menubar item has a :config tag, then
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
644 it is omitted from the menubar if that tag is not a member of the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
645 `menubar-configuration' list.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
646 */ , menubar_variable_changed);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
647 Vmenubar_configuration = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
648
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
649 DEFVAR_LISP ("menubar-pointer-glyph", &Vmenubar_pointer_glyph /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
650 *The shape of the mouse-pointer when over the menubar.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
651 This is a glyph; use `set-glyph-image' to change it.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
652 If unspecified in a particular domain, the window-system-provided
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
653 default pointer is used.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
654 */ );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
655
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
656 DEFVAR_LISP ("menu-accelerator-prefix", &Vmenu_accelerator_prefix /*
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
657 Prefix key(s) that must be typed before menu accelerators will be activated.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
658 Set this to a value acceptable by define-key.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
659
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
660 NOTE: This currently only has any effect under X Windows.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
661 */ );
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
662 Vmenu_accelerator_prefix = Qnil;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
663
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
664 DEFVAR_LISP ("menu-accelerator-modifiers", &Vmenu_accelerator_modifiers /*
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
665 Modifier keys which must be pressed to get to the top level menu accelerators.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
666 This is a list of modifier key symbols. All modifier keys must be held down
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
667 while a valid menu accelerator key is pressed in order for the top level
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
668 menu to become active.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
669
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
670 NOTE: This currently only has any effect under X Windows.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
671
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
672 See also menu-accelerator-enabled and menu-accelerator-prefix.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
673 */ );
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
674 Vmenu_accelerator_modifiers = list1 (Qmeta);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
675
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
676 DEFVAR_LISP ("menu-accelerator-enabled", &Vmenu_accelerator_enabled /*
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
677 Whether menu accelerator keys can cause the menubar to become active.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
678 If 'menu-force or 'menu-fallback, then menu accelerator keys can
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
679 be used to activate the top level menu. Once the menubar becomes active, the
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
680 accelerator keys can be used regardless of the value of this variable.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
681
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
682 menu-force is used to indicate that the menu accelerator key takes
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
683 precedence over bindings in the current keymap(s). menu-fallback means
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
684 that bindings in the current keymap take precedence over menu accelerator keys.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
685 Thus a top level menu with an accelerator of "T" would be activated on a
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
686 keypress of Meta-t if menu-accelerator-enabled is menu-force.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
687 However, if menu-accelerator-enabled is menu-fallback, then
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
688 Meta-t will not activate the menubar and will instead run the function
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
689 transpose-words, to which it is normally bound.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
690
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
691 See also menu-accelerator-modifiers and menu-accelerator-prefix.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
692 */ );
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
693 Vmenu_accelerator_enabled = Qnil;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
694
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
695 DEFVAR_LISP ("menu-accelerator-map", &Vmenu_accelerator_map /*
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
696 Keymap for use when the menubar is active.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
697 The actions menu-quit, menu-up, menu-down, menu-left, menu-right,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
698 menu-select and menu-escape can be mapped to keys in this map.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
699 NOTE: This currently only has any effect under X Windows.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
700
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
701 menu-quit Immediately deactivate the menubar and any open submenus without
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
702 selecting an item.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
703 menu-up Move the menu cursor up one row in the current menu. If the
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
704 move extends past the top of the menu, wrap around to the bottom.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
705 menu-down Move the menu cursor down one row in the current menu. If the
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
706 move extends past the bottom of the menu, wrap around to the top.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
707 If executed while the cursor is in the top level menu, move down
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
708 into the selected menu.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
709 menu-left Move the cursor from a submenu into the parent menu. If executed
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
710 while the cursor is in the top level menu, move the cursor to the
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
711 left. If the move extends past the left edge of the menu, wrap
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
712 around to the right edge.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
713 menu-right Move the cursor into a submenu. If the cursor is located in the
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
714 top level menu or is not currently on a submenu heading, then move
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
715 the cursor to the next top level menu entry. If the move extends
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
716 past the right edge of the menu, wrap around to the left edge.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
717 menu-select Activate the item under the cursor. If the cursor is located on
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
718 a submenu heading, then move the cursor into the submenu.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
719 menu-escape Pop up to the next level of menus. Moves from a submenu into its
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
720 parent menu. From the top level menu, this deactivates the
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
721 menubar.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
722
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
723 This keymap can also contain normal key-command bindings, in which case the
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
724 menubar is deactivated and the corresponding command is executed.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
725
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
726 The action bindings used by the menu accelerator code are designed to mimic
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
727 the actions of menu traversal keys in a commonly used PC operating system.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
728 */ );
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
729
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
730 Fprovide (intern ("menubar"));
464
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 450
diff changeset
731 Fprovide (intern ("menu-accelerator-support"));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
732 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
733
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
734 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
735 specifier_vars_of_menubar (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
736 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
737 DEFVAR_SPECIFIER ("menubar-visible-p", &Vmenubar_visible_p /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
738 *Whether the menubar is visible.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
739 This is a specifier; use `set-specifier' to change it.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
740 */ );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
741 Vmenubar_visible_p = Fmake_specifier (Qboolean);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
742
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
743 set_specifier_fallback (Vmenubar_visible_p, list1 (Fcons (Qnil, Qt)));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
744 set_specifier_caching (Vmenubar_visible_p,
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 428
diff changeset
745 offsetof (struct window, menubar_visible_p),
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
746 menubar_visible_p_changed,
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 428
diff changeset
747 offsetof (struct frame, menubar_visible_p),
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
748 menubar_visible_p_changed_in_frame, 0);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
749 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
750
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
751 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
752 complex_vars_of_menubar (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
753 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
754 Vmenubar_pointer_glyph = Fmake_glyph_internal (Qpointer);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
755
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
756 Vmenu_accelerator_map = Fmake_keymap (Qnil);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
757 }