diff options
Diffstat (limited to 'screen.c')
-rw-r--r-- | screen.c | 59 |
1 files changed, 39 insertions, 20 deletions
@@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2019 Mark Nudelman + * Copyright (C) 1984-2020 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. @@ -219,8 +219,9 @@ extern int binattr; extern int one_screen; #if !MSDOS_COMPILER -static char *cheaper(); -static void tmodes(); +static char *cheaper LESSPARAMS((char *t1, char *t2, char *def)); +static void tmodes LESSPARAMS((char *incap, char *outcap, char **instr, + char **outstr, char *def_instr, char *def_outstr, char **spp)); #endif /* @@ -253,6 +254,11 @@ extern int hilite_search; #endif #if MSDOS_COMPILER==WIN32C extern HANDLE tty; +extern DWORD console_mode; +#ifndef ENABLE_EXTENDED_FLAGS +#define ENABLE_EXTENDED_FLAGS 0x80 +#define ENABLE_QUICK_EDIT_MODE 0x40 +#endif #else extern int tty; #endif @@ -642,7 +648,6 @@ ltget_env(capname) char *capname; { char name[64]; - char *s; if (termcap_debug) { @@ -1080,7 +1085,6 @@ get_term(VOID_PARAM) #else #if MSDOS_COMPILER==WIN32C { - DWORD nread; CONSOLE_SCREEN_BUFFER_INFO scr; con_out_save = con_out = GetStdHandle(STD_OUTPUT_HANDLE); @@ -1090,8 +1094,7 @@ get_term(VOID_PARAM) */ SET_BINARY(0); GetConsoleScreenBufferInfo(con_out, &scr); - ReadConsoleOutputAttribute(con_out, &curr_attr, - 1, scr.dwCursorPosition, &nread); + curr_attr = scr.wAttributes; sy_bg_color = (curr_attr & BG_COLORS) >> 4; /* normalize */ sy_fg_color = curr_attr & FG_COLORS; } @@ -1122,8 +1125,11 @@ get_term(VOID_PARAM) char *sp; char *t1, *t2; char *term; - char termbuf[TERMBUF_SIZE]; - + /* + * Some termcap libraries assume termbuf is static + * (accessible after tgetent returns). + */ + static char termbuf[TERMBUF_SIZE]; static char sbuf[TERMSBUF_SIZE]; #if OS2 @@ -1146,12 +1152,13 @@ get_term(VOID_PARAM) /* * Find out what kind of terminal this is. */ - if ((term = lgetenv("TERM")) == NULL) - term = DEFAULT_TERM; + if ((term = lgetenv("TERM")) == NULL) + term = DEFAULT_TERM; hardcopy = 0; - if (tgetent(termbuf, term) != TGETENT_OK) - hardcopy = 1; - if (ltgetflag("hc")) + /* {{ Should probably just pass NULL instead of termbuf. }} */ + if (tgetent(termbuf, term) != TGETENT_OK) + hardcopy = 1; + if (ltgetflag("hc")) hardcopy = 1; /* @@ -1562,7 +1569,9 @@ init_mouse(VOID_PARAM) tputs(sc_s_mousecap, sc_height, putchr); #else #if MSDOS_COMPILER==WIN32C - SetConsoleMode(tty, ENABLE_PROCESSED_INPUT | ENABLE_MOUSE_INPUT); + SetConsoleMode(tty, ENABLE_PROCESSED_INPUT | ENABLE_MOUSE_INPUT + | ENABLE_EXTENDED_FLAGS /* disable quick edit */); + #endif #endif } @@ -1580,7 +1589,8 @@ deinit_mouse(VOID_PARAM) tputs(sc_e_mousecap, sc_height, putchr); #else #if MSDOS_COMPILER==WIN32C - SetConsoleMode(tty, ENABLE_PROCESSED_INPUT); + SetConsoleMode(tty, ENABLE_PROCESSED_INPUT | ENABLE_EXTENDED_FLAGS + | (console_mode & ENABLE_QUICK_EDIT_MODE)); #endif #endif } @@ -1616,8 +1626,13 @@ init(VOID_PARAM) line_left(); #else #if MSDOS_COMPILER==WIN32C - if (!no_init) - win32_init_term(); + if (!(quit_if_one_screen && one_screen)) + { + if (!no_init) + win32_init_term(); + init_mouse(); + + } #endif initcolor(); flush(); @@ -1646,8 +1661,12 @@ deinit(VOID_PARAM) /* Restore system colors. */ SETCOLORS(sy_fg_color, sy_bg_color); #if MSDOS_COMPILER==WIN32C - if (!no_init) - win32_deinit_term(); + if (!(quit_if_one_screen && one_screen)) + { + deinit_mouse(); + if (!no_init) + win32_deinit_term(); + } #else /* Need clreol to make SETCOLORS take effect. */ clreol(); |