📄 console.c
字号:
{union REGS inregs, outregs; inregs.h.ah = 5; inregs.h.al = payg; int86( VIDEO_INT, &inregs, &outregs );}/* * Name: xygoto * Purpose: To move the cursor to the required column and line. * Date: September 28, 1991 * Passed: col: desired column (0 up to max) * line: desired line (0 up to max) * Notes: use standard BIOS video interrupt 0x10 to set the set. * * jmh 991026: (-1, -1) doesn't work for (my) 132-column mode. Use one * more than the screen height, instead. */void xygoto( int col, int line ){union REGS inregs, outregs; if (col < 0 || line < 0) { col = 0; line = g_display.nlines; } inregs.h.ah = 2; inregs.h.bh = 1; /* jmh - the editor is on page 1 */ inregs.h.dh = (unsigned char)line; inregs.h.dl = (unsigned char)col; int86( VIDEO_INT, &inregs, &outregs );}/* * Name: display_line * Purpose: display a line in the file * Author: Jason Hood * Date: October 27, 1999 * Passed: text: characters to display * attr: attributes to use * len: length to display * line: row of display * col: column of display * Notes: all parameters are assumed valid. */void display_line( text_ptr text, unsigned char *attr, int len, int line, int col ){unsigned long screen_ptr = SCREEN_PTR( line, col ); _farsetsel( _dos_ds ); do { _farnspokew( screen_ptr, *text++ | (*attr++ << 8) ); screen_ptr += 2; } while (--len != 0);}/* * Name: c_output * Purpose: Output one character * Date: June 5, 1991 * Passed: c: character to output to screen * col: col to display character * line: line number to display character * attr: attribute of character * Returns: none */void c_output( int c, int col, int line, int attr ){ _farpokew( _dos_ds, SCREEN_PTR( line, col ), (unsigned char)c | (attr << 8) );}/* * Name: c_repeat * Purpose: Output one character many times * Author: Jason Hood * Date: November 18, 2003 * Passed: c: character to output to screen * cnt: number of times to output it * col: column to display character * line: line number to display character * attr: attribute of character * Notes: if the count is negative, repeat the row, not the column. */void c_repeat( int c, int cnt, int col, int line, int attr ){unsigned long screen_ptr;int max;int ofs; if (cnt < 0) { cnt = -cnt; max = g_display.nlines - line; ofs = g_display.ncols * 2; } else { max = g_display.ncols - col; ofs = 2; } if (cnt > max) cnt = max; if (cnt > 0) { _farsetsel( _dos_ds ); screen_ptr = SCREEN_PTR( line, col ); c = (unsigned char)c | (attr << 8); do { _farnspokew( screen_ptr, c ); screen_ptr += ofs; } while (--cnt != 0); }}/* * Name: s_output * Purpose: To output a string * Date: June 5, 1991 * Passed: s: string to output * line: line to display * col: column to begin display * attr: color to display string * Notes: This function is used to output most strings not part of file text. * * 991023: Possibly output an extra space before and after. */void s_output( const char *s, int line, int col, int attr ){unsigned long screen_ptr = SCREEN_PTR( line, col );int max_col = g_display.ncols; attr <<= 8; _farsetsel( _dos_ds ); if (g_display.output_space && col != 0) _farnspokew( screen_ptr - 2, ' ' | attr ); while (*s && col++ < max_col) { _farnspokew( screen_ptr, (unsigned char)*s++ | attr ); screen_ptr += 2; } if (g_display.output_space && col != max_col) _farnspokew( screen_ptr, ' ' | attr );}/* * Name: hlight_line * Date: July 21, 1991 * Passed: x: column to begin hi lite * y: line to begin hi lite * lgth: number of characters to hi lite * attr: attribute color * Notes: The attribute byte is the hi byte. */void hlight_line( int x, int y, int lgth, int attr ){unsigned long screen_ptr = SCREEN_PTR( y, x ) + 1; _farsetsel( _dos_ds ); do { _farnspokeb( screen_ptr, attr ); screen_ptr += 2; } while (--lgth != 0);}/* * Name: cls * Purpose: clear screen * Date: June 5, 1991 * Notes: Call the video BIOS routine to clear the screen. */void cls( void ){union REGS regs; regs.w.cx = 0; /* starting row/column = 0 */ regs.h.dh = g_display.nlines - 1; /* ending row */ regs.h.dl = g_display.ncols - 1; /* ending column */ regs.h.bh = Color( Text ); /* attribute (jmh 990414) */ regs.h.al = 0; /* get number of lines */ regs.h.ah = 6; /* get function number */ int86( VIDEO_INT, ®s, ®s );}/* * Name: set_cursor_size * Purpose: To set cursor size according to insert mode. * Date: June 5, 1991 * Passed: csize: desired cursor size * Notes: use the global display structures to set the cursor size */void set_cursor_size( int csize ){union REGS regs; regs.h.ah = 1; /* function 1 - set cursor size */ regs.w.cx = csize; /* get cursor size ch:cl == top:bot */ int86( VIDEO_INT, ®s, ®s );}/* * Name: set_overscan_color * Purpose: To set overscan color * Date: April 1, 1993 * Passed: color: overscan color * Notes: before setting the overscan color, the old overscan color * needs to be saved so it can be restored. */void set_overscan_color( int color ){union REGS regs; regs.h.ah = 0x0b; regs.h.bl = color; regs.h.bh = 0; int86( VIDEO_INT, ®s, ®s );}/* * Name: save_screen_line * Purpose: To save the characters and attributes of a line on screen. * Date: June 5, 1991 * Passed: col: desired column, usually always zero * line: line on screen to save (0 up to max) * screen_buffer: buffer for screen contents, must be >= 160 chars * Notes: Save the contents of the line on screen where prompt is * to be displayed */void save_screen_line( int col, int line, Char *screen_buffer ){ dosmemget( SCREEN_PTR( line, col ), g_display.ncols * 2, screen_buffer );}/* * Name: restore_screen_line * Purpose: To restore the characters and attributes of a line on screen. * Date: June 5, 1991 * Passed: col: usually always zero * line: line to restore (0 up to max) * screen_buffer: buffer for screen contents, must be >= 160 chars * Notes: Restore the contents of the line on screen where the prompt * was displayed */void restore_screen_line( int col, int line, Char *screen_buffer ){ dosmemput( screen_buffer, g_display.ncols * 2, SCREEN_PTR( line, col ) );}/* * Name: save_area * Purpose: save text and attribute * Date: July 25, 1997 * Passed: buffer: storage for text and attribute * wid: width to save * len: length to save * row: starting row of save * col: starting column of save * * 991023: I should point out that the buffer should be (at least) * (wid + 4) * (len + 1) * sizeof(Char) bytes. */void save_area( Char *buffer, int wid, int len, int row, int col ){unsigned long pointer;int w;int cols = g_display.ncols * 2; adjust_area( &wid, &len, &row, &col, NULL ); w = wid * 2; pointer = display_address + row * cols + col * 2; do { dosmemget( pointer, w, buffer ); buffer += wid; pointer += cols; } while (--len != 0);}/* * Name: restore_area * Purpose: restore text and attribute * Date: July 25, 1997 * Passed: buffer: storage for text and attribute * wid: width to restore * len: length to restore * row: starting row for restore * col: starting column for restore * * 991023: I should point out that these parameters should be identical * to those used in the corresponding save_area(). */void restore_area( Char *buffer, int wid, int len, int row, int col ){unsigned long pointer;int w;int cols = g_display.ncols * 2; adjust_area( &wid, &len, &row, &col, NULL ); w = wid * 2; pointer = display_address + row * cols + col * 2; do { dosmemput( buffer, w, pointer ); buffer += wid; pointer += cols; } while (--len != 0);}/* * Name: shadow_area * Purpose: draw a shadow around an area * Author: Jason Hood * Date: October 20, 1999 * Passed: wid: width of area * len: length of area * row: starting row of area * col: starting column of area * Notes: the characters being shadowed are not saved. * Use attribute 8 (dark grey on black) as the shadow. */void shadow_area( int wid, int len, int row, int col ){unsigned long pointer;int w;int cols = g_display.ncols * 2;int alen;int i, j; if (g_display.shadow) { alen = len; adjust_area( &wid, &len, &row, &col, &w ); _farsetsel( _dos_ds ); if (w > 0) { pointer = display_address + (row + 1) * cols + (col + wid) * 2 - 1; for (i = len; i > 1; i--) { for (j = (w - 1) * 2; j >= 0; j -= 2) _farnspokeb( pointer - j, 8 ); pointer += cols; } } if (alen < len) { col += g_display.shadow_width; wid -= g_display.shadow_width + w; /* hlight_line( col, row + len - 1, wid, 8 ); */ pointer = display_address + (row + len - 1) * cols + col * 2 + 1; do { _farnspokeb( pointer, 8 ); pointer += 2; } while (--wid != 0); } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -