summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorThorsten Lockert <tholo@cvs.openbsd.org>1996-06-02 21:34:43 +0000
committerThorsten Lockert <tholo@cvs.openbsd.org>1996-06-02 21:34:43 +0000
commitb8d379a3b8bd8bdd763abd7ea8cdc4e53351f610 (patch)
treea7f7e1c184744929e43893e3e0a2cb573c3425ae /lib
parent65af288d2747dc891a03f23bb5259b26adf16e7b (diff)
SYSV-style menu library; from ncurses
Diffstat (limited to 'lib')
-rw-r--r--lib/libmenu/.3x.366
-rw-r--r--lib/libmenu/Makefile18
-rw-r--r--lib/libmenu/Makefile.gnu331
-rw-r--r--lib/libmenu/READ.ME18
-rw-r--r--lib/libmenu/eti.h41
-rw-r--r--lib/libmenu/m_attribs.c169
-rw-r--r--lib/libmenu/m_cursor.c76
-rw-r--r--lib/libmenu/m_driver.c509
-rw-r--r--lib/libmenu/m_format.c112
-rw-r--r--lib/libmenu/m_global.c466
-rw-r--r--lib/libmenu/m_hook.c136
-rw-r--r--lib/libmenu/m_item_cur.c153
-rw-r--r--lib/libmenu/m_item_nam.c55
-rw-r--r--lib/libmenu/m_item_new.c188
-rw-r--r--lib/libmenu/m_item_opt.c130
-rw-r--r--lib/libmenu/m_item_use.c59
-rw-r--r--lib/libmenu/m_item_val.c87
-rw-r--r--lib/libmenu/m_item_vis.c53
-rw-r--r--lib/libmenu/m_items.c90
-rw-r--r--lib/libmenu/m_new.c91
-rw-r--r--lib/libmenu/m_opts.c153
-rw-r--r--lib/libmenu/m_post.c266
-rw-r--r--lib/libmenu/m_userptr.c59
-rw-r--r--lib/libmenu/m_win.c131
-rw-r--r--lib/libmenu/menu.3156
-rw-r--r--lib/libmenu/menu.h219
-rw-r--r--lib/libmenu/menu.priv.h97
-rw-r--r--lib/libmenu/menu_attribs.371
-rw-r--r--lib/libmenu/menu_cursor.344
-rw-r--r--lib/libmenu/menu_driver.3122
-rw-r--r--lib/libmenu/menu_format.354
-rw-r--r--lib/libmenu/menu_hook.372
-rw-r--r--lib/libmenu/menu_items.362
-rw-r--r--lib/libmenu/menu_mark.355
-rw-r--r--lib/libmenu/menu_new.350
-rw-r--r--lib/libmenu/menu_opts.375
-rw-r--r--lib/libmenu/menu_pattern.354
-rw-r--r--lib/libmenu/menu_post.361
-rw-r--r--lib/libmenu/menu_userptr.344
-rw-r--r--lib/libmenu/menu_win.366
-rw-r--r--lib/libmenu/mf_common.h67
-rw-r--r--lib/libmenu/shlib_version2
42 files changed, 4828 insertions, 0 deletions
diff --git a/lib/libmenu/.3x.3 b/lib/libmenu/.3x.3
new file mode 100644
index 00000000000..5f492124ca9
--- /dev/null
+++ b/lib/libmenu/.3x.3
@@ -0,0 +1,66 @@
+'\" t
+.TH menu_win 3X ""
+.SH NAME
+\fBmenu_win\fR - make and break menu window and subwindow associations
+.SH SYNOPSIS
+\fB#include <menu.h>\fR
+.br
+int set_menu_window(MENU *menu, WINDOW *win);
+.br
+WINDOW *menu_window(MENU *menu);
+.br
+int set_menu_sub(MENU *menu, WINDOW *sub);
+.br
+WINDOW *menu_sub(MENU *menu);
+.br
+int scale_window(MENU *menu, int *rows, int *columns);
+.br
+.SH DESCRIPTION
+Every menu has an associated pair of \fBcurses\fR windows. The menu window
+displays any title and border associated with the window; the menu subwindow
+displays the items of the menu that are currently available for selection.
+
+The first four functions get and set those windows. It is not necessary to set
+either window; by default, the driver code uses \fBstdscr\fR for both.
+
+In the \fBset_\fR functions, window argument of \fBNULL\fR is treated as tbough
+it were \fBstsdcr\fR. A menu argument of \fBNULL\fR is treated as a request
+to change the system default menu window or subwindow.
+
+The function \fBscale_window\fR returns the minimum size required for the
+subwindow of \fImenu\fR.
+.SH RETURN VALUE
+Routines that return pointers return \fBNULL\fR on error. Routines that return
+an integer return one of the following error codes:
+.TP 5
+\fBE_OK\fR
+The routine succeeded.
+.TP 5
+\fBE_SYSTEM_ERROR\fR
+System error occurred (see \fBerrno\fR).
+.TP 5
+\fBE_BAD_ARGUMENT\fR
+Routine detected an incorrect or out-of-range argument.
+.TP 5
+\fBE_POSTED\fR
+The menu has already been posted.
+.TP 5
+\fBE_NOT_CONNECTED\fR
+No items are connected to the menu.
+.SH SEE ALSO
+\fBcurses\fR(3X), \fBmenu\fR(3X).
+.SH NOTES
+The header file \fB<menu.h>\fR automatically includes the header file
+\fB<curses.h>\fR.
+.SH PORTABILITY
+These routines emulate the System V menu library. They were not supported on
+Version 7 or BSD versions.
+.SH AUTHORS
+Juergen Pfeifer. Manual pages and adaptation for new curses by Eric
+S. Raymond.
+.\"#
+.\"# The following sets edit modes for GNU EMACS
+.\"# Local Variables:
+.\"# mode:nroff
+.\"# fill-column:79
+.\"# End:
diff --git a/lib/libmenu/Makefile b/lib/libmenu/Makefile
new file mode 100644
index 00000000000..8399412300e
--- /dev/null
+++ b/lib/libmenu/Makefile
@@ -0,0 +1,18 @@
+LIB= menu
+SRCS= m_attribs.c m_cursor.c m_driver.c m_format.c m_global.c m_hook.c \
+ m_item_cur.c m_item_nam.c m_item_new.c m_item_opt.c m_item_use.c \
+ m_item_val.c m_item_vis.c m_items.c m_new.c m_opts.c m_post.c \
+ m_userptr.c m_win.c
+HDRS= menu.h eti.h
+CFLAGS+=-I. -I${.CURDIR} -DHAVE_EXTERN_ERRNO
+MAN= menu.3 menu_driver.3 menu_items.3 menu_opts.3 menu_userptr.3 \
+ menu_attribs.3 menu_format.3 menu_mark.3 menu_pattern.3 menu_win.3 \
+ menu_cursor.3 menu_hook.3 menu_new.3 menu_post.3
+
+includes:
+ @cd ${.CURDIR}; for i in ${HDRS}; do \
+ cmp -s $$i ${DESTDIR}/usr/include/$$i || \
+ install -c -m 444 -o $(BINOWN) -g $(BINGRP) $$i \
+ ${DESTDIR}/usr/include; done
+
+.include <bsd.lib.mk>
diff --git a/lib/libmenu/Makefile.gnu b/lib/libmenu/Makefile.gnu
new file mode 100644
index 00000000000..54000da30aa
--- /dev/null
+++ b/lib/libmenu/Makefile.gnu
@@ -0,0 +1,331 @@
+# Generated automatically from Makefile.in by configure.
+# Makefile for menu source code.
+#
+# This makes the following:
+# libraries (normal/debug/profile/shared)
+#
+# The variable 'srcdir' refers to the source-distribution, and can be set with
+# the configure script by "--srcdir=DIR".
+#
+# The rules are organized to produce the libraries for the configured models,
+
+# turn off _all_ suffix rules; we'll generate our own
+.SUFFIXES:
+
+SHELL = /bin/sh
+THIS = Makefile
+
+MODEL = normal
+srcdir = .
+prefix = /usr/local
+exec_prefix = /usr/local
+libdir = $(exec_prefix)/lib
+includedir = $(exec_prefix)/include
+
+INSTALL = /usr/bin/install -c
+INSTALL_DATA = ${INSTALL} -m 644
+
+AWK = awk
+LN_S = ln -s
+
+CC = gcc
+CFLAGS = -O
+
+CPPFLAGS = -DNDEBUG -I. -I../include -I$(includedir) \
+ -DHAVE_CONFIG_H
+
+CCFLAGS = $(CPPFLAGS) $(CFLAGS)
+
+CFLAGS_NORMAL = $(CCFLAGS)
+CFLAGS_DEBUG = $(CCFLAGS) -g -DTRACE
+CFLAGS_PROFILE = $(CCFLAGS) -pg
+# Juergen Pfeifer reports:
+# "Unfortunately -O crashes my linker on Linux and -O2 works"
+# If your linker coughs and dies, try uncommenting the -O2
+CFLAGS_SHARED = $(CCFLAGS) unknown # -O2
+
+CFLAGS_DEFAULT = $(CFLAGS_NORMAL)
+
+LINK = $(CC)
+LDFLAGS =
+
+MK_SHARED_LIB = echo unknown
+REL_VERSION = 1.9.9e
+ABI_VERSION = 3.0
+
+RANLIB = ranlib
+
+LIBRARIES = ../lib/libmenu.a ../lib/libmenu_g.a
+
+################################################################################
+all :: ../include/menu.h ../include/eti.h ../include/mf_common.h $(LIBRARIES)
+
+install :: install.libs
+
+install.libs:: $(includedir) $(libdir)
+ $(INSTALL_DATA) $(srcdir)/menu.h $(includedir)/menu.h
+ $(INSTALL_DATA) $(srcdir)/eti.h $(includedir)/eti.h
+
+$(includedir) \
+$(libdir) :
+ $(srcdir)/../mkinstalldirs $@
+
+# make copies to simplify include-paths while still keeping menu's include
+# file in this directory.
+../include/menu.h : $(srcdir)/menu.h
+ -rm -f $@
+ cp $(srcdir)/menu.h $@
+../include/eti.h : $(srcdir)/eti.h
+ -rm -f $@
+ cp $(srcdir)/eti.h $@
+../include/mf_common.h : $(srcdir)/mf_common.h
+ -rm -f $@
+ cp $(srcdir)/mf_common.h $@
+tags:
+ ctags *.[ch]
+
+TAGS:
+ etags *.[ch]
+
+clean ::
+ -rm -f tags TAGS *~ ../include/menu.h ../include/eti.h \
+ ../include/mf_common.h
+
+distclean: clean
+ -rm -f Makefile
+
+mostlyclean: clean
+
+realclean: distclean
+
+###############################################################################
+# The remainder of this file is automatically generated during configuration
+###############################################################################
+
+NORMAL_OBJS = \
+ ../objects/m_attribs.o \
+ ../objects/m_cursor.o \
+ ../objects/m_driver.o \
+ ../objects/m_format.o \
+ ../objects/m_global.o \
+ ../objects/m_hook.o \
+ ../objects/m_item_cur.o \
+ ../objects/m_item_nam.o \
+ ../objects/m_item_new.o \
+ ../objects/m_item_opt.o \
+ ../objects/m_item_use.o \
+ ../objects/m_item_val.o \
+ ../objects/m_item_vis.o \
+ ../objects/m_items.o \
+ ../objects/m_new.o \
+ ../objects/m_opts.o \
+ ../objects/m_post.o \
+ ../objects/m_userptr.o \
+ ../objects/m_win.o
+
+../lib/libmenu.a : $(NORMAL_OBJS)
+ ar rv $@ $?
+ $(RANLIB) $@
+
+install.libs \
+install.menu :: $(libdir) ../lib/libmenu.a
+ @echo installing ../lib/libmenu.a as $(libdir)/libmenu.a
+ $(INSTALL_DATA) ../lib/libmenu.a $(libdir)/libmenu.a
+ $(RANLIB) $(libdir)/libmenu.a
+
+clean ::
+ rm -f ../lib/libmenu.a
+ rm -f $(NORMAL_OBJS)
+
+# Library objects
+
+../objects/m_attribs.o : $(srcdir)/m_attribs.c \
+ ../include/menu.h
+ cd ../objects; $(CC) $(CFLAGS_NORMAL) -c ../menu/m_attribs.c
+
+../objects/m_cursor.o : $(srcdir)/m_cursor.c \
+ ../include/menu.h
+ cd ../objects; $(CC) $(CFLAGS_NORMAL) -c ../menu/m_cursor.c
+
+../objects/m_driver.o : $(srcdir)/m_driver.c \
+ ../include/menu.h
+ cd ../objects; $(CC) $(CFLAGS_NORMAL) -c ../menu/m_driver.c
+
+../objects/m_format.o : $(srcdir)/m_format.c \
+ ../include/menu.h
+ cd ../objects; $(CC) $(CFLAGS_NORMAL) -c ../menu/m_format.c
+
+../objects/m_global.o : $(srcdir)/m_global.c \
+ ../include/menu.h
+ cd ../objects; $(CC) $(CFLAGS_NORMAL) -c ../menu/m_global.c
+
+../objects/m_hook.o : $(srcdir)/m_hook.c \
+ ../include/menu.h
+ cd ../objects; $(CC) $(CFLAGS_NORMAL) -c ../menu/m_hook.c
+
+../objects/m_item_cur.o : $(srcdir)/m_item_cur.c \
+ ../include/menu.h
+ cd ../objects; $(CC) $(CFLAGS_NORMAL) -c ../menu/m_item_cur.c
+
+../objects/m_item_nam.o : $(srcdir)/m_item_nam.c \
+ ../include/menu.h
+ cd ../objects; $(CC) $(CFLAGS_NORMAL) -c ../menu/m_item_nam.c
+
+../objects/m_item_new.o : $(srcdir)/m_item_new.c \
+ ../include/menu.h
+ cd ../objects; $(CC) $(CFLAGS_NORMAL) -c ../menu/m_item_new.c
+
+../objects/m_item_opt.o : $(srcdir)/m_item_opt.c \
+ ../include/menu.h
+ cd ../objects; $(CC) $(CFLAGS_NORMAL) -c ../menu/m_item_opt.c
+
+../objects/m_item_use.o : $(srcdir)/m_item_use.c \
+ ../include/menu.h
+ cd ../objects; $(CC) $(CFLAGS_NORMAL) -c ../menu/m_item_use.c
+
+../objects/m_item_val.o : $(srcdir)/m_item_val.c \
+ ../include/menu.h
+ cd ../objects; $(CC) $(CFLAGS_NORMAL) -c ../menu/m_item_val.c
+
+../objects/m_item_vis.o : $(srcdir)/m_item_vis.c \
+ ../include/menu.h
+ cd ../objects; $(CC) $(CFLAGS_NORMAL) -c ../menu/m_item_vis.c
+
+../objects/m_items.o : $(srcdir)/m_items.c \
+ ../include/menu.h
+ cd ../objects; $(CC) $(CFLAGS_NORMAL) -c ../menu/m_items.c
+
+../objects/m_new.o : $(srcdir)/m_new.c \
+ ../include/menu.h
+ cd ../objects; $(CC) $(CFLAGS_NORMAL) -c ../menu/m_new.c
+
+../objects/m_opts.o : $(srcdir)/m_opts.c \
+ ../include/menu.h
+ cd ../objects; $(CC) $(CFLAGS_NORMAL) -c ../menu/m_opts.c
+
+../objects/m_post.o : $(srcdir)/m_post.c \
+ ../include/menu.h
+ cd ../objects; $(CC) $(CFLAGS_NORMAL) -c ../menu/m_post.c
+
+../objects/m_userptr.o : $(srcdir)/m_userptr.c \
+ ../include/menu.h
+ cd ../objects; $(CC) $(CFLAGS_NORMAL) -c ../menu/m_userptr.c
+
+../objects/m_win.o : $(srcdir)/m_win.c \
+ ../include/menu.h
+ cd ../objects; $(CC) $(CFLAGS_NORMAL) -c ../menu/m_win.c
+
+
+DEBUG_OBJS = \
+ ../obj_g/m_attribs.o \
+ ../obj_g/m_cursor.o \
+ ../obj_g/m_driver.o \
+ ../obj_g/m_format.o \
+ ../obj_g/m_global.o \
+ ../obj_g/m_hook.o \
+ ../obj_g/m_item_cur.o \
+ ../obj_g/m_item_nam.o \
+ ../obj_g/m_item_new.o \
+ ../obj_g/m_item_opt.o \
+ ../obj_g/m_item_use.o \
+ ../obj_g/m_item_val.o \
+ ../obj_g/m_item_vis.o \
+ ../obj_g/m_items.o \
+ ../obj_g/m_new.o \
+ ../obj_g/m_opts.o \
+ ../obj_g/m_post.o \
+ ../obj_g/m_userptr.o \
+ ../obj_g/m_win.o
+
+../lib/libmenu_g.a : $(DEBUG_OBJS)
+ ar rv $@ $?
+ $(RANLIB) $@
+
+install.libs \
+install.menu :: $(libdir) ../lib/libmenu_g.a
+ @echo installing ../lib/libmenu_g.a as $(libdir)/libmenu_g.a
+ $(INSTALL_DATA) ../lib/libmenu_g.a $(libdir)/libmenu_g.a
+ $(RANLIB) $(libdir)/libmenu_g.a
+
+clean ::
+ rm -f ../lib/libmenu_g.a
+ rm -f $(DEBUG_OBJS)
+
+# Library objects
+
+../obj_g/m_attribs.o : $(srcdir)/m_attribs.c \
+ ../include/menu.h
+ cd ../obj_g; $(CC) $(CFLAGS_DEBUG) -c ../menu/m_attribs.c
+
+../obj_g/m_cursor.o : $(srcdir)/m_cursor.c \
+ ../include/menu.h
+ cd ../obj_g; $(CC) $(CFLAGS_DEBUG) -c ../menu/m_cursor.c
+
+../obj_g/m_driver.o : $(srcdir)/m_driver.c \
+ ../include/menu.h
+ cd ../obj_g; $(CC) $(CFLAGS_DEBUG) -c ../menu/m_driver.c
+
+../obj_g/m_format.o : $(srcdir)/m_format.c \
+ ../include/menu.h
+ cd ../obj_g; $(CC) $(CFLAGS_DEBUG) -c ../menu/m_format.c
+
+../obj_g/m_global.o : $(srcdir)/m_global.c \
+ ../include/menu.h
+ cd ../obj_g; $(CC) $(CFLAGS_DEBUG) -c ../menu/m_global.c
+
+../obj_g/m_hook.o : $(srcdir)/m_hook.c \
+ ../include/menu.h
+ cd ../obj_g; $(CC) $(CFLAGS_DEBUG) -c ../menu/m_hook.c
+
+../obj_g/m_item_cur.o : $(srcdir)/m_item_cur.c \
+ ../include/menu.h
+ cd ../obj_g; $(CC) $(CFLAGS_DEBUG) -c ../menu/m_item_cur.c
+
+../obj_g/m_item_nam.o : $(srcdir)/m_item_nam.c \
+ ../include/menu.h
+ cd ../obj_g; $(CC) $(CFLAGS_DEBUG) -c ../menu/m_item_nam.c
+
+../obj_g/m_item_new.o : $(srcdir)/m_item_new.c \
+ ../include/menu.h
+ cd ../obj_g; $(CC) $(CFLAGS_DEBUG) -c ../menu/m_item_new.c
+
+../obj_g/m_item_opt.o : $(srcdir)/m_item_opt.c \
+ ../include/menu.h
+ cd ../obj_g; $(CC) $(CFLAGS_DEBUG) -c ../menu/m_item_opt.c
+
+../obj_g/m_item_use.o : $(srcdir)/m_item_use.c \
+ ../include/menu.h
+ cd ../obj_g; $(CC) $(CFLAGS_DEBUG) -c ../menu/m_item_use.c
+
+../obj_g/m_item_val.o : $(srcdir)/m_item_val.c \
+ ../include/menu.h
+ cd ../obj_g; $(CC) $(CFLAGS_DEBUG) -c ../menu/m_item_val.c
+
+../obj_g/m_item_vis.o : $(srcdir)/m_item_vis.c \
+ ../include/menu.h
+ cd ../obj_g; $(CC) $(CFLAGS_DEBUG) -c ../menu/m_item_vis.c
+
+../obj_g/m_items.o : $(srcdir)/m_items.c \
+ ../include/menu.h
+ cd ../obj_g; $(CC) $(CFLAGS_DEBUG) -c ../menu/m_items.c
+
+../obj_g/m_new.o : $(srcdir)/m_new.c \
+ ../include/menu.h
+ cd ../obj_g; $(CC) $(CFLAGS_DEBUG) -c ../menu/m_new.c
+
+../obj_g/m_opts.o : $(srcdir)/m_opts.c \
+ ../include/menu.h
+ cd ../obj_g; $(CC) $(CFLAGS_DEBUG) -c ../menu/m_opts.c
+
+../obj_g/m_post.o : $(srcdir)/m_post.c \
+ ../include/menu.h
+ cd ../obj_g; $(CC) $(CFLAGS_DEBUG) -c ../menu/m_post.c
+
+../obj_g/m_userptr.o : $(srcdir)/m_userptr.c \
+ ../include/menu.h
+ cd ../obj_g; $(CC) $(CFLAGS_DEBUG) -c ../menu/m_userptr.c
+
+../obj_g/m_win.o : $(srcdir)/m_win.c \
+ ../include/menu.h
+ cd ../obj_g; $(CC) $(CFLAGS_DEBUG) -c ../menu/m_win.c
+
diff --git a/lib/libmenu/READ.ME b/lib/libmenu/READ.ME
new file mode 100644
index 00000000000..eb5a64cde4f
--- /dev/null
+++ b/lib/libmenu/READ.ME
@@ -0,0 +1,18 @@
+This is a clone of the menu library that is available with typical
+System V curses implementations (ETI).
+
+It is modelled after the documentation that comes for this library with
+a 386 based SVR4 implementation (ESIX). This system was used together
+with an NCR3000 system to compile the clone using original curses
+implementation and to run various programs to check the compatibility of
+this clone with the original libmenu library.
+
+The development environment was an ELF based Linux system, the German
+Unifix distribution (aka Linux FT).
+
+For things that still need doing, see the TO-DO file in the top-level
+directory.
+
+Juergen Pfeifer
+
+eMail: Juergen.Pfeifer@T-Online.de
diff --git a/lib/libmenu/eti.h b/lib/libmenu/eti.h
new file mode 100644
index 00000000000..c1bc876def9
--- /dev/null
+++ b/lib/libmenu/eti.h
@@ -0,0 +1,41 @@
+
+/***************************************************************************
+* COPYRIGHT NOTICE *
+****************************************************************************
+* ncurses is copyright (C) 1992-1995 *
+* Zeyd M. Ben-Halim *
+* zmbenhal@netcom.com *
+* Eric S. Raymond *
+* esr@snark.thyrsus.com *
+* *
+* Permission is hereby granted to reproduce and distribute ncurses *
+* by any means and for any fee, whether alone or as part of a *
+* larger distribution, in source or in binary form, PROVIDED *
+* this notice is included with any such distribution, and is not *
+* removed from any of its header files. Mention of ncurses in any *
+* applications linked with it is highly appreciated. *
+* *
+* ncurses comes AS IS with no warranty, implied or expressed. *
+* *
+***************************************************************************/
+
+#ifndef _ETI_ERRNO_H_
+#define _ETI_ERRNO_H_
+
+#define E_OK (0)
+#define E_SYSTEM_ERROR (-1)
+#define E_BAD_ARGUMENT (-2)
+#define E_POSTED (-3)
+#define E_CONNECTED (-4)
+#define E_BAD_STATE (-5)
+#define E_NO_ROOM (-6)
+#define E_NOT_POSTED (-7)
+#define E_UNKNOWN_COMMAND (-8)
+#define E_NO_MATCH (-9)
+#define E_NOT_SELECTABLE (-10)
+#define E_NOT_CONNECTED (-11)
+#define E_REQUEST_DENIED (-12)
+#define E_INVALID_FIELD (-13)
+#define E_CURRENT (-14)
+
+#endif
diff --git a/lib/libmenu/m_attribs.c b/lib/libmenu/m_attribs.c
new file mode 100644
index 00000000000..6361f74b93f
--- /dev/null
+++ b/lib/libmenu/m_attribs.c
@@ -0,0 +1,169 @@
+
+/***************************************************************************
+* COPYRIGHT NOTICE *
+****************************************************************************
+* ncurses is copyright (C) 1992-1995 *
+* Zeyd M. Ben-Halim *
+* zmbenhal@netcom.com *
+* Eric S. Raymond *
+* esr@snark.thyrsus.com *
+* *
+* Permission is hereby granted to reproduce and distribute ncurses *
+* by any means and for any fee, whether alone or as part of a *
+* larger distribution, in source or in binary form, PROVIDED *
+* this notice is included with any such distribution, and is not *
+* removed from any of its header files. Mention of ncurses in any *
+* applications linked with it is highly appreciated. *
+* *
+* ncurses comes AS IS with no warranty, implied or expressed. *
+* *
+***************************************************************************/
+
+/***************************************************************************
+* Module menu_attribs *
+* Control menus display attributes *
+***************************************************************************/
+
+#include "menu.priv.h"
+
+/* Macro to redraw menu if it is posted and changed */
+#define Refresh_Menu(menu) \
+ if ( (menu) && ((menu)->status & _POSTED) )\
+ {\
+ _nc_Draw_Menu( menu );\
+ _nc_Show_Menu( menu );\
+ }
+
+/* "Template" macro to generate a function to set a menus attribute */
+#define GEN_MENU_ATTR_SET_FCT( name ) \
+int set_menu_ ## name (MENU * menu, chtype attr)\
+{\
+ if (!(attr==A_NORMAL || (attr & A_ATTRIBUTES)==attr))\
+ RETURN(E_BAD_ARGUMENT);\
+ if (menu && ( menu -> name != attr))\
+ {\
+ (menu -> name) = attr;\
+ Refresh_Menu(menu);\
+ }\
+ Normalize_Menu( menu ) -> name = attr;\
+ RETURN(E_OK);\
+}
+
+/* "Template" macro to generate a function to get a menus attribute */
+#define GEN_MENU_ATTR_GET_FCT( name ) \
+chtype menu_ ## name (const MENU * menu)\
+{\
+ return (Normalize_Menu( menu ) -> name);\
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : int set_menu_fore(MENU *menu, chtype attr)
+|
+| Description : Set the attribute for selectable items. In single-
+| valued menus thiis is used to highlight the current
+| item ((i.e. where the cursor is), in multi-valued
+| menus this is used to highlight the selected items.
+|
+| Return Values : E_OK - success
+| E_BAD_ARGUMENT - an invalid value has been passed
++--------------------------------------------------------------------------*/
+GEN_MENU_ATTR_SET_FCT( fore )
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : chtype menu_fore(const MENU* menu)
+|
+| Description : Return the attribute used for selectable items that
+| are current (single-valued menu) or selected (multi-
+| valued menu).
+|
+| Return Values : Attribute value
++--------------------------------------------------------------------------*/
+GEN_MENU_ATTR_GET_FCT( fore )
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : int set_menu_back(MENU *menu, chtype attr)
+|
+| Description : Set the attribute for selectable but not yet selected
+| items.
+|
+| Return Values : E_OK - success
+| E_BAD_ARGUMENT - an invalid value has been passed
++--------------------------------------------------------------------------*/
+GEN_MENU_ATTR_SET_FCT( back )
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : chtype menu_back(const MENU *menu)
+|
+| Description : Return the attribute used for selectable but not yet
+| selected items.
+|
+| Return Values : Attribute value
++--------------------------------------------------------------------------*/
+GEN_MENU_ATTR_GET_FCT( back )
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : int set_menu_grey(MENU *menu, chtype attr)
+|
+| Description : Set the attribute for unselectable items.
+|
+| Return Values : E_OK - success
+| E_BAD_ARGUMENT - an invalid value has been passed
++--------------------------------------------------------------------------*/
+GEN_MENU_ATTR_SET_FCT( grey )
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : chtype menu_grey(const MENU *menu)
+|
+| Description : Return the attribute used for non-selectable items
+|
+| Return Values : Attribute value
++--------------------------------------------------------------------------*/
+GEN_MENU_ATTR_GET_FCT( grey )
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : int set_menu_pad(MENU *menu, int pad)
+|
+| Description : Set the character to be used to separate the item name
+| from its description. This must be a printable
+| character.
+|
+| Return Values : E_OK - success
+| E_BAD_ARGUMENT - an invalid value has been passed
++--------------------------------------------------------------------------*/
+int set_menu_pad(MENU *menu, int pad)
+{
+ bool do_refresh = !(menu);
+
+ if (!isprint((unsigned char)pad))
+ RETURN(E_BAD_ARGUMENT);
+
+ Normalize_Menu( menu );
+ menu->pad = pad;
+
+ if (do_refresh)
+ Refresh_Menu( menu );
+
+ RETURN(E_OK);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : int menu_pad(const MENU *menu)
+|
+| Description : Return the value of the padding character
+|
+| Return Values : The pad character
++--------------------------------------------------------------------------*/
+int menu_pad(const MENU * menu)
+{
+ return (Normalize_Menu( menu ) -> pad);
+}
+
+/* m_attribs.c ends here */
diff --git a/lib/libmenu/m_cursor.c b/lib/libmenu/m_cursor.c
new file mode 100644
index 00000000000..8eb1ffebf47
--- /dev/null
+++ b/lib/libmenu/m_cursor.c
@@ -0,0 +1,76 @@
+
+/***************************************************************************
+* COPYRIGHT NOTICE *
+****************************************************************************
+* ncurses is copyright (C) 1992-1995 *
+* Zeyd M. Ben-Halim *
+* zmbenhal@netcom.com *
+* Eric S. Raymond *
+* esr@snark.thyrsus.com *
+* *
+* Permission is hereby granted to reproduce and distribute ncurses *
+* by any means and for any fee, whether alone or as part of a *
+* larger distribution, in source or in binary form, PROVIDED *
+* this notice is included with any such distribution, and is not *
+* removed from any of its header files. Mention of ncurses in any *
+* applications linked with it is highly appreciated. *
+* *
+* ncurses comes AS IS with no warranty, implied or expressed. *
+* *
+***************************************************************************/
+
+/***************************************************************************
+* Module menu_cursor *
+* Correctly position a menus cursor *
+***************************************************************************/
+
+#include "menu.priv.h"
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : pos_menu_cursor
+|
+| Description : Position logical cursor to current item in menu
+|
+| Return Values : E_OK - success
+| E_BAD_ARGUMENT - invalid menu
+| E_NOT_POSTED - Menu is not posted
++--------------------------------------------------------------------------*/
+int pos_menu_cursor(const MENU * menu)
+{
+ if (!menu)
+ RETURN(E_BAD_ARGUMENT);
+ else
+ {
+ ITEM *item;
+ int x, y;
+ WINDOW *win, *sub;
+
+ if ( !( menu->status & _POSTED ) )
+ RETURN(E_NOT_POSTED);
+
+ item = menu->curitem;
+ assert(item);
+
+ x = item->x * (1 + menu->itemlen);
+ y = item->y - menu->toprow;
+ win = menu->userwin ? menu->userwin : stdscr;
+ sub = menu->usersub ? menu->usersub : win;
+ assert(win && sub);
+
+ if ((menu->opt & O_SHOWMATCH) && (menu->pindex > 0))
+ x += ( menu->pindex + menu->marklen - 1);
+
+ wmove(sub,y,x);
+
+ if ( win != sub )
+ {
+ wcursyncup(sub);
+ wsyncup(sub);
+ untouchwin(sub);
+ }
+ }
+ RETURN(E_OK);
+}
+
+/* m_cursor.c ends here */
diff --git a/lib/libmenu/m_driver.c b/lib/libmenu/m_driver.c
new file mode 100644
index 00000000000..db0f8cd9919
--- /dev/null
+++ b/lib/libmenu/m_driver.c
@@ -0,0 +1,509 @@
+
+/***************************************************************************
+* COPYRIGHT NOTICE *
+****************************************************************************
+* ncurses is copyright (C) 1992-1995 *
+* Zeyd M. Ben-Halim *
+* zmbenhal@netcom.com *
+* Eric S. Raymond *
+* esr@snark.thyrsus.com *
+* *
+* Permission is hereby granted to reproduce and distribute ncurses *
+* by any means and for any fee, whether alone or as part of a *
+* larger distribution, in source or in binary form, PROVIDED *
+* this notice is included with any such distribution, and is not *
+* removed from any of its header files. Mention of ncurses in any *
+* applications linked with it is highly appreciated. *
+* *
+* ncurses comes AS IS with no warranty, implied or expressed. *
+* *
+***************************************************************************/
+
+/***************************************************************************
+* Module menu_driver and menu_pattern *
+* Central dispatching routine and pattern matching handling *
+***************************************************************************/
+
+#include "menu.priv.h"
+
+/* Macros */
+
+/* Remove the last character from the match pattern buffer */
+#define Remove_Character_From_Pattern(menu) \
+ (menu)->pattern[--((menu)->pindex)] = '\0'
+
+/* Add a new character to the match pattern buffer */
+#define Add_Character_To_Pattern(menu,ch) \
+ { (menu)->pattern[((menu)->pindex)++] = (ch);\
+ (menu)->pattern[(menu)->pindex] = '\0'; }
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : static bool Is_Sub_String(
+| bool IgnoreCaseFlag,
+| const char *part,
+| const char *string)
+|
+| Description : Checks whether or not part is a substring of string.
+|
+| Return Values : TRUE - if it is a substring
+| FALSE - if it is not a substring
++--------------------------------------------------------------------------*/
+static bool Is_Sub_String(
+ bool IgnoreCaseFlag,
+ const char *part,
+ const char *string
+ )
+{
+ assert( part && string );
+ if ( IgnoreCaseFlag )
+ {
+ while(*string && *part)
+ {
+ if (toupper(*string++)!=toupper(*part)) break;
+ part++;
+ }
+ }
+ else
+ {
+ while( *string && *part )
+ if (*part != *string++) break;
+ part++;
+ }
+ return ( (*part) ? FALSE : TRUE );
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : static int Match_Next_Character_In_Item_Name(
+| MENU *menu,
+| int ch,
+| ITEM **item)
+|
+| Description : This internal routine is called for a menu positioned
+| at an item with three different classes of characters:
+| - a printable character; the character is added to
+| the current pattern and the next item matching
+| this pattern is searched.
+| - NUL; the pattern stays as it is and the next item
+| matching the pattern is searched
+| - BS; the pattern stays as it is and the previous
+| item matching the pattern is searched
+|
+| The item parameter contains on call a pointer to
+| the item where the search starts. On return - if
+| a match was found - it contains a pointer to the
+| matching item.
+|
+| Return Values : E_OK - an item matching the pattern was found
+| E_NO_MATCH - nothing found
++--------------------------------------------------------------------------*/
+static int Match_Next_Character_In_Item_Name(MENU *menu, int ch, ITEM **item)
+{
+ bool found = FALSE, passed = FALSE;
+ int idx, last;
+
+ assert( menu && item && *item);
+ idx = (*item)->index;
+
+ if (ch && ch!=BS)
+ {
+ /* if we become to long, we need no further checking : there can't be
+ a match ! */
+ if ((menu->pindex+1) > menu->namelen)
+ RETURN(E_NO_MATCH);
+
+ Add_Character_To_Pattern(menu,ch);
+ /* we artificially position one item back, because in the do...while
+ loop we start with the next item. This means, that with a new
+ pattern search we always start the scan with the actual item. If
+ we do a NEXT_PATTERN oder PREV_PATTERN search, we start with the
+ one after or before the actual item. */
+ if (--idx < 0)
+ idx = menu->nitems-1;
+ }
+
+ last = idx; /* this closes the cycle */
+
+ do{
+ if (ch==BS)
+ { /* we have to go backward */
+ if (--idx < 0)
+ idx = menu->nitems-1;
+ }
+ else
+ { /* otherwise we always go forward */
+ if (++idx >= menu->nitems)
+ idx = 0;
+ }
+ if (Is_Sub_String((menu->opt & O_IGNORECASE) != 0,
+ menu->pattern,
+ menu->items[idx]->name.str)
+ )
+ found = TRUE;
+ else
+ passed = TRUE;
+ } while (!found && (idx != last));
+
+ if (found)
+ {
+ if (!((idx==(*item)->index) && passed))
+ {
+ *item = menu->items[idx];
+ RETURN(E_OK);
+ }
+ /* This point is reached, if we fully cycled through the item list
+ and the only match we found is the starting item. With a NEXT_PATTERN
+ or PREV_PATTERN scan this means, that there was no additional match.
+ If we searched with an expanded new pattern, we should never reach
+ this point, because if the expanded pattern matches also the actual
+ item we will find it in the first attempt (passed==FALSE) and we
+ will never cycle through the whole item array.
+ */
+ assert( ch==0 || ch==BS );
+ }
+ else
+ {
+ if (ch && ch!=BS && menu->pindex>0)
+ {
+ /* if we had no match with a new pattern, we have to restore it */
+ Remove_Character_From_Pattern(menu);
+ }
+ }
+ RETURN(E_NO_MATCH);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : char *menu_pattern(const MENU *menu)
+|
+| Description : Return the value of the pattern buffer.
+|
+| Return Values : NULL - if there is no pattern buffer allocated
+| EmptyString - if there is a pattern buffer but no
+| pattern is stored
+| PatternString - as expected
++--------------------------------------------------------------------------*/
+char *menu_pattern(const MENU * menu)
+{
+ return (menu ? (menu->pattern ? menu->pattern : "") : (char *)0);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : int set_menu_pattern(MENU *menu, const char *p)
+|
+| Description : Set the match pattern for a menu and position to the
+| first item that matches.
+|
+| Return Values : E_OK - success
+| E_BAD_ARGUMENT - invalid menu or pattern pointer
+| E_NOT_CONNECTED - no items connected to menu
+| E_BAD_STATE - menu in user hook routine
+| E_NO_MATCH - no item matches pattern
++--------------------------------------------------------------------------*/
+int set_menu_pattern(MENU *menu, const char *p)
+{
+ ITEM *matchitem;
+ int matchpos;
+
+ if (!menu || !p)
+ RETURN(E_BAD_ARGUMENT);
+
+ if (!(menu->items))
+ RETURN(E_NOT_CONNECTED);
+
+ if ( menu->status & _IN_DRIVER )
+ RETURN(E_BAD_STATE);
+
+ Reset_Pattern(menu);
+
+ if (!(*p))
+ {
+ pos_menu_cursor(menu);
+ RETURN(E_OK);
+ }
+
+ if (menu->status & _LINK_NEEDED)
+ _nc_Link_Items(menu);
+
+ matchpos = menu->toprow;
+ matchitem = menu->curitem;
+ assert(matchitem);
+
+ while(*p)
+ {
+ if ( !isprint(*p) ||
+ (Match_Next_Character_In_Item_Name(menu,*p,&matchitem) != E_OK) )
+ {
+ Reset_Pattern(menu);
+ pos_menu_cursor(menu);
+ RETURN(E_NO_MATCH);
+ }
+ p++;
+ }
+
+ /* This is reached if there was a match. So we position to the new item */
+ Adjust_Current_Item(menu,matchpos,matchitem);
+ RETURN(E_OK);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : int menu_driver(MENU *menu, int c)
+|
+| Description : Central dispatcher for the menu. Translates the logical
+| request 'c' into a menu action.
+|
+| Return Values : E_OK - success
+| E_BAD_ARGUMENT - invalid menu pointer
+| E_BAD_STATE - menu is in user hook routine
+| E_NOT_POSTED - menu is not posted
++--------------------------------------------------------------------------*/
+int menu_driver(MENU * menu, int c)
+{
+#define NAVIGATE(dir) \
+ if (!item->dir)\
+ result = E_REQUEST_DENIED;\
+ else\
+ item = item->dir
+
+ int result = E_OK;
+ ITEM *item;
+ int my_top_row, rdiff;
+
+ if (!menu)
+ RETURN(E_BAD_ARGUMENT);
+
+ if ( menu->status & _IN_DRIVER )
+ RETURN(E_BAD_STATE);
+ if ( !( menu->status & _POSTED ) )
+ RETURN(E_NOT_POSTED);
+
+ my_top_row = menu->toprow;
+ item = menu->curitem;
+ assert(item);
+
+ if ((c > KEY_MAX) && (c<=MAX_MENU_COMMAND))
+ {
+ if (!((c==REQ_BACK_PATTERN)
+ || (c==REQ_NEXT_MATCH) || (c==REQ_PREV_MATCH)))
+ {
+ assert( menu->pattern );
+ Reset_Pattern(menu);
+ }
+
+ switch(c)
+ {
+ case REQ_LEFT_ITEM:
+ /*=================*/
+ NAVIGATE(left);
+ break;
+
+ case REQ_RIGHT_ITEM:
+ /*==================*/
+ NAVIGATE(right);
+ break;
+
+ case REQ_UP_ITEM:
+ /*===============*/
+ NAVIGATE(up);
+ break;
+
+ case REQ_DOWN_ITEM:
+ /*=================*/
+ NAVIGATE(down);
+ break;
+
+ case REQ_SCR_ULINE:
+ /*=================*/
+ if (my_top_row == 0)
+ result = E_REQUEST_DENIED;
+ else
+ {
+ --my_top_row;
+ item = item->up;
+ }
+ break;
+
+ case REQ_SCR_DLINE:
+ /*=================*/
+ my_top_row++;
+ if ((menu->rows - menu->height)>0)
+ {
+ /* only if the menu has less items than rows, we can deny the
+ request. Otherwise the epilogue of this routine adjusts the
+ top row if necessary */
+ my_top_row--;
+ result = E_REQUEST_DENIED;
+ }
+ else
+ item = item->down;
+ break;
+
+ case REQ_SCR_DPAGE:
+ /*=================*/
+ rdiff = menu->rows - menu->height - my_top_row;
+ if (rdiff > menu->height)
+ rdiff = menu->height;
+ if (rdiff==0)
+ result = E_REQUEST_DENIED;
+ else
+ {
+ my_top_row += rdiff;
+ while(rdiff-- > 0)
+ item = item->down;
+ }
+ break;
+
+ case REQ_SCR_UPAGE:
+ /*=================*/
+ rdiff = (menu->height < my_top_row) ?
+ menu->height : my_top_row;
+ if (rdiff==0)
+ result = E_REQUEST_DENIED;
+ else
+ {
+ my_top_row -= rdiff;
+ while(rdiff--)
+ item = item->up;
+ }
+ break;
+
+ case REQ_FIRST_ITEM:
+ /*==================*/
+ item = menu->items[0];
+ break;
+
+ case REQ_LAST_ITEM:
+ /*=================*/
+ item = menu->items[menu->nitems-1];
+ break;
+
+ case REQ_NEXT_ITEM:
+ /*=================*/
+ if ((item->index+1)>=menu->nitems)
+ {
+ if (menu->opt & O_NONCYCLIC)
+ result = E_REQUEST_DENIED;
+ else
+ item = menu->items[0];
+ }
+ else
+ item = menu->items[item->index + 1];
+ break;
+
+ case REQ_PREV_ITEM:
+ /*=================*/
+ if (item->index<=0)
+ {
+ if (menu->opt & O_NONCYCLIC)
+ result = E_REQUEST_DENIED;
+ else
+ item = menu->items[menu->nitems-1];
+ }
+ else
+ item = menu->items[item->index - 1];
+ break;
+
+ case REQ_TOGGLE_ITEM:
+ /*===================*/
+ if (menu->opt & O_ONEVALUE)
+ {
+ result = E_REQUEST_DENIED;
+ }
+ else
+ {
+ if (menu->curitem->opt & O_SELECTABLE)
+ {
+ menu->curitem->value = TRUE;
+ Move_And_Post_Item(menu,menu->curitem);
+ _nc_Show_Menu(menu);
+ }
+ else
+ result = E_NOT_SELECTABLE;
+ }
+ break;
+
+ case REQ_CLEAR_PATTERN:
+ /*=====================*/
+ /* already cleared in prologue */
+ break;
+
+ case REQ_BACK_PATTERN:
+ /*====================*/
+ if (menu->pindex>0)
+ {
+ assert(menu->pattern);
+ Remove_Character_From_Pattern(menu);
+ pos_menu_cursor( menu );
+ }
+ else
+ result = E_REQUEST_DENIED;
+ break;
+
+ case REQ_NEXT_MATCH:
+ /*==================*/
+ assert(menu->pattern);
+ if (menu->pattern[0])
+ result = Match_Next_Character_In_Item_Name(menu,0,&item);
+ else
+ {
+ if ((item->index+1)<menu->nitems)
+ item=menu->items[item->index+1];
+ else
+ {
+ if (menu->opt & O_NONCYCLIC)
+ result = E_REQUEST_DENIED;
+ else
+ item = menu->items[0];
+ }
+ }
+ break;
+
+ case REQ_PREV_MATCH:
+ /*==================*/
+ assert(menu->pattern);
+ if (menu->pattern[0])
+ result = Match_Next_Character_In_Item_Name(menu,BS,&item);
+ else
+ {
+ if (item->index)
+ item = menu->items[item->index-1];
+ else
+ {
+ if (menu->opt & O_NONCYCLIC)
+ result = E_REQUEST_DENIED;
+ else
+ item = menu->items[menu->nitems-1];
+ }
+ }
+ break;
+
+ default:
+ /*======*/
+ result = E_UNKNOWN_COMMAND;
+ break;
+ }
+ }
+ else
+ { /* not a command */
+ if ( !(c & ~((int)MAX_REGULAR_CHARACTER)) && isprint(c) )
+ result = Match_Next_Character_In_Item_Name( menu, c, &item );
+ else
+ result = E_UNKNOWN_COMMAND;
+ }
+
+ /* Adjust the top row if it turns out that the current item unfortunately
+ doesn't appear in the menu window */
+ if ( item->y < my_top_row )
+ my_top_row = item->y;
+ else if ( item->y >= (my_top_row + menu->height) )
+ my_top_row = item->y - menu->height + 1;
+
+ _nc_New_TopRow_and_CurrentItem( menu, my_top_row, item );
+
+ RETURN(result);
+}
+
+/* m_driver.c ends here */
diff --git a/lib/libmenu/m_format.c b/lib/libmenu/m_format.c
new file mode 100644
index 00000000000..10564106134
--- /dev/null
+++ b/lib/libmenu/m_format.c
@@ -0,0 +1,112 @@
+
+/***************************************************************************
+* COPYRIGHT NOTICE *
+****************************************************************************
+* ncurses is copyright (C) 1992-1995 *
+* Zeyd M. Ben-Halim *
+* zmbenhal@netcom.com *
+* Eric S. Raymond *
+* esr@snark.thyrsus.com *
+* *
+* Permission is hereby granted to reproduce and distribute ncurses *
+* by any means and for any fee, whether alone or as part of a *
+* larger distribution, in source or in binary form, PROVIDED *
+* this notice is included with any such distribution, and is not *
+* removed from any of its header files. Mention of ncurses in any *
+* applications linked with it is highly appreciated. *
+* *
+* ncurses comes AS IS with no warranty, implied or expressed. *
+* *
+***************************************************************************/
+
+/***************************************************************************
+* Module menu_format *
+* Set and get maximum numbers of rows and columns in menus *
+***************************************************************************/
+
+#include "menu.priv.h"
+
+#define minimum(a,b) ((a)<(b) ? (a): (b))
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : int set_menu_format(MENU *menu, int rows, int cols)
+|
+| Description : Sets the maximum number of rows and columns of items
+| that may be displayed at one time on a menu. If the
+| menu contains more items than can be displayed at
+| once, the menu will be scrollable.
+|
+| Return Values : E_OK - success
+| E_BAD_ARGUMENT - invalid values passed
+| E_NOT_CONNECTED - there are no items connected
+| E_POSTED - the menu is already posted
++--------------------------------------------------------------------------*/
+int set_menu_format(MENU *menu, int rows, int cols)
+{
+ int total_rows, total_cols;
+
+ if (rows<0 || cols<0)
+ RETURN(E_BAD_ARGUMENT);
+
+ if (menu)
+ {
+ if ( menu->status & _POSTED )
+ RETURN(E_POSTED);
+
+ if (!(menu->items))
+ RETURN(E_NOT_CONNECTED);
+
+ if (rows==0)
+ rows = menu->frows;
+ if (cols==0)
+ cols = menu->fcols;
+
+ if (menu->pattern)
+ Reset_Pattern(menu);
+
+ menu->frows = rows;
+ menu->fcols = cols;
+
+ assert(rows>0 && cols>0);
+ total_rows = (menu->nitems - 1)/cols + 1;
+ total_cols = (menu->status & O_ROWMAJOR) ?
+ minimum(menu->nitems,cols) :
+ (menu->nitems-1)/total_rows + 1;
+
+ menu->rows = total_rows;
+ menu->cols = total_cols;
+ menu->height = minimum(total_rows,rows);
+ menu->toprow = 0;
+ menu->curitem = *(menu->items);
+ assert(menu->curitem);
+ menu->status |= _LINK_NEEDED;
+ _nc_Calculate_Item_Length_and_Width(menu);
+ }
+ else
+ {
+ if (rows>0) _nc_Default_Menu.frows = rows;
+ if (cols>0) _nc_Default_Menu.fcols = cols;
+ }
+
+ RETURN(E_OK);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : void menu_format(const MENU *menu, int *rows, int *cols)
+|
+| Description : Returns the maximum number of rows and columns that may
+| be displayed at one time on menu.
+|
+| Return Values : -
++--------------------------------------------------------------------------*/
+void menu_format(const MENU *menu, int *rows, int *cols)
+{
+ if (rows)
+ *rows = Normalize_Menu(menu)->frows;
+ if (cols)
+ *cols = Normalize_Menu(menu)->fcols;
+}
+
+/* m_format.c ends here */
diff --git a/lib/libmenu/m_global.c b/lib/libmenu/m_global.c
new file mode 100644
index 00000000000..050100dc00b
--- /dev/null
+++ b/lib/libmenu/m_global.c
@@ -0,0 +1,466 @@
+
+/***************************************************************************
+* COPYRIGHT NOTICE *
+****************************************************************************
+* ncurses is copyright (C) 1992-1995 *
+* Zeyd M. Ben-Halim *
+* zmbenhal@netcom.com *
+* Eric S. Raymond *
+* esr@snark.thyrsus.com *
+* *
+* Permission is hereby granted to reproduce and distribute ncurses *
+* by any means and for any fee, whether alone or as part of a *
+* larger distribution, in source or in binary form, PROVIDED *
+* this notice is included with any such distribution, and is not *
+* removed from any of its header files. Mention of ncurses in any *
+* applications linked with it is highly appreciated. *
+* *
+* ncurses comes AS IS with no warranty, implied or expressed. *
+* *
+***************************************************************************/
+
+/***************************************************************************
+* Module menu_global *
+* Globally used internal routines and the default menu and item structures *
+***************************************************************************/
+
+#include "menu.priv.h"
+
+MENU _nc_Default_Menu = {
+ 16, /* Nr. of chars high */
+ 1, /* Nr. of chars wide */
+ 16, /* Nr. of items high */
+ 1, /* Nr. of items wide */
+ 16, /* Nr. of formatted items high */
+ 1, /* Nr. of formatted items wide */
+ 0, /* length of widest name */
+ 0, /* length of widest description */
+ 1, /* length of mark */
+ 1, /* length of one item */
+ (char *)0, /* buffer used to store match chars */
+ 0, /* Index into pattern buffer */
+ (WINDOW *)0, /* Window containing entire menu */
+ (WINDOW *)0, /* Portion of menu displayed */
+ (WINDOW *)0, /* User's window */
+ (WINDOW *)0, /* User's subwindow */
+ (ITEM **)0, /* List of items */
+ 0, /* Total Nr. of items in menu */
+ (ITEM *)0, /* Current item */
+ 0, /* Top row of menu */
+ (chtype)A_REVERSE, /* Attribute for selection */
+ (chtype)A_NORMAL, /* Attribute for nonselection */
+ (chtype)A_UNDERLINE, /* Attribute for inactive */
+ ' ', /* Pad character */
+ (Menu_Hook)0, /* Menu init */
+ (Menu_Hook)0, /* Menu term */
+ (Menu_Hook)0, /* Item init */
+ (Menu_Hook)0, /* Item term */
+ (void *)0, /* userptr */
+ "-", /* mark */
+ ALL_MENU_OPTS, /* options */
+ 0 /* status */
+};
+
+ITEM _nc_Default_Item = {
+ { (char *)0, 0 }, /* name */
+ { (char *)0, 0 }, /* description */
+ (MENU *)0, /* Pointer to parent menu */
+ (char *)0, /* Userpointer */
+ ALL_ITEM_OPTS, /* options */
+ 0, /* Item Nr. */
+ 0, /* y */
+ 0, /* x */
+ FALSE, /* value */
+ (ITEM *)0, /* left */
+ (ITEM *)0, /* right */
+ (ITEM *)0, /* up */
+ (ITEM *)0 /* down */
+ };
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : static void ComputeMaximum_NameDesc_Lenths(MENU *menu)
+|
+| Description : Calculates the maximum name and description lengths
+| of the items connected to the menu
+|
+| Return Values : -
++--------------------------------------------------------------------------*/
+INLINE static void ComputeMaximum_NameDesc_Lengths(MENU * menu)
+{
+ unsigned MaximumNameLength = 0;
+ unsigned MaximumDescriptionLength = 0;
+ ITEM **items;
+
+ assert(menu && menu->items);
+ for( items = menu->items; *items ; items++ )
+ {
+ if (items[0]->name.length > MaximumNameLength )
+ MaximumNameLength = items[0]->name.length;
+
+ if (items[0]->description.length > MaximumDescriptionLength)
+ MaximumDescriptionLength = items[0]->description.length;
+ }
+
+ menu->namelen = MaximumNameLength;
+ menu->desclen = MaximumDescriptionLength;
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : static void ResetConnectionInfo(MENU *, ITEM **)
+|
+| Description : Reset all informations in the menu and the items in
+| the item array that indicates a connection
+|
+| Return Values : -
++--------------------------------------------------------------------------*/
+INLINE static void ResetConnectionInfo(MENU *menu, ITEM **items)
+{
+ ITEM **item;
+
+ assert(menu && items);
+ for(item=items; *item; item++)
+ {
+ (*item)->index = 0;
+ (*item)->imenu = (MENU *)0;
+ }
+ if (menu->pattern)
+ free(menu->pattern);
+ menu->pattern = (char *)0;
+ menu->pindex = 0;
+ menu->items = (ITEM **)0;
+ menu->nitems = 0;
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : bool _nc_Connect_Items(MENU *menu, ITEM **items)
+|
+| Description : Connect the items in the item array to the menu.
+| Decorate all the items with a number and a backward
+| pointer to the menu.
+|
+| Return Values : TRUE - successfull connection
+| FALSE - connection failed
++--------------------------------------------------------------------------*/
+bool _nc_Connect_Items(MENU *menu, ITEM **items)
+{
+ ITEM **item;
+ unsigned int ItemCount = 0;
+
+ if ( menu && items )
+ {
+ for(item=items; *item ; item++)
+ {
+ if ( (*item)->imenu )
+ {
+ /* if a item is already connected, reject connection */
+ break;
+ }
+ }
+ if (! (*item) )
+ /* we reached the end, so there was no connected item */
+ {
+ for(item=items; *item ; item++)
+ {
+ if (menu->opt & O_ONEVALUE)
+ {
+ (*item)->value = FALSE;
+ }
+ (*item)->index = ItemCount++;
+ (*item)->imenu = menu;
+ }
+ }
+ }
+ else
+ return(FALSE);
+
+ if (ItemCount > 0)
+ {
+ menu->items = items;
+ menu->nitems = ItemCount;
+ ComputeMaximum_NameDesc_Lengths(menu);
+ if ( (menu->pattern = (char *)malloc( (unsigned)(1 + menu->namelen))) )
+ {
+ Reset_Pattern(menu);
+ set_menu_format(menu,menu->frows,menu->fcols);
+ menu->curitem = *items;
+ menu->toprow = 0;
+ return(TRUE);
+ }
+ }
+
+ /* If we fall through to this point, we have to reset all items connection
+ and inform about a reject connection */
+ ResetConnectionInfo( menu, items );
+ return(FALSE);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : void _nc_Disconnect_Items(MENU *menu)
+|
+| Description : Disconnect the menus item array from the menu
+|
+| Return Values : -
++--------------------------------------------------------------------------*/
+void _nc_Disconnect_Items(MENU * menu)
+{
+ if (menu && menu->items)
+ ResetConnectionInfo( menu, menu->items );
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : void _nc_Calculate_Item_Length_and_Width(MENU *menu)
+|
+| Description : Calculate the length of an item and the width of the
+| whole menu.
+|
+| Return Values : -
++--------------------------------------------------------------------------*/
+void _nc_Calculate_Item_Length_and_Width(MENU * menu)
+{
+ int l;
+
+ assert(menu);
+ if (menu->items && *(menu->items))
+ {
+ l = menu->namelen + menu->marklen;
+ if ( (menu->opt & O_SHOWDESC) && (menu->desclen > 0) )
+ l += (menu->desclen + 1);
+
+ menu->itemlen = l;
+ l *= menu->cols;
+ l += (menu->cols-1); /* for the padding between the columns */
+ menu->width = l;
+ }
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : void _nc_Link_Item(MENU *menu)
+|
+| Description : Statically calculate for every item its four neighbours.
+| This depends on the orientation of the menu. This
+| static aproach simplifies navigation in the menu a lot.
+|
+| Return Values : -
++--------------------------------------------------------------------------*/
+void _nc_Link_Items(MENU * menu)
+{
+ if (menu && menu->items && *(menu->items))
+ {
+ int i,j;
+ ITEM *item;
+ int Number_Of_Items = menu->nitems;
+ int col = 0, row = 0;
+ int Last_in_Row;
+ int Last_in_Column;
+ bool cycle = (menu->opt & O_NONCYCLIC) ? FALSE : TRUE;
+
+ menu->status &= ~_LINK_NEEDED;
+
+ if (menu->opt & O_ROWMAJOR)
+ {
+ int Number_Of_Columns = menu->cols;
+
+ for(i=0; i < Number_Of_Items; i++)
+ {
+ item = menu->items[i];
+
+ Last_in_Row = row * Number_Of_Columns + (Number_Of_Columns-1);
+
+ item->left = (col) ?
+ /* if we are not in the leftmost column, we can use the
+ predecessor in the items array */
+ menu->items[i-1] :
+ (cycle ? menu->items[(Last_in_Row>=Number_Of_Items) ?
+ Number_Of_Items-1:
+ Last_in_Row] :
+ (ITEM *)0 );
+
+ item->right = ( (col < (Number_Of_Columns-1)) &&
+ ((i+1) < Number_Of_Items)
+ ) ?
+ menu->items[i+1] :
+ ( cycle ? menu->items[row * Number_Of_Columns] :
+ (ITEM *)0
+ );
+
+ Last_in_Column = (menu->rows-1) * Number_Of_Columns + col;
+
+ item->up = (row) ? menu->items[i-Number_Of_Columns] :
+ (cycle ? menu->items[(Last_in_Column>=Number_Of_Items) ?
+ Number_Of_Items-1 :
+ Last_in_Column] :
+ (ITEM *)0);
+
+ item->down = ( (i+Number_Of_Columns) < Number_Of_Items )
+ ?
+ menu->items[i + Number_Of_Columns] :
+ (cycle ? menu->items[(row+1)<menu->rows ?
+ Number_Of_Items-1:col] :
+ (ITEM *)0);
+ item->x = col;
+ item->y = row;
+ if ( ++col == Number_Of_Columns )
+ {
+ row++;
+ col = 0;
+ }
+ }
+ }
+ else
+ {
+ int Number_Of_Rows = menu->rows;
+
+ for(j=0; j<Number_Of_Items; j++)
+ {
+ item = menu->items[i=(col * Number_Of_Rows + row)];
+
+ Last_in_Column = (menu->cols-1) * Number_Of_Rows + row;
+
+ item->left = (col) ?
+ menu->items[i - Number_Of_Rows] :
+ (cycle ? (Last_in_Column >= Number_Of_Items ) ?
+ menu->items[Last_in_Column-Number_Of_Rows] :
+ menu->items[Last_in_Column] :
+ (ITEM *)0 );
+
+ item->right = ((i + Number_Of_Rows) <Number_Of_Items)
+ ?
+ menu->items[i + Number_Of_Rows] :
+ (cycle ? menu->items[row] : (ITEM *)0);
+
+ Last_in_Row = col * Number_Of_Rows + (Number_Of_Rows - 1);
+
+ item->up = (row) ?
+ menu->items[i-1] :
+ (cycle ?
+ menu->items[(Last_in_Row>=Number_Of_Items) ?
+ Number_Of_Items-1:
+ Last_in_Row] :
+ (ITEM *)0);
+
+ item->down = (row < (Number_Of_Rows-1))
+ ?
+ (menu->items[((i+1)<Number_Of_Items) ?
+ i+1 :
+ (col-1)*Number_Of_Rows + row + 1]) :
+ (cycle ?
+ menu->items[col * Number_Of_Rows] :
+ (ITEM *)0
+ );
+
+ item->x = col;
+ item->y = row;
+ if ( (++row) == Number_Of_Rows )
+ {
+ col++;
+ row = 0;
+ }
+ }
+ }
+ }
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : void _nc_Show_Menu(const MENU *menu)
+|
+| Description : Update the window that is associated with the menu
+|
+| Return Values : -
++--------------------------------------------------------------------------*/
+void _nc_Show_Menu(const MENU *menu)
+{
+ WINDOW *win;
+ int maxy, maxx;
+
+ assert(menu);
+ if ( (menu->status & _POSTED) && !(menu->status & _IN_DRIVER) )
+ {
+ /* adjust the internal subwindow to start on the current top */
+ assert(menu->sub);
+ mvderwin(menu->sub,menu->toprow,0);
+ win = Get_Menu_Window(menu);
+
+ maxy = getmaxy(win);
+ maxx = getmaxx(win);
+
+ if (menu->height < maxy)
+ maxy = menu->height;
+ if (menu->width < maxx)
+ maxx = menu->width;
+
+ copywin(menu->sub,win,0,0,0,0,maxy-1,maxx-1,0);
+ pos_menu_cursor(menu);
+ }
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : void _nc_New_TopRow_and_CurrentItem(
+| MENU *menu,
+| int new_toprow,
+| ITEM *new_current_item)
+|
+| Description : Redisplay the menu so that the given row becomes the
+| top row and the given item becomes the new current
+| item.
+|
+| Return Values : -
++--------------------------------------------------------------------------*/
+void _nc_New_TopRow_and_CurrentItem(MENU *menu, int new_toprow,
+ ITEM *new_current_item)
+{
+ ITEM *cur_item;
+ bool mterm_called = FALSE;
+ bool iterm_called = FALSE;
+
+ assert(menu);
+ if (menu->status & _POSTED)
+ {
+ if (new_current_item != menu->curitem)
+ {
+ Call_Hook(menu,itemterm);
+ iterm_called = TRUE;
+ }
+ if (new_toprow != menu->toprow)
+ {
+ Call_Hook(menu,menuterm);
+ mterm_called = TRUE;
+ }
+
+ cur_item = menu->curitem;
+ assert(cur_item);
+ menu->toprow = new_toprow;
+ menu->curitem = new_current_item;
+
+ if (mterm_called)
+ {
+ Call_Hook(menu,menuinit);
+ }
+ if (iterm_called)
+ {
+ /* this means, move from the old current_item to the new one... */
+ Move_To_Current_Item( menu, cur_item );
+ Call_Hook(menu,iteminit);
+ }
+ if (mterm_called || iterm_called)
+ {
+ _nc_Show_Menu(menu);
+ }
+ else
+ pos_menu_cursor(menu);
+ }
+ else
+ { /* if we are not posted, this is quite simple */
+ menu->toprow = new_toprow;
+ menu->curitem = new_current_item;
+ }
+}
+
+/* m_global.c ends here */
diff --git a/lib/libmenu/m_hook.c b/lib/libmenu/m_hook.c
new file mode 100644
index 00000000000..891005abf31
--- /dev/null
+++ b/lib/libmenu/m_hook.c
@@ -0,0 +1,136 @@
+
+/***************************************************************************
+* COPYRIGHT NOTICE *
+****************************************************************************
+* ncurses is copyright (C) 1992-1995 *
+* Zeyd M. Ben-Halim *
+* zmbenhal@netcom.com *
+* Eric S. Raymond *
+* esr@snark.thyrsus.com *
+* *
+* Permission is hereby granted to reproduce and distribute ncurses *
+* by any means and for any fee, whether alone or as part of a *
+* larger distribution, in source or in binary form, PROVIDED *
+* this notice is included with any such distribution, and is not *
+* removed from any of its header files. Mention of ncurses in any *
+* applications linked with it is highly appreciated. *
+* *
+* ncurses comes AS IS with no warranty, implied or expressed. *
+* *
+***************************************************************************/
+
+/***************************************************************************
+* Module menu_hook *
+* Assign application specific routines for automatic invocation by menus *
+***************************************************************************/
+
+#include "menu.priv.h"
+
+/* "Template" macro to generate function to set application specific hook */
+#define GEN_HOOK_SET_FUNCTION( typ, name ) \
+int set_ ## typ ## _ ## name (MENU *menu, Menu_Hook func )\
+{\
+ (Normalize_Menu(menu) -> typ ## name = func );\
+ RETURN(E_OK);\
+}
+
+/* "Template" macro to generate function to get application specific hook */
+#define GEN_HOOK_GET_FUNCTION( typ, name ) \
+Menu_Hook typ ## _ ## name ( const MENU *menu )\
+{\
+ return (Normalize_Menu(menu) -> typ ## name);\
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : int set_menu_init(MENU *menu, void (*f)(MENU *))
+|
+| Description : Set user-exit which is called when menu is posted
+| or just after the top row changes.
+|
+| Return Values : E_OK - success
++--------------------------------------------------------------------------*/
+GEN_HOOK_SET_FUNCTION( menu, init )
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : void (*)(MENU *) menu_init(const MENU *menu)
+|
+| Description : Return address of user-exit function which is called
+| when a menu is posted or just after the top row
+| changes.
+|
+| Return Values : Menu init function address or NULL
++--------------------------------------------------------------------------*/
+GEN_HOOK_GET_FUNCTION( menu, init )
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : int set_menu_term (MENU *menu, void (*f)(MENU *))
+|
+| Description : Set user-exit which is called when menu is unposted
+| or just before the top row changes.
+|
+| Return Values : E_OK - success
++--------------------------------------------------------------------------*/
+GEN_HOOK_SET_FUNCTION( menu, term )
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : void (*)(MENU *) menu_term(const MENU *menu)
+|
+| Description : Return address of user-exit function which is called
+| when a menu is unposted or just before the top row
+| changes.
+|
+| Return Values : Menu finalization function address or NULL
++--------------------------------------------------------------------------*/
+GEN_HOOK_GET_FUNCTION( menu, term )
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : int set_item_init (MENU *menu, void (*f)(MENU *))
+|
+| Description : Set user-exit which is called when menu is posted
+| or just after the current item changes.
+|
+| Return Values : E_OK - success
++--------------------------------------------------------------------------*/
+GEN_HOOK_SET_FUNCTION( item, init )
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : void (*)(MENU *) item_init (const MENU *menu)
+|
+| Description : Return address of user-exit function which is called
+| when a menu is posted or just after the current item
+| changes.
+|
+| Return Values : Item init function address or NULL
++--------------------------------------------------------------------------*/
+GEN_HOOK_GET_FUNCTION( item, init )
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : int set_item_term (MENU *menu, void (*f)(MENU *))
+|
+| Description : Set user-exit which is called when menu is unposted
+| or just before the current item changes.
+|
+| Return Values : E_OK - success
++--------------------------------------------------------------------------*/
+GEN_HOOK_SET_FUNCTION( item, term )
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : void (*)(MENU *) item_init (const MENU *menu)
+|
+| Description : Return address of user-exit function which is called
+| when a menu is unposted or just before the current item
+| changes.
+|
+| Return Values : Item finalization function address or NULL
++--------------------------------------------------------------------------*/
+GEN_HOOK_GET_FUNCTION( item, term )
+
+/* m_hook.c ends here */
diff --git a/lib/libmenu/m_item_cur.c b/lib/libmenu/m_item_cur.c
new file mode 100644
index 00000000000..b9b43acd7e2
--- /dev/null
+++ b/lib/libmenu/m_item_cur.c
@@ -0,0 +1,153 @@
+
+/***************************************************************************
+* COPYRIGHT NOTICE *
+****************************************************************************
+* ncurses is copyright (C) 1992-1995 *
+* Zeyd M. Ben-Halim *
+* zmbenhal@netcom.com *
+* Eric S. Raymond *
+* esr@snark.thyrsus.com *
+* *
+* Permission is hereby granted to reproduce and distribute ncurses *
+* by any means and for any fee, whether alone or as part of a *
+* larger distribution, in source or in binary form, PROVIDED *
+* this notice is included with any such distribution, and is not *
+* removed from any of its header files. Mention of ncurses in any *
+* applications linked with it is highly appreciated. *
+* *
+* ncurses comes AS IS with no warranty, implied or expressed. *
+* *
+***************************************************************************/
+
+/***************************************************************************
+* Module menu_item_cur *
+* Set and get current menus item *
+***************************************************************************/
+
+#include "menu.priv.h"
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : int set_current_item(MENU *menu, const ITEM *item)
+|
+| Description : Make the item the current item
+|
+| Return Values : E_OK - success
++--------------------------------------------------------------------------*/
+int set_current_item(MENU * menu, ITEM * item)
+{
+ if (menu && item && (item->imenu==menu))
+ {
+ if ( menu->status & _IN_DRIVER )
+ RETURN(E_BAD_STATE);
+
+ assert( menu->curitem );
+ if (item != menu->curitem)
+ {
+ if (menu->status & _LINK_NEEDED)
+ {
+ /*
+ * Items are available, but they are not linked together.
+ * So we have to link here.
+ */
+ _nc_Link_Items(menu);
+ }
+ assert(menu->pattern);
+ Reset_Pattern(menu);
+ /* adjust the window to make item visible and update the menu */
+ Adjust_Current_Item(menu,menu->toprow,item);
+ }
+ }
+ else
+ RETURN(E_BAD_ARGUMENT);
+
+ RETURN(E_OK);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : ITEM *current_item(const MENU *menu)
+|
+| Description : Return the menus current item
+|
+| Return Values : Item pointer or NULL if failure
++--------------------------------------------------------------------------*/
+ITEM *current_item(const MENU * menu)
+{
+ return (menu && menu->items) ? menu->curitem : (ITEM *)0;
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : int item_index(const ITEM *)
+|
+| Description : Return the logical index of this item.
+|
+| Return Values : The index or -1 if this is an invalid item pointer
++--------------------------------------------------------------------------*/
+int item_index(const ITEM *item)
+{
+ return (item && item->imenu) ? item->index : -1;
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : int set_top_row(MENU *menu, int row)
+|
+| Description : Makes the speified row the top row in the menu
+|
+| Return Values : E_OK - success
+| E_BAD_ARGUMENT - not a menu pointer or invalid row
+| E_NOT_CONNECTED - there are no items for the menu
++--------------------------------------------------------------------------*/
+int set_top_row(MENU * menu, int row)
+{
+ ITEM *item;
+
+ if (menu)
+ {
+ if ( menu->status & _IN_DRIVER )
+ RETURN(E_BAD_STATE);
+ if (menu->items == (ITEM **)0)
+ RETURN(E_NOT_CONNECTED);
+
+ if ((row<0) || (row>=(menu->rows - menu->height)))
+ RETURN(E_BAD_ARGUMENT);
+ }
+ else
+ RETURN(E_BAD_ARGUMENT);
+
+ if (row != menu->toprow)
+ {
+ if (menu->status & _LINK_NEEDED)
+ _nc_Link_Items(menu);
+
+ item = menu->items[ (menu->opt&O_ROWMAJOR) ? (row*menu->cols) : row ];
+ assert(menu->pattern);
+ Reset_Pattern(menu);
+ _nc_New_TopRow_and_CurrentItem(menu, row, item);
+ }
+
+ RETURN(E_OK);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : int top_row(const MENU *)
+|
+| Description : Return the top row of the menu
+|
+| Return Values : The row number or -1 if there is no row
++--------------------------------------------------------------------------*/
+int top_row(const MENU * menu)
+{
+ if (menu && menu->items && *(menu->items))
+ {
+ assert( (menu->toprow>=0) && (menu->toprow < menu->rows) );
+ return menu->toprow;
+ }
+ else
+ return(-1);
+}
+
+/* m_item_cur.c ends here */
diff --git a/lib/libmenu/m_item_nam.c b/lib/libmenu/m_item_nam.c
new file mode 100644
index 00000000000..3eac4ee0343
--- /dev/null
+++ b/lib/libmenu/m_item_nam.c
@@ -0,0 +1,55 @@
+
+/***************************************************************************
+* COPYRIGHT NOTICE *
+****************************************************************************
+* ncurses is copyright (C) 1992-1995 *
+* Zeyd M. Ben-Halim *
+* zmbenhal@netcom.com *
+* Eric S. Raymond *
+* esr@snark.thyrsus.com *
+* *
+* Permission is hereby granted to reproduce and distribute ncurses *
+* by any means and for any fee, whether alone or as part of a *
+* larger distribution, in source or in binary form, PROVIDED *
+* this notice is included with any such distribution, and is not *
+* removed from any of its header files. Mention of ncurses in any *
+* applications linked with it is highly appreciated. *
+* *
+* ncurses comes AS IS with no warranty, implied or expressed. *
+* *
+***************************************************************************/
+
+/***************************************************************************
+* Module menu_item_nam *
+* Get menus item name and description *
+***************************************************************************/
+
+#include "menu.priv.h"
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : char *item_name(const ITEM *item)
+|
+| Description : Return name of menu item
+|
+| Return Values : See above; returns NULL if item is invalid
++--------------------------------------------------------------------------*/
+char *item_name(const ITEM * item)
+{
+ return ((item) ? item->name.str : (char *)0);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : char *item_description(const ITEM *item)
+|
+| Description : Returns description of item
+|
+| Return Values : See above; Returns NULL if item is invalid
++--------------------------------------------------------------------------*/
+char *item_description(const ITEM * item)
+{
+ return ((item) ? item->description.str : (char *)0);
+}
+
+/* m_item_nam.c ends here */
diff --git a/lib/libmenu/m_item_new.c b/lib/libmenu/m_item_new.c
new file mode 100644
index 00000000000..8ef123f580c
--- /dev/null
+++ b/lib/libmenu/m_item_new.c
@@ -0,0 +1,188 @@
+
+/***************************************************************************
+* COPYRIGHT NOTICE *
+****************************************************************************
+* ncurses is copyright (C) 1992-1995 *
+* Zeyd M. Ben-Halim *
+* zmbenhal@netcom.com *
+* Eric S. Raymond *
+* esr@snark.thyrsus.com *
+* *
+* Permission is hereby granted to reproduce and distribute ncurses *
+* by any means and for any fee, whether alone or as part of a *
+* larger distribution, in source or in binary form, PROVIDED *
+* this notice is included with any such distribution, and is not *
+* removed from any of its header files. Mention of ncurses in any *
+* applications linked with it is highly appreciated. *
+* *
+* ncurses comes AS IS with no warranty, implied or expressed. *
+* *
+***************************************************************************/
+
+/***************************************************************************
+* Module menu_item_new *
+* Create and destroy menu items *
+* Set and get marker string for menu
+***************************************************************************/
+
+#include "menu.priv.h"
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : bool Is_Printable_String(const char *s)
+|
+| Description : Checks whether or not the string contains only printable
+| characters.
+|
+| Return Values : TRUE - if string is printable
+| FALSE - if string contains non-printable characters
++--------------------------------------------------------------------------*/
+static bool Is_Printable_String(const char *s)
+{
+ assert(s);
+ while(*s)
+ {
+ if (!isprint((unsigned char)*s))
+ return FALSE;
+ s++;
+ }
+ return TRUE;
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : ITEM *new_item(char *name, char *description)
+|
+| Description : Create a new item with name and description. Return
+| a pointer to this new item.
+| N.B.: an item must(!) have a name.
+|
+| Return Values : The item pointer or NULL if creation failed.
++--------------------------------------------------------------------------*/
+ITEM *new_item(char *name, char *description)
+{
+ ITEM *item;
+
+ if ( !name || (*name == '\0') || !Is_Printable_String(name) )
+ {
+ item = (ITEM *)0;
+ SET_ERROR( E_BAD_ARGUMENT );
+ }
+ else
+ {
+ item = (ITEM *)calloc(1,sizeof(ITEM));
+ if (item)
+ {
+ *item = _nc_Default_Item; /* hope we have struct assignment */
+
+ item->name.str = name;
+ item->name.length = strlen(name);
+
+ item->description.str = description;
+ if (description && Is_Printable_String(description))
+ item->description.length = strlen(description);
+ else
+ {
+ item->description.length = 0;
+ item->description.str = (char *)0;
+ }
+ }
+ else
+ SET_ERROR( E_SYSTEM_ERROR );
+ }
+ return(item);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : int free_item(ITEM *item)
+|
+| Description : Free the allocated storage for this item.
+| N.B.: a connected item can't be freed.
+|
+| Return Values : E_OK - success
+| E_BAD_ARGUMENT - invalid value has been passed
+| E_CONNECTED - item is still connected to a menu
++--------------------------------------------------------------------------*/
+int free_item(ITEM * item)
+{
+ if (!item)
+ RETURN( E_BAD_ARGUMENT );
+
+ if (item->imenu)
+ RETURN( E_CONNECTED );
+
+ free(item);
+ RETURN( E_OK );
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : int set_menu_mark( MENU *menu, char *mark )
+|
+| Description : Set the mark string used to indicate the current
+| item (single-valued menu) or the selected items
+| (multi-valued menu).
+| The mark argument may be NULL, in which case no
+| marker is used.
+| This might be a little bit tricky, because this may
+| affect the geometry of the menu, which we don't allow
+| if it is already posted.
+|
+| Return Values : E_OK - success
+| E_BAD_ARGUMENT - an invalid value has been passed
++--------------------------------------------------------------------------*/
+int set_menu_mark(MENU * menu, char * mark)
+{
+ int l;
+
+ if ( mark && *mark && Is_Printable_String(mark) )
+ l = strlen(mark);
+ else
+ l = 0;
+
+ if ( menu )
+ {
+ if (menu->status & _POSTED)
+ {
+ /* If the menu is already posted, the geometry is fixed. Then
+ we can only accept a mark with exactly the same length */
+ if (menu->marklen != l)
+ RETURN(E_BAD_ARGUMENT);
+ }
+ menu->mark = l ? mark : (char *)0;
+ menu->marklen = l;
+
+ if (menu->status & _POSTED)
+ {
+ _nc_Draw_Menu( menu );
+ _nc_Show_Menu( menu );
+ }
+ else
+ {
+ /* Recalculate the geometry */
+ _nc_Calculate_Item_Length_and_Width( menu );
+ }
+ }
+ else
+ {
+ _nc_Default_Menu.mark = l ? mark : (char *)0;
+ _nc_Default_Menu.marklen = l;
+ }
+ RETURN(E_OK);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : char *menu_mark(const MENU *menu)
+|
+| Description : Return a pointer to the marker string
+|
+| Return Values : The marker string pointer or NULL if no marker defined
++--------------------------------------------------------------------------*/
+char *menu_mark(const MENU * menu)
+{
+ return Normalize_Menu( menu )->mark;
+}
+
+/* m_item_new.c */
diff --git a/lib/libmenu/m_item_opt.c b/lib/libmenu/m_item_opt.c
new file mode 100644
index 00000000000..00dd3a78d3e
--- /dev/null
+++ b/lib/libmenu/m_item_opt.c
@@ -0,0 +1,130 @@
+
+/***************************************************************************
+* COPYRIGHT NOTICE *
+****************************************************************************
+* ncurses is copyright (C) 1992-1995 *
+* Zeyd M. Ben-Halim *
+* zmbenhal@netcom.com *
+* Eric S. Raymond *
+* esr@snark.thyrsus.com *
+* *
+* Permission is hereby granted to reproduce and distribute ncurses *
+* by any means and for any fee, whether alone or as part of a *
+* larger distribution, in source or in binary form, PROVIDED *
+* this notice is included with any such distribution, and is not *
+* removed from any of its header files. Mention of ncurses in any *
+* applications linked with it is highly appreciated. *
+* *
+* ncurses comes AS IS with no warranty, implied or expressed. *
+* *
+***************************************************************************/
+
+/***************************************************************************
+* Module menu_item_opt *
+* Menus item option routines *
+***************************************************************************/
+
+#include "menu.priv.h"
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : int set_item_opts(ITEM *item, Item_Options opts)
+|
+| Description : Set the options of the item. If there are relevant
+| changes, the item is connected and the menu is posted,
+| the menu will be redisplayed.
+|
+| Return Values : E_OK - success
+| E_BAD_ARGUMENT - invalid item options
++--------------------------------------------------------------------------*/
+int set_item_opts(ITEM *item, Item_Options opts)
+{
+ if (opts & ~ALL_ITEM_OPTS)
+ RETURN(E_BAD_ARGUMENT);
+
+ if (item)
+ {
+ if (item->opt != opts)
+ {
+ MENU *menu = item->imenu;
+
+ item->opt = opts;
+
+ if ((!(opts & O_SELECTABLE)) && item->value)
+ item->value = FALSE;
+
+ if (menu && (menu->status & _POSTED))
+ {
+ Move_And_Post_Item( menu, item );
+ _nc_Show_Menu(menu);
+ }
+ }
+ }
+ else
+ _nc_Default_Item.opt = opts;
+
+ RETURN(E_OK);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : int item_opts_off(ITEM *item, Item_Options opts)
+|
+| Description : Switch of the options for this item.
+|
+| Return Values : E_OK - success
+| E_BAD_ARGUMENT - invalid options
++--------------------------------------------------------------------------*/
+int item_opts_off(ITEM *item, Item_Options opts)
+{
+ ITEM *citem = item; /* use a copy because set_item_opts must detect
+ NULL item itself to adjust its behaviour */
+
+ if (opts & ~ALL_ITEM_OPTS)
+ RETURN(E_BAD_ARGUMENT);
+ else
+ {
+ Normalize_Item(citem);
+ opts = citem->opt & ~opts;
+ return set_item_opts( item, opts );
+ }
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : int item_opts_on(ITEM *item, Item_Options opts)
+|
+| Description : Switch on the options for this item.
+|
+| Return Values : E_OK - success
+| E_BAD_ARGUMENT - invalid options
++--------------------------------------------------------------------------*/
+int item_opts_on(ITEM *item, Item_Options opts)
+{
+ ITEM *citem = item; /* use a copy because set_item_opts must detect
+ NULL item itself to adjust its behaviour */
+
+ if (opts & ~ALL_ITEM_OPTS)
+ RETURN(E_BAD_ARGUMENT);
+ else
+ {
+ Normalize_Item(citem);
+ opts = citem->opt | opts;
+ return set_item_opts( item, opts );
+ }
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : Item_Options item_opts(const ITEM *item)
+|
+| Description : Switch of the options for this item.
+|
+| Return Values : Items options
++--------------------------------------------------------------------------*/
+Item_Options item_opts(const ITEM * item)
+{
+ return (ALL_ITEM_OPTS & Normalize_Item(item)->opt);
+}
+
+/* m_item_opt.c ends here */
diff --git a/lib/libmenu/m_item_use.c b/lib/libmenu/m_item_use.c
new file mode 100644
index 00000000000..b12d573a1e7
--- /dev/null
+++ b/lib/libmenu/m_item_use.c
@@ -0,0 +1,59 @@
+
+/***************************************************************************
+* COPYRIGHT NOTICE *
+****************************************************************************
+* ncurses is copyright (C) 1992-1995 *
+* Zeyd M. Ben-Halim *
+* zmbenhal@netcom.com *
+* Eric S. Raymond *
+* esr@snark.thyrsus.com *
+* *
+* Permission is hereby granted to reproduce and distribute ncurses *
+* by any means and for any fee, whether alone or as part of a *
+* larger distribution, in source or in binary form, PROVIDED *
+* this notice is included with any such distribution, and is not *
+* removed from any of its header files. Mention of ncurses in any *
+* applications linked with it is highly appreciated. *
+* *
+* ncurses comes AS IS with no warranty, implied or expressed. *
+* *
+***************************************************************************/
+
+/***************************************************************************
+* Module menu_item_use *
+* Associate application data with menu items *
+***************************************************************************/
+
+#include "menu.priv.h"
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : int set_item_userptr(ITEM *item, char *userptr)
+|
+| Description : Set the pointer that is reserved in any item to store
+| application relevant informations.
+|
+| Return Values : E_OK - success
++--------------------------------------------------------------------------*/
+int set_item_userptr(ITEM * item, char * userptr)
+{
+ Normalize_Item(item)->userptr = userptr;
+ RETURN( E_OK );
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : char *item_userptr(const ITEM *item)
+|
+| Description : Return the pointer that is reserved in any item to store
+| application relevant informations.
+|
+| Return Values : Value of the pointer. If no such pointer has been set,
+| NULL is returned.
++--------------------------------------------------------------------------*/
+char *item_userptr(const ITEM * item)
+{
+ return Normalize_Item(item)->userptr;
+}
+
+/* m_item_use.c */
diff --git a/lib/libmenu/m_item_val.c b/lib/libmenu/m_item_val.c
new file mode 100644
index 00000000000..fdc57214e1d
--- /dev/null
+++ b/lib/libmenu/m_item_val.c
@@ -0,0 +1,87 @@
+
+/***************************************************************************
+* COPYRIGHT NOTICE *
+****************************************************************************
+* ncurses is copyright (C) 1992-1995 *
+* Zeyd M. Ben-Halim *
+* zmbenhal@netcom.com *
+* Eric S. Raymond *
+* esr@snark.thyrsus.com *
+* *
+* Permission is hereby granted to reproduce and distribute ncurses *
+* by any means and for any fee, whether alone or as part of a *
+* larger distribution, in source or in binary form, PROVIDED *
+* this notice is included with any such distribution, and is not *
+* removed from any of its header files. Mention of ncurses in any *
+* applications linked with it is highly appreciated. *
+* *
+* ncurses comes AS IS with no warranty, implied or expressed. *
+* *
+***************************************************************************/
+
+/***************************************************************************
+* Module menu_item_val *
+* Set and get menus item values *
+***************************************************************************/
+
+#include "menu.priv.h"
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : int set_item_value(ITEM *item, int value)
+|
+| Description : Programmatically set the items selection value. This is
+| only allowed if the item is selectable at all and if
+| it is not connected to a single-valued menu.
+| If the item is connected to a posted menu, the menu
+| will be redisplayed.
+|
+| Return Values : E_OK - success
+| E_REQUEST_DENIED - not selectable or single valued menu
++--------------------------------------------------------------------------*/
+int set_item_value(ITEM *item, bool value)
+{
+ MENU *menu;
+
+ if (item)
+ {
+ menu = item->imenu;
+
+ if ((!(item->opt & O_SELECTABLE)) ||
+ (menu && (menu->opt & O_ONEVALUE)))
+ RETURN(E_REQUEST_DENIED);
+
+ if (item->value ^ value)
+ {
+ item->value = value ? TRUE : FALSE;
+ if (menu)
+ {
+ if (menu->status & _POSTED)
+ {
+ Move_And_Post_Item(menu,item);
+ _nc_Show_Menu(menu);
+ }
+ }
+ }
+ }
+ else
+ _nc_Default_Item.value = value;
+
+ RETURN(E_OK);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : bool item_value(const ITEM *item)
+|
+| Description : Return the selection value of the item
+|
+| Return Values : TRUE - if item is selected
+| FALSE - if item is not selected
++--------------------------------------------------------------------------*/
+bool item_value(const ITEM *item)
+{
+ return ((Normalize_Item(item)->value) ? TRUE : FALSE);
+}
+
+/* m_item_val.c ends here */
diff --git a/lib/libmenu/m_item_vis.c b/lib/libmenu/m_item_vis.c
new file mode 100644
index 00000000000..36eeaeb6887
--- /dev/null
+++ b/lib/libmenu/m_item_vis.c
@@ -0,0 +1,53 @@
+
+/***************************************************************************
+* COPYRIGHT NOTICE *
+****************************************************************************
+* ncurses is copyright (C) 1992-1995 *
+* Zeyd M. Ben-Halim *
+* zmbenhal@netcom.com *
+* Eric S. Raymond *
+* esr@snark.thyrsus.com *
+* *
+* Permission is hereby granted to reproduce and distribute ncurses *
+* by any means and for any fee, whether alone or as part of a *
+* larger distribution, in source or in binary form, PROVIDED *
+* this notice is included with any such distribution, and is not *
+* removed from any of its header files. Mention of ncurses in any *
+* applications linked with it is highly appreciated. *
+* *
+* ncurses comes AS IS with no warranty, implied or expressed. *
+* *
+***************************************************************************/
+
+/***************************************************************************
+* Module menu_item_vis *
+* Tell if menu item is visible *
+***************************************************************************/
+
+#include "menu.priv.h"
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : bool item_visible(const ITEM *item)
+|
+| Description : A item is visible if it currently appears in the
+| subwindow of a posted menu.
+|
+| Return Values : TRUE if visible
+| FALSE if invisible
++--------------------------------------------------------------------------*/
+bool item_visible(const ITEM * item)
+{
+ MENU *menu;
+
+ if ( item &&
+ (menu=item->imenu) &&
+ (menu->status & _POSTED) &&
+ ( (menu->toprow + menu->height - 1) >= (item->y) ) &&
+ ( item->y >= menu->toprow) )
+ return TRUE;
+ else
+ return FALSE;
+}
+
+/* m_item_vis.c ends here */
diff --git a/lib/libmenu/m_items.c b/lib/libmenu/m_items.c
new file mode 100644
index 00000000000..9c4c532a834
--- /dev/null
+++ b/lib/libmenu/m_items.c
@@ -0,0 +1,90 @@
+
+/***************************************************************************
+* COPYRIGHT NOTICE *
+****************************************************************************
+* ncurses is copyright (C) 1992-1995 *
+* Zeyd M. Ben-Halim *
+* zmbenhal@netcom.com *
+* Eric S. Raymond *
+* esr@snark.thyrsus.com *
+* *
+* Permission is hereby granted to reproduce and distribute ncurses *
+* by any means and for any fee, whether alone or as part of a *
+* larger distribution, in source or in binary form, PROVIDED *
+* this notice is included with any such distribution, and is not *
+* removed from any of its header files. Mention of ncurses in any *
+* applications linked with it is highly appreciated. *
+* *
+* ncurses comes AS IS with no warranty, implied or expressed. *
+* *
+***************************************************************************/
+
+/***************************************************************************
+* Module menu_items *
+* Connect and disconnect items to and from menus *
+***************************************************************************/
+
+#include "menu.priv.h"
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : int set_menu_items(MENU *menu, ITEM **items)
+|
+| Description : Sets the item pointer array connected to menu.
+|
+| Return Values : E_OK - success
+| E_POSTED - menu is already posted
+| E_CONNECTED - one or more items are already connected
+| to another menu.
+| E_BAD_ARGUMENT - An incorrect menu or item array was
+| passed to the function
++--------------------------------------------------------------------------*/
+int set_menu_items(MENU * menu, ITEM ** items)
+{
+ if (!menu || (items && !(*items)))
+ RETURN(E_BAD_ARGUMENT);
+
+ if ( menu->status & _POSTED )
+ RETURN(E_POSTED);
+
+ if (menu->items)
+ _nc_Disconnect_Items(menu);
+
+ if (items)
+ {
+ if(!_nc_Connect_Items( menu, items ))
+ RETURN(E_CONNECTED);
+ }
+
+ menu->items = items;
+ RETURN(E_OK);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : ITEM **menu_items(const MENU *menu)
+|
+| Description : Returns a pointer to the item pointer arry of the menu
+|
+| Return Values : NULL on error
++--------------------------------------------------------------------------*/
+ITEM **menu_items(const MENU *menu)
+{
+ return(menu ? menu->items : (ITEM **)0);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : int item_count(const MENU *menu)
+|
+| Description : Get the number of items connected to the menu. If the
+| menu pointer is NULL we return -1.
+|
+| Return Values : Number of items or -1 to indicate error.
++--------------------------------------------------------------------------*/
+int item_count(const MENU *menu)
+{
+ return(menu ? menu->nitems : -1);
+}
+
+/* m_items.c ends here */
diff --git a/lib/libmenu/m_new.c b/lib/libmenu/m_new.c
new file mode 100644
index 00000000000..a9845544dd0
--- /dev/null
+++ b/lib/libmenu/m_new.c
@@ -0,0 +1,91 @@
+
+/***************************************************************************
+* COPYRIGHT NOTICE *
+****************************************************************************
+* ncurses is copyright (C) 1992-1995 *
+* Zeyd M. Ben-Halim *
+* zmbenhal@netcom.com *
+* Eric S. Raymond *
+* esr@snark.thyrsus.com *
+* *
+* Permission is hereby granted to reproduce and distribute ncurses *
+* by any means and for any fee, whether alone or as part of a *
+* larger distribution, in source or in binary form, PROVIDED *
+* this notice is included with any such distribution, and is not *
+* removed from any of its header files. Mention of ncurses in any *
+* applications linked with it is highly appreciated. *
+* *
+* ncurses comes AS IS with no warranty, implied or expressed. *
+* *
+***************************************************************************/
+
+/***************************************************************************
+* Module menu_new *
+* Creation and destruction of new menus *
+***************************************************************************/
+
+#include "menu.priv.h"
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : MENU *new_menu(ITEM **items)
+|
+| Description : Creates a new menu connected to the item pointer
+| array items and returns a pointer to the new menu.
+| The new menu is initialized with the values from the
+| default menu.
+|
+| Return Values : NULL on error
++--------------------------------------------------------------------------*/
+MENU *new_menu(ITEM ** items)
+{
+ MENU *menu = (MENU *)calloc(1,sizeof(MENU));
+
+ if (menu)
+ {
+ *menu = _nc_Default_Menu;
+ menu->rows = menu->frows;
+ menu->cols = menu->fcols;
+ if (items && *items)
+ {
+ if (!_nc_Connect_Items(menu,items))
+ {
+ free(menu);
+ menu = (MENU *)0;
+ }
+ }
+ }
+
+ if (!menu)
+ SET_ERROR(E_SYSTEM_ERROR);
+
+ return(menu);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : int free_menu(MENU *menu)
+|
+| Description : Disconnects menu from its associated item pointer
+| array and frees the storage allocated for the menu.
+|
+| Return Values : E_OK - success
+| E_BAD_ARGUMENT - Invalid menu pointer passed
+| E_POSTED - Menu is already posted
++--------------------------------------------------------------------------*/
+int free_menu(MENU * menu)
+{
+ if (!menu)
+ RETURN(E_BAD_ARGUMENT);
+
+ if ( menu->status & _POSTED )
+ RETURN(E_POSTED);
+
+ if (menu->items)
+ _nc_Disconnect_Items(menu);
+
+ free(menu);
+ RETURN(E_OK);
+}
+
+/* m_new.c ends here */
diff --git a/lib/libmenu/m_opts.c b/lib/libmenu/m_opts.c
new file mode 100644
index 00000000000..d0422e97764
--- /dev/null
+++ b/lib/libmenu/m_opts.c
@@ -0,0 +1,153 @@
+
+/***************************************************************************
+* COPYRIGHT NOTICE *
+****************************************************************************
+* ncurses is copyright (C) 1992-1995 *
+* Zeyd M. Ben-Halim *
+* zmbenhal@netcom.com *
+* Eric S. Raymond *
+* esr@snark.thyrsus.com *
+* *
+* Permission is hereby granted to reproduce and distribute ncurses *
+* by any means and for any fee, whether alone or as part of a *
+* larger distribution, in source or in binary form, PROVIDED *
+* this notice is included with any such distribution, and is not *
+* removed from any of its header files. Mention of ncurses in any *
+* applications linked with it is highly appreciated. *
+* *
+* ncurses comes AS IS with no warranty, implied or expressed. *
+* *
+***************************************************************************/
+
+/***************************************************************************
+* Module menu_opts *
+* Menus option routines *
+***************************************************************************/
+
+#include "menu.priv.h"
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : int set_menu_opts(MENU *menu, Menu_Options opts)
+|
+| Description : Set the options for this menu. If the new settings
+| end up in a change of the geometry of the menu, it
+| will be recalculated. This operation is forbidden if
+| the menu is already posted.
+|
+| Return Values : E_OK - success
+| E_BAD_ARGUMENT - invalid menu options
+| E_POSTED - menu is already posted
++--------------------------------------------------------------------------*/
+int set_menu_opts(MENU * menu, Menu_Options opts)
+{
+ if (opts & ~ALL_MENU_OPTS)
+ RETURN(E_BAD_ARGUMENT);
+
+ if (menu)
+ {
+ if ( menu->status & _POSTED )
+ RETURN(E_POSTED);
+
+ if ( (opts&O_ROWMAJOR) != (menu->opt&O_ROWMAJOR))
+ {
+ /* we need this only if the layout really changed ... */
+ if (menu->items && menu->items[0])
+ {
+ menu->toprow = 0;
+ menu->curitem = menu->items[0];
+ assert(menu->curitem);
+ set_menu_format( menu, menu->frows, menu->fcols );
+ }
+ }
+
+ menu->opt = opts;
+
+ if (opts & O_ONEVALUE)
+ {
+ ITEM **item;
+
+ if ( (item=menu->items) )
+ for(;*item;item++)
+ (*item)->value = FALSE;
+ }
+
+ if (opts & O_SHOWDESC) /* this also changes the geometry */
+ _nc_Calculate_Item_Length_and_Width( menu );
+ }
+ else
+ _nc_Default_Menu.opt = opts;
+
+ RETURN(E_OK);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : int menu_opts_off(MENU *menu, Menu_Options opts)
+|
+| Description : Switch off the options for this menu. If the new settings
+| end up in a change of the geometry of the menu, it
+| will be recalculated. This operation is forbidden if
+| the menu is already posted.
+|
+| Return Values : E_OK - success
+| E_BAD_ARGUMENT - invalid options
+| E_POSTED - menu is already posted
++--------------------------------------------------------------------------*/
+int menu_opts_off(MENU *menu, Menu_Options opts)
+{
+ MENU *cmenu = menu; /* use a copy because set_menu_opts must detect
+ NULL menu itself to adjust its behaviour */
+
+ if (opts & ~ALL_MENU_OPTS)
+ RETURN(E_BAD_ARGUMENT);
+ else
+ {
+ Normalize_Menu(cmenu);
+ opts = cmenu->opt & ~opts;
+ return set_menu_opts( menu, opts );
+ }
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : int menu_opts_on(MENU *menu, Menu_Options opts)
+|
+| Description : Switch on the options for this menu. If the new settings
+| end up in a change of the geometry of the menu, it
+| will be recalculated. This operation is forbidden if
+| the menu is already posted.
+|
+| Return Values : E_OK - success
+| E_BAD_ARGUMENT - invalid menu options
+| E_POSTED - menu is already posted
++--------------------------------------------------------------------------*/
+int menu_opts_on(MENU * menu, Menu_Options opts)
+{
+ MENU *cmenu = menu; /* use a copy because set_menu_opts must detect
+ NULL menu itself to adjust its behaviour */
+
+ if (opts & ~ALL_MENU_OPTS)
+ RETURN(E_BAD_ARGUMENT);
+ else
+ {
+ Normalize_Menu(cmenu);
+ opts = cmenu->opt | opts;
+ return set_menu_opts(menu, opts);
+ }
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : Menu_Options menu_opts(const MENU *menu)
+|
+| Description : Return the options for this menu.
+|
+| Return Values : Menu options
++--------------------------------------------------------------------------*/
+Menu_Options menu_opts(const MENU *menu)
+{
+ return (ALL_MENU_OPTS & Normalize_Menu( menu )->opt);
+}
+
+/* m_opts.c ends here */
diff --git a/lib/libmenu/m_post.c b/lib/libmenu/m_post.c
new file mode 100644
index 00000000000..fe4ed566447
--- /dev/null
+++ b/lib/libmenu/m_post.c
@@ -0,0 +1,266 @@
+
+/***************************************************************************
+* COPYRIGHT NOTICE *
+****************************************************************************
+* ncurses is copyright (C) 1992-1995 *
+* Zeyd M. Ben-Halim *
+* zmbenhal@netcom.com *
+* Eric S. Raymond *
+* esr@snark.thyrsus.com *
+* *
+* Permission is hereby granted to reproduce and distribute ncurses *
+* by any means and for any fee, whether alone or as part of a *
+* larger distribution, in source or in binary form, PROVIDED *
+* this notice is included with any such distribution, and is not *
+* removed from any of its header files. Mention of ncurses in any *
+* applications linked with it is highly appreciated. *
+* *
+* ncurses comes AS IS with no warranty, implied or expressed. *
+* *
+***************************************************************************/
+
+/***************************************************************************
+* Module menu_post *
+* Write or erase menus from associated subwindows *
+***************************************************************************/
+
+#include "menu.priv.h"
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : void _nc_Post_Item(MENU *menu, ITEM *item)
+|
+| Description : Draw the item in the menus window at the current
+| window position
+|
+| Return Values : -
++--------------------------------------------------------------------------*/
+void _nc_Post_Item(const MENU * menu, const ITEM * item)
+{
+ int i;
+ chtype ch;
+ bool isfore = FALSE, isback=FALSE, isgrey = FALSE;
+
+ assert(menu->win);
+
+ /* First we have to calculate the attribute depending on selectability
+ and selection status
+ */
+ if (!(item->opt & O_SELECTABLE))
+ {
+ wattron(menu->win,menu->grey);
+ isgrey = TRUE;
+ }
+ else
+ {
+ if (item->value || item==menu->curitem)
+ {
+ wattron(menu->win,menu->fore);
+ isfore = TRUE;
+ }
+ else
+ {
+ wattron(menu->win,menu->back);
+ isback = TRUE;
+ }
+ }
+
+ /* We need a marker iff
+ - it is a onevalued menu and it is the current item
+ - or it has a selection value
+ */
+ if (item->value || ((menu->opt&O_ONEVALUE) && (item==menu->curitem)) )
+ {
+ if (menu->marklen)
+ waddstr(menu->win,menu->mark);
+ }
+ else /* otherwise we have to wipe out the marker area */
+ for(ch=menu->pad,i=menu->marklen;i>0;i--)
+ waddch(menu->win,ch);
+
+ waddnstr(menu->win,item->name.str,item->name.length);
+ for(ch=menu->pad,i=menu->namelen-item->name.length;i>0;i--)
+ {
+ waddch(menu->win,ch);
+ }
+
+ /* Show description if required and available */
+ if ( (menu->opt & O_SHOWDESC) && menu->desclen>0 )
+ {
+ waddch(menu->win,menu->pad);
+ if (item->description.length)
+ waddnstr(menu->win,item->description.str,item->description.length);
+ for(ch=menu->pad,i=menu->desclen-item->description.length; i>0; i--)
+ {
+ waddch(menu->win,ch);
+ }
+ }
+
+ /* Remove attributes */
+ if (isfore)
+ wattroff(menu->win,menu->fore);
+ if (isback)
+ wattroff(menu->win,menu->back);
+ if (isgrey)
+ wattroff(menu->win,menu->grey);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : void _nc_Draw_Menu(const MENU *)
+|
+| Description : Display the menu in its windows
+|
+| Return Values : -
++--------------------------------------------------------------------------*/
+void _nc_Draw_Menu(const MENU * menu)
+{
+ ITEM *item = menu->items[0];
+ ITEM *lasthor, *lastvert;
+ ITEM *hitem;
+ int y = 0;
+
+ assert(item && menu->win);
+
+ lastvert = (menu->opt & O_NONCYCLIC) ? (ITEM *)0 : item;
+
+ do
+ {
+ wmove(menu->win,y++,0);
+
+ hitem = item;
+ lasthor = (menu->opt & O_NONCYCLIC) ? (ITEM *)0 : hitem;
+
+ do
+ {
+ _nc_Post_Item( menu, hitem);
+ if ( ((hitem = hitem->right) != lasthor) && hitem )
+ {
+ waddch( menu->win,menu->pad);
+ }
+ } while (hitem && (hitem != lasthor));
+
+ item = item->down;
+
+ } while( item && (item != lastvert) );
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : int post_menu(MENU *)
+|
+| Description : Post a menu to the screen. This makes it visible.
+|
+| Return Values : E_OK - success
+| E_BAD_ARGUMENT - not a valid menu pointer
+| E_SYSTEM_ERROR - error in lower layers
+| E_NO_ROOM - Menu to large for screen
+| E_NOT_CONNECTED - No items connected to menu
+| E_BAD_STATE - Menu in userexit routine
+| E_POSTED - Menu already posted
++--------------------------------------------------------------------------*/
+int post_menu(MENU * menu)
+{
+ if (!menu)
+ RETURN(E_BAD_ARGUMENT);
+
+ if ( menu->status & _IN_DRIVER )
+ RETURN(E_BAD_STATE);
+
+ if ( menu->status & _POSTED )
+ RETURN(E_POSTED);
+
+ if (menu->items && *(menu->items))
+ {
+ int y;
+ WINDOW *win = Get_Menu_Window(menu);
+ int maxy = getmaxy(win);
+ int maxx = getmaxx(win);
+
+ if (maxx < menu->width || maxy < menu->height)
+ RETURN(E_NO_ROOM);
+
+ if ( (menu->win = newpad(menu->rows,menu->width)) )
+ {
+ y = (maxy >= menu->rows) ? menu->rows : maxy;
+ if (y>=menu->height)
+ y = menu->height;
+ if(!(menu->sub = subpad(menu->win,y,menu->width,0,0)))
+ RETURN(E_SYSTEM_ERROR);
+ }
+ else
+ RETURN(E_SYSTEM_ERROR);
+
+ if (menu->status & _LINK_NEEDED)
+ _nc_Link_Items(menu);
+ }
+ else
+ RETURN(E_NOT_CONNECTED);
+
+ menu->status |= _POSTED;
+
+ if (!(menu->opt&O_ONEVALUE))
+ {
+ ITEM **items;
+
+ for(items=menu->items;*items;items++)
+ {
+ (*items)->value = FALSE;
+ }
+ }
+
+ _nc_Draw_Menu(menu);
+
+ Call_Hook(menu,menuinit);
+ Call_Hook(menu,iteminit);
+
+ _nc_Show_Menu(menu);
+
+ RETURN(E_OK);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : int unpost_menu(MENU *)
+|
+| Description : Detach menu from screen
+|
+| Return Values : E_OK - success
+| E_BAD_ARGUMENT - not a valid menu pointer
+| E_BAD_STATE - menu in userexit routine
+| E_NOT_POSTED - menu is not posted
++--------------------------------------------------------------------------*/
+int unpost_menu(MENU * menu)
+{
+ WINDOW *win;
+
+ if (!menu)
+ RETURN(E_BAD_ARGUMENT);
+
+ if ( menu->status & _IN_DRIVER )
+ RETURN(E_BAD_STATE);
+
+ if ( !( menu->status & _POSTED ) )
+ RETURN(E_NOT_POSTED);
+
+ Call_Hook(menu,itemterm);
+ Call_Hook(menu,menuterm);
+
+ win = Get_Menu_Window(menu);
+ werase(win);
+ wsyncup(win);
+
+ assert(menu->sub);
+ delwin(menu->sub);
+ menu->sub = (WINDOW *)0;
+
+ assert(menu->win);
+ delwin(menu->win);
+ menu->win = (WINDOW *)0;
+
+ menu->status &= ~_POSTED;
+
+ RETURN(E_OK);
+}
+
+/* m_post.c ends here */
diff --git a/lib/libmenu/m_userptr.c b/lib/libmenu/m_userptr.c
new file mode 100644
index 00000000000..634b4b2b29a
--- /dev/null
+++ b/lib/libmenu/m_userptr.c
@@ -0,0 +1,59 @@
+
+/***************************************************************************
+* COPYRIGHT NOTICE *
+****************************************************************************
+* ncurses is copyright (C) 1992-1995 *
+* Zeyd M. Ben-Halim *
+* zmbenhal@netcom.com *
+* Eric S. Raymond *
+* esr@snark.thyrsus.com *
+* *
+* Permission is hereby granted to reproduce and distribute ncurses *
+* by any means and for any fee, whether alone or as part of a *
+* larger distribution, in source or in binary form, PROVIDED *
+* this notice is included with any such distribution, and is not *
+* removed from any of its header files. Mention of ncurses in any *
+* applications linked with it is highly appreciated. *
+* *
+* ncurses comes AS IS with no warranty, implied or expressed. *
+* *
+***************************************************************************/
+
+/***************************************************************************
+* Module menu_userptr *
+* Associate application data with menus *
+***************************************************************************/
+
+#include "menu.priv.h"
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : int set_menu_userptr(MENU *menu, char *userptr)
+|
+| Description : Set the pointer that is reserved in any menu to store
+| application relevant informations.
+|
+| Return Values : E_OK - success
++--------------------------------------------------------------------------*/
+int set_menu_userptr(MENU * menu, char * userptr)
+{
+ Normalize_Menu(menu)->userptr = userptr;
+ RETURN( E_OK );
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : char *menu_userptr(const MENU *menu)
+|
+| Description : Return the pointer that is reserved in any menu to
+| store application relevant informations.
+|
+| Return Values : Value of the pointer. If no such pointer has been set,
+| NULL is returned
++--------------------------------------------------------------------------*/
+char *menu_userptr(const MENU * menu)
+{
+ return( Normalize_Menu(menu)->userptr);
+}
+
+/* m_userptr.c ends here */
diff --git a/lib/libmenu/m_win.c b/lib/libmenu/m_win.c
new file mode 100644
index 00000000000..7baad40c5d8
--- /dev/null
+++ b/lib/libmenu/m_win.c
@@ -0,0 +1,131 @@
+
+/***************************************************************************
+* COPYRIGHT NOTICE *
+****************************************************************************
+* ncurses is copyright (C) 1992-1995 *
+* Zeyd M. Ben-Halim *
+* zmbenhal@netcom.com *
+* Eric S. Raymond *
+* esr@snark.thyrsus.com *
+* *
+* Permission is hereby granted to reproduce and distribute ncurses *
+* by any means and for any fee, whether alone or as part of a *
+* larger distribution, in source or in binary form, PROVIDED *
+* this notice is included with any such distribution, and is not *
+* removed from any of its header files. Mention of ncurses in any *
+* applications linked with it is highly appreciated. *
+* *
+* ncurses comes AS IS with no warranty, implied or expressed. *
+* *
+***************************************************************************/
+
+/***************************************************************************
+* Module menu_win *
+* Menus window and subwindow association routines *
+***************************************************************************/
+
+#include "menu.priv.h"
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : int set_menu_win(MENU *menu, WINDOW *win)
+|
+| Description : Sets the window of the menu.
+|
+| Return Values : E_OK - success
+| E_POSTED - menu is already posted
++--------------------------------------------------------------------------*/
+int set_menu_win(MENU *menu, WINDOW *win)
+{
+ if (menu)
+ {
+ if ( menu->status & _POSTED )
+ RETURN(E_POSTED);
+ menu->userwin = win;
+ _nc_Calculate_Item_Length_and_Width(menu);
+ }
+ else
+ _nc_Default_Menu.userwin = win;
+
+ RETURN(E_OK);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : WINDOW *menu_win(const MENU *)
+|
+| Description : Returns pointer to the window of the menu
+|
+| Return Values : NULL on error, otherwise pointer to window
++--------------------------------------------------------------------------*/
+WINDOW *menu_win(const MENU *menu)
+{
+ return Normalize_Menu(menu)->userwin;
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : int set_menu_sub(MENU *menu, WINDOW *win)
+|
+| Description : Sets the subwindow of the menu.
+|
+| Return Values : E_OK - success
+| E_POSTED - menu is already posted
++--------------------------------------------------------------------------*/
+int set_menu_sub(MENU *menu, WINDOW *win)
+{
+ if (menu)
+ {
+ if ( menu->status & _POSTED )
+ RETURN(E_POSTED);
+ menu->usersub = win;
+ _nc_Calculate_Item_Length_and_Width(menu);
+ }
+ else
+ _nc_Default_Menu.usersub = win;
+
+ RETURN(E_OK);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : WINDOW *menu_sub(const MENU *menu)
+|
+| Description : Returns a pointer to the subwindow of the menu
+|
+| Return Values : NULL on error, otherwise a pointer to the window
++--------------------------------------------------------------------------*/
+WINDOW *menu_sub(const MENU * menu)
+{
+ return Normalize_Menu(menu)->usersub;
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
+| Function : int scale_menu(const MENU *menu)
+|
+| Description : Returns the minimum window size necessary for the
+| subwindow of menu.
+|
+| Return Values : E_OK - success
+| E_BAD_ARGUMENT - invalid menu pointer
+| E_NOT_CONNECTED - no items are connected to menu
++--------------------------------------------------------------------------*/
+int scale_menu(const MENU *menu, int *rows, int *cols)
+{
+ if (!menu)
+ RETURN( E_BAD_ARGUMENT );
+
+ if (menu->items && *(menu->items))
+ {
+ if (rows)
+ *rows = menu->height;
+ if (cols)
+ *cols = menu->width;
+ RETURN(E_OK);
+ }
+ else
+ RETURN( E_NOT_CONNECTED );
+}
+
+/* m_win.c ends here */
diff --git a/lib/libmenu/menu.3 b/lib/libmenu/menu.3
new file mode 100644
index 00000000000..99b3a962973
--- /dev/null
+++ b/lib/libmenu/menu.3
@@ -0,0 +1,156 @@
+'\" t
+.TH menus 3X ""
+.SH NAME
+\fBmenus\fR - curses extension for programming menus
+.SH SYNOPSIS
+\fB#include <menu.h>\fR
+.br
+.SH DESCRIPTION
+The \fBmenus\fR library provides terminal-independent facilities for composing
+menu systems on character-cell terminals. The library includes: item routines,
+which create and modify menu items; and menu routines, which group items into
+menus, display menus on the screen, and handle interaction with the user.
+
+The \fBmenus\fR library uses the \fBcurses\fR libraries, and a curses
+initialization routine such as \fBinitscr\fR must be called before using any of
+these functions. To use the \Bmenus\fR library, link with the options
+\fB-lmenu -lcurses\fR.
+
+.SS Current Default Values for Item Attributes
+
+The \fBmenus\fR library maintains a default value for item attributes. You can
+get or set this default by calling the appropriate \fBget_\fR or \fBset_\fR
+routine with a \fBNULL\fR item pointer. Changing this default with a
+\fBset_\fR function affects future item creations, but does not change the
+rendering of items already created.
+
+.SS Routine Name Index
+
+The following table lists each \fBmenu\fR routine and the name of
+the manual page on which it is described.
+
+.nf
+\fBcurses\fR Routine Name Manual Page Name
+_________________________________________
+\fBcurrent_item\fR mitem_current(3X)
+\fBfree_item\fR mitem_new(3X)
+\fBfree_menu\fR menu_new(3X)
+\fBitem_count\fR menu_items(3X)
+\fBitem_description\fR mitem_name(3X)
+\fBitem_index\fR mitem_current(3X)
+\fBitem_init\fR menu_hook(3X)
+\fBitem_name\fR mitem_name(3X)
+\fBitem_opts\fR mitem_opts(3X)
+\fBitem_opts_off\fR mitem_opts(3X)
+\fBitem_opts_on\fR mitem_opts(3X)
+\fBitem_term\fR menu_hook(3X)
+\fBitem_userptr\fR mitem_userptr(3X)
+\fBitem_value\fR mitem_value(3X)
+\fBitem_visible\fR mitem_visible(3X)
+\fBmenu_back\fR menu_attribs(3X)
+\fBmenu_driver\fR menu_driver(3X)
+\fBmenu_fore\fR menu_fore(3X)
+\fBmenu_format\fR menu_format(3X)
+\fBmenu_grey\fR menu_attribs(3X)
+\fBmenu_init\fR menu_hook(3X)
+\fBmenu_items\fR menu_items(3X)
+\fBmenu_mark\fR menu_mark(3X)
+\fBmenu_opts\fR menu_opts(3X)
+\fBmenu_opts_off\fR menu_opts(3X)
+\fBmenu_opts_on\fR menu_opts(3X)
+\fBmenu_pad\fR menu_attribs(3X)
+\fBmenu_pattern\fR menu_pattern(3X)
+\fBmenu_sub\fR menu_win(3X)
+\fBmenu_term\fR menu_hook(3X)
+\fBmenu_userptr\fR menu_userptr(3X)
+\fBmenu_win\fR menu_win(3X)
+\fBnew_item\fR mitem_new(3X)
+\fBnew_menu\fR menu_new(3X)
+\fBpos_menu_cursor\fR menu_cursor(3X)
+\fBpost_menu\fR menu_post(3X)
+\fBscale_menu\fR menu_win(3X)
+\fBset_current_item\fR menu_current_item(3X)
+\fBset_item_init\fR menu_hook(3X)
+\fBset_item_opts\fR mitem_opts(3X)
+\fBset_item_term\fR menu_hook(3X)
+\fBset_item_userptr\fR mitem_userptr(3X)
+\fBset_item_value\fR mitem_value(3X)
+\fBset_menu_back\fR menu_attribs(3X)
+\fBset_menu_fore\fR menu_attribs(3X)
+\fBset_menu_format\fR menu_format(3X)
+\fBset_menu_grey\fR menu_attribs(3X)
+\fBset_menu_init\fR menu_hook(3X)
+\fBset_menu_items\fR menu_items(3X)
+\fBset_menu_mark\fR menu_mark(3X)
+\fBset_menu_opts\fR mitem_opts(3X)
+\fBset_menu_pad\fR menu_attribs(3X)
+\fBset_menu_pattern\fR menu_pattern(3X)
+\fBset_menu_sub\fR menu_win(3X)
+\fBset_menu_term\fR menu_hook(3X)
+\fBset_menu_userptr\fR menu_userptr(3X)
+\fBset_menu_win\fR menu_win(3X)
+\fBset_top_row\fR mitem_current(3X)
+\fBtop_row\fR mitem_current(3X)
+\fBunpost_menu\fR menu_post(3X)
+.fi
+.SH RETURN VALUE
+Routines that return pointers return \fBNULL\fR on error. Routines that return
+an integer return one of the following error codes:
+.TP 5
+\fBE_OK\fR
+The routine succeeded.
+.TP 5
+\fBE_SYSTEM_ERROR\fR
+System error occurred (see \fBerrno\fR).
+.TP 5
+\fBE_BAD_ARGUMENT\fR
+Routine detected an incorrect or out-of-range argument.
+.TP 5
+\fBE_POSTED\fR
+The menu is already posted.
+.TP 5
+\fBE_BAD_STATE\fR
+Routine was called from an initialization or termination function.
+.TP 5
+\fBE_NO_ROOM\fR
+Menu is too large for its window.
+.TP 5
+\fBE_NOT_POSTED\fR
+The menu has not been posted.
+.TP 5
+\fBE_UNKNOWN_COMMAND\fR
+The menu driver code saw an unknown request code.
+.TP 5
+\fBE_NO_MATCH\fR
+Character failed to match.
+.TP 5
+\fBE_NOT_SELECTABLE\fR
+The designated item cannot be selected.
+.TP 5
+\fBE_NOT_CONNECTED\fR
+No items are connected to the menu.
+.TP 5
+\fBE_REQUEST_DENIED\fR
+The menu driver could not process the request.
+.SH SEE ALSO
+\fBcurses\fR(3X) and 3X pages whose names begin "menu_" for detailed
+descriptions of the entry points.
+.SH NOTES
+The header file \fB<menu.h>\fR automatically includes the header files
+\fB<curses.h>\fR and \fB<eti.h>\fR.
+
+In your library list, libmenu.a should be before libncurses.a; that is,
+you want to say `-lmenu -lncurses', not the other way around (which would
+give you a link error using GNU \fBld\fR(1) and many other linkers).
+.SH PORTABILITY
+These routines emulate the System V menu library. They were not supported on
+Version 7 or BSD versions.
+.SH AUTHORS
+Juergen Pfeifer. Manual pages and adaptation for ncurses by Eric
+S. Raymond.
+.\"#
+.\"# The following sets edit modes for GNU EMACS
+.\"# Local Variables:
+.\"# mode:nroff
+.\"# fill-column:79
+.\"# End:
diff --git a/lib/libmenu/menu.h b/lib/libmenu/menu.h
new file mode 100644
index 00000000000..31eb96a6c0b
--- /dev/null
+++ b/lib/libmenu/menu.h
@@ -0,0 +1,219 @@
+
+/***************************************************************************
+* COPYRIGHT NOTICE *
+****************************************************************************
+* ncurses is copyright (C) 1992-1995 *
+* Zeyd M. Ben-Halim *
+* zmbenhal@netcom.com *
+* Eric S. Raymond *
+* esr@snark.thyrsus.com *
+* *
+* Permission is hereby granted to reproduce and distribute ncurses *
+* by any means and for any fee, whether alone or as part of a *
+* larger distribution, in source or in binary form, PROVIDED *
+* this notice is included with any such distribution, and is not *
+* removed from any of its header files. Mention of ncurses in any *
+* applications linked with it is highly appreciated. *
+* *
+* ncurses comes AS IS with no warranty, implied or expressed. *
+* *
+***************************************************************************/
+
+#ifndef ETI_MENU
+#define ETI_MENU
+
+#include <curses.h>
+#include <term.h>
+#include <eti.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef int Menu_Options;
+typedef int Item_Options;
+
+/* Menu options: */
+#define O_ONEVALUE (0x01)
+#define O_SHOWDESC (0x02)
+#define O_ROWMAJOR (0x04)
+#define O_IGNORECASE (0x08)
+#define O_SHOWMATCH (0x10)
+#define O_NONCYCLIC (0x20)
+
+/* Item options: */
+#define O_SELECTABLE (0x01)
+
+typedef struct
+{
+ char* str;
+ unsigned short length;
+} TEXT;
+
+typedef struct tagITEM
+{
+ TEXT name; /* name of menu item */
+ TEXT description; /* description of item, optional in display */
+ struct tagMENU *imenu; /* Pointer to parent menu */
+ void *userptr; /* Pointer to user defined per item data */
+ Item_Options opt; /* Item options */
+ short index; /* Item number if connected to a menu */
+ short y; /* y and x location of item in menu */
+ short x;
+ bool value; /* Selection value */
+
+ struct tagITEM *left; /* neighbour items */
+ struct tagITEM *right;
+ struct tagITEM *up;
+ struct tagITEM *down;
+
+} ITEM;
+
+typedef void (*Menu_Hook)(struct tagMENU *);
+
+typedef struct tagMENU
+{
+ short height; /* Nr. of chars high */
+ short width; /* Nr. of chars wide */
+ short rows; /* Nr. of items high */
+ short cols; /* Nr. of items wide */
+ short frows; /* Nr. of formatted items high */
+ short fcols; /* Nr. of formatted items wide */
+ short namelen; /* Max. name length */
+ short desclen; /* Max. description length */
+ short marklen; /* Length of mark, if any */
+ short itemlen; /* Length of one item */
+ char *pattern; /* Buffer to store match chars */
+ short pindex; /* Index into pattern buffer */
+ WINDOW *win; /* Window containing menu */
+ WINDOW *sub; /* Subwindow for menu display */
+ WINDOW *userwin; /* User's window */
+ WINDOW *usersub; /* User's subwindow */
+ ITEM **items; /* array of items */
+ short nitems; /* Nr. of items in menu */
+ ITEM *curitem; /* Current item */
+ short toprow; /* Top row of menu */
+ chtype fore; /* Selection attribute */
+ chtype back; /* Nonselection attribute */
+ chtype grey; /* Inactive attribute */
+ unsigned char pad; /* Pad character */
+
+ Menu_Hook menuinit; /* User hooks */
+ Menu_Hook menuterm;
+ Menu_Hook iteminit;
+ Menu_Hook itemterm;
+
+ void *userptr; /* Pointer to menus user data */
+ char *mark; /* Pointer to marker string */
+
+ Menu_Options opt; /* Menu options */
+ unsigned short status; /* Internal state of menu */
+
+} MENU;
+
+
+/* Define keys */
+
+#define REQ_LEFT_ITEM (KEY_MAX + 1)
+#define REQ_RIGHT_ITEM (KEY_MAX + 2)
+#define REQ_UP_ITEM (KEY_MAX + 3)
+#define REQ_DOWN_ITEM (KEY_MAX + 4)
+#define REQ_SCR_ULINE (KEY_MAX + 5)
+#define REQ_SCR_DLINE (KEY_MAX + 6)
+#define REQ_SCR_DPAGE (KEY_MAX + 7)
+#define REQ_SCR_UPAGE (KEY_MAX + 8)
+#define REQ_FIRST_ITEM (KEY_MAX + 9)
+#define REQ_LAST_ITEM (KEY_MAX + 10)
+#define REQ_NEXT_ITEM (KEY_MAX + 11)
+#define REQ_PREV_ITEM (KEY_MAX + 12)
+#define REQ_TOGGLE_ITEM (KEY_MAX + 13)
+#define REQ_CLEAR_PATTERN (KEY_MAX + 14)
+#define REQ_BACK_PATTERN (KEY_MAX + 15)
+#define REQ_NEXT_MATCH (KEY_MAX + 16)
+#define REQ_PREV_MATCH (KEY_MAX + 17)
+#define MAX_MENU_COMMAND (KEY_MAX + 17)
+
+/*
+ * Some AT&T code expects MAX_COMMAND to be out-of-band not
+ * just for meny commands but for forms ones as well.
+ */
+#define MAX_COMMAND (KEY_MAX + 128)
+
+/* --------- prototypes for libmenu functions ----------------------------- */
+
+extern ITEM **menu_items(const MENU *),
+ *current_item(const MENU *),
+ *new_item(char *,char *);
+
+extern MENU *new_menu(ITEM **);
+
+extern Item_Options item_opts(const ITEM *);
+extern Menu_Options menu_opts(const MENU *);
+
+Menu_Hook item_init(const MENU *),
+ item_term(const MENU *),
+ menu_init(const MENU *),
+ menu_term(const MENU *);
+
+extern WINDOW *menu_sub(const MENU *),
+ *menu_win(const MENU *);
+
+extern char *item_description(const ITEM *),
+ *item_name(const ITEM *),
+ *menu_mark(const MENU *),
+ *menu_pattern(const MENU *);
+
+extern char *item_userptr(const ITEM *),
+ *menu_userptr(const MENU *);
+
+extern chtype menu_back(const MENU *),
+ menu_fore(const MENU *),
+ menu_grey(const MENU *);
+
+extern int free_item(ITEM *),
+ free_menu(MENU *),
+ item_count(const MENU *),
+ item_index(const ITEM *),
+ item_opts_off(ITEM *,Item_Options),
+ item_opts_on(ITEM *,Item_Options),
+ menu_driver(MENU *,int),
+ menu_opts_off(MENU *,Menu_Options),
+ menu_opts_on(MENU *,Menu_Options),
+ menu_pad(const MENU *),
+ pos_menu_cursor(const MENU *),
+ post_menu(MENU *),
+ scale_menu(const MENU *,int *,int *),
+ set_current_item(MENU *menu,ITEM *item),
+ set_item_init(MENU *,void(*)(MENU *)),
+ set_item_opts(ITEM *,Item_Options),
+ set_item_term(MENU *,void(*)(MENU *)),
+ set_item_userptr(ITEM *, char *),
+ set_item_value(ITEM *,bool),
+ set_menu_back(MENU *,chtype),
+ set_menu_fore(MENU *,chtype),
+ set_menu_format(MENU *,int,int),
+ set_menu_grey(MENU *,chtype),
+ set_menu_init(MENU *,void(*)(MENU *)),
+ set_menu_items(MENU *,ITEM **),
+ set_menu_mark(MENU *, char *),
+ set_menu_opts(MENU *,Menu_Options),
+ set_menu_pad(MENU *,int),
+ set_menu_pattern(MENU *,const char *),
+ set_menu_sub(MENU *,WINDOW *),
+ set_menu_term(MENU *,void(*)(MENU *)),
+ set_menu_userptr(MENU *,char *),
+ set_menu_win(MENU *,WINDOW *),
+ set_top_row(MENU *,int),
+ top_row(const MENU *),
+ unpost_menu(MENU *);
+
+extern bool item_value(const ITEM *),
+ item_visible(const ITEM *);
+
+void menu_format(const MENU *,int *,int *);
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif /* ETI_MENU */
diff --git a/lib/libmenu/menu.priv.h b/lib/libmenu/menu.priv.h
new file mode 100644
index 00000000000..1086c1bd3a8
--- /dev/null
+++ b/lib/libmenu/menu.priv.h
@@ -0,0 +1,97 @@
+
+/***************************************************************************
+* COPYRIGHT NOTICE *
+****************************************************************************
+* ncurses is copyright (C) 1992-1995 *
+* Zeyd M. Ben-Halim *
+* zmbenhal@netcom.com *
+* Eric S. Raymond *
+* esr@snark.thyrsus.com *
+* *
+* Permission is hereby granted to reproduce and distribute ncurses *
+* by any means and for any fee, whether alone or as part of a *
+* larger distribution, in source or in binary form, PROVIDED *
+* this notice is included with any such distribution, and is not *
+* removed from any of its header files. Mention of ncurses in any *
+* applications linked with it is highly appreciated. *
+* *
+* ncurses comes AS IS with no warranty, implied or expressed. *
+* *
+***************************************************************************/
+
+/***************************************************************************
+* Module menu.priv.h *
+* Top level private header file for all libnmenu modules *
+***************************************************************************/
+
+#include "mf_common.h"
+#include "menu.h"
+
+/* Backspace code */
+#define BS (8)
+
+extern ITEM _nc_Default_Item;
+extern MENU _nc_Default_Menu;
+
+/* Normalize item to default if none was given */
+#define Normalize_Item( item ) ((item)=(item)?(item):&_nc_Default_Item)
+
+/* Normalize menu to default if none was given */
+#define Normalize_Menu( menu ) ((menu)=(menu)?(menu):&_nc_Default_Menu)
+
+/* Normalize menu window */
+#define Get_Menu_Window( menu ) \
+ ( (menu)->usersub ? (menu)->usersub : (\
+ (menu)->userwin ? (menu)->userwin : stdscr ))
+
+/* menu specific status flags */
+#define _LINK_NEEDED (0x04)
+
+#define ALL_MENU_OPTS ( \
+ O_ONEVALUE | \
+ O_SHOWDESC | \
+ O_ROWMAJOR | \
+ O_IGNORECASE | \
+ O_SHOWMATCH | \
+ O_NONCYCLIC )
+
+#define ALL_ITEM_OPTS (O_SELECTABLE)
+
+/* Move to the window position of an item and draw it */
+#define Move_And_Post_Item(menu,item) \
+ {wmove((menu)->win,(item)->y,((menu)->itemlen+1)*(item)->x);\
+ _nc_Post_Item((menu),(item));}
+
+#define Move_To_Current_Item(menu,item) \
+ if ( (item) != (menu)->curitem)\
+ {\
+ Move_And_Post_Item(menu,item);\
+ Move_And_Post_Item(menu,(menu)->curitem);\
+ }
+
+/* This macro ensures, that the item becomes visible, if possible with the
+ specified row as the top row of the window. If this is not possible,
+ the top row will be adjusted and the value is stored in the row argument.
+*/
+#define Adjust_Current_Item(menu,row,item) \
+ { if ((item)->y < row) \
+ row = (item)->y;\
+ if ( (item)->y >= (row + (menu)->height) )\
+ row = ( (item)->y < ((menu)->rows - row) ) ? \
+ (item)->y : (menu)->rows - (menu)->height;\
+ _nc_New_TopRow_and_CurrentItem(menu,row,item); }
+
+/* Reset the match pattern buffer */
+#define Reset_Pattern(menu) \
+ { (menu)->pindex = 0; \
+ (menu)->pattern[0] = '\0'; }
+
+/* Internal functions. */
+extern void _nc_Draw_Menu(const MENU *);
+extern void _nc_Show_Menu(const MENU *);
+extern void _nc_Calculate_Item_Length_and_Width(MENU *);
+extern void _nc_Post_Item(const MENU *, const ITEM *);
+extern bool _nc_Connect_Items(MENU *, ITEM **);
+extern void _nc_Disconnect_Items(MENU *);
+extern void _nc_New_TopRow_and_CurrentItem(MENU *,int, ITEM *);
+extern void _nc_Link_Items(MENU *);
diff --git a/lib/libmenu/menu_attribs.3 b/lib/libmenu/menu_attribs.3
new file mode 100644
index 00000000000..ebd5563d219
--- /dev/null
+++ b/lib/libmenu/menu_attribs.3
@@ -0,0 +1,71 @@
+'\" t
+.TH menu_attributes 3X ""
+.SH NAME
+\fBmenu_attributes\fR - color and attribute control for menus
+.SH SYNOPSIS
+\fB#include <menu.h>\fR
+.br
+int set_menu_fore(MENU *menu, chtype attr);
+.br
+chtype menu_fore(MENU *menu);
+.br
+int set_menu_back(MENU *menu, chtype attr);
+.br
+chtype menu_back(MENU *menu);
+.br
+int set_menu_grey(MENU *menu, chtype attr);
+.br
+chtype menu_grey(MENU *menu);
+.br
+int set_menu_pad(MENU *menu, int pad);
+.br
+chtype menu_pad(MENU *menu);
+.br
+.SH DESCRIPTION
+The function \fBset_menu_fore\fR sets the foreground attribute of
+\fImenu\fR. This is the highlight used for selected menu items.
+\fBmenu_fore\fR returns the foreground attribute. The default
+is \fBA_STANDOUT\fR.
+
+The function \fBset_menu_back\fR sets the background attribute of
+\fImenu\fR. This is the highlight used for selectable (but not currently
+selected) menu items. The function \fBmenu_back\fR returns the background
+attribute. The default is \fBA_NORMAL\fR.
+
+The function \fBset_menu_grey\fR sets the grey attribute of \fImenu\fR. This is
+the highlight used for un-selectable menu items in menus that permit more than
+one selection. The function \fBmenu_grey\fR returns the grey attribute.
+The default is \fBA_UNDERLINE\fR.
+
+The function \fBset_menu_pad\fR sets the character used to fill the space
+between the name and description parts of a menu item. \fBmenu_pad\fR returns
+the given menu's pad character. The default is a blank.
+.SH RETURN VALUE
+These routines return one of the following:
+.TP 5
+\fBE_OK\fR
+The routine succeeded.
+.TP 5
+\fBE_SYSTEM_ERROR\fR
+System error occurred (see \fBerrno\fR).
+.TP 5
+\fBE_BAD_ARGUMENT\fR
+Routine detected an incorrect or out-of-range argument.
+.SH SEE ALSO
+\fBcurses\fR(3X) and 3X pages whose names begin "menu_" for detailed
+descriptions of the entry points.
+.SH NOTES
+The header file \fB<menu.h>\fR automatically includes the header file
+\fB<curses.h>\fR.
+.SH PORTABILITY
+These routines emulate the System V menu library. They were not supported on
+Version 7 or BSD versions.
+.SH AUTHORS
+Juergen Pfeifer. Manual pages and adaptation for new curses by Eric
+S. Raymond.
+.\"#
+.\"# The following sets edit modes for GNU EMACS
+.\"# Local Variables:
+.\"# mode:nroff
+.\"# fill-column:79
+.\"# End:
diff --git a/lib/libmenu/menu_cursor.3 b/lib/libmenu/menu_cursor.3
new file mode 100644
index 00000000000..882fe52a299
--- /dev/null
+++ b/lib/libmenu/menu_cursor.3
@@ -0,0 +1,44 @@
+'\" t
+.TH menu_cursor 3X ""
+.SH NAME
+\fBmenu_cursor\fR - position a menu's cursor
+.SH SYNOPSIS
+\fB#include <menu.h>\fR
+.br
+int pos_menu_cursor(MENU *menu);
+.br
+.SH DESCRIPTION
+The function \fBpos_menu_cursor\fR restores the cursor to the current position
+associated with the menu's selected item. This is useful after \fBcurses\fR
+routines have been called to do screen-painting in response to a menu select.
+.SH RETURN VALUE
+This routine returns one of the following:
+.TP 5
+\fBE_OK\fR
+The routine succeeded.
+.TP 5
+\fBE_SYSTEM_ERROR\fR
+System error occurred (see \fBerrno\fR).
+.TP 5
+\fBE_BAD_ARGUMENT\fR
+Routine detected an incorrect or out-of-range argument.
+.TP 5
+\fBE_NOT_POSTED\fR
+The menu has not been posted.
+.SH SEE ALSO
+\fBcurses\fR(3X), \fBmenu\fR(3X).
+.SH NOTES
+The header file \fB<menu.h>\fR automatically includes the header file
+\fB<curses.h>\fR.
+.SH PORTABILITY
+These routines emulate the System V menu library. They were not supported on
+Version 7 or BSD versions.
+.SH AUTHORS
+Juergen Pfeifer. Manual pages and adaptation for new curses by Eric
+S. Raymond.
+.\"#
+.\"# The following sets edit modes for GNU EMACS
+.\"# Local Variables:
+.\"# mode:nroff
+.\"# fill-column:79
+.\"# End:
diff --git a/lib/libmenu/menu_driver.3 b/lib/libmenu/menu_driver.3
new file mode 100644
index 00000000000..dc571056c73
--- /dev/null
+++ b/lib/libmenu/menu_driver.3
@@ -0,0 +1,122 @@
+'\" t
+.TH menu_driver 3X ""
+.SH NAME
+\fBmenu_driver\fR - command-processing loop of the menu system
+.SH SYNOPSIS
+\fB#include <menu.h>\fR
+.br
+int menu_driver(MENU *menu, int c);
+.br
+.SH DESCRIPTION
+Once a menu has been posted (displayed), you should funnel input events to it
+through \fBmenu_driver\fR. This routine has two major input cases; either
+the input is a menu navigation request or it's a printable ASCII character.
+The menu driver requests are as follows:
+.TP 5
+REQ_LEFT_ITEM
+Move left to an item.
+.TP 5
+REQ_RIGHT_ITEM
+Move right to an item.
+.TP 5
+REQ_UP_ITEM
+Move up to an item.
+.TP 5
+REQ_DOWN_ITEM
+Move down to an item.
+.TP 5
+REQ_SCR_ULINE
+Scroll up a line.
+.TP 5
+REQ_SCR_DLINE
+Scroll down a line.
+.TP 5
+REQ_SCR_DPAGE
+Scroll down a page.
+.TP 5
+REQ_SCR_UPAGE
+Scroll up a page.
+.TP 5
+REQ_FIRST_ITEM
+Move to the first item.
+.TP 5
+REQ_LAST_ITEM
+Move to the last item.
+.TP 5
+REQ_NEXT_ITEM
+Move to the next item.
+.TP 5
+REQ_PREV_ITEM
+Move to the previous item.
+.TP 5
+REQ_TOGGLE_ITEM
+Select/deselect an item.
+.TP 5
+REQ_CLEAR_PATTERN
+Clear the menu pattern buffer.
+.TP 5
+REQ_BACK_PATTERN
+Delete the previous character from the pattern buffer.
+.TP 5
+REQ_NEXT_MATCH
+Move to the next item matching the pattern match.
+.TP 5
+REQ_PREV_MATCH
+Move to the previous item matching the pattern match.
+.PP
+If the second argument is a printable ASCII character, the code appends
+it to the pattern buffer and attempts to move to the next item matching
+the new pattern. If there is no such match, \fBmenu_driver\fR returns
+\fBE_NO_MATCH\fR and deletes the appended character from the buffer.
+.PP
+If the second argument is one of the above pre-defined requests, the
+corresponding action is performed.
+.PP
+If the second argument is neither printable ASCII nor one of the above
+pre-defined menu requests, the drive asumes it is an application-specific
+command and returns \fBE_UNKNOWN_COMMAND\fR. Application-defined commands
+should be defined relative to \fBMAX_COMMAND\fR, the maximum value of these
+pre-defined requests.
+.SH RETURN VALUE
+\fBmenu_driver\fR return one of the following error codes:
+.TP 5
+\fBE_OK\fR
+The routine succeeded.
+.TP 5
+\fBE_SYSTEM_ERROR\fR
+System error occurred (see \fBerrno\fR).
+.TP 5
+\fBE_BAD_ARGUMENT\fR
+Routine detected an incorrect or out-of-range argument.
+.TP 5
+\fBE_BAD_STATE\fR
+Routine was called from an initialization or termination function.
+.TP 5
+\fBE_NOT_POSTED\fR
+The menu has not been posted.
+.TP 5
+\fBE_UNKNOWN_COMMAND\fR
+The menu driver code saw an unknown request code.
+.TP 5
+\fBE_NO_MATCH\fR
+Character failed to match.
+.TP 5
+\fBE_REQUEST_DENIED\fR
+The menu driver could not process the request.
+.SH SEE ALSO
+\fBcurses\fR(3X), \fBmenus\fR(3x).
+.SH NOTES
+The header file \fB<menu.h>\fR automatically includes the header files
+\fB<curses.h>\fR.
+.SH PORTABILITY
+These routines emulate the System V menu library. They were not supported on
+Version 7 or BSD versions.
+.SH AUTHORS
+Juergen Pfeifer. Manual pages and adaptation for new curses by Eric
+S. Raymond.
+.\"#
+.\"# The following sets edit modes for GNU EMACS
+.\"# Local Variables:
+.\"# mode:nroff
+.\"# fill-column:79
+.\"# End:
diff --git a/lib/libmenu/menu_format.3 b/lib/libmenu/menu_format.3
new file mode 100644
index 00000000000..04ac9edcf1d
--- /dev/null
+++ b/lib/libmenu/menu_format.3
@@ -0,0 +1,54 @@
+'\" t
+.TH menu_format 3X ""
+.SH NAME
+\fBmenu_format\fR - set and get menu sizes
+.SH SYNOPSIS
+\fB#include <menu.h>\fR
+.br
+int set_menu_format(MENU *menu, int rows, int cols);
+.br
+int menu_format(MENU *menu, int *rows, int *cols);
+.br
+.SH DESCRIPTION
+The function \fBset_menu_format\fR sets the maximum display size of the given
+window. If this size is too small to display all menu items, the menu will be
+made scrollable.
+
+The default format is 16 rows, 1 column. Calling \fBset_menu_format\fR with a
+null menu pointer will change this default. A zero row or column argument to
+\fBset_menu_format\fR is interpreted as a request not to change the current
+value.
+
+The function \fBget_menu_format\fR returns the maximum-size constraints for the
+given menu into the storage addressed by \fBrows\fR and \fBcols\fR.
+.SH RETURN VALUE
+These routines returns one of the following:
+.TP 5
+\fBE_OK\fR
+The routine succeeded.
+.TP 5
+\fBE_SYSTEM_ERROR\fR
+System error occurred (see \fBerrno\fR).
+.TP 5
+\fBE_BAD_ARGUMENT\fR
+Routine detected an incorrect or out-of-range argument.
+.TP 5
+\fBE_POSTED\fR
+The menu is already posted.
+.SH SEE ALSO
+\fBcurses\fR(3X), \fBmenu\fR(3X).
+.SH NOTES
+The header file \fB<menu.h>\fR automatically includes the header file
+\fB<curses.h>\fR.
+.SH PORTABILITY
+These routines emulate the System V menu library. They were not supported on
+Version 7 or BSD versions.
+.SH AUTHORS
+Juergen Pfeifer. Manual pages and adaptation for new curses by Eric
+S. Raymond.
+.\"#
+.\"# The following sets edit modes for GNU EMACS
+.\"# Local Variables:
+.\"# mode:nroff
+.\"# fill-column:79
+.\"# End:
diff --git a/lib/libmenu/menu_hook.3 b/lib/libmenu/menu_hook.3
new file mode 100644
index 00000000000..85d1dea6931
--- /dev/null
+++ b/lib/libmenu/menu_hook.3
@@ -0,0 +1,72 @@
+'\" t
+.TH menu_hook 3X ""
+.SH NAME
+\fBmenu_hook\fR - set hooks for automatic invocation by applications
+.SH SYNOPSIS
+\fB#include <menu.h>\fR
+.br
+int set_item_init(MENU *menu, void (*func)(MENU *));
+.br
+void (*)(MENU *) item_init(MWNU *menu);
+.br
+int set_item_term(MENU *menu, void (*func)(MENU *));
+.br
+void (*)(MENU *) item_term(MWNU *menu);
+.br
+int set_menu_init(MENU *menu, void (*func)(MENU *));
+.br
+void (*)(MENU *) menu_init(MWNU *menu);
+.br
+int set_menu_term(MENU *menu, void (*func)(MENU *));
+.br
+void (*)(MENU *) menu_term(MWNU *menu);
+.br
+.SH DESCRIPTION
+These functions make it possible to set hook functions to be called at various
+points in the automatic processing of input event codes by \fBmenu_driver\fR.
+
+The function \fBset_item_init\fR sets a hook to be called at menu-post time and
+each time the selected item changes (after the change). \fBitem_init\fR
+returns the current item init hook, if any (\fBNULL\fR if there is no such
+hook).
+
+The function \fBset_item_term\fR sets a hook to be called at menu-unpost time
+and each time the selected item changes (before the change). \fBitem_term\fR
+returns the current item term hook, if any (\fBNULL\fR if there is no such
+hook).
+
+The function \fBset_menu_init\fR sets a hook to be called at menu-post time and
+just after the top row on the menu changes once it is posted. \fBmenu_init\fR
+returns the current menu init hook, if any (\fBNULL\fR if there is no such
+hook).
+
+The function \fBset_menu_term\fR sets a hook to be called at menu-unpost time
+and just before the top row on the menu changes once it is posted.
+\fBmenu_term\fR returns the current menu term hook, if any (\fBNULL\fR if there
+is no such hook).
+.SH RETURN VALUE
+Routines that return pointers return \fBNULL\fR on error. Other routines
+return one of the following:
+.TP 5
+\fBE_OK\fR
+The routine succeeded.
+.TP 5
+\fBE_SYSTEM_ERROR\fR
+System error occurred (see \fBerrno\fR).
+.SH SEE ALSO
+\fBcurses\fR(3X), \fBmenu\fR(3X).
+.SH NOTES
+The header file \fB<menu.h>\fR automatically includes the header file
+\fB<curses.h>\fR.
+.SH PORTABILITY
+These routines emulate the System V menu library. They were not supported on
+Version 7 or BSD versions.
+.SH AUTHORS
+Juergen Pfeifer. Manual pages and adaptation for new curses by Eric
+S. Raymond.
+.\"#
+.\"# The following sets edit modes for GNU EMACS
+.\"# Local Variables:
+.\"# mode:nroff
+.\"# fill-column:79
+.\"# End:
diff --git a/lib/libmenu/menu_items.3 b/lib/libmenu/menu_items.3
new file mode 100644
index 00000000000..4545ccce538
--- /dev/null
+++ b/lib/libmenu/menu_items.3
@@ -0,0 +1,62 @@
+'\" t
+.TH menu_items 3X ""
+.SH NAME
+\fBmenu_items\fR - make and break connections between items and menus
+.SH SYNOPSIS
+\fB#include <menu.h>\fR
+.br
+int set_menu_items(MENU *menu, ITEM **items);
+.br
+ITEM **menu_items(MENU *menu);
+.br
+int item_count(MENU *menu);
+.br
+.SH DESCRIPTION
+The function \fBset_menu_items\fR changes the item pointer array of the given
+\fImenu\fR. The array must be terminated by a \fBNULL\fR.
+
+The function \fBmenu_items\fR returns the item array of the given menu.
+
+The function \fBitem_count\fR returns the count of items in \fImenu\fR.
+.SH RETURN VALUES
+The function \fBmenu_items\fR returns \fBNULL\fR on error.
+
+The function \fBitem_count\fR returns \fBERR\fR (the general \fBcurses\fR error
+return value) on error.
+
+The function \fBset_menu_items\fR returns one of the following codes on error:
+.TP 5
+\fBE_OK\fR
+The routine succeeded.
+.TP 5
+\fBE_SYSTEM_ERROR\fR
+System error occurred (see \fBerrno\fR).
+.TP 5
+\fBE_BAD_ARGUMENT\fR
+Routine detected an incorrect or out-of-range argument.
+.TP 5
+\fBE_POSTED\fR
+The menu is already posted.
+.TP 5
+\fBE_NOT_CONNECTED\fR
+No items are connected to the menu.
+.SH SEE ALSO
+\fBcurses\fR(3X), \fBmenu\fR(3X).
+.SH NOTES
+The header file \fB<menu.h>\fR automatically includes the header file
+\fB<curses.h>\fR.
+.SH PORTABILITY
+These routines emulate the System V menu library. They were not supported on
+Version 7 or BSD versions.
+
+The SVr4 menu library documentation specifies the \fBitem_count\fR error value
+as -1 (which is the value of \fBERR\fR).
+.SH AUTHORS
+Juergen Pfeifer. Manual pages and adaptation for new curses by Eric
+S. Raymond.
+.\"#
+.\"# The following sets edit modes for GNU EMACS
+.\"# Local Variables:
+.\"# mode:nroff
+.\"# fill-column:79
+.\"# End:
diff --git a/lib/libmenu/menu_mark.3 b/lib/libmenu/menu_mark.3
new file mode 100644
index 00000000000..61fef90afd5
--- /dev/null
+++ b/lib/libmenu/menu_mark.3
@@ -0,0 +1,55 @@
+'\" t
+.TH menu_mark 3X ""
+.SH NAME
+\fBmenu_mark\fR - get and set the menu mark string
+.SH SYNOPSIS
+\fB#include <menu.h>\fR
+.br
+int set_menu_mark(MENU *menu, char *mark);
+.br
+char *menu_mark(MENU *menu);
+.br
+.SH DESCRIPTION
+In order to make menu selections visible on older terminals without
+highlighting or color capability, the menu library marks selected items
+in a menu with a prefix string.
+
+The function \fBset_menu_mark\fR sets the mark string for the given menu.
+Calling \fBset_menu_mark\fR with a null menu item will abolish the mark string.
+Note that changing the length of the mark string for a menu while the
+menu is posted is likely to produce unhelpful behavior.
+
+The default string is "-" (a dash). Calling \fBset_menu_mark\fR wiith
+a \fBNULL\fR menu argument will change this default.
+
+The function \fBmenu_mark\fR returns the menu's mark string (or \fBNULL\fR if
+there is none).
+.SH RETURN VALUE
+The function \fBmenu_mark\fR returns \fBNULL\fR on error. The function
+\fBset_menu_mark\fR maty return the following error codes:
+.TP 5
+\fBE_OK\fR
+The routine succeeded.
+.TP 5
+\fBE_SYSTEM_ERROR\fR
+System error occurred (see \fBerrno\fR).
+.TP 5
+\fBE_BAD_ARGUMENT\fR
+Routine detected an incorrect or out-of-range argument.
+.SH SEE ALSO
+\fBcurses\fR(3X), \fBmenu\fR(3X).
+.SH NOTES
+The header file \fB<menu.h>\fR automatically includes the header file
+\fB<curses.h>\fR.
+.SH PORTABILITY
+These routines emulate the System V menu library. They were not supported on
+Version 7 or BSD versions.
+.SH AUTHORS
+Juergen Pfeifer. Manual pages and adaptation for new curses by Eric
+S. Raymond.
+.\"#
+.\"# The following sets edit modes for GNU EMACS
+.\"# Local Variables:
+.\"# mode:nroff
+.\"# fill-column:79
+.\"# End:
diff --git a/lib/libmenu/menu_new.3 b/lib/libmenu/menu_new.3
new file mode 100644
index 00000000000..b7585dc0b40
--- /dev/null
+++ b/lib/libmenu/menu_new.3
@@ -0,0 +1,50 @@
+'\" t
+.TH menu_new 3X ""
+.SH NAME
+\fBmenu_new\fR - create and destroy menus
+.SH SYNOPSIS
+\fB#include <menu.h>\fR
+.br
+MENU *new_menu(ITEM **items);
+.br
+char *free_menu(MENU *menu);
+.br
+.SH DESCRIPTION
+The function \fBnew_menu\fR creates a new menu connected to a specified item
+pointer array (which must be \fBNULL\fR-terminated).
+
+The function \fBfree_menu\fR discomnnects \fImenu\fR from its item array
+and frees the storage allocated for the menu.
+.SH RETURN VALUE
+The function \fBnew_menu\fR returns \fBNULL\fR on error.
+
+The function \fBfree_menu\fR returns one of the following:
+.TP 5
+\fBE_OK\fR
+The routine succeeded.
+.TP 5
+\fBE_SYSTEM_ERROR\fR
+System error occurred (see \fBerrno\fR).
+.TP 5
+\fBE_BAD_ARGUMENT\fR
+Routine detected an incorrect or out-of-range argument.
+.TP 5
+\fBE_POSTED\fR
+The menu has already been posted.
+.SH SEE ALSO
+\fBcurses\fR(3X), \fBmenu\fR(3X).
+.SH NOTES
+The header file \fB<menu.h>\fR automatically includes the header file
+\fB<curses.h>\fR.
+.SH PORTABILITY
+These routines emulate the System V menu library. They were not supported on
+Version 7 or BSD versions.
+.SH AUTHORS
+Juergen Pfeifer. Manual pages and adaptation for new curses by Eric
+S. Raymond.
+.\"#
+.\"# The following sets edit modes for GNU EMACS
+.\"# Local Variables:
+.\"# mode:nroff
+.\"# fill-column:79
+.\"# End:
diff --git a/lib/libmenu/menu_opts.3 b/lib/libmenu/menu_opts.3
new file mode 100644
index 00000000000..b307936fb74
--- /dev/null
+++ b/lib/libmenu/menu_opts.3
@@ -0,0 +1,75 @@
+'\" t
+.TH menu_opts 3X ""
+.SH NAME
+\fBmenu_opts\fR - set and get menu options
+.SH SYNOPSIS
+\fB#include <menu.h>\fR
+.br
+int set_menu_opts(MENU *menu, OPTIONS opts);
+.br
+int menu_opts_on(MENU *menu, OPTIONS opts);
+.br
+int menu_opts_off(MENU *menu, OPTIONS opts);
+.br
+OPTIONS menu_opts(MENU *menu);
+.br
+.SH DESCRIPTION
+The function \fBset_menu_opts\fR sets all the given menu's option bits (menu
+option bits may be logically-ored together).
+
+The function \fBmenu_opts_on\fR turns on the given option bits, and leaves
+others alone.
+
+The function \fBmenu_opts_off\fR turns off the given option bits, and leaves
+others alone.
+
+The function \fBmenu_opts\fR returns the menu's current option bits.
+
+The following options are defined (all are on by default):
+.TP 5
+O_ONEVALUE
+Only one item can be selected for this menu.
+.TP 5
+O_SHOWDESC
+Display the item descriptions when the menu is posted.
+.TP 5
+O_ROWMAJOR
+Display the menu in row-major order.
+.TP 5
+O_IGNORECASE
+Ignore the case when pattern-matching.
+.TP 5
+O_SHOWMATCH
+Move the cursor to within the item name while pattern-matching.
+.TP 5
+O_NONCYCLIC
+Don't wrap around next-item and previous-item,
+requests to the other end of the menu.
+.SH RETURN VALUE
+Except for \fBmenu_opts\fR, each routine returns one of the following:
+.TP 5
+\fBE_OK\fR
+The routine succeeded.
+.TP 5
+\fBE_SYSTEM_ERROR\fR
+System error occurred (see \fBerrno\fR).
+.TP 5
+\fBE_POSTED\fR
+The menu is already posted.
+.SH SEE ALSO
+\fBcurses\fR(3X), \fBmenu\fR(3X).
+.SH NOTES
+The header file \fB<menu.h>\fR automatically includes the header file
+\fB<curses.h>\fR.
+.SH PORTABILITY
+These routines emulate the System V menu library. They were not supported on
+Version 7 or BSD versions.
+.SH AUTHORS
+Juergen Pfeifer. Manual pages and adaptation for new curses by Eric
+S. Raymond.
+.\"#
+.\"# The following sets edit modes for GNU EMACS
+.\"# Local Variables:
+.\"# mode:nroff
+.\"# fill-column:79
+.\"# End:
diff --git a/lib/libmenu/menu_pattern.3 b/lib/libmenu/menu_pattern.3
new file mode 100644
index 00000000000..233ba35e0a8
--- /dev/null
+++ b/lib/libmenu/menu_pattern.3
@@ -0,0 +1,54 @@
+'\" t
+.TH menu_pattern 3X ""
+.SH NAME
+\fBmenu_pattern\fR - get and set a menu's pattern buffer
+.SH SYNOPSIS
+\fB#include <menu.h>\fR
+.br
+int set_menu_pattern(MENU *menu, char *pattern);
+.br
+char *menu_pattern(MENU *menu);
+.br
+.SH DESCRIPTION
+Every menu has an associated pattern match buffer. As input events that are
+printable ASCII characters come in, they are appended to this match buffer
+and tested for a match, as decribed in \fBmenu_driver\fR(3x).
+
+The function \fBset_menu_pattern\fR sets the pattern buffer for the given menu
+and tries to find the first matching item. If it succeeds, that item becomes
+current; if not, the current item does not change.
+
+The function \fBmenu_pattern\fR returns the pattern buffer of the given
+\fImenu\fR.
+.SH RETURN VALUE
+The function \fBmenu_pattern\fR returns \fBNULL\fR on error. The function
+\fBset_menu_pattern\fR maty return the following error codes:
+.TP 5
+\fBE_OK\fR
+The routine succeeded.
+.TP 5
+\fBE_SYSTEM_ERROR\fR
+System error occurred (see \fBerrno\fR).
+.TP 5
+\fBE_BAD_ARGUMENT\fR
+Routine detected an incorrect or out-of-range argument.
+.TP 5
+\fBE_NO_MATCH\fR
+Character failed to match.
+.SH SEE ALSO
+\fBcurses\fR(3X), \fBmenu\fR(3X).
+.SH NOTES
+The header file \fB<menu.h>\fR automatically includes the header file
+\fB<curses.h>\fR.
+.SH PORTABILITY
+These routines emulate the System V menu library. They were not supported on
+Version 7 or BSD versions.
+.SH AUTHORS
+Juergen Pfeifer. Manual pages and adaptation for new curses by Eric
+S. Raymond.
+.\"#
+.\"# The following sets edit modes for GNU EMACS
+.\"# Local Variables:
+.\"# mode:nroff
+.\"# fill-column:79
+.\"# End:
diff --git a/lib/libmenu/menu_post.3 b/lib/libmenu/menu_post.3
new file mode 100644
index 00000000000..21e39aa5dd9
--- /dev/null
+++ b/lib/libmenu/menu_post.3
@@ -0,0 +1,61 @@
+'\" t
+.TH menu_post 3X ""
+.SH NAME
+\fBmenu_post\fR - write or erase menus from associated subwindows
+.SH SYNOPSIS
+\fB#include <menu.h>\fR
+.br
+int post_menu(MENU *menu);
+.br
+int unpost_menu(MENU *menu);
+.br
+.SH DESCRIPTION
+The function \fBpost_menu\fR displays a menu to its associated subwindow. To
+trigger physical display of the subwindow, use \fBrefresh\fR or some equivalent
+\fBcurses\fR routine (the implicit \fBdoupdate\fR triggered by an \fBcurses\fR
+input request will do).
+
+The function \fBunpost_menu\fR erases menu from its associated subwindow.
+.SH RETURN VALUE
+These routines return one of the following:
+.TP 5
+\fBE_OK\fR
+The routine succeeded.
+.TP 5
+\fBE_SYSTEM_ERROR\fR
+System error occurred (see \fBerrno\fR).
+.TP 5
+\fBE_BAD_ARGUMENT\fR
+Routine detected an incorrect or out-of-range argument.
+.TP 5
+\fBE_POSTED\fR
+The menu has already been posted.
+.TP 5
+\fBE_BAD_STATE\fR
+Routine was called from an initialization or termination function.
+.TP 5
+\fBE_NO_ROOM\fR
+Menu is too large for its window.
+.TP 5
+\fBE_NOT_POSTED\fR
+The menu has not been posted.
+.TP 5
+\fBE_NOT_CONNECTED\fR
+No items are connected to the menu.
+.SH SEE ALSO
+\fBcurses\fR(3X), \fBmenu\fR(3X).
+.SH NOTES
+The header file \fB<menu.h>\fR automatically includes the header file
+\fB<curses.h>\fR.
+.SH PORTABILITY
+These routines emulate the System V menu library. They were not supported on
+Version 7 or BSD versions.
+.SH AUTHORS
+Juergen Pfeifer. Manual pages and adaptation for new curses by Eric
+S. Raymond.
+.\"#
+.\"# The following sets edit modes for GNU EMACS
+.\"# Local Variables:
+.\"# mode:nroff
+.\"# fill-column:79
+.\"# End:
diff --git a/lib/libmenu/menu_userptr.3 b/lib/libmenu/menu_userptr.3
new file mode 100644
index 00000000000..fab891f7869
--- /dev/null
+++ b/lib/libmenu/menu_userptr.3
@@ -0,0 +1,44 @@
+'\" t
+.TH menu_userptr 3X ""
+.SH NAME
+\fBmenu_userptr\fR - associate application data with a menu item
+.SH SYNOPSIS
+\fB#include <menu.h>\fR
+.br
+int set_menu_userptr(MENU *menu, char *userptr);
+.br
+char menu_userptr(MENU *menu);
+.br
+.SH DESCRIPTION
+Every menu and every menu item has a field that can be used to hold
+application-specific data (that is, the menu-driver code leaves it alone).
+These functions get and set the menu user pointer field.
+.SH RETURN VALUE
+Except for \fBmenu_userptr\fR (which returns \fBNULL\fR on error), each
+function returns one of the following:
+.TP 5
+\fBE_OK\fR
+The routine succeeded.
+.TP 5
+\fBE_SYSTEM_ERROR\fR
+System error occurred (see \fBerrno\fR).
+.SH SEE ALSO
+\fBcurses\fR(3X), \fBmenu\fR(3X).
+.SH NOTES
+The header file \fB<menu.h>\fR automatically includes the header file
+\fB<curses.h>\fR.
+.SH PORTABILITY
+These routines emulate the System V menu library. They were not supported on
+Version 7 or BSD versions.
+
+The user pointer should be a void pointer. We leave it as a char pointer for
+SVr4 compatibility.
+.SH AUTHORS
+Juergen Pfeifer. Manual pages and adaptation for new curses by Eric
+S. Raymond.
+.\"#
+.\"# The following sets edit modes for GNU EMACS
+.\"# Local Variables:
+.\"# mode:nroff
+.\"# fill-column:79
+.\"# End:
diff --git a/lib/libmenu/menu_win.3 b/lib/libmenu/menu_win.3
new file mode 100644
index 00000000000..5f492124ca9
--- /dev/null
+++ b/lib/libmenu/menu_win.3
@@ -0,0 +1,66 @@
+'\" t
+.TH menu_win 3X ""
+.SH NAME
+\fBmenu_win\fR - make and break menu window and subwindow associations
+.SH SYNOPSIS
+\fB#include <menu.h>\fR
+.br
+int set_menu_window(MENU *menu, WINDOW *win);
+.br
+WINDOW *menu_window(MENU *menu);
+.br
+int set_menu_sub(MENU *menu, WINDOW *sub);
+.br
+WINDOW *menu_sub(MENU *menu);
+.br
+int scale_window(MENU *menu, int *rows, int *columns);
+.br
+.SH DESCRIPTION
+Every menu has an associated pair of \fBcurses\fR windows. The menu window
+displays any title and border associated with the window; the menu subwindow
+displays the items of the menu that are currently available for selection.
+
+The first four functions get and set those windows. It is not necessary to set
+either window; by default, the driver code uses \fBstdscr\fR for both.
+
+In the \fBset_\fR functions, window argument of \fBNULL\fR is treated as tbough
+it were \fBstsdcr\fR. A menu argument of \fBNULL\fR is treated as a request
+to change the system default menu window or subwindow.
+
+The function \fBscale_window\fR returns the minimum size required for the
+subwindow of \fImenu\fR.
+.SH RETURN VALUE
+Routines that return pointers return \fBNULL\fR on error. Routines that return
+an integer return one of the following error codes:
+.TP 5
+\fBE_OK\fR
+The routine succeeded.
+.TP 5
+\fBE_SYSTEM_ERROR\fR
+System error occurred (see \fBerrno\fR).
+.TP 5
+\fBE_BAD_ARGUMENT\fR
+Routine detected an incorrect or out-of-range argument.
+.TP 5
+\fBE_POSTED\fR
+The menu has already been posted.
+.TP 5
+\fBE_NOT_CONNECTED\fR
+No items are connected to the menu.
+.SH SEE ALSO
+\fBcurses\fR(3X), \fBmenu\fR(3X).
+.SH NOTES
+The header file \fB<menu.h>\fR automatically includes the header file
+\fB<curses.h>\fR.
+.SH PORTABILITY
+These routines emulate the System V menu library. They were not supported on
+Version 7 or BSD versions.
+.SH AUTHORS
+Juergen Pfeifer. Manual pages and adaptation for new curses by Eric
+S. Raymond.
+.\"#
+.\"# The following sets edit modes for GNU EMACS
+.\"# Local Variables:
+.\"# mode:nroff
+.\"# fill-column:79
+.\"# End:
diff --git a/lib/libmenu/mf_common.h b/lib/libmenu/mf_common.h
new file mode 100644
index 00000000000..518c3f49e10
--- /dev/null
+++ b/lib/libmenu/mf_common.h
@@ -0,0 +1,67 @@
+
+/***************************************************************************
+* COPYRIGHT NOTICE *
+****************************************************************************
+* ncurses is copyright (C) 1992-1995 *
+* Zeyd M. Ben-Halim *
+* zmbenhal@netcom.com *
+* Eric S. Raymond *
+* esr@snark.thyrsus.com *
+* *
+* Permission is hereby granted to reproduce and distribute ncurses *
+* by any means and for any fee, whether alone or as part of a *
+* larger distribution, in source or in binary form, PROVIDED *
+* this notice is included with any such distribution, and is not *
+* removed from any of its header files. Mention of ncurses in any *
+* applications linked with it is highly appreciated. *
+* *
+* ncurses comes AS IS with no warranty, implied or expressed. *
+* *
+***************************************************************************/
+
+/* Common internal header for menu and form library */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <stdlib.h>
+#include <assert.h>
+#include <string.h>
+#include <ctype.h>
+
+#if !HAVE_EXTERN_ERRNO
+extern int errno;
+#endif
+
+#if HAVE_EXTERN_ERRNO
+#include <errno.h>
+#endif
+
+/* in case of debug version we ignore the suppression of assertions */
+#ifdef TRACE
+# ifdef NDEBUG
+# undef NDEBUG
+# endif
+#endif
+
+/* Maximum regular 8-bit character code */
+#define MAX_REGULAR_CHARACTER (0xff)
+
+#define SET_ERROR(code) (errno=(code))
+#define RETURN(code) return( SET_ERROR(code) )
+
+/* The few common values in the status fields for menus and forms */
+#define _POSTED (0x01) /* menu or form is posted */
+#define _IN_DRIVER (0x02) /* menu or form is processing hook routine */
+
+/* Call object hook */
+#define Call_Hook( object, handler ) \
+ if ( (object) && ((object)->handler) )\
+ {\
+ (object)->status |= _IN_DRIVER;\
+ (object)->handler(object);\
+ (object)->status &= ~_IN_DRIVER;\
+ }
+
+#define INLINE __inline
diff --git a/lib/libmenu/shlib_version b/lib/libmenu/shlib_version
new file mode 100644
index 00000000000..97c9f92d6b8
--- /dev/null
+++ b/lib/libmenu/shlib_version
@@ -0,0 +1,2 @@
+major=0
+minor=0