#include "main.h" #include "dataops.h" #include "fexists.h" #include "verify.h" #include "curse.h" #include "listname.h" #include //main // //This is the main function for the movie review file //verification and review set program for cs2574. // //This funciton calls the other functions in this program //to verify content and format for movie review system files //and allows changes to be made to the loaded movie review set. // //called by: system //calls: ShowStart // ShowHelp // DoWork // ShowEnd // //Params: None // //Author: Glenn Rioux // //Revisions: none // //Version: 1.0 // // int main (int argc, char *argv[]) { //Initialize Curses and Menus InitCurses(); InitMenus(); //Update the display SUDS(1,1,1,1,1,1,1,0,0,0); UpdateDisplay(); if(!Fexists("ccc.messages")) { SetMsgNum(32767); DisplayMessage(); int temp = Response(JUST_ENTER, 1, "Please press 'ENTER' to exit this program."); return(-1); } ShowStart(); if(argc > 1) { SetArgument(argv[1]); ReadMRS(); } else SetArgument((char *)NULL); //This function is the "meat" of the program MainHandler(); //forces proper shut down of curses ShutDownCurses(); return(0); } //ShowStart // //This function describes the purpose of the program in a //"splash screen" and provides the programmer's names and //e-mail addresses. // //This funciton displays a few lines of text using the cout //iostream. // //called by: main //calls: DisplayFunctions // //Params: None // //Author: Glenn Rioux // //Revisions: Glenn Rioux - Text change to reflect program changes // //Version: 1.5 // // void ShowStart(void) { SetMsgNum(1); DisplayMessage(); int temp = Response(JUST_ENTER, 1, "Please press 'ENTER' to continue."); } /********************************************************************** * * Function: MainHandler * Input: none * Returns: void * * Description: * Heart of the program. Takes keystrokes and controls the activation * of various aspects of the program * * Variables: register int key - the current keystroke * cccmenuopts menuCode - data type for the menu activated * mode currentMode - the current mode * int selection - current selected item * int length - the length of the current list * int winsel - currently selected item redux * window active - the iowindow * int temp1 - used to hold temporary values * int temp2 - also used for useless stuff * int msgMode - the current state of messaging * bool inputMode - the current input mode * * Called by: main * * Calls: SetMsgNum * GetDispParams * GetMode * SetMode * GetMsgMode * List * ListMovie * Execute * MsgWinKeyOpts * SUDS * UpdateDisplay * SetDispParams * GetExit * List * ListMovie * * Author: Glenn Rioux * Revisions: * * Version: 2.0 * * **********************************************************************/ void MainHandler(void) { register int key; cccmenuopts menuCode = NONE; mode currentMode = NO_FILE; int selection = 0, length = 0, winsel = 0; window active = GetWindow(IOWIN); int temp1, temp2, msgMode = 0; bool inputMode = false, done = false; do { SetMsgNum(13); GetDispParams(winsel,temp1,temp2); touchwin(active); wrefresh(active); currentMode = GetMode(); msgMode = GetMsgMode(); key = wgetch(active); key = tolower(key); if((msgMode) && (key != F1_KEY)) { MsgWinKeyOpts(key); if(menuCode != NONE) { SUDS(0,0,0,0,0,0,0,1,0,0); UpdateDisplay(); } } if((!inputMode) && (!msgMode) && (menuCode != NONE)) { // if there is a menu pulled down, listen // for the ESCAPE, ENTER, and arrow keys switch(key) { case ENTER: SUDS(0,1,1,0,0,0,0,0,0,0); UpdateDisplay(); Execute(menuCode,currentMode,selection); menuCode = NONE; currentMode=GetMode(); SUDS(0,1,1,0,0,0,0,0,0,0); UpdateDisplay(); if (GetExit()) return; break; case UP_ARROW: DrawMenu(selection); selection = (selection-1); if(!selection) selection = length; DrawMenu(menuCode, selection); SUDS(0,0,0,0,0,0,0,1,0,0); UpdateDisplay(); break; case DOWN_ARROW: DrawMenu(selection); selection = (selection+1); if(selection == (length+1)) selection = FIRST; DrawMenu(menuCode, selection); SUDS(0,0,0,0,0,0,0,1,0,0); UpdateDisplay(); break; case LEFT_ARROW: menuCode = (cccmenuopts((int)menuCode-1)); if(menuCode == NONE) { menuCode = SRCH_MENU; } selection = FIRST; SUDS(0,1,1,0,0,0,0,1,0,0); UpdateDisplay(menuCode, selection, &length); break; case RIGHT_ARROW: if(menuCode == SRCH_MENU) { menuCode = NONE; } menuCode = (cccmenuopts((int)menuCode+1)); selection = FIRST; SUDS(0,1,1,0,0,0,0,1,0,0); UpdateDisplay(menuCode, selection, &length); break; case ESCAPE: menuCode = NONE; SUDS(0,1,1,0,0,0,0,0,0,0); UpdateDisplay(); key = NULL; break; case P_KEY: case F_KEY: case E_KEY: case C_KEY: case V_KEY: case S_KEY: case NULL: case CTRL_N_KEY: case CTRL_O_KEY: case CTRL_S_KEY: case CTRL_A_KEY: case CTRL_L_KEY: case CTRL_Q_KEY: break; default: beep(); } // end switch }// end if else { if((!inputMode) && (!msgMode) && (menuCode == NONE) && (key == UP_ARROW || key == DOWN_ARROW || key == PG_UP || key == PG_DN || key == HOME_KEY || key == END_KEY || key == ENTER || key == ESCAPE)) { switch(key) { case UP_ARROW: winsel--; switch(currentMode) { case 1: List(winsel); break; case 2: ListMovie(winsel); break; default: break; } GetDispParams(winsel,temp1,temp2); break; case DOWN_ARROW: winsel++; switch(currentMode) { case 1: List(winsel); break; case 2: ListMovie(winsel); break; default: break; } GetDispParams(winsel,temp1,temp2); break; case PG_UP/*339*/: winsel=winsel-20; SetDispParams(winsel, winsel, winsel+20); switch(currentMode) { case 1: List(winsel); break; case 2: ListMovie(winsel); break; default: break; } //add twenty to the display list GetDispParams(winsel,temp1,temp2); break; case PG_DN/*338*/: winsel=winsel+20; SetDispParams(winsel, winsel-20, winsel); switch(currentMode) { case 1: List(winsel); break; case 2: ListMovie(winsel); break; default: break; } //subtract twenty from the display list GetDispParams(winsel,temp1,temp2); break; case HOME_KEY/*262*/: winsel=0; SetDispParams(winsel,winsel, winsel+20); switch(currentMode) { case 1: List(winsel); break; case 2: ListMovie(winsel); break; default: break; } //set display list to zero GetDispParams(winsel,temp1,temp2); break; case END_KEY/*347*/: switch(currentMode) { case 1: winsel=GetMovieCounter()-1; SetDispParams(winsel,winsel-20, winsel); List(winsel); break; case 2: winsel=GetReviewNum(); SetDispParams(winsel,winsel-20, winsel); ListMovie(winsel); break; default: break; } //set display list to max GetDispParams(winsel,temp1,temp2); break; case ENTER: switch(GetMode()) { case 1: ListMovie(GetEntry(winsel)); break; case 2: ViewFile(); default: break; } break; case ESCAPE: switch(GetMode()) { case 2: List(winsel); break; default: break; } break; }//switch SUDS(1,1,1,1,1,1,1,0,0,0); }//if }//else if((!inputMode) && (!msgMode) && (key == P_KEY || key == F_KEY || key == E_KEY || key == C_KEY || key == V_KEY || key == S_KEY)) // if a menu command key is pressed, set the // menu code and update the screen. { switch(key) { case P_KEY: menuCode = PROG_MENU; break; case F_KEY: menuCode = FILE_MENU; break; case E_KEY: menuCode = EDIT_MENU; break; case C_KEY: menuCode = CCC_MENU; break; case V_KEY: menuCode = VIEW_MENU; break; case S_KEY: menuCode = SRCH_MENU; break; default: break; } // end case selection = FIRST; SUDS(0,1,1,0,0,0,0,1,0,0); key = SPACE; UpdateDisplay(menuCode, selection, &length); } // end if if(key == F1_KEY) { DisplayMessage(); } if(key == F2_KEY) { SetMsgNum(-2); SUDS(0,1,1,0,0,0,0,0,0,0); UpdateDisplay(); } if(key == F3_KEY) { SetMsgNum(-1); SUDS(0,1,1,0,0,0,0,0,0,0); UpdateDisplay(); } if(key == F4_KEY) { SetMsgNum(1); SUDS(0,1,1,0,0,0,0,0,0,0); UpdateDisplay(); } if(key == F5_KEY) { SetMsgNum(2); SUDS(0,1,1,0,0,0,0,0,0,0); UpdateDisplay(); } if(key == F6_KEY) { SetMsgNum(3); SUDS(0,1,1,0,0,0,0,0,0,0); UpdateDisplay(); } if(key == F7_KEY) { SetMsgNum(4); SUDS(0,1,1,0,0,0,0,0,0,0); UpdateDisplay(); } if(key == F9_KEY) { inputMode = true; } if(key == F10_KEY) { inputMode = false; } if((currentMode >= 1) && ((key == CTRL_N_KEY) || (key == CTRL_O_KEY) || (key == CTRL_S_KEY) || (key == CTRL_A_KEY) || (key == CTRL_L_KEY) || (key == CTRL_Q_KEY))) { menuCode = FILE_MENU; switch(key) { case CTRL_N_KEY: selection = 1; break; case CTRL_O_KEY: selection = 2; break; case CTRL_S_KEY: selection = 3; break; case CTRL_A_KEY: selection = 4; break; case CTRL_L_KEY: selection = 5; break; case CTRL_Q_KEY: selection = 6; break; } SUDS(0,1,1,0,0,0,0,0,0,0); UpdateDisplay(); Execute(menuCode,currentMode,selection); menuCode = NONE; currentMode=GetMode(); SUDS(0,1,1,0,0,0,0,0,0,0); UpdateDisplay(); if (GetExit()) return; } if((currentMode == 0) && (key == CTRL_N_KEY) || (key == CTRL_O_KEY) || (key == CTRL_Q_KEY)) { menuCode = FILE_MENU; switch(key) { case CTRL_N_KEY: selection = 1; break; case CTRL_O_KEY: selection = 2; break; case CTRL_Q_KEY: selection = 3; break; } SUDS(0,1,1,0,0,0,0,0,0,0); UpdateDisplay(); Execute(menuCode,currentMode,selection); menuCode = NONE; currentMode=GetMode(); SUDS(0,1,1,0,0,0,0,0,0,0); UpdateDisplay(); if (GetExit()) return; } if(((currentMode == 1) || (currentMode == 2)) && ((key == INSERT_KEY) || (key == DELETE_KEY))) { menuCode = CCC_MENU; switch(key) { case INSERT_KEY: selection = 1; break; case DELETE_KEY: selection = 2; break; } SUDS(0,1,1,0,0,0,0,0,0,0); UpdateDisplay(); Execute(menuCode,currentMode,selection); menuCode = NONE; currentMode=GetMode(); SUDS(0,1,1,0,0,0,0,0,0,0); UpdateDisplay(); } }while(!done); } /********************************************************************** * * Function: Category * Input: none * Returns: void * * Description: * Grabs info and sticks it to List. * * Variables: int winsel - currently selected item redux * int temp1 - used to hold temporary values * int temp2 - also used for useless stuff * * Called by: Add * Delete * ModFileTitle * ModFileName * * Calls: GetDispParams * List * * Author: Tim McGaughey * Revisions: * * Version: 1.0 * * **********************************************************************/ void Category(void) { int winsel, temp1, temp2; GetDispParams(winsel,temp1,temp2); List(winsel); } /********************************************************************** * * Function: Movie * Input: none * Returns: void * * Description: * Grabs info and uses it for ListMovie * * Variables: int winsel - currently selected item redux * int temp1 - used to hold temporary values * int temp2 - also used for useless stuff * DLnkNodePtr TempPtr - holds selected node * * Called by: Add * Delete * ModFileTitle * ModFileName * ModStarRating * ViewFile * * Calls: GetMode * GetDispParams * ListMovie * * Author: Tim McGaughey * Revisions: * * Version: 1.0 * * **********************************************************************/ void Movie(void) { if (GetMode()==1) { DLnkNodePtr TempPtr=GetSelNode(); ListMovie(TempPtr); } else { int winsel, temp1, temp2; GetDispParams(winsel,temp1,temp2); ListMovie(winsel); } }