Merge branch 'master' into nhmall-booktribute

Conflicts:
	include/context.h
This commit is contained in:
nhmall
2015-04-02 19:19:50 -04:00
148 changed files with 24895 additions and 13655 deletions
+11 -2
View File
@@ -1,4 +1,4 @@
/* NetHack 3.5 winmenu.c $NHDT-Date$ $NHDT-Branch$:$NHDT-Revision$ */
/* NetHack 3.5 winmenu.c $NHDT-Date: 1427881480 2015/04/01 09:44:40 $ $NHDT-Branch: master $:$NHDT-Revision: 1.5 $ */
/* NetHack 3.5 winmenu.c $Date: 2009/05/06 10:55:53 $ $Revision: 1.5 $ */
/* SCCS Id: @(#)winmenu.c 3.5 1996/08/15 */
/* Copyright (c) Dean Luick, 1992 */
@@ -206,6 +206,7 @@ menu_key(w, event, params, num_params)
struct xwindow *wp;
char ch;
int count;
boolean selected_something;
wp = find_widget(w);
menu_info = wp->menu_information;
@@ -218,6 +219,13 @@ menu_key(w, event, params, num_params)
}
if (menu_info->is_active) { /* waiting for input */
/* first check for an explicit selector match, so that it won't be
overridden if it happens to duplicate a mapped menu command (':'
to look inside a container vs ':' to select via search string) */
for (curr = menu_info->curr_menu.base; curr; curr = curr->next)
if (curr->identifier.a_void != 0 && curr->selector == ch)
goto make_selection;
ch = map_menu_cmd(ch);
if (ch == '\033') { /* quit */
if (menu_info->counting) {
@@ -294,7 +302,8 @@ menu_key(w, event, params, num_params)
X11_nhbell();
return;
} else {
boolean selected_something = FALSE;
make_selection:
selected_something = FALSE;
for (count = 0, curr = menu_info->curr_menu.base; curr;
curr = curr->next, count++)
if (curr->identifier.a_void != 0 && curr->selector == ch) break;
+107 -24
View File
@@ -1,4 +1,4 @@
/* NetHack 3.5 termcap.c $NHDT-Date$ $NHDT-Branch$:$NHDT-Revision$ */
/* NetHack 3.5 termcap.c $NHDT-Date: 1427756993 2015/03/30 23:09:53 $ $NHDT-Branch: master $:$NHDT-Revision: 1.15 $ */
/* NetHack 3.5 termcap.c $Date: 2009/05/06 10:59:19 $ $Revision: 1.13 $ */
/* SCCS Id: @(#)termcap.c 3.5 2007/12/12 */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
@@ -809,10 +809,9 @@ cl_eos() /* free after Robert Viduya */
extern char *tparm();
#endif
# ifdef COLOR_BLACK /* trust include file */
#undef COLOR_BLACK
# else
# ifndef COLOR_BLACK /* trust include file */
# ifndef _M_UNIX /* guess BGR */
#define COLOR_BLACK 0
#define COLOR_BLUE 1
#define COLOR_GREEN 2
#define COLOR_CYAN 3
@@ -821,6 +820,7 @@ extern char *tparm();
#define COLOR_YELLOW 6
#define COLOR_WHITE 7
# else /* guess RGB */
#define COLOR_BLACK 0
#define COLOR_RED 1
#define COLOR_GREEN 2
#define COLOR_YELLOW 3
@@ -830,43 +830,126 @@ extern char *tparm();
#define COLOR_WHITE 7
# endif
# endif
#define COLOR_BLACK COLOR_BLUE
const int ti_map[8] = {
COLOR_BLACK, COLOR_RED, COLOR_GREEN, COLOR_YELLOW,
COLOR_BLUE, COLOR_MAGENTA, COLOR_CYAN, COLOR_WHITE };
/* Mapping data for the six terminfo colors that resolve to pairs of nethack
* colors. Black and white are handled specially.
*/
const struct {int ti_color, nh_color, nh_bright_color;} ti_map[6] =
{
{COLOR_RED,CLR_RED,CLR_ORANGE},
{COLOR_GREEN,CLR_GREEN,CLR_BRIGHT_GREEN},
{COLOR_YELLOW,CLR_BROWN,CLR_YELLOW},
{COLOR_BLUE,CLR_BLUE,CLR_BRIGHT_BLUE},
{COLOR_MAGENTA,CLR_MAGENTA,CLR_BRIGHT_MAGENTA},
{COLOR_CYAN,CLR_CYAN,CLR_BRIGHT_CYAN}
};
static char nilstring[] = "";
static void
init_hilite()
{
register int c;
char *setf, *scratch;
for (c = 0; c < SIZE(hilites); c++)
hilites[c] = nh_HI;
hilites[CLR_GRAY] = hilites[NO_COLOR] = (char *)0;
int md_len;
if (tgetnum("Co") < 8
|| (MD == NULL) || (strlen(MD) == 0)
|| ((setf = tgetstr("AF", (char **)0)) == (char *)0
&& (setf = tgetstr("Sf", (char **)0)) == (char *)0))
{
/* Fallback when colors not available
* It's arbitrary to collapse all colors except gray
* together, but that's what the previous code did.
*/
hilites[CLR_BLACK] = nh_HI;
hilites[CLR_RED] = nh_HI;
hilites[CLR_GREEN] = nh_HI;
hilites[CLR_BROWN] = nh_HI;
hilites[CLR_BLUE] = nh_HI;
hilites[CLR_MAGENTA] = nh_HI;
hilites[CLR_CYAN] = nh_HI;
hilites[CLR_GRAY] = nilstring;
hilites[NO_COLOR] = nilstring;
hilites[CLR_ORANGE] = nh_HI;
hilites[CLR_BRIGHT_GREEN] = nh_HI;
hilites[CLR_YELLOW] = nh_HI;
hilites[CLR_BRIGHT_BLUE] = nh_HI;
hilites[CLR_BRIGHT_MAGENTA] = nh_HI;
hilites[CLR_BRIGHT_CYAN] = nh_HI;
hilites[CLR_WHITE] = nh_HI;
return;
for (c = 0; c < CLR_MAX / 2; c++) {
scratch = tparm(setf, ti_map[c]);
if (c != CLR_GRAY) {
hilites[c] = (char *) alloc(strlen(scratch) + 1);
Strcpy(hilites[c], scratch);
}
if (c != CLR_BLACK) {
hilites[c|BRIGHT] = (char*) alloc(strlen(scratch)+strlen(MD)+1);
Strcpy(hilites[c|BRIGHT], MD);
Strcat(hilites[c|BRIGHT], scratch);
}
md_len = strlen(MD);
c = 6;
while (c--) {
char *work;
scratch = tparm(setf,ti_map[c].ti_color);
work = (char *) alloc(strlen(scratch) + md_len + 1);
Strcpy(work,MD);
hilites[ti_map[c].nh_bright_color] = work;
work += md_len;
Strcpy(work,scratch);
hilites[ti_map[c].nh_color] = work;
}
scratch = tparm(setf,COLOR_WHITE);
hilites[CLR_WHITE] = (char *) alloc(strlen(scratch) + md_len + 1);
Strcpy(hilites[CLR_WHITE],MD);
Strcat(hilites[CLR_WHITE],scratch);
hilites[CLR_GRAY] = nilstring;
hilites[NO_COLOR] = nilstring;
if (iflags.wc2_darkgray) {
/* On many terminals, esp. those using classic PC CGA/EGA/VGA
* textmode, specifying "hilight" and "black" simultaneously
* produces a dark shade of gray that is visible against a
* black background. We can use it to represent black objects.
*/
scratch = tparm(setf,COLOR_BLACK);
hilites[CLR_BLACK] = (char *) alloc(strlen(scratch) + md_len + 1);
Strcpy(hilites[CLR_BLACK],MD);
Strcat(hilites[CLR_BLACK],scratch);
} else {
/* But it's concievable that hilighted black-on-black could
* still be invisible on many others. We substitute blue for
* black.
*/
hilites[CLR_BLACK] = hilites[CLR_BLUE];
}
}
static void
kill_hilite()
{
/* if colors weren't available, no freeing needed */
if (hilites[CLR_BLACK] == nh_HI)
return;
if (hilites[CLR_BLACK] != hilites[CLR_BLUE])
free(hilites[CLR_BLACK]);
/* CLR_BLUE overlaps CLR_BRIGHT_BLUE, do not free */
/* CLR_GREEN overlaps CLR_BRIGHT_GREEN, do not free */
/* CLR_CYAN overlaps CLR_BRIGHT_CYAN, do not free */
/* CLR_RED overlaps CLR_ORANGE, do not free */
/* CLR_MAGENTA overlaps CLR_BRIGHT_MAGENTA, do not free */
/* CLR_BROWN overlaps CLR_YELLOW, do not free */
/* CLR_GRAY is static 'nilstring', do not free */
/* NO_COLOR is static 'nilstring', do not free */
free(hilites[CLR_BRIGHT_BLUE]);
free(hilites[CLR_BRIGHT_GREEN]);
free(hilites[CLR_BRIGHT_CYAN]);
free(hilites[CLR_YELLOW]);
free(hilites[CLR_ORANGE]);
free(hilites[CLR_BRIGHT_MAGENTA]);
free(hilites[CLR_WHITE]);
}
# else /* UNIX && TERMINFO */
# ifndef TOS
@@ -1011,7 +1094,6 @@ init_hilite()
# endif
# endif /* TOS */
}
# endif /* UNIX */
static void
kill_hilite()
@@ -1029,6 +1111,7 @@ kill_hilite()
# endif
return;
}
# endif /* UNIX */
#endif /* TEXTCOLOR */
+32 -6
View File
@@ -1,4 +1,4 @@
/* NetHack 3.5 wintty.c $NHDT-Date: 1426465444 2015/03/16 00:24:04 $ $NHDT-Branch: debug $:$NHDT-Revision: 1.71 $ */
/* NetHack 3.5 wintty.c $NHDT-Date: 1427667623 2015/03/29 22:20:23 $ $NHDT-Branch: master $:$NHDT-Revision: 1.75 $ */
/* NetHack 3.5 wintty.c $Date: 2012/01/22 06:27:09 $ $Revision: 1.66 $ */
/* Copyright (c) David Cohrs, 1991 */
/* NetHack may be freely redistributed. See license for details. */
@@ -56,7 +56,7 @@ struct window_procs tty_procs = {
#if defined(SELECTSAVED)
WC2_SELECTSAVED|
#endif
0L,
WC2_DARKGRAY,
tty_init_nhwindows,
tty_player_selection,
tty_askname,
@@ -1391,10 +1391,11 @@ struct WinDesc *cw;
{
tty_menu_item *page_start, *page_end, *curr;
long count;
int n, curr_page, page_lines;
int n, curr_page, page_lines, resp_len;
boolean finished, counting, reset_count;
char *cp, *rp, resp[QBUFSZ], gacc[QBUFSZ],
*msave, *morestr;
*msave, *morestr, really_morc;
#define MENU_EXPLICIT_CHOICE 0x7f /* pseudo menu manipulation char */
curr_page = page_lines = 0;
page_start = page_end = 0;
@@ -1461,6 +1462,8 @@ struct WinDesc *cw;
for (page_lines = 0, curr = page_start;
curr != page_end;
page_lines++, curr = curr->next) {
int color = NO_COLOR, attr = ATR_NONE;
boolean menucolr = FALSE;
if (curr->selector)
*rp++ = curr->selector;
@@ -1476,6 +1479,11 @@ struct WinDesc *cw;
* actually output the character. We're faster doing
* this.
*/
if (iflags.use_menu_color &&
(menucolr = get_menu_coloring(curr->str, &color,&attr))) {
term_start_attr(attr);
if (color != NO_COLOR) term_start_color(color);
} else
term_start_attr(curr->attr);
for (n = 0, cp = curr->str;
#ifndef WIN32CON
@@ -1493,6 +1501,10 @@ struct WinDesc *cw;
(void) putchar('#'); /* count selected */
} else
(void) putchar(*cp);
if (iflags.use_menu_color && menucolr) {
if (color != NO_COLOR) term_end_color();
term_end_attr(attr);
} else
term_end_attr(curr->attr);
}
} else {
@@ -1501,6 +1513,8 @@ struct WinDesc *cw;
page_lines = 0;
}
*rp = 0;
/* remember how many explicit menu choices there are */
resp_len = (int)strlen(resp);
/* corner window - clear extra lines from last page */
if (cw->offx) {
@@ -1533,7 +1547,15 @@ struct WinDesc *cw;
xwaitforspace(resp);
}
morc = map_menu_cmd(morc);
really_morc = morc; /* (only used with MENU_EXPLICIT_CHOICE */
if ((rp = index(resp, morc)) != 0 && rp < resp + resp_len)
/* explicit menu selection; don't override it if it also
happens to match a mapped menu command (such as ':' to
look inside a container vs ':' to search) */
morc = MENU_EXPLICIT_CHOICE;
else
morc = map_menu_cmd(morc);
switch (morc) {
case '0':
/* special case: '0' is also the default ball class */
@@ -1646,7 +1668,7 @@ struct WinDesc *cw;
boolean on_curr_page = FALSE;
int lineno = 0;
tty_getlin("Search for:", tmpbuf);
if (!tmpbuf || tmpbuf[0] == '\033') break;
if (!tmpbuf[0] || tmpbuf[0] == '\033') break;
Sprintf(searchbuf, "*%s*", tmpbuf);
for (curr = cw->mlist; curr; curr = curr->next) {
if (on_curr_page) lineno++;
@@ -1664,6 +1686,9 @@ struct WinDesc *cw;
}
}
break;
case MENU_EXPLICIT_CHOICE:
morc = really_morc;
/*FALLTHRU*/
default:
if (cw->how == PICK_NONE || !index(resp, morc)) {
/* unacceptable input received */
@@ -1809,6 +1834,7 @@ tty_display_nhwindow(window, blocking)
cw->offx = (uchar) (int)
max((int) 10, (int) (ttyDisplay->cols - cw->maxcol - 1));
#endif
if(cw->offx < 0) cw->offx = 0;
if(cw->type == NHW_MENU)
cw->offy = 0;
if(ttyDisplay->toplin == 1)
+22 -3
View File
@@ -17,10 +17,14 @@
@echo LEXYYC set to $(LEXYYC)
!ENDIF
# these won't have an impact unless YACC/LEX are defined
YTABC = y.tab.c
YTABH = y.tab.h
LEXYYC = lex.yy.c
default: all
all: ..\util\lev_yacc.c ..\util\lev_lex.c
all: tools ..\util\lev_yacc.c ..\util\lev_lex.c
rebuild: clean all
@@ -29,15 +33,29 @@ clean:
-del ..\util\lev_yacc.c
-del ..\include\lev_comp.h
tools:
!IFDEF YACC
@echo Yacc-alike set to $(YACC)
@echo YTABC set to $(YTABC)
@echo YTABH set to $(YTABH)
!ENDIF
!IFDEF LEX
@echo Lex-alike set to $(LEX)
@echo LEXYYC set to $(LEXYYC)
!ENDIF
#==========================================
# Level Compiler Stuff
#==========================================
..\util\lev_yacc.c ..\include\lev_comp.h: ..\util\lev_comp.y
!IF "$(YACC)"==""
!IFNDEF YACC
@echo Using pre-built lev_yacc.c and lev_comp.h
@copy ..\sys\share\lev_yacc.c ..\util\lev_yacc.c
@copy ..\sys\share\lev_comp.h ..\include\lev_comp.h
!ELSE
@echo Generating lev_yacc.c and lev_comp.h
chdir ..\util
$(YACC) -d lev_comp.y
copy $(YTABC) $@
@@ -48,10 +66,11 @@ clean:
!ENDIF
..\util\lev_lex.c: ..\util\lev_comp.l
!IF "$(LEX)"==""
!IFNDEF LEX
@echo Using pre-built lev_lex.c
@copy ..\sys\share\lev_lex.c $@
!ELSE
@echo Generating lev_lex.c
chdir ..\util
$(LEX) lev_comp.l
copy $(LEXYYC) $@
-1
View File
@@ -45,7 +45,6 @@ static void nhcoord2display(PNHMapWindow data, int x, int y, LPRECT lpOut);
#if (VERSION_MAJOR < 4) && (VERSION_MINOR < 4) && (PATCHLEVEL < 2)
static void nhglyph2charcolor(short glyph, uchar* ch, int* color);
#endif
static COLORREF nhcolor_to_RGB(int c);
HWND mswin_init_map_window () {
static int run_once = 0;
+1
View File
@@ -12,6 +12,7 @@
#include "global.h"
COLORREF nhcolor_to_RGB (int c);
HWND mswin_init_map_window (void);
void mswin_map_stretch(HWND hWnd, LPSIZE lpsz, BOOL redraw);
int mswin_map_mode(HWND hWnd, int mode);
+10
View File
@@ -917,6 +917,9 @@ BOOL onDrawItem(HWND hWnd, WPARAM wParam, LPARAM lParam)
int column;
int spacing = 0;
int color = NO_COLOR, attr;
boolean menucolr = FALSE;
lpdis = (LPDRAWITEMSTRUCT) lParam;
/* If there are no list box items, skip this message. */
@@ -967,6 +970,13 @@ BOOL onDrawItem(HWND hWnd, WPARAM wParam, LPARAM lParam)
buf[0] = item->accelerator;
buf[1] = '\x0';
if (iflags.use_menu_color &&
(menucolr = get_menu_coloring(item->str, &color,&attr))) {
/* TODO: use attr too */
if (color != NO_COLOR)
SetTextColor(lpdis->hDC, nhcolor_to_RGB(color));
}
SetRect( &drawRect, x, lpdis->rcItem.top, lpdis->rcItem.right, lpdis->rcItem.bottom );
DrawText(lpdis->hDC, NH_A2W(buf, wbuf, 2), 1, &drawRect, DT_LEFT | DT_VCENTER | DT_SINGLELINE | DT_NOPREFIX);
}