// Source: display.cpp // Author: Michele Estebon // Date: 11/21/96 // For: CS1704: Introduction to Data Structures and Software Design // Last revision: 12/2/96 // Version: 1.1 /************************************************************************ Display functions Implements: IOwin IO display bar statwin Program Status display bar displaywin General main display window menubar Main menubar Provided functions: InitWindows initializes above windows for display and sets colors IOerr sends an error message to IOwin and beeps console IOin gets user input from IOwin entered from keyboard IOout sends message/prompt to IOwin StatusUpdate displays left message, middle message and right message to statwin. DisplayScr displays a screenful (MAXLINES) at a time and waits for a carriage return from keyboard *************************************************************************/ #include #include #include #include "curses.h" #include "display.h" #include "bool.h" #include "globals.h" #include "listglob.h" #include "dblist.h" /*-- CONSTANTS ---------------------------------------------------------*/ #define FAILURE FALSE // globals #define SUCCESS TRUE // globals const char LINECHAR = '-'; const int BAR = 0; // line position for a bar window /*--- LOCAL FUNCTION PROTOTYPES -----------------------------------------*/ Boolean SetMenu (winptr &mainwin, winptr &menubar ); Boolean SetDisplay (winptr &mainwin, winptr &displaywin ); Boolean SetIO (winptr &mainwin, winptr &IOwin ); Boolean SetStat (winptr &mainwin, winptr &statwin ); void DisplCat (winptr& displaywin, char* filename); void DisplDoc(winptr& displaywin, char* filename, Boolean desc); /************************************************************************/ //--------------------------------------------------------------------------\\ // FN: InitWindows // IN: --- // OUT: ptrs to curses windows: mainwin, menubar, displaywin, IOwin, statwin // CALLS: curses.h: wattrset, newwin, wclear, touchwin, mvwaddch, wrefresh // SetMenu, SetDisplay, SetIO, SetStat // PRE: ptrs to windows are previously declared and initialized // POST: windows are created and ready for input and display // ****** Inits curses and creates main display windows //--------------------------------------------------------------------------\\ Boolean InitWindows (winptr &mainwin, winptr &menubar, winptr &displaywin, winptr &IOwin, winptr &statwin) { int i; initscr(); mainwin = newwin(0,0,0,0); if (mainwin == null) return (FAILURE); wattrset( mainwin, B_CYAN | F_BLACK ); wclear(mainwin); if ( SetMenu( mainwin, menubar) && SetDisplay(mainwin, displaywin) && SetIO( mainwin, IOwin) && SetStat( mainwin, statwin) ); else return (FAILURE); for (i=0; iC_ENDHDR+1); if (!terminated) mvwaddstr(displaywin, ++linenum, 1,line); } infile.close(); } //--------------------------------------------------------------------------\\ // FN: DisplDoc // IN: filename, desc // OUT: displaywin // CALLS: wclear, mvwaddstr, wrefresh // PRE: file existance has already been checked // POST: file is displayed to displaywin // ****** Displays documentation file to displaywin. If desc == TRUE, description // info is displayed, else Codeinfo is displayed. //--------------------------------------------------------------------------\\ void DisplDoc(winptr& displaywin, char* filename, Boolean desc) { string80 line; int linenum; ifstream infile; infile.open(filename); for (linenum=0; linenum