couple of string concatenations in win/tty/
Plus a modest amount (really!) of reformatting. Also got rid of 'copy_of()' since dupstr() does the same thing [except for the 'treat Null as ""' part; when needed, that can be done in the call: dupstr(!str ? "" : str)].
This commit is contained in:
+39
-34
@@ -1,4 +1,4 @@
|
|||||||
/* NetHack 3.6 termcap.c $NHDT-Date: 1432512813 2015/05/25 00:13:33 $ $NHDT-Branch: master $:$NHDT-Revision: 1.21 $ */
|
/* NetHack 3.6 termcap.c $NHDT-Date: 1446856761 2015/11/07 00:39:21 $ $NHDT-Branch: master $:$NHDT-Revision: 1.22 $ */
|
||||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||||
/* NetHack may be freely redistributed. See license for details. */
|
/* NetHack may be freely redistributed. See license for details. */
|
||||||
|
|
||||||
@@ -7,7 +7,6 @@
|
|||||||
#if defined(TTY_GRAPHICS) && !defined(NO_TERMS)
|
#if defined(TTY_GRAPHICS) && !defined(NO_TERMS)
|
||||||
|
|
||||||
#include "wintty.h"
|
#include "wintty.h"
|
||||||
|
|
||||||
#include "tcap.h"
|
#include "tcap.h"
|
||||||
|
|
||||||
#ifdef MICROPORT_286_BUG
|
#ifdef MICROPORT_286_BUG
|
||||||
@@ -134,7 +133,7 @@ int *wid, *hgt;
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
HO = "\033[H";
|
HO = "\033[H";
|
||||||
/* nh_CD = "\033[J"; */
|
/* nh_CD = "\033[J"; */
|
||||||
CE = "\033[K"; /* the ANSI termcap */
|
CE = "\033[K"; /* the ANSI termcap */
|
||||||
#ifndef TERMLIB
|
#ifndef TERMLIB
|
||||||
nh_CM = "\033[%d;%dH";
|
nh_CM = "\033[%d;%dH";
|
||||||
@@ -262,7 +261,7 @@ int *wid, *hgt;
|
|||||||
CRMOD, and many output routines will have to be modified
|
CRMOD, and many output routines will have to be modified
|
||||||
slightly. Let's leave that till the next release. */
|
slightly. Let's leave that till the next release. */
|
||||||
XD = Tgetstr("xd");
|
XD = Tgetstr("xd");
|
||||||
/* not: XD = Tgetstr("do"); */
|
/* not: XD = Tgetstr("do"); */
|
||||||
if (!(nh_CM = Tgetstr("cm"))) {
|
if (!(nh_CM = Tgetstr("cm"))) {
|
||||||
if (!UP && !HO)
|
if (!UP && !HO)
|
||||||
error("NetHack needs CM or UP or HO.");
|
error("NetHack needs CM or UP or HO.");
|
||||||
@@ -286,9 +285,9 @@ int *wid, *hgt;
|
|||||||
KE = Tgetstr("ke"); /* keypad end (ordinary mode [ie, digits]) */
|
KE = Tgetstr("ke"); /* keypad end (ordinary mode [ie, digits]) */
|
||||||
MR = Tgetstr("mr"); /* reverse */
|
MR = Tgetstr("mr"); /* reverse */
|
||||||
#if 0
|
#if 0
|
||||||
MB = Tgetstr("mb"); /* blink */
|
MB = Tgetstr("mb"); /* blink */
|
||||||
MD = Tgetstr("md"); /* boldface */
|
MD = Tgetstr("md"); /* boldface */
|
||||||
MH = Tgetstr("mh"); /* dim */
|
MH = Tgetstr("mh"); /* dim */
|
||||||
#endif
|
#endif
|
||||||
ME = Tgetstr("me"); /* turn off all attributes */
|
ME = Tgetstr("me"); /* turn off all attributes */
|
||||||
if (!ME || (SE == nullstr))
|
if (!ME || (SE == nullstr))
|
||||||
@@ -394,12 +393,12 @@ tty_decgraphics_termcap_fixup()
|
|||||||
if (!KS)
|
if (!KS)
|
||||||
KS = appMode; /* ESC= (application keypad mode) */
|
KS = appMode; /* ESC= (application keypad mode) */
|
||||||
if (!KE)
|
if (!KE)
|
||||||
KE = numMode; /* ESC> (numeric keypad mode) */
|
KE = numMode; /* ESC> (numeric keypad mode) */
|
||||||
/*
|
/*
|
||||||
* Select the line-drawing character set as the alternate font.
|
* Select the line-drawing character set as the alternate font.
|
||||||
* Do not select NA ASCII as the primary font since people may
|
* Do not select NA ASCII as the primary font since people may
|
||||||
* reasonably be using the UK character set.
|
* reasonably be using the UK character set.
|
||||||
*/
|
*/
|
||||||
if (SYMHANDLING(H_DEC))
|
if (SYMHANDLING(H_DEC))
|
||||||
xputs("\033)0");
|
xputs("\033)0");
|
||||||
#ifdef PC9800
|
#ifdef PC9800
|
||||||
@@ -544,14 +543,15 @@ int x, y;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((int) ttyDisplay->curx < x) { /* Go to the right. */
|
if ((int) ttyDisplay->curx < x) { /* Go to the right. */
|
||||||
if (!nh_ND)
|
if (!nh_ND) {
|
||||||
cmov(x, y);
|
cmov(x, y);
|
||||||
else /* bah */
|
} else { /* bah */
|
||||||
/* should instead print what is there already */
|
/* should instead print what is there already */
|
||||||
while ((int) ttyDisplay->curx < x) {
|
while ((int) ttyDisplay->curx < x) {
|
||||||
xputs(nh_ND);
|
xputs(nh_ND);
|
||||||
ttyDisplay->curx++;
|
ttyDisplay->curx++;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else if ((int) ttyDisplay->curx > x) {
|
} else if ((int) ttyDisplay->curx > x) {
|
||||||
while ((int) ttyDisplay->curx > x) { /* Go to the left. */
|
while ((int) ttyDisplay->curx > x) { /* Go to the left. */
|
||||||
xputs(BC);
|
xputs(BC);
|
||||||
@@ -598,13 +598,13 @@ const char *s;
|
|||||||
void
|
void
|
||||||
cl_end()
|
cl_end()
|
||||||
{
|
{
|
||||||
if (CE)
|
if (CE) {
|
||||||
xputs(CE);
|
xputs(CE);
|
||||||
else { /* no-CE fix - free after Harold Rynes */
|
} else { /* no-CE fix - free after Harold Rynes */
|
||||||
/* this looks terrible, especially on a slow terminal
|
|
||||||
but is better than nothing */
|
|
||||||
register int cx = ttyDisplay->curx + 1;
|
register int cx = ttyDisplay->curx + 1;
|
||||||
|
|
||||||
|
/* this looks terrible, especially on a slow terminal
|
||||||
|
but is better than nothing */
|
||||||
while (cx < CO) {
|
while (cx < CO) {
|
||||||
xputc(' ');
|
xputc(' ');
|
||||||
cx++;
|
cx++;
|
||||||
@@ -656,34 +656,39 @@ standoutend()
|
|||||||
void
|
void
|
||||||
revbeg()
|
revbeg()
|
||||||
{
|
{
|
||||||
if(MR) xputs(MR);
|
if (MR)
|
||||||
|
xputs(MR);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
boldbeg()
|
boldbeg()
|
||||||
{
|
{
|
||||||
if(MD) xputs(MD);
|
if (MD)
|
||||||
|
xputs(MD);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
blinkbeg()
|
blinkbeg()
|
||||||
{
|
{
|
||||||
if(MB) xputs(MB);
|
if (MB)
|
||||||
|
xputs(MB);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
dimbeg()
|
dimbeg()
|
||||||
/* not in most termcap entries */
|
|
||||||
{
|
{
|
||||||
if(MH) xputs(MH);
|
/* not in most termcap entries */
|
||||||
|
if (MH)
|
||||||
|
xputs(MH);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
m_end()
|
m_end()
|
||||||
{
|
{
|
||||||
if(ME) xputs(ME);
|
if (ME)
|
||||||
|
xputs(ME);
|
||||||
}
|
}
|
||||||
#endif
|
#endif /*0*/
|
||||||
|
|
||||||
void
|
void
|
||||||
backsp()
|
backsp()
|
||||||
@@ -1007,7 +1012,7 @@ int *fg, *bg;
|
|||||||
|
|
||||||
while (c < len) {
|
while (c < len) {
|
||||||
if ((code = atoi(&str[c])) == 0) { /* reset */
|
if ((code = atoi(&str[c])) == 0) { /* reset */
|
||||||
/* this also catches errors */
|
/* this also catches errors */
|
||||||
#ifdef MICRO
|
#ifdef MICRO
|
||||||
*fg = CLR_GRAY;
|
*fg = CLR_GRAY;
|
||||||
*bg = CLR_BLACK;
|
*bg = CLR_BLACK;
|
||||||
@@ -1017,13 +1022,13 @@ int *fg, *bg;
|
|||||||
} else if (code == 1) { /* bold */
|
} else if (code == 1) { /* bold */
|
||||||
*fg |= BRIGHT;
|
*fg |= BRIGHT;
|
||||||
#if 0
|
#if 0
|
||||||
/* I doubt we'll ever resort to using blinking characters,
|
/* I doubt we'll ever resort to using blinking characters,
|
||||||
unless we want a pulsing glow for something. But, in case
|
unless we want a pulsing glow for something. But, in case
|
||||||
we do... - 3. */
|
we do... -3. */
|
||||||
} else if (code == 5) { /* blinking */
|
} else if (code == 5) { /* blinking */
|
||||||
*fg |= BLINK;
|
*fg |= BLINK;
|
||||||
} else if (code == 25) { /* stop blinking */
|
} else if (code == 25) { /* stop blinking */
|
||||||
*fg &= ~BLINK;
|
*fg &= ~BLINK;
|
||||||
#endif
|
#endif
|
||||||
} else if (code == 7 || code == 27) { /* reverse */
|
} else if (code == 7 || code == 27) { /* reverse */
|
||||||
code = *fg & ~BRIGHT;
|
code = *fg & ~BRIGHT;
|
||||||
|
|||||||
+103
-116
@@ -1,5 +1,5 @@
|
|||||||
/* NetHack 3.6 wintty.c $NHDT-Date: 1433984834 2015/06/11 01:07:14 $ $NHDT-Branch: master $:$NHDT-Revision: 1.106 $ */
|
/* NetHack 3.6 wintty.c $NHDT-Date: 1446856765 2015/11/07 00:39:25 $ $NHDT-Branch: master $:$NHDT-Revision: 1.110 $ */
|
||||||
/* Copyright (c) David Cohrs, 1991 */
|
/* Copyright (c) David Cohrs, 1991 */
|
||||||
/* NetHack may be freely redistributed. See license for details. */
|
/* NetHack may be freely redistributed. See license for details. */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -157,7 +157,6 @@ STATIC_DCL void FDECL(process_text_window, (winid, struct WinDesc *));
|
|||||||
STATIC_DCL tty_menu_item *FDECL(reverse, (tty_menu_item *));
|
STATIC_DCL tty_menu_item *FDECL(reverse, (tty_menu_item *));
|
||||||
STATIC_DCL const char *FDECL(compress_str, (const char *));
|
STATIC_DCL const char *FDECL(compress_str, (const char *));
|
||||||
STATIC_DCL void FDECL(tty_putsym, (winid, int, int, CHAR_P));
|
STATIC_DCL void FDECL(tty_putsym, (winid, int, int, CHAR_P));
|
||||||
STATIC_DCL char *FDECL(copy_of, (const char *));
|
|
||||||
STATIC_DCL void FDECL(bail, (const char *)); /* __attribute__((noreturn)) */
|
STATIC_DCL void FDECL(bail, (const char *)); /* __attribute__((noreturn)) */
|
||||||
STATIC_DCL void FDECL(setup_rolemenu, (winid, BOOLEAN_P, int, int, int));
|
STATIC_DCL void FDECL(setup_rolemenu, (winid, BOOLEAN_P, int, int, int));
|
||||||
STATIC_DCL void FDECL(setup_racemenu, (winid, BOOLEAN_P, int, int, int));
|
STATIC_DCL void FDECL(setup_racemenu, (winid, BOOLEAN_P, int, int, int));
|
||||||
@@ -204,12 +203,12 @@ winch()
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
getwindowsz();
|
getwindowsz();
|
||||||
/* For long running events such as multi-page menus and
|
/* For long running events such as multi-page menus and
|
||||||
* display_file(), we note the signal's occurance and
|
* display_file(), we note the signal's occurance and
|
||||||
* hope the code there decides to handle the situation
|
* hope the code there decides to handle the situation
|
||||||
* and reset the flag. There will be race conditions
|
* and reset the flag. There will be race conditions
|
||||||
* when handling this - code handlers so it doesn't matter.
|
* when handling this - code handlers so it doesn't matter.
|
||||||
*/
|
*/
|
||||||
#ifdef notyet
|
#ifdef notyet
|
||||||
winch_seen = TRUE;
|
winch_seen = TRUE;
|
||||||
#endif
|
#endif
|
||||||
@@ -727,21 +726,21 @@ makepicks:
|
|||||||
} while (ROLE < 0 || RACE < 0 || GEND < 0 || ALGN < 0);
|
} while (ROLE < 0 || RACE < 0 || GEND < 0 || ALGN < 0);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Role, race, &c have now been determined;
|
* Role, race, &c have now been determined;
|
||||||
* ask for confirmation and maybe go back to choose all over again.
|
* ask for confirmation and maybe go back to choose all over again.
|
||||||
*
|
*
|
||||||
* Uses ynaq for familiarity, although 'a' is usually a
|
* Uses ynaq for familiarity, although 'a' is usually a
|
||||||
* superset of 'y' but here is an alternate form of 'n'.
|
* superset of 'y' but here is an alternate form of 'n'.
|
||||||
* Menu layout:
|
* Menu layout:
|
||||||
* title: Is this ok? [ynaq]
|
* title: Is this ok? [ynaq]
|
||||||
* blank:
|
* blank:
|
||||||
* text: $name, $alignment $gender $race $role
|
* text: $name, $alignment $gender $race $role
|
||||||
* blank:
|
* blank:
|
||||||
* menu: y + yes; play
|
* menu: y + yes; play
|
||||||
* n - no; pick again
|
* n - no; pick again
|
||||||
* maybe: a - no; rename hero
|
* maybe: a - no; rename hero
|
||||||
* q - quit
|
* q - quit
|
||||||
* (end)
|
* (end)
|
||||||
*/
|
*/
|
||||||
getconfirmation = (pick4u != 'a' && !flags.randomall);
|
getconfirmation = (pick4u != 'a' && !flags.randomall);
|
||||||
while (getconfirmation) {
|
while (getconfirmation) {
|
||||||
@@ -794,26 +793,25 @@ makepicks:
|
|||||||
default: /* 'q' or ESC */
|
default: /* 'q' or ESC */
|
||||||
goto give_up; /* quit */
|
goto give_up; /* quit */
|
||||||
break;
|
break;
|
||||||
case 3: /* 'a' */
|
case 3: { /* 'a' */
|
||||||
/*
|
/*
|
||||||
* TODO: what, if anything, should be done if the name is
|
* TODO: what, if anything, should be done if the name is
|
||||||
* changed to or from "wizard" after port-specific startup
|
* changed to or from "wizard" after port-specific startup
|
||||||
* code has set flags.debug based on the original name?
|
* code has set flags.debug based on the original name?
|
||||||
*/
|
*/
|
||||||
{
|
int saveROLE, saveRACE, saveGEND, saveALGN;
|
||||||
int saveROLE, saveRACE, saveGEND, saveALGN;
|
|
||||||
|
|
||||||
iflags.renameinprogress = TRUE;
|
iflags.renameinprogress = TRUE;
|
||||||
/* plnamesuffix() can change any or all of ROLE, RACE,
|
/* plnamesuffix() can change any or all of ROLE, RACE,
|
||||||
GEND, ALGN; we'll override that and honor only the name */
|
GEND, ALGN; we'll override that and honor only the name */
|
||||||
saveROLE = ROLE, saveRACE = RACE, saveGEND = GEND,
|
saveROLE = ROLE, saveRACE = RACE, saveGEND = GEND,
|
||||||
saveALGN = ALGN;
|
saveALGN = ALGN;
|
||||||
*plname = '\0';
|
*plname = '\0';
|
||||||
plnamesuffix(); /* calls askname() when plname[] is empty */
|
plnamesuffix(); /* calls askname() when plname[] is empty */
|
||||||
ROLE = saveROLE, RACE = saveRACE, GEND = saveGEND,
|
ROLE = saveROLE, RACE = saveRACE, GEND = saveGEND,
|
||||||
ALGN = saveALGN;
|
ALGN = saveALGN;
|
||||||
}
|
|
||||||
break; /* getconfirmation is still True */
|
break; /* getconfirmation is still True */
|
||||||
|
}
|
||||||
case 2: /* 'n' */
|
case 2: /* 'n' */
|
||||||
/* start fresh, but bypass "shall I pick everything for you?"
|
/* start fresh, but bypass "shall I pick everything for you?"
|
||||||
step; any partial role selection via config file, command
|
step; any partial role selection via config file, command
|
||||||
@@ -1051,7 +1049,7 @@ tty_askname()
|
|||||||
switch (restore_menu(BASE_WINDOW)) {
|
switch (restore_menu(BASE_WINDOW)) {
|
||||||
case -1:
|
case -1:
|
||||||
bail("Until next time then..."); /* quit */
|
bail("Until next time then..."); /* quit */
|
||||||
/*NOTREACHED*/
|
/*NOTREACHED*/
|
||||||
case 0:
|
case 0:
|
||||||
break; /* no game chosen; start new game */
|
break; /* no game chosen; start new game */
|
||||||
case 1:
|
case 1:
|
||||||
@@ -1367,6 +1365,7 @@ boolean free_data;
|
|||||||
cw->maxrow = cw->maxcol = 0;
|
cw->maxrow = cw->maxcol = 0;
|
||||||
if (cw->mlist) {
|
if (cw->mlist) {
|
||||||
tty_menu_item *temp;
|
tty_menu_item *temp;
|
||||||
|
|
||||||
while ((temp = cw->mlist) != 0) {
|
while ((temp = cw->mlist) != 0) {
|
||||||
cw->mlist = cw->mlist->next;
|
cw->mlist = cw->mlist->next;
|
||||||
if (temp->str)
|
if (temp->str)
|
||||||
@@ -1494,6 +1493,7 @@ int lineno;
|
|||||||
tty_menu_item *item;
|
tty_menu_item *item;
|
||||||
{
|
{
|
||||||
char ch = item->selected ? (item->count == -1L ? '+' : '#') : '-';
|
char ch = item->selected ? (item->count == -1L ? '+' : '#') : '-';
|
||||||
|
|
||||||
tty_curs(window, 4, lineno);
|
tty_curs(window, 4, lineno);
|
||||||
term_start_attr(item->attr);
|
term_start_attr(item->attr);
|
||||||
(void) putchar(ch);
|
(void) putchar(ch);
|
||||||
@@ -1553,8 +1553,7 @@ char acc; /* group accelerator, 0 => all */
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Invert all entries that match the give group accelerator (or all if
|
* Invert all entries that match the give group accelerator (or all if zero).
|
||||||
* zero).
|
|
||||||
*/
|
*/
|
||||||
STATIC_OVL void
|
STATIC_OVL void
|
||||||
invert_all(window, page_start, page_end, acc)
|
invert_all(window, page_start, page_end, acc)
|
||||||
@@ -1789,8 +1788,8 @@ struct WinDesc *cw;
|
|||||||
* item is selected. If not selected, then
|
* item is selected. If not selected, then
|
||||||
* "0b" could mean:
|
* "0b" could mean:
|
||||||
*
|
*
|
||||||
* count starting zero: "zero b's"
|
* count starting zero: "zero b's"
|
||||||
* ignore starting zero: "select b"
|
* ignore starting zero: "select b"
|
||||||
*
|
*
|
||||||
* At present I don't know which is better.
|
* At present I don't know which is better.
|
||||||
*/
|
*/
|
||||||
@@ -2051,7 +2050,7 @@ boolean blocking; /* with ttys, all windows are blocking */
|
|||||||
break;
|
break;
|
||||||
case NHW_TEXT:
|
case NHW_TEXT:
|
||||||
cw->maxcol = ttyDisplay->cols; /* force full-screen mode */
|
cw->maxcol = ttyDisplay->cols; /* force full-screen mode */
|
||||||
/*FALLTHRU*/
|
/*FALLTHRU*/
|
||||||
case NHW_MENU:
|
case NHW_MENU:
|
||||||
cw->active = 1;
|
cw->active = 1;
|
||||||
#ifdef H2344_BROKEN
|
#ifdef H2344_BROKEN
|
||||||
@@ -2332,7 +2331,7 @@ const char *str;
|
|||||||
|
|
||||||
switch (cw->type) {
|
switch (cw->type) {
|
||||||
case NHW_MESSAGE:
|
case NHW_MESSAGE:
|
||||||
/* really do this later */
|
/* really do this later */
|
||||||
#if defined(USER_SOUNDS) && defined(WIN32CON)
|
#if defined(USER_SOUNDS) && defined(WIN32CON)
|
||||||
play_sound_for_message(str);
|
play_sound_for_message(str);
|
||||||
#endif
|
#endif
|
||||||
@@ -2373,7 +2372,7 @@ const char *str;
|
|||||||
cw->cury = (cw->cury + 1) % 2;
|
cw->cury = (cw->cury + 1) % 2;
|
||||||
cw->curx = 0;
|
cw->curx = 0;
|
||||||
#ifdef STATUS_VIA_WINDOWPORT
|
#ifdef STATUS_VIA_WINDOWPORT
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case NHW_MAP:
|
case NHW_MAP:
|
||||||
@@ -2589,13 +2588,15 @@ boolean preselected; /* item is marked as selected */
|
|||||||
if (str == (const char *) 0)
|
if (str == (const char *) 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (window == WIN_ERR || (cw = wins[window]) == (struct WinDesc *) 0
|
if (window == WIN_ERR
|
||||||
|
|| (cw = wins[window]) == (struct WinDesc *) 0
|
||||||
|| cw->type != NHW_MENU)
|
|| cw->type != NHW_MENU)
|
||||||
panic(winpanicstr, window);
|
panic(winpanicstr, window);
|
||||||
|
|
||||||
cw->nitems++;
|
cw->nitems++;
|
||||||
if (identifier->a_void) {
|
if (identifier->a_void) {
|
||||||
int len = strlen(str);
|
int len = strlen(str);
|
||||||
|
|
||||||
if (len >= BUFSZ) {
|
if (len >= BUFSZ) {
|
||||||
/* We *think* everything's coming in off at most BUFSZ bufs... */
|
/* We *think* everything's coming in off at most BUFSZ bufs... */
|
||||||
impossible("Menu item too long (%d).", len);
|
impossible("Menu item too long (%d).", len);
|
||||||
@@ -2615,7 +2616,7 @@ boolean preselected; /* item is marked as selected */
|
|||||||
item->selector = ch;
|
item->selector = ch;
|
||||||
item->gselector = gch;
|
item->gselector = gch;
|
||||||
item->attr = attr;
|
item->attr = attr;
|
||||||
item->str = copy_of(newstr);
|
item->str = dupstr(newstr ? newstr : "");
|
||||||
|
|
||||||
item->next = cw->mlist;
|
item->next = cw->mlist;
|
||||||
cw->mlist = item;
|
cw->mlist = item;
|
||||||
@@ -2718,9 +2719,9 @@ const char *prompt; /* prompt to for menu */
|
|||||||
/* produce the largest demo string */
|
/* produce the largest demo string */
|
||||||
Sprintf(buf, "(%ld of %ld) ", cw->npages, cw->npages);
|
Sprintf(buf, "(%ld of %ld) ", cw->npages, cw->npages);
|
||||||
len = strlen(buf);
|
len = strlen(buf);
|
||||||
cw->morestr = copy_of("");
|
cw->morestr = dupstr("");
|
||||||
} else {
|
} else {
|
||||||
cw->morestr = copy_of("(end) ");
|
cw->morestr = dupstr("(end) ");
|
||||||
len = strlen(cw->morestr);
|
len = strlen(cw->morestr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3045,7 +3046,7 @@ int glyph, bkglyph;
|
|||||||
|
|
||||||
/* must be after color check; term_end_color may turn off inverse too */
|
/* must be after color check; term_end_color may turn off inverse too */
|
||||||
if (((special & MG_PET) && iflags.hilite_pet)
|
if (((special & MG_PET) && iflags.hilite_pet)
|
||||||
|| ((special & MG_OBJPILE) && iflags.hilite_pile)
|
|| ((special & MG_OBJPILE) && iflags.hilite_pile)
|
||||||
|| ((special & MG_DETECT) && iflags.use_inverse)) {
|
|| ((special & MG_DETECT) && iflags.use_inverse)) {
|
||||||
term_start_attr(ATR_INVERSE);
|
term_start_attr(ATR_INVERSE);
|
||||||
reverse_on = TRUE;
|
reverse_on = TRUE;
|
||||||
@@ -3131,10 +3132,9 @@ tty_nhgetch()
|
|||||||
if (WIN_MESSAGE != WIN_ERR && wins[WIN_MESSAGE])
|
if (WIN_MESSAGE != WIN_ERR && wins[WIN_MESSAGE])
|
||||||
wins[WIN_MESSAGE]->flags &= ~WIN_STOP;
|
wins[WIN_MESSAGE]->flags &= ~WIN_STOP;
|
||||||
#ifdef UNIX
|
#ifdef UNIX
|
||||||
i = ((++nesting == 1) ? tgetch() : (read(fileno(stdin),
|
i = (++nesting == 1) ? tgetch()
|
||||||
(genericptr_t) &nestbuf, 1) == 1
|
: (read(fileno(stdin), (genericptr_t) &nestbuf, 1)
|
||||||
? (int) nestbuf
|
== 1) ? (int) nestbuf : EOF;
|
||||||
: EOF));
|
|
||||||
--nesting;
|
--nesting;
|
||||||
#else
|
#else
|
||||||
i = tgetch();
|
i = tgetch();
|
||||||
@@ -3207,23 +3207,7 @@ char *posbar;
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
|
||||||
* Allocate a copy of the given string. If null, return a string of
|
|
||||||
* zero length.
|
|
||||||
*
|
|
||||||
* This is an exact duplicate of copy_of() in X11/winmenu.c.
|
|
||||||
*/
|
|
||||||
STATIC_OVL char *
|
|
||||||
copy_of(s)
|
|
||||||
const char *s;
|
|
||||||
{
|
|
||||||
if (!s)
|
|
||||||
s = "";
|
|
||||||
return strcpy((char *) alloc((unsigned) (strlen(s) + 1)), s);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef STATUS_VIA_WINDOWPORT
|
#ifdef STATUS_VIA_WINDOWPORT
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The following data structures come from the genl_ routines in
|
* The following data structures come from the genl_ routines in
|
||||||
* src/windows.c and as such are considered to be on the window-port
|
* src/windows.c and as such are considered to be on the window-port
|
||||||
@@ -3283,30 +3267,29 @@ tty_status_init()
|
|||||||
* -- the fldindex identifies which field is changing and
|
* -- the fldindex identifies which field is changing and
|
||||||
* is an integer index value from botl.h
|
* is an integer index value from botl.h
|
||||||
* -- fldindex could be any one of the following from botl.h:
|
* -- fldindex could be any one of the following from botl.h:
|
||||||
* BL_TITLE, BL_STR, BL_DX, BL_CO, BL_IN, BL_WI, BL_CH,
|
* BL_TITLE, BL_STR, BL_DX, BL_CO, BL_IN, BL_WI, BL_CH,
|
||||||
* BL_ALIGN, BL_SCORE, BL_CAP, BL_GOLD, BL_ENE, BL_ENEMAX,
|
* BL_ALIGN, BL_SCORE, BL_CAP, BL_GOLD, BL_ENE, BL_ENEMAX,
|
||||||
* BL_XP, BL_AC, BL_HD, BL_TIME, BL_HUNGER, BL_HP, BL_HPMAX,
|
* BL_XP, BL_AC, BL_HD, BL_TIME, BL_HUNGER, BL_HP, BL_HPMAX,
|
||||||
* BL_LEVELDESC, BL_EXP, BL_CONDITION
|
* BL_LEVELDESC, BL_EXP, BL_CONDITION
|
||||||
* -- fldindex could also be BL_FLUSH (-1), which is not really
|
* -- fldindex could also be BL_FLUSH (-1), which is not really
|
||||||
* a field index, but is a special trigger to tell the
|
* a field index, but is a special trigger to tell the
|
||||||
* windowport that it should redisplay all its status fields,
|
* windowport that it should redisplay all its status fields,
|
||||||
* even if no changes have been presented to it.
|
* even if no changes have been presented to it.
|
||||||
* -- ptr is usually a "char *", unless fldindex is BL_CONDITION.
|
* -- ptr is usually a "char *", unless fldindex is BL_CONDITION.
|
||||||
* If fldindex is BL_CONDITION, then ptr is a long value with
|
* If fldindex is BL_CONDITION, then ptr is a long value with
|
||||||
* any or none of the following bits set (from botl.h):
|
* any or none of the following bits set (from botl.h):
|
||||||
* BL_MASK_BLIND 0x00000001L
|
* BL_MASK_BLIND 0x00000001L
|
||||||
* BL_MASK_CONF 0x00000002L
|
* BL_MASK_CONF 0x00000002L
|
||||||
* BL_MASK_FOODPOIS 0x00000004L
|
* BL_MASK_FOODPOIS 0x00000004L
|
||||||
* BL_MASK_ILL 0x00000008L
|
* BL_MASK_ILL 0x00000008L
|
||||||
* BL_MASK_HALLU 0x00000010L
|
* BL_MASK_HALLU 0x00000010L
|
||||||
* BL_MASK_STUNNED 0x00000020L
|
* BL_MASK_STUNNED 0x00000020L
|
||||||
* BL_MASK_SLIMED 0x00000040L
|
* BL_MASK_SLIMED 0x00000040L
|
||||||
* -- The value passed for BL_GOLD includes a leading
|
* -- The value passed for BL_GOLD includes a leading
|
||||||
* symbol for GOLD "$:nnn". If the window port needs to use
|
* symbol for GOLD "$:nnn". If the window port needs to use
|
||||||
* the textual gold amount without the leading "$:" the port
|
* the textual gold amount without the leading "$:" the port
|
||||||
* will have to add 2 to the passed "ptr" for the BL_GOLD case.
|
* will have to add 2 to the passed "ptr" for the BL_GOLD case.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void
|
void
|
||||||
tty_status_update(fldidx, ptr, chg, percent)
|
tty_status_update(fldidx, ptr, chg, percent)
|
||||||
int fldidx, chg, percent;
|
int fldidx, chg, percent;
|
||||||
@@ -3326,10 +3309,11 @@ genericptr_t ptr;
|
|||||||
static boolean beenhere = FALSE;
|
static boolean beenhere = FALSE;
|
||||||
enum statusfields fieldorder[2][15] = {
|
enum statusfields fieldorder[2][15] = {
|
||||||
{ BL_TITLE, BL_STR, BL_DX, BL_CO, BL_IN, BL_WI, BL_CH, BL_ALIGN,
|
{ BL_TITLE, BL_STR, BL_DX, BL_CO, BL_IN, BL_WI, BL_CH, BL_ALIGN,
|
||||||
BL_SCORE, BL_FLUSH, BL_FLUSH, BL_FLUSH, BL_FLUSH, BL_FLUSH, BL_FLUSH},
|
BL_SCORE, BL_FLUSH, BL_FLUSH, BL_FLUSH, BL_FLUSH, BL_FLUSH,
|
||||||
|
BL_FLUSH },
|
||||||
{ BL_LEVELDESC, BL_GOLD, BL_HP, BL_HPMAX, BL_ENE, BL_ENEMAX,
|
{ BL_LEVELDESC, BL_GOLD, BL_HP, BL_HPMAX, BL_ENE, BL_ENEMAX,
|
||||||
BL_AC, BL_XP, BL_EXP, BL_HD, BL_TIME, BL_HUNGER,
|
BL_AC, BL_XP, BL_EXP, BL_HD, BL_TIME, BL_HUNGER,
|
||||||
BL_CAP, BL_CONDITION, BL_FLUSH}
|
BL_CAP, BL_CONDITION, BL_FLUSH }
|
||||||
};
|
};
|
||||||
|
|
||||||
if (fldidx != BL_FLUSH) {
|
if (fldidx != BL_FLUSH) {
|
||||||
@@ -3383,8 +3367,8 @@ genericptr_t ptr;
|
|||||||
{
|
{
|
||||||
int pct_th = 0;
|
int pct_th = 0;
|
||||||
if (tty_status_hilites[fldidx].thresholdtype != ANY_INT) {
|
if (tty_status_hilites[fldidx].thresholdtype != ANY_INT) {
|
||||||
impossible("tty_status_update: unsupported percentage "
|
impossible(
|
||||||
"threshold type %d",
|
"tty_status_update: unsupported percentage threshold type %d",
|
||||||
tty_status_hilites[fldidx].thresholdtype);
|
tty_status_hilites[fldidx].thresholdtype);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -3418,8 +3402,8 @@ genericptr_t ptr;
|
|||||||
c = (value & t->a_ulong) ? o : u;
|
c = (value & t->a_ulong) ? o : u;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
impossible("tty_status_update: unsupported absolute threshold "
|
impossible(
|
||||||
"type %d\n",
|
"tty_status_update: unsupported absolute threshold type %d\n",
|
||||||
tty_status_hilites[fldidx].thresholdtype);
|
tty_status_hilites[fldidx].thresholdtype);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -3439,12 +3423,14 @@ genericptr_t ptr;
|
|||||||
newbot1[0] = '\0';
|
newbot1[0] = '\0';
|
||||||
for (i = 0; fieldorder[0][i] >= 0; ++i) {
|
for (i = 0; fieldorder[0][i] >= 0; ++i) {
|
||||||
int idx1 = fieldorder[0][i];
|
int idx1 = fieldorder[0][i];
|
||||||
|
|
||||||
if (status_activefields[idx1])
|
if (status_activefields[idx1])
|
||||||
Strcat(newbot1, status_vals[idx1]);
|
Strcat(newbot1, status_vals[idx1]);
|
||||||
}
|
}
|
||||||
newbot2[0] = '\0';
|
newbot2[0] = '\0';
|
||||||
for (i = 0; fieldorder[1][i] >= 0; ++i) {
|
for (i = 0; fieldorder[1][i] >= 0; ++i) {
|
||||||
int idx2 = fieldorder[1][i];
|
int idx2 = fieldorder[1][i];
|
||||||
|
|
||||||
if (status_activefields[idx2])
|
if (status_activefields[idx2])
|
||||||
Strcat(newbot2, status_vals[idx2]);
|
Strcat(newbot2, status_vals[idx2]);
|
||||||
}
|
}
|
||||||
@@ -3460,7 +3446,8 @@ genericptr_t ptr;
|
|||||||
curs(WIN_STATUS, 1, 0);
|
curs(WIN_STATUS, 1, 0);
|
||||||
for (i = 0; fieldorder[0][i] != BL_FLUSH; ++i) {
|
for (i = 0; fieldorder[0][i] != BL_FLUSH; ++i) {
|
||||||
int fldidx1 = fieldorder[0][i];
|
int fldidx1 = fieldorder[0][i];
|
||||||
if (status_activefields[fldidx1]) {
|
|
||||||
|
v if (status_activefields[fldidx1]) {
|
||||||
if (tty_status_colors[fldidx1] < 0 &&
|
if (tty_status_colors[fldidx1] < 0 &&
|
||||||
tty_status_colors[fldidx1] >= -3) {
|
tty_status_colors[fldidx1] >= -3) {
|
||||||
/* attribute, not a color */
|
/* attribute, not a color */
|
||||||
@@ -3483,6 +3470,7 @@ genericptr_t ptr;
|
|||||||
curs(WIN_STATUS, 1, 1);
|
curs(WIN_STATUS, 1, 1);
|
||||||
for (i = 0; fieldorder[1][i] != BL_FLUSH; ++i) {
|
for (i = 0; fieldorder[1][i] != BL_FLUSH; ++i) {
|
||||||
int fldidx2 = fieldorder[1][i];
|
int fldidx2 = fieldorder[1][i];
|
||||||
|
|
||||||
if (status_activefields[fldidx2]) {
|
if (status_activefields[fldidx2]) {
|
||||||
if (tty_status_colors[fldidx2] < 0 &&
|
if (tty_status_colors[fldidx2] < 0 &&
|
||||||
tty_status_colors[fldidx2] >= -3) {
|
tty_status_colors[fldidx2] >= -3) {
|
||||||
@@ -3498,7 +3486,7 @@ genericptr_t ptr;
|
|||||||
if (fldidx2 == BL_GOLD) {
|
if (fldidx2 == BL_GOLD) {
|
||||||
/* putmixed() due to GOLD glyph */
|
/* putmixed() due to GOLD glyph */
|
||||||
putmixed(WIN_STATUS, 0, status_vals[fldidx2]);
|
putmixed(WIN_STATUS, 0, status_vals[fldidx2]);
|
||||||
} else {
|
} else {
|
||||||
putstr(WIN_STATUS, 0, status_vals[fldidx2]);
|
putstr(WIN_STATUS, 0, status_vals[fldidx2]);
|
||||||
}
|
}
|
||||||
if (tty_status_colors[fldidx2] != NO_COLOR)
|
if (tty_status_colors[fldidx2] != NO_COLOR)
|
||||||
@@ -3513,7 +3501,7 @@ genericptr_t ptr;
|
|||||||
|
|
||||||
#ifdef STATUS_HILITES
|
#ifdef STATUS_HILITES
|
||||||
/*
|
/*
|
||||||
* status_threshold(int fldidx, int threshholdtype, anything threshold,
|
* status_threshold(int fldidx, int threshholdtype, anything threshold,
|
||||||
* int behavior, int under, int over)
|
* int behavior, int under, int over)
|
||||||
*
|
*
|
||||||
* -- called when a hiliting preference is added, changed, or
|
* -- called when a hiliting preference is added, changed, or
|
||||||
@@ -3521,12 +3509,12 @@ genericptr_t ptr;
|
|||||||
* -- the fldindex identifies which field is having its hiliting
|
* -- the fldindex identifies which field is having its hiliting
|
||||||
* preference set. It is an integer index value from botl.h
|
* preference set. It is an integer index value from botl.h
|
||||||
* -- fldindex could be any one of the following from botl.h:
|
* -- fldindex could be any one of the following from botl.h:
|
||||||
* BL_TITLE, BL_STR, BL_DX, BL_CO, BL_IN, BL_WI, BL_CH,
|
* BL_TITLE, BL_STR, BL_DX, BL_CO, BL_IN, BL_WI, BL_CH,
|
||||||
* BL_ALIGN, BL_SCORE, BL_CAP, BL_GOLD, BL_ENE, BL_ENEMAX,
|
* BL_ALIGN, BL_SCORE, BL_CAP, BL_GOLD, BL_ENE, BL_ENEMAX,
|
||||||
* BL_XP, BL_AC, BL_HD, BL_TIME, BL_HUNGER, BL_HP, BL_HPMAX,
|
* BL_XP, BL_AC, BL_HD, BL_TIME, BL_HUNGER, BL_HP, BL_HPMAX,
|
||||||
* BL_LEVELDESC, BL_EXP, BL_CONDITION
|
* BL_LEVELDESC, BL_EXP, BL_CONDITION
|
||||||
* -- datatype is P_INT, P_UINT, P_LONG, or P_MASK.
|
* -- datatype is P_INT, P_UINT, P_LONG, or P_MASK.
|
||||||
* -- threshold is an "anything" union which can contain the
|
* -- threshold is an "anything" union which can contain the
|
||||||
* datatype value.
|
* datatype value.
|
||||||
* -- behavior is used to define how threshold is used and can
|
* -- behavior is used to define how threshold is used and can
|
||||||
* be BL_TH_NONE, BL_TH_VAL_PERCENTAGE, BL_TH_VAL_ABSOLUTE,
|
* be BL_TH_NONE, BL_TH_VAL_PERCENTAGE, BL_TH_VAL_ABSOLUTE,
|
||||||
@@ -3536,23 +3524,22 @@ genericptr_t ptr;
|
|||||||
* value. BL_TH_VAL_ABSOLUTE means that the threshold is an
|
* value. BL_TH_VAL_ABSOLUTE means that the threshold is an
|
||||||
* actual value. BL_TH_UPDOWN means that threshold is not
|
* actual value. BL_TH_UPDOWN means that threshold is not
|
||||||
* used, and the two below/above hilite values indicate how
|
* used, and the two below/above hilite values indicate how
|
||||||
* to display something going down (under) or rising (over).
|
* to display something going down (under) or rising (over).
|
||||||
* -- under is the hilite attribute used if value is below the
|
* -- under is the hilite attribute used if value is below the
|
||||||
* threshold. The attribute can be BL_HILITE_NONE,
|
* threshold. The attribute can be BL_HILITE_NONE,
|
||||||
* BL_HILITE_INVERSE, BL_HILITE_BOLD (-1, -2, or -3), or one
|
* BL_HILITE_INVERSE, BL_HILITE_BOLD (-1, -2, or -3), or one
|
||||||
* of the color indexes of CLR_BLACK, CLR_RED, CLR_GREEN,
|
* of the color indexes of CLR_BLACK, CLR_RED, CLR_GREEN,
|
||||||
* CLR_BROWN, CLR_BLUE, CLR_MAGENTA, CLR_CYAN, CLR_GRAY,
|
* CLR_BROWN, CLR_BLUE, CLR_MAGENTA, CLR_CYAN, CLR_GRAY,
|
||||||
* CLR_ORANGE, CLR_BRIGHT_GREEN, CLR_YELLOW, CLR_BRIGHT_BLUE,
|
* CLR_ORANGE, CLR_BRIGHT_GREEN, CLR_YELLOW, CLR_BRIGHT_BLUE,
|
||||||
* CLR_BRIGHT_MAGENTA, CLR_BRIGHT_CYAN, or CLR_WHITE (0 - 15).
|
* CLR_BRIGHT_MAGENTA, CLR_BRIGHT_CYAN, or CLR_WHITE (0 - 15).
|
||||||
* -- over is the hilite attribute used if value is at or above
|
* -- over is the hilite attribute used if value is at or above
|
||||||
* the threshold. The attribute can be BL_HILITE_NONE,
|
* the threshold. The attribute can be BL_HILITE_NONE,
|
||||||
* BL_HILITE_INVERSE, BL_HILITE_BOLD (-1, -2, or -3), or one
|
* BL_HILITE_INVERSE, BL_HILITE_BOLD (-1, -2, or -3), or one
|
||||||
* of the color indexes of CLR_BLACK, CLR_RED, CLR_GREEN,
|
* of the color indexes of CLR_BLACK, CLR_RED, CLR_GREEN,
|
||||||
* CLR_BROWN, CLR_BLUE, CLR_MAGENTA, CLR_CYAN, CLR_GRAY,
|
* CLR_BROWN, CLR_BLUE, CLR_MAGENTA, CLR_CYAN, CLR_GRAY,
|
||||||
* CLR_ORANGE, CLR_BRIGHT_GREEN, CLR_YELLOW, CLR_BRIGHT_BLUE,
|
* CLR_ORANGE, CLR_BRIGHT_GREEN, CLR_YELLOW, CLR_BRIGHT_BLUE,
|
||||||
* CLR_BRIGHT_MAGENTA, CLR_BRIGHT_CYAN, or CLR_WHITE (0 - 15).
|
* CLR_BRIGHT_MAGENTA, CLR_BRIGHT_CYAN, or CLR_WHITE (0 - 15).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void
|
void
|
||||||
tty_status_threshold(fldidx, thresholdtype, threshold, behavior, under, over)
|
tty_status_threshold(fldidx, thresholdtype, threshold, behavior, under, over)
|
||||||
int fldidx, thresholdtype;
|
int fldidx, thresholdtype;
|
||||||
@@ -3566,7 +3553,7 @@ anything threshold;
|
|||||||
tty_status_hilites[fldidx].over = over;
|
tty_status_hilites[fldidx].over = over;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* STATUS_HILITES */
|
#endif /* STATUS_HILITES */
|
||||||
#endif /*STATUS_VIA_WINDOWPORT*/
|
#endif /*STATUS_VIA_WINDOWPORT*/
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user