]> granicus.if.org Git - nethack/commitdiff
fix display problem with tabs on win32tty
authornethack.allison <nethack.allison>
Sun, 27 Jul 2003 03:22:15 +0000 (03:22 +0000)
committernethack.allison <nethack.allison>
Sun, 27 Jul 2003 03:22:15 +0000 (03:22 +0000)
include/extern.h
include/flag.h
sys/share/pcmain.c
sys/share/pcsys.c
sys/share/pctty.c
sys/share/pcunix.c
sys/winnt/nttty.c
win/tty/wintty.c

index 1572986d344c7434abb8bef878b4d09b73c04646..976bb1b8cff5466fecb789dcd36fbd39c56fa5f3 100644 (file)
@@ -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 ### */
index f494b44d2e5d0c599bea280eceea280f2db8bc7c..8b5c6e05d07fce46e5f6116e08901eadf4474412 100644 (file)
@@ -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
index 8ccec94b60900f130d667cac2fadf8741f719c63..a5aea36b7c444c4fa973919b732edde64d8b81f6 100644 (file)
@@ -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 */
index 9c3f762845b5e2861e41c4c9b95c3d3cc2e3f24a..2100d086af6dabc4a56496606890112b15235024 100644 (file)
@@ -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();
index 5dd3d002328b767b58578387baef4e55eb2cc289..0307082d1b49041ec6e130730384c057f31bbd2e 100644 (file)
@@ -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');
index fe73d6a3d3cc655c6f3186d91609d68d1746431f..79ff656f7457c04559a8f39ef2a3e7676cb78de0 100644 (file)
@@ -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 */
 
index 70374b3781ceb2812b6a500955a67fd60493a294..292617881651b8ec43f20927279cdc283e8e14d5 100644 (file)
@@ -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 */
index 15b124976995b1cf6947d1894a0fa5a5afb8f907..1be3537514d92127b5ec460cd176c3493f59a526 100644 (file)
@@ -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);