summaryrefslogtreecommitdiff
path: root/lib/libmenu
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2010-01-12 23:22:15 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2010-01-12 23:22:15 +0000
commit6ee254699bf787d78835419be2b3241fb037d444 (patch)
tree07fe67dab517e4990f344fe2c00e65cef4d25b81 /lib/libmenu
parent0b62f5dc36fc7203a74cdc812c4234ae188fdfd2 (diff)
Update to ncurses 5.7, with local changes reapplied.
This is around eight years worth of changes (previously we were around ncurses 5.2), too many to list - many bug fixes and also a few new functions. A major bump for libcurses, libpanel, libform and libmenu. ok deraadt
Diffstat (limited to 'lib/libmenu')
-rw-r--r--lib/libmenu/Makefile4
-rw-r--r--lib/libmenu/READ.ME42
-rw-r--r--lib/libmenu/eti.h12
-rw-r--r--lib/libmenu/m_attribs.c28
-rw-r--r--lib/libmenu/m_cursor.c41
-rw-r--r--lib/libmenu/m_driver.c670
-rw-r--r--lib/libmenu/m_format.c72
-rw-r--r--lib/libmenu/m_global.c429
-rw-r--r--lib/libmenu/m_hook.c28
-rw-r--r--lib/libmenu/m_item_cur.c34
-rw-r--r--lib/libmenu/m_item_nam.c20
-rw-r--r--lib/libmenu/m_item_new.c133
-rw-r--r--lib/libmenu/m_item_opt.c61
-rw-r--r--lib/libmenu/m_item_top.c45
-rw-r--r--lib/libmenu/m_item_use.c18
-rw-r--r--lib/libmenu/m_item_val.c30
-rw-r--r--lib/libmenu/m_item_vis.c27
-rw-r--r--lib/libmenu/m_items.c38
-rw-r--r--lib/libmenu/m_new.c38
-rw-r--r--lib/libmenu/m_opts.c53
-rw-r--r--lib/libmenu/m_pad.c29
-rw-r--r--lib/libmenu/m_pattern.c59
-rw-r--r--lib/libmenu/m_post.c273
-rw-r--r--lib/libmenu/m_req_name.c80
-rw-r--r--lib/libmenu/m_scale.c21
-rw-r--r--lib/libmenu/m_spacing.c43
-rw-r--r--lib/libmenu/m_sub.c24
-rw-r--r--lib/libmenu/m_trace.c (renamed from lib/libmenu/m_adabind.c)62
-rw-r--r--lib/libmenu/m_userptr.c18
-rw-r--r--lib/libmenu/m_win.c24
-rw-r--r--lib/libmenu/menu.3tbl73
-rw-r--r--lib/libmenu/menu.h18
-rw-r--r--lib/libmenu/menu.priv.h44
-rw-r--r--lib/libmenu/menu_attributes.322
-rw-r--r--lib/libmenu/menu_cursor.314
-rw-r--r--lib/libmenu/menu_driver.3105
-rw-r--r--lib/libmenu/menu_format.323
-rw-r--r--lib/libmenu/menu_hook.334
-rw-r--r--lib/libmenu/menu_items.338
-rw-r--r--lib/libmenu/menu_mark.330
-rw-r--r--lib/libmenu/menu_new.325
-rw-r--r--lib/libmenu/menu_opts.328
-rw-r--r--lib/libmenu/menu_pattern.339
-rw-r--r--lib/libmenu/menu_post.324
-rw-r--r--lib/libmenu/menu_requestname.314
-rw-r--r--lib/libmenu/menu_spacing.312
-rw-r--r--lib/libmenu/menu_userptr.324
-rw-r--r--lib/libmenu/menu_win.322
-rw-r--r--lib/libmenu/mf_common.h40
-rw-r--r--lib/libmenu/mitem_current.335
-rw-r--r--lib/libmenu/mitem_name.313
-rw-r--r--lib/libmenu/mitem_new.327
-rw-r--r--lib/libmenu/mitem_opts.326
-rw-r--r--lib/libmenu/mitem_userptr.324
-rw-r--r--lib/libmenu/mitem_value.314
-rw-r--r--lib/libmenu/mitem_visible.34
-rw-r--r--lib/libmenu/shlib_version2
57 files changed, 1824 insertions, 1406 deletions
diff --git a/lib/libmenu/Makefile b/lib/libmenu/Makefile
index ede206b1067..fbf5facbe93 100644
--- a/lib/libmenu/Makefile
+++ b/lib/libmenu/Makefile
@@ -1,10 +1,10 @@
LIB= menu
WANTLINT=
-SRCS= m_adabind.c m_attribs.c m_cursor.c m_driver.c m_format.c \
+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_top.c m_item_use.c m_item_val.c m_item_vis.c \
m_items.c m_new.c m_opts.c m_pad.c m_pattern.c m_post.c \
- m_req_name.c m_scale.c m_spacing.c m_sub.c m_userptr.c m_win.c
+ m_req_name.c m_scale.c m_spacing.c m_sub.c m_trace.c m_userptr.c m_win.c
HDRS= menu.h eti.h
CFLAGS+=-I${.CURDIR} -I${.CURDIR}/../libcurses -DHAVE_CONFIG_H
MAN= menu.3tbl menu_attributes.3 menu_cursor.3 menu_driver.3 menu_format.3 \
diff --git a/lib/libmenu/READ.ME b/lib/libmenu/READ.ME
new file mode 100644
index 00000000000..56f1715cc04
--- /dev/null
+++ b/lib/libmenu/READ.ME
@@ -0,0 +1,42 @@
+-------------------------------------------------------------------------------
+-- Copyright (c) 1998-2003,2006 Free Software Foundation, Inc. --
+-- --
+-- Permission is hereby granted, free of charge, to any person obtaining a --
+-- copy of this software and associated documentation files (the --
+-- "Software"), to deal in the Software without restriction, including --
+-- without limitation the rights to use, copy, modify, merge, publish, --
+-- distribute, distribute with modifications, sublicense, and/or sell copies --
+-- of the Software, and to permit persons to whom the Software is furnished --
+-- to do so, subject to the following conditions: --
+-- --
+-- The above copyright notice and this permission notice shall be included --
+-- in all copies or substantial portions of the Software. --
+-- --
+-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS --
+-- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF --
+-- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN --
+-- NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, --
+-- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR --
+-- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE --
+-- USE OR OTHER DEALINGS IN THE SOFTWARE. --
+-- --
+-- Except as contained in this notice, the name(s) of the above copyright --
+-- holders shall not be used in advertising or otherwise to promote the --
+-- sale, use or other dealings in this Software without prior written --
+-- authorization. --
+-------------------------------------------------------------------------------
+-- $Id: READ.ME,v 1.4 2010/01/12 23:22:07 nicm Exp $
+-------------------------------------------------------------------------------
+
+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).
+
+The development environment was and is an ELF based Linux system.
+
+For things that still need doing, see the TO-DO file in the top-level
+directory.
+
+Juergen Pfeifer
diff --git a/lib/libmenu/eti.h b/lib/libmenu/eti.h
index bf037d83143..d0df2de14be 100644
--- a/lib/libmenu/eti.h
+++ b/lib/libmenu/eti.h
@@ -1,7 +1,7 @@
-/* $OpenBSD: eti.h,v 1.5 1999/05/17 03:04:18 millert Exp $ */
+/* $OpenBSD: eti.h,v 1.6 2010/01/12 23:22:07 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,11 +29,13 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
-#ifndef _ETI_ERRNO_H_
-#define _ETI_ERRNO_H_
+/* $Id: eti.h,v 1.6 2010/01/12 23:22:07 nicm Exp $ */
+
+#ifndef NCURSES_ETI_H_incl
+#define NCURSES_ETI_H_incl 1
#define E_OK (0)
#define E_SYSTEM_ERROR (-1)
diff --git a/lib/libmenu/m_attribs.c b/lib/libmenu/m_attribs.c
index 2008b8ec113..6b7f56f038f 100644
--- a/lib/libmenu/m_attribs.c
+++ b/lib/libmenu/m_attribs.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: m_attribs.c,v 1.6 2001/01/22 18:02:02 millert Exp $ */
+/* $OpenBSD: m_attribs.c,v 1.7 2010/01/12 23:22:07 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,2004 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,7 +29,7 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
/***************************************************************************
@@ -39,7 +39,7 @@
#include "menu.priv.h"
-MODULE_ID("$From: m_attribs.c,v 1.9 2000/12/10 02:16:48 tom Exp $")
+MODULE_ID("$Id: m_attribs.c,v 1.7 2010/01/12 23:22:07 nicm Exp $")
/* Macro to redraw menu if it is posted and changed */
#define Refresh_Menu(menu) \
@@ -53,6 +53,7 @@ MODULE_ID("$From: m_attribs.c,v 1.9 2000/12/10 02:16:48 tom Exp $")
#define GEN_MENU_ATTR_SET_FCT( name ) \
NCURSES_IMPEXP int NCURSES_API set_menu_ ## name (MENU * menu, chtype attr)\
{\
+ T((T_CALLED("set_menu_" #name "(%p,%s)"), menu, _traceattr(attr)));\
if (!(attr==A_NORMAL || (attr & A_ATTRIBUTES)==attr))\
RETURN(E_BAD_ARGUMENT);\
if (menu && ( menu -> name != attr))\
@@ -64,11 +65,12 @@ NCURSES_IMPEXP int NCURSES_API set_menu_ ## name (MENU * menu, chtype attr)\
RETURN(E_OK);\
}
-/* "Template" macro to generate a function to get a menus attribute */
+/* "Template" macro to generate a function to get a menu's attribute */
#define GEN_MENU_ATTR_GET_FCT( name ) \
NCURSES_IMPEXP chtype NCURSES_API menu_ ## name (const MENU * menu)\
{\
- return (Normalize_Menu( menu ) -> name);\
+ T((T_CALLED("menu_" #name "(%p)"), menu));\
+ returnAttr(Normalize_Menu( menu ) -> name);\
}
/*---------------------------------------------------------------------------
@@ -76,14 +78,14 @@ NCURSES_IMPEXP chtype NCURSES_API menu_ ## name (const MENU * menu)\
| 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
+| valued menus this 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 )
+GEN_MENU_ATTR_SET_FCT(fore)
/*---------------------------------------------------------------------------
| Facility : libnmenu
@@ -95,7 +97,7 @@ GEN_MENU_ATTR_SET_FCT( fore )
|
| Return Values : Attribute value
+--------------------------------------------------------------------------*/
-GEN_MENU_ATTR_GET_FCT( fore )
+GEN_MENU_ATTR_GET_FCT(fore)
/*---------------------------------------------------------------------------
| Facility : libnmenu
@@ -107,7 +109,7 @@ GEN_MENU_ATTR_GET_FCT( fore )
| Return Values : E_OK - success
| E_BAD_ARGUMENT - an invalid value has been passed
+--------------------------------------------------------------------------*/
-GEN_MENU_ATTR_SET_FCT( back )
+GEN_MENU_ATTR_SET_FCT(back)
/*---------------------------------------------------------------------------
| Facility : libnmenu
@@ -118,7 +120,7 @@ GEN_MENU_ATTR_SET_FCT( back )
|
| Return Values : Attribute value
+--------------------------------------------------------------------------*/
-GEN_MENU_ATTR_GET_FCT( back )
+GEN_MENU_ATTR_GET_FCT(back)
/*---------------------------------------------------------------------------
| Facility : libnmenu
@@ -129,7 +131,7 @@ GEN_MENU_ATTR_GET_FCT( back )
| Return Values : E_OK - success
| E_BAD_ARGUMENT - an invalid value has been passed
+--------------------------------------------------------------------------*/
-GEN_MENU_ATTR_SET_FCT( grey )
+GEN_MENU_ATTR_SET_FCT(grey)
/*---------------------------------------------------------------------------
| Facility : libnmenu
@@ -139,5 +141,5 @@ GEN_MENU_ATTR_SET_FCT( grey )
|
| Return Values : Attribute value
+--------------------------------------------------------------------------*/
-GEN_MENU_ATTR_GET_FCT( grey )
+GEN_MENU_ATTR_GET_FCT(grey)
/* m_attribs.c ends here */
diff --git a/lib/libmenu/m_cursor.c b/lib/libmenu/m_cursor.c
index 4562a46efec..a9bf98c5172 100644
--- a/lib/libmenu/m_cursor.c
+++ b/lib/libmenu/m_cursor.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: m_cursor.c,v 1.7 2001/01/22 18:02:03 millert Exp $ */
+/* $OpenBSD: m_cursor.c,v 1.8 2010/01/12 23:22:07 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2004,2005 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,17 +29,17 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
/***************************************************************************
* Module m_cursor *
-* Correctly position a menus cursor *
+* Correctly position a menu's cursor *
***************************************************************************/
#include "menu.priv.h"
-MODULE_ID("$From: m_cursor.c,v 1.14 2000/12/10 02:16:48 tom Exp $")
+MODULE_ID("$Id: m_cursor.c,v 1.8 2010/01/12 23:22:07 nicm Exp $")
/*---------------------------------------------------------------------------
| Facility : libnmenu
@@ -52,24 +52,23 @@ MODULE_ID("$From: m_cursor.c,v 1.14 2000/12/10 02:16:48 tom Exp $")
| E_NOT_POSTED - Menu is not posted
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-_nc_menu_cursor_pos
-(const MENU* menu, const ITEM* item, int* pY, int* pX)
+_nc_menu_cursor_pos(const MENU * menu, const ITEM * item, int *pY, int *pX)
{
if (!menu || !pX || !pY)
- return(E_BAD_ARGUMENT);
+ return (E_BAD_ARGUMENT);
else
{
- if ((ITEM*)0 == item)
+ if ((ITEM *) 0 == item)
item = menu->curitem;
- assert(item!=(ITEM*)0);
+ assert(item != (ITEM *) 0);
- if ( !( menu->status & _POSTED ) )
- return(E_NOT_POSTED);
+ if (!(menu->status & _POSTED))
+ return (E_NOT_POSTED);
*pX = item->x * (menu->spc_cols + menu->itemlen);
*pY = (item->y - menu->toprow) * menu->spc_rows;
}
- return(E_OK);
+ return (E_OK);
}
/*---------------------------------------------------------------------------
@@ -83,24 +82,26 @@ _nc_menu_cursor_pos
| E_NOT_POSTED - Menu is not posted
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-pos_menu_cursor (const MENU * menu)
+pos_menu_cursor(const MENU * menu)
{
WINDOW *win, *sub;
- int x, y;
- int err = _nc_menu_cursor_pos(menu,(ITEM*)0,&y,&x);
+ int x = 0, y = 0;
+ int err = _nc_menu_cursor_pos(menu, (ITEM *) 0, &y, &x);
- if (E_OK==err)
+ T((T_CALLED("pos_menu_cursor(%p)"), menu));
+
+ if (E_OK == err)
{
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);
+ x += (menu->pindex + menu->marklen - 1);
- wmove(sub,y,x);
+ wmove(sub, y, x);
- if ( win != sub )
+ if (win != sub)
{
wcursyncup(sub);
wsyncup(sub);
diff --git a/lib/libmenu/m_driver.c b/lib/libmenu/m_driver.c
index ccf9a82c9c8..6e08249575b 100644
--- a/lib/libmenu/m_driver.c
+++ b/lib/libmenu/m_driver.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: m_driver.c,v 1.7 2001/01/22 18:02:03 millert Exp $ */
+/* $OpenBSD: m_driver.c,v 1.8 2010/01/12 23:22:07 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2005,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,7 +29,7 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
/***************************************************************************
@@ -39,7 +39,7 @@
#include "menu.priv.h"
-MODULE_ID("$From: m_driver.c,v 1.18 2000/12/10 02:16:48 tom Exp $")
+MODULE_ID("$Id: m_driver.c,v 1.8 2010/01/12 23:22:07 nicm Exp $")
/* Macros */
@@ -64,28 +64,31 @@ MODULE_ID("$From: m_driver.c,v 1.18 2000/12/10 02:16:48 tom Exp $")
| 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
- )
+static bool
+Is_Sub_String(
+ bool IgnoreCaseFlag,
+ const char *part,
+ const char *string
+)
{
- assert( part && string );
- if ( IgnoreCaseFlag )
+ assert(part && string);
+ if (IgnoreCaseFlag)
{
- while(*string && *part)
+ while (*string && *part)
{
- if (toupper(*string++)!=toupper(*part)) break;
+ if (toupper(UChar(*string++)) != toupper(UChar(*part)))
+ break;
part++;
}
}
else
{
- while( *string && *part )
- if (*part != *string++) break;
+ while (*string && *part)
+ if (*part != *string++)
+ break;
part++;
}
- return ( (*part) ? FALSE : TRUE );
+ return ((*part) ? FALSE : TRUE);
}
/*---------------------------------------------------------------------------
@@ -115,73 +118,77 @@ static bool Is_Sub_String(
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
_nc_Match_Next_Character_In_Item_Name
-(MENU *menu, int ch, ITEM **item)
+(MENU * menu, int ch, ITEM ** item)
{
bool found = FALSE, passed = FALSE;
- int idx, last;
+ int idx, last;
+
+ T((T_CALLED("_nc_Match_Next_Character(%p,%d,%p)"), menu, ch, item));
- assert( menu && item && *item);
+ assert(menu && item && *item);
idx = (*item)->index;
- if (ch && ch!=BS)
+ 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)
+ a match ! */
+ if ((menu->pindex + 1) > menu->namelen)
RETURN(E_NO_MATCH);
- Add_Character_To_Pattern(menu,ch);
+ 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. */
+ 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;
+ 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)
+ 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((bool)((menu->opt & O_IGNORECASE) != 0),
+ menu->pattern,
+ menu->items[idx]->name.str)
)
- found = TRUE;
- else
- passed = TRUE;
- } while (!found && (idx != last));
+ found = TRUE;
+ else
+ passed = TRUE;
+ }
+ while (!found && (idx != last));
if (found)
{
- if (!((idx==(*item)->index) && passed))
+ 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 );
+ 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 (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);
@@ -203,7 +210,7 @@ _nc_Match_Next_Character_In_Item_Name
| E_NOT_POSTED - menu is not posted
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-menu_driver (MENU * menu, int c)
+menu_driver(MENU * menu, int c)
{
#define NAVIGATE(dir) \
if (!item->dir)\
@@ -215,327 +222,332 @@ menu_driver (MENU * menu, int c)
ITEM *item;
int my_top_row, rdiff;
+ T((T_CALLED("menu_driver(%p,%d)"), menu, c));
+
if (!menu)
RETURN(E_BAD_ARGUMENT);
- if ( menu->status & _IN_DRIVER )
+ if (menu->status & _IN_DRIVER)
RETURN(E_BAD_STATE);
- if ( !( menu->status & _POSTED ) )
+ if (!(menu->status & _POSTED))
RETURN(E_NOT_POSTED);
item = menu->curitem;
- my_top_row = menu->toprow;
- 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:
+ my_top_row = menu->toprow;
+ 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;
+ NAVIGATE(left);
+ break;
- case REQ_RIGHT_ITEM:
+ case REQ_RIGHT_ITEM:
/*==================*/
- NAVIGATE(right);
- break;
+ NAVIGATE(right);
+ break;
- case REQ_UP_ITEM:
+ case REQ_UP_ITEM:
/*===============*/
- NAVIGATE(up);
- break;
+ NAVIGATE(up);
+ break;
- case REQ_DOWN_ITEM:
+ case REQ_DOWN_ITEM:
/*=================*/
- NAVIGATE(down);
- break;
+ NAVIGATE(down);
+ break;
- case REQ_SCR_ULINE:
+ case REQ_SCR_ULINE:
/*=================*/
if (my_top_row == 0 || !(item->up))
- result = E_REQUEST_DENIED;
- else
- {
- --my_top_row;
- item = item->up;
- }
- break;
-
- case REQ_SCR_DLINE:
+ result = E_REQUEST_DENIED;
+ else
+ {
+ --my_top_row;
+ item = item->up;
+ }
+ break;
+
+ case REQ_SCR_DLINE:
/*=================*/
if ((my_top_row + menu->arows >= menu->rows) || !(item->down))
- {
- /* 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 */
- result = E_REQUEST_DENIED;
- }
- else {
- my_top_row++;
+ {
+ /* 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 */
+ result = E_REQUEST_DENIED;
+ }
+ else
+ {
+ my_top_row++;
item = item->down;
- }
- break;
+ }
+ break;
- case REQ_SCR_DPAGE:
+ case REQ_SCR_DPAGE:
/*=================*/
rdiff = menu->rows - (menu->arows + my_top_row);
- if (rdiff > menu->arows)
- rdiff = menu->arows;
- if (rdiff<=0)
- result = E_REQUEST_DENIED;
- else
- {
- my_top_row += rdiff;
- while(rdiff-- > 0 && item!=(ITEM*)0)
- item = item->down;
- }
- break;
-
- case REQ_SCR_UPAGE:
+ if (rdiff > menu->arows)
+ rdiff = menu->arows;
+ if (rdiff <= 0)
+ result = E_REQUEST_DENIED;
+ else
+ {
+ my_top_row += rdiff;
+ while (rdiff-- > 0 && item != 0 && item->down != 0)
+ item = item->down;
+ }
+ break;
+
+ case REQ_SCR_UPAGE:
/*=================*/
rdiff = (menu->arows < my_top_row) ? menu->arows : my_top_row;
- if (rdiff<=0)
- result = E_REQUEST_DENIED;
- else
- {
- my_top_row -= rdiff;
- while(rdiff-- && item!=(ITEM*)0)
- item = item->up;
- }
- break;
+ if (rdiff <= 0)
+ result = E_REQUEST_DENIED;
+ else
+ {
+ my_top_row -= rdiff;
+ while (rdiff-- > 0 && item != 0 && item->up != 0)
+ item = item->up;
+ }
+ break;
- case REQ_FIRST_ITEM:
+ case REQ_FIRST_ITEM:
/*==================*/
- item = menu->items[0];
- break;
+ item = menu->items[0];
+ break;
- case REQ_LAST_ITEM:
+ case REQ_LAST_ITEM:
/*=================*/
- item = menu->items[menu->nitems-1];
- break;
+ item = menu->items[menu->nitems - 1];
+ break;
- case REQ_NEXT_ITEM:
+ 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 + 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)
- {
+ if (item->index <= 0)
+ {
+ if (menu->opt & O_NONCYCLIC)
result = E_REQUEST_DENIED;
- }
- else
- {
- if (menu->curitem->opt & O_SELECTABLE)
- {
- menu->curitem->value = !menu->curitem->value;
- Move_And_Post_Item(menu,menu->curitem);
- _nc_Show_Menu(menu);
- }
- else
- result = E_NOT_SELECTABLE;
- }
- break;
-
- case REQ_CLEAR_PATTERN:
+ 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 = !menu->curitem->value;
+ 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;
+ /* already cleared in prologue */
+ break;
- case REQ_BACK_PATTERN:
+ 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:
+ 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 = _nc_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 = _nc_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 = _nc_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:
+ assert(menu->pattern);
+ if (menu->pattern[0])
+ result = _nc_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 = _nc_Match_Next_Character_In_Item_Name( menu, c, &item );
+ result = E_UNKNOWN_COMMAND;
+ break;
+ }
+ }
+ else
+ { /* not a command */
+ if (!(c & ~((int)MAX_REGULAR_CHARACTER)) && isprint(UChar(c)))
+ result = _nc_Match_Next_Character_In_Item_Name(menu, c, &item);
#ifdef NCURSES_MOUSE_VERSION
- else if (KEY_MOUSE == c)
- {
- MEVENT event;
- WINDOW* uwin = Get_Menu_UserWin(menu);
-
- getmouse(&event);
- if ((event.bstate & (BUTTON1_CLICKED |
- BUTTON1_DOUBLE_CLICKED |
- BUTTON1_TRIPLE_CLICKED ))
- && wenclose(uwin,event.y, event.x))
- { /* we react only if the click was in the userwin, that means
- * inside the menu display area or at the decoration window.
- */
- WINDOW* sub = Get_Menu_Window(menu);
- int ry = event.y, rx = event.x; /* screen coordinates */
+ else if (KEY_MOUSE == c)
+ {
+ MEVENT event;
+ WINDOW *uwin = Get_Menu_UserWin(menu);
+
+ getmouse(&event);
+ if ((event.bstate & (BUTTON1_CLICKED |
+ BUTTON1_DOUBLE_CLICKED |
+ BUTTON1_TRIPLE_CLICKED))
+ && wenclose(uwin, event.y, event.x))
+ { /* we react only if the click was in the userwin, that means
+ * inside the menu display area or at the decoration window.
+ */
+ WINDOW *sub = Get_Menu_Window(menu);
+ int ry = event.y, rx = event.x; /* screen coordinates */
- result = E_REQUEST_DENIED;
- if (mouse_trafo(&ry,&rx,FALSE))
- { /* rx, ry are now "curses" coordinates */
- if (ry < sub->_begy)
- { /* we clicked above the display region; this is
- * interpreted as "scroll up" request
- */
- if (event.bstate & BUTTON1_CLICKED)
- result = menu_driver(menu,REQ_SCR_ULINE);
- else if (event.bstate & BUTTON1_DOUBLE_CLICKED)
- result = menu_driver(menu,REQ_SCR_UPAGE);
- else if (event.bstate & BUTTON1_TRIPLE_CLICKED)
- result = menu_driver(menu,REQ_FIRST_ITEM);
- RETURN(result);
- }
- else if (ry >= sub->_begy + sub->_maxy)
- { /* we clicked below the display region; this is
- * interpreted as "scroll down" request
- */
- if (event.bstate & BUTTON1_CLICKED)
- result = menu_driver(menu,REQ_SCR_DLINE);
- else if (event.bstate & BUTTON1_DOUBLE_CLICKED)
- result = menu_driver(menu,REQ_SCR_DPAGE);
- else if (event.bstate & BUTTON1_TRIPLE_CLICKED)
- result = menu_driver(menu,REQ_LAST_ITEM);
- RETURN(result);
- }
- else if (wenclose(sub,event.y,event.x))
- { /* Inside the area we try to find the hit item */
- int i,x,y,err;
- ry = event.y; rx = event.x;
- if (wmouse_trafo(sub,&ry,&rx,FALSE))
- {
- for(i=0;i<menu->nitems;i++)
- {
- err = _nc_menu_cursor_pos(menu,menu->items[i],
- &y, &x);
- if (E_OK==err)
- {
- if ((ry==y) &&
- (rx>=x) &&
- (rx < x + menu->itemlen))
- {
- item = menu->items[i];
- result = E_OK;
- break;
- }
- }
- }
- if (E_OK==result)
- { /* We found an item, now we can handle the click.
+ result = E_REQUEST_DENIED;
+ if (mouse_trafo(&ry, &rx, FALSE))
+ { /* rx, ry are now "curses" coordinates */
+ if (ry < sub->_begy)
+ { /* we clicked above the display region; this is
+ * interpreted as "scroll up" request
+ */
+ if (event.bstate & BUTTON1_CLICKED)
+ result = menu_driver(menu, REQ_SCR_ULINE);
+ else if (event.bstate & BUTTON1_DOUBLE_CLICKED)
+ result = menu_driver(menu, REQ_SCR_UPAGE);
+ else if (event.bstate & BUTTON1_TRIPLE_CLICKED)
+ result = menu_driver(menu, REQ_FIRST_ITEM);
+ RETURN(result);
+ }
+ else if (ry > sub->_begy + sub->_maxy)
+ { /* we clicked below the display region; this is
+ * interpreted as "scroll down" request
+ */
+ if (event.bstate & BUTTON1_CLICKED)
+ result = menu_driver(menu, REQ_SCR_DLINE);
+ else if (event.bstate & BUTTON1_DOUBLE_CLICKED)
+ result = menu_driver(menu, REQ_SCR_DPAGE);
+ else if (event.bstate & BUTTON1_TRIPLE_CLICKED)
+ result = menu_driver(menu, REQ_LAST_ITEM);
+ RETURN(result);
+ }
+ else if (wenclose(sub, event.y, event.x))
+ { /* Inside the area we try to find the hit item */
+ int i, x, y, err;
+
+ ry = event.y;
+ rx = event.x;
+ if (wmouse_trafo(sub, &ry, &rx, FALSE))
+ {
+ for (i = 0; i < menu->nitems; i++)
+ {
+ err = _nc_menu_cursor_pos(menu, menu->items[i],
+ &y, &x);
+ if (E_OK == err)
+ {
+ if ((ry == y) &&
+ (rx >= x) &&
+ (rx < x + menu->itemlen))
+ {
+ item = menu->items[i];
+ result = E_OK;
+ break;
+ }
+ }
+ }
+ if (E_OK == result)
+ { /* We found an item, now we can handle the click.
* A single click just positions the menu cursor
* to the clicked item. A double click toggles
* the item.
*/
- if (event.bstate & BUTTON1_DOUBLE_CLICKED)
- {
- _nc_New_TopRow_and_CurrentItem(menu,
- my_top_row,
- item);
- menu_driver(menu,REQ_TOGGLE_ITEM);
- result = E_UNKNOWN_COMMAND;
- }
- }
- }
- }
- }
- }
- else
- result = E_REQUEST_DENIED;
- }
+ if (event.bstate & BUTTON1_DOUBLE_CLICKED)
+ {
+ _nc_New_TopRow_and_CurrentItem(menu,
+ my_top_row,
+ item);
+ menu_driver(menu, REQ_TOGGLE_ITEM);
+ result = E_UNKNOWN_COMMAND;
+ }
+ }
+ }
+ }
+ }
+ }
+ else
+ result = E_REQUEST_DENIED;
+ }
#endif /* NCURSES_MOUSE_VERSION */
- else
- result = E_UNKNOWN_COMMAND;
- }
+ else
+ result = E_UNKNOWN_COMMAND;
+ }
- if (E_OK==result)
+ if (E_OK == result)
{
- /* 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->arows) )
- my_top_row = item->y - menu->arows + 1;
-
- _nc_New_TopRow_and_CurrentItem( menu, my_top_row, item );
+ /* 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->arows))
+ my_top_row = item->y - menu->arows + 1;
+
+ _nc_New_TopRow_and_CurrentItem(menu, my_top_row, item);
}
diff --git a/lib/libmenu/m_format.c b/lib/libmenu/m_format.c
index 8a16f001b9a..3a5fd3ab6dd 100644
--- a/lib/libmenu/m_format.c
+++ b/lib/libmenu/m_format.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: m_format.c,v 1.6 2001/01/22 18:02:03 millert Exp $ */
+/* $OpenBSD: m_format.c,v 1.7 2010/01/12 23:22:07 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,2004 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,7 +29,7 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
/***************************************************************************
@@ -39,14 +39,14 @@
#include "menu.priv.h"
-MODULE_ID("$From: m_format.c,v 1.10 2000/12/10 02:16:48 tom Exp $")
+MODULE_ID("$Id: m_format.c,v 1.7 2010/01/12 23:22:07 nicm Exp $")
#define minimum(a,b) ((a)<(b) ? (a): (b))
/*---------------------------------------------------------------------------
-| Facility : libnmenu
+| 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
@@ -58,42 +58,44 @@ MODULE_ID("$From: m_format.c,v 1.10 2000/12/10 02:16:48 tom Exp $")
| E_POSTED - the menu is already posted
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-set_menu_format (MENU *menu, int rows, int cols)
+set_menu_format(MENU * menu, int rows, int cols)
{
int total_rows, total_cols;
-
- if (rows<0 || cols<0)
+
+ T((T_CALLED("set_menu_format(%p,%d,%d)"), menu, rows, cols));
+
+ if (rows < 0 || cols < 0)
RETURN(E_BAD_ARGUMENT);
-
+
if (menu)
{
- if ( menu->status & _POSTED )
+ if (menu->status & _POSTED)
RETURN(E_POSTED);
-
+
if (!(menu->items))
RETURN(E_NOT_CONNECTED);
-
- if (rows==0)
+
+ if (rows == 0)
rows = menu->frows;
- if (cols==0)
+ 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->arows = minimum(total_rows,rows);
- menu->toprow = 0;
+
+ assert(rows > 0 && cols > 0);
+ total_rows = (menu->nitems - 1) / cols + 1;
+ total_cols = (menu->opt & O_ROWMAJOR) ?
+ minimum(menu->nitems, cols) :
+ (menu->nitems - 1) / total_rows + 1;
+
+ menu->rows = total_rows;
+ menu->cols = total_cols;
+ menu->arows = minimum(total_rows, rows);
+ menu->toprow = 0;
menu->curitem = *(menu->items);
assert(menu->curitem);
menu->status |= _LINK_NEEDED;
@@ -101,24 +103,26 @@ set_menu_format (MENU *menu, int rows, int cols)
}
else
{
- if (rows>0) _nc_Default_Menu.frows = rows;
- if (cols>0) _nc_Default_Menu.fcols = cols;
+ if (rows > 0)
+ _nc_Default_Menu.frows = rows;
+ if (cols > 0)
+ _nc_Default_Menu.fcols = cols;
}
-
+
RETURN(E_OK);
}
/*---------------------------------------------------------------------------
-| Facility : libnmenu
+| 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 : -
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(void)
-menu_format (const MENU *menu, int *rows, int *cols)
+menu_format(const MENU * menu, int *rows, int *cols)
{
if (rows)
*rows = Normalize_Menu(menu)->frows;
diff --git a/lib/libmenu/m_global.c b/lib/libmenu/m_global.c
index 762261bb017..af6fa156924 100644
--- a/lib/libmenu/m_global.c
+++ b/lib/libmenu/m_global.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: m_global.c,v 1.7 2003/01/05 22:41:37 deraadt Exp $ */
+/* $OpenBSD: m_global.c,v 1.8 2010/01/12 23:22:07 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2004,2005 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,7 +29,7 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
/***************************************************************************
@@ -39,8 +39,10 @@
#include "menu.priv.h"
-MODULE_ID("$From: m_global.c,v 1.12 2000/12/10 02:16:48 tom Exp $")
+MODULE_ID("$Id: m_global.c,v 1.8 2010/01/12 23:22:07 nicm Exp $")
+static char mark[] = "-";
+/* *INDENT-OFF* */
NCURSES_EXPORT_VAR(MENU) _nc_Default_Menu = {
16, /* Nr. of chars high */
1, /* Nr. of chars wide */
@@ -75,7 +77,7 @@ NCURSES_EXPORT_VAR(MENU) _nc_Default_Menu = {
(Menu_Hook)0, /* Item init */
(Menu_Hook)0, /* Item term */
(void *)0, /* userptr */
- "-", /* mark */
+ mark, /* mark */
ALL_MENU_OPTS, /* options */
0 /* status */
};
@@ -95,6 +97,7 @@ NCURSES_EXPORT_VAR(ITEM) _nc_Default_Item = {
(ITEM *)0, /* up */
(ITEM *)0 /* down */
};
+/* *INDENT-ON* */
/*---------------------------------------------------------------------------
| Facility : libnmenu
@@ -105,24 +108,29 @@ NCURSES_EXPORT_VAR(ITEM) _nc_Default_Item = {
|
| Return Values : -
+--------------------------------------------------------------------------*/
-INLINE static void ComputeMaximum_NameDesc_Lengths(MENU * menu)
+NCURSES_INLINE static void
+ComputeMaximum_NameDesc_Lengths(MENU * menu)
{
- unsigned MaximumNameLength = 0;
+ unsigned MaximumNameLength = 0;
unsigned MaximumDescriptionLength = 0;
ITEM **items;
-
+ unsigned check;
+
assert(menu && menu->items);
- for( items = menu->items; *items ; 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;
+ check = _nc_Calculate_Text_Width(&((*items)->name));
+ if (check > MaximumNameLength)
+ MaximumNameLength = check;
+
+ check = _nc_Calculate_Text_Width(&((*items)->description));
+ if (check > MaximumDescriptionLength)
+ MaximumDescriptionLength = check;
}
-
+
menu->namelen = MaximumNameLength;
menu->desclen = MaximumDescriptionLength;
+ T(("ComputeMaximum_NameDesc_Lengths %d,%d", menu->namelen, menu->desclen));
}
/*---------------------------------------------------------------------------
@@ -134,22 +142,23 @@ INLINE static void ComputeMaximum_NameDesc_Lengths(MENU * menu)
|
| Return Values : -
+--------------------------------------------------------------------------*/
-INLINE static void ResetConnectionInfo(MENU *menu, ITEM **items)
+NCURSES_INLINE static void
+ResetConnectionInfo(MENU * menu, ITEM ** items)
{
ITEM **item;
-
+
assert(menu && items);
- for(item=items; *item; item++)
+ for (item = items; *item; item++)
{
(*item)->index = 0;
- (*item)->imenu = (MENU *)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;
+ menu->pindex = 0;
+ menu->items = (ITEM **) 0;
+ menu->nitems = 0;
}
/*---------------------------------------------------------------------------
@@ -164,25 +173,25 @@ INLINE static void ResetConnectionInfo(MENU *menu, ITEM **items)
| FALSE - connection failed
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(bool)
-_nc_Connect_Items (MENU *menu, ITEM **items)
+_nc_Connect_Items(MENU * menu, ITEM ** items)
{
ITEM **item;
unsigned int ItemCount = 0;
-
- if ( menu && items )
- {
- for(item=items; *item ; item++)
+
+ if (menu && items)
+ {
+ for (item = items; *item; item++)
{
- if ( (*item)->imenu )
+ if ((*item)->imenu)
{
/* if a item is already connected, reject connection */
break;
}
}
- if (! (*item) )
+ if (!(*item))
/* we reached the end, so there was no connected item */
{
- for(item=items; *item ; item++)
+ for (item = items; *item; item++)
{
if (menu->opt & O_ONEVALUE)
{
@@ -190,31 +199,31 @@ _nc_Connect_Items (MENU *menu, ITEM **items)
}
(*item)->index = ItemCount++;
(*item)->imenu = menu;
- }
+ }
}
}
else
- return(FALSE);
-
+ return (FALSE);
+
if (ItemCount != 0)
{
- menu->items = items;
+ menu->items = items;
menu->nitems = ItemCount;
ComputeMaximum_NameDesc_Lengths(menu);
- if ( (menu->pattern = (char *)malloc( (unsigned)(1 + menu->namelen))) )
+ if ((menu->pattern = typeMalloc(char, (unsigned)(1 + menu->namelen))))
{
- Reset_Pattern(menu);
- set_menu_format(menu,menu->frows,menu->fcols);
+ Reset_Pattern(menu);
+ set_menu_format(menu, menu->frows, menu->fcols);
menu->curitem = *items;
menu->toprow = 0;
- return(TRUE);
+ 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);
+ ResetConnectionInfo(menu, items);
+ return (FALSE);
}
/*---------------------------------------------------------------------------
@@ -226,14 +235,102 @@ _nc_Connect_Items (MENU *menu, ITEM **items)
| Return Values : -
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(void)
-_nc_Disconnect_Items (MENU * menu)
+_nc_Disconnect_Items(MENU * menu)
{
if (menu && menu->items)
- ResetConnectionInfo( menu, menu->items );
+ ResetConnectionInfo(menu, menu->items);
}
/*---------------------------------------------------------------------------
| Facility : libnmenu
+| Function : int _nc_Calculate_Text_Width(const TEXT * item)
+|
+| Description : Calculate the number of columns for a TEXT.
+|
+| Return Values : the width
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(int)
+_nc_Calculate_Text_Width(const TEXT * item /*FIXME: limit length */ )
+{
+#if USE_WIDEC_SUPPORT
+ int result = item->length;
+
+ T((T_CALLED("_nc_menu_text_width(%p)"), item));
+ if (result != 0 && item->str != 0)
+ {
+ int count = mbstowcs(0, item->str, 0);
+ wchar_t *temp = 0;
+
+ if (count > 0
+ && (temp = typeMalloc(wchar_t, 2 + count)) != 0)
+ {
+ int n;
+
+ result = 0;
+ mbstowcs(temp, item->str, (unsigned)count);
+ for (n = 0; n < count; ++n)
+ {
+ int test = wcwidth(temp[n]);
+
+ if (test <= 0)
+ test = 1;
+ result += test;
+ }
+ free(temp);
+ }
+ }
+ returnCode(result);
+#else
+ return item->length;
+#endif
+}
+
+/*
+ * Calculate the actual width of a menu entry for wide-characters.
+ */
+#if USE_WIDEC_SUPPORT
+static int
+calculate_actual_width(MENU * menu, bool name)
+{
+ int width = 0;
+ int check = 0;
+ ITEM **items;
+
+ assert(menu && menu->items);
+
+ if (menu->items != 0)
+ {
+ for (items = menu->items; *items; items++)
+ {
+ if (name)
+ {
+ check = _nc_Calculate_Text_Width(&((*items)->name));
+ }
+ else
+ {
+ check = _nc_Calculate_Text_Width(&((*items)->description));
+ }
+ if (check > width)
+ width = check;
+ }
+ }
+ else
+ {
+ width = (name ? menu->namelen : menu->desclen);
+ }
+
+ T(("calculate_actual_width %s = %d/%d",
+ name ? "name" : "desc",
+ width,
+ name ? menu->namelen : menu->desclen));
+ return width;
+}
+#else
+#define calculate_actual_width(menu, name) (name ? menu->namelen : menu->desclen)
+#endif
+
+/*---------------------------------------------------------------------------
+| Facility : libnmenu
| Function : void _nc_Calculate_Item_Length_and_Width(MENU *menu)
|
| Description : Calculate the length of an item and the width of the
@@ -242,93 +339,103 @@ _nc_Disconnect_Items (MENU * menu)
| Return Values : -
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(void)
-_nc_Calculate_Item_Length_and_Width (MENU * menu)
+_nc_Calculate_Item_Length_and_Width(MENU * menu)
{
int l;
-
+
assert(menu);
- menu->height = 1 + menu->spc_rows * (menu->arows - 1);
+ menu->height = 1 + menu->spc_rows * (menu->arows - 1);
+
+ l = calculate_actual_width(menu, TRUE);
+ l += menu->marklen;
+
+ if ((menu->opt & O_SHOWDESC) && (menu->desclen > 0))
+ {
+ l += calculate_actual_width(menu, FALSE);
+ l += menu->spc_desc;
+ }
- l = menu->namelen + menu->marklen;
- if ( (menu->opt & O_SHOWDESC) && (menu->desclen > 0) )
- l += (menu->desclen + menu->spc_desc);
-
menu->itemlen = l;
l *= menu->cols;
- l += (menu->cols-1)*menu->spc_cols; /* for the padding between the columns */
+ l += (menu->cols - 1) * menu->spc_cols; /* for the padding between the columns */
menu->width = l;
-}
+
+ T(("_nc_CalculateItem_Length_and_Width columns %d, item %d, width %d",
+ menu->cols,
+ menu->itemlen,
+ menu->width));
+}
/*---------------------------------------------------------------------------
| Facility : libnmenu
| Function : void _nc_Link_Item(MENU *menu)
|
-| Description : Statically calculate for every item its four neighbours.
+| Description : Statically calculate for every item its four neighbors.
| This depends on the orientation of the menu. This
-| static aproach simplifies navigation in the menu a lot.
+| static approach simplifies navigation in the menu a lot.
|
| Return Values : -
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(void)
-_nc_Link_Items (MENU * menu)
+_nc_Link_Items(MENU * menu)
{
if (menu && menu->items && *(menu->items))
{
- int i,j;
+ 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++)
+
+ 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);
+
+ 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 )
+ if (++col == Number_Of_Columns)
{
row++;
col = 0;
@@ -338,48 +445,48 @@ _nc_Link_Items (MENU * menu)
else
{
int Number_Of_Rows = menu->rows;
-
- for(j=0; j<Number_Of_Items; j++)
+
+ 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) ?
+ 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);
-
+ (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->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 )
+ if ((++row) == Number_Of_Rows)
{
col++;
row = 0;
@@ -398,31 +505,31 @@ _nc_Link_Items (MENU * menu)
| Return Values : -
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(void)
-_nc_Show_Menu (const MENU *menu)
+_nc_Show_Menu(const MENU * menu)
{
WINDOW *win;
int maxy, maxx;
-
+
assert(menu);
- if ( (menu->status & _POSTED) && !(menu->status & _IN_DRIVER) )
+ 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->spc_rows * menu->toprow,0);
+ mvderwin(menu->sub, menu->spc_rows * menu->toprow, 0);
win = Get_Menu_Window(menu);
-
+
maxy = getmaxy(win);
- maxx = getmaxx(win);
-
- if (menu->height < maxy)
+ maxx = getmaxx(win);
+
+ if (menu->height < maxy)
maxy = menu->height;
- if (menu->width < maxx)
+ if (menu->width < maxx)
maxx = menu->width;
-
- copywin(menu->sub,win,0,0,0,0,maxy-1,maxx-1,0);
+
+ copywin(menu->sub, win, 0, 0, 0, 0, maxy - 1, maxx - 1, 0);
pos_menu_cursor(menu);
- }
-}
+ }
+}
/*---------------------------------------------------------------------------
| Facility : libnmenu
@@ -438,41 +545,41 @@ _nc_Show_Menu (const MENU *menu)
| Return Values : -
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(void)
-_nc_New_TopRow_and_CurrentItem
-(MENU *menu, int new_toprow, ITEM *new_current_item)
+ _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);
+ Call_Hook(menu, itemterm);
iterm_called = TRUE;
}
if (new_toprow != menu->toprow)
{
- Call_Hook(menu,menuterm);
+ Call_Hook(menu, menuterm);
mterm_called = TRUE;
- }
-
- cur_item = menu->curitem;
+ }
+
+ cur_item = menu->curitem;
assert(cur_item);
- menu->toprow = new_toprow;
- menu->curitem = new_current_item;
-
+ menu->toprow = new_toprow;
+ menu->curitem = new_current_item;
+
if (mterm_called)
{
- Call_Hook(menu,menuinit);
+ 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);
+ Move_To_Current_Item(menu, cur_item);
+ Call_Hook(menu, iteminit);
}
if (mterm_called || iterm_called)
{
@@ -482,8 +589,8 @@ _nc_New_TopRow_and_CurrentItem
pos_menu_cursor(menu);
}
else
- { /* if we are not posted, this is quite simple */
- menu->toprow = new_toprow;
+ { /* if we are not posted, this is quite simple */
+ menu->toprow = new_toprow;
menu->curitem = new_current_item;
}
}
diff --git a/lib/libmenu/m_hook.c b/lib/libmenu/m_hook.c
index 11b62354d13..cab55c10ba8 100644
--- a/lib/libmenu/m_hook.c
+++ b/lib/libmenu/m_hook.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: m_hook.c,v 1.6 2001/01/22 18:02:03 millert Exp $ */
+/* $OpenBSD: m_hook.c,v 1.7 2010/01/12 23:22:08 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,2004 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,7 +29,7 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
/***************************************************************************
@@ -39,12 +39,13 @@
#include "menu.priv.h"
-MODULE_ID("$From: m_hook.c,v 1.9 2000/12/10 02:16:48 tom Exp $")
+MODULE_ID("$Id: m_hook.c,v 1.7 2010/01/12 23:22:08 nicm Exp $")
/* "Template" macro to generate function to set application specific hook */
#define GEN_HOOK_SET_FUNCTION( typ, name ) \
NCURSES_IMPEXP int NCURSES_API set_ ## typ ## _ ## name (MENU *menu, Menu_Hook func )\
{\
+ T((T_CALLED("set_" #typ "_" #name "(%p,%p)"), menu, func));\
(Normalize_Menu(menu) -> typ ## name = func );\
RETURN(E_OK);\
}
@@ -53,7 +54,8 @@ NCURSES_IMPEXP int NCURSES_API set_ ## typ ## _ ## name (MENU *menu, Menu_Hook f
#define GEN_HOOK_GET_FUNCTION( typ, name ) \
NCURSES_IMPEXP Menu_Hook NCURSES_API typ ## _ ## name ( const MENU *menu )\
{\
- return (Normalize_Menu(menu) -> typ ## name);\
+ T((T_CALLED(#typ "_" #name "(%p)"), menu));\
+ returnMenuHook(Normalize_Menu(menu) -> typ ## name);\
}
/*---------------------------------------------------------------------------
@@ -65,7 +67,7 @@ NCURSES_IMPEXP Menu_Hook NCURSES_API typ ## _ ## name ( const MENU *menu )\
|
| Return Values : E_OK - success
+--------------------------------------------------------------------------*/
-GEN_HOOK_SET_FUNCTION( menu, init )
+GEN_HOOK_SET_FUNCTION(menu, init)
/*---------------------------------------------------------------------------
| Facility : libnmenu
@@ -77,7 +79,7 @@ GEN_HOOK_SET_FUNCTION( menu, init )
|
| Return Values : Menu init function address or NULL
+--------------------------------------------------------------------------*/
-GEN_HOOK_GET_FUNCTION( menu, init )
+GEN_HOOK_GET_FUNCTION(menu, init)
/*---------------------------------------------------------------------------
| Facility : libnmenu
@@ -88,7 +90,7 @@ GEN_HOOK_GET_FUNCTION( menu, init )
|
| Return Values : E_OK - success
+--------------------------------------------------------------------------*/
-GEN_HOOK_SET_FUNCTION( menu, term )
+GEN_HOOK_SET_FUNCTION(menu, term)
/*---------------------------------------------------------------------------
| Facility : libnmenu
@@ -100,7 +102,7 @@ GEN_HOOK_SET_FUNCTION( menu, term )
|
| Return Values : Menu finalization function address or NULL
+--------------------------------------------------------------------------*/
-GEN_HOOK_GET_FUNCTION( menu, term )
+GEN_HOOK_GET_FUNCTION(menu, term)
/*---------------------------------------------------------------------------
| Facility : libnmenu
@@ -111,7 +113,7 @@ GEN_HOOK_GET_FUNCTION( menu, term )
|
| Return Values : E_OK - success
+--------------------------------------------------------------------------*/
-GEN_HOOK_SET_FUNCTION( item, init )
+GEN_HOOK_SET_FUNCTION(item, init)
/*---------------------------------------------------------------------------
| Facility : libnmenu
@@ -123,7 +125,7 @@ GEN_HOOK_SET_FUNCTION( item, init )
|
| Return Values : Item init function address or NULL
+--------------------------------------------------------------------------*/
-GEN_HOOK_GET_FUNCTION( item, init )
+GEN_HOOK_GET_FUNCTION(item, init)
/*---------------------------------------------------------------------------
| Facility : libnmenu
@@ -134,7 +136,7 @@ GEN_HOOK_GET_FUNCTION( item, init )
|
| Return Values : E_OK - success
+--------------------------------------------------------------------------*/
-GEN_HOOK_SET_FUNCTION( item, term )
+GEN_HOOK_SET_FUNCTION(item, term)
/*---------------------------------------------------------------------------
| Facility : libnmenu
@@ -146,6 +148,6 @@ GEN_HOOK_SET_FUNCTION( item, term )
|
| Return Values : Item finalization function address or NULL
+--------------------------------------------------------------------------*/
-GEN_HOOK_GET_FUNCTION( item, term )
+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
index 25be32ff9f0..af3e26d1cdc 100644
--- a/lib/libmenu/m_item_cur.c
+++ b/lib/libmenu/m_item_cur.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: m_item_cur.c,v 1.6 2001/01/22 18:02:03 millert Exp $ */
+/* $OpenBSD: m_item_cur.c,v 1.7 2010/01/12 23:22:08 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,2004 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,7 +29,7 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
/***************************************************************************
@@ -39,7 +39,7 @@
#include "menu.priv.h"
-MODULE_ID("$From: m_item_cur.c,v 1.12 2000/12/10 02:16:48 tom Exp $")
+MODULE_ID("$Id: m_item_cur.c,v 1.7 2010/01/12 23:22:08 nicm Exp $")
/*---------------------------------------------------------------------------
| Facility : libnmenu
@@ -50,14 +50,16 @@ MODULE_ID("$From: m_item_cur.c,v 1.12 2000/12/10 02:16:48 tom Exp $")
| Return Values : E_OK - success
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-set_current_item (MENU * menu, ITEM * item)
+set_current_item(MENU * menu, ITEM * item)
{
- if (menu && item && (item->imenu==menu))
+ T((T_CALLED("set_current_item(%p,%p)"), menu, item));
+
+ if (menu && item && (item->imenu == menu))
{
- if ( menu->status & _IN_DRIVER )
+ if (menu->status & _IN_DRIVER)
RETURN(E_BAD_STATE);
-
- assert( menu->curitem );
+
+ assert(menu->curitem);
if (item != menu->curitem)
{
if (menu->status & _LINK_NEEDED)
@@ -71,12 +73,12 @@ set_current_item (MENU * menu, ITEM * item)
assert(menu->pattern);
Reset_Pattern(menu);
/* adjust the window to make item visible and update the menu */
- Adjust_Current_Item(menu,menu->toprow,item);
+ Adjust_Current_Item(menu, menu->toprow, item);
}
}
else
RETURN(E_BAD_ARGUMENT);
-
+
RETURN(E_OK);
}
@@ -89,9 +91,10 @@ set_current_item (MENU * menu, ITEM * item)
| Return Values : Item pointer or NULL if failure
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(ITEM *)
-current_item (const MENU * menu)
+current_item(const MENU * menu)
{
- return (menu && menu->items) ? menu->curitem : (ITEM *)0;
+ T((T_CALLED("current_item(%p)"), menu));
+ returnItem((menu && menu->items) ? menu->curitem : (ITEM *) 0);
}
/*---------------------------------------------------------------------------
@@ -103,9 +106,10 @@ current_item (const MENU * menu)
| Return Values : The index or ERR if this is an invalid item pointer
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-item_index (const ITEM *item)
+item_index(const ITEM * item)
{
- return (item && item->imenu) ? item->index : ERR;
+ T((T_CALLED("item_index(%p)"), item));
+ returnCode((item && item->imenu) ? item->index : ERR);
}
/* m_item_cur.c ends here */
diff --git a/lib/libmenu/m_item_nam.c b/lib/libmenu/m_item_nam.c
index 2a882146737..9d1bebfb2ee 100644
--- a/lib/libmenu/m_item_nam.c
+++ b/lib/libmenu/m_item_nam.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: m_item_nam.c,v 1.6 2001/01/22 18:02:04 millert Exp $ */
+/* $OpenBSD: m_item_nam.c,v 1.7 2010/01/12 23:22:08 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,2004 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,7 +29,7 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
/***************************************************************************
@@ -39,7 +39,7 @@
#include "menu.priv.h"
-MODULE_ID("$From: m_item_nam.c,v 1.10 2000/12/10 02:16:48 tom Exp $")
+MODULE_ID("$Id: m_item_nam.c,v 1.7 2010/01/12 23:22:08 nicm Exp $")
/*---------------------------------------------------------------------------
| Facility : libnmenu
@@ -50,11 +50,12 @@ MODULE_ID("$From: m_item_nam.c,v 1.10 2000/12/10 02:16:48 tom Exp $")
| Return Values : See above; returns NULL if item is invalid
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(const char *)
-item_name (const ITEM * item)
+item_name(const ITEM * item)
{
- return ((item) ? item->name.str : (char *)0);
+ T((T_CALLED("item_name(%p)"), item));
+ returnCPtr((item) ? item->name.str : (char *)0);
}
-
+
/*---------------------------------------------------------------------------
| Facility : libnmenu
| Function : char *item_description(const ITEM *item)
@@ -64,9 +65,10 @@ item_name (const ITEM * item)
| Return Values : See above; Returns NULL if item is invalid
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(const char *)
-item_description (const ITEM * item)
+item_description(const ITEM * item)
{
- return ((item) ? item->description.str : (char *)0);
+ T((T_CALLED("item_description(%p)"), item));
+ returnCPtr((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
index d5b9e8206b5..85bb38b7187 100644
--- a/lib/libmenu/m_item_new.c
+++ b/lib/libmenu/m_item_new.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: m_item_new.c,v 1.8 2003/04/04 23:04:36 tdeval Exp $ */
+/* $OpenBSD: m_item_new.c,v 1.9 2010/01/12 23:22:08 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2005,2006 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,7 +29,7 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
/***************************************************************************
@@ -40,7 +40,13 @@
#include "menu.priv.h"
-MODULE_ID("$From: m_item_new.c,v 1.12 2000/12/10 02:16:48 tom Exp $")
+#if USE_WIDEC_SUPPORT
+#if HAVE_WCTYPE_H
+#include <wctype.h>
+#endif
+#endif
+
+MODULE_ID("$Id: m_item_new.c,v 1.9 2010/01/12 23:22:08 nicm Exp $")
/*---------------------------------------------------------------------------
| Facility : libnmenu
@@ -52,16 +58,44 @@ MODULE_ID("$From: m_item_new.c,v 1.12 2000/12/10 02:16:48 tom Exp $")
| Return Values : TRUE - if string is printable
| FALSE - if string contains non-printable characters
+--------------------------------------------------------------------------*/
-static bool Is_Printable_String(const char *s)
+static bool
+Is_Printable_String(const char *s)
{
+ int result = TRUE;
+
+#if USE_WIDEC_SUPPORT
+ int count = mbstowcs(0, s, 0);
+ wchar_t *temp = 0;
+
+ assert(s);
+
+ if (count > 0
+ && (temp = typeCalloc(wchar_t, (2 + (unsigned)count))) != 0)
+ {
+ int n;
+
+ mbstowcs(temp, s, (unsigned)count);
+ for (n = 0; n < count; ++n)
+ if (!iswprint((wint_t) temp[n]))
+ {
+ result = FALSE;
+ break;
+ }
+ free(temp);
+ }
+#else
assert(s);
- while(*s)
+ while (*s)
{
- if (!isprint((unsigned char)*s))
- return FALSE;
+ if (!isprint(UChar(*s)))
+ {
+ result = FALSE;
+ break;
+ }
s++;
}
- return TRUE;
+#endif
+ return result;
}
/*---------------------------------------------------------------------------
@@ -75,41 +109,45 @@ static bool Is_Printable_String(const char *s)
| Return Values : The item pointer or NULL if creation failed.
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(ITEM *)
-new_item (const char *name, const char *description)
+new_item(const char *name, const char *description)
{
ITEM *item;
-
- if ( !name || (*name == '\0') || !Is_Printable_String(name) )
+
+ T((T_CALLED("new_item(\"%s\", \"%s\")"),
+ name ? name : "",
+ description ? description : ""));
+
+ if (!name || (*name == '\0') || !Is_Printable_String(name))
{
- item = (ITEM *)0;
- SET_ERROR( E_BAD_ARGUMENT );
+ item = (ITEM *) 0;
+ SET_ERROR(E_BAD_ARGUMENT);
}
else
{
- item = (ITEM *)calloc(1,sizeof(ITEM));
+ item = (ITEM *) calloc(1, sizeof(ITEM));
if (item)
{
- *item = _nc_Default_Item; /* hope we have struct assignment */
-
- item->name.length = strlen(name);
- item->name.str = name;
+ *item = _nc_Default_Item; /* hope we have struct assignment */
+
+ item->name.length = strlen(name);
+ item->name.str = name;
- if (description && (*description != '\0') &&
+ if (description && (*description != '\0') &&
Is_Printable_String(description))
{
- item->description.length = strlen(description);
- item->description.str = description;
+ item->description.length = strlen(description);
+ item->description.str = description;
}
else
{
item->description.length = 0;
- item->description.str = (char *)0;
+ item->description.str = (char *)0;
}
}
else
- SET_ERROR( E_SYSTEM_ERROR );
- }
- return(item);
+ SET_ERROR(E_SYSTEM_ERROR);
+ }
+ returnItem(item);
}
/*---------------------------------------------------------------------------
@@ -124,17 +162,19 @@ new_item (const char *name, const char *description)
| E_CONNECTED - item is still connected to a menu
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-free_item (ITEM * item)
+free_item(ITEM * item)
{
+ T((T_CALLED("free_item(%p)"), item));
+
if (!item)
- RETURN( E_BAD_ARGUMENT );
+ RETURN(E_BAD_ARGUMENT);
if (item->imenu)
- RETURN( E_CONNECTED );
-
+ RETURN(E_CONNECTED);
+
free(item);
- RETURN( E_OK );
+ RETURN(E_OK);
}
/*---------------------------------------------------------------------------
@@ -155,16 +195,18 @@ free_item (ITEM * item)
| E_SYSTEM_ERROR - no memory to store mark
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-set_menu_mark (MENU * menu, const char * mark)
+set_menu_mark(MENU * menu, const char *mark)
{
- int l;
+ unsigned l;
+
+ T((T_CALLED("set_menu_mark(%p,%s)"), menu, _nc_visbuf(mark)));
- if ( mark && (*mark != '\0') && Is_Printable_String(mark) )
+ if (mark && (*mark != '\0') && Is_Printable_String(mark))
l = strlen(mark);
else
l = 0;
- if ( menu )
+ if (menu)
{
char *old_mark = menu->mark;
unsigned short old_status = menu->status;
@@ -173,13 +215,13 @@ set_menu_mark (MENU * menu, const char * mark)
{
/* 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)
+ if (menu->marklen != (int)l)
RETURN(E_BAD_ARGUMENT);
- }
+ }
menu->marklen = l;
if (l)
{
- menu->mark = (char *)malloc(l+1);
+ menu->mark = (char *)malloc(l + 1);
if (menu->mark)
{
strlcpy(menu->mark, mark, l+1);
@@ -194,24 +236,24 @@ set_menu_mark (MENU * menu, const char * mark)
}
else
menu->mark = (char *)0;
-
+
if ((old_status & _MARK_ALLOCATED) && old_mark)
free(old_mark);
if (menu->status & _POSTED)
{
- _nc_Draw_Menu( menu );
- _nc_Show_Menu( menu );
+ _nc_Draw_Menu(menu);
+ _nc_Show_Menu(menu);
}
else
{
/* Recalculate the geometry */
- _nc_Calculate_Item_Length_and_Width( menu );
+ _nc_Calculate_Item_Length_and_Width(menu);
}
}
else
{
- return set_menu_mark(&_nc_Default_Menu, mark);
+ returnCode(set_menu_mark(&_nc_Default_Menu, mark));
}
RETURN(E_OK);
}
@@ -225,9 +267,10 @@ set_menu_mark (MENU * menu, const char * mark)
| Return Values : The marker string pointer or NULL if no marker defined
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(const char *)
-menu_mark (const MENU * menu)
+menu_mark(const MENU * menu)
{
- return Normalize_Menu( menu )->mark;
+ T((T_CALLED("menu_mark(%p)"), menu));
+ returnPtr(Normalize_Menu(menu)->mark);
}
/* m_item_new.c */
diff --git a/lib/libmenu/m_item_opt.c b/lib/libmenu/m_item_opt.c
index 1ee8f030f18..8dc31abbff0 100644
--- a/lib/libmenu/m_item_opt.c
+++ b/lib/libmenu/m_item_opt.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: m_item_opt.c,v 1.8 2001/01/22 18:02:04 millert Exp $ */
+/* $OpenBSD: m_item_opt.c,v 1.9 2010/01/12 23:22:08 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,2004 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,7 +29,7 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
/***************************************************************************
@@ -39,7 +39,7 @@
#include "menu.priv.h"
-MODULE_ID("$From: m_item_opt.c,v 1.11 2000/12/10 02:16:48 tom Exp $")
+MODULE_ID("$Id: m_item_opt.c,v 1.9 2010/01/12 23:22:08 nicm Exp $")
/*---------------------------------------------------------------------------
| Facility : libnmenu
@@ -53,34 +53,36 @@ MODULE_ID("$From: m_item_opt.c,v 1.11 2000/12/10 02:16:48 tom Exp $")
| E_BAD_ARGUMENT - invalid item options
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-set_item_opts (ITEM *item, Item_Options opts)
-{
+set_item_opts(ITEM * item, Item_Options opts)
+{
+ T((T_CALLED("set_menu_opts(%p,%d)"), item, opts));
+
opts &= ALL_ITEM_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 );
+ Move_And_Post_Item(menu, item);
_nc_Show_Menu(menu);
}
}
}
else
_nc_Default_Item.opt = opts;
-
+
RETURN(E_OK);
}
@@ -94,18 +96,21 @@ set_item_opts (ITEM *item, Item_Options opts)
| E_BAD_ARGUMENT - invalid options
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(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 */
+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 behavior */
+
+ T((T_CALLED("item_opts_off(%p,%d)"), item, opts));
if (opts & ~ALL_ITEM_OPTS)
RETURN(E_BAD_ARGUMENT);
else
{
- Normalize_Item(citem);
+ Normalize_Item(citem);
opts = citem->opt & ~(opts & ALL_ITEM_OPTS);
- return set_item_opts( item, opts );
+ returnCode(set_item_opts(item, opts));
}
}
@@ -119,11 +124,14 @@ item_opts_off (ITEM *item, Item_Options opts)
| E_BAD_ARGUMENT - invalid options
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-item_opts_on (ITEM *item, Item_Options opts)
+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 */
-
+ ITEM *citem = item; /* use a copy because set_item_opts must detect
+
+ NULL item itself to adjust its behavior */
+
+ T((T_CALLED("item_opts_on(%p,%d)"), item, opts));
+
opts &= ALL_ITEM_OPTS;
if (opts & ~ALL_ITEM_OPTS)
RETURN(E_BAD_ARGUMENT);
@@ -131,7 +139,7 @@ item_opts_on (ITEM *item, Item_Options opts)
{
Normalize_Item(citem);
opts = citem->opt | opts;
- return set_item_opts( item, opts );
+ returnCode(set_item_opts(item, opts));
}
}
@@ -144,9 +152,10 @@ item_opts_on (ITEM *item, Item_Options opts)
| Return Values : Items options
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(Item_Options)
-item_opts (const ITEM * item)
+item_opts(const ITEM * item)
{
- return (ALL_ITEM_OPTS & Normalize_Item(item)->opt);
+ T((T_CALLED("item_opts(%p)"), item));
+ returnItemOpts(ALL_ITEM_OPTS & Normalize_Item(item)->opt);
}
/* m_item_opt.c ends here */
diff --git a/lib/libmenu/m_item_top.c b/lib/libmenu/m_item_top.c
index 2a492ad986c..d17c1d48744 100644
--- a/lib/libmenu/m_item_top.c
+++ b/lib/libmenu/m_item_top.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: m_item_top.c,v 1.4 2001/01/22 18:02:04 millert Exp $ */
+/* $OpenBSD: m_item_top.c,v 1.5 2010/01/12 23:22:08 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,2004 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,7 +29,7 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
/***************************************************************************
@@ -39,48 +39,50 @@
#include "menu.priv.h"
-MODULE_ID("$From: m_item_top.c,v 1.5 2000/12/10 02:16:48 tom Exp $")
+MODULE_ID("$Id: m_item_top.c,v 1.5 2010/01/12 23:22:08 nicm Exp $")
/*---------------------------------------------------------------------------
| Facility : libnmenu
| Function : int set_top_row(MENU *menu, int row)
|
-| Description : Makes the speified row the top row in the menu
+| Description : Makes the specified 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
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-set_top_row (MENU * menu, int row)
+set_top_row(MENU * menu, int row)
{
ITEM *item;
-
+
+ T((T_CALLED("set_top_row(%p,%d)"), menu, row));
+
if (menu)
{
- if ( menu->status & _IN_DRIVER )
+ if (menu->status & _IN_DRIVER)
RETURN(E_BAD_STATE);
- if (menu->items == (ITEM **)0)
+ if (menu->items == (ITEM **) 0)
RETURN(E_NOT_CONNECTED);
-
- if ((row<0) || (row > (menu->rows - menu->arows)))
+
+ if ((row < 0) || (row > (menu->rows - menu->arows)))
RETURN(E_BAD_ARGUMENT);
}
else
RETURN(E_BAD_ARGUMENT);
-
+
if (row != menu->toprow)
{
- if (menu->status & _LINK_NEEDED)
+ if (menu->status & _LINK_NEEDED)
_nc_Link_Items(menu);
-
- item = menu->items[ (menu->opt&O_ROWMAJOR) ? (row*menu->cols) : row ];
+
+ 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);
+
+ RETURN(E_OK);
}
/*---------------------------------------------------------------------------
@@ -92,15 +94,16 @@ set_top_row (MENU * menu, int row)
| Return Values : The row number or ERR if there is no row
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-top_row (const MENU * menu)
+top_row(const MENU * menu)
{
+ T((T_CALLED("top_row(%p)"), menu));
if (menu && menu->items && *(menu->items))
{
- assert( (menu->toprow>=0) && (menu->toprow < menu->rows) );
- return menu->toprow;
+ assert((menu->toprow >= 0) && (menu->toprow < menu->rows));
+ returnCode(menu->toprow);
}
else
- return(ERR);
+ returnCode(ERR);
}
/* m_item_top.c ends here */
diff --git a/lib/libmenu/m_item_use.c b/lib/libmenu/m_item_use.c
index b7fcd8633b0..68313046aa4 100644
--- a/lib/libmenu/m_item_use.c
+++ b/lib/libmenu/m_item_use.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: m_item_use.c,v 1.6 2001/01/22 18:02:04 millert Exp $ */
+/* $OpenBSD: m_item_use.c,v 1.7 2010/01/12 23:22:08 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,2004 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,7 +29,7 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
/***************************************************************************
@@ -39,7 +39,7 @@
#include "menu.priv.h"
-MODULE_ID("$From: m_item_use.c,v 1.11 2000/12/10 02:16:48 tom Exp $")
+MODULE_ID("$Id: m_item_use.c,v 1.7 2010/01/12 23:22:08 nicm Exp $")
/*---------------------------------------------------------------------------
| Facility : libnmenu
@@ -51,10 +51,11 @@ MODULE_ID("$From: m_item_use.c,v 1.11 2000/12/10 02:16:48 tom Exp $")
| Return Values : E_OK - success
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-set_item_userptr (ITEM * item, void * userptr)
+set_item_userptr(ITEM * item, void *userptr)
{
+ T((T_CALLED("set_item_userptr(%p,%p)"), item, userptr));
Normalize_Item(item)->userptr = userptr;
- RETURN( E_OK );
+ RETURN(E_OK);
}
/*---------------------------------------------------------------------------
@@ -68,9 +69,10 @@ set_item_userptr (ITEM * item, void * userptr)
| NULL is returned.
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(void *)
-item_userptr (const ITEM * item)
+item_userptr(const ITEM * item)
{
- return Normalize_Item(item)->userptr;
+ T((T_CALLED("item_userptr(%p)"), item));
+ returnVoidPtr(Normalize_Item(item)->userptr);
}
/* m_item_use.c */
diff --git a/lib/libmenu/m_item_val.c b/lib/libmenu/m_item_val.c
index 939ebd76fb5..9d4b69c79ce 100644
--- a/lib/libmenu/m_item_val.c
+++ b/lib/libmenu/m_item_val.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: m_item_val.c,v 1.6 2001/01/22 18:02:04 millert Exp $ */
+/* $OpenBSD: m_item_val.c,v 1.7 2010/01/12 23:22:08 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,2004 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,7 +29,7 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
/***************************************************************************
@@ -39,13 +39,13 @@
#include "menu.priv.h"
-MODULE_ID("$From: m_item_val.c,v 1.9 2000/12/10 02:16:48 tom Exp $")
+MODULE_ID("$Id: m_item_val.c,v 1.7 2010/01/12 23:22:08 nicm Exp $")
/*---------------------------------------------------------------------------
| Facility : libnmenu
| Function : int set_item_value(ITEM *item, int value)
|
-| Description : Programmatically set the items selection value. This is
+| Description : Programmatically set the item's 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
@@ -55,18 +55,19 @@ MODULE_ID("$From: m_item_val.c,v 1.9 2000/12/10 02:16:48 tom Exp $")
| E_REQUEST_DENIED - not selectable or single valued menu
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-set_item_value (ITEM *item, bool value)
+set_item_value(ITEM * item, bool value)
{
MENU *menu;
-
+
+ T((T_CALLED("set_item_value(%p,%d)"), item, value));
if (item)
{
menu = item->imenu;
-
+
if ((!(item->opt & O_SELECTABLE)) ||
- (menu && (menu->opt & O_ONEVALUE)))
+ (menu && (menu->opt & O_ONEVALUE)))
RETURN(E_REQUEST_DENIED);
-
+
if (item->value ^ value)
{
item->value = value ? TRUE : FALSE;
@@ -74,7 +75,7 @@ set_item_value (ITEM *item, bool value)
{
if (menu->status & _POSTED)
{
- Move_And_Post_Item(menu,item);
+ Move_And_Post_Item(menu, item);
_nc_Show_Menu(menu);
}
}
@@ -82,7 +83,7 @@ set_item_value (ITEM *item, bool value)
}
else
_nc_Default_Item.value = value;
-
+
RETURN(E_OK);
}
@@ -96,9 +97,10 @@ set_item_value (ITEM *item, bool value)
| FALSE - if item is not selected
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(bool)
-item_value (const ITEM *item)
+item_value(const ITEM * item)
{
- return ((Normalize_Item(item)->value) ? TRUE : FALSE);
+ T((T_CALLED("item_value(%p)"), item));
+ returnBool((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
index 9fbe0fcc874..9297c6c46f2 100644
--- a/lib/libmenu/m_item_vis.c
+++ b/lib/libmenu/m_item_vis.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: m_item_vis.c,v 1.6 2001/01/22 18:02:05 millert Exp $ */
+/* $OpenBSD: m_item_vis.c,v 1.7 2010/01/12 23:22:08 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,2004 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,7 +29,7 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
/***************************************************************************
@@ -39,7 +39,7 @@
#include "menu.priv.h"
-MODULE_ID("$From: m_item_vis.c,v 1.11 2000/12/10 02:16:48 tom Exp $")
+MODULE_ID("$Id: m_item_vis.c,v 1.7 2010/01/12 23:22:08 nicm Exp $")
/*---------------------------------------------------------------------------
| Facility : libnmenu
@@ -52,18 +52,19 @@ MODULE_ID("$From: m_item_vis.c,v 1.11 2000/12/10 02:16:48 tom Exp $")
| FALSE if invisible
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(bool)
-item_visible (const ITEM * item)
+item_visible(const ITEM * item)
{
MENU *menu;
-
- if ( item &&
- (menu=item->imenu) &&
- (menu->status & _POSTED) &&
- ( (menu->toprow + menu->arows) > (item->y) ) &&
- ( item->y >= menu->toprow) )
- return TRUE;
+
+ T((T_CALLED("item_visible(%p)"), item));
+ if (item &&
+ (menu = item->imenu) &&
+ (menu->status & _POSTED) &&
+ ((menu->toprow + menu->arows) > (item->y)) &&
+ (item->y >= menu->toprow))
+ returnBool(TRUE);
else
- return FALSE;
+ returnBool(FALSE);
}
/* m_item_vis.c ends here */
diff --git a/lib/libmenu/m_items.c b/lib/libmenu/m_items.c
index 133b1534003..991d0229838 100644
--- a/lib/libmenu/m_items.c
+++ b/lib/libmenu/m_items.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: m_items.c,v 1.6 2001/01/22 18:02:05 millert Exp $ */
+/* $OpenBSD: m_items.c,v 1.7 2010/01/12 23:22:08 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2004,2005 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,7 +29,7 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
/***************************************************************************
@@ -39,7 +39,7 @@
#include "menu.priv.h"
-MODULE_ID("$From: m_items.c,v 1.9 2000/12/10 02:16:48 tom Exp $")
+MODULE_ID("$Id: m_items.c,v 1.7 2010/01/12 23:22:08 nicm Exp $")
/*---------------------------------------------------------------------------
| Facility : libnmenu
@@ -55,39 +55,42 @@ MODULE_ID("$From: m_items.c,v 1.9 2000/12/10 02:16:48 tom Exp $")
| passed to the function
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-set_menu_items (MENU * menu, ITEM ** items)
+set_menu_items(MENU * menu, ITEM ** items)
{
+ T((T_CALLED("set_menu_items(%p,%p)"), menu, items));
+
if (!menu || (items && !(*items)))
RETURN(E_BAD_ARGUMENT);
-
- if ( menu->status & _POSTED )
+
+ if (menu->status & _POSTED)
RETURN(E_POSTED);
-
+
if (menu->items)
_nc_Disconnect_Items(menu);
-
+
if (items)
{
- if(!_nc_Connect_Items( menu, 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
+| Description : Returns a pointer to the item pointer array of the menu
|
| Return Values : NULL on error
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(ITEM **)
-menu_items (const MENU *menu)
+menu_items(const MENU * menu)
{
- return(menu ? menu->items : (ITEM **)0);
+ T((T_CALLED("menu_items(%p)"), menu));
+ returnItemPtr(menu ? menu->items : (ITEM **) 0);
}
/*---------------------------------------------------------------------------
@@ -100,9 +103,10 @@ menu_items (const MENU *menu)
| Return Values : Number of items or -1 to indicate error.
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-item_count (const MENU *menu)
+item_count(const MENU * menu)
{
- return(menu ? menu->nitems : -1);
+ T((T_CALLED("item_count(%p)"), menu));
+ returnCode(menu ? menu->nitems : -1);
}
/* m_items.c ends here */
diff --git a/lib/libmenu/m_new.c b/lib/libmenu/m_new.c
index c237cb976fa..ce9ece3d4e9 100644
--- a/lib/libmenu/m_new.c
+++ b/lib/libmenu/m_new.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: m_new.c,v 1.7 2001/01/22 18:02:05 millert Exp $ */
+/* $OpenBSD: m_new.c,v 1.8 2010/01/12 23:22:08 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2004,2006 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,7 +29,7 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
/***************************************************************************
@@ -39,7 +39,7 @@
#include "menu.priv.h"
-MODULE_ID("$From: m_new.c,v 1.11 2000/12/10 02:16:48 tom Exp $")
+MODULE_ID("$Id: m_new.c,v 1.8 2010/01/12 23:22:08 nicm Exp $")
/*---------------------------------------------------------------------------
| Facility : libnmenu
@@ -53,10 +53,12 @@ MODULE_ID("$From: m_new.c,v 1.11 2000/12/10 02:16:48 tom Exp $")
| Return Values : NULL on error
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(MENU *)
-new_menu (ITEM ** items)
+new_menu(ITEM ** items)
{
- MENU *menu = (MENU *)calloc(1,sizeof(MENU));
-
+ int err = E_SYSTEM_ERROR;
+ MENU *menu = (MENU *) calloc(1, sizeof(MENU));
+
+ T((T_CALLED("new_menu(%p)"), items));
if (menu)
{
*menu = _nc_Default_Menu;
@@ -65,18 +67,19 @@ new_menu (ITEM ** items)
menu->cols = menu->fcols;
if (items && *items)
{
- if (!_nc_Connect_Items(menu,items))
+ if (!_nc_Connect_Items(menu, items))
{
+ err = E_NOT_CONNECTED;
free(menu);
- menu = (MENU *)0;
+ menu = (MENU *) 0;
}
}
}
if (!menu)
- SET_ERROR(E_SYSTEM_ERROR);
+ SET_ERROR(err);
- return(menu);
+ returnMenu(menu);
}
/*---------------------------------------------------------------------------
@@ -91,17 +94,18 @@ new_menu (ITEM ** items)
| E_POSTED - Menu is already posted
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-free_menu (MENU * menu)
+free_menu(MENU * menu)
{
+ T((T_CALLED("free_menu(%p)"), menu));
if (!menu)
RETURN(E_BAD_ARGUMENT);
-
- if ( menu->status & _POSTED )
+
+ if (menu->status & _POSTED)
RETURN(E_POSTED);
-
- if (menu->items)
+
+ if (menu->items)
_nc_Disconnect_Items(menu);
-
+
if ((menu->status & _MARK_ALLOCATED) && menu->mark)
free(menu->mark);
diff --git a/lib/libmenu/m_opts.c b/lib/libmenu/m_opts.c
index 9ca1078e27b..ce7600244b1 100644
--- a/lib/libmenu/m_opts.c
+++ b/lib/libmenu/m_opts.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: m_opts.c,v 1.7 2001/01/22 18:02:05 millert Exp $ */
+/* $OpenBSD: m_opts.c,v 1.8 2010/01/12 23:22:08 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,2004 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,7 +29,7 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
/***************************************************************************
@@ -39,7 +39,7 @@
#include "menu.priv.h"
-MODULE_ID("$From: m_opts.c,v 1.13 2000/12/10 02:16:48 tom Exp $")
+MODULE_ID("$Id: m_opts.c,v 1.8 2010/01/12 23:22:08 nicm Exp $")
/*---------------------------------------------------------------------------
| Facility : libnmenu
@@ -55,8 +55,10 @@ MODULE_ID("$From: m_opts.c,v 1.13 2000/12/10 02:16:48 tom Exp $")
| E_POSTED - menu is already posted
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-set_menu_opts (MENU * menu, Menu_Options opts)
+set_menu_opts(MENU * menu, Menu_Options opts)
{
+ T((T_CALLED("set_menu_opts(%p,%d)"), menu, opts));
+
opts &= ALL_MENU_OPTS;
if (opts & ~ALL_MENU_OPTS)
@@ -64,18 +66,18 @@ set_menu_opts (MENU * menu, Menu_Options opts)
if (menu)
{
- if ( menu->status & _POSTED )
+ if (menu->status & _POSTED)
RETURN(E_POSTED);
- if ( (opts&O_ROWMAJOR) != (menu->opt&O_ROWMAJOR))
+ 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->toprow = 0;
menu->curitem = menu->items[0];
assert(menu->curitem);
- set_menu_format( menu, menu->frows, menu->fcols );
+ set_menu_format(menu, menu->frows, menu->fcols);
}
}
@@ -85,13 +87,13 @@ set_menu_opts (MENU * menu, Menu_Options opts)
{
ITEM **item;
- if ( ((item=menu->items) != (ITEM**)0) )
- for(;*item;item++)
+ if (((item = menu->items) != (ITEM **) 0))
+ for (; *item; item++)
(*item)->value = FALSE;
}
if (opts & O_SHOWDESC) /* this also changes the geometry */
- _nc_Calculate_Item_Length_and_Width( menu );
+ _nc_Calculate_Item_Length_and_Width(menu);
}
else
_nc_Default_Menu.opt = opts;
@@ -113,10 +115,13 @@ set_menu_opts (MENU * menu, Menu_Options opts)
| E_POSTED - menu is already posted
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-menu_opts_off (MENU *menu, Menu_Options opts)
+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 */
+ MENU *cmenu = menu; /* use a copy because set_menu_opts must detect
+
+ NULL menu itself to adjust its behavior */
+
+ T((T_CALLED("menu_opts_off(%p,%d)"), menu, opts));
opts &= ALL_MENU_OPTS;
if (opts & ~ALL_MENU_OPTS)
@@ -125,7 +130,7 @@ menu_opts_off (MENU *menu, Menu_Options opts)
{
Normalize_Menu(cmenu);
opts = cmenu->opt & ~opts;
- return set_menu_opts( menu, opts );
+ returnCode(set_menu_opts(menu, opts));
}
}
@@ -143,10 +148,13 @@ menu_opts_off (MENU *menu, Menu_Options opts)
| E_POSTED - menu is already posted
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-menu_opts_on (MENU * menu, Menu_Options opts)
+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 */
+ MENU *cmenu = menu; /* use a copy because set_menu_opts must detect
+
+ NULL menu itself to adjust its behavior */
+
+ T((T_CALLED("menu_opts_on(%p,%d)"), menu, opts));
opts &= ALL_MENU_OPTS;
if (opts & ~ALL_MENU_OPTS)
@@ -155,7 +163,7 @@ menu_opts_on (MENU * menu, Menu_Options opts)
{
Normalize_Menu(cmenu);
opts = cmenu->opt | opts;
- return set_menu_opts(menu, opts);
+ returnCode(set_menu_opts(menu, opts));
}
}
@@ -168,9 +176,10 @@ menu_opts_on (MENU * menu, Menu_Options opts)
| Return Values : Menu options
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(Menu_Options)
-menu_opts (const MENU *menu)
+menu_opts(const MENU * menu)
{
- return (ALL_MENU_OPTS & Normalize_Menu( menu )->opt);
+ T((T_CALLED("menu_opts(%p)"), menu));
+ returnMenuOpts(ALL_MENU_OPTS & Normalize_Menu(menu)->opt);
}
/* m_opts.c ends here */
diff --git a/lib/libmenu/m_pad.c b/lib/libmenu/m_pad.c
index 78122817642..4ea8d09fdf8 100644
--- a/lib/libmenu/m_pad.c
+++ b/lib/libmenu/m_pad.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: m_pad.c,v 1.4 2001/01/22 18:02:05 millert Exp $ */
+/* $OpenBSD: m_pad.c,v 1.5 2010/01/12 23:22:08 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,2004 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,7 +29,7 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
/***************************************************************************
@@ -39,7 +39,7 @@
#include "menu.priv.h"
-MODULE_ID("$From: m_pad.c,v 1.5 2000/12/10 02:16:48 tom Exp $")
+MODULE_ID("$Id: m_pad.c,v 1.5 2010/01/12 23:22:08 nicm Exp $")
/* Macro to redraw menu if it is posted and changed */
#define Refresh_Menu(menu) \
@@ -61,18 +61,20 @@ MODULE_ID("$From: m_pad.c,v 1.5 2000/12/10 02:16:48 tom Exp $")
| E_BAD_ARGUMENT - an invalid value has been passed
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-set_menu_pad (MENU *menu, int pad)
+set_menu_pad(MENU * menu, int pad)
{
- bool do_refresh = (menu != (MENU*)0);
+ bool do_refresh = (menu != (MENU *) 0);
- if (!isprint((unsigned char)pad))
+ T((T_CALLED("set_menu_pad(%p,%d)"), menu, pad));
+
+ if (!isprint(UChar(pad)))
RETURN(E_BAD_ARGUMENT);
-
- Normalize_Menu( menu );
+
+ Normalize_Menu(menu);
menu->pad = pad;
-
+
if (do_refresh)
- Refresh_Menu( menu );
+ Refresh_Menu(menu);
RETURN(E_OK);
}
@@ -86,9 +88,10 @@ set_menu_pad (MENU *menu, int pad)
| Return Values : The pad character
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-menu_pad (const MENU * menu)
+menu_pad(const MENU * menu)
{
- return (Normalize_Menu( menu ) -> pad);
+ T((T_CALLED("menu_pad(%p)"), menu));
+ returnCode(Normalize_Menu(menu)->pad);
}
/* m_pad.c ends here */
diff --git a/lib/libmenu/m_pattern.c b/lib/libmenu/m_pattern.c
index f750c02aae3..88ae225339b 100644
--- a/lib/libmenu/m_pattern.c
+++ b/lib/libmenu/m_pattern.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: m_pattern.c,v 1.4 2001/01/22 18:02:05 millert Exp $ */
+/* $OpenBSD: m_pattern.c,v 1.5 2010/01/12 23:22:08 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2005,2006 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,7 +29,7 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
/***************************************************************************
@@ -39,7 +39,7 @@
#include "menu.priv.h"
-MODULE_ID("$From: m_pattern.c,v 1.6 2000/12/10 02:16:48 tom Exp $")
+MODULE_ID("$Id: m_pattern.c,v 1.5 2010/01/12 23:22:08 nicm Exp $")
/*---------------------------------------------------------------------------
| Facility : libnmenu
@@ -53,9 +53,12 @@ MODULE_ID("$From: m_pattern.c,v 1.6 2000/12/10 02:16:48 tom Exp $")
| PatternString - as expected
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(char *)
-menu_pattern (const MENU * menu)
+menu_pattern(const MENU * menu)
{
- return (menu ? (menu->pattern ? menu->pattern : "") : (char *)0);
+ static char empty[] = "";
+
+ T((T_CALLED("menu_pattern(%p)"), menu));
+ returnPtr(menu ? (menu->pattern ? menu->pattern : empty) : 0);
}
/*---------------------------------------------------------------------------
@@ -67,54 +70,56 @@ menu_pattern (const MENU * menu)
|
| 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_NOT_CONNECTED - no items connected to menu
| E_NO_MATCH - no item matches pattern
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-set_menu_pattern (MENU *menu, const char *p)
+set_menu_pattern(MENU * menu, const char *p)
{
ITEM *matchitem;
- int matchpos;
-
- if (!menu || !p)
+ int matchpos;
+
+ T((T_CALLED("set_menu_pattern(%p,%s)"), menu, _nc_visbuf(p)));
+
+ if (!menu || !p)
RETURN(E_BAD_ARGUMENT);
-
+
if (!(menu->items))
RETURN(E_NOT_CONNECTED);
-
- if ( menu->status & _IN_DRIVER )
+
+ 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)
+
+ if (menu->status & _LINK_NEEDED)
_nc_Link_Items(menu);
-
- matchpos = menu->toprow;
+
+ matchpos = menu->toprow;
matchitem = menu->curitem;
assert(matchitem);
-
- while(*p)
+
+ while (*p)
{
- if ( !isprint((unsigned char)(*p)) ||
- (_nc_Match_Next_Character_In_Item_Name(menu,*p,&matchitem) != E_OK) )
+ if (!isprint(UChar(*p)) ||
+ (_nc_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);
+ Adjust_Current_Item(menu, matchpos, matchitem);
RETURN(E_OK);
}
diff --git a/lib/libmenu/m_post.c b/lib/libmenu/m_post.c
index 828177fe568..504174189ad 100644
--- a/lib/libmenu/m_post.c
+++ b/lib/libmenu/m_post.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: m_post.c,v 1.6 2001/01/22 18:02:06 millert Exp $ */
+/* $OpenBSD: m_post.c,v 1.7 2010/01/12 23:22:08 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,2004 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,7 +29,7 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
/***************************************************************************
@@ -39,113 +39,117 @@
#include "menu.priv.h"
-MODULE_ID("$From: m_post.c,v 1.17 2000/12/10 02:16:48 tom Exp $")
+MODULE_ID("$Id: m_post.c,v 1.7 2010/01/12 23:22:08 nicm Exp $")
/*---------------------------------------------------------------------------
-| Facility : libnmenu
-| Function : void _nc_Post_Item(MENU *menu, ITEM *item)
-|
+| Facility : libnmenu
+| Function : void _nc_Post_Item(MENU *menu, ITEM *item)
+|
| Description : Draw the item in the menus window at the current
-| window position
+| window position
|
| Return Values : -
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(void)
-_nc_Post_Item (const MENU * menu, const ITEM * item)
+_nc_Post_Item(const MENU * menu, const ITEM * item)
{
int i;
chtype ch;
int item_x, item_y;
int count = 0;
- bool isfore = FALSE, isback=FALSE, isgrey = FALSE;
-
+ bool isfore = FALSE, isback = FALSE, isgrey = FALSE;
+ int name_len;
+ int desc_len;
+
assert(menu->win);
-
- getyx(menu->win,item_y,item_x);
-
+
+ getyx(menu->win, item_y, item_x);
+
/* We need a marker iff
- it is a onevalued menu and it is the current item
- or it has a selection value
- */
- wattron(menu->win,menu->back);
- if (item->value || (item==menu->curitem))
+ */
+ wattron(menu->win, menu->back);
+ if (item->value || (item == menu->curitem))
{
- if (menu->marklen)
+ if (menu->marklen)
{
/* In a multi selection menu we use the fore attribute
for a selected marker that is not the current one.
This improves visualization of the menu, because now
always the 'normal' marker denotes the current
item. */
- if (!(menu->opt & O_ONEVALUE) && item->value && item!=menu->curitem)
+ if (!(menu->opt & O_ONEVALUE) && item->value && item != menu->curitem)
{
- wattron(menu->win,menu->fore);
+ wattron(menu->win, menu->fore);
isfore = TRUE;
}
- waddstr(menu->win,menu->mark);
+ waddstr(menu->win, menu->mark);
if (isfore)
{
- wattron(menu->win,menu->fore);
+ wattron(menu->win, menu->fore);
isfore = FALSE;
}
}
}
- else /* otherwise we have to wipe out the marker area */
- for(ch=' ',i=menu->marklen;i>0;i--)
- waddch(menu->win,ch);
- wattroff(menu->win,menu->back);
+ else /* otherwise we have to wipe out the marker area */
+ for (ch = ' ', i = menu->marklen; i > 0; i--)
+ waddch(menu->win, ch);
+ wattroff(menu->win, menu->back);
count += menu->marklen;
/* First we have to calculate the attribute depending on selectability
and selection status
- */
+ */
if (!(item->opt & O_SELECTABLE))
{
- wattron(menu->win,menu->grey);
+ wattron(menu->win, menu->grey);
isgrey = TRUE;
}
else
{
- if (item->value || item==menu->curitem)
+ if (item->value || item == menu->curitem)
{
- wattron(menu->win,menu->fore);
+ wattron(menu->win, menu->fore);
isfore = TRUE;
}
else
{
- wattron(menu->win,menu->back);
+ wattron(menu->win, menu->back);
isback = TRUE;
}
}
- waddnstr(menu->win,item->name.str,item->name.length);
- for(ch=' ',i=menu->namelen-item->name.length;i>0;i--)
+ waddnstr(menu->win, item->name.str, item->name.length);
+ name_len = _nc_Calculate_Text_Width(&(item->name));
+ for (ch = ' ', i = menu->namelen - name_len; i > 0; i--)
{
- waddch(menu->win,ch);
+ waddch(menu->win, ch);
}
count += menu->namelen;
/* Show description if required and available */
- if ( (menu->opt & O_SHOWDESC) && menu->desclen>0 )
+ if ((menu->opt & O_SHOWDESC) && menu->desclen > 0)
{
- int m = menu->spc_desc/2;
+ int m = menu->spc_desc / 2;
int cy = -1, cx = -1;
- for(ch=' ',i=0; i < menu->spc_desc; i++)
+ for (ch = ' ', i = 0; i < menu->spc_desc; i++)
{
- if (i==m)
+ if (i == m)
{
- waddch(menu->win,menu->pad);
- getyx(menu->win,cy,cx);
+ waddch(menu->win, menu->pad);
+ getyx(menu->win, cy, cx);
}
else
- waddch(menu->win,ch);
+ waddch(menu->win, ch);
}
if (item->description.length)
- waddnstr(menu->win,item->description.str,item->description.length);
- for(ch=' ',i=menu->desclen-item->description.length; i>0; i--)
+ waddnstr(menu->win, item->description.str, item->description.length);
+ desc_len = _nc_Calculate_Text_Width(&(item->description));
+ for (ch = ' ', i = menu->desclen - desc_len; i > 0; i--)
{
- waddch(menu->win,ch);
+ waddch(menu->win, ch);
}
count += menu->desclen + menu->spc_desc;
@@ -153,47 +157,49 @@ _nc_Post_Item (const MENU * menu, const ITEM * item)
{
int j, k, ncy, ncx;
- assert(cx>=0 && cy>=0);
- getyx(menu->win,ncy,ncx);
- if (isgrey) wattroff(menu->win,menu->grey);
- else if (isfore) wattroff(menu->win,menu->fore);
- wattron(menu->win,menu->back);
- for(j=1; j < menu->spc_rows;j++)
+ assert(cx >= 0 && cy >= 0);
+ getyx(menu->win, ncy, ncx);
+ if (isgrey)
+ wattroff(menu->win, menu->grey);
+ else if (isfore)
+ wattroff(menu->win, menu->fore);
+ wattron(menu->win, menu->back);
+ for (j = 1; j < menu->spc_rows; j++)
{
- if ((item_y+j) < getmaxy(menu->win))
+ if ((item_y + j) < getmaxy(menu->win))
{
- wmove (menu->win,item_y+j,item_x);
- for(k=0;k<count;k++)
- waddch(menu->win,' ');
+ wmove(menu->win, item_y + j, item_x);
+ for (k = 0; k < count; k++)
+ waddch(menu->win, ' ');
}
- if ((cy+j) < getmaxy(menu->win))
- mvwaddch(menu->win,cy+j,cx-1,menu->pad);
+ if ((cy + j) < getmaxy(menu->win))
+ mvwaddch(menu->win, cy + j, cx - 1, menu->pad);
}
- wmove(menu->win,ncy,ncx);
+ wmove(menu->win, ncy, ncx);
if (!isback)
- wattroff(menu->win,menu->back);
+ wattroff(menu->win, menu->back);
}
}
-
+
/* Remove attributes */
if (isfore)
- wattroff(menu->win,menu->fore);
+ wattroff(menu->win, menu->fore);
if (isback)
- wattroff(menu->win,menu->back);
+ wattroff(menu->win, menu->back);
if (isgrey)
- wattroff(menu->win,menu->grey);
-}
+ wattroff(menu->win, menu->grey);
+}
/*---------------------------------------------------------------------------
-| Facility : libnmenu
+| Facility : libnmenu
| Function : void _nc_Draw_Menu(const MENU *)
-|
+|
| Description : Display the menu in its windows
|
| Return Values : -
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(void)
-_nc_Draw_Menu (const MENU * menu)
+_nc_Draw_Menu(const MENU * menu)
{
ITEM *item = menu->items[0];
ITEM *lasthor, *lastvert;
@@ -204,75 +210,78 @@ _nc_Draw_Menu (const MENU * menu)
assert(item && menu->win);
s_bkgd = getbkgd(menu->win);
- wbkgdset(menu->win,menu->back);
+ wbkgdset(menu->win, menu->back);
werase(menu->win);
- wbkgdset(menu->win,s_bkgd);
+ wbkgdset(menu->win, s_bkgd);
- lastvert = (menu->opt & O_NONCYCLIC) ? (ITEM *)0 : item;
+ lastvert = (menu->opt & O_NONCYCLIC) ? (ITEM *) 0 : item;
do
- {
- wmove(menu->win,y,0);
+ {
+ wmove(menu->win, y, 0);
+
+ hitem = item;
+ lasthor = (menu->opt & O_NONCYCLIC) ? (ITEM *) 0 : hitem;
- hitem = item;
- lasthor = (menu->opt & O_NONCYCLIC) ? (ITEM *)0 : hitem;
-
do
{
- _nc_Post_Item( menu, hitem);
+ _nc_Post_Item(menu, hitem);
- wattron(menu->win,menu->back);
- if ( ((hitem = hitem->right) != lasthor) && hitem )
+ wattron(menu->win, menu->back);
+ if (((hitem = hitem->right) != lasthor) && hitem)
{
- int i,j, cy, cx;
+ int i, j, cy, cx;
chtype ch = ' ';
- getyx(menu->win,cy,cx);
- for(j=0;j<menu->spc_rows;j++)
+ getyx(menu->win, cy, cx);
+ for (j = 0; j < menu->spc_rows; j++)
{
- wmove(menu->win,cy+j,cx);
- for(i=0; i < menu->spc_cols; i++)
+ wmove(menu->win, cy + j, cx);
+ for (i = 0; i < menu->spc_cols; i++)
{
- waddch( menu->win,ch);
+ waddch(menu->win, ch);
}
}
- wmove(menu->win,cy,cx+menu->spc_cols);
+ wmove(menu->win, cy, cx + menu->spc_cols);
}
- } while (hitem && (hitem != lasthor));
- wattroff(menu->win,menu->back);
-
+ }
+ while (hitem && (hitem != lasthor));
+ wattroff(menu->win, menu->back);
+
item = item->down;
y += menu->spc_rows;
-
- } while( item && (item != lastvert) );
+
+ }
+ while (item && (item != lastvert));
}
/*---------------------------------------------------------------------------
-| Facility : libnmenu
+| 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
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-post_menu (MENU * menu)
+post_menu(MENU * menu)
{
+ T((T_CALLED("post_menu(%p)"), menu));
+
if (!menu)
RETURN(E_BAD_ARGUMENT);
-
- if ( menu->status & _IN_DRIVER )
+
+ if (menu->status & _IN_DRIVER)
RETURN(E_BAD_STATE);
- if ( menu->status & _POSTED )
+ if (menu->status & _POSTED)
RETURN(E_POSTED);
-
+
if (menu->items && *(menu->items))
{
int y;
@@ -280,54 +289,50 @@ post_menu (MENU * menu)
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(h,menu->width)) )
+ if ((menu->win = newpad(h, menu->width)))
{
y = (maxy >= h) ? h : maxy;
- if (y>=menu->height)
+ if (y >= menu->height)
y = menu->height;
- if(!(menu->sub = subpad(menu->win,y,menu->width,0,0)))
+ 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)
+ 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))
+ if (!(menu->opt & O_ONEVALUE))
{
ITEM **items;
-
- for(items=menu->items;*items;items++)
+
+ for (items = menu->items; *items; items++)
{
(*items)->value = FALSE;
}
}
-
+
_nc_Draw_Menu(menu);
-
- Call_Hook(menu,menuinit);
- Call_Hook(menu,iteminit);
-
+
+ Call_Hook(menu, menuinit);
+ Call_Hook(menu, iteminit);
+
_nc_Show_Menu(menu);
-
+
RETURN(E_OK);
}
/*---------------------------------------------------------------------------
-| Facility : libnmenu
+| Facility : libnmenu
| Function : int unpost_menu(MENU *)
-|
+|
| Description : Detach menu from screen
|
| Return Values : E_OK - success
@@ -336,36 +341,38 @@ post_menu (MENU * menu)
| E_NOT_POSTED - menu is not posted
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-unpost_menu (MENU * menu)
+unpost_menu(MENU * menu)
{
WINDOW *win;
-
+
+ T((T_CALLED("unpost_menu(%p)"), menu));
+
if (!menu)
RETURN(E_BAD_ARGUMENT);
-
- if ( menu->status & _IN_DRIVER )
+
+ if (menu->status & _IN_DRIVER)
RETURN(E_BAD_STATE);
- if ( !( menu->status & _POSTED ) )
+ if (!(menu->status & _POSTED))
RETURN(E_NOT_POSTED);
-
- Call_Hook(menu,itemterm);
- Call_Hook(menu,menuterm);
-
+
+ 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);
}
diff --git a/lib/libmenu/m_req_name.c b/lib/libmenu/m_req_name.c
index 23951eb9c3c..14eda0f1fa4 100644
--- a/lib/libmenu/m_req_name.c
+++ b/lib/libmenu/m_req_name.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: m_req_name.c,v 1.5 2001/01/22 18:02:06 millert Exp $ */
+/* $OpenBSD: m_req_name.c,v 1.6 2010/01/12 23:22:08 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2005,2008 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,7 +29,7 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
/***************************************************************************
@@ -39,27 +39,29 @@
#include "menu.priv.h"
-MODULE_ID("$From: m_req_name.c,v 1.13 2000/12/10 02:16:48 tom Exp $")
+MODULE_ID("$Id: m_req_name.c,v 1.6 2010/01/12 23:22:08 nicm Exp $")
-static const char *request_names[ MAX_MENU_COMMAND - MIN_MENU_COMMAND + 1 ] = {
- "LEFT_ITEM" ,
- "RIGHT_ITEM" ,
- "UP_ITEM" ,
- "DOWN_ITEM" ,
- "SCR_ULINE" ,
- "SCR_DLINE" ,
- "SCR_DPAGE" ,
- "SCR_UPAGE" ,
- "FIRST_ITEM" ,
- "LAST_ITEM" ,
- "NEXT_ITEM" ,
- "PREV_ITEM" ,
- "TOGGLE_ITEM" ,
+static const char *request_names[MAX_MENU_COMMAND - MIN_MENU_COMMAND + 1] =
+{
+ "LEFT_ITEM",
+ "RIGHT_ITEM",
+ "UP_ITEM",
+ "DOWN_ITEM",
+ "SCR_ULINE",
+ "SCR_DLINE",
+ "SCR_DPAGE",
+ "SCR_UPAGE",
+ "FIRST_ITEM",
+ "LAST_ITEM",
+ "NEXT_ITEM",
+ "PREV_ITEM",
+ "TOGGLE_ITEM",
"CLEAR_PATTERN",
- "BACK_PATTERN" ,
- "NEXT_MATCH" ,
- "PREV_MATCH"
+ "BACK_PATTERN",
+ "NEXT_MATCH",
+ "PREV_MATCH"
};
+
#define A_SIZE (sizeof(request_names)/sizeof(request_names[0]))
/*---------------------------------------------------------------------------
@@ -72,18 +74,18 @@ static const char *request_names[ MAX_MENU_COMMAND - MIN_MENU_COMMAND + 1 ] = {
| NULL - on invalid request code
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(const char *)
-menu_request_name ( int request )
+menu_request_name(int request)
{
- if ( (request < MIN_MENU_COMMAND) || (request > MAX_MENU_COMMAND) )
+ T((T_CALLED("menu_request_name(%d)"), request));
+ if ((request < MIN_MENU_COMMAND) || (request > MAX_MENU_COMMAND))
{
SET_ERROR(E_BAD_ARGUMENT);
- return (const char *)0;
+ returnCPtr((const char *)0);
}
else
- return request_names[ request - MIN_MENU_COMMAND ];
+ returnCPtr(request_names[request - MIN_MENU_COMMAND]);
}
-
/*---------------------------------------------------------------------------
| Facility : libnmenu
| Function : int menu_request_by_name (const char *str);
@@ -94,28 +96,30 @@ menu_request_name ( int request )
| E_NO_MATCH - request not found
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-menu_request_by_name ( const char *str )
-{
+menu_request_by_name(const char *str)
+{
/* because the table is so small, it doesn't really hurt
to run sequentially through it.
- */
+ */
unsigned int i = 0;
char buf[16];
-
+
+ T((T_CALLED("menu_request_by_name(%s)"), _nc_visbuf(str)));
+
if (str)
{
- strncpy(buf,str,sizeof(buf));
- while( (i<sizeof(buf)) && (buf[i] != '\0') )
+ strncpy(buf, str, sizeof(buf));
+ while ((i < sizeof(buf)) && (buf[i] != '\0'))
{
- buf[i] = toupper(buf[i]);
+ buf[i] = toupper(UChar(buf[i]));
i++;
}
-
- for (i=0; i < A_SIZE; i++)
+
+ for (i = 0; i < A_SIZE; i++)
{
- if (strncmp(request_names[i],buf,sizeof(buf))==0)
- return MIN_MENU_COMMAND + i;
- }
+ if (strncmp(request_names[i], buf, sizeof(buf)) == 0)
+ returnCode(MIN_MENU_COMMAND + (int)i);
+ }
}
RETURN(E_NO_MATCH);
}
diff --git a/lib/libmenu/m_scale.c b/lib/libmenu/m_scale.c
index ebd8801e9ec..002605cc94b 100644
--- a/lib/libmenu/m_scale.c
+++ b/lib/libmenu/m_scale.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: m_scale.c,v 1.4 2001/01/22 18:02:06 millert Exp $ */
+/* $OpenBSD: m_scale.c,v 1.5 2010/01/12 23:22:08 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,2004 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,7 +29,7 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
/***************************************************************************
@@ -39,7 +39,7 @@
#include "menu.priv.h"
-MODULE_ID("$From: m_scale.c,v 1.5 2000/12/10 02:16:48 tom Exp $")
+MODULE_ID("$Id: m_scale.c,v 1.5 2010/01/12 23:22:08 nicm Exp $")
/*---------------------------------------------------------------------------
| Facility : libnmenu
@@ -53,11 +53,13 @@ MODULE_ID("$From: m_scale.c,v 1.5 2000/12/10 02:16:48 tom Exp $")
| E_NOT_CONNECTED - no items are connected to menu
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-scale_menu (const MENU *menu, int *rows, int *cols)
+scale_menu(const MENU * menu, int *rows, int *cols)
{
- if (!menu)
- RETURN( E_BAD_ARGUMENT );
-
+ T((T_CALLED("scale_menu(%p,%p,%p)"), menu, rows, cols));
+
+ if (!menu)
+ RETURN(E_BAD_ARGUMENT);
+
if (menu->items && *(menu->items))
{
if (rows)
@@ -67,8 +69,7 @@ scale_menu (const MENU *menu, int *rows, int *cols)
RETURN(E_OK);
}
else
- RETURN( E_NOT_CONNECTED );
+ RETURN(E_NOT_CONNECTED);
}
/* m_scale.c ends here */
-
diff --git a/lib/libmenu/m_spacing.c b/lib/libmenu/m_spacing.c
index f31f928d3ae..d1ba795ddbe 100644
--- a/lib/libmenu/m_spacing.c
+++ b/lib/libmenu/m_spacing.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: m_spacing.c,v 1.5 2001/01/22 18:02:06 millert Exp $ */
+/* $OpenBSD: m_spacing.c,v 1.6 2010/01/12 23:22:08 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,2004 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,7 +29,7 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
/***************************************************************************
@@ -39,7 +39,7 @@
#include "menu.priv.h"
-MODULE_ID("$From: m_spacing.c,v 1.12 2000/12/10 02:16:48 tom Exp $")
+MODULE_ID("$Id: m_spacing.c,v 1.6 2010/01/12 23:22:08 nicm Exp $")
#define MAX_SPC_DESC ((TABSIZE) ? (TABSIZE) : 8)
#define MAX_SPC_COLS ((TABSIZE) ? (TABSIZE) : 8)
@@ -49,15 +49,17 @@ MODULE_ID("$From: m_spacing.c,v 1.12 2000/12/10 02:16:48 tom Exp $")
| Facility : libnmenu
| Function : int set_menu_spacing(MENU *menu,int desc, int r, int c);
|
-| Description : Set the spacing between entried
+| Description : Set the spacing between entries
|
| Return Values : E_OK - on success
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-set_menu_spacing
-(MENU *menu, int s_desc, int s_row, int s_col )
+set_menu_spacing(MENU * menu, int s_desc, int s_row, int s_col)
{
- MENU *m; /* split for ATAC workaround */
+ MENU *m; /* split for ATAC workaround */
+
+ T((T_CALLED("set_menu_spacing(%p,%d,%d,%d)"), menu, s_desc, s_row, s_col));
+
m = Normalize_Menu(menu);
assert(m);
@@ -65,19 +67,18 @@ set_menu_spacing
RETURN(E_POSTED);
if (((s_desc < 0) || (s_desc > MAX_SPC_DESC)) ||
- ((s_row < 0) || (s_row > MAX_SPC_ROWS)) ||
- ((s_col < 0) || (s_col > MAX_SPC_COLS)))
+ ((s_row < 0) || (s_row > MAX_SPC_ROWS)) ||
+ ((s_col < 0) || (s_col > MAX_SPC_COLS)))
RETURN(E_BAD_ARGUMENT);
m->spc_desc = s_desc ? s_desc : 1;
- m->spc_rows = s_row ? s_row : 1;
- m->spc_cols = s_col ? s_col : 1;
+ m->spc_rows = s_row ? s_row : 1;
+ m->spc_cols = s_col ? s_col : 1;
_nc_Calculate_Item_Length_and_Width(m);
RETURN(E_OK);
}
-
/*---------------------------------------------------------------------------
| Facility : libnmenu
| Function : int menu_spacing (const MENU *,int *,int *,int *);
@@ -87,15 +88,21 @@ set_menu_spacing
| Return Values : E_OK - on success
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-menu_spacing ( const MENU *menu, int* s_desc, int* s_row, int* s_col)
+menu_spacing(const MENU * menu, int *s_desc, int *s_row, int *s_col)
{
- const MENU *m; /* split for ATAC workaround */
+ const MENU *m; /* split for ATAC workaround */
+
+ T((T_CALLED("menu_spacing(%p,%p,%p,%p)"), menu, s_desc, s_row, s_col));
+
m = Normalize_Menu(menu);
assert(m);
- if (s_desc) *s_desc = m->spc_desc;
- if (s_row) *s_row = m->spc_rows;
- if (s_col) *s_col = m->spc_cols;
+ if (s_desc)
+ *s_desc = m->spc_desc;
+ if (s_row)
+ *s_row = m->spc_rows;
+ if (s_col)
+ *s_col = m->spc_cols;
RETURN(E_OK);
}
diff --git a/lib/libmenu/m_sub.c b/lib/libmenu/m_sub.c
index d91658f057d..7204ba47e4b 100644
--- a/lib/libmenu/m_sub.c
+++ b/lib/libmenu/m_sub.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: m_sub.c,v 1.4 2001/01/22 18:02:06 millert Exp $ */
+/* $OpenBSD: m_sub.c,v 1.5 2010/01/12 23:22:08 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,2004 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,7 +29,7 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
/***************************************************************************
@@ -39,7 +39,7 @@
#include "menu.priv.h"
-MODULE_ID("$From: m_sub.c,v 1.5 2000/12/10 02:16:48 tom Exp $")
+MODULE_ID("$Id: m_sub.c,v 1.5 2010/01/12 23:22:08 nicm Exp $")
/*---------------------------------------------------------------------------
| Facility : libnmenu
@@ -51,18 +51,20 @@ MODULE_ID("$From: m_sub.c,v 1.5 2000/12/10 02:16:48 tom Exp $")
| E_POSTED - menu is already posted
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-set_menu_sub (MENU *menu, WINDOW *win)
+set_menu_sub(MENU * menu, WINDOW *win)
{
+ T((T_CALLED("set_menu_sub(%p,%p)"), menu, win));
+
if (menu)
{
- if ( menu->status & _POSTED )
+ 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);
}
@@ -75,10 +77,12 @@ set_menu_sub (MENU *menu, WINDOW *win)
| Return Values : NULL on error, otherwise a pointer to the window
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(WINDOW *)
-menu_sub (const MENU * menu)
+menu_sub(const MENU * menu)
{
- const MENU* m = Normalize_Menu(menu);
- return Get_Menu_Window(m);
+ const MENU *m = Normalize_Menu(menu);
+
+ T((T_CALLED("menu_sub(%p)"), menu));
+ returnWin(Get_Menu_Window(m));
}
/* m_sub.c ends here */
diff --git a/lib/libmenu/m_adabind.c b/lib/libmenu/m_trace.c
index c9b134866e9..2adca5df7b2 100644
--- a/lib/libmenu/m_adabind.c
+++ b/lib/libmenu/m_trace.c
@@ -1,7 +1,5 @@
-/* $OpenBSD: m_adabind.c,v 1.1 1998/07/24 16:38:52 millert Exp $ */
-
/****************************************************************************
- * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * Copyright (c) 2004,2005 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,39 +27,51 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <Juergen.Pfeifer@T-Online.de> 1995,1997 *
+ * Author: Thomas E. Dickey *
****************************************************************************/
-/***************************************************************************
-* Module m_adabind.c *
-* Helper routines to ease the implementation of an Ada95 binding to *
-* ncurses. For details and copyright of the binding see the ../Ada95 *
-* subdirectory. *
-***************************************************************************/
#include "menu.priv.h"
-MODULE_ID("$From: m_adabind.c,v 1.6 1998/02/11 12:13:50 tom Exp $")
+MODULE_ID("$Id: m_trace.c,v 1.1 2010/01/12 23:22:08 nicm Exp $")
+
+NCURSES_EXPORT(ITEM *)
+_nc_retrace_item(ITEM * code)
+{
+ T((T_RETURN("%p"), code));
+ return code;
+}
+
+NCURSES_EXPORT(ITEM **)
+_nc_retrace_item_ptr(ITEM ** code)
+{
+ T((T_RETURN("%p"), code));
+ return code;
+}
-/* Prototypes for the functions in this module */
-void _nc_ada_normalize_menu_opts (int *opt);
-void _nc_ada_normalize_item_opts (int *opt);
-ITEM* _nc_get_item(const MENU*, int);
+NCURSES_EXPORT(Item_Options)
+_nc_retrace_item_opts(Item_Options code)
+{
+ T((T_RETURN("%d"), code));
+ return code;
+}
-void _nc_ada_normalize_menu_opts (int *opt)
+NCURSES_EXPORT(MENU *)
+_nc_retrace_menu(MENU * code)
{
- *opt = ALL_MENU_OPTS & (*opt);
+ T((T_RETURN("%p"), code));
+ return code;
}
-void _nc_ada_normalize_item_opts (int *opt)
+NCURSES_EXPORT(Menu_Hook)
+_nc_retrace_menu_hook(Menu_Hook code)
{
- *opt = ALL_ITEM_OPTS & (*opt);
+ T((T_RETURN("%p"), code));
+ return code;
}
-ITEM* _nc_get_item(const MENU* menu, int idx) {
- if (menu && menu->items && idx>=0 && (idx<menu->nitems))
- {
- return menu->items[idx];
- }
- else
- return (ITEM*)0;
+NCURSES_EXPORT(Menu_Options)
+_nc_retrace_menu_opts(Menu_Options code)
+{
+ T((T_RETURN("%d"), code));
+ return code;
}
diff --git a/lib/libmenu/m_userptr.c b/lib/libmenu/m_userptr.c
index 1e8894e0ca8..a97a5d857a1 100644
--- a/lib/libmenu/m_userptr.c
+++ b/lib/libmenu/m_userptr.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: m_userptr.c,v 1.6 2001/01/22 18:02:06 millert Exp $ */
+/* $OpenBSD: m_userptr.c,v 1.7 2010/01/12 23:22:08 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,2004 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,7 +29,7 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
/***************************************************************************
@@ -39,7 +39,7 @@
#include "menu.priv.h"
-MODULE_ID("$From: m_userptr.c,v 1.11 2000/12/10 02:16:48 tom Exp $")
+MODULE_ID("$Id: m_userptr.c,v 1.7 2010/01/12 23:22:08 nicm Exp $")
/*---------------------------------------------------------------------------
| Facility : libnmenu
@@ -51,10 +51,11 @@ MODULE_ID("$From: m_userptr.c,v 1.11 2000/12/10 02:16:48 tom Exp $")
| Return Values : E_OK - success
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-set_menu_userptr (MENU * menu, void * userptr)
+set_menu_userptr(MENU * menu, void *userptr)
{
+ T((T_CALLED("set_menu_userptr(%p,%p)"), menu, userptr));
Normalize_Menu(menu)->userptr = userptr;
- RETURN( E_OK );
+ RETURN(E_OK);
}
/*---------------------------------------------------------------------------
@@ -68,9 +69,10 @@ set_menu_userptr (MENU * menu, void * userptr)
| NULL is returned
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(void *)
-menu_userptr (const MENU * menu)
+menu_userptr(const MENU * menu)
{
- return( Normalize_Menu(menu)->userptr);
+ T((T_CALLED("menu_userptr(%p)"), menu));
+ returnVoidPtr(Normalize_Menu(menu)->userptr);
}
/* m_userptr.c ends here */
diff --git a/lib/libmenu/m_win.c b/lib/libmenu/m_win.c
index 988e9695f18..369a922214f 100644
--- a/lib/libmenu/m_win.c
+++ b/lib/libmenu/m_win.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: m_win.c,v 1.6 2001/01/22 18:02:06 millert Exp $ */
+/* $OpenBSD: m_win.c,v 1.7 2010/01/12 23:22:08 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,2004 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,7 +29,7 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
/***************************************************************************
@@ -39,7 +39,7 @@
#include "menu.priv.h"
-MODULE_ID("$From: m_win.c,v 1.10 2000/12/10 02:16:48 tom Exp $")
+MODULE_ID("$Id: m_win.c,v 1.7 2010/01/12 23:22:08 nicm Exp $")
/*---------------------------------------------------------------------------
| Facility : libnmenu
@@ -51,18 +51,20 @@ MODULE_ID("$From: m_win.c,v 1.10 2000/12/10 02:16:48 tom Exp $")
| E_POSTED - menu is already posted
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-set_menu_win (MENU *menu, WINDOW *win)
+set_menu_win(MENU * menu, WINDOW *win)
{
+ T((T_CALLED("set_menu_win(%p,%p)"), menu, win));
+
if (menu)
{
- if ( menu->status & _POSTED )
+ 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);
}
@@ -75,10 +77,12 @@ set_menu_win (MENU *menu, WINDOW *win)
| Return Values : NULL on error, otherwise pointer to window
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(WINDOW *)
-menu_win (const MENU *menu)
+menu_win(const MENU * menu)
{
- const MENU* m = Normalize_Menu(menu);
- return (m->userwin ? m->userwin : stdscr);
+ const MENU *m = Normalize_Menu(menu);
+
+ T((T_CALLED("menu_win(%p)"), menu));
+ returnWin(m->userwin ? m->userwin : stdscr);
}
/* m_win.c ends here */
diff --git a/lib/libmenu/menu.3tbl b/lib/libmenu/menu.3tbl
index cf7e1e6d5cd..828ba82080f 100644
--- a/lib/libmenu/menu.3tbl
+++ b/lib/libmenu/menu.3tbl
@@ -1,8 +1,8 @@
'\" t
-.\" $OpenBSD: menu.3tbl,v 1.5 2000/07/24 04:06:12 millert Exp $
+.\" $OpenBSD: menu.3tbl,v 1.6 2010/01/12 23:22:08 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998-2002,2006 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -29,7 +29,7 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: menu.3x,v 1.14 2000/07/15 22:55:59 tom Exp $
+.\" $Id: menu.3tbl,v 1.6 2010/01/12 23:22:08 nicm Exp $
.TH menu 3 ""
.SH NAME
\fBmenu\fR - curses extension for programming menus
@@ -41,25 +41,25 @@ The \fBmenu\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.
-
+.PP
The \fBmenu\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 \fBmenu\fR library, link with the options
\fB-lmenu -lcurses\fR.
-
+.
.SS Current Default Values for Item Attributes
-
+.
The \fBmenu\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.
-
+.
.TS
l l .
\fBcurses\fR Routine Name Manual Page Name
@@ -133,57 +133,60 @@ unpost_menu \fBmenu_post\fR(3)
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
+.B E_OK
The routine succeeded.
.TP 5
-\fBE_SYSTEM_ERROR\fR
-System error occurred (see \fBerrno\fR).
-.TP 5
-\fBE_BAD_ARGUMENT\fR
+.B E_BAD_ARGUMENT
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
+.B E_BAD_STATE
Routine was called from an initialization or termination function.
.TP 5
-\fBE_NO_ROOM\fR
-Menu is too large for its window.
+.B E_NO_MATCH
+Character failed to match.
.TP 5
-\fBE_NOT_POSTED\fR
-The menu has not been posted.
+.B E_NO_ROOM
+Menu is too large for its window.
.TP 5
-\fBE_UNKNOWN_COMMAND\fR
-The menu driver code saw an unknown request code.
+.B E_NOT_CONNECTED
+No items are connected to the menu.
.TP 5
-\fBE_NO_MATCH\fR
-Character failed to match.
+.B E_NOT_POSTED
+The menu has not been posted.
.TP 5
-\fBE_NOT_SELECTABLE\fR
+.B E_NOT_SELECTABLE
The designated item cannot be selected.
.TP 5
-\fBE_NOT_CONNECTED\fR
-No items are connected to the menu.
+.B E_POSTED
+The menu is already posted.
.TP 5
-\fBE_REQUEST_DENIED\fR
+.B E_REQUEST_DENIED
The menu driver could not process the request.
+.TP 5
+.B E_SYSTEM_ERROR
+System error occurred (see \fBerrno\fR).
+.TP 5
+.B E_UNKNOWN_COMMAND
+The menu driver code saw an unknown request code.
.SH SEE ALSO
-\fBcurses\fR(3) and 3 pages whose names begin "menu_" for detailed
+\fBcurses\fR(3) and related 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 libcurses.a; that is,
-you want to say `-lmenu -lcurses', not the other way around (which would
-give you a link error using GNU \fBld\fR(1) and many other linkers).
+.PP
+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
+usually give a link-error).
.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.
+.SH SEE ALSO
+This describes \fBncurses\fR
+version 5.7.
.\"#
.\"# The following sets edit modes for GNU EMACS
.\"# Local Variables:
diff --git a/lib/libmenu/menu.h b/lib/libmenu/menu.h
index 19d0ab5fe51..a5f3a5e2bf7 100644
--- a/lib/libmenu/menu.h
+++ b/lib/libmenu/menu.h
@@ -1,7 +1,5 @@
-/* $OpenBSD: menu.h,v 1.7 2001/01/22 18:02:07 millert Exp $ */
-
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,2007 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,9 +27,11 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
+/* $Id: menu.h,v 1.8 2010/01/12 23:22:08 nicm Exp $ */
+
#ifndef ETI_MENU
#define ETI_MENU
@@ -78,7 +78,7 @@ typedef struct tagITEM
short x;
bool value; /* Selection value */
- struct tagITEM *left; /* neighbour items */
+ struct tagITEM *left; /* neighbor items */
struct tagITEM *right;
struct tagITEM *up;
struct tagITEM *down;
@@ -217,23 +217,23 @@ extern NCURSES_EXPORT(int) pos_menu_cursor (const MENU *);
extern NCURSES_EXPORT(int) post_menu (MENU *);
extern NCURSES_EXPORT(int) scale_menu (const MENU *,int *,int *);
extern NCURSES_EXPORT(int) set_current_item (MENU *menu,ITEM *item);
-extern NCURSES_EXPORT(int) set_item_init (MENU *,void(*)(MENU *));
+extern NCURSES_EXPORT(int) set_item_init (MENU *, Menu_Hook);
extern NCURSES_EXPORT(int) set_item_opts (ITEM *,Item_Options);
-extern NCURSES_EXPORT(int) set_item_term (MENU *,void(*)(MENU *));
+extern NCURSES_EXPORT(int) set_item_term (MENU *, Menu_Hook);
extern NCURSES_EXPORT(int) set_item_userptr (ITEM *, void *);
extern NCURSES_EXPORT(int) set_item_value (ITEM *,bool);
extern NCURSES_EXPORT(int) set_menu_back (MENU *,chtype);
extern NCURSES_EXPORT(int) set_menu_fore (MENU *,chtype);
extern NCURSES_EXPORT(int) set_menu_format (MENU *,int,int);
extern NCURSES_EXPORT(int) set_menu_grey (MENU *,chtype);
-extern NCURSES_EXPORT(int) set_menu_init (MENU *,void(*)(MENU *));
+extern NCURSES_EXPORT(int) set_menu_init (MENU *, Menu_Hook);
extern NCURSES_EXPORT(int) set_menu_items (MENU *,ITEM **);
extern NCURSES_EXPORT(int) set_menu_mark (MENU *, const char *);
extern NCURSES_EXPORT(int) set_menu_opts (MENU *,Menu_Options);
extern NCURSES_EXPORT(int) set_menu_pad (MENU *,int);
extern NCURSES_EXPORT(int) set_menu_pattern (MENU *,const char *);
extern NCURSES_EXPORT(int) set_menu_sub (MENU *,WINDOW *);
-extern NCURSES_EXPORT(int) set_menu_term (MENU *,void(*)(MENU *));
+extern NCURSES_EXPORT(int) set_menu_term (MENU *, Menu_Hook);
extern NCURSES_EXPORT(int) set_menu_userptr (MENU *,void *);
extern NCURSES_EXPORT(int) set_menu_win (MENU *,WINDOW *);
extern NCURSES_EXPORT(int) set_top_row (MENU *,int);
diff --git a/lib/libmenu/menu.priv.h b/lib/libmenu/menu.priv.h
index 3d7527c6b07..913e0d1c795 100644
--- a/lib/libmenu/menu.priv.h
+++ b/lib/libmenu/menu.priv.h
@@ -1,7 +1,7 @@
-/* $OpenBSD: menu.priv.h,v 1.7 2001/01/22 18:02:07 millert Exp $ */
+/* $OpenBSD: menu.priv.h,v 1.8 2010/01/12 23:22:08 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2004,2005 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,14 +29,20 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
+/* $Id: menu.priv.h,v 1.8 2010/01/12 23:22:08 nicm Exp $ */
+
/***************************************************************************
* Module menu.priv.h *
* Top level private header file for all libnmenu modules *
***************************************************************************/
+#ifndef MENU_PRIV_H_incl
+#define MENU_PRIV_H_incl 1
+
+#include "curses.priv.h"
#include "mf_common.h"
#include "menu.h"
@@ -102,10 +108,13 @@ extern NCURSES_EXPORT_VAR(MENU) _nc_Default_Menu;
{ (menu)->pindex = 0; \
(menu)->pattern[0] = '\0'; }
+#define UChar(c) ((unsigned char)(c))
+
/* Internal functions. */
extern NCURSES_EXPORT(void) _nc_Draw_Menu (const MENU *);
extern NCURSES_EXPORT(void) _nc_Show_Menu (const MENU *);
extern NCURSES_EXPORT(void) _nc_Calculate_Item_Length_and_Width (MENU *);
+extern NCURSES_EXPORT(int) _nc_Calculate_Text_Width(const TEXT *);
extern NCURSES_EXPORT(void) _nc_Post_Item (const MENU *, const ITEM *);
extern NCURSES_EXPORT(bool) _nc_Connect_Items (MENU *, ITEM **);
extern NCURSES_EXPORT(void) _nc_Disconnect_Items (MENU *);
@@ -114,3 +123,32 @@ extern NCURSES_EXPORT(void) _nc_Link_Items (MENU *);
extern NCURSES_EXPORT(int) _nc_Match_Next_Character_In_Item_Name (MENU*,int,ITEM**);
extern NCURSES_EXPORT(int) _nc_menu_cursor_pos (const MENU* menu, const ITEM* item,
int* pY, int* pX);
+
+#ifdef TRACE
+
+#define returnItem(code) TRACE_RETURN(code,item)
+#define returnItemPtr(code) TRACE_RETURN(code,item_ptr)
+#define returnItemOpts(code) TRACE_RETURN(code,item_opts)
+#define returnMenu(code) TRACE_RETURN(code,menu)
+#define returnMenuHook(code) TRACE_RETURN(code,menu_hook)
+#define returnMenuOpts(code) TRACE_RETURN(code,menu_opts)
+
+extern NCURSES_EXPORT(ITEM *) _nc_retrace_item (ITEM *);
+extern NCURSES_EXPORT(ITEM **) _nc_retrace_item_ptr (ITEM **);
+extern NCURSES_EXPORT(Item_Options) _nc_retrace_item_opts (Item_Options);
+extern NCURSES_EXPORT(MENU *) _nc_retrace_menu (MENU *);
+extern NCURSES_EXPORT(Menu_Hook) _nc_retrace_menu_hook (Menu_Hook);
+extern NCURSES_EXPORT(Menu_Options) _nc_retrace_menu_opts (Menu_Options);
+
+#else /* !TRACE */
+
+#define returnItem(code) return code
+#define returnItemPtr(code) return code
+#define returnItemOpts(code) return code
+#define returnMenu(code) return code
+#define returnMenuHook(code) return code
+#define returnMenuOpts(code) return code
+
+#endif /* TRACE/!TRACE */
+
+#endif /* MENU_PRIV_H_incl */
diff --git a/lib/libmenu/menu_attributes.3 b/lib/libmenu/menu_attributes.3
index e400d63fe20..60990ba50b8 100644
--- a/lib/libmenu/menu_attributes.3
+++ b/lib/libmenu/menu_attributes.3
@@ -1,8 +1,8 @@
'\" t
-.\" $OpenBSD: menu_attributes.3,v 1.1 2000/07/24 04:06:12 millert Exp $
+.\" $OpenBSD: menu_attributes.3,v 1.2 2010/01/12 23:22:08 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998-2006,2008 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -29,7 +29,7 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: menu_attributes.3x,v 1.6 1998/11/29 01:09:20 Rick.Ohnemus Exp $
+.\" $Id: menu_attributes.3,v 1.2 2010/01/12 23:22:08 nicm Exp $
.TH menu_attributes 3 ""
.SH NAME
\fBmenu_attributes\fR - color and attribute control for menus
@@ -56,34 +56,34 @@ int menu_pad(const MENU *menu);
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.
-
+is \fBA_REVERSE\fR.
+.PP
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.
-
+.PP
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.
-
+.PP
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
+.B E_OK
The routine succeeded.
.TP 5
-\fBE_SYSTEM_ERROR\fR
+.B E_SYSTEM_ERROR
System error occurred (see \fBerrno\fR).
.TP 5
-\fBE_BAD_ARGUMENT\fR
+.B E_BAD_ARGUMENT
Routine detected an incorrect or out-of-range argument.
.SH SEE ALSO
-\fBcurses\fR(3) and 3 pages whose names begin with "menu_" for detailed
+\fBcurses\fR(3) and related 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
diff --git a/lib/libmenu/menu_cursor.3 b/lib/libmenu/menu_cursor.3
index ce4599d2fbc..3f657861eae 100644
--- a/lib/libmenu/menu_cursor.3
+++ b/lib/libmenu/menu_cursor.3
@@ -1,8 +1,8 @@
'\" t
-.\" $OpenBSD: menu_cursor.3,v 1.6 1999/01/22 03:45:06 millert Exp $
+.\" $OpenBSD: menu_cursor.3,v 1.7 2010/01/12 23:22:08 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998,2006 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -29,7 +29,7 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: menu_cursor.3x,v 1.5 1998/11/29 01:09:30 Rick.Ohnemus Exp $
+.\" $Id: menu_cursor.3,v 1.7 2010/01/12 23:22:08 nicm Exp $
.TH menu_cursor 3 ""
.SH NAME
\fBmenu_cursor\fR - position a menu's cursor
@@ -45,16 +45,16 @@ 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
+.B E_OK
The routine succeeded.
.TP 5
-\fBE_SYSTEM_ERROR\fR
+.B E_SYSTEM_ERROR
System error occurred (see \fBerrno\fR).
.TP 5
-\fBE_BAD_ARGUMENT\fR
+.B E_BAD_ARGUMENT
Routine detected an incorrect or out-of-range argument.
.TP 5
-\fBE_NOT_POSTED\fR
+.B E_NOT_POSTED
The menu has not been posted.
.SH SEE ALSO
\fBcurses\fR(3), \fBmenu\fR(3).
diff --git a/lib/libmenu/menu_driver.3 b/lib/libmenu/menu_driver.3
index fb6cd06759a..5b9bb140fb1 100644
--- a/lib/libmenu/menu_driver.3
+++ b/lib/libmenu/menu_driver.3
@@ -1,7 +1,7 @@
-.\" $OpenBSD: menu_driver.3,v 1.6 2000/03/14 21:31:46 aaron Exp $
+.\" $OpenBSD: menu_driver.3,v 1.7 2010/01/12 23:22:08 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -28,7 +28,7 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.'" $From: menu_driver.3x,v 1.8 1999/01/09 22:55:18 tom Exp $
+.\" $Id: menu_driver.3,v 1.7 2010/01/12 23:22:08 nicm Exp $
.TH menu_driver 3 ""
.SH NAME
\fBmenu_driver\fR - command-processing loop of the menu system
@@ -39,9 +39,21 @@ 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 three major input cases; either
-the input is a menu navigation request, it's a printable ASCII character or it
-is the KEY_MOUSE special key associated with an mouse event.
+through \fBmenu_driver\fR. This routine has three major input cases:
+.TP 3
+-
+The input is a form navigation request.
+Navigation request codes are constants defined in \fB<form.h>\fP,
+which are distinct from the key- and character codes returned by \fBwgetch\fP.
+.TP 3
+-
+The input is a printable character.
+Printable characters (which must be positive, less than 256) are
+checked according to the program's locale settings.
+.TP 3
+-
+The input is the KEY_MOUSE special key associated with an mouse event.
+.PP
The menu driver requests are as follows:
.TP 5
REQ_LEFT_ITEM
@@ -95,34 +107,65 @@ Move to the next item matching the pattern match.
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
+If the second argument is a printable 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.
+.SS MOUSE HANDLING
.PP
If the second argument is the KEY_MOUSE special key, the associated
mouse event is translated into one of the above pre-defined requests.
Currently only clicks in the user window (e.g., inside the menu display
-area or the decoration window) are handled. If you click above the
-display region of the menu, a REQ_SCR_ULINE is generated, if you
-doubleclick a REQ_SCR_UPAGE is generated and if you tripleclick a
-REQ_FIRST_ITEM is generated. If you click below the display region of
-the menu, a REQ_SCR_DLINE is generated, if you doubleclick a REQ_SCR_DPAGE
-is generated and if you tripleclick a REQ_LAST_ITEM is generated. If you
-click at an item inside the display area of the menu, the menu cursor
-is positioned to that item. If you double-click at an item a REQ_TOGGLE_ITEM
-is generated and \fBE_UNKNOWN_COMMAND\fR is returned. This return value makes
-sense, because a double click usually means that an item-specific action should
-be returned. It's exactly the purpose of this return value to signal that an
-application specific command should be executed. If a translation
+area or the decoration window) are handled.
+.PP
+If you click above the display region of the menu:
+.RS
+.TP
+a REQ_SCR_ULINE is generated for a single click,
+.TP
+a REQ_SCR_UPAGE is generated for a double-click and
+.TP
+a REQ_FIRST_ITEM is generated for a triple-click.
+.RE
+.PP
+If you click below the display region of the menu:
+.RS
+.TP
+a REQ_SCR_DLINE is generated for a single click,
+.TP
+a REQ_SCR_DPAGE is generated for a double-click and
+.TP
+a REQ_LAST_ITEM is generated for a triple-click.
+.RE
+.PP
+If you click at an item inside the display area of the menu:
+.RS
+.TP 3
+-
+the menu cursor is positioned to that item.
+.TP 3
+-
+If you double-click an item a REQ_TOGGLE_ITEM
+is generated and \fBE_UNKNOWN_COMMAND\fR is returned.
+This return value makes sense,
+because a double click usually means that an item-specific action should
+be returned.
+It is exactly the purpose of this return value to signal that an
+application specific command should be executed.
+.TP 3
+-
+If a translation
into a request was done, \fBmenu_driver\fR returns the result of this request.
-If you clicked outside the user window or the mouse event couldn't be translated
+.RE
+.PP
+If you clicked outside the user window or the mouse event could not be translated
into a menu request an \fBE_REQUEST_DENIED\fR is returned.
+.SS APPLICATION-DEFINED COMMANDS
.PP
-If the second argument is neither printable ASCII nor one of the above
+If the second argument is neither printable nor one of the above
pre-defined menu requests or KEY_MOUSE, the drive assumes 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
@@ -130,31 +173,33 @@ pre-defined requests.
.SH RETURN VALUE
\fBmenu_driver\fR return one of the following error codes:
.TP 5
-\fBE_OK\fR
+.B E_OK
The routine succeeded.
.TP 5
-\fBE_SYSTEM_ERROR\fR
+.B E_SYSTEM_ERROR
System error occurred (see \fBerrno\fR).
.TP 5
-\fBE_BAD_ARGUMENT\fR
+.B E_BAD_ARGUMENT
Routine detected an incorrect or out-of-range argument.
.TP 5
-\fBE_BAD_STATE\fR
+.B E_BAD_STATE
Routine was called from an initialization or termination function.
.TP 5
-\fBE_NOT_POSTED\fR
+.B E_NOT_POSTED
The menu has not been posted.
.TP 5
-\fBE_UNKNOWN_COMMAND\fR
+.B E_UNKNOWN_COMMAND
The menu driver code saw an unknown request code.
.TP 5
-\fBE_NO_MATCH\fR
+.B E_NO_MATCH
Character failed to match.
.TP 5
-\fBE_REQUEST_DENIED\fR
+.B E_REQUEST_DENIED
The menu driver could not process the request.
.SH SEE ALSO
-\fBcurses\fR(3), \fBmenu\fR(3).
+\fBcurses\fR(3),
+\fBmenu\fR(3),
+\fBwgetch\fR(3).
.SH NOTES
The header file \fB<menu.h>\fR automatically includes the header files
\fB<curses.h>\fR.
diff --git a/lib/libmenu/menu_format.3 b/lib/libmenu/menu_format.3
index 2ea075b1585..2f827be8fa7 100644
--- a/lib/libmenu/menu_format.3
+++ b/lib/libmenu/menu_format.3
@@ -1,8 +1,8 @@
'\" t
-.\" $OpenBSD: menu_format.3,v 1.6 1999/01/22 03:45:06 millert Exp $
+.\" $OpenBSD: menu_format.3,v 1.7 2010/01/12 23:22:08 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998-2001,2006 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -29,7 +29,7 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: menu_format.3x,v 1.7 1998/11/29 01:09:39 Rick.Ohnemus Exp $
+.\" $Id: menu_format.3,v 1.7 2010/01/12 23:22:08 nicm Exp $
.TH menu_format 3 ""
.SH NAME
\fBmenu_format\fR - set and get menu sizes
@@ -38,35 +38,38 @@
.br
int set_menu_format(MENU *menu, int rows, int cols);
.br
-int menu_format(const MENU *menu, int *rows, int *cols);
+void menu_format(const MENU *menu, int *rows, int *cols);
.br
.SH DESCRIPTION
The function \fBset_menu_format\fR sets the maximum display size of the given
menu. If this size is too small to display all menu items, the menu will be
made scrollable. If this size is larger than the menus subwindow and the
subwindow is too small to display all menu items, \fBpost_menu()\fR will fail.
-
+.PP
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.
-
+.PP
The function \fBmenu_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
+.B E_OK
The routine succeeded.
.TP 5
-\fBE_SYSTEM_ERROR\fR
+.B E_SYSTEM_ERROR
System error occurred (see \fBerrno\fR).
.TP 5
-\fBE_BAD_ARGUMENT\fR
+.B E_BAD_ARGUMENT
Routine detected an incorrect or out-of-range argument.
.TP 5
-\fBE_POSTED\fR
+.B E_POSTED
The menu is already posted.
+.TP 5
+.B E_NOT_CONNECTED
+No items are connected to the menu.
.SH SEE ALSO
\fBcurses\fR(3), \fBmenu\fR(3).
.SH NOTES
diff --git a/lib/libmenu/menu_hook.3 b/lib/libmenu/menu_hook.3
index 88066b67a4f..dc8bdfd10be 100644
--- a/lib/libmenu/menu_hook.3
+++ b/lib/libmenu/menu_hook.3
@@ -1,8 +1,8 @@
'\" t
-.\" $OpenBSD: menu_hook.3,v 1.6 1999/01/22 03:45:06 millert Exp $
+.\" $OpenBSD: menu_hook.3,v 1.7 2010/01/12 23:22:08 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -29,48 +29,48 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: menu_hook.3x,v 1.6 1998/11/29 01:09:47 Rick.Ohnemus Exp $
+.\" $Id: menu_hook.3,v 1.7 2010/01/12 23:22:08 nicm Exp $
.TH menu_hook 3 ""
.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 *));
+int set_item_init(MENU *menu, Menu_Hook func);
.br
-void (*)(MENU *) item_init(const MENU *menu);
+Menu_Hook item_init(const MENU *menu);
.br
-int set_item_term(MENU *menu, void (*func)(MENU *));
+int set_item_term(MENU *menu, Menu_Hook func);
.br
-void (*)(MENU *) item_term(const MENU *menu);
+Menu_Hook item_term(const MENU *menu);
.br
-int set_menu_init(MENU *menu, void (*func)(MENU *));
+int set_menu_init(MENU *menu, Menu_Hook func);
.br
-void (*)(MENU *) menu_init(const MENU *menu);
+Menu_Hook menu_init(const MENU *menu);
.br
-int set_menu_term(MENU *menu, void (*func)(MENU *));
+int set_menu_term(MENU *menu, Menu_Hook func);
.br
-void (*)(MENU *) menu_term(const MENU *menu);
+Menu_Hook menu_term(const MENU *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.
-
+.PP
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).
-
+.PP
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).
-
+.PP
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).
-
+.PP
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
@@ -79,10 +79,10 @@ is no such hook).
Routines that return pointers return \fBNULL\fR on error. Other routines
return one of the following:
.TP 5
-\fBE_OK\fR
+.B E_OK
The routine succeeded.
.TP 5
-\fBE_SYSTEM_ERROR\fR
+.B E_SYSTEM_ERROR
System error occurred (see \fBerrno\fR).
.SH SEE ALSO
\fBcurses\fR(3), \fBmenu\fR(3).
diff --git a/lib/libmenu/menu_items.3 b/lib/libmenu/menu_items.3
index 9adac1f204d..fc75b26c85e 100644
--- a/lib/libmenu/menu_items.3
+++ b/lib/libmenu/menu_items.3
@@ -1,8 +1,8 @@
'\" t
-.\" $OpenBSD: menu_items.3,v 1.6 1999/01/22 03:45:06 millert Exp $
+.\" $OpenBSD: menu_items.3,v 1.7 2010/01/12 23:22:08 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998,2006 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -29,7 +29,7 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: menu_items.3x,v 1.5 1998/11/29 01:09:56 Rick.Ohnemus Exp $
+.\" $Id: menu_items.3,v 1.7 2010/01/12 23:22:08 nicm Exp $
.TH menu_items 3 ""
.SH NAME
\fBmenu_items\fR - make and break connections between items and menus
@@ -45,32 +45,34 @@ int item_count(const MENU *menu);
.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.
-
+.PP
The function \fBmenu_items\fR returns the item array of the given menu.
-
+.PP
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 \fBmenu_items\fR returns a pointer (which may be \fBNULL\fR).
+It does not set errno.
+.PP
The function \fBitem_count\fR returns \fBERR\fR (the general \fBcurses\fR error
-return value) on error.
-
+return value) if its \fImenu\fP parameter is \fBNULL\fP.
+.PP
The function \fBset_menu_items\fR returns one of the following codes on error:
.TP 5
-\fBE_OK\fR
+.B E_OK
The routine succeeded.
.TP 5
-\fBE_SYSTEM_ERROR\fR
-System error occurred (see \fBerrno\fR).
-.TP 5
-\fBE_BAD_ARGUMENT\fR
+.B E_BAD_ARGUMENT
Routine detected an incorrect or out-of-range argument.
.TP 5
-\fBE_POSTED\fR
+.B E_NOT_CONNECTED
+No items are connected to the menu.
+.TP 5
+.B E_POSTED
The menu is already posted.
.TP 5
-\fBE_NOT_CONNECTED\fR
-No items are connected to the menu.
+.B E_SYSTEM_ERROR
+System error occurred (see \fBerrno\fR).
+.
.SH SEE ALSO
\fBcurses\fR(3), \fBmenu\fR(3).
.SH NOTES
@@ -79,7 +81,7 @@ The header file \fB<menu.h>\fR automatically includes the header file
.SH PORTABILITY
These routines emulate the System V menu library. They were not supported on
Version 7 or BSD versions.
-
+.PP
The SVr4 menu library documentation specifies the \fBitem_count\fR error value
as -1 (which is the value of \fBERR\fR).
.SH AUTHORS
diff --git a/lib/libmenu/menu_mark.3 b/lib/libmenu/menu_mark.3
index 3ff7a47c64c..b7b8ea2f706 100644
--- a/lib/libmenu/menu_mark.3
+++ b/lib/libmenu/menu_mark.3
@@ -1,8 +1,8 @@
'\" t
-.\" $OpenBSD: menu_mark.3,v 1.6 1999/01/22 03:45:06 millert Exp $
+.\" $OpenBSD: menu_mark.3,v 1.7 2010/01/12 23:22:08 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998,2006 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -29,7 +29,7 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: menu_mark.3x,v 1.6 1998/11/29 01:10:03 Rick.Ohnemus Exp $
+.\" $Id: menu_mark.3,v 1.7 2010/01/12 23:22:08 nicm Exp $
.TH menu_mark 3 ""
.SH NAME
\fBmenu_mark\fR - get and set the menu mark string
@@ -44,29 +44,31 @@ const char *menu_mark(const MENU *menu);
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.
-
+.PP
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.
-
+.PP
The default string is "-" (a dash). Calling \fBset_menu_mark\fR with
-a \fBNULL\fR menu argument will change this default.
-
+a non-\fBNULL\fR menu argument will change this default.
+.PP
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 may return the following error codes:
+The function \fBmenu_mark\fR returns a pointer (which may be \fBNULL\fR).
+It does not set errno.
+.PP
+The function \fBset_menu_mark\fR may return the following error codes:
.TP 5
-\fBE_OK\fR
+.B E_OK
The routine succeeded.
.TP 5
-\fBE_SYSTEM_ERROR\fR
-System error occurred (see \fBerrno\fR).
-.TP 5
-\fBE_BAD_ARGUMENT\fR
+.B E_BAD_ARGUMENT
Routine detected an incorrect or out-of-range argument.
+.TP 5
+.B E_SYSTEM_ERROR
+System error occurred (see \fBerrno\fR).
.SH SEE ALSO
\fBcurses\fR(3), \fBmenu\fR(3).
.SH NOTES
diff --git a/lib/libmenu/menu_new.3 b/lib/libmenu/menu_new.3
index 8a18206c584..3056aab25e7 100644
--- a/lib/libmenu/menu_new.3
+++ b/lib/libmenu/menu_new.3
@@ -1,8 +1,8 @@
'\" t
-.\" $OpenBSD: menu_new.3,v 1.6 1999/01/22 03:45:07 millert Exp $
+.\" $OpenBSD: menu_new.3,v 1.7 2010/01/12 23:22:08 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998,2006 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -29,7 +29,7 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: menu_new.3x,v 1.7 1998/11/29 01:10:13 Rick.Ohnemus Exp $
+.\" $Id: menu_new.3,v 1.7 2010/01/12 23:22:08 nicm Exp $
.TH menu_new 3 ""
.SH NAME
\fBmenu_new\fR - create and destroy menus
@@ -43,24 +43,31 @@ int free_menu(MENU *menu);
.SH DESCRIPTION
The function \fBnew_menu\fR creates a new menu connected to a specified item
pointer array (which must be \fBNULL\fR-terminated).
-
+.PP
The function \fBfree_menu\fR disconnects \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.
-
+It sets errno according to the function's failure:
+.TP 5
+.B E_NOT_CONNECTED
+No items are connected to the menu.
+.TP 5
+.B E_SYSTEM_ERROR
+System error occurred, e.g., malloc failure.
+.PP
The function \fBfree_menu\fR returns one of the following:
.TP 5
-\fBE_OK\fR
+.B E_OK
The routine succeeded.
.TP 5
-\fBE_SYSTEM_ERROR\fR
+.B E_SYSTEM_ERROR
System error occurred (see \fBerrno\fR).
.TP 5
-\fBE_BAD_ARGUMENT\fR
+.B E_BAD_ARGUMENT
Routine detected an incorrect or out-of-range argument.
.TP 5
-\fBE_POSTED\fR
+.B E_POSTED
The menu has already been posted.
.SH SEE ALSO
\fBcurses\fR(3), \fBmenu\fR(3).
diff --git a/lib/libmenu/menu_opts.3 b/lib/libmenu/menu_opts.3
index c9eecc8f1be..dfa3e2a7959 100644
--- a/lib/libmenu/menu_opts.3
+++ b/lib/libmenu/menu_opts.3
@@ -1,8 +1,8 @@
'\" t
-.\" $OpenBSD: menu_opts.3,v 1.7 1999/05/12 13:26:49 aaron Exp $
+.\" $OpenBSD: menu_opts.3,v 1.8 2010/01/12 23:22:08 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -29,33 +29,33 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: menu_opts.3x,v 1.7 1998/11/29 01:10:21 Rick.Ohnemus Exp $
+.\" $Id: menu_opts.3,v 1.8 2010/01/12 23:22:08 nicm Exp $
.TH menu_opts 3 ""
.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);
+int set_menu_opts(MENU *menu, Menu_Options opts);
.br
-int menu_opts_on(MENU *menu, OPTIONS opts);
+int menu_opts_on(MENU *menu, Menu_Options opts);
.br
-int menu_opts_off(MENU *menu, OPTIONS opts);
+int menu_opts_off(MENU *menu, Menu_Options opts);
.br
-OPTIONS menu_opts(const MENU *menu);
+Menu_Options menu_opts(const 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 OR'ed together).
-
+.PP
The function \fBmenu_opts_on\fR turns on the given option bits, and leaves
others alone.
-
+.PP
The function \fBmenu_opts_off\fR turns off the given option bits, and leaves
others alone.
-
+.PP
The function \fBmenu_opts\fR returns the menu's current option bits.
-
+.PP
The following options are defined (all are on by default):
.TP 5
O_ONEVALUE
@@ -79,13 +79,13 @@ 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
+.B E_OK
The routine succeeded.
.TP 5
-\fBE_SYSTEM_ERROR\fR
+.B E_SYSTEM_ERROR
System error occurred (see \fBerrno\fR).
.TP 5
-\fBE_POSTED\fR
+.B E_POSTED
The menu is already posted.
.SH SEE ALSO
\fBcurses\fR(3), \fBmenu\fR(3).
diff --git a/lib/libmenu/menu_pattern.3 b/lib/libmenu/menu_pattern.3
index 63240fc886a..8c6251e3b26 100644
--- a/lib/libmenu/menu_pattern.3
+++ b/lib/libmenu/menu_pattern.3
@@ -1,7 +1,7 @@
-.\" $OpenBSD: menu_pattern.3,v 1.5 1999/01/22 03:45:07 millert Exp $
+.\" $OpenBSD: menu_pattern.3,v 1.6 2010/01/12 23:22:08 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998-2006,2008 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -28,7 +28,7 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.'" $From: menu_pattern.3x,v 1.5 1998/03/11 21:12:53 juergen Exp $
+.\" $Id: menu_pattern.3,v 1.6 2010/01/12 23:22:08 nicm Exp $
.TH menu_pattern 3 ""
.SH NAME
\fBmenu_pattern\fR - get and set a menu's pattern buffer
@@ -41,30 +41,39 @@ char *menu_pattern(const 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
+printable characters come in, they are appended to this match buffer
and tested for a match, as described in \fBmenu_driver\fR(3).
-
+.PP
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.
-
+current; if not, the current item does not change.
+.PP
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 may return the following error codes:
+The function \fBmenu_pattern\fR returns a pointer, which is \fBNULL\fR if the \fImenu\fP parameter is \fBNULL\fP.
+Otherwise, it is a pointer to a string which is empty if no pattern has been set.
+It does not set errno.
+.PP
+The function \fBset_menu_pattern\fR may return the following error codes:
.TP 5
-\fBE_OK\fR
+.B E_OK
The routine succeeded.
.TP 5
-\fBE_SYSTEM_ERROR\fR
-System error occurred (see \fBerrno\fR).
-.TP 5
-\fBE_BAD_ARGUMENT\fR
+.B E_BAD_ARGUMENT
Routine detected an incorrect or out-of-range argument.
.TP 5
-\fBE_NO_MATCH\fR
+.B E_BAD_STATE
+Routine was called from an initialization or termination function.
+.TP 5
+.B E_NOT_CONNECTED
+No items are connected to menu.
+.TP 5
+.B E_NO_MATCH
Character failed to match.
+.TP 5
+.B E_SYSTEM_ERROR
+System error occurred (see \fBerrno\fR).
.SH SEE ALSO
\fBcurses\fR(3), \fBmenu\fR(3).
.SH NOTES
diff --git a/lib/libmenu/menu_post.3 b/lib/libmenu/menu_post.3
index 24d2ee641bc..ce77165f75c 100644
--- a/lib/libmenu/menu_post.3
+++ b/lib/libmenu/menu_post.3
@@ -1,8 +1,8 @@
'\" t
-.\" $OpenBSD: menu_post.3,v 1.6 1999/01/22 03:45:07 millert Exp $
+.\" $OpenBSD: menu_post.3,v 1.7 2010/01/12 23:22:08 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998,2006 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -29,7 +29,7 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: menu_post.3x,v 1.7 1998/11/29 01:10:33 Rick.Ohnemus Exp $
+.\" $Id: menu_post.3,v 1.7 2010/01/12 23:22:08 nicm Exp $
.TH menu_post 3 ""
.SH NAME
\fBmenu_post\fR - write or erase menus from associated subwindows
@@ -45,34 +45,34 @@ 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). \fBpost_menu\fR resets the selection status of all items.
-
+.PP
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
+.B E_OK
The routine succeeded.
.TP 5
-\fBE_SYSTEM_ERROR\fR
+.B E_SYSTEM_ERROR
System error occurred (see \fBerrno\fR).
.TP 5
-\fBE_BAD_ARGUMENT\fR
+.B E_BAD_ARGUMENT
Routine detected an incorrect or out-of-range argument.
.TP 5
-\fBE_POSTED\fR
+.B E_POSTED
The menu has already been posted.
.TP 5
-\fBE_BAD_STATE\fR
+.B E_BAD_STATE
Routine was called from an initialization or termination function.
.TP 5
-\fBE_NO_ROOM\fR
+.B E_NO_ROOM
Menu is too large for its window. You should consider to use
\fBset_menu_format()\fR to solve the problem.
.TP 5
-\fBE_NOT_POSTED\fR
+.B E_NOT_POSTED
The menu has not been posted.
.TP 5
-\fBE_NOT_CONNECTED\fR
+.B E_NOT_CONNECTED
No items are connected to the menu.
.SH SEE ALSO
\fBcurses\fR(3), \fBmenu\fR(3).
diff --git a/lib/libmenu/menu_requestname.3 b/lib/libmenu/menu_requestname.3
index 58d815c3bfb..a09c5b5d7fb 100644
--- a/lib/libmenu/menu_requestname.3
+++ b/lib/libmenu/menu_requestname.3
@@ -1,8 +1,8 @@
'\" t
-.\" $OpenBSD: menu_requestname.3,v 1.5 1999/01/22 03:45:07 millert Exp $
+.\" $OpenBSD: menu_requestname.3,v 1.6 2010/01/12 23:22:08 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998,2006 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -29,7 +29,7 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: menu_requestname.3x,v 1.6 1998/11/29 01:10:40 Rick.Ohnemus Exp $
+.\" $Id: menu_requestname.3,v 1.6 2010/01/12 23:22:08 nicm Exp $
.TH menu_requestname 3 ""
.SH NAME
\fBmenu_requestname\fR - handle printable menu request names
@@ -45,12 +45,14 @@ The function \fBmenu_request_name\fR returns the printable name of a menu
request code.
.br
The function \fBmenu_request_by_name\fR searches in the name-table for a request
-with the given name and returns its request code. Otherwise E_NO_MATCH is returned.
+with the given name and returns its request code.
+Otherwise E_NO_MATCH is returned.
.SH RETURN VALUE
-\fBmenu_request_name\fR returns \fBNULL\fR on error and sets errno
-to \fBE_BAD_ARGUMENT\fR.
+\fBmenu_request_name\fR returns \fBNULL\fR on error
+and sets errno to \fBE_BAD_ARGUMENT\fR.
.br
\fBmenu_request_by_name\fR returns \fBE_NO_MATCH\fR on error.
+It does not set errno.
.SH SEE ALSO
\fBcurses\fR(3), \fBmenu\fR(3).
.SH NOTES
diff --git a/lib/libmenu/menu_spacing.3 b/lib/libmenu/menu_spacing.3
index e000a3c13fc..ac6e8e50345 100644
--- a/lib/libmenu/menu_spacing.3
+++ b/lib/libmenu/menu_spacing.3
@@ -1,8 +1,8 @@
'\" t
-.\" $OpenBSD: menu_spacing.3,v 1.5 1999/01/22 03:45:07 millert Exp $
+.\" $OpenBSD: menu_spacing.3,v 1.6 2010/01/12 23:22:08 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998-2001,2004 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -29,7 +29,7 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: menu_spacing.3x,v 1.5 1998/11/29 01:10:51 Rick.Ohnemus Exp $
+.\" $Id: menu_spacing.3,v 1.6 2010/01/12 23:22:08 nicm Exp $
.TH menu_spacing 3 ""
.SH NAME
\fBmenu_spacing\fR - Control spacing between menu items.
@@ -37,12 +37,12 @@
\fB#include <menu.h>\fR
.br
int set_menu_spacing(MENU *menu,
- int spc_description
+ int spc_description,
int spc_rows,
int spc_columns);
.br
int menu_spacing(const MENU *menu,
- int* spc_description
+ int* spc_description,
int* spc_rows,
int* spc_columns);
.br
@@ -53,7 +53,7 @@ description. It must not be larger than \fBTABSIZE\fR. The menu system puts in t
middle of this spacing area the pad character. The remaining parts are filled with
spaces.
\fBspc_rows\fR controls the number of rows that are used for an item. It must not be
-larger than 3. The menu system inserts then blank lines between item rows, these lines
+larger than 3. The menu system inserts the blank lines between item rows, these lines
will contain the pad character in the appropriate positions.
\fBspc_columns\fR controls the number of blanks between columns of items. It must not
be larger than TABSIZE.
diff --git a/lib/libmenu/menu_userptr.3 b/lib/libmenu/menu_userptr.3
index 38e33fa9e44..ff00ba445ae 100644
--- a/lib/libmenu/menu_userptr.3
+++ b/lib/libmenu/menu_userptr.3
@@ -1,8 +1,8 @@
'\" t
-.\" $OpenBSD: menu_userptr.3,v 1.6 1999/01/22 03:45:07 millert Exp $
+.\" $OpenBSD: menu_userptr.3,v 1.7 2010/01/12 23:22:08 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998,2006 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -29,7 +29,7 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: menu_userptr.3x,v 1.6 1998/11/29 01:11:02 Rick.Ohnemus Exp $
+.\" $Id: menu_userptr.3,v 1.7 2010/01/12 23:22:08 nicm Exp $
.TH menu_userptr 3 ""
.SH NAME
\fBmenu_userptr\fR - associate application data with a menu item
@@ -45,14 +45,10 @@ 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).
+\fBmenu_userptr\fR returns a pointer (which may be \fBNULL\fR).
+It does not set errno.
+.PP
+\fBset_menu_userptr\fP returns \fBE_OK\fP (success).
.SH SEE ALSO
\fBcurses\fR(3), \fBmenu\fR(3).
.SH NOTES
@@ -61,9 +57,9 @@ The header file \fB<menu.h>\fR automatically includes the header file
.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.
+.PP
+The user pointer is a void pointer.
+We chose not to leave it as a char pointer for SVr4 compatibility.
.SH AUTHORS
Juergen Pfeifer. Manual pages and adaptation for new curses by Eric
S. Raymond.
diff --git a/lib/libmenu/menu_win.3 b/lib/libmenu/menu_win.3
index b21d77e18ab..29b5e4f2670 100644
--- a/lib/libmenu/menu_win.3
+++ b/lib/libmenu/menu_win.3
@@ -1,8 +1,8 @@
'\" t
-.\" $OpenBSD: menu_win.3,v 1.6 1999/01/22 03:45:07 millert Exp $
+.\" $OpenBSD: menu_win.3,v 1.7 2010/01/12 23:22:08 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998,2006 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -29,7 +29,7 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: menu_win.3x,v 1.6 1998/11/29 01:11:11 Rick.Ohnemus Exp $
+.\" $Id: menu_win.3,v 1.7 2010/01/12 23:22:08 nicm Exp $
.TH menu_win 3 ""
.SH NAME
\fBmenu_win\fR - make and break menu window and subwindow associations
@@ -50,33 +50,33 @@ int scale_menu(const MENU *menu, int *rows, int *columns);
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.
-
+.PP
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.
-
+.PP
In the \fBset_\fR functions, window argument of \fBNULL\fR is treated as though
it were \fBstsdcr\fR. A menu argument of \fBNULL\fR is treated as a request
to change the system default menu window or subwindow.
-
+.PP
The function \fBscale_menu\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
+.B E_OK
The routine succeeded.
.TP 5
-\fBE_SYSTEM_ERROR\fR
+.B E_SYSTEM_ERROR
System error occurred (see \fBerrno\fR).
.TP 5
-\fBE_BAD_ARGUMENT\fR
+.B E_BAD_ARGUMENT
Routine detected an incorrect or out-of-range argument.
.TP 5
-\fBE_POSTED\fR
+.B E_POSTED
The menu has already been posted.
.TP 5
-\fBE_NOT_CONNECTED\fR
+.B E_NOT_CONNECTED
No items are connected to the menu.
.SH SEE ALSO
\fBcurses\fR(3), \fBmenu\fR(3).
diff --git a/lib/libmenu/mf_common.h b/lib/libmenu/mf_common.h
index b88aa91ac5b..c1a4e32dba4 100644
--- a/lib/libmenu/mf_common.h
+++ b/lib/libmenu/mf_common.h
@@ -1,7 +1,7 @@
-/* $OpenBSD: mf_common.h,v 1.6 2000/10/08 22:47:07 millert Exp $ */
+/* $OpenBSD: mf_common.h,v 1.7 2010/01/12 23:22:08 nicm Exp $ */
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,2004 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@ -29,14 +29,18 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
+/* $Id: mf_common.h,v 1.7 2010/01/12 23:22:08 nicm Exp $ */
+
/* Common internal header for menu and form library */
-#if HAVE_CONFIG_H
-# include <ncurses_cfg.h>
-#endif
+#ifndef MF_COMMON_H_incl
+#define MF_COMMON_H_incl 1
+
+#include <ncurses_cfg.h>
+#include <curses.h>
#include <stdlib.h>
#include <sys/types.h>
@@ -69,27 +73,25 @@ extern int errno;
#define MAX_REGULAR_CHARACTER (0xff)
#define SET_ERROR(code) (errno=(code))
-#define GET_ERROR() (errno)
-#define RETURN(code) return( SET_ERROR(code) )
+#define GET_ERROR() (errno)
+
+#ifdef TRACE
+#define RETURN(code) returnCode( SET_ERROR(code) )
+#else
+#define RETURN(code) return( SET_ERROR(code) )
+#endif
/* 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 */
+#define _POSTED (0x01U) /* menu or form is posted */
+#define _IN_DRIVER (0x02U) /* menu or form is processing hook routine */
/* Call object hook */
#define Call_Hook( object, handler ) \
- if ( (object) && ((object)->handler) )\
+ if ( (object) != 0 && ((object)->handler) != (void *) 0 )\
{\
(object)->status |= _IN_DRIVER;\
(object)->handler(object);\
(object)->status &= ~_IN_DRIVER;\
}
-#define INLINE
-
-#ifndef TRACE
-# if CC_HAS_INLINE_FUNCS
-# undef INLINE
-# define INLINE inline
-# endif
-#endif
+#endif /* MF_COMMON_H_incl */
diff --git a/lib/libmenu/mitem_current.3 b/lib/libmenu/mitem_current.3
index 811c04a65d4..58e9b1d64a2 100644
--- a/lib/libmenu/mitem_current.3
+++ b/lib/libmenu/mitem_current.3
@@ -1,8 +1,8 @@
'\" t
-.\" $OpenBSD: mitem_current.3,v 1.4 1999/01/22 03:45:07 millert Exp $
+.\" $OpenBSD: mitem_current.3,v 1.5 2010/01/12 23:22:08 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998,2006 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -29,7 +29,7 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: mitem_current.3x,v 1.9 1998/12/26 19:52:34 tom Exp $
+.\" $Id: mitem_current.3,v 1.5 2010/01/12 23:22:08 nicm Exp $
.TH mitem_current 3 ""
.SH NAME
\fBmitem_current\fR - set and get current_menu_item
@@ -50,37 +50,38 @@ int item_index(const ITEM *item);
The function \fBset_current_item\fR sets the current item (the item on which
the menu cursor is positioned). \fBcurrent_item\fR returns a pointer to the
current item in the given menu.
-
+.PP
The function \fBset_top_row\fR sets the top row of the menu to show the given
row (the top row is initially 0, and is reset to this value whenever the
\fBO_ROWMAJOR\fR option is toggled). The item leftmost on the given row
becomes current. The function \fBtop_row\fR returns the number of the top menu
row being displayed.
-
+.PP
The function \fBitem_index\fR returns the (zero-origin) index of \fIitem\fR in
the menu's item pointer list.
.SH RETURN VALUE
-\fBcurrent_item\fR returns \fBNULL\fR on error.
-
+\fBcurrent_item\fR returns a pointer (which may be \fBNULL\fR).
+It does not set errno.
+.PP
\fBtop_row\fR and \fBitem_index\fR return \fBERR\fR (the general \fBcurses\fR
-error value) on error.
-
+error value) if their \fImenu\fP parameter is \fBNULL\fP.
+.PP
\fBset_current_item\fR and \fBset_top_row\fR return one of the following:
.TP 5
-\fBE_OK\fR
+.B E_OK
The routine succeeded.
.TP 5
-\fBE_SYSTEM_ERROR\fR
-System error occurred (see \fBerrno\fR).
-.TP 5
-\fBE_BAD_ARGUMENT\fR
+.B E_BAD_ARGUMENT
Routine detected an incorrect or out-of-range argument.
.TP 5
-\fBE_BAD_STATE\fR
+.B E_BAD_STATE
Routine was called from an initialization or termination function.
.TP 5
-\fBE_NOT_CONNECTED\fR
+.B E_NOT_CONNECTED
No items are connected to the menu.
+.TP 5
+.B E_SYSTEM_ERROR
+System error occurred (see \fBerrno\fR).
.SH SEE ALSO
\fBcurses\fR(3), \fBmenu\fR(3).
.SH NOTES
@@ -89,7 +90,7 @@ The header file \fB<menu.h>\fR automatically includes the header file
.SH PORTABILITY
These routines emulate the System V menu library. They were not supported on
Version 7 or BSD versions.
-
+.PP
The SVr4 menu library documentation specifies the \fBtop_row\fR and
\fBindex_item\fR error value as -1 (which is the value of \fBERR\fR).
.SH AUTHORS
diff --git a/lib/libmenu/mitem_name.3 b/lib/libmenu/mitem_name.3
index 80af3095b49..11a5f442cf4 100644
--- a/lib/libmenu/mitem_name.3
+++ b/lib/libmenu/mitem_name.3
@@ -1,8 +1,8 @@
'\" t
-.\" $OpenBSD: mitem_name.3,v 1.4 1999/01/22 03:45:07 millert Exp $
+.\" $OpenBSD: mitem_name.3,v 1.5 2010/01/12 23:22:08 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998,2006 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -29,7 +29,7 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: mitem_name.3x,v 1.5 1998/11/29 01:11:29 Rick.Ohnemus Exp $
+.\" $Id: mitem_name.3,v 1.5 2010/01/12 23:22:08 nicm Exp $
.TH mitem_name 3 ""
.SH NAME
\fBmitem_name\fR - get menu item name and description fields
@@ -46,15 +46,16 @@ The function \fBitem_name\fR returns the name part of the given item.
The function \fBitem_description\fR returns the description part of the given
item.
.SH RETURN VALUE
-These routines returns \fBNULL\fR on error.
+These routines return a pointer (which may be \fBNULL\fR).
+They do not set errno.
.SH SEE ALSO
\fBcurses\fR(3), \fBmenu\fR(3).
.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.
+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.
diff --git a/lib/libmenu/mitem_new.3 b/lib/libmenu/mitem_new.3
index d722a995836..71f0a41e9ee 100644
--- a/lib/libmenu/mitem_new.3
+++ b/lib/libmenu/mitem_new.3
@@ -1,8 +1,8 @@
'\" t
-.\" $OpenBSD: mitem_new.3,v 1.5 2003/10/22 08:07:09 jmc Exp $
+.\" $OpenBSD: mitem_new.3,v 1.6 2010/01/12 23:22:08 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998-2003,2006 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -29,7 +29,7 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: mitem_new.3x,v 1.7 1998/11/29 01:11:38 Rick.Ohnemus Exp $
+.\" $Id: mitem_new.3,v 1.6 2010/01/12 23:22:08 nicm Exp $
.TH mitem_new 3 ""
.SH NAME
\fBmitem_new\fR - create and destroy menu items
@@ -52,20 +52,27 @@ is the responsibility of the application to release the memory for the
name or the description of the item.
.SH RETURN VALUE
The function \fBnew_item\fR returns \fBNULL\fR on error.
-
+It sets errno according to the function's failure:
+.TP 5
+.B E_BAD_ARGUMENT
+Routine detected an incorrect or out-of-range argument.
+.TP 5
+.B E_SYSTEM_ERROR
+System error occurred, e.g., malloc failure.
+.PP
The function \fBfree_item\fR returns one of the following:
.TP 5
-\fBE_OK\fR
+.B E_OK
The routine succeeded.
.TP 5
-\fBE_SYSTEM_ERROR\fR
-System error occurred (see \fBerrno\fR).
-.TP 5
-\fBE_BAD_ARGUMENT\fR
+.B E_BAD_ARGUMENT
Routine detected an incorrect or out-of-range argument.
.TP 5
-\fBE_CONNECTED\fR
+.B E_CONNECTED
Item is connected to a menu.
+.TP 5
+.B E_SYSTEM_ERROR
+System error occurred (see \fBerrno\fR).
.SH SEE ALSO
\fBcurses\fR(3), \fBmenu\fR(3).
.SH NOTES
diff --git a/lib/libmenu/mitem_opts.3 b/lib/libmenu/mitem_opts.3
index 714937a0ea7..0dfc691d84d 100644
--- a/lib/libmenu/mitem_opts.3
+++ b/lib/libmenu/mitem_opts.3
@@ -1,8 +1,8 @@
'\" t
-.\" $OpenBSD: mitem_opts.3,v 1.5 1999/05/12 13:26:49 aaron Exp $
+.\" $OpenBSD: mitem_opts.3,v 1.6 2010/01/12 23:22:08 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -29,43 +29,43 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: mitem_opts.3x,v 1.6 1998/11/29 01:12:37 Rick.Ohnemus Exp $
+.\" $Id: mitem_opts.3,v 1.6 2010/01/12 23:22:08 nicm Exp $
.TH mitem_opts 3 ""
.SH NAME
\fBmitem_opts\fR - set and get menu item options
.SH SYNOPSIS
\fB#include <menu.h>\fR
.br
-int set_item_opts(ITEM *item, OPTIONS opts);
+int set_item_opts(ITEM *item, Item_Options opts);
.br
-int item_opts_on(ITEM *item, OPTIONS opts);
+int item_opts_on(ITEM *item, Item_Options opts);
.br
-int item_opts_off(ITEM *item, OPTIONS opts);
+int item_opts_off(ITEM *item, Item_Options opts);
.br
-OPTIONS item_opts(const ITEM *item);
+Item_Options item_opts(const ITEM *item);
.br
.SH DESCRIPTION
The function \fBset_item_opts\fR sets all the given item's option bits (menu
option bits may be logically OR'ed together).
-
+.PP
The function \fBitem_opts_on\fR turns on the given option bits, and leaves
others alone.
-
+.PP
The function \fBitem_opts_off\fR turns off the given option bits, and leaves
others alone.
-
+.PP
The function \fBitem_opts\fR returns the item's current option bits.
-
+.PP
There is only one defined option bit mask, \fBO_SELECTABLE\fR. When this is
on, the item may be selected during menu processing. This option defaults
to on.
.SH RETURN VALUE
Except for \fBitem_opts\fR, each routine returns one of the following:
.TP 5
-\fBE_OK\fR
+.B E_OK
The routine succeeded.
.TP 5
-\fBE_SYSTEM_ERROR\fR
+.B E_SYSTEM_ERROR
System error occurred (see \fBerrno\fR).
.SH SEE ALSO
\fBcurses\fR(3), \fBmenu\fR(3).
diff --git a/lib/libmenu/mitem_userptr.3 b/lib/libmenu/mitem_userptr.3
index db4c0dd67b7..48db807db2b 100644
--- a/lib/libmenu/mitem_userptr.3
+++ b/lib/libmenu/mitem_userptr.3
@@ -1,8 +1,8 @@
'\" t
-.\" $OpenBSD: mitem_userptr.3,v 1.4 1999/01/22 03:45:07 millert Exp $
+.\" $OpenBSD: mitem_userptr.3,v 1.5 2010/01/12 23:22:08 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998,2006 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -29,7 +29,7 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: mitem_userptr.3x,v 1.6 1998/11/29 01:12:47 Rick.Ohnemus Exp $
+.\" $Id: mitem_userptr.3,v 1.5 2010/01/12 23:22:08 nicm Exp $
.TH mitem_userptr 3 ""
.SH NAME
\fBmitem_userptr\fR - associate application data with a menu item
@@ -45,13 +45,11 @@ 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
that field.
.SH RETURN VALUE
-Except for \fBitem_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).
+The function \fBitem_userptr\fR returns a pointer (possibly \fBNULL\fR).
+It does not set errno.
+.PP
+The \fBset_item_userptr\fP always returns \fBE_OK\fP (success).
+.
.SH SEE ALSO
\fBcurses\fR(3), \fBmenu\fR(3).
.SH NOTES
@@ -60,9 +58,9 @@ The header file \fB<menu.h>\fR automatically includes the header file
.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.
+.PP
+The user pointer is a void pointer.
+We chose not to leave it as a char pointer for SVr4 compatibility.
.SH AUTHORS
Juergen Pfeifer. Manual pages and adaptation for new curses by Eric
S. Raymond.
diff --git a/lib/libmenu/mitem_value.3 b/lib/libmenu/mitem_value.3
index 2a55770c59d..bf5631551b3 100644
--- a/lib/libmenu/mitem_value.3
+++ b/lib/libmenu/mitem_value.3
@@ -1,7 +1,7 @@
-.\" $OpenBSD: mitem_value.3,v 1.2 1998/07/24 16:39:49 millert Exp $
+.\" $OpenBSD: mitem_value.3,v 1.3 2010/01/12 23:22:08 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998-2002,2006 Free Software Foundation, Inc. *
.\" *
.\" Permission is hereby granted, free of charge, to any person obtaining a *
.\" copy of this software and associated documentation files (the *
@@ -28,7 +28,7 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.'" $From: mitem_value.3x,v 1.4 1998/03/11 21:12:53 juergen Exp $
+.\" $Id: mitem_value.3,v 1.3 2010/01/12 23:22:08 nicm Exp $
.TH mitem_value 3 ""
.SH NAME
\fBmitem_value\fR - set and get menu item values
@@ -44,20 +44,20 @@ If you turn off the menu option \fBO_ONEVALUE\fR (e.g., with
\fBset_menu_opts\fR or \fBmenu_opts_off\fR; see \fBmenu_opts\fR(3)), the menu
becomes multi-valued; that is, more than one item may simultaneously be
selected.
-
+.PP
In a multi_valued menu, you can used \fBset_item_value\fR to select the
given menu item (second argument \fBTRUE\fR) or deselect it (second argument
\fBFALSE\fR).
.SH RETURN VALUE
The function \fBset_item_value\fR returns one of the following:
.TP 5
-\fBE_OK\fR
+.B E_OK
The routine succeeded.
.TP 5
-\fBE_SYSTEM_ERROR\fR
+.B E_SYSTEM_ERROR
System error occurred (see \fBerrno\fR).
.TP 5
-\fBE_REQUEST_DENIED\fR
+.B E_REQUEST_DENIED
The menu driver could not process the request.
.SH SEE ALSO
\fBcurses\fR(3), \fBmenu\fR(3).
diff --git a/lib/libmenu/mitem_visible.3 b/lib/libmenu/mitem_visible.3
index 55531f4d726..a157019a9b9 100644
--- a/lib/libmenu/mitem_visible.3
+++ b/lib/libmenu/mitem_visible.3
@@ -1,5 +1,5 @@
'\" t
-.\" $OpenBSD: mitem_visible.3,v 1.4 1999/01/22 03:45:07 millert Exp $
+.\" $OpenBSD: mitem_visible.3,v 1.5 2010/01/12 23:22:08 nicm Exp $
.\"
.\"***************************************************************************
.\" Copyright (c) 1998 Free Software Foundation, Inc. *
@@ -29,7 +29,7 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: mitem_visible.3x,v 1.5 1998/11/29 01:12:55 Rick.Ohnemus Exp $
+.\" $Id: mitem_visible.3,v 1.5 2010/01/12 23:22:08 nicm Exp $
.TH mitem_visible 3 ""
.SH NAME
\fBmitem_visible\fR - check visibility of a menu item
diff --git a/lib/libmenu/shlib_version b/lib/libmenu/shlib_version
index 012c14171d3..d9961ea9fef 100644
--- a/lib/libmenu/shlib_version
+++ b/lib/libmenu/shlib_version
@@ -1,2 +1,2 @@
-major=3
+major=4
minor=0