AddMenus - User Defined Menu Examples


Copyright Apple Computer, Inc. 1987
All rights reserved.


This file contains a large collection of AddMenu commands, used to add
user defined items to the shell menus.  You'll probably want to try
the commands that look interesting by selecting them and pressing Enter.

You can make any of these menu items part of your customized MPW system
by placing them in your UserStartup file, in the same directory as
the MPW Shell.


File Menu

	The commands below add Restart and Shut Down items to the File menu.
	Restart and Shut Down are similar to the same menu items in the Finder.
	Add the -y option to either command (before the final single quote) to
	automatically save all files, avoiding the save dialogs.

		AddMenu File Restart 'ShutDown -r'  # add -y to save all
		AddMenu File 'Shut Down' 'ShutDown'	# add -y to save all

	The commands below add Eject items to the File menu.  These items
	unmount and eject the disks in drives 1 and 2.  The command key
	equivalents are Cmd-1 and Cmd-2.  (Note that these menu items
	differ from Cmd-Shift-1 and Cmd-Shift-2, which eject the disks
	without unmounting them.)   The first command below adds a dividing
	line that separates these menu items from others already in the File
	menu.

		AddMenu File '(-' ''
		AddMenu File 'Eject 1/1' 'Eject 1'
		AddMenu File 'Eject 2/2' 'Eject 2'


	The menu items created by the following AddMenu commands replace the
	current selection with the volume names of disks 1 and 2.  Because
	they replace the selection (or insertion point) and leave the insertion
	point immediately following the name, these menu items serve as
	shortcuts for typing the volume names.  The command key equivalents
	are Cmd-¡ (i.e. Cmd-Option-1) and Cmd-™ (i.e. Cmd-Option-2).

		AddMenu File '(-' ''
		AddMenu File 'Disk Name 1/¡' ∂
			'(Replace § "`Volumes 1`" "{Active}") ≥ Dev:Null'
		AddMenu File 'Disk Name 2/™' ∂
			'(Replace § "`Volumes 2`" "{Active}") ≥ Dev:Null'


Edit Menu

	The commands below provide menu items with command key equivalents
	for deleting characters and words, and for moving the insertion point
	forward and backward a word at a time.

	Delete Char   - delete the selection and the following character
	Delete Word   - delete the selection and the following word
	Forward Word  - place the insertion point after the next word
	Backward Word - place the insertion point before the previous word

		AddMenu Edit '(-' ''
		AddMenu Edit 'Delete Char/ß' ∂
			'Clear "§:§!1" "{Active}"'
		AddMenu Edit 'Delete Word/∂' ∂
			'Clear "§:∆/[{WordSet}][¬{WordSet}]/!1" "{Active}"'
		AddMenu Edit 'Forward Word/ƒ' ∂
			'Find "∆/[{WordSet}][¬{WordSet}]/!1" "{Active}"'
		AddMenu Edit 'Backward Word/©' ∂
			'Find "§¡1" "{Active}"; ∂
			 Find "∆\[¬{WordSet}][{WordSet}]\!1" "{Active}"'

	The commands above define the following command key equivalents:

		Delete Char 	ß 	Cmd-Option-s
		Delete Word		∂	Cmd-Option-d
		Forward Word	ƒ	Cmd-Option-f
		Backward Word 	© 	Cmd-Option-g

	{WordSet} is a variable defined in the Startup file that determines the
	characters in words.  The default value for {WordSet} is 'a-zA-Z_0-9'.

	{Active} is a variable, defined by the shell, that contains the name
	of the active window.

	The selection expressions are interpreted as follows:

	§:§!1  							means  §:(§!1)
	§:∆/[{WordSet}][¬{WordSet}]/!1  means  §:((∆/[{WordSet}][¬{WordSet}]/)!1)
	∆/[{WordSet}][¬{WordSet}]/!1  	means  (∆/[{WordSet}][¬{WordSet}]/)!1
	∆\[¬{WordSet}][{WordSet}]\!1  	means  (∆\[¬{WordSet}][{WordSet}]\)!1

	You might want to use Help to review the definitions of Selections
	and Patterns.

		Help Selections
		Help Patterns



Find Menu

	The Show Line Number menu item displays an alert showing the line
	number of the line containing the insertion point (or the last
	character of the selection).  As a side effect, this line is selected.

		AddMenu Find 'Show Line Number' ∂
			'Begin; ∂
			 Find !0:• "{Active}"; ∂
			 Alert `Echo -n "Line "; Count -l "{Active}".§`; ∂
			 Find !0 "{Active}"; ∂
			 End > Dev:Null ≥ Dev:Null'

	The commands above select everything from the beginning of the file
	to the end of the current selection, and then use Count to count the
	lines in this new selection.  Alert is used to display the results
	of Count.  Finally, the current line is selected.



Build Menu

	The Build menu is created by the script {MPW}Scripts:BuildMenu, which
	is normally run from UserStartup.  The following are possible additions
	to the Build menu.

	The Build Same menu item can be used to avoid the dialog that asks
	for the name of the program.  Build Same, and the other Build menu items,
	use the shell variable {Program} to remember the name of the most recently
	built program.  Its command key equivalent is ∫ (Cmd-Option-b).

	Next Error and Previous Error are used to step through assembler or
	compiler errors in the Worksheet.  The menu items select and execute
	lines beginning with the word "File".  The command key equivalents
	are ≤ (Cmd-Option-<) and ≥ (Cmd-Option->).

	Build Same		- build the most recently built program again
	Next Error		- select the source line of the next error
	Previous Error  - select the source line of the previous error

		AddMenu Build '(-' ''
		AddMenu Build 'Build Same/∫' ∂
			'Begin; ∂
			 Exit If "{Program}" == ""; ∂
			 Open "{Worksheet}"; ∂
			 Echo; Echo; ∂
			 BuildProgram "{Program}"; ∂
			 End >> "{Worksheet}" ≥≥ Dev:StdOut'
		AddMenu Build '(-' ''
		AddMenu Build 'Next Error/≥' ∂
		   	'Begin; ∂
			 Find /•[ ∂t]*File/ "{Worksheet}"; ∂
		 	 Find !0 "{Worksheet}"; ∂
			 Execute "{Worksheet}.§"; ∂
			 End > Dev:Null ≥ Dev:Null'
		AddMenu Build 'Previous Error/≤' ∂
		   	'Begin; ∂
			 Find \•[ ∂t]*File\ "{Worksheet}"; ∂
		 	 Find !0 "{Worksheet}"; ∂
			 Execute "{Worksheet}.§"; ∂
			 End > Dev:Null ≥ Dev:Null'



Lookup Menu

	The Lookup menu is used to open files in specific directories.  Each
	menu item corresponds to a different directory.

	The Lookup script displays a standard file dialog that is open to
	the specified directory.  Furthermore, standard file's default
	directory is saved and restored, so future uses of standard file
	are unaffected by this temporary excursion into another directory.

	To see the the Lookup script, execute the following:

		Open "{MPW}"Examples:Lookup

	Important:	To use these menu items, you must duplicate the Lookup
	script to a directory in which the shell looks for commands:

		Duplicate "{MPW}"Examples:Lookup "{MPW}"Scripts:

	The following commands create Lookup menu items for the shell's
	directory, the scripts folder, and each of the include file and
	interface folders.  You may want to add your own directories following
	the dividing line created by the last command below.

		AddMenu Lookup '{ShellDirectory}' ∂
			'Lookup "{ShellDirectory}" > Dev:Null ≥ Dev:Null'
		AddMenu Lookup '{MPW}Scripts:' ∂
			'Lookup "{MPW}"Scripts: > Dev:Null ≥ Dev:Null'
		AddMenu Lookup '{AIncludes}' ∂
			'Lookup "{AIncludes}" > Dev:Null ≥ Dev:Null'
		AddMenu Lookup '{CIncludes}' ∂
			'Lookup "{CIncludes}" > Dev:Null ≥ Dev:Null'
		AddMenu Lookup '{PInterfaces}' ∂
			'Lookup "{PInterfaces}" > Dev:Null ≥ Dev:Null'
		AddMenu Lookup '{RIncludes}' ∂
			'Lookup "{RIncludes}" > Dev:Null ≥ Dev:Null'
		AddMenu Lookup '(-' ''
