diff options
Diffstat (limited to 'screen.c')
-rw-r--r-- | screen.c | 157 |
1 files changed, 101 insertions, 56 deletions
diff --git a/screen.c b/screen.c index 8ae52fac80d89..ad3fca1639dd2 100644 --- a/screen.c +++ b/screen.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2015 Mark Nudelman + * Copyright (C) 1984-2016 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. @@ -151,6 +151,7 @@ public int bl_fg_color; /* Color of blinking text */ public int bl_bg_color; static int sy_fg_color; /* Color of system text (before less) */ static int sy_bg_color; +public int sgr_mode; /* Honor ANSI sequences rather than using above */ #else @@ -205,9 +206,8 @@ static int attrmode = AT_NORMAL; extern int binattr; #if !MSDOS_COMPILER -static char *cheaper(char *t1, char *t2, char *def); -static void tmodes(char *incap, char *outcap, char **instr, char **outstr, - char *def_instr, char *def_outstr, char **spp); +static char *cheaper(); +static void tmodes(); #endif /* @@ -254,7 +254,8 @@ extern char *tgoto(); * It doesn't matter whether an input \n is mapped to \r, or vice versa. */ public void -raw_mode(int on) +raw_mode(on) + int on; { static int curr_on = 0; @@ -618,7 +619,8 @@ raw_mode(int on) static int hardcopy; static char * -ltget_env(char *capname) +ltget_env(capname) + char *capname; { char name[16]; char *s; @@ -646,7 +648,8 @@ ltget_env(char *capname) } static int -ltgetflag(char *capname) +ltgetflag(capname) + char *capname; { char *s; @@ -658,7 +661,8 @@ ltgetflag(char *capname) } static int -ltgetnum(char *capname) +ltgetnum(capname) + char *capname; { char *s; @@ -670,7 +674,9 @@ ltgetnum(char *capname) } static char * -ltgetstr(char *capname, char **pp) +ltgetstr(capname, pp) + char *capname; + char **pp; { char *s; @@ -686,9 +692,9 @@ ltgetstr(char *capname, char **pp) * Get size of the output screen. */ public void -scrsize(void) +scrsize() { - char *s; + register char *s; int sys_height; int sys_width; #if !MSDOS_COMPILER @@ -816,7 +822,7 @@ scrsize(void) * Figure out how many empty loops it takes to delay a millisecond. */ static void -get_clock(void) +get_clock() { clock_t start; @@ -844,14 +850,15 @@ get_clock(void) * Delay for a specified number of milliseconds. */ static void -dummy_func(void) +dummy_func() { static long delay_dummy = 0; delay_dummy++; } static void -delay(int msec) +delay(msec) + int msec; { long i; @@ -873,7 +880,8 @@ delay(int msec) * Return the characters actually input by a "special" key. */ public char * -special_key_str(int key) +special_key_str(key) + int key; { static char tbuf[40]; char *s; @@ -1045,7 +1053,7 @@ special_key_str(int key) * Get terminal capabilities via termcap. */ public void -get_term(void) +get_term() { #if MSDOS_COMPILER auto_wrap = 1; @@ -1099,6 +1107,7 @@ get_term(void) so_bg_color = 9; bl_fg_color = 15; bl_bg_color = 0; + sgr_mode = 0; /* * Get size of the screen. @@ -1110,7 +1119,7 @@ get_term(void) #else /* !MSDOS_COMPILER */ char *sp; - char *t1, *t2; + register char *t1, *t2; char *term; char termbuf[TERMBUF_SIZE]; @@ -1342,14 +1351,16 @@ static int costcount; /*ARGSUSED*/ static int -inc_costcount(int c) +inc_costcount(c) + int c; { costcount++; return (c); } static int -cost(char *t) +cost(t) + char *t; { costcount = 0; tputs(t, sc_height, inc_costcount); @@ -1362,7 +1373,9 @@ cost(char *t) * cost (see cost() function). */ static char * -cheaper(char *t1, char *t2, char *def) +cheaper(t1, t2, def) + char *t1, *t2; + char *def; { if (*t1 == '\0' && *t2 == '\0') { @@ -1379,8 +1392,14 @@ cheaper(char *t1, char *t2, char *def) } static void -tmodes(char *incap, char *outcap, char **instr, char **outstr, char *def_instr, - char *def_outstr, char **spp) +tmodes(incap, outcap, instr, outstr, def_instr, def_outstr, spp) + char *incap; + char *outcap; + char **instr; + char **outstr; + char *def_instr; + char *def_outstr; + char **spp; { *instr = ltgetstr(incap, spp); if (*instr == NULL) @@ -1429,8 +1448,11 @@ _settextposition(int row, int col) * Initialize the screen to the correct color at startup. */ static void -initcolor(void) +initcolor() { +#if MSDOS_COMPILER==BORLANDC || MSDOS_COMPILER==DJGPPC + intensevideo(); +#endif SETCOLORS(nm_fg_color, nm_bg_color); #if 0 /* @@ -1462,7 +1484,7 @@ initcolor(void) * Termcap-like init with a private win32 console. */ static void -win32_init_term(void) +win32_init_term() { CONSOLE_SCREEN_BUFFER_INFO scr; COORD size; @@ -1513,7 +1535,7 @@ win32_deinit_term() * Initialize terminal */ public void -init(void) +init() { #if !MSDOS_COMPILER if (!no_init) @@ -1549,7 +1571,7 @@ init(void) * Deinitialize terminal */ public void -deinit(void) +deinit() { if (!init_done) return; @@ -1576,7 +1598,7 @@ deinit(void) * Home cursor (move to upper left corner of screen). */ public void -home(void) +home() { #if !MSDOS_COMPILER tputs(sc_home, 1, putchr); @@ -1591,7 +1613,7 @@ home(void) * Should scroll the display down. */ public void -add_line(void) +add_line() { #if !MSDOS_COMPILER tputs(sc_addline, sc_height, putchr); @@ -1649,7 +1671,8 @@ add_line(void) * into the scrollback buffer when we go down-one-line (in WIN32). */ public void -remove_top(int n) +remove_top(n) + int n; { #if MSDOS_COMPILER==WIN32C SMALL_RECT rcSrc, rcClip; @@ -1702,7 +1725,7 @@ remove_top(int n) * Clear the screen. */ static void -win32_clear(void) +win32_clear() { /* * This will clear only the currently visible rows of the NT @@ -1733,7 +1756,8 @@ win32_clear(void) * window upward. */ public void -win32_scroll_up(int n) +win32_scroll_up(n) + int n; { SMALL_RECT rcSrc, rcClip; CHAR_INFO fillchar; @@ -1798,7 +1822,7 @@ win32_scroll_up(int n) * Move cursor to lower left corner of screen. */ public void -lower_left(void) +lower_left() { #if !MSDOS_COMPILER tputs(sc_lower_left, 1, putchr); @@ -1812,7 +1836,7 @@ lower_left(void) * Move cursor to left position of current line. */ public void -line_left(void) +line_left() { #if !MSDOS_COMPILER tputs(sc_return, 1, putchr); @@ -1844,7 +1868,7 @@ line_left(void) * (in lieu of SIGWINCH for WIN32). */ public void -check_winch(void) +check_winch() { #if MSDOS_COMPILER==WIN32C CONSOLE_SCREEN_BUFFER_INFO scr; @@ -1874,7 +1898,8 @@ check_winch(void) * Goto a specific line on the screen. */ public void -goto_line(int slinenum) +goto_line(slinenum) + int slinenum; { #if !MSDOS_COMPILER tputs(tgoto(sc_move, 0, slinenum), 1, putchr); @@ -1892,7 +1917,7 @@ goto_line(int slinenum) * {{ Yuck! There must be a better way to get a visual bell. }} */ static void -create_flash(void) +create_flash() { #if MSDOS_COMPILER==MSOFTC struct videoconfig w; @@ -1921,7 +1946,7 @@ create_flash(void) } #else #if MSDOS_COMPILER==BORLANDC - int n; + register int n; whitescreen = (unsigned short *) malloc(sc_width * sc_height * sizeof(short)); @@ -1931,7 +1956,7 @@ create_flash(void) whitescreen[n] = 0x7020; #else #if MSDOS_COMPILER==WIN32C - int n; + register int n; whitescreen = (WORD *) malloc(sc_height * sc_width * sizeof(WORD)); @@ -1951,7 +1976,7 @@ create_flash(void) * Output the "visual bell", if there is one. */ public void -vbell(void) +vbell() { #if !MSDOS_COMPILER if (*sc_visual_bell == '\0') @@ -2015,7 +2040,7 @@ vbell(void) * Make a noise. */ static void -beep(void) +beep() { #if !MSDOS_COMPILER putchr(CONTROL('G')); @@ -2032,7 +2057,7 @@ beep(void) * Ring the terminal bell. */ public void -bell(void) +bell() { if (quiet == VERY_QUIET) vbell(); @@ -2044,7 +2069,7 @@ bell(void) * Clear the screen. */ public void -clear(void) +clear() { #if !MSDOS_COMPILER tputs(sc_clear, sc_height, putchr); @@ -2063,7 +2088,7 @@ clear(void) * {{ This must not move the cursor. }} */ public void -clear_eol(void) +clear_eol() { #if !MSDOS_COMPILER tputs(sc_eol_clear, 1, putchr); @@ -2122,7 +2147,7 @@ clear_eol(void) * Clear the screen if there's off-screen memory below the display. */ static void -clear_eol_bot(void) +clear_eol_bot() { #if MSDOS_COMPILER clear_eol(); @@ -2139,7 +2164,7 @@ clear_eol_bot(void) * Leave the cursor at the beginning of the bottom line. */ public void -clear_bot(void) +clear_bot() { /* * If we're in a non-normal attribute mode, temporarily exit @@ -2164,7 +2189,8 @@ clear_bot(void) } public void -at_enter(int attr) +at_enter(attr) + int attr; { attr = apply_at_specials(attr); @@ -2202,7 +2228,7 @@ at_enter(int attr) } public void -at_exit(void) +at_exit() { #if !MSDOS_COMPILER /* Undo things in the reverse order we did them. */ @@ -2223,7 +2249,8 @@ at_exit(void) } public void -at_switch(int attr) +at_switch(attr) + int attr; { int new_attrmode = apply_at_specials(attr); int ignore_modes = AT_ANSI; @@ -2236,7 +2263,9 @@ at_switch(int attr) } public int -is_at_equiv(int attr1, int attr2) +is_at_equiv(attr1, attr2) + int attr1; + int attr2; { attr1 = apply_at_specials(attr1); attr2 = apply_at_specials(attr2); @@ -2245,7 +2274,8 @@ is_at_equiv(int attr1, int attr2) } public int -apply_at_specials(int attr) +apply_at_specials(attr) + int attr; { if (attr & AT_BINARY) attr |= binattr; @@ -2262,7 +2292,7 @@ apply_at_specials(int attr) * and move the cursor left. */ public void -backspace(void) +backspace() { #if !MSDOS_COMPILER /* @@ -2311,7 +2341,7 @@ backspace(void) * Output a plain backspace, without erasing the previous char. */ public void -putbs(void) +putbs() { #if !MSDOS_COMPILER tputs(sc_backspace, 1, putchr); @@ -2350,7 +2380,8 @@ putbs(void) * Determine whether an input character is waiting to be read. */ static int -win32_kbhit(HANDLE tty) +win32_kbhit(tty) + HANDLE tty; { INPUT_RECORD ip; DWORD read; @@ -2406,7 +2437,16 @@ win32_kbhit(HANDLE tty) currentKey.scan = PCK_CTL_DELETE; break; } + } else if (ip.Event.KeyEvent.dwControlKeyState & SHIFT_PRESSED) + { + switch (currentKey.scan) + { + case PCK_SHIFT_TAB: /* tab */ + currentKey.ascii = 0; + break; + } } + return (TRUE); } @@ -2414,7 +2454,8 @@ win32_kbhit(HANDLE tty) * Read a character from the keyboard. */ public char -WIN32getch(int tty) +WIN32getch(tty) + int tty; { int ascii; @@ -2447,7 +2488,9 @@ WIN32getch(int tty) /* */ public void -WIN32setcolors(int fg, int bg) +WIN32setcolors(fg, bg) + int fg; + int bg; { SETCOLORS(fg, bg); } @@ -2455,7 +2498,9 @@ WIN32setcolors(int fg, int bg) /* */ public void -WIN32textout(char *text, int len) +WIN32textout(text, len) + char *text; + int len; { #if MSDOS_COMPILER==WIN32C DWORD written; |