home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The C Users' Group Library 1994 August
/
wc-cdrom-cusersgrouplibrary-1994-08.iso
/
listings
/
v_11_04
/
1104034a
< prev
next >
Wrap
Text File
|
1992-12-15
|
2KB
|
144 lines
/*
listing 4 - menu.c
*/
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <time.h>
#include <string.h>
#ifdef BCC
#include <dos.h>
#include <conio.h>
#endif
#include "curses.h"
#include "menu.h"
#include "internal.h"
char choice;
/* windows global to all routines */
WINDOW *dialogue;
WINDOW *tbar;
/* define menubar with three options */
MENUBAR menubar[TCHOICES] = {
"file", 'f', 0,
"edit", 'e', 0,
"options", 'o', 0,
};
/* define pulldown menu sub-choices */
CHOICES choices1[3] = {
"open ", 'o', c_open,
"close", 'c', c_close,
"exit ", 'e', c_exit,
};
CHOICES choices2[4] = {
"copy ", 'c', c_copy,
"paste ", 'p', c_paste,
"delete", 'd', c_delete,
"move ", 'm', c_move,
};
CHOICES choices3[4] = {
"version", 'v', c_version,
"compile", 'c', c_compile,
"link ", 'l', c_link,
"run ", 'r', c_run,
};
/* tie all choices into one struct */
PULLDOWN pullmenu[TCHOICES] = {
3, 5, choices1,
4, 6, choices2,
4, 7, choices3,
};
main()
{
int i,j,k;
initscr();
/* needed to return one keystroke at a time */
#ifndef VMS
cbreak();
#else
crmode();
#endif
/* activate keypad code */
#ifdef HPUX
keypad(stdscr, TRUE);
#endif
noecho();
#ifdef BCC
cursoff();
#endif
/* set up screen */
set_stdscr();
dialogue = popup(3, MAX_COLUMNS-4, MAX_ROWS-4, 2);
clear_dialogue();
tbar = topbar(stdscr);
/* enter loop to process options */
for (;;) {
choice = do_menubar(tbar, menubar);
for (i=0;i<TCHOICES;i++) {
if ( choice == menubar[i].letter) {
choice = do_pulldown(i,pullmenu,menubar);
execute_command(i, choice, pullmenu);
break;
} /* if */
} /* for loop */
} /* end main loop (for (;;))*/
}
/* these commands must be called at exit */
int clean_up()
{
erase();
refresh();
endwin();
#ifdef BCC
clrscr();
#endif
exit(0);
return(0);
}