Subject: lib/17680: libmenu, no menu_mark displayed for when menu opt O_ONEVALUE
To: None <gnats-bugs@gnats.netbsd.org>
From: None <rtr@wasabisystems.com>
List: netbsd-bugs
Date: 07/23/2002 13:58:33
>Number:         17680
>Category:       lib
>Synopsis:       libmenu, can't toggle mark on opt O_ONEVALUE menu.
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    lib-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Jul 22 10:54:01 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     Tyler Retzlaff
>Release:        NetBSD 1.6D
>Organization:
	Wasabi Systems
>Environment:
System: NetBSD elysium 1.6D NetBSD 1.6D (elysium) #0: Mon Jul 15 06:43:10 EST 2002 rtr@elysium:/usr/src/sys/arch/i386/compile/elysium i386
Architecture: i386
Machine: i386
>Description:
	As per blymn's comments on icb libmenu should be able to provide 
	web page radio-list like behavior.  This is characterized by a set of
	items where only one can be marked as 'selected'.  libmenu was unable
	to do this because it returned E_REQUEST_DENIED if REQ_TOGGLE_ITEM
	was used on O_ONEVALUE opt menu.

	This fix enables the REQ_TOGGLE_ITEM for menu items in menus where
	the O_ONEVALUE option is set.  For O_ONEVALUE menus it deselects any
	other selected item and selects the current_item.

	This matches the behavior described for REQ_TOGGLE_ITEM in
	menu_driver(3).

	As for finding out which item is actually selected after it is no
	longer the current_item, I'm not sure how.

>How-To-Repeat:
	use libmenu, with a menu that has menu mark set and a O_ONEVALUE opt.
>Fix:

*** ../driver.c Mon Jul 15 06:15:27 2002
--- driver.c    Tue Jul 23 13:49:47 2002
***************
*** 40,50 ****
   * request and is not printable then it assumed to be a user defined command.
   */
  int
  menu_driver(MENU *menu, int c)
  {
!       int drv_top_row, drv_scroll, it, status = E_OK;
        ITEM *drv_new_item;
        
        if (menu == NULL)
                return E_BAD_ARGUMENT;
        if (menu->posted == 0)
--- 40,50 ----
   * request and is not printable then it assumed to be a user defined command.
   */
  int
  menu_driver(MENU *menu, int c)
  {
!       int drv_top_row, drv_scroll, it, i, status = E_OK;
        ITEM *drv_new_item;
        
        if (menu == NULL)
                return E_BAD_ARGUMENT;
        if (menu->posted == 0)
***************
*** 166,176 ****
--- 166,191 ----
                                          menu->items[menu->cur_item - 1];
                          }
                          break;
                  case REQ_TOGGLE_ITEM:
                          if ((menu->opts & O_ONEVALUE) == O_ONEVALUE) {
+                               if ((drv_new_item->opts
+                                       & O_SELECTABLE) == O_SELECTABLE) {
+ 
+                                       for (i = 0; i < menu->item_count; i++) {
+                                               if (menu->items[i]->selected) {
+                                                  menu->items[i]->selected = 0;
+                                                       _menui_draw_item(menu,
+                                                       menu->items[i]->index);
+                                               }
+                                       }
+                                       drv_new_item->selected ^= 1;
+                                       _menui_draw_item(menu,
+                                                       drv_new_item->index);
+                               } else {
                                  return E_REQUEST_DENIED;
+                               }
                          } else {
                                  if ((drv_new_item->opts
                                       & O_SELECTABLE) == O_SELECTABLE) {
                                            /* toggle select flag */
                                          drv_new_item->selected ^= 1;

>Release-Note:
>Audit-Trail:
>Unformatted: