Module Name: src Committed By: martin Date: Mon Feb 25 20:47:37 UTC 2019
Modified Files: src/usr.bin/menuc: mdb.c mdb.h menu_sys.def menuc.1 parse.y scan.l src/usr.bin/menuc/testm: menus.mc Log Message: Add an option to supress the vertical space between menu title and menu items. To generate a diff of this commit: cvs rdiff -u -r1.50 -r1.51 src/usr.bin/menuc/mdb.c cvs rdiff -u -r1.10 -r1.11 src/usr.bin/menuc/mdb.h cvs rdiff -u -r1.66 -r1.67 src/usr.bin/menuc/menu_sys.def cvs rdiff -u -r1.36 -r1.37 src/usr.bin/menuc/menuc.1 cvs rdiff -u -r1.17 -r1.18 src/usr.bin/menuc/parse.y src/usr.bin/menuc/scan.l cvs rdiff -u -r1.11 -r1.12 src/usr.bin/menuc/testm/menus.mc Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.bin/menuc/mdb.c diff -u src/usr.bin/menuc/mdb.c:1.50 src/usr.bin/menuc/mdb.c:1.51 --- src/usr.bin/menuc/mdb.c:1.50 Wed Feb 6 20:08:15 2019 +++ src/usr.bin/menuc/mdb.c Mon Feb 25 20:47:37 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: mdb.c,v 1.50 2019/02/06 20:08:15 martin Exp $ */ +/* $NetBSD: mdb.c,v 1.51 2019/02/25 20:47:37 martin Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -41,7 +41,7 @@ #include <sys/cdefs.h> #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: mdb.c,v 1.50 2019/02/06 20:08:15 martin Exp $"); +__RCSID("$NetBSD: mdb.c,v 1.51 2019/02/25 20:47:37 martin Exp $"); #endif @@ -225,6 +225,7 @@ write_menu_file(char *initcode) MC_OPT(MC_DFLTEXIT) MC_OPT(MC_ALWAYS_SCROLL) MC_OPT(MC_SUBMENU) + MC_OPT(MC_CONTINUOUS) MC_OPT(MC_VALID) #undef MC_OPT #undef STR Index: src/usr.bin/menuc/mdb.h diff -u src/usr.bin/menuc/mdb.h:1.10 src/usr.bin/menuc/mdb.h:1.11 --- src/usr.bin/menuc/mdb.h:1.10 Wed Nov 21 20:04:48 2018 +++ src/usr.bin/menuc/mdb.h Mon Feb 25 20:47:37 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: mdb.h,v 1.10 2018/11/21 20:04:48 martin Exp $ */ +/* $NetBSD: mdb.h,v 1.11 2019/02/25 20:47:37 martin Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -95,5 +95,6 @@ struct menu_info { #define MC_DFLTEXIT 32 #define MC_ALWAYS_SCROLL 64 #define MC_SUBMENU 128 +#define MC_CONTINUOUS 256 #define MC_VALID 0x10000 #endif Index: src/usr.bin/menuc/menu_sys.def diff -u src/usr.bin/menuc/menu_sys.def:1.66 src/usr.bin/menuc/menu_sys.def:1.67 --- src/usr.bin/menuc/menu_sys.def:1.66 Sat Feb 16 18:57:21 2019 +++ src/usr.bin/menuc/menu_sys.def Mon Feb 25 20:47:37 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: menu_sys.def,v 1.66 2019/02/16 18:57:21 martin Exp $ */ +/* $NetBSD: menu_sys.def,v 1.67 2019/02/25 20:47:37 martin Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -141,7 +141,8 @@ init_menu(menudesc *m) y = m->y; w = m->w; wmax = 0; - hadd = ((m->mopt & MC_NOBOX) ? 0 : 2); + hadd = ((m->mopt & MC_NOBOX) ? 0 : + ((m->mopt & MC_CONTINUOUS) ? 1 : 2)); wadd = ((m->mopt & MC_NOBOX) ? 2 : 4); if (!(m->mopt & MC_NOSHORTCUT)) wadd += 3; @@ -358,7 +359,8 @@ draw_menu(menudesc *m, void *arg) if (ep == NULL || *ep == 0) break; } - tadd++; + if ((m->mopt & MC_CONTINUOUS) == 0) + tadd++; } cury = tadd; Index: src/usr.bin/menuc/menuc.1 diff -u src/usr.bin/menuc/menuc.1:1.36 src/usr.bin/menuc/menuc.1:1.37 --- src/usr.bin/menuc/menuc.1:1.36 Sat Feb 16 19:09:07 2019 +++ src/usr.bin/menuc/menuc.1 Mon Feb 25 20:47:37 2019 @@ -1,4 +1,4 @@ -.\" $NetBSD: menuc.1,v 1.36 2019/02/16 19:09:07 martin Exp $ +.\" $NetBSD: menuc.1,v 1.37 2019/02/25 20:47:37 martin Exp $ .\" .\" Copyright 1997 Piermont Information Systems Inc. .\" All rights reserved. @@ -29,7 +29,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF .\" THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd February 16, 2019 +.Dd February 25, 2019 .Dt MENUC 1 .Os .Sh NAME @@ -233,6 +233,9 @@ menu window is created. .It Ic sub menu If specified, the screen contents that the menu window overwrites are saved and restored when the menu exits. +.It Ic continuous title +If specified there is no vertical space between the title and the menu +content. .El .Pp The @@ -458,6 +461,7 @@ struct menudesc { #define MC_DFLTEXIT 32 #define MC_ALWAYS_SCROLL 64 #define MC_SUBMENU 128 +#define MC_CONTINUOUS 256 int new_menu(const char *title, menu_ent *opts, int numopts, int x, int y, int h, int w, int mopt, Index: src/usr.bin/menuc/parse.y diff -u src/usr.bin/menuc/parse.y:1.17 src/usr.bin/menuc/parse.y:1.18 --- src/usr.bin/menuc/parse.y:1.17 Wed Nov 21 20:04:48 2018 +++ src/usr.bin/menuc/parse.y Mon Feb 25 20:47:37 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: parse.y,v 1.17 2018/11/21 20:04:48 martin Exp $ */ +/* $NetBSD: parse.y,v 1.18 2019/02/25 20:47:37 martin Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -54,6 +54,7 @@ static optn_info *cur_optn; %token <i_value> X Y W H NO BOX SUB HELP MENU NEXT EXIT ACTION ENDWIN OPTION %token <i_value> TITLE DEFAULT DISPLAY ERROR EXITSTRING EXPAND ALLOW DYNAMIC MENUS SCROLLABLE SHORTCUT CLEAR MESSAGES ALWAYS SCROLL + CONTINUOUS %token <s_value> STRING NAME CODE INT_CONST CHAR_CONST %type <s_value> init_code system helpstr text @@ -150,6 +151,7 @@ opt : NO EXIT { cur_menu->info->mopt | ALWAYS SCROLL { cur_menu->info->mopt |= MC_ALWAYS_SCROLL; } | NO SUB MENU { cur_menu->info->mopt &= ~MC_SUBMENU; } | SUB MENU { cur_menu->info->mopt |= MC_SUBMENU; } + | CONTINUOUS TITLE { cur_menu->info->mopt |= MC_CONTINUOUS; } | X "=" INT_CONST { cur_menu->info->x = atoi($3); } | Y "=" INT_CONST { cur_menu->info->y = atoi($3); } | W "=" INT_CONST { cur_menu->info->w = atoi($3); } Index: src/usr.bin/menuc/scan.l diff -u src/usr.bin/menuc/scan.l:1.17 src/usr.bin/menuc/scan.l:1.18 --- src/usr.bin/menuc/scan.l:1.17 Wed Nov 21 20:04:48 2018 +++ src/usr.bin/menuc/scan.l Mon Feb 25 20:47:37 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: scan.l,v 1.17 2018/11/21 20:04:48 martin Exp $ */ +/* $NetBSD: scan.l,v 1.18 2019/02/25 20:47:37 martin Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -70,6 +70,8 @@ no { return NO; } box { return BOX; } +continuous { return CONTINUOUS; } + sub { return SUB; } help { return HELP; } Index: src/usr.bin/menuc/testm/menus.mc diff -u src/usr.bin/menuc/testm/menus.mc:1.11 src/usr.bin/menuc/testm/menus.mc:1.12 --- src/usr.bin/menuc/testm/menus.mc:1.11 Fri Sep 17 18:16:31 2004 +++ src/usr.bin/menuc/testm/menus.mc Mon Feb 25 20:47:37 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: menus.mc,v 1.11 2004/09/17 18:16:31 wrstuden Exp $ */ +/* $NetBSD: menus.mc,v 1.12 2019/02/25 20:47:37 martin Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -83,6 +83,9 @@ menu root, title " Main Menu of Test Sy option "A dynamic menu ...", action { do_dynamic (); } ; + option "Continuous title and menu ...", + sub menu contdemo + ; option "Run a shell...", action (endwin) { system ("/bin/sh"); } ; @@ -275,3 +278,16 @@ menu scrollit2, scrollable, title " Big option "option 49", action {}; option "option 50", action {}; option "option 51", action {}; + +menu contdemo, title "Menus without space between title and menu", y=3, x=10; + option "With box", sub menu contdemo_box; + option "No box", sub menu contdemo_none; + +menu contdemo_box, title "title text ends here-->", y=3, x=10, no exit, + continuous title; + option "<--- first menu item here", exit; + +menu contdemo_none, title "title text ends here-->", y=3, x=10, no box, no exit, + continuous title; + option "<--- first menu item here", exit; +