//Displays the screen for deleting a record. User will only be able to delete a record
//after pressing F3 two times, to ascertain that she wants to delete the record.
void deleteScreen(){
  setup();
  
  for(i = 0; i < 12; i++){
    xt_par2(XT_SET_ROW_COL_POS, row = 11+i, col = 24);
    printf("|");
    xt_par2(XT_SET_ROW_COL_POS, row = 11+i, col = 96);
    printf("|");
  }
  xt_par2(XT_SET_ROW_COL_POS, row = 11, col = 25);
  printf("-----------------------------------------------------------------------");
  xt_par0(XT_CH_GREEN);
  xt_par2(XT_SET_ROW_COL_POS, row = 12, col = 25);
  printf("Record - (---------- --:--:--)");                       //print the record number and time using myui1 
  xt_par2(XT_SET_ROW_COL_POS, row = 13, col = 25);
  printf("Category:");
  xt_par2(XT_SET_ROW_COL_POS, row = 15, col = 25);
  printf("Title:");
  xt_par2(XT_SET_ROW_COL_POS, row = 18, col = 25);
  printf("Body:");
  xt_par0(XT_CH_BLUE);
  xt_par2(XT_SET_ROW_COL_POS, row = 22, col = 25);
  printf("-------------------------------F3-Delete-------------------------------");
  xt_par2(XT_SET_ROW_COL_POS, row = 28, col = 1);
  xt_par0(XT_CH_BLUE);
  printf("-------------------------------------------------------F9-EXIT----------------------------------------------------------");
  xt_par0(XT_CH_WHITE);
  xt_par2(XT_SET_ROW_COL_POS,row = 14, col = 25);
}
//Chronological sorting with bubbleSort.
void bubbleSortTime() {
  int a = 0, b = 0;
  for(a = 0; a < maxRecord - 1; a++) {
    for(b = 0; b < maxRecord - a - 1; b++) {
      if(strcmp(dataStorage[b].timedate,dataStorage[b+1].timedate) > 0 && 
         strcmp(dataStorage[b].category,dataStorage[b+1].category) == 0) {
      	struct ArrayRecords temp;
      	temp = dataStorage[b+1];
      	dataStorage[b+1] = dataStorage[b];
      	dataStorage[b] = temp;
      }
    }
  } 
  for(i = 0; i < 18; i++){
    xt_par2(XT_SET_ROW_COL_POS, row = 8 + i, col = 2);
    if(i < catCounter){
      printf("              ");
      xt_par2(XT_SET_ROW_COL_POS, row = 8 + i, col = 2);
      printf("%s", categoryList[i].category);
    }
    else printf("--------------");  //prints the list of subjects, utilizes the forking program/myui1  cmd(mystore, subject, i+1)
  }
  recordView = currentRecord = 0;
  //updateRecords(0);
  xt_par2(XT_SET_ROW_COL_POS,row = 8, col = 2);
  CATEGORY = row;
  updateRecords(0);
}
Beispiel #3
0
void display(){
  xt_par0(XT_CLEAR_SCREEN);
  xt_par2(XT_SET_ROW_COL_POS, 1, 1);
  xt_par0(XT_CH_BOLD);
  printf("Welcome to MyStore.\n");
  xt_par0(XT_CH_NORMAL);
  printf("Scroll through records using left and right arrow keys.\n\n");
  printf("Press F2 to add a new record\n");
  printf("Press F3 to delete current record\n");
  printf("Press F4 to return to welcome screen\n");
  printf("Press F5 to delete all records\n");
  printf("Press F6 to edit\n");
  printf("Press F7 to SEARCH for a key word\n");
  printf("Press F9 to jump to first record\n");
  if (numRecords == 0){
    xt_par0(XT_CH_BOLD);
    printf("\n\n\nNO RECORDS AS OF YET");
    xt_par0(XT_CH_NORMAL);
    viewRecordHelper();
  }
  else{
    char strRecordNum[10];
    sprintf(strRecordNum, "%d", recordNum);
    ReadMystoreFromChild("display", strRecordNum, NULL, NULL);
    setNumStructsNeeded();
    ParseInput();



    char *date = (char *)malloc(100 * sizeof(char));
    date = pairs[2].value;
    char *subject = (char *)malloc(30 * sizeof(char));

    subject = pairs[3].value;
    char *body = (char *)malloc(141 * sizeof(char));
    body = pairs[4].value;
    xt_par2(XT_SET_ROW_COL_POS, 15, 1);
    xt_par0(XT_CH_BOLD);
    printf("ITEM #: ");
    xt_par0(XT_CH_NORMAL);
    printf("%d\n", recordNum);
    xt_par2(XT_SET_ROW_COL_POS, 16, 1);
    xt_par0(XT_CH_BOLD);
    printf("SUBJECT: ");
    xt_par0(XT_CH_NORMAL);
    printf("%s", subject);
    xt_par2(XT_SET_ROW_COL_POS, 17,1);
    xt_par0(XT_CH_BOLD);
    printf("BODY: ");
    xt_par0(XT_CH_NORMAL);
    printf("%s", body);
    xt_par2(XT_SET_ROW_COL_POS, 19, 1);
    xt_par0(XT_CH_BOLD);
    printf("TIME ADDED: ");
    xt_par0(XT_CH_NORMAL);
    printf("%s", date);
    viewRecordHelper();
  }
}
Beispiel #4
0
static void drawDoodler(Doodler d) {
	xt_par2(XT_SET_ROW_COL_POS,1,1);
	xt_par2(XT_SET_ROW_COL_POS,d.y,d.x);
	xt_par0(XT_BG_RED);
	//printf("doodler");
	puts(DOODLER_SHAPE);
	xt_par0(XT_BG_DEFAULT);

}
//Clears the search after the user exits from that portion of the screen.
void clearSearch(){
  //insert code for resetting Title, Category, and Body (for some reason we have several versions of this)
  int trow, tcol;
  xt_par2(XT_SET_ROW_COL_POS, trow = 8, tcol = 95);
  xt_par0(XT_CH_GREEN);
  printf("Category:");
  xt_par2(XT_SET_ROW_COL_POS, trow = 11, tcol = 95);
  printf("Title:");
  xt_par2(XT_SET_ROW_COL_POS, trow = 15, tcol = 95);
  printf("Body:");
  xt_par0(XT_CH_WHITE);
  xt_par2(XT_SET_ROW_COL_POS, trow = 9, tcol = 95);
  printf("------------------");
  xt_par2(XT_SET_ROW_COL_POS, trow = 12, tcol = 95);
  printf("-------");
  xt_par2(XT_SET_ROW_COL_POS, trow = 13, tcol = 95);
  printf("------------------");
  for(i = 0; i < 5; i++){
    xt_par2(XT_SET_ROW_COL_POS, trow = 16+i, tcol = 95);
    printf("-------------------------");
  }
  xt_par2(XT_SET_ROW_COL_POS, trow = 16 + 5, tcol = 95);
  printf("---------------");
  xt_par2(XT_SET_ROW_COL_POS, row, col);
}
Beispiel #6
0
void ClearBoard() {
  int i,j;
  for (i = 0; i < 23; i++) {
    for (j = 0; j < 80; j++) {
      Board[i][j] = ' ';
    }
  }
  xt_par0(XT_CLEAR_SCREEN);
  xt_par2(XT_SET_ROW_COL_POS,24,1);
  printf("%s",greeting);
  xt_par2(XT_SET_ROW_COL_POS,1,1);
}
Beispiel #7
0
//display functions
int displayUIElement(Area window,struct displayText ui, ...) {
	int row = 0;
	int col = 0;
	int len = strlen(ui.text);
	va_list args;
	va_start(args,ui);

	row = verticalMargin(ui.verticalMargin,window);
	if(ui.verticalMargin > 0) {
		row = window.top + ui.verticalMargin;
	} else if (ui.verticalMargin < 0) {
		row = window.bot + ui.verticalMargin;
	}

	if(ui.alignment == TEXT_ALIGN_LEFT) {
		col = window.left;
	} else if (ui.alignment == TEXT_ALIGN_CENTER) {
		col = (window.right - window.left - len) / 2;
	} else if (ui.alignment == TEXT_ALIGN_RIGHT) {
		col = window.right - len;
	}

	xt_par2(XT_SET_ROW_COL_POS,row,col);
	xt_par0(ui.color);
	vprintf(ui.text,args);
	va_end(args);
	return row;
}
Beispiel #8
0
void setUpBoard(){
  xt_par0(XT_CLEAR_SCREEN);
  printscores();
  xt_par2(XT_SET_ROW_COL_POS,row=1,col=1);
  FILE *fp;
  fp = fopen("pacman.txt", "r");
  int i;
  
  for (i = 0; i < 25; i++){
    char line[25];
    (fgets(line, 25, fp));
    strcpy(data[i], line);
    printf("%s",data[i]);
  }
  fclose(fp);
  xt_par2(XT_SET_ROW_COL_POS, row=19, col=12);
  putchar('<');
  xt_par2(XT_SET_ROW_COL_POS, row=19, col=12);
}
Beispiel #9
0
void setUpAddEditScreen(){
  row = col = 10;
  screenPos = 1;
  printf("Use up and down arrow keys to scroll between subject and body.\n");
  printf("When you are totally finished, press 'ENTER' on the save button.\n");
  printf("Alternatively, press F3 to return to the display screen without saving\n");

  xt_par0(XT_CH_BLUE);
  xt_par2(XT_SET_ROW_COL_POS, 10,1);
  printf("SUBJECT: ");
  xt_par0(XT_CH_DEFAULT);
  printf("%s", subjInput);

  xt_par2(XT_SET_ROW_COL_POS,15,1);
  printf("BODY: %s", bodyInput);

  xt_par2(XT_SET_ROW_COL_POS, 20, 10);
  printf("SAVE");

  xt_par2(XT_SET_ROW_COL_POS, 10,10);
}
Beispiel #10
0
void raiseScreen(){
  if (screenPos == 1){
    xt_par2(XT_SET_ROW_COL_POS, 10, 1);
    printf("SUBJECT: ");
    xt_par0(XT_CH_BLUE);
    xt_par2(XT_SET_ROW_COL_POS, 20, 10);
    printf("SAVE");
    xt_par0(XT_CH_DEFAULT);
    screenPos = 3;
  }
  else if (screenPos == 2){
    xt_par2(XT_SET_ROW_COL_POS, 15, 1);
    printf("BODY: ");
    xt_par0(XT_CH_BLUE);
    xt_par2(XT_SET_ROW_COL_POS, 10, 1);
    printf("SUBJECT: ");
    xt_par0(XT_CH_DEFAULT);
    row = 10;
    col = 10;
    subjPos = 0;
    screenPos = 1;
  }
  else {
    xt_par2(XT_SET_ROW_COL_POS, 20, 10);
    printf("SAVE");
    xt_par0(XT_CH_BLUE);	
    xt_par2(XT_SET_ROW_COL_POS, 15, 1);
    printf("BODY: ");
    xt_par0(XT_CH_DEFAULT);
    row = 15;
    col = 7;
    bodyPos = 0;
    screenPos = 2;
  }
}
//Creates the text representation of myuiscreen by using ASCII art.
void setup() {                    //print using myui (stat)
  xt_par0(XT_CLEAR_SCREEN);
  setStat();
  xt_par2(XT_SET_ROW_COL_POS, row = 1, col = 1);
  xt_par0(XT_CH_GREEN);
  printf("-------------------------------------------------------LifeTracker------------------------------------------------------");
  xt_par0(XT_CH_WHITE);
  xt_par2(XT_SET_ROW_COL_POS, row = 2, col = 25);
  printf("Number of Records: %s | Authors: %s | Version: %s ", data[3].value, data[2].value, data[1].value);
  xt_par2(XT_SET_ROW_COL_POS,row = 3, col = 24);
  if (maxRecord != 0) printf("First Record  Time: %s | Last Record  Time: %s", data[4].value, data[5].value);
  else printf("             First Record Time: (NULL) | Last Record Time: (NULL)");
  xt_par2(XT_SET_ROW_COL_POS, row = 4, col = 1);
  printf("------------------------------------------------------------------------------------------------------------------------");
  xt_par2(XT_SET_ROW_COL_POS, row = 5, col = 1);
  xt_par0(XT_CH_BLUE);
  if(screen == 0)
    printf("------------UP/Down-Scroll between Subjects/Records/Search Left/Right-Toggle between Subjects/Records/Search------------");
  else if(screen == 1 || screen == 2)
    printf("-------------------------------------UP/Down-Switch rows Left/Right-Switch columns--------------------------------------");
  else
    printf("------------------------------------------------------------------------------------------------------------------------");
  xt_par0(XT_CH_WHITE);
  xt_par2(XT_SET_ROW_COL_POS, row = 7, col = 21); 
}
Beispiel #12
0
void addRecord(){
  saveOption = 0;
  subjInput = (char*)malloc(31 * sizeof(char));
  bodyInput = (char*)malloc(141 * sizeof(char));
  subjPos = bodyPos = 0;
  xt_par0(XT_CLEAR_SCREEN);
  xt_par2(XT_SET_ROW_COL_POS, 1, 1);
  xt_par0(XT_CH_BOLD);
  printf("Welcome to MyStore.\n");
  xt_par0(XT_CH_NORMAL);
  setUpAddEditScreen();
  addEditKeyboardControl();
}
//The function to loop through dataStorage to determine the records that match 
//the input parameters for T, B, and C in Search.
void searchResults(int range){
  free(catStorage);
  int trow, tcol;
  char TempBodyA[71];
  char TempBodyB[71];
  int r;
  int i;
  removeBlanks();
  for(i = 6; i <= 25; i++){
    xt_par2(XT_SET_ROW_COL_POS,trow=i,tcol=20);
    printf("                                                                       ");
  }  
  tempCounter = 0;
  //struct ArrayRecords *catStorage; 
  catStorage = (struct ArrayRecords*)malloc((maxRecord) * sizeof(struct ArrayRecords));
  for(i = 0; i < maxRecord; i++){
    if(strstr(dataStorage[i].subject, Title) != NULL &&
       strstr(dataStorage[i].body, Body) != NULL &&
       strstr(dataStorage[i].category, Category) != NULL) { 
      catStorage[tempCounter] = dataStorage[i];
      tempCounter++;
    }
  }
  i = 0;
  //printf("Is there anything in catStorage? %s\n", catStorage[1].body);
  for(r = range; r < 4+range; r++){
    if(r < tempCounter){
      int k = 0;
      while(k != 70) {
        TempBodyA[k] = ' ';
        TempBodyB[k] = ' ';
        k++;
      }
      TempBodyA[70] = '\0';
      TempBodyB[70] = '\0';
      k = 0;
      xt_par2(XT_SET_ROW_COL_POS, trow = 7+5*i, tcol = 20);
      xt_par0(XT_CH_GREEN);
      printf("Record %d (%s)", r+1, catStorage[r].timedate); //get the time using myui1
      xt_par0(XT_CH_WHITE);
      xt_par2(XT_SET_ROW_COL_POS, trow = 8+5*i, tcol = 20);
      int j = 0;
      while(catStorage[r].body[j] != '\0'){
        if(j < 70) TempBodyA[j] = catStorage[r].body[j];
        else if(j < 140) TempBodyB[j%70] = catStorage[r].body[j];
        j++;
      }
      xt_par0(XT_CH_GREEN);
      printf("%s", catStorage[r].subject);
      xt_par0(XT_CH_WHITE);
      xt_par2(XT_SET_ROW_COL_POS, trow = 9+5*i, tcol = 20);
      printf("%s", TempBodyA);
      xt_par2(XT_SET_ROW_COL_POS, trow = 10+5*i, tcol = 20);
      printf("%s", TempBodyB);
      i++;
    }
  }
  xt_par2(XT_SET_ROW_COL_POS,row,col);
}
Beispiel #14
0
void PutInTerminal() {
  int i, j;
  xt_par2(XT_SET_ROW_COL_POS,1,1);
  for(i = 0; i < 23; i++) {
    //for(j = 0; j < 80; j++) {
    //if (Board[i][j] != ' ') {
	//xt_par2(XT_SET_ROW_COL_POS, i, j);
	//putchar(Board[i][j]);
	//}
      //}
  printf("%s\n", Board[i]);

  }
  usleep(1000000);
}
//Function to update the screen by displaying the correct records when the user scrolls
//up and down. The maximum number of records displayed at any time is four, from range to
//range + four. 
void updateRecords(int range){
  free(catStorage);
  int trow, tcol;
  char TempBodyA[71];
  char TempBodyB[71];
  int r;
  int i;
  for(i = 6; i <= 25; i++){
    xt_par2(XT_SET_ROW_COL_POS,trow=i,tcol=20);
    printf("                                                                       ");
  }  
  tempCounter = 0;
  //struct ArrayRecords *catStorage; 
  catStorage = (struct ArrayRecords*)malloc((maxRecord) * sizeof(struct ArrayRecords));
  for(i = 0; i < maxRecord; i++){
    if(strcmp(dataStorage[i].category, categoryList[CATEGORY-8].category) == 0){
      catStorage[tempCounter] = dataStorage[i];
      tempCounter++;
    }
  }
  i = 0;
  for(r = range; r < 4+range; r++){
    if(r < tempCounter){
      int k = 0;
      while(k != 70) {
        TempBodyA[k] = ' ';
        TempBodyB[k] = ' ';
        k++;
      }
      TempBodyA[70] = '\0';
      TempBodyB[70] = '\0';
      k = 0;
      xt_par2(XT_SET_ROW_COL_POS, trow = 7+5*i, tcol = 20);
      xt_par0(XT_CH_GREEN);
      printf("Record %d (%s)", r+1, catStorage[r].timedate); //get the time using myui1
      xt_par0(XT_CH_WHITE);
      xt_par2(XT_SET_ROW_COL_POS, trow = 8+5*i, tcol = 20);
      int j = 0;
      while(catStorage[r].body[j] != '\0'){
        if(j < 70) TempBodyA[j] = catStorage[r].body[j];
        else if(j < 140) TempBodyB[j%70] = catStorage[r].body[j];
        j++;
      }
      xt_par0(XT_CH_GREEN);
      printf("%s", catStorage[r].subject);
      xt_par0(XT_CH_WHITE);
      xt_par2(XT_SET_ROW_COL_POS, trow = 9+5*i, tcol = 20);
      printf("%s", TempBodyA);
      xt_par2(XT_SET_ROW_COL_POS, trow = 10+5*i, tcol = 20);
      printf("%s", TempBodyB);
      i++;
    }
  }
  xt_par2(XT_SET_ROW_COL_POS,row,col);
}
Beispiel #16
0
void endGame(){
  xt_par0(XT_CLEAR_SCREEN);
  xt_par2(XT_SET_ROW_COL_POS, 1, 1);
  if (numMoves < bestScore)
    bestScore = numMoves;
  printf("CONGRATULATIONS! You finished in %d moves!\n\n\n", numMoves);
  printf("Would you like to play again?\nIf so, press the LEFT arrow key. If not, press the RIGHT arrow key.\n");
  while (1){
    while((c=getkey()) == KEY_NOTHING);
    if (c == KEY_LEFT){
      play();
      break;
    }
    else if (c == KEY_RIGHT)
      break;
  }
}
Beispiel #17
0
void main(){
  xt_par0(XT_CLEAR_SCREEN);
  int score = 0;
  int highscore = 0;
  xt_par2(XT_SET_ROW_COL_POS, 1,1);
  printf("Welcome to Pacman! Press any arrow key to start a new game.\n# are walls\n* are pellets to eat\n");
  printf("Objective: Collect all the pellets in as few moves as possible.\n");
  printf("Press F3 to restart. Press F2 to quit.\n");
  while (1){
    while ((c = getkey()) == KEY_NOTHING);
    if (c == KEY_LEFT || c == KEY_RIGHT || c == KEY_UP || c == KEY_DOWN)
      play();
    break;
  }
  getkey_terminate();
  xt_par0(XT_CLEAR_SCREEN);
}
Beispiel #18
0
void editRecord(){
  saveOption = 1;
  subjInput = (char*)malloc(31 * sizeof(char));
  bodyInput = (char*)malloc(141 * sizeof(char));
  subjPos = bodyPos = 0;
  char strRecordNum[10];
  sprintf(strRecordNum, "%d", recordNum);
  ReadMystoreFromChild("display", strRecordNum, NULL, NULL);
  ParseInput();
  strcpy(subjInput,pairs[3].value);
  strcpy(bodyInput,pairs[4].value);
  xt_par0(XT_CLEAR_SCREEN);
  xt_par2(XT_SET_ROW_COL_POS, 1, 1);
  xt_par0(XT_CH_BOLD);
  printf("Welcome to MyStore.\n");
  xt_par0(XT_CH_NORMAL);
  printf("This is the EDIT Page.\n");
  printf("Added/edited text shows up in RED.\n");
  setUpAddEditScreen();
  addEditKeyboardControl();
}
Beispiel #19
0
void displayModeBar(int cursorArea,Area window,struct modeBar modeBar){
	int i;
	int totalLength = modeBar.nModes * UI_MODE_LABEL_WIDTH;
	char *next = "%s%s";
	char *format = "%s%-*s";
	char *formatSelected = "[%s]";
	int col = window.top;
	int row = window.left;
	char *output = '\0';
	for(i = 0; i < modeBar.nModes;i++) {
		char *input = modeBar.modes[i].text;

		char * color = getColor(classicModeBar.subject);
		if(isMode(cursorArea,modeBar.modes[i])) {
			color = getColor(classicModeBar.body);
			input = saveFormatted(formatSelected,input);
		}
		input = saveFormatted(format,color,UI_MODE_LABEL_WIDTH,input);
		if(output) {
			output = saveFormatted(next,output,input);
		} else {
			output = saveFormatted(input);
		}
		//message(output);
	}
	/*for(i = 0; i < modeBar.nModes;i++) {
		totalLength += strlen(modeBar.modes[i].text);
		totalLength += 2;
	}*/
	col = (window.right - totalLength) / 2;
	if(col < window.left) {
		col = window.left;
	}
	row = verticalMargin(modeBar.verticalMargin,window);

	xt_par2(XT_SET_ROW_COL_POS,row,col);
	printf(output);
	flushPool();

}
Beispiel #20
0
void lowerScreen(){
  if (screenPos == 1){
    xt_par2(XT_SET_ROW_COL_POS, 10, 1);
    printf("SUBJECT: ");
    xt_par0(XT_CH_BLUE);
    xt_par2(XT_SET_ROW_COL_POS, 15, 1);
    printf("BODY: ");
    xt_par0(XT_CH_DEFAULT);
    row = 15;
    col = 7;
    //xt_par0(XT_CH_RED);
    //	bodyInput = enterInput(0);
    bodyPos = 0;
    screenPos = 2;
  }
  else if (screenPos == 2){
    xt_par2(XT_SET_ROW_COL_POS, 15, 1);
    printf("BODY: ");
    xt_par0(XT_CH_BLUE);
    xt_par2(XT_SET_ROW_COL_POS, 20, 10);
    printf ("SAVE");
    xt_par0(XT_CH_DEFAULT);
    screenPos = 3;
  }
  else {
    xt_par2(XT_SET_ROW_COL_POS, 20, 10);
    printf("SAVE");
    xt_par0(XT_CH_BLUE);	
    xt_par2(XT_SET_ROW_COL_POS, 10, 1);
    printf("SUBJECT: ");
    xt_par0(XT_CH_DEFAULT);
    row = 10;
    col = 10;
    //	subjInput = enterInput(1);
    subjPos = 0;
    screenPos = 1;
  }
}
Beispiel #21
0
void viewRecordHelper(){
  while (1){
    while ((c=getkey()) == KEY_NOTHING);
    if (c == KEY_LEFT){
      if (numRecords != 1){
	recordNum --;
	if (recordNum <= 0)
	  recordNum = numRecords;
	display();
	break;
      }
    }
    else if (c == KEY_RIGHT){
      if (numRecords != 1){
	recordNum ++;
	if (recordNum == (numRecords + 1)){
	  if (numRecords > 0)
	    recordNum = 1;
	  else
	    recordNum = 0;
	}
	display();
	break;
      }
    }
    else if (c == KEY_F2){
      addRecord();
      break;
    }
    else if (c == KEY_F3){
      if (recordNum > 0){
	deleteRecordHelper();
	display();
	break;
      }
      else{
	xt_par2(XT_SET_ROW_COL_POS, 18, 1);
	xt_par0(XT_ERASE_LINE);
	printf("No record to delete.");
      }
    }
    else if (c == KEY_F4){
      welcomeScreen();
      break;
    }
    else if (c == KEY_F5){
      if (recordNum > 0){
	deleteAllRecords();
	display();
	break;
      }
      else{
	xt_par2(XT_SET_ROW_COL_POS, 18, 1);
	xt_par0(XT_ERASE_LINE);
	printf("No records to delete.");
      }
    }
    else if (c == KEY_F6){
      if (numRecords > 0){
	editRecord();
	//	display();
	break;
      }
      else{
	xt_par2(XT_SET_ROW_COL_POS, 18, 1);
	xt_par0(XT_ERASE_LINE);
	printf("No record to edit.");
      }
    }
    
    else if (c == KEY_F7){
      if (numRecords > 0){
	findInputScreen();
	break;
      }
      else{
	xt_par2(XT_SET_ROW_COL_POS, 18, 1);
	xt_par0(XT_ERASE_LINE);
	printf("No records to search through.");
      }
    }
    else if (c == KEY_F9){
      if (numRecords > 0){
	recordNum = 1;
	display();
	break;
      }
      else{
	xt_par2(XT_SET_ROW_COL_POS, 18, 1);
	xt_par0(XT_ERASE_LINE);
	printf("There is no first record yet!");
      }
    }

  }
  getkey_terminate();
}
Beispiel #22
0
void addEditKeyboardControl(){
 while (1){
    while ((c = getkey()) == KEY_NOTHING);

    //temp testing code
    /*
    xt_par2(XT_SET_ROW_COL_POS, 20, 1);
    xt_par0(XT_ERASE_LINE);
    xt_par2(XT_SET_ROW_COL_POS, 21, 1);
    xt_par0(XT_ERASE_LINE);
    xt_par2(XT_SET_ROW_COL_POS, 20, 1);
    printf("subject test: %s\n", subjInput);
    printf("body test: %s\n", bodyInput);
    xt_par2(XT_SET_ROW_COL_POS, row, col);
    */
    //end temp testing code


    if (c == KEY_ENTER){
      if (screenPos == 3){
	if (strlen(subjInput) > 0 && strlen(bodyInput) > 0){
	  save();
	  break;
	}
      }
    }
    else if (c == KEY_DOWN){
      lowerScreen();
    }
    else if (c == KEY_UP){
      raiseScreen();
    }
    else if (c >= ' ' && c <= '~'){
      xt_par0(XT_CH_RED);
      if (screenPos == 1){
	//row = 10;
	//col = 10;
	size = 31;
	xt_par2(XT_SET_ROW_COL_POS, row, col);
	if (subjPos < size - 1){
	  if (subjInput[subjPos] == '\0')
	    subjInput[subjPos + 1] = '\0';
	  subjInput[subjPos++] = c;
	  //	  subjInput[++subjPos] = '\0';
	  putchar(c);
	  col++;
	}
      }
      else if (screenPos == 2){
	//row = 15;
	//col = 7;
	size = 141;
	if (bodyPos < size - 1){
	  if (bodyInput[bodyPos] == '\0')
	    bodyInput[bodyPos + 1] = '\0';
	  bodyInput[bodyPos++] = c;
	  //	  bodyInput[++bodyPos] = '\0';
	  putchar(c);
	  col++;
	  if (col > 80){
	    xt_par2(XT_SET_ROW_COL_POS, row=16, col=1);
	  }
	}
      }
      xt_par0(XT_CH_DEFAULT);
    }
    else if (c == KEY_BACKSPACE){
      if (screenPos == 1){
	if (subjPos > 0){
	  if (subjInput[subjPos] == '\0')
	    subjInput[--subjPos] = '\0';
	  else
	    subjInput[--subjPos] = ' ';
	  xt_par2(XT_SET_ROW_COL_POS, row, --col);
	  putchar(' ');
	  xt_par2(XT_SET_ROW_COL_POS, row, col);
	}
      }
      else if (screenPos == 2){
	if (bodyPos > 0){
	  if (bodyInput[bodyPos] == '\0')
	    bodyInput[--bodyPos] = '\0';
	  else
	    bodyInput[--bodyPos] = ' ';
	  if (row == 16 && col == 1)
	    xt_par2(XT_SET_ROW_COL_POS, row=15, col=80);
	  else
	    xt_par2(XT_SET_ROW_COL_POS, row, --col);
	  putchar(' ');
	  xt_par2(XT_SET_ROW_COL_POS, row, col);
	}
      }
    }
    else if (c == KEY_DELETE){
      if (screenPos == 1){
	if (subjInput[subjPos] != '\0')
	  subjInput[subjPos] = ' ';
	putchar(' ');
	xt_par2(XT_SET_ROW_COL_POS, row, col);
      }
      else if (screenPos == 2){
	if (bodyInput[bodyPos] != '\0')
	  bodyInput[bodyPos] = ' ';
	putchar(' ');
	xt_par2(XT_SET_ROW_COL_POS, row, col);
      }
    }
    else if (c == KEY_LEFT){
      if (screenPos == 1){
	if (subjPos > 0){
	  subjPos --;
	  xt_par2(XT_SET_ROW_COL_POS, row, --col);
	}
      }
      else if (screenPos == 2){
	if (bodyPos > 0){
	  bodyPos --;
	  if (row == 16 && col == 1)
	    xt_par2(XT_SET_ROW_COL_POS, row=15, col=80);
	  else
	    xt_par2(XT_SET_ROW_COL_POS, row, --col);
	}
      }
    }
    else if (c == KEY_RIGHT){
      if (screenPos == 1){
	if (subjInput[subjPos] != '\0'){
	  subjPos++;
	  xt_par2(XT_SET_ROW_COL_POS, row, ++col);
	}
      }
      else if (screenPos == 2){
	if (bodyInput[bodyPos] != '\0'){
	  bodyPos++;
	  if (row == 15 && col == 80)
	    xt_par2(XT_SET_ROW_COL_POS, row=16, col=1);
	  else 
	    xt_par2(XT_SET_ROW_COL_POS, row, ++col);
	}
      }
    }
    else if (c == KEY_F3){
      //      recordNum = 1;
      display();
      break;
    }
  }
 getkey_terminate();
}
Beispiel #23
0
void deleteAllRecords(){
  xt_par0(XT_CLEAR_SCREEN);
  xt_par2(XT_SET_ROW_COL_POS, 10,1);
  xt_par0(XT_CH_BOLD);
  printf("Are you sure you want to delete ALL records?");
  xt_par0(XT_CH_NORMAL);
  xt_par2(XT_SET_ROW_COL_POS, 11, 20);
  printf("YES");
  xt_par0(XT_CH_BLUE);
  xt_par2(XT_SET_ROW_COL_POS, 11, 40);
  printf("NO");
  xt_par0(XT_CH_NORMAL);
  xt_par2(XT_SET_ROW_COL_POS,24,80);

  int curSelect = 1;
  int key;
  
  while(1){
    while ((key=getkey()) == KEY_NOTHING);
    
    if(key == KEY_LEFT){
      curSelect = 0;
      xt_par0(XT_CH_BLUE);
      xt_par2(XT_SET_ROW_COL_POS, 11, 20);
      printf("YES");
      xt_par0(XT_CH_NORMAL);
      xt_par2(XT_SET_ROW_COL_POS, 11, 40);
      printf("NO");
      xt_par2(XT_SET_ROW_COL_POS,24,80);
    }
    else if(key == KEY_RIGHT){
      curSelect = 1;
      xt_par0(XT_CH_NORMAL);
      xt_par2(XT_SET_ROW_COL_POS, 11, 20);
      printf("YES");
      xt_par0(XT_CH_BLUE);
      xt_par2(XT_SET_ROW_COL_POS, 11, 40);
      printf("NO");
      xt_par0(XT_CH_NORMAL);
      xt_par2(XT_SET_ROW_COL_POS,24,80);
    }
    else if(key == KEY_ENTER){
      
      if(curSelect == 0){
		
	char del[2];
	del[0] = '1';
	del[1] = '\0';
	recordNum = 1;

	while(numRecords > 0){
	  //printf("%d\n", numRecords);

	  ReadMystoreFromChild("delete",del,NULL,NULL);
	  --numRecords;
	}

	//while(1);
      }
      
      break;
    }
  }
}
Beispiel #24
0
void deleteRecordHelper(){
  xt_par2(XT_SET_ROW_COL_POS,23,1);
  xt_par0(XT_CH_BOLD);
  printf("Are you sure you wish to delete current record?");
  xt_par0(XT_CH_NORMAL);
  xt_par2(XT_SET_ROW_COL_POS,24,20);
  printf("YES");
  xt_par0(XT_CH_BLUE);
  xt_par2(XT_SET_ROW_COL_POS, 24, 40);
  printf("NO");
  xt_par0(XT_CH_NORMAL);
  xt_par2(XT_SET_ROW_COL_POS,24,80);

  int curSelect = 1;

  while(1){
    while ((c=getkey()) == KEY_NOTHING);

    if(c == KEY_LEFT){
      curSelect = 0;
      xt_par0(XT_CH_BLUE);
      xt_par2(XT_SET_ROW_COL_POS,24,20);
      printf("YES");
      xt_par0(XT_CH_NORMAL);
      xt_par2(XT_SET_ROW_COL_POS, 24, 40);
      printf("NO");
      xt_par0(XT_CH_NORMAL);
      xt_par2(XT_SET_ROW_COL_POS,24,80);
    }
    else if(c == KEY_RIGHT){
      curSelect = 1;
      xt_par0(XT_CH_NORMAL);
      xt_par2(XT_SET_ROW_COL_POS,24,20);
      printf("YES");
      xt_par0(XT_CH_BLUE);
      xt_par2(XT_SET_ROW_COL_POS, 24, 40);
      printf("NO");
      xt_par0(XT_CH_NORMAL);
      xt_par2(XT_SET_ROW_COL_POS,24,80);
    }
    else if(c == KEY_ENTER){
      xt_par2(XT_SET_ROW_COL_POS,23,1);
      xt_par0(XT_ERASE_LINE);
      xt_par2(XT_SET_ROW_COL_POS,24,1);
      xt_par0(XT_ERASE_LINE);
	  
      if(curSelect == 0){
	char del[5];
	sprintf(del, "%d", recordNum); 
	ReadMystoreFromChild("delete",del,NULL,NULL);

	if(recordNum == numRecords)
	  recordNum--;
	numRecords--;
      }
      break;	
	
    }
  }
}
Beispiel #25
0
void displayFoundRecords(){
  xt_par2(XT_SET_ROW_COL_POS, 15, 1);
  xt_par0(XT_ERASE_LINE);
  xt_par2(XT_SET_ROW_COL_POS, 16, 1);
  xt_par0(XT_ERASE_LINE);
  xt_par2(XT_SET_ROW_COL_POS, 17, 1);
  xt_par0(XT_ERASE_LINE);
  xt_par2(XT_SET_ROW_COL_POS, 18, 1);
  xt_par0(XT_ERASE_LINE);
  xt_par2(XT_SET_ROW_COL_POS, 19, 1);
  xt_par0(XT_ERASE_LINE);
  xt_par2(XT_SET_ROW_COL_POS, 20, 1);
  xt_par0(XT_ERASE_LINE);
  xt_par2(XT_SET_ROW_COL_POS, 1, 1);
  printf("Records with \n");
  printf("Scroll through found records using left and right arrow keys.\n\n");
  printf("Press F3 to delete current record\n");
  printf("Press F4 to return to all records\n");
  printf("Press F5 to input a new SEARCH\n");
  printf("Press F6 to edit current record\n");

  recordNum = foundRecords[fi];

  if (numFoundRecords == 0){
    printf("\n\n\nNO MATCHING RECORDS FOUND");
    viewFoundRecordsHelper();
  }
  else{
    char strRecordNum[10];
    sprintf(strRecordNum, "%d", recordNum);
    ReadMystoreFromChild("display", strRecordNum, NULL, NULL);
    setNumStructsNeeded();
    ParseInput();
    char *date = (char*)malloc(100 * sizeof(char));
    date = pairs[2].value;
    char *subject = (char *)malloc(31 * sizeof(char));
    subject = pairs[3].value;
    char *body = (char *)malloc(141 * sizeof(char));
    body = pairs[4].value;
    xt_par2(XT_SET_ROW_COL_POS, 10, 1);
    xt_par2(XT_SET_ROW_COL_POS, 15, 1);
    xt_par0(XT_CH_BOLD);
    printf("ITEM #: ");
    xt_par0(XT_CH_NORMAL);
    printf("%d\n", recordNum);
    xt_par2(XT_SET_ROW_COL_POS, 16, 1);
    xt_par0(XT_CH_BOLD);
    printf("SUBJECT: ");
    xt_par0(XT_CH_NORMAL);
    printf("%s", subject);
    xt_par2(XT_SET_ROW_COL_POS, 17,1);
    xt_par0(XT_CH_BOLD);
    printf("BODY: ");
    xt_par0(XT_CH_NORMAL);
    printf("%s", body);
    xt_par2(XT_SET_ROW_COL_POS, 19, 1);
    xt_par0(XT_CH_BOLD);
    printf("TIME ADDED: ");
    xt_par0(XT_CH_NORMAL);
    printf("%s", date);
    viewFoundRecordsHelper();
  }
}
Beispiel #26
0
void welcomeScreen(){
  xt_par0(XT_CLEAR_SCREEN);
  xt_par0(XT_CH_NORMAL);
  xt_par0(XT_CH_BOLD);
  xt_par0(XT_CH_UNDERLINE);
  xt_par2(XT_SET_ROW_COL_POS,1,1);
  printf("WELCOME TO MYSTORE!!!");
  xt_par2(XT_SET_ROW_COL_POS,5,1);
  xt_par0(XT_CH_NORMAL);
  printf("Mystore Back End designed and developed by ");
  xt_par0(XT_CH_BOLD);
  printf("Peter Brooks.\n");
  xt_par0(XT_CH_NORMAL);
  printf("Mystore Front End designed and developed by ");
  xt_par0(XT_CH_BOLD);
  printf("Justin Duda");
  xt_par0(XT_CH_NORMAL);
  printf(" and ");
  xt_par0(XT_CH_BOLD);
  printf("Jeremy Karson.\n\n\n");
  printf("System Level Programming\n");
  printf("Fall 2013\n");
  printf("Period 5\n");
  xt_par0(XT_CH_NORMAL);

  xt_par2(XT_SET_ROW_COL_POS, 20, 20);
  xt_par0(XT_CH_BLUE);
  printf("CONTINUE");
  xt_par2(XT_SET_ROW_COL_POS, 20, 55);
  xt_par0(XT_CH_NORMAL);
  printf("EXIT");
  xt_par2(XT_SET_ROW_COL_POS, 24, 80);

  int screenPos = 1;

  while(1){
    while ((c=getkey()) == KEY_NOTHING);
    if (c == KEY_LEFT){
      if (screenPos == 2){
	  xt_par2(XT_SET_ROW_COL_POS, 20, 20);
	  xt_par0(XT_CH_BLUE);
	  printf("CONTINUE");
	  xt_par2(XT_SET_ROW_COL_POS, 20, 55);
	  xt_par0(XT_CH_NORMAL);
	  printf("EXIT");
	  xt_par2(XT_SET_ROW_COL_POS, 24, 80);
	  screenPos = 1;
      }
    }
    else if (c == KEY_RIGHT){
      if (screenPos == 1){
	  xt_par2(XT_SET_ROW_COL_POS, 20, 20);
	  xt_par0(XT_CH_NORMAL);
	  printf("CONTINUE");
	  xt_par2(XT_SET_ROW_COL_POS, 20, 55);
	  xt_par0(XT_CH_BLUE);
	  printf("EXIT");
	  xt_par2(XT_SET_ROW_COL_POS, 24, 80);
	  xt_par0(XT_CH_NORMAL);
	  screenPos = 2;
      }
    }
    else if (c == KEY_ENTER){
      if (screenPos == 1){
	display();
	break;
      }
      else{
	xt_par0(XT_CLEAR_SCREEN);
	xt_par2(XT_SET_ROW_COL_POS,1,1);
	break;
      }
    }
  }
  getkey_terminate();
}
Beispiel #27
0
void viewFoundRecordsHelper(){
  while (1){
    while ((c=getkey()) == KEY_NOTHING);
    //    xt_par2(XT_SET_ROW_COL_POS, 18, 1);
    //    xt_par0(XT_ERASE_LINE);
    if (c == KEY_LEFT){
      if (numFoundRecords != 1){
	fi--;
	if (fi < 0)
	  fi = numFoundRecords-1;
	displayFoundRecords();
	break;
      }
    }
    else if (c == KEY_RIGHT){
      if (numFoundRecords != 1){
	fi++;
	if (fi == numFoundRecords)
	  fi = 0;
	displayFoundRecords();
	break;
      }
    }
    else if (c == KEY_F3){
      if (numFoundRecords > 0){
	int tempRecordCounter = numRecords;
	deleteRecordHelper();
	calculateNumRecords();
	if (numRecords < tempRecordCounter)
	  numFoundRecords--;
	//numRecords --;
	if (fi == numRecords)
	  fi--;
	displayFoundRecords();
	break;
      }
      else{
	xt_par2(XT_SET_ROW_COL_POS, 18, 1);
	xt_par0(XT_ERASE_LINE);
	printf("No record to delete.");
      }
    }
    else if (c == KEY_F4){
      if (numRecords > 0)
	recordNum = 1;
      display();
      break;
    }
    else if (c == KEY_F5){
      findInputScreen();
      break;
    }
    else if (c == KEY_F6){
      if (numFoundRecords > 0){
	editRecord();
	//displayFoundRecords();
	break;
      }
      else{
	xt_par2(XT_SET_ROW_COL_POS, 18, 1);
	xt_par0(XT_ERASE_LINE);
	printf("No record to edit.");
      }
    }
  }
  getkey_terminate();
}
Beispiel #28
0
void play(){
  setUpBoard();
  numMoves = 0;
  pelletsLeft = 194;
  printscores();

  //cursor pos is data[row-1][col-1]
  while (1){
    while ((c = getkey()) == KEY_NOTHING);
    if (c == KEY_RIGHT){
      if (data[row-1][col] == '#')
	;
      else{
	numMoves++;
	putchar(' ');
	data[row-1][col-1] = ' ';

	//special middle area
	if (row == 12 && col == 23)
	  xt_par2(XT_SET_ROW_COL_POS, row=12, col=1);

	else
	  xt_par2(XT_SET_ROW_COL_POS, row, ++col);
	if (data[row-1][col-1] == '*')
	  pelletsLeft--;
	putchar('<');
	printscores();
	if (pelletsLeft == 0){
	  endGame();	    
	  break;
	}
      }
    }
    else if (c == KEY_LEFT){
      if (data[row-1][col-2] == '#')
	;
      
      else{
	numMoves++;
	putchar(' ');
	data[row-1][col-1] = ' ';

	//special middle area
	if (row == 12 && col == 1)
	    xt_par2(XT_SET_ROW_COL_POS, row=12, col=23);

	else
	  xt_par2(XT_SET_ROW_COL_POS, row, --col);
	if (data[row-1][col-1] == '*')
	  pelletsLeft--;
	putchar('>');
	printscores();
	if (pelletsLeft == 0){
	  endGame();	    
	  break;
	}
      }
    }
    else if (c == KEY_UP){
      if (data[row-2][col-1] == '#')
	;
      else{
	numMoves++;
	putchar(' ');
	data[row-1][col-1] = ' ';
	xt_par2(XT_SET_ROW_COL_POS, --row, col);
	if (data[row-1][col-1] == '*')
	  pelletsLeft--;
	putchar('V');
	printscores();
	if (pelletsLeft == 0){
	  endGame();	    
	  break;
	}
      }
    }
    else if (c == KEY_DOWN){
      if (data[row][col-1] == '#')
	;
      else{
	numMoves++;
	putchar(' ');
	data[row-1][col-1] = ' ';
	xt_par2(XT_SET_ROW_COL_POS, ++row, col);
	if (data[row-1][col-1] == '*')
	  pelletsLeft--;
	putchar('A');
	printscores();
	if (pelletsLeft == 0){
	  endGame();	    
	  break;
	}
      }
    }
    if(c == KEY_F3){
      play();
      break;
    }
    if(c == KEY_F2)break;
  }	
    getkey_terminate();
    xt_par0(XT_CLEAR_SCREEN);
}
Beispiel #29
0
void printscores(){
  xt_par2(XT_SET_ROW_COL_POS, 26, 1);
  printf("WELCOME TO PACMAN! Pellets Left: %d    # of moves: %d  \n", pelletsLeft, numMoves);
  printf("Your best score: %d moves", bestScore);
  xt_par2(XT_SET_ROW_COL_POS, row, col);
}
Beispiel #30
0
void findInputScreen(){
  int vertPos = 0;
  int subjOrBod  = 0;
  char* search = (char*)malloc(141 * sizeof(char));
  int searchPos = 0;
  int row = 10;
  int col = 13;
  xt_par0(XT_CLEAR_SCREEN);
  xt_par2(XT_SET_ROW_COL_POS, 1, 1);
  printf("Please indicate what key word you would like to search for.\n");
  printf("Then, please Indicate if you would like to search through SUBJECTS or BODIES.\n");
  printf("To return to the previous screen, press F4.");
  xt_par0(XT_CH_BLUE);
  xt_par2(XT_SET_ROW_COL_POS, 10, 1);
  printf("Search for:");
  xt_par0(XT_CH_NORMAL);
  xt_par2(XT_SET_ROW_COL_POS, 20, 20);
  printf("SUBJECTS");
  xt_par2(XT_SET_ROW_COL_POS, 20, 55);
  printf("BODIES");
  xt_par2(XT_SET_ROW_COL_POS, 10, 13);

  while (1){
    while ((c=getkey()) == KEY_NOTHING);
    //    xt_par2(XT_SET_ROW_COL_POS, 15, 1);
    //    xt_par0(XT_ERASE_LINE);
    //printf("%s", search);
    if (c == KEY_DOWN){
      if (vertPos == 0){
	xt_par0(XT_CH_NORMAL);
	xt_par2(XT_SET_ROW_COL_POS, 10, 1);
	printf("Search for:");
	if (subjOrBod == 0){
	  xt_par2(XT_SET_ROW_COL_POS, 20, 20);
	  xt_par0(XT_CH_BLUE);
	  printf("SUBJECTS");
	  xt_par2(XT_SET_ROW_COL_POS, 20, 55);
	  xt_par0(XT_CH_NORMAL);
	  printf("BODIES");
	  xt_par2(XT_SET_ROW_COL_POS, 24, 80);
	  xt_par0(XT_CH_NORMAL);
	}
	else{
	  xt_par2(XT_SET_ROW_COL_POS, 20, 20);
	  xt_par0(XT_CH_NORMAL);
	  printf("SUBJECTS");
	  xt_par2(XT_SET_ROW_COL_POS, 20, 55);
	  xt_par0(XT_CH_BLUE);
	  printf("BODIES");
	  xt_par2(XT_SET_ROW_COL_POS, 24, 80);
	  xt_par0(XT_CH_NORMAL);
	}
	vertPos = 1;
      }
    }
    else if (c == KEY_UP){
      if (vertPos == 1){
	xt_par0(XT_CH_BLUE);
	xt_par2(XT_SET_ROW_COL_POS, 10, 1);
	printf("Search for:");
	xt_par0(XT_CH_NORMAL);
	xt_par2(XT_SET_ROW_COL_POS, 20, 20);
	printf("SUBJECTS");
	xt_par2(XT_SET_ROW_COL_POS, 20, 55);
	printf("BODIES");
	xt_par2(XT_SET_ROW_COL_POS, 10, 13);	
	vertPos = 0;
      }
    }
    else if (c == KEY_LEFT){
      if (vertPos == 1 && subjOrBod == 1){
	xt_par2(XT_SET_ROW_COL_POS, 20, 20);
	xt_par0(XT_CH_BLUE);
	printf("SUBJECTS");
	xt_par2(XT_SET_ROW_COL_POS, 20, 55);
	xt_par0(XT_CH_NORMAL);
	printf("BODIES");
	xt_par2(XT_SET_ROW_COL_POS, 24, 80);
	subjOrBod = 0;
      }
      else if (vertPos == 0){
        if (searchPos > 0){
          searchPos --;
          if (row == 11 && col == 1)
            xt_par2(XT_SET_ROW_COL_POS, row = 10, col=80);
          else
            xt_par2(XT_SET_ROW_COL_POS, row, --col);
        }
      }
    }
    else if (c == KEY_RIGHT){
      if (vertPos == 1 && subjOrBod == 0){
	xt_par2(XT_SET_ROW_COL_POS, 20, 20);
	xt_par0(XT_CH_NORMAL);
	printf("SUBJECTS");
	xt_par2(XT_SET_ROW_COL_POS, 20, 55);
	xt_par0(XT_CH_BLUE);
	printf("BODIES");
	xt_par2(XT_SET_ROW_COL_POS, 24, 80);
	xt_par0(XT_CH_NORMAL);
	subjOrBod = 1;
      }
      else if (vertPos == 0){
        if (search[searchPos] != '\0'){
          searchPos++;
          if (row == 10 && col == 80)
            xt_par2(XT_SET_ROW_COL_POS, row=11, col=1);
          else
            xt_par2(XT_SET_ROW_COL_POS, row, ++col);
        }
      }
    }
    else if (c >= ' ' && c <= '~'){
      if (vertPos == 0){
	xt_par2(XT_SET_ROW_COL_POS, row, col);
	xt_par0(XT_CH_RED);
	if (searchPos < 140){
	  if (search[searchPos] == '\0')
	    search[searchPos + 1] = '\0';
	  search[searchPos++] = c;
	  putchar(c);
	  col ++;
	  if (col > 80){
	    xt_par2(XT_SET_ROW_COL_POS, row=11, col=1);
	  }
	}
      }
      xt_par0(XT_CH_DEFAULT);
    }
    else if (c == KEY_BACKSPACE){
      if (vertPos == 0){
	if (searchPos > 0){
	  if (search[searchPos] == '\0')
	    search[--searchPos] = '\0';
	  else
	    search[--searchPos] = ' ';
	  if (row == 11 && col == 1)
	    xt_par2(XT_SET_ROW_COL_POS, row=10, col=80);
	  else
	    xt_par2(XT_SET_ROW_COL_POS, row, --col);
	  putchar(' ');
	  xt_par2(XT_SET_ROW_COL_POS, row, col);
	}
      }
    }
    else if (c == KEY_DELETE){
      if (vertPos == 0){
	if (search[searchPos] != '\0')
	  search[searchPos] = ' ';
	putchar(' ');
	xt_par2(XT_SET_ROW_COL_POS, row, col);
      }
    }
    else if (c == KEY_ENTER){
      if (vertPos == 1 && strlen(search) > 0){
	findRecords(search, subjOrBod);
	xt_par0(XT_CLEAR_SCREEN);
	xt_par2(XT_SET_ROW_COL_POS, 1, 14);
	xt_par0(XT_CH_BOLD);
	printf("%s",search);
	xt_par0(XT_CH_NORMAL);
	printf(" in ");
	xt_par0(XT_CH_BOLD);
	if (subjOrBod == 0)
	  printf("subject");
	else
	  printf("body");
	xt_par0(XT_CH_NORMAL);
	displayFoundRecords();
	break;
      }
    }
    else if (c == KEY_F4){
      display();
      break;
    }
  }
  getkey_terminate();
}