* Moved the contents of the EXPOSE_PRIVATES ifdef into internal.h and

killed the now empty ifdef in menu.h.  Also removed the define in
  the CFLAGS in Makefile.
* Renamed _menui_menu_hook to Menu_Hook for compatiability with
  ncurses.
* Renamed all internal functions to have _menui prefix instead of
  __menui
* Cleaned up some automatic function variable names that were
  shadowing function calls.
* Fixed email address in headers.
This commit is contained in:
blymn 1999-12-16 12:08:06 +00:00
parent 7dfd08b2e2
commit b7466e4fd7
12 changed files with 170 additions and 166 deletions

View File

@ -1,7 +1,7 @@
# $NetBSD: Makefile,v 1.3 1999/11/24 12:20:14 kleink Exp $
# $NetBSD: Makefile,v 1.4 1999/12/16 12:08:06 blymn Exp $
#
CPPFLAGS+=-I${.CURDIR} -D__LIBMENU_EXPOSE_PRIVATES__
CPPFLAGS+=-I${.CURDIR}
LIB= menu
SRCS= menu.c item.c userptr.c internals.c driver.c post.c attributes.c
MAN= menu_attributes.3 menu_item_name.3 menu_items.3 menu_userptr.3 \

View File

@ -1,7 +1,7 @@
/* $NetBSD: attributes.c,v 1.2 1999/11/24 12:43:15 kleink Exp $ */
/* $Id: attributes.c,v 1.3 1999/12/16 12:08:06 blymn Exp $ */
/*-
* Copyright (c) 1998-1999 Brett Lymn (blymn@baea.com.au, brett_lymn@yahoo.com)
* Copyright (c) 1998-1999 Brett Lymn (blymn@baea.com.au, brett_lymn@yahoo.com.au)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without

View File

@ -1,7 +1,7 @@
/* $NetBSD: driver.c,v 1.2 1999/11/24 12:43:15 kleink Exp $ */
/* $Id: driver.c,v 1.3 1999/12/16 12:08:07 blymn Exp $ */
/*-
* Copyright (c) 1998-1999 Brett Lymn (blymn@baea.com.au, brett_lymn@yahoo.com)
* Copyright (c) 1998-1999 Brett Lymn (blymn@baea.com.au, brett_lymn@yahoo.com.au)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -44,8 +44,8 @@ menu_driver(menu, c)
MENU *menu;
int c;
{
int top_row, scroll, it, status = E_OK;
ITEM *new_item;
int drv_top_row, drv_scroll, it, status = E_OK;
ITEM *drv_new_item;
if (menu == NULL)
return E_BAD_ARGUMENT;
@ -59,11 +59,12 @@ menu_driver(menu, c)
return E_BAD_STATE;
/* this one should never happen but just in case.... */
if (menu->items[menu->cur_item] == NULL) return E_SYSTEM_ERROR;
if (menu->items[menu->cur_item] == NULL)
return E_SYSTEM_ERROR;
new_item = menu->items[menu->cur_item];
drv_new_item = menu->items[menu->cur_item];
it = menu->cur_item;
top_row = menu->top_row;
drv_top_row = menu->top_row;
if ((c > REQ_BASE_NUM) && (c <= MAX_COMMAND)) {
/* is a known driver request - first check if the pattern
@ -83,62 +84,62 @@ menu_driver(menu, c)
switch (c) {
case REQ_LEFT_ITEM:
new_item = new_item->left;
drv_new_item = drv_new_item->left;
break;
case REQ_RIGHT_ITEM:
new_item = new_item->right;
drv_new_item = drv_new_item->right;
break;
case REQ_UP_ITEM:
new_item = new_item->up;
drv_new_item = drv_new_item->up;
break;
case REQ_DOWN_ITEM:
new_item = new_item->down;
drv_new_item = drv_new_item->down;
break;
case REQ_SCR_ULINE:
if (top_row == 0)
if (drv_top_row == 0)
return E_REQUEST_DENIED;
top_row--;
new_item = new_item->up;
drv_top_row--;
drv_new_item = drv_new_item->up;
break;
case REQ_SCR_DLINE:
top_row++;
if ((top_row + menu->rows - 1)> menu->item_rows)
drv_top_row++;
if ((drv_top_row + menu->rows - 1)> menu->item_rows)
return E_REQUEST_DENIED;
new_item = new_item->down;
drv_new_item = drv_new_item->down;
break;
case REQ_SCR_DPAGE:
scroll = menu->item_rows - menu->rows
drv_scroll = menu->item_rows - menu->rows
- menu->top_row;
if (scroll > menu->rows) {
scroll = menu->rows;
if (drv_scroll > menu->rows) {
drv_scroll = menu->rows;
}
if (scroll <= 0) {
if (drv_scroll <= 0) {
return E_REQUEST_DENIED;
} else {
top_row += scroll;
while (scroll-- > 0)
new_item = new_item->down;
drv_top_row += drv_scroll;
while (drv_scroll-- > 0)
drv_new_item = drv_new_item->down;
}
break;
case REQ_SCR_UPAGE:
if (menu->rows < menu->top_row) {
scroll = menu->rows;
drv_scroll = menu->rows;
} else {
scroll = menu->top_row;
drv_scroll = menu->top_row;
}
if (scroll == 0)
if (drv_scroll == 0)
return E_REQUEST_DENIED;
top_row -= scroll;
while (scroll-- > 0)
new_item = new_item->up;
drv_top_row -= drv_scroll;
while (drv_scroll-- > 0)
drv_new_item = drv_new_item->up;
break;
case REQ_FIRST_ITEM:
new_item = menu->items[0];
drv_new_item = menu->items[0];
break;
case REQ_LAST_ITEM:
new_item = menu->items[menu->item_count - 1];
drv_new_item = menu->items[menu->item_count - 1];
break;
case REQ_NEXT_ITEM:
if ((menu->cur_item + 1) >= menu->item_count) {
@ -146,10 +147,11 @@ menu_driver(menu, c)
== O_NONCYCLIC) {
return E_REQUEST_DENIED;
} else {
new_item = menu->items[0];
drv_new_item = menu->items[0];
}
} else {
new_item = menu->items[menu->cur_item + 1];
drv_new_item =
menu->items[menu->cur_item + 1];
}
break;
case REQ_PREV_ITEM:
@ -158,24 +160,25 @@ menu_driver(menu, c)
== O_NONCYCLIC) {
return E_REQUEST_DENIED;
} else {
new_item = menu->items[
drv_new_item = menu->items[
menu->item_count - 1];
}
} else {
new_item = menu->items[menu->cur_item - 1];
drv_new_item =
menu->items[menu->cur_item - 1];
}
break;
case REQ_TOGGLE_ITEM:
if ((menu->opts & O_ONEVALUE) == O_ONEVALUE) {
return E_REQUEST_DENIED;
} else {
if ((new_item->opts
if ((drv_new_item->opts
& O_SELECTABLE) == O_SELECTABLE) {
/* toggle select flag */
new_item->selected ^= 1;
drv_new_item->selected ^= 1;
/* update item in menu */
__menui_draw_item(menu,
new_item->index);
_menui_draw_item(menu,
drv_new_item->index);
} else {
return E_NOT_SELECTABLE;
}
@ -197,19 +200,19 @@ menu_driver(menu, c)
if (menu->pattern == NULL)
return E_REQUEST_DENIED;
status = __menui_match_pattern(menu, 0,
status = _menui_match_pattern(menu, 0,
MATCH_NEXT_FORWARD,
&it);
new_item = menu->items[it];
drv_new_item = menu->items[it];
break;
case REQ_PREV_MATCH:
if (menu->pattern == NULL)
return E_REQUEST_DENIED;
status = __menui_match_pattern(menu, 0,
status = _menui_match_pattern(menu, 0,
MATCH_NEXT_REVERSE,
&it);
new_item = menu->items[it];
drv_new_item = menu->items[it];
break;
}
} else if (c > MAX_COMMAND) {
@ -217,9 +220,9 @@ menu_driver(menu, c)
return E_UNKNOWN_COMMAND;
} else if (isprint((char) c)) {
/* otherwise search items for the character. */
status = __menui_match_pattern(menu, c, MATCH_FORWARD,
status = _menui_match_pattern(menu, c, MATCH_FORWARD,
&it);
new_item = menu->items[it];
drv_new_item = menu->items[it];
/* update the position of the cursor if we are doing
* show match and the current item has not changed. If
@ -227,7 +230,7 @@ menu_driver(menu, c)
* display will not be updated due to the current item
* not changing.
*/
if ((new_item->index == menu->cur_item)
if ((drv_new_item->index == menu->cur_item)
&& ((menu->opts & O_SHOWMATCH) == O_SHOWMATCH)) {
pos_menu_cursor(menu);
}
@ -238,14 +241,16 @@ menu_driver(menu, c)
return E_BAD_ARGUMENT;
}
if (new_item == NULL) return E_REQUEST_DENIED;
if (drv_new_item == NULL)
return E_REQUEST_DENIED;
if (new_item->row < top_row) top_row = new_item->row;
if (new_item->row >= (top_row + menu->rows))
top_row = new_item->row - menu->rows + 1;
if (drv_new_item->row < drv_top_row) drv_top_row = drv_new_item->row;
if (drv_new_item->row >= (drv_top_row + menu->rows))
drv_top_row = drv_new_item->row - menu->rows + 1;
if ((new_item->index != menu->cur_item) || (top_row != menu->top_row))
__menui_goto_item(menu, new_item, top_row);
if ((drv_new_item->index != menu->cur_item)
|| (drv_top_row != menu->top_row))
_menui_goto_item(menu, drv_new_item, drv_top_row);
return status;
}

View File

@ -1,7 +1,7 @@
/* $NetBSD: eti.h,v 1.3 1999/11/24 12:43:15 kleink Exp $ */
/* $Id: eti.h,v 1.4 1999/12/16 12:08:07 blymn Exp $ */
/*-
* Copyright (c) 1998-1999 Brett Lymn (blymn@baea.com.au, brett_lymn@yahoo.com)
* Copyright (c) 1998-1999 Brett Lymn (blymn@baea.com.au, brett_lymn@yahoo.com.au)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without

View File

@ -1,7 +1,7 @@
/* $NetBSD: internals.c,v 1.2 1999/11/24 12:43:15 kleink Exp $ */
/* $Id: internals.c,v 1.3 1999/12/16 12:08:07 blymn Exp $ */
/*-
* Copyright (c) 1998-1999 Brett Lymn (blymn@baea.com.au, brett_lymn@yahoo.com)
* Copyright (c) 1998-1999 Brett Lymn (blymn@baea.com.au, brett_lymn@yahoo.com.au)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -34,9 +34,9 @@
/* internal function prototypes */
static void
__menui_calc_neighbours(MENU *, int, int, int, int, ITEM **, ITEM **,
_menui_calc_neighbours(MENU *, int, int, int, int, ITEM **, ITEM **,
ITEM **, ITEM **);
static void __menui_redraw_menu __P((MENU *, int, int));
static void _menui_redraw_menu __P((MENU *, int, int));
/*
* Link all the menu items together to speed up navigation. We need
@ -46,7 +46,7 @@ static void __menui_redraw_menu __P((MENU *, int, int));
* calculated and the item structures updated.
*/
int
__menui_stitch_items(menu)
_menui_stitch_items(menu)
MENU *menu;
{
int i, cycle, row_major;
@ -72,7 +72,7 @@ __menui_stitch_items(menu)
}
__menui_max_item_size(menu);
_menui_max_item_size(menu);
for (i = 0; i < menu->item_count; i++) {
/* Calculate the neighbours. The ugliness here deals with
@ -80,7 +80,7 @@ __menui_stitch_items(menu)
* the neighbour calculation so we change the arguments
* around depending on the layout style.
*/
__menui_calc_neighbours(menu, i, cycle,
_menui_calc_neighbours(menu, i, cycle,
(row_major) ? menu->item_rows
: menu->item_cols,
(row_major) ? menu->item_cols
@ -115,10 +115,10 @@ __menui_stitch_items(menu)
* style.
*/
static void
__menui_calc_neighbours(menu, index, cycle, item_rows, item_cols, next, prev,
_menui_calc_neighbours(menu, item_no, cycle, item_rows, item_cols, next, prev,
major_next, major_prev)
MENU *menu;
int index;
int item_no;
int cycle;
int item_rows;
int item_cols;
@ -131,24 +131,24 @@ __menui_calc_neighbours(menu, index, cycle, item_rows, item_cols, next, prev,
if (item_rows < 2) {
if (cycle) {
*major_next = menu->items[index];
*major_prev = menu->items[index];
*major_next = menu->items[item_no];
*major_prev = menu->items[item_no];
} else {
*major_next = NULL;
*major_prev = NULL;
}
} else {
neighbour = index + item_cols;
neighbour = item_no + item_cols;
if (neighbour >= menu->item_count) {
if (cycle) {
if (item_rows == 2) {
neighbour = index - item_cols;
neighbour = item_no - item_cols;
if (neighbour < 0)
neighbour = index;
neighbour = item_no;
*major_next = menu->items[neighbour];
} else {
*major_next =
menu->items[index % item_cols];
menu->items[item_no % item_cols];
}
} else
*major_next = NULL;
@ -156,20 +156,20 @@ __menui_calc_neighbours(menu, index, cycle, item_rows, item_cols, next, prev,
*major_next = menu->items[neighbour];
neighbour = index - item_cols;
neighbour = item_no - item_cols;
if (neighbour < 0) {
if (cycle) {
if (item_rows == 2) {
neighbour = index + item_cols;
neighbour = item_no + item_cols;
if (neighbour >= menu->item_count)
neighbour = index;
neighbour = item_no;
*major_prev = menu->items[neighbour];
} else {
neighbour = index +
neighbour = item_no +
(item_rows - 1) * item_cols;
if (neighbour >= menu->item_count)
neighbour = index +
neighbour = item_no +
(item_rows - 2)
* item_cols;
@ -181,15 +181,15 @@ __menui_calc_neighbours(menu, index, cycle, item_rows, item_cols, next, prev,
*major_prev = menu->items[neighbour];
}
if ((index % item_cols) == 0) {
if ((item_no % item_cols) == 0) {
if (cycle) {
if (item_cols < 2) {
*prev = menu->items[index];
*prev = menu->items[item_no];
} else {
neighbour = index + item_cols - 1;
neighbour = item_no + item_cols - 1;
if (neighbour >= menu->item_count) {
if (item_cols == 2) {
*prev = menu->items[index];
*prev = menu->items[item_no];
} else {
*prev = menu->items[menu->item_count - 1];
}
@ -199,19 +199,19 @@ __menui_calc_neighbours(menu, index, cycle, item_rows, item_cols, next, prev,
} else
*prev = NULL;
} else
*prev = menu->items[index - 1];
*prev = menu->items[item_no - 1];
if ((index % item_cols) == (item_cols - 1)) {
if ((item_no % item_cols) == (item_cols - 1)) {
if (cycle) {
if (item_cols < 2) {
*next = menu->items[index];
*next = menu->items[item_no];
} else {
neighbour = index - item_cols + 1;
neighbour = item_no - item_cols + 1;
if (neighbour >= menu->item_count) {
if (item_cols == 2) {
*next = menu->items[index];
*next = menu->items[item_no];
} else {
neighbour = item_cols * index / item_cols;
neighbour = item_cols * item_no / item_cols;
*next = menu->items[neighbour];
}
@ -221,7 +221,7 @@ __menui_calc_neighbours(menu, index, cycle, item_rows, item_cols, next, prev,
} else
*next = NULL;
} else {
neighbour = index + 1;
neighbour = item_no + 1;
if (neighbour >= menu->item_count) {
if (cycle) {
neighbour = item_cols * (item_rows - 1);
@ -238,10 +238,10 @@ __menui_calc_neighbours(menu, index, cycle, item_rows, item_cols, next, prev,
* accordingly. Call the term and init functions if required.
*/
int
__menui_goto_item(menu, item, top_row)
_menui_goto_item(menu, item, new_top_row)
MENU *menu;
ITEM *item;
int top_row;
int new_top_row;
{
int old_top_row = menu->top_row, old_cur_item = menu->cur_item;
@ -250,10 +250,10 @@ __menui_goto_item(menu, item, top_row)
return E_REQUEST_DENIED;
menu->in_init = 1;
if (menu->top_row != top_row) {
if (menu->top_row != new_top_row) {
if ((menu->posted == 1) && (menu->menu_term != NULL))
menu->menu_term(menu);
menu->top_row = top_row;
menu->top_row = new_top_row;
if ((menu->posted == 1) && (menu->menu_init != NULL))
menu->menu_init(menu);
@ -270,7 +270,7 @@ __menui_goto_item(menu, item, top_row)
menu->cur_col = item->col;
if (menu->posted == 1)
__menui_redraw_menu(menu, old_top_row, old_cur_item);
_menui_redraw_menu(menu, old_top_row, old_cur_item);
if ((menu->posted == 1) && (menu->item_init != NULL))
menu->item_init(menu);
@ -287,7 +287,7 @@ __menui_goto_item(menu, item, top_row)
* otherwise return E_NO_MATCH
*/
int
__menui_match_items(menu, direction, item_matched)
_menui_match_items(menu, direction, item_matched)
MENU *menu;
int direction;
int *item_matched;
@ -310,14 +310,15 @@ __menui_match_items(menu, direction, item_matched)
if (caseless) {
if (strncasecmp(menu->items[i]->name.string,
menu->pattern,
menu->plen) == 0) {
(size_t) menu->plen) == 0) {
*item_matched = i;
menu->match_len = menu->plen;
return E_OK;
}
} else {
if (strncmp(menu->items[i]->name.string,
menu->pattern, menu->plen) == 0) {
menu->pattern,
(size_t) menu->plen) == 0) {
*item_matched = i;
menu->match_len = menu->plen;
return E_OK;
@ -345,7 +346,7 @@ __menui_match_items(menu, direction, item_matched)
* index of the item that matched the pattern.
*/
int
__menui_match_pattern(menu, c, direction, item_matched)
_menui_match_pattern(menu, c, direction, item_matched)
MENU *menu;
char c;
int direction;
@ -376,14 +377,14 @@ __menui_match_pattern(menu, c, direction, item_matched)
return E_NO_MATCH;
}
if (__menui_match_items(menu, direction,
if (_menui_match_items(menu, direction,
item_matched) == E_NO_MATCH) {
menu->pattern[--menu->plen] = '\0';
return E_NO_MATCH;
} else
return E_OK;
} else {
if (__menui_match_items(menu, direction,
if (_menui_match_items(menu, direction,
item_matched) == E_OK) {
return E_OK;
} else {
@ -396,7 +397,7 @@ __menui_match_pattern(menu, c, direction, item_matched)
* Draw an item in the subwindow complete with appropriate highlighting.
*/
void
__menui_draw_item(menu, item)
_menui_draw_item(menu, item)
MENU *menu;
int item;
{
@ -471,7 +472,7 @@ __menui_draw_item(menu, item)
* Draw the menu in the subwindow provided.
*/
int
__menui_draw_menu(menu)
_menui_draw_menu(menu)
MENU *menu;
{
int rowmajor, i, j, max_items, last_item, row = -1, col = -1;
@ -522,7 +523,7 @@ __menui_draw_menu(menu)
for (j = 0; j < menu->col_width; j++)
waddch(menu->menu_subwin, ' ');
} else {
__menui_draw_item(menu, i);
_menui_draw_item(menu, i);
}
@ -542,7 +543,7 @@ __menui_draw_menu(menu)
*
*/
void
__menui_max_item_size(menu)
_menui_max_item_size(menu)
MENU *menu;
{
int i, with_desc, width;
@ -565,7 +566,7 @@ __menui_max_item_size(menu)
* unhighlight the old item and highlight the new one.
*/
static void
__menui_redraw_menu(menu, old_top_row, old_cur_item)
_menui_redraw_menu(menu, old_top_row, old_cur_item)
MENU *menu;
int old_top_row;
int old_cur_item;
@ -579,13 +580,13 @@ __menui_redraw_menu(menu, old_top_row, old_cur_item)
* XXXX changed lines.
*/
wclear(menu->menu_subwin);
__menui_draw_menu(menu);
_menui_draw_menu(menu);
} else {
if (menu->cur_item != old_cur_item) {
/* redo the old item as a normal one. */
__menui_draw_item(menu, old_cur_item);
_menui_draw_item(menu, old_cur_item);
}
/* and then redraw the current item */
__menui_draw_item(menu, menu->cur_item);
_menui_draw_item(menu, menu->cur_item);
}
}

View File

@ -1,7 +1,7 @@
/* $NetBSD: internals.h,v 1.2 1999/11/24 12:43:15 kleink Exp $ */
/* $Id: internals.h,v 1.3 1999/12/16 12:08:07 blymn Exp $ */
/*-
* Copyright (c) 1998-1999 Brett Lymn (blymn@baea.com.au, brett_lymn@yahoo.com)
* Copyright (c) 1998-1999 Brett Lymn (blymn@baea.com.au, brett_lymn@yahoo.com.au)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -36,13 +36,17 @@
#define MATCH_NEXT_FORWARD 3
#define MATCH_NEXT_REVERSE 4
/* stole this from curses.h */
#define max(a,b) ((a) > (b) ? a : b)
/* function prototypes */
int __menui_stitch_items __P((MENU *));
int __menui_goto_item __P((MENU *, ITEM *, int));
int __menui_match_pattern __P((MENU *, char, int, int *));
int __menui_match_items __P((MENU *, int, int *));
int __menui_draw_menu __P((MENU *));
void __menui_max_item_size __P((MENU *));
void _menui_draw_item __P((MENU *, int));
int _menui_draw_menu __P((MENU *));
int _menui_goto_item __P((MENU *, ITEM *, int));
int _menui_match_pattern __P((MENU *, char, int, int *));
int _menui_match_items __P((MENU *, int, int *));
void _menui_max_item_size __P((MENU *));
int _menui_stitch_items __P((MENU *));
#endif

View File

@ -1,7 +1,7 @@
/* $NetBSD: item.c,v 1.3 1999/11/30 15:58:16 kleink Exp $ */
/* $Id: item.c,v 1.4 1999/12/16 12:08:07 blymn Exp $ */
/*-
* Copyright (c) 1998-1999 Brett Lymn (blymn@baea.com.au, brett_lymn@yahoo.com)
* Copyright (c) 1998-1999 Brett Lymn (blymn@baea.com.au, brett_lymn@yahoo.com.au)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -99,7 +99,7 @@ item_description(item)
int
set_item_init(menu, func)
MENU *menu;
_menui_menu_hook func;
Menu_Hook func;
{
if (menu == NULL)
_menui_default_menu.item_init = func;
@ -112,7 +112,7 @@ set_item_init(menu, func)
/*
* Return a pointer to the item initialisation routine.
*/
_menui_menu_hook
Menu_Hook
item_init(menu)
MENU *menu;
{
@ -129,7 +129,7 @@ item_init(menu)
int
set_item_term(menu, func)
MENU *menu;
_menui_menu_hook func;
Menu_Hook func;
{
if (menu == NULL)
_menui_default_menu.item_term = func;
@ -141,7 +141,7 @@ set_item_term(menu, func)
/*
* Return a pointer to the termination function
*/
_menui_menu_hook
Menu_Hook
item_term(menu)
MENU *menu;
{

View File

@ -1,7 +1,7 @@
/* $NetBSD: menu.c,v 1.3 1999/11/30 15:58:16 kleink Exp $ */
/* $Id: menu.c,v 1.4 1999/12/16 12:08:07 blymn Exp $ */
/*-
* Copyright (c) 1998-1999 Brett Lymn (blymn@baea.com.au, brett_lymn@yahoo.com)
* Copyright (c) 1998-1999 Brett Lymn (blymn@baea.com.au, brett_lymn@yahoo.com.au)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -91,7 +91,7 @@ set_menu_mark(m, mark)
menu->mark.length = strlen(mark);
/* max item size may have changed - recalculate. */
__menui_max_item_size(menu);
_menui_max_item_size(menu);
return E_OK;
}
@ -129,7 +129,7 @@ set_menu_unmark(m, mark)
strcpy(menu->unmark.string, mark);
menu->unmark.length = strlen(mark);
/* max item size may have changed - recalculate. */
__menui_max_item_size(menu);
_menui_max_item_size(menu);
return E_OK;
}
@ -218,7 +218,7 @@ set_menu_format(param_menu, rows, cols)
if (menu->items != NULL)
/* recalculate the item neighbours */
return __menui_stitch_items(menu);
return _menui_stitch_items(menu);
return E_OK;
}
@ -244,7 +244,7 @@ menu_format(param_menu, rows, cols)
int
set_menu_init(menu, func)
MENU *menu;
_menui_menu_hook func;
Menu_Hook func;
{
if (menu == NULL)
_menui_default_menu.menu_init = func;
@ -256,7 +256,7 @@ set_menu_init(menu, func)
/*
* Return the pointer to the menu init function.
*/
_menui_menu_hook
Menu_Hook
menu_init(MENU *menu)
{
if (menu == NULL)
@ -271,7 +271,7 @@ menu_init(MENU *menu)
int
set_menu_term(menu, func)
MENU *menu;
_menui_menu_hook func;
Menu_Hook func;
{
if (menu == NULL)
_menui_default_menu.menu_term = func;
@ -283,7 +283,7 @@ set_menu_term(menu, func)
/*
* Return the user defined menu termination function pointer.
*/
_menui_menu_hook
Menu_Hook
menu_term(menu)
MENU *menu;
{
@ -321,7 +321,7 @@ set_menu_opts(param_menu, opts)
if ((menu->opts & O_ROWMAJOR) != (old_opts & O_ROWMAJOR))
/* changed menu layout - need to recalc neighbours */
__menui_stitch_items(menu);
_menui_stitch_items(menu);
return E_OK;
}
@ -342,7 +342,7 @@ menu_opts_on(param_menu, opts)
if ((menu->items != NULL) &&
(menu->opts & O_ROWMAJOR) != (old_opts & O_ROWMAJOR))
/* changed menu layout - need to recalc neighbours */
__menui_stitch_items(menu);
_menui_stitch_items(menu);
return E_OK;
}
@ -363,7 +363,7 @@ menu_opts_off(param_menu, opts)
if ((menu->items != NULL ) &&
(menu->opts & O_ROWMAJOR) != (old_opts & O_ROWMAJOR))
/* changed menu layout - need to recalc neighbours */
__menui_stitch_items(menu);
_menui_stitch_items(menu);
return E_OK;
}
@ -405,7 +405,7 @@ set_menu_pattern(param_menu, pat)
menu->plen = strlen(pat);
/* search item list for pat here */
return __menui_match_items(menu, MATCH_FORWARD, &menu->cur_item);
return _menui_match_items(menu, MATCH_FORWARD, &menu->cur_item);
}
/*
@ -485,7 +485,7 @@ scale_menu(param_menu, rows, cols)
return E_BAD_ARGUMENT;
/* calculate the max item size */
__menui_max_item_size(menu);
_menui_max_item_size(menu);
*rows = menu->rows;
*cols = menu->cols * menu->max_item_width;
@ -547,7 +547,7 @@ set_menu_items(param_menu, items)
menu->match_len = 0;
}
__menui_stitch_items(menu); /* recalculate the item neighbours */
_menui_stitch_items(menu); /* recalculate the item neighbours */
return E_OK;
}

View File

@ -1,7 +1,7 @@
/* $NetBSD: menu.h,v 1.3 1999/11/24 12:43:16 kleink Exp $ */
/* $Id: menu.h,v 1.4 1999/12/16 12:08:07 blymn Exp $ */
/*-
* Copyright (c) 1998-1999 Brett Lymn (blymn@baea.com.au, brett_lymn@yahoo.com)
* Copyright (c) 1998-1999 Brett Lymn (blymn@baea.com.au, brett_lymn@yahoo.com.au)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -81,7 +81,7 @@ typedef struct __menu_str {
typedef struct __menu MENU;
typedef struct __item ITEM;
typedef void (*_menui_menu_hook) (MENU *);
typedef void (*Menu_Hook) (MENU *);
struct __item {
MENU_STR name;
@ -129,11 +129,11 @@ struct __menu {
ITEM **items; /* items associated with this menu */
int cur_item; /* item cursor is currently positioned at */
int in_init; /* set when processing an init or term function call */
_menui_menu_hook menu_init; /* call this when menu is posted */
_menui_menu_hook menu_term; /* call this when menu is unposted */
_menui_menu_hook item_init; /* call this when menu posted & after
Menu_Hook menu_init; /* call this when menu is posted */
Menu_Hook menu_term; /* call this when menu is unposted */
Menu_Hook item_init; /* call this when menu posted & after
current item changes */
_menui_menu_hook item_term; /* call this when menu unposted & just
Menu_Hook item_term; /* call this when menu unposted & just
before current item changes */
WINDOW *menu_win; /* the menu window */
WINDOW *menu_subwin; /* the menu subwindow */
@ -154,7 +154,7 @@ char menu_back __P((MENU *));
char menu_fore __P((MENU *));
void menu_format __P((MENU *, int *, int *));
char menu_grey __P((MENU *));
_menui_menu_hook menu_init __P((MENU *));
Menu_Hook menu_init __P((MENU *));
char *menu_mark __P((MENU *));
OPTIONS menu_opts __P((MENU *));
int menu_opts_off __P((MENU *, OPTIONS));
@ -162,7 +162,7 @@ int menu_opts_on __P((MENU *, OPTIONS));
int menu_pad __P((MENU *));
char *menu_pattern __P((MENU *));
WINDOW *menu_sub __P((MENU *));
_menui_menu_hook menu_term __P((MENU *));
Menu_Hook menu_term __P((MENU *));
char *menu_unmark __P((MENU *));
char *menu_userptr __P((MENU *));
WINDOW *menu_win __P((MENU *));
@ -172,14 +172,14 @@ int set_menu_back __P((MENU *, attr_t));
int set_menu_fore __P((MENU *, attr_t));
int set_menu_format __P((MENU *, int, int));
int set_menu_grey __P((MENU *, attr_t));
int set_menu_init __P((MENU *, _menui_menu_hook));
int set_menu_init __P((MENU *, Menu_Hook));
int set_menu_items __P((MENU *, ITEM **));
int set_menu_mark __P((MENU *, char *));
int set_menu_opts __P((MENU *, OPTIONS));
int set_menu_pad __P((MENU *, int));
int set_menu_pattern __P((MENU *, char *));
int set_menu_sub __P((MENU *, WINDOW *));
int set_menu_term __P((MENU *, _menui_menu_hook));
int set_menu_term __P((MENU *, Menu_Hook));
int set_menu_unmark __P((MENU *, char *));
int set_menu_userptr __P((MENU *, char *));
int set_menu_win __P((MENU *, WINDOW *));
@ -190,30 +190,24 @@ int free_item __P((ITEM *));
int item_count __P((MENU *));
char *item_description __P((ITEM *));
int item_index __P((ITEM *));
_menui_menu_hook item_init __P((MENU *));
Menu_Hook item_init __P((MENU *));
char *item_name __P((ITEM *));
OPTIONS item_opts __P((ITEM *));
int item_opts_off __P((ITEM *, OPTIONS));
int item_opts_on __P((ITEM *, OPTIONS));
_menui_menu_hook item_term __P((MENU *));
Menu_Hook item_term __P((MENU *));
char *item_userptr __P((ITEM *));
int item_value __P((ITEM *));
int item_visible __P((ITEM *));
ITEM **menu_items __P((MENU *));
ITEM *new_item __P((char *, char *));
int set_current_item __P((MENU *, ITEM *));
int set_item_init __P((MENU *, _menui_menu_hook));
int set_item_init __P((MENU *, Menu_Hook));
int set_item_opts __P((ITEM *, OPTIONS));
int set_item_term __P((MENU *, _menui_menu_hook));
int set_item_term __P((MENU *, Menu_Hook));
int set_item_userptr __P((ITEM *, char *));
int set_item_value __P((ITEM *, int));
#ifdef __LIBMENU_EXPOSE_PRIVATES__
void __menui_draw_item __P((MENU *, int));
/* stole this from curses.h */
#define max(a,b) ((a) > (b) ? a : b)
#endif
__END_DECLS
#endif /* !_MENU_H_ */

View File

@ -1,7 +1,7 @@
/* $NetBSD: post.c,v 1.2 1999/11/24 12:43:20 kleink Exp $ */
/* $Id: post.c,v 1.3 1999/12/16 12:08:12 blymn Exp $ */
/*-
* Copyright (c) 1998-1999 Brett Lymn (blymn@baea.com.au, brett_lymn@yahoo.com)
* Copyright (c) 1998-1999 Brett Lymn (blymn@baea.com.au, brett_lymn@yahoo.com.au)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -91,7 +91,7 @@ post_menu(menu)
}
menu->posted = 1;
return __menui_draw_menu(menu);
return _menui_draw_menu(menu);
}

View File

@ -1,5 +1,5 @@
# $NetBSD: shlib_version,v 1.2 1999/11/24 12:43:20 kleink Exp $
# $Id: shlib_version,v 1.3 1999/12/16 12:08:12 blymn Exp $
# Remember to update distrib/sets/lists/base/shl.* when changing
#
major=0
minor=0
minor=1

View File

@ -1,7 +1,7 @@
/* $NetBSD: userptr.c,v 1.3 1999/11/30 15:58:17 kleink Exp $ */
/* $Id: userptr.c,v 1.4 1999/12/16 12:08:12 blymn Exp $ */
/*-
* Copyright (c) 1998-1999 Brett Lymn (blymn@baea.com.au, brett_lymn@yahoo.com)
* Copyright (c) 1998-1999 Brett Lymn (blymn@baea.com.au, brett_lymn@yahoo.com.au)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without