CVS commit: src/lib/libmenu
Module Name:src Committed By: blymn Date: Sun Dec 30 12:27:09 UTC 2012 Modified Files: src/lib/libmenu: internals.c menu.c Log Message: Fix bug where menu mark was not displayed on menus with O_ONEVALUE set Set a default menu mark To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/lib/libmenu/internals.c cvs rdiff -u -r1.17 -r1.18 src/lib/libmenu/menu.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libmenu/internals.c diff -u src/lib/libmenu/internals.c:1.15 src/lib/libmenu/internals.c:1.16 --- src/lib/libmenu/internals.c:1.15 Wed Jun 27 11:53:36 2012 +++ src/lib/libmenu/internals.c Sun Dec 30 12:27:09 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: internals.c,v 1.15 2012/06/27 11:53:36 blymn Exp $ */ +/* $NetBSD: internals.c,v 1.16 2012/12/30 12:27:09 blymn Exp $ */ /*- * Copyright (c) 1998-1999 Brett Lymn (bl...@baea.com.au, brett_l...@yahoo.com.au) @@ -27,7 +27,7 @@ */ #include sys/cdefs.h -__RCSID($NetBSD: internals.c,v 1.15 2012/06/27 11:53:36 blymn Exp $); +__RCSID($NetBSD: internals.c,v 1.16 2012/12/30 12:27:09 blymn Exp $); #include menu.h #include ctype.h @@ -446,7 +446,9 @@ _menui_draw_item(MENU *menu, int item) * all others unless the menu unmark string is set in which * case the unmark string is written. */ - if (menu-items[item]-selected == 1) { + if ((menu-items[item]-selected == 1) || + (((menu-opts O_ONEVALUE) == O_ONEVALUE) + (menu-cur_item == item))) { if (menu-mark.string != NULL) { for (j = 0; j menu-mark.length; j++) { waddch(menu-scrwin, Index: src/lib/libmenu/menu.c diff -u src/lib/libmenu/menu.c:1.17 src/lib/libmenu/menu.c:1.18 --- src/lib/libmenu/menu.c:1.17 Wed Mar 21 05:33:27 2012 +++ src/lib/libmenu/menu.c Sun Dec 30 12:27:09 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: menu.c,v 1.17 2012/03/21 05:33:27 matt Exp $ */ +/* $NetBSD: menu.c,v 1.18 2012/12/30 12:27:09 blymn Exp $ */ /*- * Copyright (c) 1998-1999 Brett Lymn (bl...@baea.com.au, brett_l...@yahoo.com.au) @@ -27,7 +27,7 @@ */ #include sys/cdefs.h -__RCSID($NetBSD: menu.c,v 1.17 2012/03/21 05:33:27 matt Exp $); +__RCSID($NetBSD: menu.c,v 1.18 2012/12/30 12:27:09 blymn Exp $); #include ctype.h #include menu.h @@ -445,7 +445,8 @@ MENU * new_menu(ITEM **items) { MENU *the_menu; - +char mark[2]; + if ((the_menu = (MENU *)malloc(sizeof(MENU))) == NULL) return NULL; @@ -483,6 +484,12 @@ new_menu(ITEM **items) (unsigned) _menui_default_menu.unmark.length+ 1 ); } + /* default mark needs to be set */ + mark[0] = '-'; + mark[1] = '\0'; + + set_menu_mark(the_menu, mark); + /* now attach the items, if any */ if (items != NULL) { if(set_menu_items(the_menu, items) 0) {
CVS commit: src/lib/libmenu
Module Name:src Committed By: jdf Date: Sat Jun 30 09:25:55 UTC 2012 Modified Files: src/lib/libmenu: menu_items.3 menu_new.3 Log Message: Replace wrong variable type (s/ITEMS/ITEM). To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/lib/libmenu/menu_items.3 \ src/lib/libmenu/menu_new.3 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libmenu/menu_items.3 diff -u src/lib/libmenu/menu_items.3:1.9 src/lib/libmenu/menu_items.3:1.10 --- src/lib/libmenu/menu_items.3:1.9 Wed Apr 16 13:35:11 2003 +++ src/lib/libmenu/menu_items.3 Sat Jun 30 09:25:55 2012 @@ -1,4 +1,4 @@ -.\ $NetBSD: menu_items.3,v 1.9 2003/04/16 13:35:11 wiz Exp $ +.\ $NetBSD: menu_items.3,v 1.10 2012/06/30 09:25:55 jdf Exp $ .\ .\ Copyright (c) 1999 .\ Brett Lymn - bl...@baea.com.au, brett_l...@yahoo.com.au @@ -43,7 +43,7 @@ .In menu.h .Ft int .Fn item_count MENU *menu -.Ft ITEMS ** +.Ft ITEM ** .Fn menu_items MENU *menu .Ft int .Fn set_menu_items MENU *menu ITEM **items Index: src/lib/libmenu/menu_new.3 diff -u src/lib/libmenu/menu_new.3:1.9 src/lib/libmenu/menu_new.3:1.10 --- src/lib/libmenu/menu_new.3:1.9 Wed Apr 16 13:35:11 2003 +++ src/lib/libmenu/menu_new.3 Sat Jun 30 09:25:55 2012 @@ -1,4 +1,4 @@ -.\ $NetBSD: menu_new.3,v 1.9 2003/04/16 13:35:11 wiz Exp $ +.\ $NetBSD: menu_new.3,v 1.10 2012/06/30 09:25:55 jdf Exp $ .\ .\ Copyright (c) 1999 .\ Brett Lymn - bl...@baea.com.au, brett_l...@yahoo.com.au @@ -43,7 +43,7 @@ .Ft int .Fn free_menu MENU *menu .Ft MENU * -.Fn new_menu ITEMS **items +.Fn new_menu ITEM **items .Sh DESCRIPTION The .Fn free_menu
CVS commit: src/lib/libmenu
Module Name:src Committed By: blymn Date: Wed Jun 27 11:39:14 UTC 2012 Modified Files: src/lib/libmenu: internals.c Log Message: Extraneous whitespace removal. To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/lib/libmenu/internals.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libmenu/internals.c diff -u src/lib/libmenu/internals.c:1.13 src/lib/libmenu/internals.c:1.14 --- src/lib/libmenu/internals.c:1.13 Fri Nov 24 19:46:58 2006 +++ src/lib/libmenu/internals.c Wed Jun 27 11:39:14 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: internals.c,v 1.13 2006/11/24 19:46:58 christos Exp $ */ +/* $NetBSD: internals.c,v 1.14 2012/06/27 11:39:14 blymn Exp $ */ /*- * Copyright (c) 1998-1999 Brett Lymn (bl...@baea.com.au, brett_l...@yahoo.com.au) @@ -27,7 +27,7 @@ */ #include sys/cdefs.h -__RCSID($NetBSD: internals.c,v 1.13 2006/11/24 19:46:58 christos Exp $); +__RCSID($NetBSD: internals.c,v 1.14 2012/06/27 11:39:14 blymn Exp $); #include menu.h #include ctype.h @@ -73,7 +73,7 @@ _menui_stitch_items(MENU *menu) if (menu-item_count (menu-item_rows * menu-item_cols)) menu-item_cols += 1; } - + _menui_max_item_size(menu); @@ -96,7 +96,7 @@ _menui_stitch_items(MENU *menu) : menu-items[i]-right, (row_major) ? menu-items[i]-up : menu-items[i]-left); - + /* fill in the row and column value of the item */ if (row_major) { menu-items[i]-row = i / menu-item_cols; @@ -106,7 +106,7 @@ _menui_stitch_items(MENU *menu) menu-items[i]-col = i / menu-item_rows; } } - + return E_OK; } @@ -148,8 +148,8 @@ _menui_calc_neighbours(MENU *menu, int i *major_next = NULL; } else *major_next = menu-items[neighbour]; - - + + neighbour = item_no - item_cols; if (neighbour 0) { if (cycle) { @@ -166,7 +166,7 @@ _menui_calc_neighbours(MENU *menu, int i neighbour = item_no + (item_rows - 2) * item_cols; - + *major_prev = menu-items[neighbour]; } } else @@ -174,7 +174,7 @@ _menui_calc_neighbours(MENU *menu, int i } else *major_prev = menu-items[neighbour]; } - + if ((item_no % item_cols) == 0) { if (cycle) { if (item_cols 2) { @@ -194,7 +194,7 @@ _menui_calc_neighbours(MENU *menu, int i *prev = NULL; } else *prev = menu-items[item_no - 1]; - + if ((item_no % item_cols) == (item_cols - 1)) { if (cycle) { if (item_cols 2) { @@ -206,7 +206,7 @@ _menui_calc_neighbours(MENU *menu, int i *next = menu-items[item_no]; } else { neighbour = item_cols * item_no / item_cols; - + *next = menu-items[neighbour]; } } else @@ -235,7 +235,7 @@ int _menui_goto_item(MENU *menu, ITEM *item, int new_top_row) { int old_top_row = menu-top_row, old_cur_item = menu-cur_item; - + /* If we get a null then the menu is not cyclic so deny request */ if (item == NULL) return E_REQUEST_DENIED; @@ -249,7 +249,7 @@ _menui_goto_item(MENU *menu, ITEM *item, if ((menu-posted == 1) (menu-menu_init != NULL)) menu-menu_init(menu); } - + /* this looks like wasted effort but it can happen */ if (menu-cur_item != item-index) { @@ -262,10 +262,10 @@ _menui_goto_item(MENU *menu, ITEM *item, if (menu-posted == 1) _menui_redraw_menu(menu, old_top_row, old_cur_item); - + if ((menu-posted == 1) (menu-item_init != NULL)) menu-item_init(menu); - + } menu-in_init = 0; @@ -283,7 +283,7 @@ _menui_match_items(MENU *menu, int direc int i, caseless; caseless = ((menu-opts O_IGNORECASE) == O_IGNORECASE); - + i = menu-cur_item; if (direction == MATCH_NEXT_FORWARD) { if (++i = menu-item_count) i = 0; @@ -291,7 +291,7 @@ _menui_match_items(MENU *menu, int direc if (--i 0) i = menu-item_count - 1; } - + do { if (menu-items[i]-name.length = menu-plen) { /* no chance if pattern is longer */ @@ -313,7 +313,7 @@ _menui_match_items(MENU *menu, int direc } } } - + if ((direction == MATCH_FORWARD) || (direction == MATCH_NEXT_FORWARD)) { if (++i = menu-item_count) i = 0; @@ -327,7 +327,7 @@ _menui_match_items(MENU *menu, int direc } /* - * Attempt to match the pattern buffer against the items. If c is a + * Attempt to match the pattern buffer against the items. If c is a * printable character then add it to the pattern buffer prior to * performing the match. Direction determines the direction of matching. * If the match is successful update the item_matched variable with the @@ -360,7 +360,7 @@ _menui_match_pattern(MENU *menu, int c, menu-pattern[--menu-plen] = '\0'; return E_NO_MATCH; } - + if (_menui_match_items(menu, direction, item_matched) == E_NO_MATCH) { menu-pattern[--menu-plen] = '\0'; @@ -384,9 +384,9 @@ void _menui_draw_item(MENU *menu, int item) { int j, pad_len, mark_len; - +
CVS commit: src/lib/libmenu
Module Name:src Committed By: blymn Date: Wed Jun 27 11:53:36 UTC 2012 Modified Files: src/lib/libmenu: internals.c Log Message: * Corrected menu drawing when O_ROWMAJOR is not set * Corrected menu item neighbour calculation so it works when O_ROWMAJOR is set and unset. This corrects item navigation which was previously broken when O_ROWMAJOR was not set. This resolves lib/46620. To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 src/lib/libmenu/internals.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libmenu/internals.c diff -u src/lib/libmenu/internals.c:1.14 src/lib/libmenu/internals.c:1.15 --- src/lib/libmenu/internals.c:1.14 Wed Jun 27 11:39:14 2012 +++ src/lib/libmenu/internals.c Wed Jun 27 11:53:36 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: internals.c,v 1.14 2012/06/27 11:39:14 blymn Exp $ */ +/* $NetBSD: internals.c,v 1.15 2012/06/27 11:53:36 blymn Exp $ */ /*- * Copyright (c) 1998-1999 Brett Lymn (bl...@baea.com.au, brett_l...@yahoo.com.au) @@ -27,7 +27,7 @@ */ #include sys/cdefs.h -__RCSID($NetBSD: internals.c,v 1.14 2012/06/27 11:39:14 blymn Exp $); +__RCSID($NetBSD: internals.c,v 1.15 2012/06/27 11:53:36 blymn Exp $); #include menu.h #include ctype.h @@ -37,9 +37,7 @@ __RCSID($NetBSD: internals.c,v 1.14 201 /* internal function prototypes */ static void -_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); +_menui_calc_neighbours(MENU *menu, int item_no); static void _menui_redraw_menu(MENU *menu, int old_top_row, int old_cur_item); /* @@ -52,9 +50,8 @@ static void _menui_redraw_menu(MENU *men int _menui_stitch_items(MENU *menu) { - int i, cycle, row_major; + int i, row_major; - cycle = ((menu-opts O_NONCYCLIC) != O_NONCYCLIC); row_major = ((menu-opts O_ROWMAJOR) == O_ROWMAJOR); if (menu-posted == 1) @@ -62,41 +59,14 @@ _menui_stitch_items(MENU *menu) if (menu-items == NULL) return E_BAD_ARGUMENT; - if (row_major) { - menu-item_rows = menu-item_count / menu-cols; - menu-item_cols = menu-cols; - if (menu-item_count (menu-item_rows * menu-item_cols)) - menu-item_rows += 1; - } else { - menu-item_cols = menu-item_count / menu-rows; - menu-item_rows = menu-rows; - if (menu-item_count (menu-item_rows * menu-item_cols)) - menu-item_cols += 1; - } - + menu-item_rows = menu-item_count / menu-cols; + menu-item_cols = menu-cols; + if (menu-item_count (menu-item_rows * menu-item_cols)) + menu-item_rows += 1; _menui_max_item_size(menu); for (i = 0; i menu-item_count; i++) { - /* Calculate the neighbours. The ugliness here deals with - * the differing menu layout styles. The layout affects - * the neighbour calculation so we change the arguments - * around depending on the layout style. - */ - _menui_calc_neighbours(menu, i, cycle, - (row_major) ? menu-item_rows - : menu-item_cols, - (row_major) ? menu-item_cols - : menu-item_rows, - (row_major) ? menu-items[i]-right - : menu-items[i]-down, - (row_major) ? menu-items[i]-left - : menu-items[i]-up, - (row_major) ? menu-items[i]-down - : menu-items[i]-right, - (row_major) ? menu-items[i]-up - : menu-items[i]-left); - /* fill in the row and column value of the item */ if (row_major) { menu-items[i]-row = i / menu-item_cols; @@ -105,125 +75,200 @@ _menui_stitch_items(MENU *menu) menu-items[i]-row = i % menu-item_rows; menu-items[i]-col = i / menu-item_rows; } + + _menui_calc_neighbours(menu, i); } return E_OK; } /* - * Calculate the neighbours for an item in menu. This routine deliberately - * does not refer to up/down/left/right as these concepts depend on the menu - * layout style (row major or not). By arranging the arguments in the right - * order the caller can generate the neighbours for either menu layout style. + * Calculate the neighbours for an item in menu. */ static void -_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) +_menui_calc_neighbours(MENU *menu, int item_no) { - int neighbour; + int neighbour, cycle, row_major, edge; + ITEM *item; + + row_major = ((menu-opts O_ROWMAJOR) == O_ROWMAJOR); + cycle = ((menu-opts O_NONCYCLIC) != O_NONCYCLIC); + item = menu-items[item_no]; - if (item_rows 2) { + if (menu-item_rows 2) { if (cycle) { - *major_next = menu-items[item_no]; - *major_prev = menu-items[item_no]; + item-up = item; + item-down = item; } else { - *major_next = NULL; - *major_prev = NULL; + item-up = NULL; + item-down = NULL; } } else { - neighbour = item_no + item_cols; - if (neighbour = menu-item_count) { - if (cycle) { -if (item_rows == 2) {
CVS commit: src/lib/libmenu
Module Name:src Committed By: reed Date: Sat Oct 24 11:17:13 UTC 2009 Modified Files: src/lib/libmenu: menu_post.3 Log Message: Add missing comma in the NAME Nm list. To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/lib/libmenu/menu_post.3 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libmenu/menu_post.3 diff -u src/lib/libmenu/menu_post.3:1.9 src/lib/libmenu/menu_post.3:1.10 --- src/lib/libmenu/menu_post.3:1.9 Wed Apr 16 13:35:11 2003 +++ src/lib/libmenu/menu_post.3 Sat Oct 24 11:17:13 2009 @@ -1,4 +1,4 @@ -.\ $NetBSD: menu_post.3,v 1.9 2003/04/16 13:35:11 wiz Exp $ +.\ $NetBSD: menu_post.3,v 1.10 2009/10/24 11:17:13 reed Exp $ .\ .\ Copyright (c) 1999 .\ Brett Lymn - bl...@baea.com.au, brett_l...@yahoo.com.au @@ -33,7 +33,7 @@ .Dt MENU_POST 3 .Os .Sh NAME -.Nm post_menu +.Nm post_menu , .Nm unpost_menu .Nd post (draw) or unpost a menu .Sh LIBRARY