Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libmenu * Made all functions and prototypes ANSI style.
details: https://anonhg.NetBSD.org/src/rev/45551c44c10b
branches: trunk
changeset: 485141:45551c44c10b
user: blymn <blymn%NetBSD.org@localhost>
date: Thu Apr 20 12:17:57 2000 +0000
description:
* Made all functions and prototypes ANSI style.
* Fixed problem with highlight bar on inverse menus.
* Fixed libmenu crashing when posting a menu without sub window set.
* Fixed man page glitches.
diffstat:
lib/libmenu/attributes.c | 30 ++------
lib/libmenu/driver.c | 6 +-
lib/libmenu/internals.c | 83 ++++++++++---------------
lib/libmenu/internals.h | 17 ++--
lib/libmenu/item.c | 60 +++++-------------
lib/libmenu/menu.c | 99 ++++++++----------------------
lib/libmenu/menu.h | 126 ++++++++++++++++++++--------------------
lib/libmenu/menu_format.3 | 4 +-
lib/libmenu/menu_item_current.3 | 6 +-
lib/libmenu/menu_item_name.3 | 4 +-
lib/libmenu/post.c | 16 ++--
lib/libmenu/userptr.c | 16 +---
12 files changed, 185 insertions(+), 282 deletions(-)
diffs (truncated from 1133 to 300 lines):
diff -r 3580a5d6832d -r 45551c44c10b lib/libmenu/attributes.c
--- a/lib/libmenu/attributes.c Thu Apr 20 12:08:50 2000 +0000
+++ b/lib/libmenu/attributes.c Thu Apr 20 12:17:57 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: attributes.c,v 1.4 1999/12/22 14:38:12 kleink Exp $ */
+/* $NetBSD: attributes.c,v 1.5 2000/04/20 12:17:57 blymn Exp $ */
/*-
* Copyright (c) 1998-1999 Brett Lymn (blymn%baea.com.au@localhost, brett_lymn%yahoo.com.au@localhost)
@@ -35,9 +35,7 @@
* Set the menu foreground attribute
*/
int
-set_menu_fore(menu, attr)
- MENU *menu;
- attr_t attr;
+set_menu_fore(MENU *menu, attr_t attr)
{
if (menu == NULL)
_menui_default_menu.fore = attr;
@@ -50,8 +48,7 @@
* Return the menu foreground attribute
*/
char
-menu_fore(menu)
- MENU *menu;
+menu_fore(MENU *menu)
{
if (menu == NULL)
return _menui_default_menu.fore;
@@ -63,9 +60,7 @@
* Set the menu background attribute
*/
int
-set_menu_back(menu, attr)
- MENU *menu;
- attr_t attr;
+set_menu_back(MENU *menu, attr_t attr)
{
if (menu == NULL)
_menui_default_menu.back = attr;
@@ -78,8 +73,7 @@
* Return the menu background attribute
*/
char
-menu_back(menu)
- MENU *menu;
+menu_back(MENU *menu)
{
if (menu == NULL)
return _menui_default_menu.back;
@@ -91,9 +85,7 @@
* Set the menu greyed out attribute
*/
int
-set_menu_grey(menu, attr)
- MENU *menu;
- attr_t attr;
+set_menu_grey(MENU *menu, attr_t attr)
{
if (menu == NULL)
_menui_default_menu.grey = attr;
@@ -106,8 +98,7 @@
* Return the menu greyed out attribute
*/
char
-menu_grey(menu)
- MENU *menu;
+menu_grey(MENU *menu)
{
if (menu == NULL)
return _menui_default_menu.grey;
@@ -119,9 +110,7 @@
* Set the menu pad character - the filler char between name and description
*/
int
-set_menu_pad(menu, pad)
- MENU *menu;
- int pad;
+set_menu_pad(MENU *menu, int pad)
{
if (menu == NULL)
_menui_default_menu.pad = pad;
@@ -134,8 +123,7 @@
* Return the menu pad character
*/
int
-menu_pad(menu)
- MENU *menu;
+menu_pad(MENU *menu)
{
if (menu == NULL)
return _menui_default_menu.pad;
diff -r 3580a5d6832d -r 45551c44c10b lib/libmenu/driver.c
--- a/lib/libmenu/driver.c Thu Apr 20 12:08:50 2000 +0000
+++ b/lib/libmenu/driver.c Thu Apr 20 12:17:57 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: driver.c,v 1.4 1999/12/22 14:38:12 kleink Exp $ */
+/* $NetBSD: driver.c,v 1.5 2000/04/20 12:17:57 blymn Exp $ */
/*-
* Copyright (c) 1998-1999 Brett Lymn (blymn%baea.com.au@localhost, brett_lymn%yahoo.com.au@localhost)
@@ -40,9 +40,7 @@
* request and is not printable then it assumed to be a user defined command.
*/
int
-menu_driver(menu, c)
- MENU *menu;
- int c;
+menu_driver(MENU *menu, int c)
{
int drv_top_row, drv_scroll, it, status = E_OK;
ITEM *drv_new_item;
diff -r 3580a5d6832d -r 45551c44c10b lib/libmenu/internals.c
--- a/lib/libmenu/internals.c Thu Apr 20 12:08:50 2000 +0000
+++ b/lib/libmenu/internals.c Thu Apr 20 12:17:57 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: internals.c,v 1.5 2000/03/13 22:59:22 soren Exp $ */
+/* $NetBSD: internals.c,v 1.6 2000/04/20 12:17:57 blymn Exp $ */
/*-
* Copyright (c) 1998-1999 Brett Lymn (blymn%baea.com.au@localhost, brett_lymn%yahoo.com.au@localhost)
@@ -34,9 +34,10 @@
/* internal function prototypes */
static void
-_menui_calc_neighbours(MENU *, int, int, int, int, ITEM **, ITEM **,
- ITEM **, ITEM **);
-static void _menui_redraw_menu __P((MENU *, int, int));
+_menui_calc_neighbours(MENU *menu, int item_no, int cycle, int item_rows,
+ int item_cols, ITEM **next, ITEM **prev,
+ ITEM **major_next, ITEM **major_prev);
+static void _menui_redraw_menu(MENU *menu, int old_top_row, int old_cur_item);
/*
* Link all the menu items together to speed up navigation. We need
@@ -46,8 +47,7 @@
* calculated and the item structures updated.
*/
int
-_menui_stitch_items(menu)
- MENU *menu;
+_menui_stitch_items(MENU *menu)
{
int i, cycle, row_major;
@@ -114,17 +114,9 @@
* order the caller can generate the neighbours for either menu layout style.
*/
static void
-_menui_calc_neighbours(menu, item_no, cycle, item_rows, item_cols, next, prev,
- major_next, major_prev)
- MENU *menu;
- int item_no;
- int cycle;
- int item_rows;
- int item_cols;
- ITEM **next;
- ITEM **prev;
- ITEM **major_next;
- ITEM **major_prev;
+_menui_calc_neighbours(MENU *menu, int item_no, int cycle, int item_rows,
+ int item_cols, ITEM **next, ITEM **prev,
+ ITEM **major_next, ITEM **major_prev)
{
int neighbour;
@@ -237,10 +229,7 @@
* accordingly. Call the term and init functions if required.
*/
int
-_menui_goto_item(menu, item, new_top_row)
- MENU *menu;
- ITEM *item;
- int new_top_row;
+_menui_goto_item(MENU *menu, ITEM *item, int new_top_row)
{
int old_top_row = menu->top_row, old_cur_item = menu->cur_item;
@@ -286,10 +275,7 @@
* otherwise return E_NO_MATCH
*/
int
-_menui_match_items(menu, direction, item_matched)
- MENU *menu;
- int direction;
- int *item_matched;
+_menui_match_items(MENU *menu, int direction, int *item_matched)
{
int i, caseless;
@@ -345,11 +331,7 @@
* index of the item that matched the pattern.
*/
int
-_menui_match_pattern(menu, c, direction, item_matched)
- MENU *menu;
- char c;
- int direction;
- int *item_matched;
+_menui_match_pattern(MENU *menu, char c, int direction, int *item_matched)
{
if (menu == NULL)
return E_BAD_ARGUMENT;
@@ -396,9 +378,7 @@
* Draw an item in the subwindow complete with appropriate highlighting.
*/
void
-_menui_draw_item(menu, item)
- MENU *menu;
- int item;
+_menui_draw_item(MENU *menu, int item)
{
int j, pad_len, mark_len;
@@ -406,10 +386,10 @@
wmove(menu->menu_subwin,
menu->items[item]->row - menu->top_row,
- menu->items[item]->col * (menu->col_width + 1));
-
+ menu->items[item]->col * menu->col_width);
+
if ((menu->cur_item == item) || (menu->items[item]->selected == 1))
- wattron(menu->menu_subwin, menu->fore);
+ wattrset(menu->menu_subwin, menu->fore);
if ((menu->items[item]->opts & O_SELECTABLE) != O_SELECTABLE)
wattron(menu->menu_subwin, menu->grey);
@@ -460,6 +440,19 @@
waddch(menu->menu_subwin, ' ');
}
menu->items[item]->visible = 1;
+
+ /*
+ * Fill in the spacing between items, annoying but it looks
+ * odd if the menu items are inverse because the spacings do not
+ * have the same attributes as the items.
+ */
+ if (menu->items[item]->col > 0) {
+ wmove(menu->menu_subwin,
+ menu->items[item]->row - menu->top_row,
+ menu->items[item]->col * menu->col_width - 1);
+ waddch(menu->menu_subwin, ' ');
+ }
+
/* kill any special attributes... */
wattrset(menu->menu_subwin, menu->back);
@@ -471,8 +464,7 @@
* Draw the menu in the subwindow provided.
*/
int
-_menui_draw_menu(menu)
- MENU *menu;
+_menui_draw_menu(MENU *menu)
{
int rowmajor, i, j, max_items, last_item, row = -1, col = -1;
@@ -488,9 +480,6 @@
menu->col_width = getmaxx(menu->menu_subwin) / menu->cols;
- /*if ((menu->opts & O_SHOWDESC) == O_SHOWDESC)
- menu->col_width++;*/
-
max_items = menu->rows * menu->cols;
last_item = ((max_items + i) > menu->item_count) ? menu->item_count :
(max_items + i);
@@ -498,7 +487,7 @@
for (; i < last_item; i++) {
if (i > menu->item_count) {
/* no more items to draw, write background blanks */
- wattron(menu->menu_subwin, menu->back);
+ wattrset(menu->menu_subwin, menu->back);
if (row < 0) {
row = menu->items[menu->item_count - 1]->row;
col = menu->items[menu->item_count - 1]->col;
@@ -518,7 +507,7 @@
}
}
wmove(menu->menu_subwin, row,
- col * (menu->col_width + 1));
+ col * menu->col_width);
for (j = 0; j < menu->col_width; j++)
waddch(menu->menu_subwin, ' ');
} else {
@@ -542,8 +531,7 @@
*
*/
void
-_menui_max_item_size(menu)
- MENU *menu;
+_menui_max_item_size(MENU *menu)
{
int i, with_desc, width;
@@ -565,10 +553,7 @@
* unhighlight the old item and highlight the new one.
*/
Home |
Main Index |
Thread Index |
Old Index