Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libmenu * Fixed menu command constants so they no longer...



details:   https://anonhg.NetBSD.org/src/rev/53a9741b0bc9
branches:  trunk
changeset: 521735:53a9741b0bc9
user:      blymn <blymn%NetBSD.org@localhost>
date:      Mon Feb 04 13:02:05 2002 +0000

description:
* Fixed menu command constants so they no longer clash with
  curses key symbols
* Fixed behaviour of the menu window handling.  The library no longer
  creates the subwindow or window which is correct behaviour as documented
  in the ETI library documentation.

diffstat:

 lib/libmenu/internals.c   |  42 +++++++++++++++++++++---------------------
 lib/libmenu/menu.c        |  33 ++++++++++++++++++++++++---------
 lib/libmenu/menu.h        |  45 +++++++++++++++++++++++----------------------
 lib/libmenu/post.c        |  31 ++++---------------------------
 lib/libmenu/shlib_version |   4 ++--
 5 files changed, 74 insertions(+), 81 deletions(-)

diffs (truncated from 362 to 300 lines):

diff -r 72400cc35719 -r 53a9741b0bc9 lib/libmenu/internals.c
--- a/lib/libmenu/internals.c   Mon Feb 04 12:00:52 2002 +0000
+++ b/lib/libmenu/internals.c   Mon Feb 04 13:02:05 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: internals.c,v 1.8 2001/06/13 10:45:59 wiz Exp $        */
+/*     $NetBSD: internals.c,v 1.9 2002/02/04 13:02:05 blymn Exp $      */
 
 /*-
  * Copyright (c) 1998-1999 Brett Lymn (blymn%baea.com.au@localhost, brett_lymn%yahoo.com.au@localhost)
@@ -384,14 +384,14 @@
        
        mark_len = max(menu->mark.length, menu->unmark.length);
        
-       wmove(menu->menu_subwin,
+       wmove(menu->scrwin,
              menu->items[item]->row - menu->top_row,
              menu->items[item]->col * menu->col_width);
 
        if ((menu->cur_item == item) || (menu->items[item]->selected == 1))
-               wattrset(menu->menu_subwin, menu->fore);
+               wattrset(menu->scrwin, menu->fore);
        if ((menu->items[item]->opts & O_SELECTABLE) != O_SELECTABLE)
-               wattron(menu->menu_subwin, menu->grey);
+               wattron(menu->scrwin, menu->grey);
 
          /* deal with the menu mark, if  one is set.
           * We mark the selected items and write blanks for
@@ -401,28 +401,28 @@
        if (menu->items[item]->selected == 1) {
                if (menu->mark.string != NULL) {
                        for (j = 0; j < menu->mark.length; j++) {
-                               waddch(menu->menu_subwin,
+                               waddch(menu->scrwin,
                                       menu->mark.string[j]);
                        }
                }
                  /* blank any length difference between mark & unmark */
                for (j = menu->mark.length; j < mark_len; j++)
