ShellPanel Utilities for NEXTSTEP Version 2.0 (R&A) May 1996 Alert, Menu, Open and Save are simple wrappers for the NEXTSTEP NXRunAlertPanel routine and Menu, OpenPanel and SavePanel objects that allow them to be used from (interactive) Unix shell scripts (to provide consistent GUI panels across C and shell executables). NIDomain, NIOpen and NISave are wrappers for the NIKit NIDomainPanel,NIOpenPanel and NISavePanel objects that allow them to be used from Unix shell scripts. (The included wrapper for NILoginPanel doesn't work.) Inputline and Text are slightly more complex wrappers for the NEXTSTEP TextField and Text objects that allow them to be used from (interactive) Unix shell scripts. All ShellPanel utilities recognize at least the following optional arguments (unless noted otherwise): -H Display on-line help. -V Display version information. -i iconFile Use the tiff or eps image in iconFile as application icon. -t title Set title string to title. Alert takes several optional arguments, the message to display and three button labels as arguments: Alert [-A] [message] [defaultButton] [altButton] [otherButton] All arguments are optional--buttons are not drawn if labels are not supplied. The return value of NXRunAlertPanel is remapped into something useful for shell scripts; for the first (default) button (first button argument but first from the right on the panel), it returns 0 (success), otherwise 1 or 2 for the other buttons and -1 (255 in some shells like sh) on error. Thus, you can do things like: Alert 'Are you sure?' 'Yes' 'No' 'Help' if ( $status == 2 ) ... There is no access to the printf-like features of NXRunAlertPanel as you can provide the same functionality from within the shell script language, eg: Alert "Using the current time (`date`)" The title of the alert panel is taken from the name of the program if not given explicitly, so you can have a Warning panel by doing 'ln -s Alert Warning' where Alert is stored (eg. /usr/local/bin). Use the -A option if you don't want the Alert panel to become the main window, so it won't eat your keystrokes when it pops up. This is useful, for instance, if Alert is invoked to signal an error condition in a background process (where you wouldn't normally expect it to pop up, or you cannot predict when it will pop up.) Menu takes several optional arguments and at least one required menu item: Menu [-c char] [-t title] [-x xpos -y ypos] [-T seconds] item [item [...]] Where char is the character from which to start assigning key equivalents ('1' by default) , title is the title of the menu (the name of the Menu program by default), xpos and ypos are the coordinates where the menu should be displayed (upper left corner by default)--both positions must be specified if either is and seconds is the time to wait before timing out (30 seconds by default)--a value of 0 prevents a timeout. Menu exits with status = 0 on success (a menu item was selected) and prints the selected item to stdout . If the menu timeout occurs, it exits with status = 1 (failure) and prints nothing. If given bad arguments, it exits with status = 2 and prints a usage message to stderr. An example use of Menu from csh: set zones = `find /etc/zoneinfo ! -name '*GMT*' -type f -exec basename {} \;` set zone = `Menu -t 'Select Time Zone' $zones` if ($status == 0) setenv TZ $zone Menu does not recognize the -i option. Open and Save take several optional arguments: Open [-f file] [-d directory] [-e type [-e type]] [-p prompt] [-t title] [-m] [-c] Save [-f file] [-d directory] [-e type] [-p prompt] [-t title] [-u] Where file is the file to display in the form field of the panel, directory is the directory to display in tkF†RF—FÆR&–çFVBBF†RF÷öbF†R y in tanel and prompt is the title of the form field (defaults to List Title:). The -f option to NISave sets the initially selected directory. Both NIOpen and NISave exit with status = 0 on success and print the (fully expanded) file name(s) to stdout (one per line). If the user selects Cancel, they exit with status = 3 (cancel) and print nothing. If given bad arguments, they exit with status = 2 and print a usage message to stderr. Installation Run make to (re)compile the ShellPanel programs. By default the utilities are compiled quad-fat. If you do not want this (or cannot do this since you run NS3.2 or earlier versions then run: make RC_ARCHS='-arch arch1 [-arch arch2...]' After that you can install the programs in /usr/local/bin with the command: make install This will also install the nib file needed by Inputline in /LocalLibrary/Resources. All other programs are standalone. Comments and/or suggestions welcome. Christopher Lane (lane@sumex-aim.stanford.edu). Copyright 1990, 1991 & 1992 by The Leland Stanford Junior University. 2.0 upgrade and Inputline, Text by: Tom Hageman , Gerben Wierda Copyright 1994±1996 by R&A.