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
This commit is contained in:
@@ -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 *));
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user