Bug fixes, tweeks to scrolling, beginnings of dynamic menus.
This commit is contained in:
parent
d663cd1216
commit
5aa748c608
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: defs.h,v 1.2 1997/11/09 20:59:11 phil Exp $ */
|
||||
/* $NetBSD: defs.h,v 1.3 1998/07/01 07:46:02 phil Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright 1997 Piermont Information Systems Inc.
|
||||
@ -61,6 +61,7 @@ EXTERN char *src_name;
|
||||
EXTERN char *out_name INIT("menu_defs");
|
||||
EXTERN char *sys_name INIT("menu_sys.def");
|
||||
|
||||
EXTERN int do_dynamic INIT(0);
|
||||
EXTERN int line_no INIT(1);
|
||||
EXTERN int had_errors INIT(FALSE);
|
||||
EXTERN int max_strlen INIT(1);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: mdb.c,v 1.8 1998/06/29 08:46:37 phil Exp $ */
|
||||
/* $NetBSD: mdb.c,v 1.9 1998/07/01 07:46:02 phil Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright 1997 Piermont Information Systems Inc.
|
||||
@ -151,7 +151,20 @@ write_menu_file (char *initcode)
|
||||
"#include <string.h>\n"
|
||||
"#include <ctype.h>\n"
|
||||
"#include <curses.h>\n"
|
||||
"\n"
|
||||
"\n");
|
||||
|
||||
if (do_dynamic)
|
||||
(void) fprintf (out_file,
|
||||
"\n#define DYNAMIC_MENUS\n\n"
|
||||
"typedef\n"
|
||||
"struct dyn_menu_ent {\n"
|
||||
" char *optname;\n"
|
||||
" int nextmenu;\n"
|
||||
" int submenu;\n"
|
||||
" void (*action)(void);\n"
|
||||
"} dyn_menu_ent ;\n");
|
||||
|
||||
(void) fprintf (out_file, "%s",
|
||||
"typedef\n"
|
||||
"struct menudesc {\n"
|
||||
" char *title;\n"
|
||||
@ -163,13 +176,27 @@ write_menu_file (char *initcode)
|
||||
" int topline;\n"
|
||||
" char **opts;\n"
|
||||
" WINDOW *mw;\n"
|
||||
" char *helpstr;\n"
|
||||
" char *helpstr;\n");
|
||||
|
||||
if (do_dynamic)
|
||||
(void) fprintf (out_file,
|
||||
" dyn_menu_ent *dyn_opts;\n"
|
||||
" void (*post_act)(void);\n"
|
||||
" void (*exit_act)(void);\n");
|
||||
|
||||
(void) fprintf (out_file, "%s",
|
||||
"} menudesc ;\n"
|
||||
"\n"
|
||||
"/* defines for mopt field. */\n"
|
||||
"#define NOEXITOPT 1\n"
|
||||
"#define NOBOX 2\n"
|
||||
"#define SCROLL 4\n"
|
||||
"#define SCROLL 4\n");
|
||||
|
||||
if (do_dynamic)
|
||||
(void) fprintf (out_file,
|
||||
"#define DYNAMIC 8\n");
|
||||
|
||||
(void) fprintf (out_file, "%s",
|
||||
"\n"
|
||||
"/* initilization flag */\n"
|
||||
"extern int __m_endwin;\n"
|
||||
@ -185,8 +212,8 @@ write_menu_file (char *initcode)
|
||||
menus[i]->id, i);
|
||||
}
|
||||
(void) fprintf (out_file, "\n#define MAX_STRLEN %d\n", max_strlen);
|
||||
(void) fprintf (out_file, "#endif\n");
|
||||
|
||||
(void) fprintf (out_file, "#endif\n");
|
||||
fclose (out_file);
|
||||
|
||||
/* Now the C file */
|
||||
@ -238,7 +265,7 @@ write_menu_file (char *initcode)
|
||||
menus[i]->info->w, menus[i]->info->mopt,
|
||||
menus[i]->info->numopt, i);
|
||||
if (menus[i]->info->helpstr == NULL)
|
||||
(void) fprintf (out_file, "NULL},\n");
|
||||
(void) fprintf (out_file, "NULL");
|
||||
else {
|
||||
tmpstr = menus[i]->info->helpstr;
|
||||
/* Skip an initial newline. */
|
||||
@ -252,8 +279,13 @@ write_menu_file (char *initcode)
|
||||
(void) fprintf (out_file, "\\n\\\n");
|
||||
tmpstr++;
|
||||
}
|
||||
(void) fprintf (out_file, "\"},\n");
|
||||
(void) fprintf (out_file, "\"");
|
||||
}
|
||||
if (do_dynamic)
|
||||
(void) fprintf (out_file, ",NULL,NULL,NULL},\n");
|
||||
else
|
||||
(void) fprintf (out_file, "},\n");
|
||||
|
||||
}
|
||||
(void) fprintf (out_file, "{NULL}};\n\n");
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: menu_sys.def,v 1.10 1998/06/30 06:57:57 phil Exp $ */
|
||||
/* $NetBSD: menu_sys.def,v 1.11 1998/07/01 07:46:02 phil Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright 1997 Piermont Information Systems Inc.
|
||||
@ -189,18 +189,20 @@ static int menucmd (WINDOW *w)
|
||||
switch (ch) {
|
||||
case '\n':
|
||||
return REQ_EXECUTE;
|
||||
case '\016':
|
||||
case '\016': /* Contnrol-P */
|
||||
case KEYSEQ_DOWN_ARROW:
|
||||
return REQ_NEXT_ITEM;
|
||||
case '\020':
|
||||
case '\020': /* Control-N */
|
||||
case KEYSEQ_UP_ARROW:
|
||||
return REQ_PREV_ITEM;
|
||||
case '\014':
|
||||
case '\014': /* Control-L */
|
||||
return REQ_REDISPLAY;
|
||||
case '<':
|
||||
case '\010': /* Control-H (backspace) */
|
||||
case KEYSEQ_PAGE_UP:
|
||||
return REQ_SCROLLUP;
|
||||
case '>':
|
||||
case ' ':
|
||||
case KEYSEQ_PAGE_DOWN:
|
||||
return REQ_SCROLLDOWN;
|
||||
case '?':
|
||||
@ -445,6 +447,8 @@ static void process_req (struct menudesc *m, int num, int req)
|
||||
m->cursel++;
|
||||
scroll_sel = 1;
|
||||
refresh = 1;
|
||||
if (m->cursel >= m->topline + m->h -1 )
|
||||
m->topline += 1;
|
||||
} else
|
||||
mbeep();
|
||||
|
||||
@ -453,6 +457,8 @@ static void process_req (struct menudesc *m, int num, int req)
|
||||
m->cursel--;
|
||||
scroll_sel = 1;
|
||||
refresh = 1;
|
||||
if (m->cursel < m->topline )
|
||||
m->topline -= 1;
|
||||
} else
|
||||
mbeep();
|
||||
|
||||
@ -473,6 +479,8 @@ static void process_req (struct menudesc *m, int num, int req)
|
||||
mbeep();
|
||||
else {
|
||||
m->topline -= m->h-1;
|
||||
if (m->topline < 0)
|
||||
m->topline = 0;
|
||||
wclear (m->mw);
|
||||
refresh = 1;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: parse.y,v 1.4 1998/06/25 09:58:57 phil Exp $ */
|
||||
/* $NetBSD: parse.y,v 1.5 1998/07/01 07:46:02 phil Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright 1997 Piermont Information Systems Inc.
|
||||
@ -56,7 +56,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 SCROLLABLE
|
||||
%token <i_value> TITLE DEFAULT DISPLAY ERROR INCLUDE DYNAMIC SCROLLABLE
|
||||
%token <s_value> STRING NAME CODE INT_CONST CHAR_CONST
|
||||
|
||||
%type <s_value> init_code system helpstr
|
||||
@ -83,8 +83,12 @@ menu_list : /* empty */
|
||||
| menu_list menu_def
|
||||
| menu_list default_def
|
||||
| menu_list initerror_def
|
||||
| menu_list dynamic_def
|
||||
;
|
||||
|
||||
dynamic_def : INCLUDE DYNAMIC MENU ';'
|
||||
{ do_dynamic = 1; }
|
||||
|
||||
initerror_def : ERROR action ';'
|
||||
{ error_act = $2; }
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: scan.l,v 1.5 1998/06/25 09:58:58 phil Exp $ */
|
||||
/* $NetBSD: scan.l,v 1.6 1998/07/01 07:46:02 phil Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright 1997 Piermont Information Systems Inc.
|
||||
@ -96,6 +96,10 @@ display { return DISPLAY; }
|
||||
|
||||
error { return ERROR; }
|
||||
|
||||
include { return INCLUDE; }
|
||||
|
||||
dynamic { return DYNAMIC; }
|
||||
|
||||
scrollable { return SCROLLABLE; }
|
||||
|
||||
\"([^\"\n]*(\\\")?)*\" {
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: menus.mc,v 1.6 1998/06/29 22:21:03 phil Exp $ */
|
||||
/* $NetBSD: menus.mc,v 1.7 1998/07/01 07:46:02 phil Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright 1997 Piermont Information Systems Inc.
|
||||
@ -44,6 +44,8 @@
|
||||
|
||||
default x=20, y=10;
|
||||
|
||||
include dynamic menu;
|
||||
|
||||
error action { fprintf (stderr, "Testm: Could not initialize curses.\n");
|
||||
exit(1); };
|
||||
|
||||
@ -153,6 +155,7 @@ menu submenu, title " submenu test";
|
||||
option "upper right", sub menu upperright;
|
||||
option "lower left", sub menu lowerleft;
|
||||
option "middle, no title", sub menu middle;
|
||||
option "next menu", next menu nextmenu;
|
||||
|
||||
menu upperright, title "upper right", y=2, x=60, no exit;
|
||||
option "Just Exit!", exit;
|
||||
@ -163,6 +166,9 @@ menu lowerleft, title "lower left", y=20, x=2, no exit;
|
||||
menu middle, no box;
|
||||
option "Just Exit!", exit;
|
||||
|
||||
menu nextmenu, title " A next window! ? for comments", no exit;
|
||||
option "Just Exit!:", exit;
|
||||
|
||||
menu scrollit, scrollable, h=4, title " Scrollable Menu";
|
||||
option "option 1", action {};
|
||||
option "option 2", action {};
|
||||
|
Loading…
Reference in New Issue
Block a user