|
|
1.1.1.2 ! root 1: /* Created by Microsoft Corp. 1987 */ ! 2: 1.1 root 3: /*** dispatch() - accepts keyboard input and dispatches control to 4: * the appropriate function. 5: * 6: * Wait in a loop for keyboard input, then dispatch to any of several 7: * functions based on what the character code was. Default is insert() 8: * after validating, otherwise it is one of our control keys. There is 9: * a second dispatch function for special keys - those with zero for a 10: * character value. special_dispatch() works based on the scan code. 11: * 12: * EFFECTS: No global variables are directly effected by this function 13: */ 14: 1.1.1.2 ! root 15: #define INCL_SUB ! 16: #define INCL_DOSPROCESS 1.1 root 17: 1.1.1.2 ! root 18: #include <os2def.h> ! 19: #include <bse.h> 1.1 root 20: #include <ctype.h> 21: #include "ssedefs.h" 22: #include "keydefs.h" 23: 24: 25: void dispatch() 26: { 27: 1.1.1.2 ! root 28: KBDKEYINFO keydata; /* data structure from bsesub.h */ ! 29: KBDINFO kbdstatus; /* data structure from bsesub.h */ 1.1 root 30: 1.1.1.2 ! root 31: kbdstatus.cb = sizeof( kbdstatus ); ! 32: KbdGetStatus( &kbdstatus, 0 ); /* set keyboard mode */ ! 33: kbdstatus.fsMask |= 4; ! 34: KbdSetStatus( &kbdstatus, 0 ); 1.1 root 35: 36: 37: /* the following section waits for keyboard input */ 38: /* then examines the key received and dispatches us */ 39: /* to the appropriate function for the key pressed. */ 40: 41: 42: while(1) { 43: 44: 1.1.1.2 ! root 45: KbdCharIn( &keydata, 0, 0 ); /* get a character from KBD */ 1.1 root 46: 47: 1.1.1.2 ! root 48: switch( keydata.chChar ) { 1.1 root 49: 1.1.1.2 ! root 50: default: /* default is not */ ! 51: if ( isprint( keydata.chChar ) ) /* a control key. */ ! 52: insert( keydata.chChar ); /* check validity */ ! 53: else badkey(); /* and if good, */ ! 54: break; /* call insert() */ 1.1 root 55: 56: /* "special keys", those with character codes of 00, must */ 57: /* be sent to another dispatcher that checks scan codes. */ 58: 59: case SPECIAL_KEYS_CHAR: 1.1.1.2 ! root 60: special_dispatch( keydata.chScan, ! 61: keydata.fsState ); 1.1 root 62: break; 63: 64: /* all others keys we can dispatch from here. some */ 65: /* are easy, just dispatch based on char code... */ 66: 67: case CTRL_B_CHAR: 68: ctrl_b(); 69: break; 70: 71: case BKSP_CHAR: 72: bksp(); 73: break; 74: 75: case TAB_CHAR: 76: tab(); 77: break; 78: 79: case CRETURN_CHAR: 80: creturn(); 81: break; 82: 83: case CTRL_N_CHAR: 84: ctrl_n(); 85: break; 86: 87: case CTRL_Y_CHAR: 88: ctrl_y(); 89: break; 90: 91: 92: /* ...for others, we must check the scan code and shift */ 93: /* also as the char code may be shared with another key. */ 94: 95: case SHIFT_END_CHAR: 1.1.1.2 ! root 96: if ( keydata.chScan == END_SCAN && ! 97: keydata.fsState < 3 ) 1.1 root 98: shift_end(); 1.1.1.2 ! root 99: else insert( keydata.chChar ); 1.1 root 100: break; 101: 102: case SHIFT_DOWN_CHAR: 1.1.1.2 ! root 103: if ( keydata.chScan == DOWN_SCAN && ! 104: keydata.fsState < 3 ) 1.1 root 105: shift_down(); 1.1.1.2 ! root 106: else insert( keydata.chChar ); 1.1 root 107: break; 108: 109: case SHIFT_LEFT_CHAR: 1.1.1.2 ! root 110: if ( keydata.chScan == LEFT_SCAN && ! 111: keydata.fsState < 3 ) 1.1 root 112: shift_left(); 1.1.1.2 ! root 113: else insert( keydata.chChar ); 1.1 root 114: break; 115: 116: case SHIFT_RIGHT_CHAR: 1.1.1.2 ! root 117: if ( keydata.chScan == RIGHT_SCAN && ! 118: keydata.fsState < 3 ) 1.1 root 119: shift_right(); 1.1.1.2 ! root 120: else insert( keydata.chChar ); 1.1 root 121: break; 122: 123: case SHIFT_HOME_CHAR: 1.1.1.2 ! root 124: if ( keydata.chScan == HOME_SCAN && ! 125: keydata.fsState < 3 ) 1.1 root 126: shift_home(); 1.1.1.2 ! root 127: else insert( keydata.chChar ); 1.1 root 128: break; 129: 130: case SHIFT_UP_CHAR: 1.1.1.2 ! root 131: if ( keydata.chScan == UP_SCAN && ! 132: keydata.fsState < 3 ) 1.1 root 133: shift_up(); 1.1.1.2 ! root 134: else insert( keydata.chChar ); 1.1 root 135: break; 136: 137: /* There's one other possibility, that the char code is 0xE0 */ 138: /* which indicates an arrow key on the new AT03 keyboard. */ 139: /* We will treat these in the same manner as special keys. */ 140: 141: case ARROW_CHAR: 1.1.1.2 ! root 142: special_dispatch( keydata.chScan, ! 143: keydata.fsState ); 1.1 root 144: break; 145: 146: 147: } 148: 149: } 150: 151: } 152: 153: 154: /*** special_dispatch(c,s) - dispatches control to the appropriate function 155: * based on character and scan codes received 156: * 157: * Characters with zero character codes or character code 0xE0 are sent 158: * here to be dispatched based on their scan code and shift status. These 159: * values are passed to special_dispatch as parameters. 160: * 161: * The left and right arrow keys are handled in this routine rather than 162: * dispatched to their own functions in an attempt to gain some speed. 163: * 164: * ENTRY: scan - scan code of the key press 165: * shift - shift state of the key press 166: * 167: * EFFECTS: No global variables are directly effected by this function 168: * unless the key is an unshifted right or left arrow. 169: * In that case, effects are: 170: * 171: * LinesMarked - this flag is cleared 172: * MarkedLine[] - all cleared 173: * CharsMarked - this flag is cleared 174: * MarkedChar[] - all cleared 175: * EditBuff[] - may be flushed if above were set 176: * EditBuffDirty - cleared if EditBuff[] flushed 177: * CurCol - incremented or decremented 178: */ 179: 180: special_dispatch(scan,shift) /* dispatcher for "special keys" based on */ 181: /* the scan code and shift code from KBD */ 182: 1.1.1.2 ! root 183: UCHAR scan; /* scan code - must be unsigned */ ! 184: unsigned shift; /* shift code */ 1.1 root 185: 186: { 187: 188: register short i; /* indexing variable */ 189: 190: switch( scan ) { /* dispatch based on what scan code was */ 191: /* - check the shift state if necessary */ 192: case LEFT_SCAN: 193: if( shift == 0 ) { /* left arrow handled here for speed */ 194: 195: if ( LinesMarked || CharsMarked ) { 196: LinesMarked = 0; /* if there's marked */ 197: CharsMarked = 0; /* text, clear it */ 198: for ( i = 0; i < MAXLINES; i++ ) 199: MarkedLine[i] = 0; 200: for ( i = 0; i < LINESIZE; i++ ) 201: MarkedChar[i] = 0; 202: if (EditBuffDirty) { /* flush EditBuff before redraw */ 203: EditBuffDirty = 0; 204: flushline((TopRow + CurRow), EditBuff); 205: } 206: drawscr(TopRow); /* redraw the screen */ 207: } 208: 209: if ( CurCol > 0 ) { 210: CurCol -= 1; /* move cursor left 1 */ 1.1.1.2 ! root 211: VioSetCurPos( CurRow, CurCol, 0 ); /* if there's room */ 1.1 root 212: } 213: 214: } 215: 216: else 217: shift_left(); 218: break; 219: 220: case RIGHT_SCAN: 221: if( shift == 0 ) { /* right arrow handled here for speed */ 222: 223: if ( LinesMarked || CharsMarked ) { 224: LinesMarked = 0; /* if there's marked */ 225: CharsMarked = 0; /* text, clear it */ 226: for ( i = 0; i < MAXLINES; i++ ) 227: MarkedLine[i] = 0; 228: for ( i = 0; i < LINESIZE; i++ ) 229: MarkedChar[i] = 0; 230: if (EditBuffDirty) { /* flush EditBuff before redraw */ 231: EditBuffDirty = 0; 232: flushline((TopRow + CurRow), EditBuff); 233: } 234: drawscr(TopRow); /* redraw the screen */ 235: } 236: 237: if (CurCol < (LINESIZE -1)) { /* move cursor right one */ 238: CurCol += 1; /* column if there's room */ 1.1.1.2 ! root 239: VioSetCurPos( CurRow, CurCol, 0 ); 1.1 root 240: } 241: 242: } 243: 244: else 245: shift_right(); 246: break; 247: 248: case UP_SCAN: 249: if( shift == 0 ) 250: up(); 251: else 252: shift_up(); 253: break; 254: 255: case DOWN_SCAN: 256: if( shift == 0 ) 257: down(); 258: else 259: shift_down(); 260: break; 261: 262: case HOME_SCAN: 263: if( shift == 0 ) 264: home(); 265: else 266: shift_home(); 267: break; 268: 269: case END_SCAN: 270: if( shift == 0 ) 271: end_(); 272: else 273: shift_end(); 274: break; 275: 276: case PGUP_SCAN: 277: pgup(); 278: break; 279: 280: case PGDN_SCAN: 281: pgdn(); 282: break; 283: 284: case CTRL_HOME_SCAN: 285: ctrl_home(); 286: break; 287: 288: case CTRL_END_SCAN: 289: ctrl_end(); 290: break; 291: 292: case CTRL_PGUP_SCAN: 293: ctrl_pgup(); 294: break; 295: 296: case CTRL_PGDN_SCAN: 297: ctrl_pgdn(); 298: break; 299: 300: case DEL_SCAN: 301: del(); 302: break; 303: 304: case F9_SCAN: 305: F9(); 306: break; 307: 308: case F10_SCAN: 309: F10(); 310: break; 311: 312: default: 313: badkey(); 314: 315: } 316: 317: } 318: 319: 320: /*** badkey() - sounds a beep when an invalid or inappropriate key is hit 321: * 322: * EFFECTS: None 323: */ 324: 325: badkey() 326: { 1.1.1.2 ! root 327: DosBeep (500, 50); /* frequency = 500 Hertz */ 1.1 root 328: } /* duration = 50 milliseconds */ 329: 330: 331: /*** clearscr() - clears the screen by writing blanks over entire screen 332: * 333: * clearscr() writes blanks with normal attributes over the entire screen, 334: * effectively clearing it. 335: * 336: * EFFECTS: None 337: */ 338: 339: void clearscr() 340: { 341: char buff[2]; /* local buffer for filling cell value */ 342: 343: buff[0] = ' '; /* cell to replicate is a blank */ 344: buff[1] = BackNorm + ForeNorm; /* with normal attributes */ 345: 1.1.1.2 ! root 346: VioScrollUp(0, 0, -1, -1, -1, (PBYTE)buff, 0); 1.1 root 347: 348: /* when the first 5 parameters are */ 349: /* set as above, the entire screen */ 350: /* is filled with the cell in buff */ 351: } 352: 353: 354: /*** drawscr(startline) - redraws the screen starting at the specified line 355: * 356: * drawscr() redraws the screen starting at the line specified in the 357: * parameter it is passed, startline. The screen is drawn with normal 358: * attributes, since this call will never be made with lines marked. 359: * Nothing is done with EditBuff[], that is left to the caller, as is 360: * the value of TopRow. 361: * 362: * ENTRY: startline - the line in the file which will be at the top of 363: * the screen when redrawn. 364: * 365: * EFFECTS: ScrBuff[][] - gets reloaded 366: */ 367: 368: void drawscr(startline) 369: 1.1.1.2 ! root 370: USHORT startline; 1.1 root 371: { 372: 1.1.1.2 ! root 373: register USHORT i, j; /* indexing variables */ 1.1 root 374: 375: char normal = BackNorm + ForeNorm; /* normal attributes */ 376: 377: for ( i = startline, j = 0 ; j < PageSize ; i++, j++) 378: getline( i, &ScrBuff[j][0] ); /* load ScrBuff[][] with the */ 379: /* part of the screen we want */ 380: 1.1.1.2 ! root 381: VioWrtCharStrAtt ( (PCH)ScrBuff, ( PageSize * LINESIZE ), 0, 0, 1.1 root 382: &normal, 0 ); 383: /* write it out to the screen */ 384: } 385: 386: 387: /*** drawline() - redraws the current line 388: * 389: * drawline() redraws the line the cursor is currently on, using the 390: * contents of EditBuff[]. All marked characters will be drawn with the 391: * appropriate attributes. If the line is marked, all characters are 392: * drawn as marked; if the line is not marked, then the characters marked 393: * flag is checked. If characters are marked, the line is drawn in three 394: * sections - unmarked characters at the front of the line (may be 0), 395: * marked characters in the middle of the line (at least 1), and unmarked 396: * characters at the end of the line (may be 0). If no characters are marked 397: * either, then the line is drawn with all normal attributes. 398: * 399: * EFFECTS: None 400: */ 401: 402: drawline() 403: { 1.1.1.2 ! root 404: USHORT i; /* indexing variables */ ! 405: USHORT j; 1.1 root 406: 407: char hilite = BackHilite + ForeHilite; /* attributes for marked */ 408: char normal = BackNorm + ForeNorm; /* attributes for not marked */ 409: 410: if( MarkedLine[TopRow+CurRow] ) 1.1.1.2 ! root 411: VioWrtCharStrAtt( EditBuff, LINESIZE, CurRow, 0, &hilite, 0); 1.1 root 412: /* if line is marked, do this */ 413: else if (CharsMarked) { 414: for( i = 0; !MarkedChar[i] & (i < LINESIZE); i++ ); 415: for( j = i; MarkedChar[j] & (j < LINESIZE); j++ ); 1.1.1.2 ! root 416: VioWrtCharStrAtt( &EditBuff[0], i, CurRow, 0, &normal, 0); ! 417: VioWrtCharStrAtt( &EditBuff[i], (j - i), CurRow, i, &hilite, 0); ! 418: VioWrtCharStrAtt( &EditBuff[j], (LINESIZE - j), CurRow, j, 1.1 root 419: &normal, 0); 420: } /* else if characters marked, do this */ 421: 1.1.1.2 ! root 422: else VioWrtCharStrAtt( EditBuff, LINESIZE, CurRow, 0, &normal, 0); 1.1 root 423: } /* else if neither marked, do this */ 424: 425: 426: /*** line25() - updates line number information on last line 427: * 428: * line25() updates the line numbers maintained in the lower right hand 429: * corner of the screen - current line of cursor and total lines in file. 430: * These numbers are first converted from their zero-based internal values 431: * to a more friendly one-based number. Lots of standing on our heads is 432: * done to get the numbers into decimal characters without using C runtime 433: * routines or doing divisions. 434: * 435: * Note that while the names of these routines refer to the 25th line, 436: * the pagesize is not hardcoded - if we are in 43 line mode, this 437: * information will appear on the 43rd line. However, the spacing within 438: * the line is hardcoded for an 80-column display. 439: * 440: * EFFECTS - None 441: */ 442: 443: void line25() 444: { 445: 446: int flag0 = 0; /* flag to aid in supressing leading 0's */ 447: int col = 67; /* starting column for this info */ 448: int i, n; /* indexing variables */ 449: char buff[LINESIZE]; /* buffer to build output string */ 450: char attrib = Back25 + Fore25; /* attributes for output string */ 451: 452: n = (TopRow + CurRow + 1); /* set n to line number cursor is on */ 453: 454: for( i = 0; n > 9999; n -= 10000, i++ ); 455: if( i > 0 ) { 456: flag0 = 1; /* 10,000's place of current line */ 457: buff[0] = i + 0x30; 458: } 459: else buff[0] = ' '; 1.1.1.2 ! root 460: VioWrtCharStrAtt( buff, 1, PageSize, col, &attrib, 0 ); 1.1 root 461: col += 1; 462: 463: for( i = 0; n > 999; n -= 1000, i++ ); 464: if( i > 0 ) { 465: flag0 = 1; /* 1,000's place of current line */ 466: buff[0] = i + 0x30; 467: } 468: else if( flag0 ) buff[0] = '0'; 469: else buff[0] = ' '; 1.1.1.2 ! root 470: VioWrtCharStrAtt( buff, 1, PageSize, col, &attrib, 0 ); 1.1 root 471: col += 1; 472: 473: for( i = 0; n > 99; n -= 100, i++ ); 474: if( i > 0 ) { 475: flag0 = 1; /* 100's place of current line */ 476: buff[0] = i + 0x30; 477: } 478: else if( flag0 ) buff[0] = '0'; 479: else buff[0] = ' '; 1.1.1.2 ! root 480: VioWrtCharStrAtt( buff, 1, PageSize, col, &attrib, 0 ); 1.1 root 481: col += 1; 482: 483: for( i = 0; n > 9; n -= 10, i++ ); 484: if( i > 0 ) { 485: flag0 = 1; /* 10's place of current line */ 486: buff[0] = i + 0x30; 487: } 488: else if( flag0 ) buff[0] = '0'; 489: else buff[0] = ' '; 1.1.1.2 ! root 490: VioWrtCharStrAtt( buff, 1, PageSize, col, &attrib, 0 ); 1.1 root 491: col += 1; 492: 493: buff[0] = n + 0x30; /* 1's place of current line */ 1.1.1.2 ! root 494: VioWrtCharStrAtt( buff, 1, PageSize, col, &attrib, 0 ); 1.1 root 495: col += 1; 496: 497: buff[0] = ' '; 498: buff[1] = '/'; /* delimiting characters */ 499: buff[2] = ' '; 1.1.1.2 ! root 500: VioWrtCharStrAtt( buff, 3, PageSize, col, &attrib, 0 ); 1.1 root 501: col += 3; 502: 503: flag0 = 0; 504: n = TotalLines; /* n is total lines in file */ 505: 506: for( i = 0; n > 9999; n -= 10000, i++ ); 507: if( i > 0 ) { 508: flag0 = 1; /* 10,000's place of total lines */ 509: buff[0] = i + 0x30; 1.1.1.2 ! root 510: VioWrtCharStrAtt( buff, 1, PageSize, col, &attrib, 0 ); 1.1 root 511: col += 1; 512: } 513: 514: for( i = 0; n > 999; n -= 1000, i++ ); 515: if( i > 0 ) { 516: flag0 = 1; /* 1,000's place of total lines */ 517: buff[0] = i + 0x30; 1.1.1.2 ! root 518: VioWrtCharStrAtt( buff, 1, PageSize, col, &attrib, 0 ); 1.1 root 519: col += 1; 520: } 521: else if( flag0 ) { 522: buff[0] = '0'; 1.1.1.2 ! root 523: VioWrtCharStrAtt( buff, 1, PageSize, col, &attrib, 0 ); 1.1 root 524: col += 1; 525: } 526: 527: for( i = 0; n > 99; n -= 100, i++ ); 528: if( i > 0 ) { 529: flag0 = 1; /* 100's place of total lines */ 530: buff[0] = i + 0x30; 1.1.1.2 ! root 531: VioWrtCharStrAtt( buff, 1, PageSize, col, &attrib, 0 ); 1.1 root 532: col += 1; 533: } 534: else if( flag0 ) { 535: buff[0] = '0'; 1.1.1.2 ! root 536: VioWrtCharStrAtt( buff, 1, PageSize, col, &attrib, 0 ); 1.1 root 537: col += 1; 538: } 539: 540: for( i = 0; n > 9; n -= 10, i++ ); 541: if( i > 0 ) { 542: flag0 = 1; /* 10's place of total lines */ 543: buff[0] = i + 0x30; 1.1.1.2 ! root 544: VioWrtCharStrAtt( buff, 1, PageSize, col, &attrib, 0 ); 1.1 root 545: col += 1; 546: } 547: else if( flag0 ) { 548: buff[0] = '0'; 1.1.1.2 ! root 549: VioWrtCharStrAtt( buff, 1, PageSize, col, &attrib, 0 ); 1.1 root 550: col += 1; 551: } 552: 553: buff[0] = n + 0x30; /* 1's place of total lines */ 1.1.1.2 ! root 554: VioWrtCharStrAtt( buff, 1, PageSize, col, &attrib, 0 ); 1.1 root 555: 556: col +=1; 557: n = LINESIZE - col; /* fill rest of line with blanks; n is how many */ 558: for( i = 0; i < LINESIZE; buff[i] = ' ', i++ ); 1.1.1.2 ! root 559: VioWrtCharStrAtt( buff, n, PageSize, col, &attrib, 0 ); 1.1 root 560: 561: } 562: 563: /*** name25() - draws prompt and displays filename on 25th line 564: * 565: * This routine draws a prompt line with usage information about some 566: * of the less obvious function keys, and the name of the file currently 567: * being edited. Will be called at the start of execution, and whenever 568: * an error message has been displayed on the 25th line so that we need 569: * to re-draw the usage message after the error is responded to. The 570: * line25() routine takes care of the line numbers at the far right end 571: * of the line. 572: * 573: * Note that while the names of these routines refer to the 25th line, 574: * the pagesize is not hardcoded - if we are in 43 line mode, this 575: * information will appear on the 43rd line. Spacing within the line 576: * is hardcoded for an 80-column display. 577: * 578: * EFFECTS - None 579: */ 580: 581: void name25() 582: { 583: 584: static char message[51] = "^N/^B=insert above/below ^Y=delete F9=save F10=quit"; 585: char name[16]; /* for holding name of file */ 586: char attrib = Back25 + Fore25; /* attributes for message */ 587: int i, j, k; /* indexing variables */ 588: 589: 590: /* first, print usage message */ 1.1.1.2 ! root 591: VioWrtCharStrAtt( message, 51, PageSize, 0, &attrib, 0 ); 1.1 root 592: 593: 594: /* build filename string */ 595: 596: name[0] = ' '; 597: name[1] = ' '; /* some blanks at start and end */ 598: name[2] = ' '; 599: name[15] = ' '; 600: 601: for( i = 0; fname[i] != 0; i++); /* find null terminator for fname */ 602: 603: if( i > 0 ) i--; /* point i to last letter in fname */ 604: 605: for( j = i, k = 14; 606: (fname[j] != '\\') && (fname[j] != ':') && (j >= 0) && (k >= 0); 607: name[k] = fname[j], j--, k-- ); 608: /* move the file name into name[] backwards until */ 609: /* we hit a backslash, colon or start of the name */ 610: 611: for( ; k >= 0; name[k] = ' ', k-- ); /* if any room left, blank fill */ 612: 1.1.1.2 ! root 613: VioWrtCharStrAtt( name, 16, PageSize, 51, &attrib, 0 ); /* write it */ 1.1 root 614: 615: line25(); /* call the line number routine */ 616: 617: } 618: 619: 620: /*** error25(error) - displays error messages on 25th line, accepts responses 621: * 622: * error25() displays an error message on the 25th line when any of several 623: * error conditions are encountered, the type of error being passed as a 624: * parameter. In some cases we just abort; in others we accept input from 625: * the user to determine what to do next. 626: * 627: * Note that while the names of these routines refer to the 25th line, 628: * the pagesize is not hardcoded - if we are in 43 line mode, this 629: * information will appear on the 43rd line. Spacing within the line 630: * is hardcoded for an 80-column display. 631: * 632: * ENTRY - Error - an arbitrary number identifying the error encountered 633: * 634: * EFFECTS - May cause us to end execution; otherwise, none 635: */ 636: 637: void error25(error) 1.1.1.2 ! root 638: USHORT error; 1.1 root 639: { 640: static char message1[51] = "ERROR: Out of memory or can't read file "; 641: static char message2[51] = "ERROR: Unable to create backup. Continue? (y/n) "; 642: static char message3[51] = "File not found. Create? (y/n) "; 643: static char message4[51] = "ERROR: Unable to create file "; 644: static char message5[51] = "ERROR: Unable to open file - denied write access "; 645: static char message6[51] = "ERROR: Unable to open file "; 646: static char message7[51] = "ERROR: Out of memory. S = save Q = quit "; 647: static char message8[51] = "ERROR: No filename given on command line "; 648: static char message9[51] = "ERROR: Invalid argument on command line "; 649: static char message10[51] = "ERROR: Too many parameters on command line "; 650: static char message11[51] = "ERROR: Unable to save file. C = continue "; 651: static char message99[51] = "ERROR: Unknown error. Continue? (y/n) "; 1.1.1.2 ! root 652: KBDKEYINFO keydata; 1.1 root 653: char attrib = Back25 + Fore25; /* attributes for our messages */ 654: 655: 656: switch( error ) { /* take the appropriate action for the error */ 657: 658: case 1: 1.1.1.2 ! root 659: VioWrtCharStrAtt( message1, 51, PageSize, 0, &attrib, 0 ); 1.1 root 660: quit(1); 661: break; /* 1 -> print message and quit */ 662: 663: case 2: 1.1.1.2 ! root 664: VioWrtCharStrAtt( message2, 51, PageSize, 0, &attrib, 0 ); ! 665: VioSetCurPos( PageSize, 50, 0 ); 1.1 root 666: 667: while( 1 ) { /* 2 -> get a character from KBD */ 668: 1.1.1.2 ! root 669: KbdCharIn( &keydata, 0, 0 ); 1.1 root 670: 1.1.1.2 ! root 671: if( (keydata.chChar == 'y') || (keydata.chChar == 'Y') ) { 1.1 root 672: name25(); 673: break; /* if Y, go ahead */ 674: } 675: 1.1.1.2 ! root 676: else if( (keydata.chChar == 'n') || (keydata.chChar == 'N') ) { ! 677: VioWrtCharStrAtt( &keydata.chChar, 1, PageSize, 50, &attrib, 0 ); 1.1 root 678: quit(1); /* if N, quit with error */ 679: break; 680: } 681: 682: else badkey(); /* otherwise wait for another key */ 683: 684: } 685: break; 686: 687: case 3: 1.1.1.2 ! root 688: VioWrtCharStrAtt( message3, 51, PageSize, 0, &attrib, 0 ); ! 689: VioSetCurPos( PageSize, 32, 0 ); 1.1 root 690: 691: while( 1 ) { /* 3 -> get a character from KBD */ 692: 1.1.1.2 ! root 693: KbdCharIn( &keydata, 0, 0 ); 1.1 root 694: 1.1.1.2 ! root 695: if( (keydata.chChar == 'y') || (keydata.chChar == 'Y') ) { 1.1 root 696: name25(); 697: break; /* if Y, go ahead */ 698: } 699: 1.1.1.2 ! root 700: else if( (keydata.chChar == 'n') || (keydata.chChar == 'N') ) { ! 701: VioWrtCharStrAtt( &keydata.chChar, 1, PageSize, 50, &attrib, 0 ); 1.1 root 702: quit(1); /* if N, quit with error */ 703: break; 704: } 705: 706: else badkey(); /* otherwise wait for another key */ 707: 708: } 709: break; 710: 711: case 4: 1.1.1.2 ! root 712: VioWrtCharStrAtt( message4, 51, PageSize, 0, &attrib, 0 ); 1.1 root 713: quit(1); 714: break; /* 4 -> print message and quit */ 715: 716: case 5: 1.1.1.2 ! root 717: VioWrtCharStrAtt( message5, 51, PageSize, 0, &attrib, 0 ); 1.1 root 718: quit(1); 719: break; /* 5 -> print message and quit */ 720: 721: case 6: 1.1.1.2 ! root 722: VioWrtCharStrAtt( message6, 51, PageSize, 0, &attrib, 0 ); 1.1 root 723: quit(1); 724: break; /* 6 -> print message and quit */ 725: 726: case 7: 1.1.1.2 ! root 727: VioWrtCharStrAtt( message7, 51, PageSize, 0, &attrib, 0 ); ! 728: VioSetCurPos( PageSize, 44, 0 ); 1.1 root 729: 730: while( 1 ) { /* 7 -> get a character from KBD */ 731: 1.1.1.2 ! root 732: KbdCharIn( &keydata, 0, 0 ); 1.1 root 733: 1.1.1.2 ! root 734: if( (keydata.chChar == 's') || (keydata.chChar == 'S') ) { ! 735: VioWrtCharStrAtt( &keydata.chChar, 1, PageSize, 50, &attrib, 0 ); 1.1 root 736: if ( !savefile(fhandle)) { /* if S, save file and quit */ 737: freesegs(); 1.1.1.2 ! root 738: VioSetCurPos( PageSize, 0, 0 ); 1.1 root 739: quit(1); 740: } 741: else 742: error25(11); /* call error 11 if can't save */ 743: } 744: 1.1.1.2 ! root 745: else if( (keydata.chChar == 'q') || (keydata.chChar == 'Q') ) { ! 746: VioWrtCharStrAtt( &keydata.chChar, 1, PageSize, 50, &attrib, 0 ); 1.1 root 747: quit(1); /* if Q, quit with error */ 748: break; 749: } 750: 751: else badkey(); /* otherwise wait for another key */ 752: 753: } 754: break; 755: 756: case 8: 1.1.1.2 ! root 757: VioWrtCharStrAtt( message8, 51, PageSize, 0, &attrib, 0 ); 1.1 root 758: quit(1); 759: break; /* 8 -> print message and quit */ 760: 761: case 9: 1.1.1.2 ! root 762: VioWrtCharStrAtt( message9, 51, PageSize, 0, &attrib, 0 ); 1.1 root 763: quit(1); 764: break; /* 9 -> print message and quit */ 765: 766: case 10: 1.1.1.2 ! root 767: VioWrtCharStrAtt( message10, 51, PageSize, 0, &attrib, 0 ); 1.1 root 768: quit(1); 769: break; /* 10 -> print message and quit */ 770: 771: case 11: 1.1.1.2 ! root 772: VioWrtCharStrAtt( message11, 51, PageSize, 0, &attrib, 0 ); ! 773: VioSetCurPos( PageSize, 45, 0 ); 1.1 root 774: 775: while( 1 ) { /* 11 -> get a character from KBD */ 776: 1.1.1.2 ! root 777: KbdCharIn( &keydata, 0, 0 ); 1.1 root 778: 1.1.1.2 ! root 779: if( (keydata.chChar == 'c') || (keydata.chChar == 'C') ) { 1.1 root 780: name25(); 781: break; /* C means continue */ 782: } 783: else badkey(); /* otherwise wait for another key */ 784: 785: } 786: break; 787: 788: default: 1.1.1.2 ! root 789: VioWrtCharStrAtt( message99, 51, PageSize, 0, &attrib, 0 ); ! 790: VioSetCurPos( PageSize, 40, 0 ); 1.1 root 791: 792: while( 1 ) { /* UNKNOWN error number! */ 793: /* get a character from KBD */ 1.1.1.2 ! root 794: KbdCharIn( &keydata, 0, 0 ); 1.1 root 795: 1.1.1.2 ! root 796: if( (keydata.chChar == 'y') || (keydata.chChar == 'Y') ) { 1.1 root 797: name25(); 798: break; /* if Y, go ahead */ 799: } 800: 1.1.1.2 ! root 801: else if( (keydata.chChar == 'n') || (keydata.chChar == 'N') ) { ! 802: VioWrtCharStrAtt( &keydata.chChar, 1, PageSize, 50, &attrib, 0 ); 1.1 root 803: quit(1); /* if N, quit with error */ 804: break; 805: } 806: 807: else badkey(); /* otherwise wait for another key */ 808: 809: } 810: break; 811: 812: } 813: 814: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.