void Int16Handler(struct Registers * registers) { //Call the function for this function code switch(registers->r_ax.b.h) { //int 0x16/ah=0x00: Get keystroke //int 0x16/ah=0x10: Get enhanced keystroke case 0x00: case 0x10: GetKeystroke(registers); break; //int 0x16/ah=0x01: Check for keystroke //int 0x16/ah=0x11: Check for enhanced keystroke case 0x01: case 0x11: CheckForKeystroke(registers); break; //int 0x16/ah=0x02: Get shift flags case 0x02: //Return the shift flags from the BDA registers->r_ax.b.l = *(Byte far *)MK_FP(BDA_SEG, BDA_KEYBOARD_FLAGS0); break; //int 0x16/ah=0x03: Set typematic rate and delay - Unimplemented case 0x03: break; //int 0x16/ah=0x6f: HP Vectra functions, selected by al - None supported case 0x6f: break; } }
void client_main_loop (void) { int quit = 0; int engine_updated = 0; /* Set up the game */ reset_start_time (); update_avail_modules (0); screen_full_refresh (); if (no_init_help == 0) { block_help_exit = 1; help_flag = 1; if (make_dir_ok_flag) { activate_help ("ask-dir.hlp"); make_dir_ok_flag = 0; } else { activate_help ("opening.hlp"); } } /* Set speed */ #if defined (CS_PROFILE) || defined (START_FAST_SPEED) select_fast (); #else select_medium (); #endif /* Main Loop */ do { int key; /* Get timestamp for this iteration */ get_real_time(); /* Process events */ #if defined (LC_X11) call_event (); key = x_key_value; x_key_value = 0; #elif defined (WIN32) call_event (); key = GetKeystroke (); #else mouse_update (); key = vga_getkey (); #endif /* nothing happened if key == 0 XXX: right? */ /* GCS: I'm not sure */ if (key != 0) { process_keystrokes (key); } /* Simulate the timestep */ quit = execute_timestep (); } while (quit == 0); }
void si_scroll_text (void) { char s[LC_PATH_MAX], line1[100], line2[100], line3[100], c; int i, t, l1c = 0, l2c = 0, l3c = 0; FILE *inf1, *inf2, *inf3; #ifdef LC_X11 XEvent xev; #endif Fgl_enableclipping (); sprintf (s, "%s%c%s", opening_path, PATH_SLASH, "text1"); if ((inf1 = fopen (s, "rb")) == NULL) do_error ("Can't open opening/text1"); for (i = 0; i < 52; i++) line1[i] = si_next_char (inf1); line1[52] = 0; sprintf (s, "%s%c%s", opening_path, PATH_SLASH, "text2"); if ((inf2 = fopen (s, "rb")) == NULL) do_error ("Can't open opening/text2"); for (i = 0; i < 52; i++) line2[i] = si_next_char (inf2); line2[52] = 0; sprintf (s, "%s%c%s", opening_path, PATH_SLASH, "text3"); if ((inf3 = fopen (s, "rb")) == NULL) do_error ("Can't open opening/text3"); for (i = 0; i < 52; i++) line3[i] = si_next_char (inf3); line3[52] = 0; do { get_real_time (); t = real_time + SPLASH_SCROLL_DELAY; #ifdef LC_X11 if (XPending (display.dpy)) { XNextEvent (display.dpy, &xev); HandleEvent (&xev); } c = x_key_value; #elif defined (WIN32) c = GetKeystroke (); #elif defined LC_SVGA c = vga_getkey (); #endif if (l1c >= 8) { for (i = 0; i < 51; i++) line1[i] = line1[i + 1]; line1[51] = si_next_char (inf1); l1c = 0; } Fgl_setfont (8, 8, start_font1); Fgl_setclippingwindow (120, 30, 520, 40); Fgl_setfontcolors (SI_BLACK, SI_RED); #if defined (LC_X11) || defined (WIN32) open_write (120 - l1c, 31, line1); #else Fgl_write (120 - l1c, 31, line1); #endif l1c++; if (l2c >= 8) { for (i = 0; i < 51; i++) line2[i] = line2[i + 1]; line2[51] = si_next_char (inf2); l2c = 0; } Fgl_setfont (8, 16, start_font2); Fgl_setclippingwindow (120, 55, 520, 73); Fgl_setfontcolors (SI_BLACK, SI_GREEN); #if defined (LC_X11) || defined (WIN32) open_write (120 - l2c, 57, line2); #else Fgl_write (120 - l2c, 57, line2); #endif l2c += 2; if (l3c >= 8) { for (i = 0; i < 51; i++) line3[i] = line3[i + 1]; line3[51] = si_next_char (inf3); l3c = 0; } Fgl_setfont (8, 16, start_font3); Fgl_setclippingwindow (120, 88, 520, 106); Fgl_setfontcolors (SI_BLACK, SI_YELLOW); #if defined (LC_X11) || defined (WIN32) open_write (120 - l3c, 90, line3); #else Fgl_write (120 - l3c, 90, line3); #endif l3c += 2; #if defined (WIN32) /* Scroll a little faster for WIN32 */ if (pix_double) { l1c += 10; l2c += 10; l3c += 10; } else { l1c += 2; l2c += 4; l3c += 4; } #endif while (real_time < t) { lc_usleep (1); get_real_time (); } } while (c == 0); fclose (inf1); fclose (inf2); fclose (inf3); Fgl_disableclipping (); }
uint MenuPanel ( register panel_t *panel ) { int key = ESCAPE, choice; uint row = panel->box.row, column = panel->box.column, max_string_length; char **line = panel->text_line; bool finished = FALSE; ShowPanel ( panel ); if ( panel->box.number_of_text_rows == 0 ) { return key; /* early exit */ } max_string_length = panel->box.row_length; if ( panel->control & HAS_BORDER ) { ++row; ++column; max_string_length -= 2; } choice = ValidatePanelChoice ( panel, DOWN_CURSOR ); ReverseAttributes ( row + choice, column, max_string_length, 1 ); if ( line [choice][0] == NOT_SELECTABLE_CHAR ) { /* none selectable */ finished = TRUE; } while ( ! finished ) { key = GetKeystroke (); switch ( key ) { case UP_CURSOR: if ( choice > 0 ) { ReverseAttributes ( row + choice, column, max_string_length, 1 ); --panel->choice; choice = ValidatePanelChoice ( panel, UP_CURSOR ); ReverseAttributes ( row + choice, column, max_string_length, 1 ); } break; case DOWN_CURSOR: if ( line [choice + 1] ) { ReverseAttributes ( row + choice, column, max_string_length, 1 ); ++panel->choice; choice = ValidatePanelChoice ( panel, DOWN_CURSOR ); ReverseAttributes ( row + choice, column, max_string_length, 1 ); } break; case HELP: if ( panel->help.routine ) { panel->help.routine ( panel ); } break; default: finished = TRUE; } } panel->choice = choice; /* update it */ return key; }
uint ScrollingPanel ( panel_t *panel ) { int key = ESCAPE; uint row = panel->box.row, row_count, number_of_text_rows, save_control, column = panel->box.column; char **original_text_line = panel->text_line, **top_line = panel->text_line, **bottom_line; bool finished = FALSE; SetPanelSize ( panel ); number_of_text_rows = panel->box.number_of_text_rows; if ( number_of_text_rows == 0 ) { return key; /* early exit */ } save_control = panel->control; if ( panel->control & HAS_BORDER ) { ++row; ++column; } if ( panel->control & IS_SCROLLABLE ) { panel->control |= SHOW_SCROLL_BAR; } else { panel->control &= ~SHOW_SCROLL_BAR; } panel->text_line = top_line; bottom_line = top_line; for ( row_count = 1; row_count < number_of_text_rows; ++row_count ) { if ( *(bottom_line + 1) ) { ++bottom_line; } else { break; } } ShowPanel ( panel ); panel->control &= ~SHOW_NON_TEXT_ITEMS; /* just need to show text */ while ( ! finished ) { key = GetKeystroke (); switch ( key ) { case UP_CURSOR: if ( top_line > original_text_line ) { --top_line; --bottom_line; } break; case DOWN_CURSOR: if ( *(bottom_line + 1) ) { ++top_line; ++bottom_line; } break; case DOWNPAGE: row_count = 0; for ( ; *bottom_line; ++bottom_line, ++top_line ) { if ( ++row_count >= number_of_text_rows ) { break; /* last window line */ } if ( ! *(bottom_line + 1) ) { /* no more lines */ break; } } break; case UPPAGE: row_count = 0; while ( top_line > original_text_line ) { if ( ++row_count >= number_of_text_rows ) { break; /* 1 page of lines */ } --top_line; --bottom_line; } break; case TOP_OF_FILE: while ( top_line > original_text_line ) { --top_line; --bottom_line; } break; case END_OF_FILE: while ( *(bottom_line + 1) ) { ++top_line; ++bottom_line; } break; case ESCAPE: finished = TRUE; break; case HELP: if ( panel->help.routine ) { panel->help.routine ( panel ); } break; } panel->text_line = top_line; ShowPanel ( panel ); } panel->text_line = original_text_line; /* restore values */ panel->control = save_control; return key; }
int ScrollingMenuPanel ( register panel_t *panel ) { int key = ESCAPE, direction; uint row, row_count, max_string_length, number_of_text_rows, save_control, save_border_attribute = panel->box.border_attribute, column; char **original_text_line = panel->text_line, **top_line, **current_line, **bottom_line; bool finished = FALSE; uint (* _System callback) (panel_t *panel) = panel->callback; if ( panel->control & INITIALIZE_PANEL ) { panel->control &= ~INITIALIZE_PANEL; top_line = original_text_line; while ( *top_line && **top_line == NOT_SELECTABLE_CHAR ) { if ( *++top_line == NULL ) { --top_line; break; } } panel->top_line = top_line; panel->current_line = top_line; } SetPanelSize ( panel ); number_of_text_rows = panel->box.number_of_text_rows; if ( number_of_text_rows == 0 ) { return key; /* early exit */ } if ( panel->control & HIGHLIGHT_BORDER_LINE ) { panel->box.border_attribute |= HIGHLIGHTED_FG; } save_control = panel->control; if ( panel->control & IS_SCROLLABLE ) { panel->control |= SHOW_SCROLL_BAR; } else { panel->control &= ~SHOW_SCROLL_BAR; } row = panel->box.row; column = panel->box.column; top_line = panel->top_line; current_line = panel->current_line; max_string_length = panel->box.row_length; if ( panel->control & HAS_BORDER ) { ++row; ++column; max_string_length -= 2; } panel->text_line = top_line; bottom_line = top_line; for ( row_count = 1; row_count < number_of_text_rows; ++row_count ) { if ( *(bottom_line + 1) ) { ++bottom_line; } else { break; } } ShowPanel ( panel ); panel->control &= ~SHOW_NON_TEXT_ITEMS; /* just need to show text */ if ( panel->control & HAS_NON_SELECTABLE_LINE ) { panel->control |= SHOW_ATTRIBUTES; } if ( callback ) { panel->text_line = original_text_line; /* restore value */ panel->choice = current_line - original_text_line; callback ( panel ); } row += current_line - top_line; ReverseAttributes ( row, column, max_string_length, 1 ); /* on */ while ( ! finished ) { key = GetKeystroke (); ReverseAttributes ( row, column, max_string_length, 1 ); /* off */ switch ( key ) { case UP_CURSOR: if ( current_line > original_text_line ) { if ( current_line == top_line ) { --top_line; --bottom_line; } else { --row; } --current_line; } direction = UP_CURSOR; break; case DOWN_CURSOR: if ( *(current_line + 1) ) { if ( current_line == bottom_line ) { ++top_line; ++bottom_line; } else { ++row; } ++current_line; } direction = DOWN_CURSOR; break; case DOWNPAGE: row_count = 1; for ( ; row_count < number_of_text_rows; ++row_count ) { if ( ! *(bottom_line + 1) ) { /* no more lines */ break; } ++top_line; ++bottom_line; ++current_line; } direction = DOWN_CURSOR; break; case UPPAGE: row_count = 0; while ( top_line > original_text_line ) { if ( ++row_count >= number_of_text_rows ) { break; /* 1 page of lines */ } --top_line; --bottom_line; --current_line; } direction = UP_CURSOR; break; case TOP_OF_FILE: while ( top_line > original_text_line ) { --top_line; --bottom_line; --current_line; } while ( current_line > top_line ) { --current_line; --row; } direction = UP_CURSOR; break; case END_OF_FILE: while ( *(bottom_line + 1) ) { ++top_line; ++bottom_line; ++current_line; } while ( current_line < bottom_line ) { ++current_line; ++row; } direction = DOWN_CURSOR; break; case HELP: if ( panel->help.routine ) { panel->help.routine ( panel ); } direction = 0; break; default: direction = 0; finished = TRUE; } switch ( direction ) { /* skip over non-selectable lines */ case UP_CURSOR: while ( **current_line == NOT_SELECTABLE_CHAR ) { if ( current_line > original_text_line ) { if ( current_line == top_line ) { --top_line; --bottom_line; } else { --row; } --current_line; } else { break; } } while ( **current_line == NOT_SELECTABLE_CHAR ) { if ( *(current_line + 1) ) { if ( current_line == bottom_line ) { ++top_line; ++bottom_line; } else { ++row; } ++current_line; } else { break; } } break; case DOWN_CURSOR: while ( **current_line == NOT_SELECTABLE_CHAR ) { if ( *(current_line + 1) ) { if ( current_line == bottom_line ) { ++top_line; ++bottom_line; } else { ++row; } ++current_line; } else { break; } } while ( **current_line == NOT_SELECTABLE_CHAR ) { if ( current_line > original_text_line ) { if ( current_line == top_line ) { --top_line; --bottom_line; } else { --row; } --current_line; } else { break; } } break; default: ; } if ( panel->top_line != top_line ) { panel->top_line = top_line; panel->text_line = top_line; ShowPanel ( panel ); } ReverseAttributes ( row, column, max_string_length, 1 ); /* on */ if ( ! finished ) { if ( callback ) { panel->text_line = original_text_line; /* restore values */ panel->top_line = top_line; /* update values */ panel->current_line = current_line; panel->choice = current_line - original_text_line; callback ( panel ); } } } panel->top_line = top_line; /* update values */ panel->current_line = current_line; panel->choice = current_line - original_text_line; panel->control = save_control; /* restore values */ panel->box.border_attribute = save_border_attribute; panel->text_line = original_text_line; if ( panel->control & TURN_OFF_LIGHT_BAR ) { ReverseAttributes ( row, column, max_string_length, 1 ); /* off */ } if ( panel->control & HIGHLIGHT_BORDER_LINE ) { ShowOutline ( &panel->box ); } return key; }
uint UserDefinedMenuPanel ( register panel_t *panel, uint count_menu_items, /* number of menu items */ uint *menu_item_action, /* pointer to array of menu item action */ char char_for_selection1, /* character to show selected menu item */ char char_for_selection2) /* character to show selected menu item */ { int key = 0, i; uint row = panel->box.row, column = panel->box.column, max_string_length; uint *action; char **line = panel->text_line; uint (* _System callback) (panel_t *panel) = panel->callback; bool finished = FALSE; uint grayed_attribute, normal_attribute; ShowPanel ( panel ); if ( panel->box.number_of_text_rows == 0 ) { return key; /* early exit */ } max_string_length = panel->box.row_length; if ( panel->control & HAS_BORDER ) { ++row; ++column; max_string_length -= 2; } if (callback == NULL) /* must have callback routine */ finished = TRUE; grayed_attribute = normal_attribute = panel->box.attribute; if ( grayed_attribute & HIGHLIGHTED_FG ) { grayed_attribute &= ~HIGHLIGHTED_FG; /* just dim it */ } else { grayed_attribute &= 0xF0; /* zero foreground */ grayed_attribute |= GRAY_FG; /* make it gray */ } while ( ! finished ) { switch ( key ) { case HELP: if ( panel->help.routine ) { panel->help.routine ( panel ); } break; /* case UP_CURSOR: */ /* case DOWN_CURSOR: */ /* case SPACE: */ default: /* call back */ if (key) { panel->choice = (uint)key; /* notify caller a key was pressed */ finished = (bool)callback(panel); /* callback routine must update "choice" */ } /* the caller must set the state for each of the menu items */ for (i=0, action=menu_item_action; i<count_menu_items; i++, action++) { if (*action & ACTION_NONE) continue; /* leave the menu item as is */ if (*action & ACTION_REDRAW) /* redraw this menu item */ DisplayString ( line[i], row+i, column, max_string_length ); if (*action & ACTION_DESELECT) { DisplayChars(' ', row+i, column, 1, 1); if (char_for_selection2) DisplayChars(' ', row+i, column + strlen(line[i])-1, 1, 1); } if (*action & ACTION_SELECT) { DisplayChars(char_for_selection1, row+i, column, 1, 1); if (char_for_selection2) DisplayChars(char_for_selection2, row+i, column + strlen(line[i])-1, 1, 1); } if (*action & ACTION_SET_NOT_SELECTABLE) DisplayAttributes (row+i, column, max_string_length, 1, grayed_attribute ); if (*action & ACTION_SET_SELECTABLE) DisplayAttributes (row+i, column, max_string_length, 1, normal_attribute ); if (*action & (ACTION_HIGHLIGHT | ACTION_UNHIGHLIGHT)) ReverseAttributes ( row+i, column, max_string_length, 1); } break; } if (! finished) key = GetKeystroke (); } return key; }
// process a single INI file static int IniFProc(LPTSTR fname, INIFILE *InitData, unsigned int fIgnoreSection) { LPTSTR arg; unsigned int line_num, SecFound = 0, CurrentSec = 0; int fh, nReturn = 0; TCHAR szBuffer[2048]; LPTSTR errmsg; if ( ++nNestLevel > MAX_INI_NEST ) { ini_error( E_NEST, InitData, fname, 1, NULLSTR ); nReturn = -1; goto IFProcExit; } // force ignore of sections that aren't ours fIgnoreSection |= 0x100; // open the INI file if ((fh = _sopen(fname, (O_RDONLY | O_BINARY), SH_DENYWR)) < 0) { nReturn = -1; goto IFProcExit; } // loop to process each line for ( line_num = 1; ( getline( fh, szBuffer, 2047, 0 ) > 0 ); line_num++ ) { // skip line if empty or all comment arg = skipspace( szBuffer ); if ((*arg == _TEXT('\0')) || (*arg == _TEXT(';'))) continue; // query if it was requested if ( InitData->INIQuery != 0 ) { WriteTTY(szBuffer); WriteTTY(INI_QUERY); query_prompt: switch (GetKeystroke(EDIT_BIOS_KEY | EDIT_ECHO | EDIT_ECHO_CRLF | EDIT_UC_SHIFT)) { case YES_CHAR: break; case NO_CHAR: continue; case INI_QUIT_CHAR: goto ini_done; case REST_CHAR: InitData->INIQuery = 0; break; case INI_EDIT_CHAR: egets( szBuffer, 2047, EDIT_BIOS_KEY | EDIT_ECHO ); break; default: qputc( STDOUT, BS ); honk(); goto query_prompt; } } // process the line, holler if any error if ((nReturn = IniLine(szBuffer, InitData, (fIgnoreSection & CurrentSec), 0, &errmsg)) > 0) ini_error( errmsg, InitData, fname, line_num , szBuffer ); // if no error, see if we have an included file to process else if (nReturn == -1) { // call ourselves recursively to process the included file if ( is_file( szBuffer )) (void)IniFProc( szBuffer, InitData, fIgnoreSection); else ini_error( E_INCL, InitData, fname, line_num, szBuffer ); // if no error, see if we found a section name } else if (nReturn < 0) { CurrentSec = -nReturn; // save section bit if section is one of ours if (CurrentSec & 0xFF) SecFound |= CurrentSec; } } ini_done: InitData->SecFlag = SecFound; // save sections found _close(fh); nReturn = 0; IFProcExit: --nNestLevel; return nReturn; }
// print the file on the default printer void ListPrintFile( void ) { register int i, n; int c, nRows, nBytesPrinted, nFH; long lTemp; POPWINDOWPTR wn; TCHAR szBuffer[MAXLISTLINE+1]; int fKBHit; // disable ^C / ^BREAK handling HoldSignals(); wn = wOpen( 2, 1, 4, strlen( LIST_PRINTING ) + 8, nInverse, LIST_PRINT_TITLE, NULL ); wn->nAttrib = nNormal; wClear(); sprintf( szBuffer, LIST_QUERY_PRINT, LIST_PRINT_FILE_CHAR, LIST_PRINT_PAGE_CHAR ); wWriteListStr( 0, 1, wn, szBuffer ); if ((( c = GetKeystroke( EDIT_ECHO | EDIT_UC_SHIFT | EDIT_BIOS_KEY )) == LIST_PRINT_FILE_CHAR ) || ( c == LIST_PRINT_PAGE_CHAR )) { // save start position lTemp = LFile.lViewPtr; // display "Printing ..." wWriteListStr( 0, 1, wn, LIST_PRINTING ); if (( nFH = _sopen((( gpIniptr->Printer != INI_EMPTYSTR ) ? gpIniptr->StrData + gpIniptr->Printer : _TEXT("LPT1") ), (_O_BINARY | _O_WRONLY | _O_CREAT), _SH_DENYNO, _S_IWRITE | _S_IREAD )) >= 0 ) { if ( setjmp( cv.env ) == -1 ) { _close( nFH ); return; } // reset to beginning of file if ( c == LIST_PRINT_FILE_CHAR ) ListSetCurrent( 0L ); else { nRows = GetScrRows(); ListSetCurrent( LFile.lViewPtr ); } // print the header (filename, date & time) qprintf( nFH, _TEXT("%s %s %s\r\n\r\n"), LFile.szName, gdate( 0 ), gtime( gaCountryInfo.fsTimeFmt ) ); do { // abort printing if a key is hit // kbhit() in DOS tries to read from STDIN, which screws // up a LIST /S pipe _asm { mov ah, 1 int 16h mov fKBHit, 1 jnz KBHDone mov fKBHit, 0 KBHDone: } if ( fKBHit && ( GetKeystroke( EDIT_NO_ECHO | EDIT_BIOS_KEY ) == ESC )) break; i = FormatLine( szBuffer, MAXLISTLINE, LFile.lViewPtr, &nBytesPrinted, TRUE ); LFile.lViewPtr += 16; // replace 0-31 with "." if ( lListFlags & LIST_HEX ) { for ( n = 0; ( n < i ); n++ ) { if ( szBuffer[n] < 32 ) szBuffer[n] = _TEXT('.'); } } if (( c == LIST_PRINT_PAGE_CHAR ) && ( nRows-- <= 0 )) break; } while (( nBytesPrinted > 0 ) && ( qprintf( nFH, _TEXT("%.*s\r\n"), i, szBuffer ) > 0 )); // print a formfeed qputc( nFH, _TEXT('\014') ); _close( nFH ); // restore start position LFile.lViewPtr = lTemp; ListSetCurrent( LFile.lViewPtr ); } else honk(); } wRemove( wn ); // enable ^C / ^BREAK handling EnableSignals(); }
static int _fastcall _list( LPTSTR pszFileName ) { register int c, i; TCHAR szDescription[512], szHeader[132], szLine[32]; long lTemp, lRow; POPWINDOWPTR wn = NULL; FILESEARCH dir; // get default normal and inverse attributes if ( gpIniptr->ListColor != 0 ) { SetScrColor( nScreenRows, nScreenColumns, gpIniptr->ListColor ); } // set colors GetAtt( (unsigned int *)&nNormal, (unsigned int *)&nInverse ); if ( gpIniptr->ListStatusColor != 0 ) nInverse = gpIniptr->ListStatusColor; // flip the first line to inverse video clear_header(); // open the file & initialize buffers if ( ListOpenFile( pszFileName )) return ERROR_EXIT; // kludge for empty files or pipes if ( LFile.lSize == 0L ) LFile.lSize = 1L; for ( ; ; ) { // display header if ( fDirtyHeader ) { clear_header(); sprintf( szHeader, LIST_HEADER, fname_part(LFile.szName), gchVerticalBar, gchVerticalBar, gchVerticalBar ); WriteStrAtt( 0, 0, nInverse, szHeader ); fDirtyHeader = 0; } // display location within file // (don't use color_printf() so we won't have // problems with windowed sessions) i = sprintf( szHeader, LIST_LINE, LFile.nListHorizOffset, LFile.lCurrentLine + gpIniptr->ListRowStart, (int)((( LFile.lViewPtr + 1 ) * 100 ) / LFile.lSize )); WriteStrAtt( 0, ( nScreenColumns - i ), nInverse, szHeader ); SetCurPos( 0, 0 ); if ( lListFlags & LIST_SEARCH ) { lListFlags &= ~LIST_SEARCH; fSearchFlags = 0; if ( lListFlags & LIST_REVERSE ) { c = LIST_FIND_CHAR_REVERSE; fSearchFlags |= FFIND_REVERSE_SEARCH; // goto the last row while ( ListMoveLine( 1 ) != 0 ) ; } else c = LIST_FIND_CHAR; if ( lListFlags & LIST_NOWILDCARDS ) fSearchFlags |= FFIND_NOWILDCARDS; bListSkipLine = 0; goto FindNext; } // get the key from the BIOS, because // STDIN might be redirected if ((( c = cvtkey( GetKeystroke( EDIT_NO_ECHO | EDIT_BIOS_KEY | EDIT_UC_SHIFT), MAP_GEN | MAP_LIST)) == (TCHAR)ESC )) break; switch ( c ) { case CTRLC: return CTRLC; case CUR_LEFT: case CTL_LEFT: if (( lListFlags & LIST_WRAP ) || ( LFile.nListHorizOffset == 0 )) goto bad_key; if (( LFile.nListHorizOffset -= (( c == CUR_LEFT ) ? 8 : 40 )) < 0 ) LFile.nListHorizOffset = 0; break; case CUR_RIGHT: case CTL_RIGHT: if (( lListFlags & LIST_WRAP ) || ( LFile.nListHorizOffset >= MAXLISTLINE + 1 )) goto bad_key; if ((LFile.nListHorizOffset += ((c == CUR_RIGHT) ? 8 : 40 )) > MAXLISTLINE + 1 ) LFile.nListHorizOffset = MAXLISTLINE+1; break; case CUR_UP: if ( ListMoveLine( -1 ) == 0 ) goto bad_key; Scroll(1, 0, nScreenRows, nScreenColumns, -1, nNormal); DisplayLine( 1, LFile.lViewPtr ); continue; case CUR_DOWN: if ( ListMoveLine( 1 ) == 0 ) goto bad_key; Scroll( 1, 0, nScreenRows, nScreenColumns, 1, nNormal ); // display last line lTemp = LFile.lViewPtr; lRow = (nScreenRows - 1); lTemp += MoveViewPtr( lTemp, &lRow ); if ( lRow == ( nScreenRows - 1 )) DisplayLine( nScreenRows, lTemp ); continue; case HOME: ListHome(); break; case END: // goto the last row list_wait( LIST_WAIT ); while ( ListMoveLine( 1 ) != 0 ) ; case PgUp: // already at TOF? if ( LFile.lViewPtr == 0L ) goto bad_key; for ( i = 1; (( i < nScreenRows ) && ( ListMoveLine( -1 ) != 0 )); i++ ) ; break; case PgDn: case SPACE: if ( ListMoveLine( nScreenRows - 1 ) == 0 ) goto bad_key; break; case F1: // help // don't allow a ^X exit from HELP _help( gpInternalName, HELP_NX ); continue; case TAB: // change tab size // disable ^C / ^BREAK handling HoldSignals(); wn = wOpen( 2, 5, 4, strlen( LIST_TABSIZE ) + 10, nInverse, LIST_TABSIZE_TITLE, NULL ); wn->nAttrib = nNormal; wClear(); wWriteListStr( 0, 1, wn, LIST_TABSIZE ); egets( szLine, 2, (EDIT_DIALOG | EDIT_BIOS_KEY | EDIT_NO_CRLF | EDIT_DIGITS)); wRemove( wn ); if (( i = atoi( szLine )) > 0 ) TABSIZE = i; // enable ^C / ^BREAK handling EnableSignals(); break; case DEL: // delete this file if (( lListFlags & LIST_STDIN ) == 0 ) { // disable ^C / ^BREAK handling HoldSignals(); wn = wOpen( 2, 5, 4, strlen( LIST_DELETE ) + 10, nInverse, LIST_DELETE_TITLE, NULL ); wn->nAttrib = nNormal; wClear(); wWriteListStr( 0, 1, wn, LIST_DELETE ); i = GetKeystroke( EDIT_ECHO | EDIT_BIOS_KEY | EDIT_UC_SHIFT ); wRemove( wn ); // enable ^C / ^BREAK handling EnableSignals(); if ( i == (TCHAR)YES_CHAR ) { if ( LFile.hHandle > 0 ) _close( LFile.hHandle ); LFile.hHandle = -1; remove( pszFileName ); return 0; } } break; case INS: // save to a file ListSaveFile(); break; case LIST_INFO_CHAR: { unsigned int uSize = 1024; TCHAR _far *lpszText, _far *lpszArg; int fFSType, fSFN = 1; TCHAR szBuf[16]; DOSFILEDATE laDir, crDir; // disable ^C / ^BREAK handling HoldSignals(); memset( &dir, '\0', sizeof(FILESEARCH) ); if (( lListFlags & LIST_STDIN ) == 0 ) { if ( find_file( FIND_FIRST, LFile.szName, 0x07 | FIND_CLOSE | FIND_EXACTLY, &dir, NULL ) == NULL ) { honk(); continue; } } // display info on the current file i = (( lListFlags & LIST_STDIN ) ? 5 : 10 ); if (( fFSType = ifs_type( LFile.szName )) != FAT ) i = 11; wn = wOpen( 2, 1, i, 77, nInverse, gpInternalName, NULL ); wn->nAttrib = nNormal; wClear(); i = 0; if ( lListFlags & LIST_STDIN ) wWriteStrAtt( 0, 1, nNormal, LIST_INFO_PIPE ); else { szDescription[0] = _TEXT('\0'); process_descriptions( LFile.szName, szDescription, DESCRIPTION_READ ); lpszText = lpszArg = (TCHAR _far *)AllocMem( &uSize ); strcpy(szBuf, FormatDate( dir.fd.file_date.months, dir.fd.file_date.days, dir.fd.file_date.years + 80, 0 )); if (fFSType != FAT) { FileTimeToDOSTime( &(dir.ftLastAccessTime), &( laDir.ft.wr_time), &( laDir.fd.wr_date) ); FileTimeToDOSTime( &(dir.ftCreationTime), &(crDir.ft.wr_time), &(crDir.fd.wr_date) ); strcpy( szLine, FormatDate( laDir.fd.file_date.months, laDir.fd.file_date.days, laDir.fd.file_date.years + 80, 0 )); sprintf_far( lpszText, LIST_INFO_LFN, LFile.szName, szDescription, dir.ulSize, szBuf, dir.ft.file_time.hours, gaCountryInfo.szTimeSeparator[0],dir.ft.file_time.minutes, szLine, laDir.ft.file_time.hours, gaCountryInfo.szTimeSeparator[0], laDir.ft.file_time.minutes, FormatDate( crDir.fd.file_date.months, crDir.fd.file_date.days, crDir.fd.file_date.years + 80, 0 ), crDir.ft.file_time.hours, gaCountryInfo.szTimeSeparator[0], crDir.ft.file_time.minutes); } else { sprintf_far( lpszText, LIST_INFO_FAT, LFile.szName, szDescription, dir.ulSize, szBuf, dir.ft.file_time.hours, gaCountryInfo.szTimeSeparator[0],dir.ft.file_time.minutes ); } // print the text for ( ; ( *lpszArg != _TEXT('\0') ); i++ ) { sscanf_far( lpszArg, _TEXT("%[^\n]%*c%n"), szHeader, &uSize ); // allow for long filenames ... if (( i == 0 ) && ( strlen( szHeader ) > 73 )) { c = szHeader[73]; szHeader[73] = _TEXT('\0'); wWriteStrAtt( i++, 1, nNormal, szHeader ); szHeader[73] = (TCHAR)c; wWriteStrAtt( i, 15, nNormal, szHeader+73 ); fSFN = 0; } else wWriteStrAtt( i, 1, nNormal, szHeader ); lpszArg += uSize; } FreeMem( lpszText ); } wWriteListStr( i+fSFN, 1, wn, PAUSE_PROMPT ); GetKeystroke( EDIT_NO_ECHO | EDIT_BIOS_KEY ); wRemove( wn ); // enable ^C / ^BREAK handling EnableSignals(); continue; } case LIST_GOTO_CHAR: // goto the specified line / hex offset // disable ^C / ^BREAK handling HoldSignals(); wn = wOpen( 2, 5, 4, strlen( LIST_GOTO_OFFSET ) + 20, nInverse, LIST_GOTO_TITLE, NULL ); wn->nAttrib = nNormal; wClear(); wWriteListStr( 0, 1, wn, (( lListFlags & LIST_HEX) ? LIST_GOTO_OFFSET : LIST_GOTO)); i = egets( szLine, 10, (EDIT_DIALOG | EDIT_BIOS_KEY | EDIT_NO_CRLF)); wRemove( wn ); // enable ^C / ^BREAK handling EnableSignals(); if ( i == 0 ) break; list_wait( LIST_WAIT ); // if in hex mode, jump to offset if ( lListFlags & LIST_HEX ) { strupr( szLine ); sscanf( szLine, _TEXT("%lx"), &lRow ); lRow = lRow / 0x10; } else if ( sscanf( szLine, FMT_LONG, &lRow ) == 0 ) continue; lRow -= gpIniptr->ListRowStart; if ( lRow >= 0 ) { LFile.lViewPtr = MoveViewPtr( 0L, &lRow ); LFile.lCurrentLine = lRow; } else { LFile.lViewPtr += MoveViewPtr( LFile.lViewPtr, &lRow ); LFile.lCurrentLine += lRow; } break; case LIST_HIBIT_CHAR: // toggle high bit filter lListFlags ^= LIST_HIBIT; break; case LIST_WRAP_CHAR: // toggle line wrap lListFlags ^= LIST_WRAP; nRightMargin = (( lListFlags & LIST_WRAP ) ? GetScrCols() : MAXLISTLINE ); // recalculate current line list_wait( LIST_WAIT ); // get start of line LFile.nListHorizOffset = 0; // line number probably changed, so recompute everything LFile.lCurrentLine = ComputeLines( 0L, LFile.lViewPtr ); LFile.lViewPtr = MoveViewPtr( 0L, &(LFile.lCurrentLine )); break; case LIST_HEX_CHAR: // toggle hex display lListFlags ^= LIST_HEX; // if hex, reset to previous 16-byte // boundary if ( lListFlags & LIST_HEX ) { LFile.lViewPtr -= ( LFile.lViewPtr % 16 ); } else { // if not hex, reset to start of line ListMoveLine( 1 ); ListMoveLine( -1 ); } // recalculate current line list_wait( LIST_WAIT ); LFile.lCurrentLine = ComputeLines( 0L, LFile.lViewPtr ); break; case LIST_FIND_CHAR: case LIST_FIND_CHAR_REVERSE: // find first matching string bListSkipLine = 0; //lint -fallthrough case LIST_FIND_NEXT_CHAR: case LIST_FIND_NEXT_CHAR_REVERSE: // find next matching string if (( c == LIST_FIND_CHAR ) || ( c == LIST_FIND_CHAR_REVERSE )) { // disable ^C / ^BREAK handling HoldSignals(); fSearchFlags = 0; wn = wOpen( 2, 1, 4, 75, nInverse, (( c == LIST_FIND_NEXT_CHAR_REVERSE ) ? LIST_FIND_TITLE_REVERSE : LIST_FIND_TITLE ), NULL ); wn->nAttrib = nNormal; wClear(); if ( lListFlags & LIST_HEX ) { wWriteListStr( 0, 1, wn, LIST_FIND_HEX ); if ( GetKeystroke( EDIT_ECHO | EDIT_BIOS_KEY | EDIT_UC_SHIFT ) == YES_CHAR ) fSearchFlags |= FFIND_HEX_SEARCH; wClear(); } wWriteListStr( 0, 1, wn, LIST_FIND ); egets( szListFindWhat, 64, (EDIT_DIALOG | EDIT_BIOS_KEY | EDIT_NO_CRLF)); wRemove( wn ); // enable ^C / ^BREAK handling EnableSignals(); } else { FindNext: // a "Next" has to be from current position fSearchFlags &= ~FFIND_TOPSEARCH; } if ( szListFindWhat[0] == _TEXT('\0') ) continue; sprintf( szDescription, LIST_FIND_WAIT, szListFindWhat ); list_wait( szDescription ); // save start position lTemp = LFile.lViewPtr; lRow = LFile.lCurrentLine; if (( c == LIST_FIND_CHAR_REVERSE ) || ( c == LIST_FIND_NEXT_CHAR_REVERSE )) { // start on the previous line fSearchFlags |= FFIND_REVERSE_SEARCH; } else { fSearchFlags &= ~FFIND_REVERSE_SEARCH; // skip the first line (except on /T"xxx") if ( bListSkipLine ) ListMoveLine( 1 ); } bListSkipLine = 1; if ( SearchFile( fSearchFlags ) != 1 ) { ListSetCurrent( lTemp ); LFile.lViewPtr = lTemp; LFile.lCurrentLine = lRow; } else LFile.fDisplaySearch = (( fSearchFlags & FFIND_CHECK_CASE ) ? 2 : 1 ); break; case LIST_PRINT_CHAR: // print the file ListPrintFile(); continue; case LIST_CONTINUE_CHAR: case CTL_PgDn: return 0; case LIST_PREVIOUS_CHAR: case CTL_PgUp: // previous file if ( nCurrent > 0 ) { nCurrent--; return 0; } //lint -fallthrough default: bad_key: honk(); continue; } // rewrite the display ListUpdateScreen(); } return 0; }