fix display problem with tabs on win32tty
This commit is contained in:
@@ -1324,6 +1324,7 @@ E void NDECL(nttty_open);
|
||||
E void NDECL(nttty_rubout);
|
||||
E int NDECL(tgetch);
|
||||
E int FDECL(ntposkey,(int *, int *, int *));
|
||||
E void FDECL(set_output_mode, (int));
|
||||
#endif
|
||||
|
||||
/* ### o_init.c ### */
|
||||
|
||||
@@ -193,6 +193,8 @@ struct instance_flags {
|
||||
#endif
|
||||
#ifdef MICRO
|
||||
boolean BIOS; /* use IBM or ST BIOS calls when appropriate */
|
||||
#endif
|
||||
#if defined(MICRO) || defined(WIN32)
|
||||
boolean rawio; /* whether can use rawio (IOCTL call) */
|
||||
#endif
|
||||
#ifdef MAC_GRAPHICS_ENV
|
||||
|
||||
@@ -291,8 +291,19 @@ char *argv[];
|
||||
# endif
|
||||
#endif
|
||||
|
||||
if (!*plname)
|
||||
if (!*plname) {
|
||||
#ifdef WIN32CON
|
||||
boolean revert = FALSE;
|
||||
if (!iflags.rawio) {
|
||||
set_output_mode(1);
|
||||
revert = TRUE;
|
||||
}
|
||||
#endif
|
||||
askname();
|
||||
#ifdef WIN32CON
|
||||
if (revert && iflags.rawio) set_output_mode(0);
|
||||
#endif
|
||||
}
|
||||
plnamesuffix(); /* strip suffix from name; calls askname() */
|
||||
/* again if suffix was whole name */
|
||||
/* accepts any suffix */
|
||||
|
||||
@@ -416,6 +416,9 @@ msmsg VA_DECL(const char *, fmt)
|
||||
if (iflags.grmode)
|
||||
gr_finish();
|
||||
# endif
|
||||
#ifdef WIN32CON
|
||||
if (iflags.rawio) set_output_mode(0);
|
||||
#endif
|
||||
Vprintf(fmt, VA_ARGS);
|
||||
flushout();
|
||||
VA_END();
|
||||
|
||||
@@ -75,6 +75,9 @@ error VA_DECL(const char *,s)
|
||||
VA_INIT(s, const char *);
|
||||
/* error() may get called before tty is initialized */
|
||||
if (iflags.window_inited) end_screen();
|
||||
#ifdef WIN32CON
|
||||
if (iflags.rawio) set_output_mode(0);
|
||||
#endif
|
||||
putchar('\n');
|
||||
Vprintf(s,VA_ARGS);
|
||||
putchar('\n');
|
||||
|
||||
@@ -263,6 +263,9 @@ gotlock:
|
||||
# if defined(MSDOS) && defined(NO_TERMS)
|
||||
if (grmode) gr_init();
|
||||
# endif
|
||||
#ifdef WIN32CON
|
||||
if (!iflags.rawio) set_output_mode(1);
|
||||
#endif
|
||||
}
|
||||
#endif /* PC_LOCKING */
|
||||
|
||||
|
||||
@@ -153,6 +153,38 @@ const char *s;
|
||||
if(s) raw_print(s);
|
||||
}
|
||||
|
||||
/*
|
||||
* mode == 0 set processed console output mode.
|
||||
* mode == 1 set raw console output mode (no control character expansion).
|
||||
*/
|
||||
void
|
||||
set_output_mode(mode)
|
||||
int mode;
|
||||
{
|
||||
static DWORD save_output_cmode = 0;
|
||||
static boolean initmode = FALSE;
|
||||
DWORD cmode, mask = ENABLE_PROCESSED_OUTPUT;
|
||||
if (!initmode) {
|
||||
/* fetch original output mode */
|
||||
GetConsoleMode(hConOut,&save_output_cmode);
|
||||
initmode = TRUE;
|
||||
}
|
||||
if (mode == 0) {
|
||||
cmode = save_output_cmode;
|
||||
/* Turn ON the settings specified in the mask */
|
||||
cmode |= mask;
|
||||
SetConsoleMode(hConOut,cmode);
|
||||
iflags.rawio = 0;
|
||||
} else {
|
||||
cmode = save_output_cmode;
|
||||
/* Turn OFF the settings specified in the mask */
|
||||
cmode &= ~mask;
|
||||
SetConsoleMode(hConOut,cmode);
|
||||
iflags.rawio = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* called by init_nhwindows() and resume_nhwindows() */
|
||||
void
|
||||
setftty()
|
||||
@@ -219,6 +251,7 @@ DWORD ctrltype;
|
||||
case CTRL_CLOSE_EVENT:
|
||||
case CTRL_LOGOFF_EVENT:
|
||||
case CTRL_SHUTDOWN_EVENT:
|
||||
set_output_mode(0); /* Allow processed output */
|
||||
getreturn_disable = TRUE;
|
||||
#ifndef NOSAVEONHANGUP
|
||||
hangup(0);
|
||||
@@ -285,6 +318,8 @@ nttty_open()
|
||||
cmode |= ENABLE_MOUSE_INPUT;
|
||||
#endif
|
||||
SetConsoleMode(hConIn,cmode);
|
||||
|
||||
set_output_mode(1); /* raw output mode; no tab expansion */
|
||||
if (!SetConsoleCtrlHandler((PHANDLER_ROUTINE)CtrlHandler, TRUE)) {
|
||||
/* Unable to set control handler */
|
||||
cmode = 0; /* just to have a statement to break on for debugger */
|
||||
|
||||
@@ -707,7 +707,7 @@ tty_askname()
|
||||
if(c < 'A' || (c > 'Z' && c < 'a') || c > 'z') c = '_';
|
||||
#endif
|
||||
if (ct < (int)(sizeof plname) - 1) {
|
||||
#if defined(MICRO) || defined(WIN32CON)
|
||||
#if defined(MICRO)
|
||||
# if defined(MSDOS)
|
||||
if (iflags.grmode) {
|
||||
(void) putchar(c);
|
||||
|
||||
Reference in New Issue
Block a user