-                       waddch(menu->menu_subwin, ' ');
+                       waddch(menu->scrwin, ' ');
        } else {
                if (menu->unmark.string != NULL) {
                        for (j = 0; j < menu->unmark.length; j++) {
-                               waddch(menu->menu_subwin,
+                               waddch(menu->scrwin,
                                       menu->unmark.string[j]);
                        }
                }
                  /* blank any length difference between mark & unmark */
                for (j = menu->unmark.length; j < mark_len; j++)
-                       waddch(menu->menu_subwin, ' ');
+                       waddch(menu->scrwin, ' ');
        }
        
          /* add the menu name */
        for (j=0; j < menu->items[item]->name.length; j++)
-               waddch(menu->menu_subwin,
+               waddch(menu->scrwin,
                       menu->items[item]->name.string[j]);
        
        pad_len = menu->col_width - menu->items[item]->name.length
@@ -430,14 +430,14 @@
        if ((menu->opts & O_SHOWDESC) == O_SHOWDESC) {
                pad_len -= menu->items[item]->description.length - 1;
                for (j = 0; j < pad_len; j++)
-                       waddch(menu->menu_subwin, menu->pad);
+                       waddch(menu->scrwin, menu->pad);
                for (j = 0; j < menu->items[item]->description.length; j++) {
-                       waddch(menu->menu_subwin,
+                       waddch(menu->scrwin,
                               menu->items[item]->description.string[j]);
                }
        } else {
                for (j = 0; j < pad_len; j++)
-                       waddch(menu->menu_subwin, ' ');
+                       waddch(menu->scrwin, ' ');
        }
        menu->items[item]->visible = 1;
        
@@ -447,14 +447,14 @@
           * have the same attributes as the items.
           */
        if (menu->items[item]->col > 0) {
-               wmove(menu->menu_subwin,
+               wmove(menu->scrwin,
                      menu->items[item]->row - menu->top_row,
                      menu->items[item]->col * menu->col_width - 1);
-               waddch(menu->menu_subwin, ' ');
+               waddch(menu->scrwin, ' ');
        }
        
          /* kill any special attributes... */
-       wattrset(menu->menu_subwin, menu->back);
+       wattrset(menu->scrwin, menu->back);
 
          /* and position the cursor nicely */
        pos_menu_cursor(menu);
@@ -476,9 +476,9 @@
                menu->items[i]->visible = 0;
        }
 
-       wmove(menu->menu_subwin, 0, 0);
+       wmove(menu->scrwin, 0, 0);
 
-       menu->col_width = getmaxx(menu->menu_subwin) / menu->cols;
+       menu->col_width = getmaxx(menu->scrwin) / menu->cols;
 
        max_items = menu->rows * menu->cols;
        last_item = ((max_items + i) > menu->item_count) ? menu->item_count :
@@ -487,7 +487,7 @@
        for (; i < last_item; i++) {
                if (i > menu->item_count) {
                          /* no more items to draw, write background blanks */
-                       wattrset(menu->menu_subwin, menu->back);
+                       wattrset(menu->scrwin, menu->back);
                        if (row < 0) {
                                row = menu->items[menu->item_count - 1]->row;
                                col = menu->items[menu->item_count - 1]->col;
@@ -506,10 +506,10 @@
                                        col++;
                                }
                        }
-                       wmove(menu->menu_subwin, row,
+                       wmove(menu->scrwin, row,
                              col * menu->col_width);
                        for (j = 0; j < menu->col_width; j++)
-                               waddch(menu->menu_subwin, ' ');
+                               waddch(menu->scrwin, ' ');
                } else {
                        _menui_draw_item(menu, i);
                        
@@ -563,7 +563,7 @@
                   * XXXX we could scroll the window and just fill in the
                   * XXXX changed lines.
                   */
-               wclear(menu->menu_subwin);
+               wclear(menu->scrwin);
                _menui_draw_menu(menu);
        } else {
                if (menu->cur_item != old_cur_item) {
diff -r 72400cc35719 -r 53a9741b0bc9 lib/libmenu/menu.c
--- a/lib/libmenu/menu.c        Mon Feb 04 12:00:52 2002 +0000
+++ b/lib/libmenu/menu.c        Mon Feb 04 13:02:05 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: menu.c,v 1.10 2001/06/13 10:45:59 wiz Exp $    */
+/*     $NetBSD: menu.c,v 1.11 2002/02/04 13:02:05 blymn Exp $  */
 
 /*-
  * Copyright (c) 1998-1999 Brett Lymn (blymn%baea.com.au@localhost, brett_lymn%yahoo.com.au@localhost)
@@ -64,7 +64,7 @@
         NULL,       /* function called when current item changes */
         NULL,       /* the menu window */
        NULL,       /* the menu subwindow */
-       0           /* subwindow was created by library call */
+       NULL,       /* the window to write to */
 };
 
 
@@ -147,10 +147,18 @@
 int
 set_menu_win(MENU *menu, WINDOW *win)
 {
-       if (menu == NULL)
+       if (menu == NULL) {
                _menui_default_menu.menu_win = win;
-       else
-               menu->menu_win = win;
+               _menui_default_menu.scrwin = win;
+       } else {
+               if (menu->posted == TRUE) {
+                       return E_POSTED;
+               } else {
+                       menu->menu_win = win;
+                       menu->scrwin = win;
+               }
+       }
+       
         return E_OK;
 }
 
@@ -174,10 +182,17 @@
         MENU *menu;
         WINDOW *sub;
 {
-       if (menu == NULL)
+       if (menu == NULL) {
                _menui_default_menu.menu_subwin = sub;
-       else
+               _menui_default_menu.scrwin = sub;
+       } else {
+               if (menu->posted == TRUE)
+                       return E_POSTED;
+               
                menu->menu_subwin = sub;
+               menu->scrwin = sub;
+       }
+       
         return E_OK;
 }
 
@@ -394,7 +409,7 @@
 
          /* set a default window if none already set. */
        if (the_menu->menu_win == NULL)
-               the_menu->menu_win = stdscr;
+               the_menu->scrwin = stdscr;
        
           /* now attach the items, if any */
         if (items != NULL) {
@@ -628,7 +643,7 @@
        if (menu->match_len > 0)
                movx += menu->match_len - 1;
        
-       wmove(menu->menu_subwin,
+       wmove(menu->scrwin,
              menu->items[menu->cur_item]->row - menu->top_row, movx);
 
        return E_OK;
diff -r 72400cc35719 -r 53a9741b0bc9 lib/libmenu/menu.h
--- a/lib/libmenu/menu.h        Mon Feb 04 12:00:52 2002 +0000
+++ b/lib/libmenu/menu.h        Mon Feb 04 13:02:05 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: menu.h,v 1.10 2001/06/13 10:45:59 wiz Exp $    */
+/*     $NetBSD: menu.h,v 1.11 2002/02/04 13:02:06 blymn Exp $  */
 
 /*-
  * Copyright (c) 1998-1999 Brett Lymn (blymn%baea.com.au@localhost, brett_lymn%yahoo.com.au@localhost)
@@ -33,27 +33,28 @@
 #include <eti.h>
 
 /* requests for the menu_driver call */
-#define REQ_BASE_NUM      (0x100)
-#define REQ_LEFT_ITEM     (0x101)
-#define REQ_RIGHT_ITEM    (0x102)
-#define REQ_UP_ITEM       (0x103)
-#define REQ_DOWN_ITEM     (0x104)
-#define REQ_SCR_ULINE     (0x105)
-#define REQ_SCR_DLINE     (0x106)
-#define REQ_SCR_DPAGE     (0x107)
-#define REQ_SCR_UPAGE     (0x108)
-#define REQ_FIRST_ITEM    (0x109)
-#define REQ_LAST_ITEM     (0x10a)
-#define REQ_NEXT_ITEM     (0x10b)
-#define REQ_PREV_ITEM     (0x10c)
-#define REQ_TOGGLE_ITEM   (0x10d)
-#define REQ_CLEAR_PATTERN (0x10e)
-#define REQ_BACK_PATTERN  (0x10f)
-#define REQ_NEXT_MATCH    (0x110)
-#define REQ_PREV_MATCH    (0x111)
+#define REQ_BASE_NUM      (KEY_MAX + 0x100)
+#define REQ_LEFT_ITEM     (KEY_MAX + 0x101)
+#define REQ_RIGHT_ITEM    (KEY_MAX + 0x102)
+#define REQ_UP_ITEM       (KEY_MAX + 0x103)
+#define REQ_DOWN_ITEM     (KEY_MAX + 0x104)
+#define REQ_SCR_ULINE     (KEY_MAX + 0x105)
+#define REQ_SCR_DLINE     (KEY_MAX + 0x106)
+#define REQ_SCR_DPAGE     (KEY_MAX + 0x107)
+#define REQ_SCR_UPAGE     (KEY_MAX + 0x108)
+#define REQ_FIRST_ITEM    (KEY_MAX + 0x109)
+#define REQ_LAST_ITEM     (KEY_MAX + 0x10a)
+#define REQ_NEXT_ITEM     (KEY_MAX + 0x10b)
+#define REQ_PREV_ITEM     (KEY_MAX + 0x10c)
+#define REQ_TOGGLE_ITEM   (KEY_MAX + 0x10d)
+#define REQ_CLEAR_PATTERN (KEY_MAX + 0x10e)
+#define REQ_BACK_PATTERN  (KEY_MAX + 0x10f)
+#define REQ_NEXT_MATCH    (KEY_MAX + 0x110)
+#define REQ_PREV_MATCH    (KEY_MAX + 0x111)
 
-#define MAX_COMMAND       (0x111) /* last menu driver request - for application
-                                    defined commands */
+#define MAX_COMMAND       (KEY_MAX + 0x111) /* last menu driver request
+                                              - for application defined
+                                              commands */
 
 /* Menu options */
 typedef unsigned int OPTIONS;
@@ -131,7 +132,7 @@
                                       before current item changes */
         WINDOW *menu_win; /* the menu window */
         WINDOW *menu_subwin; /* the menu subwindow */
-       int we_created;
+       WINDOW *scrwin; /* the window to write to */
 };
 
 
diff -r 72400cc35719 -r 53a9741b0bc9 lib/libmenu/post.c
--- a/lib/libmenu/post.c        Mon Feb 04 12:00:52 2002 +0000
+++ b/lib/libmenu/post.c        Mon Feb 04 13:02:05 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: post.c,v 1.8 2001/06/13 10:45:59 wiz Exp $     */
+/*     $NetBSD: post.c,v 1.9 2002/02/04 13:02:06 blymn Exp $   */
 
 /*-
  * Copyright (c) 1998-1999 Brett Lymn (blymn%baea.com.au@localhost, brett_lymn%yahoo.com.au@localhost)
@@ -49,8 +49,6 @@
                return E_NOT_CONNECTED;
        if (*menu->items == NULL)
                return E_NOT_CONNECTED;
-       if (menu->menu_win == NULL)
-               return E_BAD_ARGUMENT;



Home | Main Index | Thread Index | Old Index