]> granicus.if.org Git - nethack/commitdiff
win32tty: startup msg cleanup
authornethack.allison <nethack.allison>
Fri, 24 Oct 2003 15:15:44 +0000 (15:15 +0000)
committernethack.allison <nethack.allison>
Fri, 24 Oct 2003 15:15:44 +0000 (15:15 +0000)
the win32 cursor restriction stuff messed up any
messages displayed during abnormal start conditions
where the window system never got initialized properly.
among them:
- messages relating to lock files or games in progress
- dungeon errors
- early panic messages

include/extern.h
sys/share/pcsys.c
sys/winnt/nttty.c
sys/winnt/winnt.c
win/tty/wintty.c

index eb492c3209962c8aadb0b3998a6b3ddfa520f7f6..d97dce46512bb801e70d18067ec5e6b0e5ac9132 100644 (file)
@@ -1333,6 +1333,7 @@ E void NDECL(lan_mail_terminate);
 E void NDECL(get_scr_size);
 E int NDECL(nttty_kbhit);
 E void NDECL(nttty_open);
+E void NDECL(nttty_close);
 E void NDECL(nttty_rubout);
 E int NDECL(tgetch);
 E int FDECL(ntposkey,(int *, int *, int *));
index 9828508de2be8ebd1b489b31f1b60fe4670c6908..cbeaca7957ecf84b02ca8ea944da46c1548d8123 100644 (file)
@@ -408,6 +408,7 @@ const char *str;
        return;
 }
 
+#ifndef WIN32CON
 void
 msmsg VA_DECL(const char *, fmt)
        VA_START(fmt);
@@ -421,6 +422,7 @@ msmsg VA_DECL(const char *, fmt)
        VA_END();
        return;
 }
+#endif
 
 /*
  * Follow the PATH, trying to fopen the file.
index a1c2668ab307afed3188669cc0215ed8bcf65854..f46fea0e7e99f0d28b3554883c616066fc316725 100644 (file)
@@ -341,7 +341,7 @@ tgetch()
        int mod;
        coord cc;
        DWORD count;
-       nocmov(ttyDisplay->curx, ttyDisplay->cury);
+       if (iflags.window_inited) nocmov(ttyDisplay->curx, ttyDisplay->cury);
        return (program_state.done_hup) ?
                '\033' :
                pCheckInput(hConIn, &ir, &count, iflags.num_pad, 0, &mod, &cc);
@@ -412,6 +412,7 @@ const char *s;
        WriteConsoleOutputCharacter(hConOut,s,slen,cursor,&ccount);
 }
 
+
 /*
  * Overrides winntty.c function of the same name
  * for win32. It is used for glyphs only, not text.
@@ -876,4 +877,60 @@ load_keyboard_handler()
        }
 }
 
+static COORD msmsgcursor = {0,4};      /* avoid copyright notice */
+
+void
+nttty_close()
+{
+       msmsgcursor.X = 0;
+       msmsgcursor.Y = 0;
+#if 0
+       if (GetConsoleScreenBufferInfo(hConOut,&csbi)) {
+           DWORD ccnt;
+           FillConsoleOutputAttribute(hConOut,
+                       FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE,
+                       csbi.dwSize.X * csbi.dwSize.Y,
+                       msmsgcursor, &ccnt);
+           FillConsoleOutputCharacter(hConOut,' ',
+                       csbi.dwSize.X * csbi.dwSize.Y,
+                       msmsgcursor, &ccnt);
+       }
+#endif
+}
+
+/* this is used when window system isn't initialized yet */
+void
+msmsg VA_DECL(const char *, fmt)
+       char buf[BUFSZ];
+       int slen, k, ac, cc;
+
+       VA_START(fmt);
+       VA_INIT(fmt, const char *);
+       Vsprintf(buf, fmt, VA_ARGS);
+       VA_END();
+
+       slen = strlen(buf);
+       SetConsoleCursorPosition(hConOut, msmsgcursor);
+       for (k = 0; k < slen; ++k) {
+               switch(buf[k]) {
+                       case '\n':
+                               msmsgcursor.Y = msmsgcursor.Y++ % 24;
+                               msmsgcursor.X = 0;
+                               break;
+                       case '\r':
+                               msmsgcursor.Y = 0;
+                               msmsgcursor.X = 0;
+                               break;
+                       default:
+                               FillConsoleOutputAttribute(hConOut,attr,1,
+                                                       msmsgcursor,&ac);
+                               WriteConsoleOutputCharacter(hConOut,&buf[k],1,
+                                                       msmsgcursor,&cc);
+                               msmsgcursor.X++;
+               }
+               SetConsoleCursorPosition(hConOut, msmsgcursor);
+       }
+       return;
+}
+
 #endif /* WIN32CON */
index 64783509d90bdd771021e1fd47c91083985f7bfc..e31bdc3740532355b4acb408ea32808cf863f6b3 100644 (file)
@@ -224,12 +224,38 @@ void Delay(int ms)
        (void)Sleep(ms);
 }
 
+#ifdef WIN32CON
+extern void NDECL(backsp);
+#endif
+
 void win32_abort()
 {
-
 #ifdef WIZARD
-       if (wizard)
-               DebugBreak();
+       int c, ci, ct;
+       if (wizard) {
+# ifdef WIN32CON
+           if (!iflags.window_inited)
+               c = 'n';
+               ct = 0;
+               msmsg("Execute debug breakpoint wizard?");
+               while ((ci=nhgetch()) != '\n') {
+                   if (ct > 0) {
+                       backsp();       /* \b is visible on NT */
+                       (void) putchar(' ');
+                       backsp();
+                       ct = 0;
+                       c = 'n';
+                   }
+                   if (ci == 'y' || ci == 'n' || ci == 'Y' || ci == 'N') {
+                       ct = 1;
+                       c = ci;
+                       msmsg("%c",c);
+                   }
+               }
+               if (c == 'y')
+                       DebugBreak();
+       }
+# endif
 #endif
        abort();
 }
index e51dcb89398edfb27cac68c640e3445ee0095408..409bb3944824d26863d1e753ba866a3cda60819d 100644 (file)
@@ -791,8 +791,11 @@ tty_exit_nhwindows(str)
 #endif
            wins[i] = 0;
        }
-#ifndef NO_TERMS       /*(until this gets added to the window interface)*/
+#ifndef NO_TERMS               /*(until this gets added to the window interface)*/
     tty_shutdown();            /* cleanup termcap/terminfo/whatever */
+#endif
+#ifdef WIN32CON
+    nttty_close();
 #endif
     iflags.window_inited = 0;
 }