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:
nethack.allison
2003-10-24 15:15:44 +00:00
parent 4ceb7c3743
commit 45dd5ffe9f
5 changed files with 94 additions and 5 deletions

View 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 */