// Source: doc.cpp // Author: Michele Estebon // Date: 11/26/96 // For: CS1704: Introduction to Data Structures and Software Design // Last revision: 12/9/96 // Version: 1.1 // Sys Req'ments: successfully compiled in MS-Visual C++ v1.52 as a // 16-bit MS-DOS application. This has to do with // the use of the curses library package. /************************************************************************ Main calling program for DR. DOC: On-line Code documentation manager Allows a user to perform set creation, viewing, and editing routines for a group of category and documentation files. The files are accessed via a root category file which lists references to other files (either category or documentation). Program implements a menuing system for which usage is explained in the opening Help screen. This screen is accessible at any time throughout the program. DR. DOC will also take command-line input. *************************************************************************/ /*-- INCLUDES ----------------------------------------------------------*/ #include "listglob.h" #include "menus.h" #include "globals.h" #include #include "bool.h" #include "display.h" #include #include "docops.h" #include "seelist.h" int GetCommand(winptr &IOwin, menus &menulist, winptr &mainwin); /************************************************************************/ /************************************************************************/ int main(int argc, char* argv[]) { int command = NOCOM; Boolean comlnset = FALSE; menus menulist = null; seeptr SeeList = null; nodeptr RFSet = null; nodeptr curptr = null; nodeptr lastone = null; nodeptr imed = null; winptr mainwin, displaywin, menubar, IOwin, statwin, seemenu; int aspect; fnametype setname; /*--------------------------*/ Splash(); if (argc>1) { // intialize vars w/ command line argument comlnset = TRUE; command = OPEN; strcpy( setname, argv[1]); if (!strstr(setname, RFEXT) ) strcat(setname, RFEXT); } else strcpy(setname,NO_SET); if ( (InitWindows(mainwin,menubar,displaywin,IOwin,statwin)) && (InitMenus( mainwin, menulist, menubar) ) ) { Help(mainwin); while (command != QUIT) { if (!comlnset) command = GetCommand(IOwin, menulist, mainwin); if (command != NO_OPT) { switch (command) { case ABOUT: About(mainwin); break; case HELP: Help(mainwin); break; case NEW: NewRFS(displaywin, IOwin, RFSet, setname, curptr); break; case OPEN: OpenRFS(displaywin, IOwin, RFSet, setname, curptr); break; case QUIT: Quit(IOwin, RFSet, setname, menulist); break; default : { if (RFSet != null) { switch (command) { case SAVE : Save(IOwin, RFSet, setname); break; case SAVEAS : SaveAs(IOwin, RFSet, setname); break; case CLOSE : Close(displaywin, IOwin, RFSet, setname, curptr); break; case UNDO : case REDO : No_imp(IOwin); break; case ADD : Add(displaywin, IOwin, RFSet, curptr); break; case DELETE : Deletef(displaywin, IOwin, RFSet, setname, curptr, SeeList); break; case MNAME : Modfile(IOwin, curptr, NAME); break; case MLABEL : Modfile(IOwin, curptr, LABEL); break; case MTYPE : Modfile(IOwin, curptr, CODE); break; case DESCR : ToggleDisplay(displaywin, IOwin, curptr, DESC); break; case CODEINFO: ToggleDisplay(displaywin, IOwin, curptr, CDINFO); break; case ROOT : Root(displaywin, IOwin, RFSet, curptr); break; case BACK : Back(displaywin, IOwin, lastone, curptr); break; case INDEX : Index(displaywin, IOwin, RFSet, curptr); break; case SEE : SeeAlso(mainwin, displaywin, IOwin, seemenu, curptr, RFSet, SeeList); ResetWin(mainwin); break; default : IOerr(IOwin, BAD_OPT); } lastone = imed; } // if else IOerr(IOwin, SET_NOT_OPEN); } // default } // switch imed = curptr; StatusUpdate(statwin, setname, DOC, curptr); UpdateSeeList(SeeList, seemenu, curptr, RFSet); } // if command comlnset = FALSE; } // while not QUIT EndProg(menubar, IOwin, statwin, displaywin, mainwin); } // if InitWindows else { cout << "Unable to intialize windows. Not enough memory or corrupt menu.ini file." << endl << "Press enter to return to operating system..." ; cin.ignore(200,'\n'); } return (0); } //--------------------------------------------------------------------------\\ // FN : GetCommand // IN : menulist // OUT : command integer value, mainwin // CALLS : Nobuff, Buffin, ValidateOpt, menumode // PRE : menulist is initialized, mainwin is init'd // POST : user has entered option from keyboard, mainwin is refreshed // ****** Gets a command option from keyboard input, uses 'menumode' which // allows a user to scroll through options and make a selection // Also allows option to escape with no selection. // See Also main menu option doesn't go into menumode. It is treated as a command. //--------------------------------------------------------------------------\\ int GetCommand(winptr &IOwin, menus &menulist, winptr &mainwin) { int ValidateOpt(winptr &IOwin, int , Boolean &); int menu; int opt; Boolean valid = TRUE;; int command; Nobuff(); opt = wgetch(mainwin); Buffin(); menu = ValidateOpt(IOwin, opt, valid); if ( (valid) && (menu != SEE) ) command = menumode(menulist, menu, mainwin, IOwin); else { if (menu == SEE) command = SEE; else command = NO_OPT; } ResetWin(mainwin); return (command); } /*------------------------------------------------------------- FUNCTION : ValidateOpt Validates user option input IN : user input character OUT : if valid, returns Boolean TRUE and function value integer corresponding to user selection; else FALSE and NOCOM value CALLS : --- CALLED BY: main PRE : character is input from keyboard POST : if error, message is displayed to IOscreen --------------------------------------------------------------*/ int ValidateOpt(winptr &IOwin, int opt, Boolean &valid) { switch (opt) { case PROGCH: case LPROGCH: return (PROG); case LFILECH: case FILECH: return (FILE); case LEDITCH: case EDITCH: return (EDIT); case LVIEWCH: case VIEWCH: return (VIEW); case LSEECH: case SEECH: return (SEE); default : IOerr(IOwin, BAD_INPUT); valid = FALSE; } return (NOCOM); }