Merge branch 'NetHack-3.6'
# Conflicts: # DEVEL/Developer.txt # include/config.h # include/decl.h # include/display.h # include/extern.h # include/global.h # include/hack.h # include/patchlevel.h # src/display.c # src/dothrow.c # src/makemon.c # src/monst.c # src/objnam.c # src/sp_lev.c # src/wield.c # src/zap.c # sys/share/pmatchregex.c # sys/winnt/Makefile.msc
This commit is contained in:
141
win/tty/wintty.c
141
win/tty/wintty.c
@@ -36,12 +36,6 @@ extern void msmsg(const char *, ...);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef NEW_KEYBOARD_HIT
|
||||
#if defined(UNIX)
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef TTY_TILES_ESCCODES
|
||||
extern short glyph2tile[];
|
||||
#define TILE_ANSI_COMMAND 'z'
|
||||
@@ -137,9 +131,6 @@ struct window_procs tty_procs = {
|
||||
genl_status_update,
|
||||
#endif
|
||||
genl_can_suspend_yes,
|
||||
#ifdef NEW_KEYBOARD_HIT
|
||||
tty_keyboard_hit
|
||||
#endif
|
||||
};
|
||||
|
||||
static int maxwin = 0; /* number of windows in use */
|
||||
@@ -330,7 +321,7 @@ int sig_unused UNUSED;
|
||||
new_status_window();
|
||||
if (u.ux) {
|
||||
i = ttyDisplay->toplin;
|
||||
ttyDisplay->toplin = TOPLINE_EMPTY;
|
||||
ttyDisplay->toplin = 0;
|
||||
docrt();
|
||||
bot();
|
||||
ttyDisplay->toplin = i;
|
||||
@@ -418,7 +409,7 @@ char **argv UNUSED;
|
||||
|
||||
/* set up tty descriptor */
|
||||
ttyDisplay = (struct DisplayDesc *) alloc(sizeof (struct DisplayDesc));
|
||||
ttyDisplay->toplin = TOPLINE_EMPTY;
|
||||
ttyDisplay->toplin = 0;
|
||||
ttyDisplay->rows = hgt;
|
||||
ttyDisplay->cols = wid;
|
||||
ttyDisplay->curx = ttyDisplay->cury = 0;
|
||||
@@ -1619,12 +1610,12 @@ winid window;
|
||||
|
||||
switch (cw->type) {
|
||||
case NHW_MESSAGE:
|
||||
if (ttyDisplay->toplin != TOPLINE_EMPTY) {
|
||||
if (ttyDisplay->toplin) {
|
||||
home();
|
||||
cl_end();
|
||||
if (cw->cury)
|
||||
docorner(1, cw->cury + 1);
|
||||
ttyDisplay->toplin = TOPLINE_EMPTY;
|
||||
ttyDisplay->toplin = 0;
|
||||
}
|
||||
break;
|
||||
case NHW_STATUS:
|
||||
@@ -2315,13 +2306,12 @@ boolean blocking; /* with ttys, all windows are blocking */
|
||||
|
||||
switch (cw->type) {
|
||||
case NHW_MESSAGE:
|
||||
if (ttyDisplay->toplin == TOPLINE_NEED_MORE) {
|
||||
if (ttyDisplay->toplin == 1) {
|
||||
more();
|
||||
ttyDisplay->toplin = TOPLINE_NEED_MORE; /* more resets this */
|
||||
ttyDisplay->toplin = 1; /* more resets this */
|
||||
tty_clear_nhwindow(window);
|
||||
nhassert(ttyDisplay->toplin == TOPLINE_EMPTY);
|
||||
} else
|
||||
ttyDisplay->toplin = TOPLINE_EMPTY;
|
||||
ttyDisplay->toplin = 0;
|
||||
cw->curx = cw->cury = 0;
|
||||
if (!cw->active)
|
||||
iflags.window_inited = TRUE;
|
||||
@@ -2329,8 +2319,8 @@ boolean blocking; /* with ttys, all windows are blocking */
|
||||
case NHW_MAP:
|
||||
end_glyphout();
|
||||
if (blocking) {
|
||||
if (ttyDisplay->toplin != TOPLINE_EMPTY)
|
||||
ttyDisplay->toplin = TOPLINE_NEED_MORE;
|
||||
if (!ttyDisplay->toplin)
|
||||
ttyDisplay->toplin = 1;
|
||||
tty_display_nhwindow(WIN_MESSAGE, TRUE);
|
||||
return;
|
||||
}
|
||||
@@ -2360,7 +2350,7 @@ boolean blocking; /* with ttys, all windows are blocking */
|
||||
cw->offx = 0;
|
||||
if (cw->type == NHW_MENU)
|
||||
cw->offy = 0;
|
||||
if (ttyDisplay->toplin == TOPLINE_NEED_MORE)
|
||||
if (ttyDisplay->toplin == 1)
|
||||
tty_display_nhwindow(WIN_MESSAGE, TRUE);
|
||||
#ifdef H2344_BROKEN
|
||||
if (cw->maxrow >= (int) ttyDisplay->rows
|
||||
@@ -2376,7 +2366,7 @@ boolean blocking; /* with ttys, all windows are blocking */
|
||||
cl_eos();
|
||||
} else
|
||||
clear_screen();
|
||||
ttyDisplay->toplin = TOPLINE_EMPTY;
|
||||
ttyDisplay->toplin = 0;
|
||||
} else {
|
||||
if (WIN_MESSAGE != WIN_ERR)
|
||||
tty_clear_nhwindow(WIN_MESSAGE);
|
||||
@@ -2405,9 +2395,8 @@ winid window;
|
||||
|
||||
switch (cw->type) {
|
||||
case NHW_MESSAGE:
|
||||
if (ttyDisplay->toplin != TOPLINE_EMPTY)
|
||||
if (ttyDisplay->toplin)
|
||||
tty_display_nhwindow(WIN_MESSAGE, TRUE);
|
||||
nhassert(ttyDisplay->toplin == TOPLINE_EMPTY);
|
||||
/*FALLTHRU*/
|
||||
case NHW_STATUS:
|
||||
case NHW_BASE:
|
||||
@@ -3158,11 +3147,10 @@ const char *mesg;
|
||||
response to a prompt, we'll assume that the display is up to date */
|
||||
tty_putstr(WIN_MESSAGE, 0, mesg);
|
||||
/* if `mesg' didn't wrap (triggering --More--), force --More-- now */
|
||||
if (ttyDisplay->toplin == TOPLINE_NEED_MORE) {
|
||||
if (ttyDisplay->toplin == 1) {
|
||||
more();
|
||||
ttyDisplay->toplin = TOPLINE_NEED_MORE; /* more resets this */
|
||||
ttyDisplay->toplin = 1; /* more resets this */
|
||||
tty_clear_nhwindow(WIN_MESSAGE);
|
||||
nhassert(ttyDisplay->toplin == TOPLINE_EMPTY);
|
||||
}
|
||||
/* normally <ESC> means skip further messages, but in this case
|
||||
it means cancel the current prompt; any other messages should
|
||||
@@ -3202,7 +3190,7 @@ tty_wait_synch()
|
||||
(void) fflush(stdout);
|
||||
} else if (ttyDisplay->inread > g.program_state.gameover) {
|
||||
/* this can only happen if we were reading and got interrupted */
|
||||
ttyDisplay->toplin = TOPLINE_SPECIAL_PROMPT;
|
||||
ttyDisplay->toplin = 3;
|
||||
/* do this twice; 1st time gets the Quit? message again */
|
||||
(void) tty_doprev_message();
|
||||
(void) tty_doprev_message();
|
||||
@@ -3489,7 +3477,6 @@ const char *str;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef NEW_KEYBOARD_HIT
|
||||
int
|
||||
tty_nhgetch()
|
||||
{
|
||||
@@ -3531,9 +3518,8 @@ tty_nhgetch()
|
||||
i = '\033'; /* map NUL to ESC since nethack doesn't expect NUL */
|
||||
else if (i == EOF)
|
||||
i = '\033'; /* same for EOF */
|
||||
/* topline has been seen - we can clear need for more */
|
||||
if (ttyDisplay && ttyDisplay->toplin == TOPLINE_NEED_MORE)
|
||||
ttyDisplay->toplin = TOPLINE_NON_EMPTY;
|
||||
if (ttyDisplay && ttyDisplay->toplin == 1)
|
||||
ttyDisplay->toplin = 2;
|
||||
#ifdef TTY_TILES_ESCCODES
|
||||
{
|
||||
/* hack to force output of the window select code */
|
||||
@@ -3545,94 +3531,6 @@ tty_nhgetch()
|
||||
#endif /* TTY_TILES_ESCCODES */
|
||||
return i;
|
||||
}
|
||||
#else /* NEW_KEYBOARD_HIT */
|
||||
#ifdef UNIX
|
||||
static boolean stdin_non_blocking = FALSE;
|
||||
|
||||
int
|
||||
tgetch()
|
||||
{
|
||||
static volatile int nesting = 0;
|
||||
int i;
|
||||
char nestbuf;
|
||||
|
||||
if (stdin_non_blocking) {
|
||||
fcntl(0, F_SETFL, fcntl(0, F_GETFL) & ~O_NONBLOCK);
|
||||
stdin_non_blocking = FALSE;
|
||||
}
|
||||
|
||||
/* kludge alert: Some Unix variants return funny values if getc()
|
||||
* is called, interrupted, and then called again. There
|
||||
* is non-reentrant code in the internal _filbuf() routine, called by
|
||||
* getc().
|
||||
*/
|
||||
i = (++nesting == 1)
|
||||
? getchar()
|
||||
: (read(fileno(stdin), (genericptr_t) &nestbuf, 1) == 1)
|
||||
? (int) nestbuf : EOF;
|
||||
--nesting;
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
boolean
|
||||
tkbhit()
|
||||
{
|
||||
int i;
|
||||
if (!stdin_non_blocking) {
|
||||
fcntl(0, F_SETFL, fcntl(0, F_GETFL) | O_NONBLOCK);
|
||||
stdin_non_blocking = TRUE;
|
||||
}
|
||||
i = getchar();
|
||||
if (i != EOF) ungetc(i, stdin);
|
||||
return (i != EOF);
|
||||
}
|
||||
#endif
|
||||
|
||||
int
|
||||
tty_nhgetch()
|
||||
{
|
||||
int i;
|
||||
HUPSKIP_RESULT('\033');
|
||||
print_vt_code1(AVTC_INLINE_SYNC);
|
||||
(void) fflush(stdout);
|
||||
/* Note: if raw_print() and wait_synch() get called to report terminal
|
||||
* initialization problems, then wins[] and ttyDisplay might not be
|
||||
* available yet. Such problems will probably be fatal before we get
|
||||
* here, but validate those pointers just in case...
|
||||
*/
|
||||
if (WIN_MESSAGE != WIN_ERR && wins[WIN_MESSAGE])
|
||||
wins[WIN_MESSAGE]->flags &= ~WIN_STOP;
|
||||
if (iflags.debug_fuzzer) {
|
||||
i = randomkey();
|
||||
} else {
|
||||
i = tgetch();
|
||||
}
|
||||
if (!i)
|
||||
i = '\033'; /* map NUL to ESC since nethack doesn't expect NUL */
|
||||
else if (i == EOF)
|
||||
i = '\033'; /* same for EOF */
|
||||
/* topline has been seen - we can clear need for more */
|
||||
if (ttyDisplay && ttyDisplay->toplin == TOPLINE_NEED_MORE)
|
||||
ttyDisplay->toplin = TOPLINE_NON_EMPTY;
|
||||
#ifdef TTY_TILES_ESCCODES
|
||||
{
|
||||
/* hack to force output of the window select code */
|
||||
int tmp = vt_tile_current_window;
|
||||
|
||||
vt_tile_current_window++;
|
||||
print_vt_code2(AVTC_SELECT_WINDOW, tmp);
|
||||
}
|
||||
#endif /* TTY_TILES_ESCCODES */
|
||||
return i;
|
||||
}
|
||||
|
||||
boolean tty_keyboard_hit()
|
||||
{
|
||||
/* tgetch provider needs to also provide tkbhit() */
|
||||
return tkbhit();
|
||||
}
|
||||
#endif /* NEW_KEYBOARD_HIT */
|
||||
|
||||
/*
|
||||
* return a key, or 0, in which case a mouse button was pressed
|
||||
@@ -3659,9 +3557,8 @@ int *x, *y, *mod;
|
||||
i = ntposkey(x, y, mod);
|
||||
if (!i && mod && (*mod == 0 || *mod == EOF))
|
||||
i = '\033'; /* map NUL or EOF to ESC, nethack doesn't expect either */
|
||||
/* topline has been seen - we can clear need for more */
|
||||
if (ttyDisplay && ttyDisplay->toplin == TOPLINE_NEED_MORE)
|
||||
ttyDisplay->toplin = TOPLINE_NON_EMPTY;
|
||||
if (ttyDisplay && ttyDisplay->toplin == 1)
|
||||
ttyDisplay->toplin = 2;
|
||||
#else /* !WIN32CON */
|
||||
nhUse(x);
|
||||
nhUse(y);
|
||||
|
||||
Reference in New Issue
Block a user