Merge branch 'NetHack-3.6.0' into win32-guitty

This commit is contained in:
nhmall
2016-01-11 18:35:50 -05:00
26 changed files with 852 additions and 127 deletions
+73 -3
View File
@@ -37,6 +37,15 @@ extern void msmsg(const char *, ...);
#endif
#endif
#ifdef TTY_TILES_ESCCODES
extern short glyph2tile[];
#define TILE_ANSI_COMMAND 'z'
#define AVTC_GLYPH_START 0
#define AVTC_GLYPH_END 1
#define AVTC_SELECT_WINDOW 2
#define AVTC_INLINE_SYNC 3
#endif
extern char mapped_menu_cmds[]; /* from options.c */
/* this is only needed until tty_status_* routines are written */
@@ -175,6 +184,36 @@ static const char default_menu_cmds[] = {
MENU_INVERT_PAGE, MENU_SEARCH, 0 /* null terminator */
};
#ifdef TTY_TILES_ESCCODES
static int vt_tile_current_window = -2;
void
print_vt_code(i, c, d)
int i, c, d;
{
if (iflags.vt_tiledata) {
if (c >= 0) {
if (i == AVTC_SELECT_WINDOW) {
if (c == vt_tile_current_window) return;
vt_tile_current_window = c;
}
if (d >= 0)
printf("\033[1;%d;%d;%d%c", i, c, d, TILE_ANSI_COMMAND);
else
printf("\033[1;%d;%d%c", i, c, TILE_ANSI_COMMAND);
} else {
printf("\033[1;%d%c", i, TILE_ANSI_COMMAND);
}
}
}
#else
# define print_vt_code(i, c, d) ;
#endif /* !TTY_TILES_ESCCODES */
#define print_vt_code1(i) print_vt_code((i), -1, -1)
#define print_vt_code2(i,c) print_vt_code((i), (c), -1)
#define print_vt_code3(i,c,d) print_vt_code((i), (c), (d))
/* clean up and quit */
STATIC_OVL void
bail(mesg)
@@ -1427,6 +1466,8 @@ winid window;
panic(winpanicstr, window);
ttyDisplay->lastwin = window;
print_vt_code2(AVTC_SELECT_WINDOW, window);
switch (cw->type) {
case NHW_MESSAGE:
if (ttyDisplay->toplin) {
@@ -2060,6 +2101,8 @@ boolean blocking; /* with ttys, all windows are blocking */
ttyDisplay->lastwin = window;
ttyDisplay->rawprint = 0;
print_vt_code2(AVTC_SELECT_WINDOW, window);
switch (cw->type) {
case NHW_MESSAGE:
if (ttyDisplay->toplin == 1) {
@@ -2108,13 +2151,15 @@ boolean blocking; /* with ttys, all windows are blocking */
if (ttyDisplay->toplin == 1)
tty_display_nhwindow(WIN_MESSAGE, TRUE);
#ifdef H2344_BROKEN
if (cw->maxrow >= (int) ttyDisplay->rows)
if (cw->maxrow >= (int) ttyDisplay->rows
|| !iflags.menu_overlay)
#else
if (cw->offx == 10 || cw->maxrow >= (int) ttyDisplay->rows)
if (cw->offx == 10 || cw->maxrow >= (int) ttyDisplay->rows
|| !iflags.menu_overlay)
#endif
{
cw->offx = 0;
if (cw->offy) {
if (cw->offy || iflags.menu_overlay) {
tty_curs(window, 1, 0);
cl_eos();
} else
@@ -2143,6 +2188,8 @@ winid window;
if (window == WIN_ERR || (cw = wins[window]) == (struct WinDesc *) 0)
panic(winpanicstr, window);
print_vt_code2(AVTC_SELECT_WINDOW, window);
switch (cw->type) {
case NHW_MESSAGE:
if (ttyDisplay->toplin)
@@ -2212,6 +2259,8 @@ register int x, y; /* not xchar: perhaps xchar is unsigned and
panic(winpanicstr, window);
ttyDisplay->lastwin = window;
print_vt_code2(AVTC_SELECT_WINDOW, window);
#if defined(USE_TILES) && defined(MSDOS)
adjust_cursor_flags(cw);
#endif
@@ -2300,6 +2349,8 @@ char ch;
if (window == WIN_ERR || (cw = wins[window]) == (struct WinDesc *) 0)
panic(winpanicstr, window);
print_vt_code2(AVTC_SELECT_WINDOW, window);
switch (cw->type) {
case NHW_STATUS:
case NHW_MAP:
@@ -2367,6 +2418,8 @@ const char *str;
ttyDisplay->lastwin = window;
print_vt_code2(AVTC_SELECT_WINDOW, window);
switch (cw->type) {
case NHW_MESSAGE:
/* really do this later */
@@ -3063,9 +3116,13 @@ int bkglyph UNUSED;
/* map glyph to character and color */
(void) mapglyph(glyph, &ch, &color, &special, x, y);
print_vt_code2(AVTC_SELECT_WINDOW, window);
/* Move the cursor. */
tty_curs(window, x, y);
print_vt_code3(AVTC_GLYPH_START, glyph2tile[glyph], special);
#ifndef NO_TERMS
if (ul_hack && ch == '_') { /* non-destructive underscore */
(void) putchar((char) ' ');
@@ -3109,6 +3166,8 @@ int bkglyph UNUSED;
#endif
}
print_vt_code1(AVTC_GLYPH_END);
wins[window]->curx++; /* one character over */
ttyDisplay->curx++; /* the real cursor moved too */
}
@@ -3119,6 +3178,7 @@ const char *str;
{
if (ttyDisplay)
ttyDisplay->rawprint++;
print_vt_code2(AVTC_SELECT_WINDOW, NHW_BASE);
#if defined(MICRO) || defined(WIN32CON)
msmsg("%s\n", str);
#else
@@ -3133,6 +3193,7 @@ const char *str;
{
if (ttyDisplay)
ttyDisplay->rawprint++;
print_vt_code2(AVTC_SELECT_WINDOW, NHW_BASE);
term_start_raw_bold();
#if defined(MICRO) || defined(WIN32CON)
msmsg("%s", str);
@@ -3162,6 +3223,7 @@ tty_nhgetch()
char nestbuf;
#endif
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
@@ -3184,6 +3246,14 @@ tty_nhgetch()
i = '\033'; /* same for EOF */
if (ttyDisplay && ttyDisplay->toplin == 1)
ttyDisplay->toplin = 2;
#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;
}