Tweek the "no shortcut" code.
MC_NOSHORTKEY to NOSHORTCUT added option "shortcut" to menuc input language. added example of this kind of menu in testm.
This commit is contained in:
parent
caa284ac57
commit
94c7405838
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: mdb.c,v 1.16 2000/08/15 01:01:41 hubertf Exp $ */
|
||||
/* $NetBSD: mdb.c,v 1.17 2000/08/15 02:09:11 phil Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright 1997 Piermont Information Systems Inc.
|
||||
|
@ -161,7 +161,7 @@ write_menu_file (char *initcode)
|
|||
(void) fprintf (out_file, "#define DYNAMIC_MENUS\n\n");
|
||||
|
||||
(void) fprintf (out_file,
|
||||
"struct menudesc;\n"
|
||||
"struct menudesc;\n"
|
||||
"typedef\n"
|
||||
"struct menu_ent {\n"
|
||||
" char *opt_name;\n"
|
||||
|
@ -194,12 +194,10 @@ write_menu_file (char *initcode)
|
|||
"#define MC_NOEXITOPT 1\n"
|
||||
"#define MC_NOBOX 2\n"
|
||||
"#define MC_SCROLL 4\n"
|
||||
"#define MC_NOSHORTCUT 16 /* don't display letter shortcuts */\n"
|
||||
"#define MC_NOSHORTCUT 8\n"
|
||||
"#define MC_VALID 256\n"
|
||||
);
|
||||
|
||||
if (do_dynamic)
|
||||
(void) fprintf (out_file, "#define MC_VALID 8\n");
|
||||
|
||||
(void) fprintf (out_file, "%s",
|
||||
"\n"
|
||||
"/* initilization flag */\n"
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: mdb.h,v 1.4 1999/06/20 02:07:18 cgd Exp $ */
|
||||
/* $NetBSD: mdb.h,v 1.5 2000/08/15 02:09:11 phil Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright 1997 Piermont Information Systems Inc.
|
||||
|
@ -91,5 +91,6 @@ struct menu_info {
|
|||
#define NOEXITOPT 1
|
||||
#define NOBOX 2
|
||||
#define SCROLL 4
|
||||
#define NOSHORTCUT 8
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: menu_sys.def,v 1.23 2000/08/15 01:01:41 hubertf Exp $ */
|
||||
/* $NetBSD: menu_sys.def,v 1.24 2000/08/15 02:09:11 phil Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright 1997 Piermont Information Systems Inc.
|
||||
|
@ -372,9 +372,9 @@ post_menu (struct menudesc *m)
|
|||
selrow = cury;
|
||||
} else
|
||||
mvwaddstr (m->mw, cury, hasbox, " ");
|
||||
if (! (m->mopt & MC_NOSHORTCUT)) {
|
||||
if (!(m->mopt & MC_NOSHORTCUT)) {
|
||||
(void) sprintf (optstr, "%c: ", opt_ch(i));
|
||||
waddstr (m->mw, optstr);
|
||||
waddstr (m->mw, optstr);
|
||||
}
|
||||
waddstr (m->mw, m->opts[i].opt_name);
|
||||
if (m->cursel == i)
|
||||
|
@ -389,7 +389,7 @@ post_menu (struct menudesc *m)
|
|||
selrow = cury;
|
||||
} else
|
||||
mvwaddstr (m->mw, cury, hasbox, " ");
|
||||
if (! (m->mopt & MC_NOSHORTCUT))
|
||||
if (!(m->mopt & MC_NOSHORTCUT))
|
||||
waddstr (m->mw, "x: ");
|
||||
waddstr (m->mw, m->exitstr);
|
||||
if (m->cursel >= m->numopts)
|
||||
|
@ -565,13 +565,13 @@ process_req (struct menudesc *m, int num, int req)
|
|||
m->cursel = m->numopts;
|
||||
scroll_sel = 1;
|
||||
refresh = 1;
|
||||
} else {
|
||||
if (! (m->mopt & MC_NOSHORTCUT)) {
|
||||
} else
|
||||
if (!(m->mopt & MC_NOSHORTCUT)) {
|
||||
if (ch > 'z')
|
||||
ch = 255;
|
||||
if (ch >= 'a') {
|
||||
if (ch > 'x') ch--;
|
||||
ch = ch - 'a';
|
||||
ch = ch - 'a';
|
||||
} else
|
||||
ch = 25 + ch - 'A';
|
||||
if (ch < 0 || ch >= m->numopts)
|
||||
|
@ -581,8 +581,8 @@ process_req (struct menudesc *m, int num, int req)
|
|||
scroll_sel = 1;
|
||||
refresh = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else
|
||||
mbeep();
|
||||
}
|
||||
|
||||
if (m->mopt & MC_SCROLL && scroll_sel) {
|
||||
|
@ -727,7 +727,7 @@ process_menu (int num)
|
|||
/* local prototypes */
|
||||
static int double_menus (void);
|
||||
|
||||
static int
|
||||
static int
|
||||
double_menus (void)
|
||||
{
|
||||
menudesc *temp;
|
||||
|
@ -749,8 +749,8 @@ double_menus (void)
|
|||
|
||||
int
|
||||
new_menu (char * title, menu_ent * opts, int numopts,
|
||||
int x, int y, int h, int w, int mopt,
|
||||
void (*post_act)(void), void (*exit_act), char * help)
|
||||
int x, int y, int h, int w, int mopt,
|
||||
void (*post_act)(void), void (*exit_act), char * help)
|
||||
{
|
||||
int ix;
|
||||
|
||||
|
@ -766,7 +766,7 @@ new_menu (char * title, menu_ent * opts, int numopts,
|
|||
/* if ix == num_menus ... panic */
|
||||
|
||||
/* Set Entries */
|
||||
menus[ix].title = title?title:"";
|
||||
menus[ix].title = title ? title : "";
|
||||
menus[ix].opts = opts;
|
||||
menus[ix].numopts = numopts;
|
||||
menus[ix].x = x;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: parse.y,v 1.8 1999/07/26 06:19:01 christos Exp $ */
|
||||
/* $NetBSD: parse.y,v 1.9 2000/08/15 02:09:11 phil Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright 1997 Piermont Information Systems Inc.
|
||||
|
@ -57,7 +57,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 ALLOW DYNAMIC MENUS
|
||||
SCROLLABLE
|
||||
SCROLLABLE SHORTCUT
|
||||
%token <s_value> STRING NAME CODE INT_CONST CHAR_CONST
|
||||
|
||||
%type <s_value> init_code system helpstr
|
||||
|
@ -134,6 +134,8 @@ opt : NO EXIT { cur_menu->info->mopt |= NOEXITOPT; }
|
|||
| BOX { cur_menu->info->mopt &= ~NOBOX; }
|
||||
| NO SCROLLABLE { cur_menu->info->mopt &= ~SCROLL; }
|
||||
| SCROLLABLE { cur_menu->info->mopt |= SCROLL; }
|
||||
| NO SHORTCUT { cur_menu->info->mopt |= NOSHORTCUT; }
|
||||
| SHORTCUT { cur_menu->info->mopt &= ~NOSHORTCUT; }
|
||||
| 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); }
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: scan.l,v 1.8 1999/06/20 02:07:18 cgd Exp $ */
|
||||
/* $NetBSD: scan.l,v 1.9 2000/08/15 02:09:11 phil Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright 1997 Piermont Information Systems Inc.
|
||||
|
@ -106,6 +106,8 @@ dynamic { return DYNAMIC; }
|
|||
|
||||
scrollable { return SCROLLABLE; }
|
||||
|
||||
shortcut { return SHORTCUT; }
|
||||
|
||||
\"([^\"\n]*(\\\")?)*\" {
|
||||
yylval.s_value = strdup (yytext);
|
||||
max_strlen = max_strlen > strlen(yytext)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: main.c,v 1.3 1998/07/23 17:56:00 phil Exp $ */
|
||||
/* $NetBSD: main.c,v 1.4 2000/08/15 02:09:12 phil Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright 1997 Piermont Information Systems Inc.
|
||||
|
@ -58,9 +58,9 @@ char ent_text[5][50] = {"name: ", "strt: ", "city: ", "opt 4", "NUM: "};
|
|||
|
||||
/* opt processing routines .. */
|
||||
|
||||
int opt_1 (void);
|
||||
int opt_1 (struct menudesc *m);
|
||||
|
||||
int opt_1 (void)
|
||||
int opt_1 (struct menudesc *m)
|
||||
{
|
||||
msg_clear();
|
||||
msg_prompt (MSG_name, "", &ent_text[0][6], 40);
|
||||
|
@ -68,9 +68,9 @@ int opt_1 (void)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int opt_2 (void);
|
||||
int opt_2 (struct menudesc *m);
|
||||
|
||||
int opt_2 (void)
|
||||
int opt_2 (struct menudesc *m)
|
||||
{
|
||||
msg_clear();
|
||||
msg_prompt (MSG_street, "", &ent_text[1][6], 40);
|
||||
|
@ -78,9 +78,9 @@ int opt_2 (void)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int opt_3 (void);
|
||||
int opt_3 (struct menudesc *m);
|
||||
|
||||
int opt_3 (void)
|
||||
int opt_3 (struct menudesc *m)
|
||||
{
|
||||
msg_clear();
|
||||
msg_prompt (MSG_city, "", &ent_text[2][6], 40);
|
||||
|
@ -101,7 +101,6 @@ int num = 0;
|
|||
|
||||
void do_dynamic(void);
|
||||
void dyn_disp (void);
|
||||
|
||||
void dyn_disp (void)
|
||||
{
|
||||
sprintf (&ent_text[4][5], "%d", num++);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: menus.mc,v 1.9 1998/07/16 07:08:26 phil Exp $ */
|
||||
/* $NetBSD: menus.mc,v 1.10 2000/08/15 02:09:12 phil Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright 1997 Piermont Information Systems Inc.
|
||||
|
@ -75,8 +75,11 @@ menu root, title " Main Menu of Test System", x=10;
|
|||
sub menu scrollit2
|
||||
;
|
||||
option "Big non-scrollable menu, bombs on small screens",
|
||||
sub menu bigscroll
|
||||
sub menu bigscroll
|
||||
;
|
||||
option "A menu with no shortcuts",
|
||||
sub menu noshort
|
||||
;
|
||||
option "A dynamic menu ...",
|
||||
action { do_dynamic (); }
|
||||
;
|
||||
|
@ -185,6 +188,11 @@ menu middle, no box;
|
|||
menu nextmenu, title " A next window! ? for comments", no exit;
|
||||
option "Just Exit!:", exit;
|
||||
|
||||
menu noshort, title " No shortcut characters!", no shortcut;
|
||||
option "first", action {};
|
||||
option "second", action {};
|
||||
option "third", action {};
|
||||
|
||||
menu scrollit, scrollable, h=4, title " Scrollable Menu";
|
||||
option "option 1", action {};
|
||||
option "option 2", action {};
|
||||
|
|
Loading…
Reference in New Issue