2002-03-21 08:15:39 +03:00
|
|
|
.\" $NetBSD: menuc.1,v 1.9 2002/03/21 05:15:39 phil Exp $
|
1997-09-26 21:54:09 +04:00
|
|
|
.\"
|
|
|
|
.\" Copyright 1997 Piermont Information Systems Inc.
|
|
|
|
.\" All rights reserved.
|
|
|
|
.\"
|
|
|
|
.\" Written by Philip A. Nelson for Piermont Information Systems Inc.
|
|
|
|
.\"
|
|
|
|
.\" Redistribution and use in source and binary forms, with or without
|
|
|
|
.\" modification, are permitted provided that the following conditions
|
|
|
|
.\" are met:
|
|
|
|
.\" 1. Redistributions of source code must retain the above copyright
|
|
|
|
.\" notice, this list of conditions and the following disclaimer.
|
|
|
|
.\" 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
.\" notice, this list of conditions and the following disclaimer in the
|
|
|
|
.\" documentation and/or other materials provided with the distribution.
|
|
|
|
.\" 3. All advertising materials mentioning features or use of this software
|
|
|
|
.\" must display the following acknowledgement:
|
|
|
|
.\" This product includes software develooped for the NetBSD Project by
|
|
|
|
.\" Piermont Information Systems Inc.
|
|
|
|
.\" 4. The name of Piermont Information Systems Inc. may not be used to endorse
|
|
|
|
.\" or promote products derived from this software without specific prior
|
|
|
|
.\" written permission.
|
|
|
|
.\"
|
|
|
|
.\" THIS SOFTWARE IS PROVIDED BY PIERMONT INFORMATION SYSTEMS INC. ``AS IS''
|
|
|
|
.\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
2001-12-01 19:43:07 +03:00
|
|
|
.\" ARE DISCLAIMED. IN NO EVENT SHALL PIERMONT INFORMATION SYSTEMS INC. BE
|
|
|
|
.\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
1997-09-26 21:54:09 +04:00
|
|
|
.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
2001-12-01 19:43:07 +03:00
|
|
|
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
1997-09-26 21:54:09 +04:00
|
|
|
.\" THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
.\"
|
|
|
|
.Dd September 26, 1997
|
1999-03-22 21:16:34 +03:00
|
|
|
.Os
|
1997-09-26 21:54:09 +04:00
|
|
|
.Dt MENUC 1
|
|
|
|
.Sh NAME
|
|
|
|
.Nm menuc
|
|
|
|
.Nd menu compiler
|
|
|
|
.Sh SYNOPSIS
|
|
|
|
menuc
|
|
|
|
.Op Fl o Ar name
|
|
|
|
.Ar file
|
|
|
|
.Sh DESCRIPTION
|
|
|
|
This implements a curses based menu system. A source file that describes
|
|
|
|
menus, their options, and how to process the options is given to
|
|
|
|
.Nm
|
|
|
|
and produces both a .c and a .h file that implement the menu system.
|
2001-12-01 19:43:07 +03:00
|
|
|
The standard base name of the files is
|
1997-10-19 09:08:17 +04:00
|
|
|
.Pa menu_defs .
|
2001-12-01 19:43:07 +03:00
|
|
|
The
|
1997-09-26 21:54:09 +04:00
|
|
|
.Fl o Ar name
|
2001-01-07 09:09:19 +03:00
|
|
|
can be used to specify a different base name.
|
1999-12-31 07:03:18 +03:00
|
|
|
.Sh ENVIRONMENT
|
|
|
|
.Bl -tag -width MENUDEF
|
|
|
|
.It Ev MENUDEF
|
2001-12-01 19:43:07 +03:00
|
|
|
Can be set to point to a different set of
|
1999-12-31 07:03:18 +03:00
|
|
|
definition files for
|
|
|
|
.Nm menuc .
|
|
|
|
The current location defaults to
|
|
|
|
.Pa /usr/share/misc .
|
|
|
|
.El
|
2001-01-07 09:09:19 +03:00
|
|
|
.Sh MENU DESCRIPTIONS
|
2001-12-01 19:43:07 +03:00
|
|
|
The input
|
|
|
|
.Ar file
|
2001-01-07 09:09:19 +03:00
|
|
|
defines static menus and options for processing
|
|
|
|
those menus. It also contains comments, initial C code that
|
|
|
|
is required to provide for definitions and other code necssary
|
|
|
|
for the menu system, and an option declaration if dynamic
|
|
|
|
menus are requested.
|
|
|
|
.Pp
|
|
|
|
Comments may appear anywhere in the input
|
|
|
|
.Ar file
|
2001-12-01 19:43:07 +03:00
|
|
|
and are like a space in the input.
|
2001-01-07 09:09:19 +03:00
|
|
|
They are like C comments starting with
|
|
|
|
.Em /*
|
|
|
|
and ending with
|
2001-12-01 23:39:13 +03:00
|
|
|
.Em */ .
|
2001-01-07 09:09:19 +03:00
|
|
|
They are unlike C comments in that they may be nested. A comment
|
2001-12-01 19:43:07 +03:00
|
|
|
does not end until a matching end comment is found.
|
2001-01-07 09:09:19 +03:00
|
|
|
.Pp
|
|
|
|
In many places, C code is included in the definition
|
2001-12-01 23:39:13 +03:00
|
|
|
.Ar file .
|
2001-01-07 09:09:19 +03:00
|
|
|
All C code is passed verbatim to the C output file.
|
2001-12-01 19:43:07 +03:00
|
|
|
.Nm menuc
|
2001-01-07 09:09:19 +03:00
|
|
|
comments do not start in C code
|
|
|
|
and comments in the C code are passed verbatim to
|
2001-12-01 19:43:07 +03:00
|
|
|
the output. The C comments are not recognized by
|
2001-12-01 23:39:13 +03:00
|
|
|
.Nm menuc .
|
2001-01-07 09:09:19 +03:00
|
|
|
In all cases, C code starts with a left brace
|
|
|
|
.Em ({)
|
|
|
|
and ends with the matching right brace
|
2001-12-01 23:39:13 +03:00
|
|
|
.Em (}) .
|
2001-01-07 09:09:19 +03:00
|
|
|
It is important to recognize that in code segments, any brace
|
|
|
|
will be counted, even if it is in a C comment inside the code.
|
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Ar file
|
|
|
|
contains an initial (and optional) code block followed by any
|
|
|
|
number of menu definition elements in any order. The initial
|
|
|
|
code block usually contains includes of header files used by
|
2001-12-01 19:43:07 +03:00
|
|
|
code in the menu code blocks later in the
|
2001-12-01 23:39:13 +03:00
|
|
|
.Ar file .
|
2001-01-07 09:09:19 +03:00
|
|
|
The file is free format, so the actual formatting of the input
|
|
|
|
.Ar file
|
|
|
|
is to the taste of the programmer.
|
|
|
|
.Pp
|
|
|
|
All other C code that will appear in an
|
2001-12-01 23:39:13 +03:00
|
|
|
.Em action .
|
2001-12-01 19:43:07 +03:00
|
|
|
This will be specified as
|
2002-02-08 04:36:18 +03:00
|
|
|
.Em \*[Lt]action\*[Gt]
|
2001-01-07 09:09:19 +03:00
|
|
|
in later text. Such an action will appear as:
|
2002-02-08 04:36:18 +03:00
|
|
|
.Dl action \*[Lt]opt_endwin\*[Gt] \*[Lt]code\*[Gt]
|
2001-12-01 19:43:07 +03:00
|
|
|
in the
|
2001-12-01 23:39:13 +03:00
|
|
|
.Ar file .
|
2001-12-01 19:43:07 +03:00
|
|
|
The
|
2002-02-08 04:36:18 +03:00
|
|
|
.Em \*[Lt]opt_endwin\*[Gt] ,
|
2001-01-07 09:09:19 +03:00
|
|
|
if present is:
|
|
|
|
.Dl ( endwin )
|
|
|
|
and specifies that the curses
|
|
|
|
.Fn endwin
|
|
|
|
function should be called before executing the code and
|
|
|
|
then reinstating the current curses window after the
|
2001-12-01 19:43:07 +03:00
|
|
|
code has been run. The
|
2002-02-08 04:36:18 +03:00
|
|
|
.Em \*[Lt]code\*[Gt]
|
2001-01-07 09:09:19 +03:00
|
|
|
is as described above.
|
|
|
|
.Pp
|
|
|
|
There are four kinds of menu definition elements. The first
|
|
|
|
one just declares whether the programmer wants dynamic menus
|
|
|
|
available. The default is static menus only. The static menus
|
|
|
|
are the ones defined by the menu definitions and do not change
|
|
|
|
at run time. The dynamic menus provide the programmer with a
|
|
|
|
method to create and modify menus during the running of the program.
|
|
|
|
To include dynamic menus, one needs only add the declaration:
|
|
|
|
.Dl allow dynamic menus ;
|
|
|
|
The semicolon is required to terminate this declaration. This
|
2001-12-01 19:43:07 +03:00
|
|
|
declaration may appear anywhere in the
|
2001-12-01 23:39:13 +03:00
|
|
|
.Ar file ,
|
2001-01-07 09:09:19 +03:00
|
|
|
but usually appears before any menus are defined.
|
|
|
|
.Pp
|
2001-12-01 19:43:07 +03:00
|
|
|
The next element is a code block to execute if the curses
|
2001-01-07 09:09:19 +03:00
|
|
|
screen can not be sucessfully initialized. The declaration
|
|
|
|
.Dl error code ;
|
|
|
|
tells the menu system to execute the associated code block
|
|
|
|
if the initialization fails. If no code is provided, a
|
|
|
|
default code block is used that prints
|
|
|
|
.Dl Could not initialize curses.
|
|
|
|
and exits. This element may appear anywhere in the
|
|
|
|
.Ar file
|
|
|
|
but usually appers before any menus are defined.
|
|
|
|
.Pp
|
|
|
|
The next element defines default options for menus. Each
|
|
|
|
menu is built from a list of options. These options include
|
|
|
|
the location of the upper left corner of the menu, whether
|
|
|
|
there is a "box" drawn around the menu, whether the menu is
|
|
|
|
scrollable, the menu's title, whether shortcut letters are
|
|
|
|
allowed, whether a standard exit option should be included
|
|
|
|
in the menu and text associated with the standard exit option.
|
|
|
|
The general format is:
|
2002-02-08 04:36:18 +03:00
|
|
|
.Dl default \*[Lt]comma separated option list\*[Gt] ;
|
2001-01-07 09:09:19 +03:00
|
|
|
The options appear in three forms:
|
|
|
|
.Dl variable = value
|
|
|
|
.Dl [no] switch
|
|
|
|
.Dl variable "string"
|
|
|
|
.Pp
|
2001-12-01 19:43:07 +03:00
|
|
|
The variables for the first form are
|
2001-12-01 23:39:13 +03:00
|
|
|
.Va x ,
|
|
|
|
.Va y ,
|
|
|
|
.Va h ,
|
2001-01-07 09:09:19 +03:00
|
|
|
and
|
2001-12-01 23:39:13 +03:00
|
|
|
.Va w .
|
2001-01-07 09:09:19 +03:00
|
|
|
These specify the upper left (x,y) and the
|
|
|
|
height (h) and width (w) of the menu window. The upper
|
2001-12-01 19:43:07 +03:00
|
|
|
left is in the curses coordinate system. If not
|
2001-01-07 09:09:19 +03:00
|
|
|
specified, the upper left is the upper left of the screen
|
|
|
|
and the height and width of the menu window is computed
|
|
|
|
from the menu definition.
|
|
|
|
.Pp
|
2001-12-01 19:43:07 +03:00
|
|
|
Options of the second form turn on or off (with the
|
2001-01-07 09:09:19 +03:00
|
|
|
optional no) features of the menu system. The
|
|
|
|
.Li box
|
|
|
|
option turns on a box around the menu window. The
|
|
|
|
.Li exit
|
|
|
|
opton enables the standard exit option in the menus. The
|
|
|
|
.Li scrollable
|
2001-12-01 19:43:07 +03:00
|
|
|
option allows the menu to be scrollable if the
|
2001-01-07 09:09:19 +03:00
|
|
|
menu window is smaller than the number of menu options. The
|
|
|
|
.Li shortcut
|
|
|
|
option prints a single character shortcut with each menu
|
|
|
|
option.
|
|
|
|
.Pp
|
2001-12-01 19:43:07 +03:00
|
|
|
The third sets text variables. The variable
|
2001-01-07 09:09:19 +03:00
|
|
|
.Va title
|
|
|
|
sets the text title for the menus. The varible
|
|
|
|
.Va exitstring
|
|
|
|
sets the text for the exit menu option.
|
|
|
|
.Pp
|
|
|
|
The default declaration may appear multiple times. Each time,
|
|
|
|
it sets the default values for menu definitions that follow
|
2001-12-01 19:43:07 +03:00
|
|
|
in the
|
2001-12-01 23:39:13 +03:00
|
|
|
.Ar file .
|
2001-01-07 09:09:19 +03:00
|
|
|
In each menu definition, any or all of these default definitions
|
|
|
|
may be overridden for that menu.
|
|
|
|
.Pp
|
2002-03-21 08:15:39 +03:00
|
|
|
The final element is the actual static menu definitions.
|
2001-01-07 09:09:19 +03:00
|
|
|
The format and order for a menu definition is:
|
|
|
|
.Bd -ragged -offset indent
|
2002-02-08 04:36:18 +03:00
|
|
|
menu \*[Lt]name\*[Gt] \*[Lt]options\*[Gt] ;
|
|
|
|
\*[Lt]display action\*[Gt]
|
|
|
|
\*[Lt]menu items\*[Gt]
|
|
|
|
\*[Lt]exit action\*[Gt]
|
|
|
|
\*[Lt]help string\*[Gt]
|
2001-01-07 09:09:19 +03:00
|
|
|
.Ed
|
|
|
|
.Pp
|
|
|
|
Names are unquoted strings of alpha-numeric and underscore
|
2001-12-01 19:43:07 +03:00
|
|
|
characters. They must start with an alpha character.
|
2001-01-07 09:09:19 +03:00
|
|
|
In C source, a menu named
|
|
|
|
.Nm foo
|
2001-12-01 19:43:07 +03:00
|
|
|
is appears as
|
2001-12-01 23:39:13 +03:00
|
|
|
.Nm MENU_foo .
|
2001-01-07 09:09:19 +03:00
|
|
|
(Capitalization is important.) This is important,
|
|
|
|
because the menu is displayed and processed by
|
|
|
|
calling the function
|
2001-12-01 19:43:07 +03:00
|
|
|
.Dl process_menu (MENU_foo) ;
|
2001-01-07 09:09:19 +03:00
|
|
|
.Pp
|
|
|
|
The options are a comma separated list of options as in the
|
2001-12-01 19:43:07 +03:00
|
|
|
.Na default
|
2001-01-07 09:09:19 +03:00
|
|
|
declaration. These override the options from the most
|
|
|
|
recent default declaration.
|
|
|
|
.Pp
|
|
|
|
The display action is optional and provides C code to
|
|
|
|
execute at each and every time the menu is displayed
|
|
|
|
for processing. If it is included, the format is:
|
2002-02-08 04:36:18 +03:00
|
|
|
.Dl display \*[Lt]action\*[Gt] ;
|
2001-01-07 09:09:19 +03:00
|
|
|
.Pp
|
2001-12-01 19:43:07 +03:00
|
|
|
The bulk of the menu definition is the specification
|
2001-01-07 09:09:19 +03:00
|
|
|
of the menu items. The general format of a menu
|
|
|
|
item is:
|
2002-02-08 04:36:18 +03:00
|
|
|
.Dl option \*[Lt]string\*[Gt], \*[Lt]element_list\*[Gt] ;
|
2001-12-01 19:43:07 +03:00
|
|
|
The
|
2002-02-08 04:36:18 +03:00
|
|
|
.Em \*[Lt]string\*[Gt]
|
2001-01-07 09:09:19 +03:00
|
|
|
is the text displayed for the menu item. There
|
|
|
|
may be an arbitrary number of these items. (If
|
|
|
|
there are shortcuts in the menu, a practical limit
|
|
|
|
of 51 should be recoginzed. It produces shortcuts
|
|
|
|
a to w, y, z and A to Z. x is the shortcut for the
|
|
|
|
exit item.)
|
|
|
|
.Pp
|
2001-12-01 19:43:07 +03:00
|
|
|
The
|
2002-02-08 04:36:18 +03:00
|
|
|
.Em \*[Lt]element_list\*[Gt]
|
2001-01-07 09:09:19 +03:00
|
|
|
is a comma separated list of what to do when the
|
|
|
|
item is selected. They may appear in any order.
|
|
|
|
.Pp
|
|
|
|
The first element processed when a menu item
|
|
|
|
is selected is the associated action. The next
|
|
|
|
element to be processed is the sub or next
|
|
|
|
menu option. They are declared as:
|
2002-02-08 04:36:18 +03:00
|
|
|
.Dl next menu \*[Lt]name\*[Gt]
|
|
|
|
.Dl sub menu \*[Lt]name\*[Gt]
|
2001-01-07 09:09:19 +03:00
|
|
|
The difference between these two is that a sub
|
|
|
|
menu will return to the current menu when exited.
|
2001-12-01 19:43:07 +03:00
|
|
|
The next menu will just replace the current
|
2001-01-07 09:09:19 +03:00
|
|
|
menu and when exited, will return to where the
|
|
|
|
current menu would have gone. Only one of menu
|
|
|
|
element may be used for each menu item. Finally,
|
|
|
|
after processing both the action and a sub menu,
|
|
|
|
the current menu will be exited if the element
|
|
|
|
.Dl exit
|
2001-12-01 19:43:07 +03:00
|
|
|
is specified.
|
2001-12-01 23:39:13 +03:00
|
|
|
.Em Note :
|
2001-12-01 19:43:07 +03:00
|
|
|
If
|
2001-01-07 09:09:19 +03:00
|
|
|
.Em exit
|
|
|
|
is specified, next menu will not work because
|
2001-12-01 19:43:07 +03:00
|
|
|
the menu system will exit the
|
2001-01-07 09:09:19 +03:00
|
|
|
.Em current
|
2001-12-01 19:43:07 +03:00
|
|
|
menu, even if current has been set by
|
2001-12-01 23:39:13 +03:00
|
|
|
.Em next menu .
|
2001-01-07 09:09:19 +03:00
|
|
|
.Pp
|
|
|
|
After all menu items, the final two menu definition
|
|
|
|
elements may appear.
|
|
|
|
The exit action is optional and provides C code to
|
|
|
|
execute in the process of exiting a menu.
|
|
|
|
If it is included, the format is:
|
2002-02-08 04:36:18 +03:00
|
|
|
.Dl exit \*[Lt]action\*[Gt] ;
|
2001-01-07 09:09:19 +03:00
|
|
|
.Pp
|
|
|
|
The final part of the menu definition is the optional
|
|
|
|
help string. The format is:
|
2002-02-08 04:36:18 +03:00
|
|
|
.Dl help \*[Lt]text\*[Gt] ;
|
2001-01-07 09:09:19 +03:00
|
|
|
This text is displayed in a full page
|
|
|
|
help window if the question mark is typed.
|
|
|
|
The actual help text starts with a left brace
|
|
|
|
.Em ({)
|
|
|
|
and ends with the matching right brace
|
2001-12-01 23:39:13 +03:00
|
|
|
.Em (}) .
|
2001-01-07 09:09:19 +03:00
|
|
|
The braces are not included in the
|
|
|
|
help string, but all other characters between
|
|
|
|
them are included. Newlines in the code
|
|
|
|
translate to newlines in the help text.
|
|
|
|
.Sh DYNAMIC MENUS
|
2001-12-01 19:43:07 +03:00
|
|
|
If requested,
|
2001-01-07 09:09:19 +03:00
|
|
|
.Nm menuc
|
|
|
|
supports dynamic menus by allowing the user to create new
|
|
|
|
menus. The related definitions for using dynamic menus
|
|
|
|
are:
|
|
|
|
.Bd -literal
|
|
|
|
struct menudesc;
|
|
|
|
|
|
|
|
typedef
|
|
|
|
struct menu_ent {
|
|
|
|
char *opt_name;
|
|
|
|
int opt_menu;
|
|
|
|
int opt_flags;
|
|
|
|
int (*opt_action)(struct menudesc *);
|
|
|
|
} menu_ent ;
|
|
|
|
|
|
|
|
/* For opt_menu */
|
|
|
|
#define OPT_NOMENU -1
|
|
|
|
|
|
|
|
/* For opt_flags */
|
|
|
|
#define OPT_SUB 1
|
|
|
|
#define OPT_ENDWIN 2
|
|
|
|
#define OPT_EXIT 4
|
|
|
|
|
|
|
|
typedef
|
|
|
|
struct menudesc {
|
|
|
|
char *title;
|
|
|
|
int y, x;
|
|
|
|
int h, w;
|
|
|
|
int mopt;
|
|
|
|
int numopts;
|
|
|
|
int cursel;
|
|
|
|
int topline;
|
|
|
|
menu_ent *opts;
|
|
|
|
WINDOW *mw;
|
|
|
|
char *helpstr;
|
|
|
|
char *exitstr;
|
|
|
|
void (*post_act)(void);
|
|
|
|
void (*exit_act)(void);
|
|
|
|
} menudesc ;
|
|
|
|
|
|
|
|
/* defines for mopt field. */
|
|
|
|
#define MC_NOEXITOPT 1
|
|
|
|
#define MC_NOBOX 2
|
|
|
|
#define MC_SCROLL 4
|
|
|
|
#define MC_NOSHORTCUT 8
|
|
|
|
|
2001-12-01 19:43:07 +03:00
|
|
|
int new_menu (char * title, menu_ent * opts, int numopts,
|
2001-01-07 09:09:19 +03:00
|
|
|
int x, int y, int h, int w, int mopt,
|
|
|
|
void (*post_act)(void), void (*exit_act)(void), char * help);
|
|
|
|
|
|
|
|
void free_menu (int menu_no);
|
|
|
|
.Ed
|
|
|
|
.Pp
|
2001-12-01 19:43:07 +03:00
|
|
|
The
|
2001-01-07 09:09:19 +03:00
|
|
|
.Ar title
|
|
|
|
is the title displayed at the top of the menu. The
|
|
|
|
.Ar opts
|
|
|
|
is an array of menu entry definitions that has
|
|
|
|
.Ar numopts
|
|
|
|
elements. The programmer must build this array and
|
|
|
|
fill in all of the fields before processing calling
|
|
|
|
.Fn process_menu
|
|
|
|
for the new menu.
|
|
|
|
The fields of the
|
|
|
|
.Ar opts
|
|
|
|
may change at any time. For example,
|
|
|
|
.Em opt_name
|
|
|
|
may change as a result of selecting that option. When
|
|
|
|
the menu is redisplayed, the new text is printed.
|
|
|
|
Arguments,
|
|
|
|
.Ar x, y, h
|
|
|
|
and
|
|
|
|
.Ar w
|
|
|
|
are the same as the options in the menu description.
|
|
|
|
.Ar mopt
|
|
|
|
is the boolean options. Note, box, exit and shortcuts are
|
|
|
|
enabled by default. You need to add option flags to turn
|
|
|
|
them off or turn on scrollable menus.
|
|
|
|
The options
|
2001-12-01 23:39:13 +03:00
|
|
|
.Ar post_act ,
|
2001-01-07 09:09:19 +03:00
|
|
|
and
|
|
|
|
.Ar exit_act
|
|
|
|
are function pointers to the the display action and the exit
|
|
|
|
action. If they are NULL, no call will be made. And
|
|
|
|
finally,
|
|
|
|
.Ar help
|
|
|
|
is the text to display in a help screen. A NULL help
|
|
|
|
pointer will disable the help feature for the menu.
|
2001-12-01 23:39:13 +03:00
|
|
|
.Sh FILES
|
|
|
|
.Bl -item -width /usr/share/misc/menu_sys.def
|
|
|
|
.It
|
|
|
|
.Pa /usr/share/misc/menu_sys.def
|
|
|
|
.El
|
|
|
|
.Sh EXAMPLES
|
2001-01-07 09:09:19 +03:00
|
|
|
The following is a simple menu definition file.
|
|
|
|
It is complete in that the output of
|
|
|
|
.Na menuc
|
|
|
|
may be compiled into a complete program. For example,
|
|
|
|
if the following was in a file called
|
2001-12-01 23:39:13 +03:00
|
|
|
.Na example.mc ,
|
2001-01-07 09:09:19 +03:00
|
|
|
an executable program could be produced by the following
|
|
|
|
commands.
|
|
|
|
.Bd -literal -offset indent
|
|
|
|
menuc -o example example.mc
|
|
|
|
cc -o example example.c -lcurses
|
|
|
|
.Ed
|
|
|
|
A much
|
|
|
|
more complete example is available with the source
|
|
|
|
distribution in a subdirectory called
|
2001-12-01 23:39:13 +03:00
|
|
|
.Em testm .
|
2001-01-07 09:09:19 +03:00
|
|
|
.Bd -literal
|
|
|
|
/* This is an example menu definition file for menuc. */
|
|
|
|
|
|
|
|
{
|
2002-02-08 04:36:18 +03:00
|
|
|
#include \*[Lt]stdio.h\*[Gt]
|
|
|
|
#include \*[Lt]unistd.h\*[Gt]
|
2001-01-07 09:09:19 +03:00
|
|
|
|
|
|
|
/* Main program! This is often in a different file. */
|
|
|
|
int
|
|
|
|
main()
|
|
|
|
{
|
|
|
|
process_menu (MENU_main);
|
2001-12-01 19:43:07 +03:00
|
|
|
endwin();
|
2001-01-07 09:09:19 +03:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Example initialize function! */
|
|
|
|
void
|
|
|
|
init_main()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
default x=20, y=10, box, scrollable, exit;
|
|
|
|
|
|
|
|
error action {
|
|
|
|
fprintf (stderr, "Example Menu: Could not initialize curses.\n");
|
|
|
|
exit(1);
|
|
|
|
};
|
|
|
|
|
|
|
|
menu main, title "Main Menu", no exit, no shortcut;
|
|
|
|
display action { init_main(); };
|
|
|
|
option "Option 1",
|
|
|
|
action (endwin) {
|
|
|
|
printf ("That was option 1!\n");
|
|
|
|
sleep(3);
|
|
|
|
};
|
|
|
|
option "Sub Menu", sub menu othermenu;
|
|
|
|
option "Next Menu", next menu othermenu;
|
|
|
|
option "Quit", exit;
|
|
|
|
help {
|
|
|
|
This is a simple help screen for an example menu definition file.
|
|
|
|
};
|
2001-12-01 19:43:07 +03:00
|
|
|
|
2001-01-07 09:09:19 +03:00
|
|
|
menu othermenu, title "Sub/Next Menu", x=5, y=5, no box;
|
|
|
|
option "Do Nothing!", action { };
|
|
|
|
.Ed
|
2001-12-01 23:39:13 +03:00
|
|
|
.Sh AUTHORS
|
1997-09-26 21:54:09 +04:00
|
|
|
Philip A. Nelson for Piermont Information Systems Inc. Initial ideas
|
|
|
|
for this were developed and implemented in Pascal at the Leiden University,
|
|
|
|
Netherlands, in the summer of 1980.
|