From: nethack.allison Date: Fri, 24 Oct 2003 15:15:44 +0000 (+0000) Subject: win32tty: startup msg cleanup X-Git-Tag: MOVE2GIT~1640 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=45dd5ffe9f723596e08449a958278bb5e2ca3624;p=nethack win32tty: startup msg cleanup 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 --- diff --git a/include/extern.h b/include/extern.h index eb492c320..d97dce465 100644 --- a/include/extern.h +++ b/include/extern.h @@ -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 *)); diff --git a/sys/share/pcsys.c b/sys/share/pcsys.c index 9828508de..cbeaca795 100644 --- a/sys/share/pcsys.c +++ b/sys/share/pcsys.c @@ -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. diff --git a/sys/winnt/nttty.c b/sys/winnt/nttty.c index a1c2668ab..f46fea0e7 100644 --- a/sys/winnt/nttty.c +++ b/sys/winnt/nttty.c @@ -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 */ diff --git a/sys/winnt/winnt.c b/sys/winnt/winnt.c index 64783509d..e31bdc374 100644 --- a/sys/winnt/winnt.c +++ b/sys/winnt/winnt.c @@ -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(); } diff --git a/win/tty/wintty.c b/win/tty/wintty.c index e51dcb893..409bb3944 100644 --- a/win/tty/wintty.c +++ b/win/tty/wintty.c @@ -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; }