annotate src/menubar.c @ 665:fdefd0186b75

[xemacs-hg @ 2001-09-20 06:28:42 by ben] The great integral types renaming. The purpose of this is to rationalize the names used for various integral types, so that they match their intended uses and follow consist conventions, and eliminate types that were not semantically different from each other. The conventions are: -- All integral types that measure quantities of anything are signed. Some people disagree vociferously with this, but their arguments are mostly theoretical, and are vastly outweighed by the practical headaches of mixing signed and unsigned values, and more importantly by the far increased likelihood of inadvertent bugs: Because of the broken "viral" nature of unsigned quantities in C (operations involving mixed signed/unsigned are done unsigned, when exactly the opposite is nearly always wanted), even a single error in declaring a quantity unsigned that should be signed, or even the even more subtle error of comparing signed and unsigned values and forgetting the necessary cast, can be catastrophic, as comparisons will yield wrong results. -Wsign-compare is turned on specifically to catch this, but this tends to result in a great number of warnings when mixing signed and unsigned, and the casts are annoying. More has been written on this elsewhere. -- All such quantity types just mentioned boil down to EMACS_INT, which is 32 bits on 32-bit machines and 64 bits on 64-bit machines. This is guaranteed to be the same size as Lisp objects of type `int', and (as far as I can tell) of size_t (unsigned!) and ssize_t. The only type below that is not an EMACS_INT is Hashcode, which is an unsigned value of the same size as EMACS_INT. -- Type names should be relatively short (no more than 10 characters or so), with the first letter capitalized and no underscores if they can at all be avoided. -- "count" == a zero-based measurement of some quantity. Includes sizes, offsets, and indexes. -- "bpos" == a one-based measurement of a position in a buffer. "Charbpos" and "Bytebpos" count text in the buffer, rather than bytes in memory; thus Bytebpos does not directly correspond to the memory representation. Use "Membpos" for this. -- "Char" refers to internal-format characters, not to the C type "char", which is really a byte. -- For the actual name changes, see the script below. I ran the following script to do the conversion. (NOTE: This script is idempotent. You can safely run it multiple times and it will not screw up previous results -- in fact, it will do nothing if nothing has changed. Thus, it can be run repeatedly as necessary to handle patches coming in from old workspaces, or old branches.) There are two tags, just before and just after the change: `pre-integral-type-rename' and `post-integral-type-rename'. When merging code from the main trunk into a branch, the best thing to do is first merge up to `pre-integral-type-rename', then apply the script and associated changes, then merge from `post-integral-type-change' to the present. (Alternatively, just do the merging in one operation; but you may then have a lot of conflicts needing to be resolved by hand.) Script `fixtypes.sh' follows: ----------------------------------- cut ------------------------------------ files="*.[ch] s/*.h m/*.h config.h.in ../configure.in Makefile.in.in ../lib-src/*.[ch] ../lwlib/*.[ch]" gr Memory_Count Bytecount $files gr Lstream_Data_Count Bytecount $files gr Element_Count Elemcount $files gr Hash_Code Hashcode $files gr extcount bytecount $files gr bufpos charbpos $files gr bytind bytebpos $files gr memind membpos $files gr bufbyte intbyte $files gr Extcount Bytecount $files gr Bufpos Charbpos $files gr Bytind Bytebpos $files gr Memind Membpos $files gr Bufbyte Intbyte $files gr EXTCOUNT BYTECOUNT $files gr BUFPOS CHARBPOS $files gr BYTIND BYTEBPOS $files gr MEMIND MEMBPOS $files gr BUFBYTE INTBYTE $files gr MEMORY_COUNT BYTECOUNT $files gr LSTREAM_DATA_COUNT BYTECOUNT $files gr ELEMENT_COUNT ELEMCOUNT $files gr HASH_CODE HASHCODE $files ----------------------------------- cut ------------------------------------ `fixtypes.sh' is a Bourne-shell script; it uses 'gr': ----------------------------------- cut ------------------------------------ #!/bin/sh # Usage is like this: # gr FROM TO FILES ... # globally replace FROM with TO in FILES. FROM and TO are regular expressions. # backup files are stored in the `backup' directory. from="$1" to="$2" shift 2 echo ${1+"$@"} | xargs global-replace "s/$from/$to/g" ----------------------------------- cut ------------------------------------ `gr' in turn uses a Perl script to do its real work, `global-replace', which follows: ----------------------------------- cut ------------------------------------ : #-*- Perl -*- ### global-modify --- modify the contents of a file by a Perl expression ## Copyright (C) 1999 Martin Buchholz. ## Copyright (C) 2001 Ben Wing. ## Authors: Martin Buchholz <martin@xemacs.org>, Ben Wing <ben@xemacs.org> ## Maintainer: Ben Wing <ben@xemacs.org> ## Current Version: 1.0, May 5, 2001 # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with XEmacs; see the file COPYING. If not, write to the Free # Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA # 02111-1307, USA. eval 'exec perl -w -S $0 ${1+"$@"}' if 0; use strict; use FileHandle; use Carp; use Getopt::Long; use File::Basename; (my $myName = $0) =~ s@.*/@@; my $usage=" Usage: $myName [--help] [--backup-dir=DIR] [--line-mode] [--hunk-mode] PERLEXPR FILE ... Globally modify a file, either line by line or in one big hunk. Typical usage is like this: [with GNU print, GNU xargs: guaranteed to handle spaces, quotes, etc. in file names] find . -name '*.[ch]' -print0 | xargs -0 $0 's/\bCONST\b/const/g'\n [with non-GNU print, xargs] find . -name '*.[ch]' -print | xargs $0 's/\bCONST\b/const/g'\n The file is read in, either line by line (with --line-mode specified) or in one big hunk (with --hunk-mode specified; it's the default), and the Perl expression is then evalled with \$_ set to the line or hunk of text, including the terminating newline if there is one. It should destructively modify the value there, storing the changed result in \$_. Files in which any modifications are made are backed up to the directory specified using --backup-dir, or to `backup' by default. To disable this, use --backup-dir= with no argument. Hunk mode is the default because it is MUCH MUCH faster than line-by-line. Use line-by-line only when it matters, e.g. you want to do a replacement only once per line (the default without the `g' argument). Conversely, when using hunk mode, *ALWAYS* use `g'; otherwise, you will only make one replacement in the entire file! "; my %options = (); $Getopt::Long::ignorecase = 0; &GetOptions ( \%options, 'help', 'backup-dir=s', 'line-mode', 'hunk-mode', ); die $usage if $options{"help"} or @ARGV <= 1; my $code = shift; die $usage if grep (-d || ! -w, @ARGV); sub SafeOpen { open ((my $fh = new FileHandle), $_[0]); confess "Can't open $_[0]: $!" if ! defined $fh; return $fh; } sub SafeClose { close $_[0] or confess "Can't close $_[0]: $!"; } sub FileContents { my $fh = SafeOpen ("< $_[0]"); my $olddollarslash = $/; local $/ = undef; my $contents = <$fh>; $/ = $olddollarslash; return $contents; } sub WriteStringToFile { my $fh = SafeOpen ("> $_[0]"); binmode $fh; print $fh $_[1] or confess "$_[0]: $!\n"; SafeClose $fh; } foreach my $file (@ARGV) { my $changed_p = 0; my $new_contents = ""; if ($options{"line-mode"}) { my $fh = SafeOpen $file; while (<$fh>) { my $save_line = $_; eval $code; $changed_p = 1 if $save_line ne $_; $new_contents .= $_; } } else { my $orig_contents = $_ = FileContents $file; eval $code; if ($_ ne $orig_contents) { $changed_p = 1; $new_contents = $_; } } if ($changed_p) { my $backdir = $options{"backup-dir"}; $backdir = "backup" if !defined ($backdir); if ($backdir) { my ($name, $path, $suffix) = fileparse ($file, ""); my $backfulldir = $path . $backdir; my $backfile = "$backfulldir/$name"; mkdir $backfulldir, 0755 unless -d $backfulldir; print "modifying $file (original saved in $backfile)\n"; rename $file, $backfile; } WriteStringToFile ($file, $new_contents); } } ----------------------------------- cut ------------------------------------ In addition to those programs, I needed to fix up a few other things, particularly relating to the duplicate definitions of types, now that some types merged with others. Specifically: 1. in lisp.h, removed duplicate declarations of Bytecount. The changed code should now look like this: (In each code snippet below, the first and last lines are the same as the original, as are all lines outside of those lines. That allows you to locate the section to be replaced, and replace the stuff in that section, verifying that there isn't anything new added that would need to be kept.) --------------------------------- snip ------------------------------------- /* Counts of bytes or chars */ typedef EMACS_INT Bytecount; typedef EMACS_INT Charcount; /* Counts of elements */ typedef EMACS_INT Elemcount; /* Hash codes */ typedef unsigned long Hashcode; /* ------------------------ dynamic arrays ------------------- */ --------------------------------- snip ------------------------------------- 2. in lstream.h, removed duplicate declaration of Bytecount. Rewrote the comment about this type. The changed code should now look like this: --------------------------------- snip ------------------------------------- #endif /* The have been some arguments over the what the type should be that specifies a count of bytes in a data block to be written out or read in, using Lstream_read(), Lstream_write(), and related functions. Originally it was long, which worked fine; Martin "corrected" these to size_t and ssize_t on the grounds that this is theoretically cleaner and is in keeping with the C standards. Unfortunately, this practice is horribly error-prone due to design flaws in the way that mixed signed/unsigned arithmetic happens. In fact, by doing this change, Martin introduced a subtle but fatal error that caused the operation of sending large mail messages to the SMTP server under Windows to fail. By putting all values back to be signed, avoiding any signed/unsigned mixing, the bug immediately went away. The type then in use was Lstream_Data_Count, so that it be reverted cleanly if a vote came to that. Now it is Bytecount. Some earlier comments about why the type must be signed: This MUST BE SIGNED, since it also is used in functions that return the number of bytes actually read to or written from in an operation, and these functions can return -1 to signal error. Note that the standard Unix read() and write() functions define the count going in as a size_t, which is UNSIGNED, and the count going out as an ssize_t, which is SIGNED. This is a horrible design flaw. Not only is it highly likely to lead to logic errors when a -1 gets interpreted as a large positive number, but operations are bound to fail in all sorts of horrible ways when a number in the upper-half of the size_t range is passed in -- this number is unrepresentable as an ssize_t, so code that checks to see how many bytes are actually written (which is mandatory if you are dealing with certain types of devices) will get completely screwed up. --ben */ typedef enum lstream_buffering --------------------------------- snip ------------------------------------- 3. in dumper.c, there are four places, all inside of switch() statements, where XD_BYTECOUNT appears twice as a case tag. In each case, the two case blocks contain identical code, and you should *REMOVE THE SECOND* and leave the first.
author ben
date Thu, 20 Sep 2001 06:31:11 +0000
parents 183866b06e0b
children 943eaba38521
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.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5 This file is part of XEmacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
7 XEmacs is free software; you can redistribute it and/or modify it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
8 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
9 Free Software Foundation; either version 2, or (at your option) any
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
10 later version.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
11
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
12 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
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
15 for more details.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
16
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
18 along with XEmacs; see the file COPYING. If not, write to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
20 Boston, MA 02111-1307, USA. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
21
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
22 /* Synched up with: Not in FSF. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
23
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
24 /* Authorship:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
25
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
26 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
27 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
28 Menu accelerators c. 1997? by ??. Moved here from event-stream.c.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
29 Much other work post-1996 by ??.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
30 */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
31
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
32 #include <config.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
33 #include "lisp.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
34
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
35 #include "buffer.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
36 #include "device.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
37 #include "frame.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
38 #include "gui.h"
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
39 #include "keymap.h"
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
40 #include "menubar.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
41 #include "redisplay.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
42 #include "window.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
43
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
44 int menubar_show_keybindings;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
45 Lisp_Object Vmenubar_configuration;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
46
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
47 Lisp_Object Qcurrent_menubar;
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 Qactivate_menubar_hook, Vactivate_menubar_hook;
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 Vmenubar_visible_p;
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 static Lisp_Object Vcurrent_menubar; /* DO NOT ever reference this.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
54 Always go through Qcurrent_menubar.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
55 See below. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
56
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
57 Lisp_Object Vblank_menubar;
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 int popup_menu_titles;
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 Lisp_Object Vmenubar_pointer_glyph;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
62
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
63 /* prefix key(s) that must match in order to activate menu.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
64 This is ugly. fix me.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
65 */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
66 Lisp_Object Vmenu_accelerator_prefix;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
67
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
68 /* list of modifier keys to match accelerator for top level menus */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
69 Lisp_Object Vmenu_accelerator_modifiers;
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 /* whether menu accelerators are enabled */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
72 Lisp_Object Vmenu_accelerator_enabled;
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 /* keymap for auxiliary menu accelerator functions */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
75 Lisp_Object Vmenu_accelerator_map;
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 Lisp_Object Qmenu_force;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
78 Lisp_Object Qmenu_fallback;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
79 Lisp_Object Qmenu_quit;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
80 Lisp_Object Qmenu_up;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
81 Lisp_Object Qmenu_down;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
82 Lisp_Object Qmenu_left;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
83 Lisp_Object Qmenu_right;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
84 Lisp_Object Qmenu_select;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
85 Lisp_Object Qmenu_escape;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
86
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
87 static int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
88 menubar_variable_changed (Lisp_Object sym, Lisp_Object *val,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
89 Lisp_Object in_object, int flags)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
90 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
91 MARK_MENUBAR_CHANGED;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
92 return 0;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
95 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
96 update_frame_menubars (struct frame *f)
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 if (f->menubar_changed || f->windows_changed)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
99 MAYBE_FRAMEMETH (f, update_frame_menubars, (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 f->menubar_changed = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
102 }
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 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
105 free_frame_menubars (struct frame *f)
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 /* If we had directly allocated any memory for the menubars instead
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
108 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
109
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
110 MAYBE_FRAMEMETH (f, free_frame_menubars, (f));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
111 }
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 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
114 menubar_visible_p_changed (Lisp_Object specifier, struct window *w,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
115 Lisp_Object oldval)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
116 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
117 MARK_MENUBAR_CHANGED;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
118 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
119
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
120 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
121 menubar_visible_p_changed_in_frame (Lisp_Object specifier, struct frame *f,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
122 Lisp_Object oldval)
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 update_frame_menubars (f);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
125 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
126
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
127 Lisp_Object
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
128 current_frame_menubar (const struct frame* f)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
129 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
130 struct window *w = XWINDOW (FRAME_LAST_NONMINIBUF_WINDOW (f));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
131 return symbol_value_in_buffer (Qcurrent_menubar, w->buffer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
132 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
133
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
134 Lisp_Object
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
135 menu_parse_submenu_keywords (Lisp_Object desc, Lisp_Object gui_item)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
136 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
137 Lisp_Gui_Item *pgui_item = XGUI_ITEM (gui_item);
428
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 /* Menu descriptor should be a list */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
140 CHECK_CONS (desc);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
141
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
142 /* First element may be menu name, although can be omitted.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
143 Let's think that if stuff begins with anything than a keyword
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
144 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
145 if (!KEYWORDP (XCAR (desc)) && !CONSP (XCAR (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 CHECK_STRING (XCAR (desc));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
148 pgui_item->name = XCAR (desc);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
149 desc = XCDR (desc);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
150 if (!NILP (desc))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
151 CHECK_CONS (desc);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
152 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
153
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
154 /* Walk along all key-value pairs */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
155 while (!NILP(desc) && KEYWORDP (XCAR (desc)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
156 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
157 Lisp_Object key, val;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
158 key = XCAR (desc);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
159 desc = XCDR (desc);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
160 CHECK_CONS (desc);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
161 val = XCAR (desc);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
162 desc = XCDR (desc);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
163 if (!NILP (desc))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
164 CHECK_CONS (desc);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
165 gui_item_add_keyval_pair (gui_item, key, val, ERROR_ME);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
166 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
167
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
168 /* Return the rest - supposed to be a list of items */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
169 return desc;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
170 }
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 DEFUN ("menu-find-real-submenu", Fmenu_find_real_submenu, 2, 2, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
173 Find a submenu descriptor within DESC by following PATH.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
174 This function finds a submenu descriptor, either from the description
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
175 DESC or generated by a filter within DESC. The function regards :config
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
176 and :included keywords in the DESC, and expands submenus along the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
177 PATH using :filter functions. Return value is a descriptor for the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
178 submenu, NOT expanded and NOT checked against :config and :included.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
179 Also, individual menu items are not looked for, only submenus.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
180
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
181 See also 'find-menu-item'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
182 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
183 (desc, path))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
184 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
185 Lisp_Object path_entry, submenu_desc, submenu;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
186 struct gcpro gcpro1, gcpro2;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
187 Lisp_Object gui_item = allocate_gui_item ();
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
188 Lisp_Gui_Item* pgui_item = XGUI_ITEM (gui_item);
428
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 GCPRO2 (gui_item, desc);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
191
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
192 EXTERNAL_LIST_LOOP (path_entry, path)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
193 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
194 /* Verify that DESC describes a menu, not single item */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
195 if (!CONSP (desc))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
196 RETURN_UNGCPRO (Qnil);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
197
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
198 /* Parse this menu */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
199 desc = menu_parse_submenu_keywords (desc, gui_item);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
200
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
201 /* Check that this (sub)menu is active */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
202 if (!gui_item_active_p (gui_item))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
203 RETURN_UNGCPRO (Qnil);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
204
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
205 /* Apply :filter */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
206 if (!NILP (pgui_item->filter))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
207 desc = call1 (pgui_item->filter, desc);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
208
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
209 /* Find the next menu on the path inside this one */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
210 EXTERNAL_LIST_LOOP (submenu_desc, desc)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
211 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
212 submenu = XCAR (submenu_desc);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
213 if (CONSP (submenu)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
214 && STRINGP (XCAR (submenu))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
215 && !NILP (Fstring_equal (XCAR (submenu), XCAR (path_entry))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
216 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
217 desc = submenu;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
218 goto descend;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
219 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
220 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
221 /* Submenu not found */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
222 RETURN_UNGCPRO (Qnil);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
223
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
224 descend:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
225 /* Prepare for the next iteration */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
226 gui_item_init (gui_item);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
227 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
228
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
229 /* We have successfully descended down the end of the path */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
230 UNGCPRO;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
231 return desc;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
232 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
233
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
234 DEFUN ("popup-menu", Fpopup_menu, 1, 2, 0, /*
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
235 Pop up the menu described by MENU-DESCRIPTION.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
236 A menu description is a list of menu items, strings, and submenus.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
237
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
238 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
239 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
240 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
241 itself.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
242
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
243 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
244 the menu as unselectable text.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
245
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
246 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
247 item will be presented as a solid horizontal line.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
248
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
249 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
250 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
251 item representing this menu on the parent.
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 Otherwise, the element must be a vector, which describes a menu item.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
254 A menu item can have any of the following forms:
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 [ "name" callback <active-p> ]
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
257 [ "name" callback <active-p> <suffix> ]
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
258 [ "name" callback :<keyword> <value> :<keyword> <value> ... ]
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 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
261 resource database, so it is possible for resources to override what string
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
262 is actually displayed.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
263
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
264 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
265 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
266 evaluated with `eval'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
267
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
268 The possible keywords are this:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
269
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
270 :active <form> Same as <active-p> in the first two forms: the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
271 expression is evaluated just before the menu is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
272 displayed, and the menu will be selectable only if
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
273 the result is non-nil.
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 :suffix <form> Same as <suffix> in the second form: the expression
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
276 is evaluated just before the menu is displayed and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
277 resulting string is appended to the displayed name,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
278 providing a convenient way of adding the name of a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
279 command's ``argument'' to the menu, like
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
280 ``Kill Buffer NAME''.
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 :keys "string" Normally, the keyboard equivalents of commands in
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
283 menus are displayed when the `callback' is a symbol.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
284 This can be used to specify keys for more complex menu
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
285 items. It is passed through `substitute-command-keys'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
286 first.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
287
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
288 :style <style> Specifies what kind of object this menu item is:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
289
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
290 nil A normal menu item.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
291 toggle A toggle button.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
292 radio A radio button.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
293
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
294 The only difference between toggle and radio buttons is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
295 how they are displayed. But for consistency, a toggle
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
296 button should be used when there is one option whose
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
297 value can be turned on or off, and radio buttons should
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
298 be used when there is a set of mutually exclusive
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
299 options. When using a group of radio buttons, you
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
300 should arrange for no more than one to be marked as
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
301 selected at a time.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
302
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
303 :selected <form> Meaningful only when STYLE is `toggle' or `radio'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
304 This specifies whether the button will be in the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
305 selected or unselected state.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
306
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
307 For example:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
308
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
309 [ "Save As..." write-file t ]
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
310 [ "Revert Buffer" revert-buffer (buffer-modified-p) ]
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
311 [ "Read Only" toggle-read-only :style toggle :selected buffer-read-only ]
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
312
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
313 See menubar.el for many more examples.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
314 */
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
315 (menu_description, event))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
316 {
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
317 struct frame *f = decode_frame (Qnil);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
318 MAYBE_FRAMEMETH (f, popup_menu, (menu_description, event));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
319 return Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
320 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
321
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
322 DEFUN ("normalize-menu-item-name", Fnormalize_menu_item_name, 1, 2, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
323 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
324 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
325 This removes %_'s (accelerator indications) and converts %% to %.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
326 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
327 (name, buffer))
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 struct buffer *buf = decode_buffer (buffer, 0);
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
330 Lisp_String *n;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
331 Charcount end;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
332 int i;
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 563
diff changeset
333 Intbyte *name_data;
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 563
diff changeset
334 Intbyte *string_result;
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 563
diff changeset
335 Intbyte *string_result_ptr;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
336 Emchar elt;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
337 int expecting_underscore = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
338
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
339 CHECK_STRING (name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
340
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
341 n = XSTRING (name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
342 end = string_char_length (n);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
343 name_data = string_data (n);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
344
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 563
diff changeset
345 string_result = (Intbyte *) alloca (end * MAX_EMCHAR_LEN);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
346 string_result_ptr = string_result;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
347 for (i = 0; i < end; i++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
348 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
349 elt = charptr_emchar (name_data);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
350 elt = DOWNCASE (buf, elt);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
351 if (expecting_underscore)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
352 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
353 expecting_underscore = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
354 switch (elt)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
355 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
356 case '%':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
357 /* Allow `%%' to mean `%'. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
358 string_result_ptr += set_charptr_emchar (string_result_ptr, '%');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
359 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
360 case '_':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
361 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
362 default:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
363 string_result_ptr += set_charptr_emchar (string_result_ptr, '%');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
364 string_result_ptr += set_charptr_emchar (string_result_ptr, elt);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
365 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
366 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
367 else if (elt == '%')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
368 expecting_underscore = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
369 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
370 string_result_ptr += set_charptr_emchar (string_result_ptr, elt);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
371 INC_CHARPTR (name_data);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
372 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
373
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
374 if (string_result_ptr - string_result == XSTRING_LENGTH (name)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
375 && !memcmp (string_result, XSTRING_DATA (name), XSTRING_LENGTH (name)))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
376 return name;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
377
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
378 return make_string (string_result, string_result_ptr - string_result);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
379 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
380
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
381 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
382 syms_of_menubar (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
383 {
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 464
diff changeset
384 DEFSYMBOL (Qcurrent_menubar);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
385
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 464
diff changeset
386 DEFSYMBOL (Qmenu_force);
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 464
diff changeset
387 DEFSYMBOL (Qmenu_fallback);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
388
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 464
diff changeset
389 DEFSYMBOL (Qmenu_quit);
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 464
diff changeset
390 DEFSYMBOL (Qmenu_up);
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 464
diff changeset
391 DEFSYMBOL (Qmenu_down);
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 464
diff changeset
392 DEFSYMBOL (Qmenu_left);
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 464
diff changeset
393 DEFSYMBOL (Qmenu_right);
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 464
diff changeset
394 DEFSYMBOL (Qmenu_select);
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 464
diff changeset
395 DEFSYMBOL (Qmenu_escape);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
396
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
397 DEFSUBR (Fpopup_menu);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
398 DEFSUBR (Fnormalize_menu_item_name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
399 DEFSUBR (Fmenu_find_real_submenu);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
400 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
401
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
402 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
403 vars_of_menubar (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
404 {
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
405 /* put in Vblank_menubar a menubar value which has no visible
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
406 * items. This is a bit tricky due to various quirks. We
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
407 * could use '(["" nil nil]), but this is apparently equivalent
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
408 * to '(nil), and a new frame created with this menubar will
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
409 * get a vertically-squished menubar. If we use " " as the
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
410 * button title instead of "", we get an etched button border.
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
411 * So we use
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
412 * '(("No active menubar" ["" nil nil]))
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
413 * which creates a menu whose title is "No active menubar",
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
414 * and this works fine.
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
415 */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
416
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
417 Vblank_menubar = list1 (list2 (build_string ("No active menubar"),
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
418 vector3 (build_string (""), Qnil, Qnil)));
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 438
diff changeset
419 staticpro (&Vblank_menubar);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
420
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
421 DEFVAR_BOOL ("popup-menu-titles", &popup_menu_titles /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
422 If true, popup menus will have title bars at the top.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
423 */ );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
424 popup_menu_titles = 1;
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 /* #### Replace current menubar with a specifier. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
427
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
428 /* All C code must access the menubar via Qcurrent_menubar
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
429 because it can be buffer-local. Note that Vcurrent_menubar
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
430 doesn't need to exist at all, except for the magic function. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
431
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
432 DEFVAR_LISP_MAGIC ("current-menubar", &Vcurrent_menubar /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
433 The current menubar. This may be buffer-local.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
434
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
435 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
436 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
437 and `set-buffer-menubar'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
438
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
439 A menubar is a list of menus and menu-items.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
440 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
441
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
442 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
443 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
444 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
445 itself.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
446
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
447 Menu accelerators can be indicated in the string by putting the
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
448 sequence "%_" before the character corresponding to the key that will
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
449 invoke the menu or menu item. Uppercase and lowercase accelerators
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
450 are equivalent. The sequence "%%" is also special, and is translated
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
451 into a single %.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
452
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
453 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
454 the first character has been tagged as an accelerator.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
455
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
456 Immediately following the name string of the menu, various optional
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
457 keyword-value pairs are permitted: currently, :filter, :active, :included,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
458 and :config. (See below.)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
459
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
460 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
461 presented as unselectable text.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
462
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
463 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
464 item will be presented as a solid horizontal line.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
465
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
466 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
467 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
468 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
469 currently work only under X Windows (with Lucid and Motif menubars);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
470 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
471 all hyphens.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
472
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
473 The possibilities are:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
474
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
475 "--:singleLine"
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
476 "--:doubleLine"
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
477 "--:singleDashedLine"
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
478 "--:doubleDashedLine"
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
479 "--:noLine"
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
480 "--:shadowEtchedIn"
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
481 "--:shadowEtchedOut"
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
482 "--:shadowEtchedInDash"
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
483 "--:shadowEtchedOutDash"
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
484 "--:shadowDoubleEtchedIn" (Lucid menubars only)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
485 "--:shadowDoubleEtchedOut" (Lucid menubars only)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
486 "--:shadowDoubleEtchedInDash" (Lucid menubars only)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
487 "--:shadowDoubleEtchedOutDash" (Lucid menubars only)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
488
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
489 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
490 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
491 item representing this menu on the parent.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
492
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
493 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
494 division between the set of menubar-items which are flushleft and those
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
495 which are flushright.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
496
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
497 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
498 A menu item is of the following form:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
499
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
500 [ "name" callback :<keyword> <value> :<keyword> <value> ... ]
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
501
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
502 The following forms are also accepted for compatibility, but deprecated:
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
503
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
504 [ "name" callback <active-p> ]
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
505 [ "name" callback <active-p> <suffix> ]
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
506
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
507 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
508 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
509 is actually displayed. Menu accelerator indicators (the sequence `%_') are
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
510 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
511 evaluated with `eval', and the result should be a string.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
512
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
513 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
514 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
515 evaluated with `eval'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
516
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
517 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
518 keyword, and <suffix> is equivalent to using the :suffix keyword.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
519
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
520 The possible keywords are:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
521
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
522 :active <form> The expression is evaluated just before the menu is
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
523 displayed, and the menu will be selectable only if
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
524 the result is non-nil.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
525
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
526 :suffix <form> The expression is evaluated just before the menu is
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
527 displayed and the resulting string is appended to
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
528 the displayed name, providing a convenient way of
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
529 adding the name of a command's ``argument'' to the
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
530 menu, like ``Kill Buffer NAME''.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
531
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
532 :keys "string" Normally, the keyboard equivalents of commands in
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
533 menus are displayed when the `callback' is a symbol.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
534 This can be used to specify keys for more complex menu
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
535 items. It is passed through `substitute-command-keys'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
536 first.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
537
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
538 :style <style> Specifies what kind of object this menu item is:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
539
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
540 nil A normal menu item.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
541 toggle A toggle button.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
542 radio A radio button.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
543 button A menubar button.
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 The only difference between toggle and radio buttons is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
546 how they are displayed. But for consistency, a toggle
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
547 button should be used when there is one option whose
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
548 value can be turned on or off, and radio buttons should
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
549 be used when there is a set of mutually exclusive
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
550 options. When using a group of radio buttons, you
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
551 should arrange for no more than one to be marked as
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
552 selected at a time.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
553
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
554 :selected <form> Meaningful only when STYLE is `toggle', `radio' or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
555 `button'. This specifies whether the button will be in
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
556 the selected or unselected state.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
557
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
558 :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
559 menu item. The form is evaluated and the menu or menu
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
560 item is only displayed if the result is non-nil.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
561
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
562 :config <symbol> This is an efficient shorthand for
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
563 :included (memq symbol menubar-configuration)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
564 See the variable `menubar-configuration'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
565
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
566 :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
567 submenu description (i.e. not in a menu item itself).
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
568 (Remember that most of the keywords can take evaluated
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
569 expressions as well as constants.) The filter is used to
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
570 incrementally create a submenu only when it is selected
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
571 by the user and not every time the menubar is activated.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
572 The filter function is passed the list of menu items in
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
573 the submenu and must return the modified list to be
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
574 actually used. The filter MUST NOT destructively modify
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
575 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
576 when the menu is about to be displayed, so other menus
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
577 may already be displayed. Vile and terrible things will
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
578 happen if a menu filter function changes the current
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
579 buffer, window, or frame. It also should not raise,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
580 lower, or iconify any frames. Basically, the filter
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
581 function should have no side-effects.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
582
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
583 :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
584 Ignored by XEmacs for easymenu.el compatibility.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
585 (XEmacs computes this information automatically.)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
586
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
587 For example:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
588
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
589 ("%_File"
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
590 :filter file-menu-filter ; file-menu-filter is a function that takes
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
591 ; one argument (a list of menu items) and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
592 ; returns a list of menu items
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
593 [ "Save %_As..." write-file t ]
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
594 [ "%_Revert Buffer" revert-buffer (buffer-modified-p) ]
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
595 [ "R%_ead Only" toggle-read-only :style toggle
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
596 :selected buffer-read-only ]
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
597 )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
598
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
599 See menubar-items.el for many more examples.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
600
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
601 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
602 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
603 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
604 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
605 dynamically alter or sensitize menus. */, menubar_variable_changed);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
606
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
607 Vcurrent_menubar = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
608
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
609 DEFVAR_LISP ("activate-menubar-hook", &Vactivate_menubar_hook /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
610 Function or functions called before a menubar menu is pulled down.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
611 These functions are called with no arguments, and should interrogate and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
612 modify the value of `current-menubar' as desired.
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 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
615 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
616 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
617 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
618 the documentation of `current-menubar'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
619
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
620 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
621 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
622 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
623 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
624 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
625 the menubar will still be performed optimally.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
626 */ );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
627 Vactivate_menubar_hook = Qnil;
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 464
diff changeset
628 DEFSYMBOL (Qactivate_menubar_hook);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
629
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
630 DEFVAR_BOOL ("menubar-show-keybindings", &menubar_show_keybindings /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
631 If true, the menubar will display keyboard equivalents.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
632 If false, only the command names will be displayed.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
633 */ );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
634 menubar_show_keybindings = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
635
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
636 DEFVAR_LISP_MAGIC ("menubar-configuration", &Vmenubar_configuration /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
637 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
638 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
639 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
640 `menubar-configuration' list.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
641 */ , menubar_variable_changed);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
642 Vmenubar_configuration = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
643
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
644 DEFVAR_LISP ("menubar-pointer-glyph", &Vmenubar_pointer_glyph /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
645 *The shape of the mouse-pointer when over the menubar.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
646 This is a glyph; use `set-glyph-image' to change it.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
647 If unspecified in a particular domain, the window-system-provided
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
648 default pointer is used.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
649 */ );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
650
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
651 DEFVAR_LISP ("menu-accelerator-prefix", &Vmenu_accelerator_prefix /*
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
652 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
653 Set this to a value acceptable by define-key.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
654
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
655 NOTE: This currently only has any effect under X Windows.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
656 */ );
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
657 Vmenu_accelerator_prefix = Qnil;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
658
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
659 DEFVAR_LISP ("menu-accelerator-modifiers", &Vmenu_accelerator_modifiers /*
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
660 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
661 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
662 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
663 menu to become active.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
664
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
665 NOTE: This currently only has any effect under X Windows.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
666
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
667 See also menu-accelerator-enabled and menu-accelerator-prefix.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
668 */ );
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
669 Vmenu_accelerator_modifiers = list1 (Qmeta);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
670
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
671 DEFVAR_LISP ("menu-accelerator-enabled", &Vmenu_accelerator_enabled /*
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
672 Whether menu accelerator keys can cause the menubar to become active.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
673 If 'menu-force or 'menu-fallback, then menu accelerator keys can
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
674 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
675 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
676
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
677 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
678 precedence over bindings in the current keymap(s). menu-fallback means
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
679 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
680 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
681 keypress of Meta-t if menu-accelerator-enabled is menu-force.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
682 However, if menu-accelerator-enabled is menu-fallback, then
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
683 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
684 transpose-words, to which it is normally bound.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
685
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
686 See also menu-accelerator-modifiers and menu-accelerator-prefix.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
687 */ );
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
688 Vmenu_accelerator_enabled = Qnil;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
689
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
690 DEFVAR_LISP ("menu-accelerator-map", &Vmenu_accelerator_map /*
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
691 Keymap for use when the menubar is active.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
692 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
693 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
694 NOTE: This currently only has any effect under X Windows.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
695
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
696 menu-quit Immediately deactivate the menubar and any open submenus without
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
697 selecting an item.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
698 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
699 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
700 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
701 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
702 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
703 into the selected menu.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
704 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
705 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
706 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
707 around to the right edge.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
708 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
709 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
710 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
711 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
712 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
713 a submenu heading, then move the cursor into the submenu.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
714 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
715 parent menu. From the top level menu, this deactivates the
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
716 menubar.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
717
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
718 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
719 menubar is deactivated and the corresponding command is executed.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
720
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
721 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
722 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
723 */ );
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
724
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
725 Fprovide (intern ("menubar"));
464
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 450
diff changeset
726 Fprovide (intern ("menu-accelerator-support"));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
727 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
728
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
729 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
730 specifier_vars_of_menubar (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
731 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
732 DEFVAR_SPECIFIER ("menubar-visible-p", &Vmenubar_visible_p /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
733 *Whether the menubar is visible.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
734 This is a specifier; use `set-specifier' to change it.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
735 */ );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
736 Vmenubar_visible_p = Fmake_specifier (Qboolean);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
737
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
738 set_specifier_fallback (Vmenubar_visible_p, list1 (Fcons (Qnil, Qt)));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
739 set_specifier_caching (Vmenubar_visible_p,
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 428
diff changeset
740 offsetof (struct window, menubar_visible_p),
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
741 menubar_visible_p_changed,
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 428
diff changeset
742 offsetof (struct frame, menubar_visible_p),
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
743 menubar_visible_p_changed_in_frame, 0);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
744 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
745
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
746 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
747 complex_vars_of_menubar (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
748 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
749 Vmenubar_pointer_glyph = Fmake_glyph_internal (Qpointer);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
750
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
751 Vmenu_accelerator_map = Fmake_keymap (Qnil);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
752 }