tty status
Started by removing two or three unused variables, ended up cleaning up a lot of formatting (tabs, trailing spaces, indentation, a few wide lines, 'if (test) return' on same line). Marked some static functions as static in their definitions instead of leaving it hidden in their prototypes. Moved a pair of short-circuit checks to skip several initializations.
This commit is contained in:
+178
-172
@@ -1,4 +1,4 @@
|
|||||||
/* NetHack 3.6 wintty.c $NHDT-Date: 1525885919 2018/05/09 17:11:59 $ $NHDT-Branch: tty-status $:$NHDT-Revision: 1.146 $ */
|
/* NetHack 3.6 wintty.c $NHDT-Date: 1526382995 2018/05/15 11:16:35 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.164 $ */
|
||||||
/* 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. */
|
||||||
|
|
||||||
@@ -209,7 +209,8 @@ int i, c, d;
|
|||||||
if (iflags.vt_tiledata) {
|
if (iflags.vt_tiledata) {
|
||||||
if (c >= 0) {
|
if (c >= 0) {
|
||||||
if (i == AVTC_SELECT_WINDOW) {
|
if (i == AVTC_SELECT_WINDOW) {
|
||||||
if (c == vt_tile_current_window) return;
|
if (c == vt_tile_current_window)
|
||||||
|
return;
|
||||||
vt_tile_current_window = c;
|
vt_tile_current_window = c;
|
||||||
}
|
}
|
||||||
if (d >= 0)
|
if (d >= 0)
|
||||||
@@ -354,7 +355,7 @@ char **argv UNUSED;
|
|||||||
setftty(); /* calls start_screen */
|
setftty(); /* calls start_screen */
|
||||||
|
|
||||||
/* set up tty descriptor */
|
/* set up tty descriptor */
|
||||||
ttyDisplay = (struct DisplayDesc *) alloc(sizeof(struct DisplayDesc));
|
ttyDisplay = (struct DisplayDesc *) alloc(sizeof (struct DisplayDesc));
|
||||||
ttyDisplay->toplin = 0;
|
ttyDisplay->toplin = 0;
|
||||||
ttyDisplay->rows = hgt;
|
ttyDisplay->rows = hgt;
|
||||||
ttyDisplay->cols = wid;
|
ttyDisplay->cols = wid;
|
||||||
@@ -2376,13 +2377,13 @@ register int x, y; /* not xchar: perhaps xchar is unsigned and
|
|||||||
s = "[base window]";
|
s = "[base window]";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
debugpline4("bad curs positioning win %d %s (%d,%d)", window, s, x,
|
debugpline4("bad curs positioning win %d %s (%d,%d)", window, s, x, y);
|
||||||
y);
|
/* This return statement caused a functional difference between
|
||||||
/* This return statement caused a functional difference between DEBUG and
|
DEBUG and non-DEBUG operation, so it is being commented
|
||||||
non-DEBUG operation, so it is being commented out. It caused tty_curs()
|
out. It caused tty_curs() to fail to move the cursor to the
|
||||||
to fail to move the cursor to the location it needed to be if the x,y
|
location it needed to be if the x,y range checks failed,
|
||||||
range checks failed, leaving the next piece of output to be displayed
|
leaving the next piece of output to be displayed at whatever
|
||||||
at whatever random location the cursor happened to be at prior. */
|
random location the cursor happened to be at prior. */
|
||||||
|
|
||||||
/* return; */
|
/* return; */
|
||||||
}
|
}
|
||||||
@@ -3492,8 +3493,8 @@ const char *fieldnames[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
#ifdef STATUS_HILITES
|
#ifdef STATUS_HILITES
|
||||||
static int FDECL(condcolor, (long, unsigned long *));
|
STATIC_DCL int FDECL(condcolor, (long, unsigned long *));
|
||||||
static int FDECL(condattr, (long, unsigned long *));
|
STATIC_DCL int FDECL(condattr, (long, unsigned long *));
|
||||||
static unsigned long *tty_colormasks;
|
static unsigned long *tty_colormasks;
|
||||||
static long tty_condition_bits;
|
static long tty_condition_bits;
|
||||||
int cond_disp_width[2]; /* 2: current and previous */
|
int cond_disp_width[2]; /* 2: current and previous */
|
||||||
@@ -3538,7 +3539,7 @@ static enum statusfields fieldorder[2][15] = { /* 2: two status lines */
|
|||||||
static boolean windowdata_init = FALSE;
|
static boolean windowdata_init = FALSE;
|
||||||
static int cond_shrinklvl = 0, cond_width_at_shrink = 0;
|
static int cond_shrinklvl = 0, cond_width_at_shrink = 0;
|
||||||
static int enclev = 0, enc_shrinklvl = 0;
|
static int enclev = 0, enc_shrinklvl = 0;
|
||||||
static int dl_shrinklvl = 0;
|
/* static int dl_shrinklvl = 0; */
|
||||||
static boolean truncation_expected = FALSE;
|
static boolean truncation_expected = FALSE;
|
||||||
|
|
||||||
/* This controls whether to skip fields that aren't
|
/* This controls whether to skip fields that aren't
|
||||||
@@ -3663,87 +3664,85 @@ unsigned long *colormasks;
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
switch (fldidx) {
|
switch (fldidx) {
|
||||||
case BL_FLUSH:
|
case BL_FLUSH:
|
||||||
force_update = TRUE;
|
force_update = TRUE;
|
||||||
break;
|
break;
|
||||||
case BL_CONDITION:
|
case BL_CONDITION:
|
||||||
tty_status[NOW][fldidx].idx = fldidx;
|
tty_status[NOW][fldidx].idx = fldidx;
|
||||||
tty_condition_bits = *condptr;
|
tty_condition_bits = *condptr;
|
||||||
tty_colormasks = colormasks;
|
tty_colormasks = colormasks;
|
||||||
tty_status[NOW][fldidx].valid = TRUE;
|
tty_status[NOW][fldidx].valid = TRUE;
|
||||||
tty_status[NOW][fldidx].dirty = TRUE;
|
tty_status[NOW][fldidx].dirty = TRUE;
|
||||||
truncation_expected = FALSE;
|
truncation_expected = FALSE;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
tty_status[NOW][fldidx].idx = fldidx;
|
tty_status[NOW][fldidx].idx = fldidx;
|
||||||
Sprintf(status_vals[fldidx],
|
Sprintf(status_vals[fldidx],
|
||||||
status_fieldfmt[fldidx] ?
|
status_fieldfmt[fldidx] ? status_fieldfmt[fldidx] : "%s",
|
||||||
status_fieldfmt[fldidx] : "%s", text);
|
text);
|
||||||
tty_status[NOW][fldidx].color = do_color ? (color & 0x00FF)
|
tty_status[NOW][fldidx].color = do_color ? (color & 0x00FF) : NO_COLOR;
|
||||||
: NO_COLOR;
|
tty_status[NOW][fldidx].attr = (color & 0xFF00) >> 8;
|
||||||
tty_status[NOW][fldidx].attr = (color & 0xFF00) >> 8;
|
tty_status[NOW][fldidx].lth = strlen(status_vals[fldidx]);
|
||||||
tty_status[NOW][fldidx].lth = strlen(status_vals[fldidx]);
|
tty_status[NOW][fldidx].valid = TRUE;
|
||||||
tty_status[NOW][fldidx].valid = TRUE;
|
tty_status[NOW][fldidx].dirty = TRUE;
|
||||||
tty_status[NOW][fldidx].dirty = TRUE;
|
break;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The core botl engine sends a single blank to the window port
|
/* The core botl engine sends a single blank to the window port
|
||||||
for carrying-capacity when its unused. Let's suppress that */
|
for carrying-capacity when its unused. Let's suppress that */
|
||||||
if (tty_status[NOW][fldidx].lth == 1
|
if (tty_status[NOW][fldidx].lth == 1
|
||||||
&& status_vals[fldidx][0] == ' ') {
|
&& status_vals[fldidx][0] == ' ') {
|
||||||
status_vals[fldidx][0] = '\0';
|
status_vals[fldidx][0] = '\0';
|
||||||
tty_status[NOW][fldidx].lth = 0;
|
tty_status[NOW][fldidx].lth = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* default processing above was required before these */
|
/* default processing above was required before these */
|
||||||
switch (fldidx) {
|
switch (fldidx) {
|
||||||
case BL_HP:
|
case BL_HP:
|
||||||
if (iflags.wc2_hitpointbar) {
|
if (iflags.wc2_hitpointbar) {
|
||||||
/* Special additional processing for hitpointbar */
|
/* Special additional processing for hitpointbar */
|
||||||
hpbar_percent = percent;
|
hpbar_percent = percent;
|
||||||
hpbar_color = do_color ? (color & 0x00FF) : NO_COLOR;
|
hpbar_color = do_color ? (color & 0x00FF) : NO_COLOR;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case BL_LEVELDESC:
|
||||||
|
case BL_HUNGER:
|
||||||
|
/* The core sends trailing blanks for some fields.
|
||||||
|
Let's suppress the trailing blanks */
|
||||||
|
lastchar = eos(status_vals[fldidx]);
|
||||||
|
lastchar--;
|
||||||
|
while (*lastchar == ' ' && lastchar >= status_vals[fldidx]) {
|
||||||
|
*lastchar-- = '\0';
|
||||||
|
tty_status[NOW][fldidx].lth--;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case BL_TITLE:
|
||||||
|
if (iflags.wc2_hitpointbar)
|
||||||
|
tty_status[NOW][fldidx].lth += 2; /* '[' and ']' */
|
||||||
|
break;
|
||||||
|
case BL_GOLD:
|
||||||
|
tty_status[NOW][fldidx].lth -= 9; /* \GXXXXNNNN counts as 1 */
|
||||||
|
break;
|
||||||
|
case BL_CAP:
|
||||||
|
fval = status_vals[fldidx];
|
||||||
|
if (fval) {
|
||||||
|
if (*fval == ' ')
|
||||||
|
fval++;
|
||||||
|
for (i = 0; i < SIZE(encvals); ++i) {
|
||||||
|
if (!strcmp(encvals[enc_shrinklvl][i], fval)) {
|
||||||
|
enclev = i;
|
||||||
|
break; /* for */
|
||||||
}
|
}
|
||||||
break;
|
}
|
||||||
case BL_LEVELDESC:
|
}
|
||||||
case BL_HUNGER:
|
break;
|
||||||
/* The core sends trailing blanks for some fields
|
|
||||||
Let's suppress the trailing blanks */
|
|
||||||
lastchar = eos(status_vals[fldidx]);
|
|
||||||
lastchar--;
|
|
||||||
while (lastchar && *lastchar == ' '
|
|
||||||
&& lastchar >= status_vals[fldidx]) {
|
|
||||||
*lastchar-- = '\0';
|
|
||||||
tty_status[NOW][fldidx].lth--;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case BL_TITLE:
|
|
||||||
if (iflags.wc2_hitpointbar)
|
|
||||||
tty_status[NOW][fldidx].lth += 2; /* '[' and ']' */
|
|
||||||
break;
|
|
||||||
case BL_GOLD:
|
|
||||||
tty_status[NOW][fldidx].lth -= 9; /* \GXXXXNNNN counts as 1 */
|
|
||||||
break;
|
|
||||||
case BL_CAP:
|
|
||||||
fval = status_vals[fldidx];
|
|
||||||
if (fval) {
|
|
||||||
if (*fval == ' ')
|
|
||||||
fval++;
|
|
||||||
for (i = 0; i < SIZE(encvals); ++i) {
|
|
||||||
if (!strcmp(encvals[enc_shrinklvl][i], fval)) {
|
|
||||||
enclev = i;
|
|
||||||
break; /* for */
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
if (make_things_fit(force_update) || truncation_expected)
|
if (make_things_fit(force_update) || truncation_expected)
|
||||||
render_status();
|
render_status();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
STATIC_OVL int
|
||||||
make_things_fit(force_update)
|
make_things_fit(force_update)
|
||||||
boolean force_update;
|
boolean force_update;
|
||||||
{
|
{
|
||||||
@@ -3754,7 +3753,8 @@ boolean force_update;
|
|||||||
condsz = condition_size();
|
condsz = condition_size();
|
||||||
for (trycnt = 0; trycnt < 6 && !fitting; ++trycnt) {
|
for (trycnt = 0; trycnt < 6 && !fitting; ++trycnt) {
|
||||||
check = check_fields(force_update, &rowsz[0], &rowsz[1]);
|
check = check_fields(force_update, &rowsz[0], &rowsz[1]);
|
||||||
if (!check) return 0;
|
if (!check)
|
||||||
|
return 0;
|
||||||
|
|
||||||
requirement = rowsz[1];
|
requirement = rowsz[1];
|
||||||
if (requirement < wins[WIN_STATUS]->cols - 1) {
|
if (requirement < wins[WIN_STATUS]->cols - 1) {
|
||||||
@@ -3833,7 +3833,7 @@ int *topsz, *bottomsz;
|
|||||||
matchprev = FALSE;
|
matchprev = FALSE;
|
||||||
if (do_field_opt && tty_status[NOW][idx].dirty) {
|
if (do_field_opt && tty_status[NOW][idx].dirty) {
|
||||||
/* compare values */
|
/* compare values */
|
||||||
const char *ob, *nb; /* old byte, new byte */
|
const char *ob, *nb; /* old byte, new byte */
|
||||||
|
|
||||||
c = col - 1;
|
c = col - 1;
|
||||||
ob = &wins[WIN_STATUS]->data[row][c];
|
ob = &wins[WIN_STATUS]->data[row][c];
|
||||||
@@ -3848,7 +3848,7 @@ int *topsz, *bottomsz;
|
|||||||
if (!*nb && c > col - 1)
|
if (!*nb && c > col - 1)
|
||||||
matchprev = TRUE;
|
matchprev = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* With STATUS_HILITES, it is possible that the color
|
* With STATUS_HILITES, it is possible that the color
|
||||||
* needs to change even if the text is the same, so
|
* needs to change even if the text is the same, so
|
||||||
@@ -3861,7 +3861,7 @@ int *topsz, *bottomsz;
|
|||||||
if (forcefields || update_right || !matchprev
|
if (forcefields || update_right || !matchprev
|
||||||
|| tty_status[NOW][idx].color != tty_status[BEFORE][idx].color
|
|| tty_status[NOW][idx].color != tty_status[BEFORE][idx].color
|
||||||
|| tty_status[NOW][idx].attr != tty_status[BEFORE][idx].attr)
|
|| tty_status[NOW][idx].attr != tty_status[BEFORE][idx].attr)
|
||||||
tty_status[NOW][idx].redraw = TRUE;
|
tty_status[NOW][idx].redraw = TRUE;
|
||||||
col += tty_status[NOW][idx].lth;
|
col += tty_status[NOW][idx].lth;
|
||||||
}
|
}
|
||||||
if (row && bottomsz)
|
if (row && bottomsz)
|
||||||
@@ -3877,11 +3877,11 @@ int *topsz, *bottomsz;
|
|||||||
* If val isn't null, it will be used rather than
|
* If val isn't null, it will be used rather than
|
||||||
* fld (it takes precedence).
|
* fld (it takes precedence).
|
||||||
*/
|
*/
|
||||||
void
|
STATIC_OVL void
|
||||||
tty_putstatusfield(fld, val, x, y)
|
tty_putstatusfield(fld, val, x, y)
|
||||||
struct tty_status_fields *fld;
|
struct tty_status_fields *fld;
|
||||||
const char *val;
|
const char *val;
|
||||||
int x,y;
|
int x, y;
|
||||||
{
|
{
|
||||||
int i, n, ncols, lth;
|
int i, n, ncols, lth;
|
||||||
struct WinDesc *cw = 0;
|
struct WinDesc *cw = 0;
|
||||||
@@ -3898,7 +3898,8 @@ int x,y;
|
|||||||
text = status_vals[fld->idx];
|
text = status_vals[fld->idx];
|
||||||
lth = fld->lth;
|
lth = fld->lth;
|
||||||
}
|
}
|
||||||
if (!text) return;
|
if (!text)
|
||||||
|
return;
|
||||||
|
|
||||||
print_vt_code2(AVTC_SELECT_WINDOW, NHW_STATUS);
|
print_vt_code2(AVTC_SELECT_WINDOW, NHW_STATUS);
|
||||||
|
|
||||||
@@ -3921,19 +3922,18 @@ int x,y;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
STATIC_OVL int
|
||||||
condition_size()
|
condition_size()
|
||||||
{
|
{
|
||||||
long mask = 0L;
|
long mask = 0L;
|
||||||
int c, x;
|
int c, x;
|
||||||
boolean fitting = FALSE;
|
|
||||||
|
|
||||||
x = 0;
|
x = 0;
|
||||||
for (c = 0; c < SIZE(conditions); ++c) {
|
for (c = 0; c < SIZE(conditions); ++c) {
|
||||||
mask = conditions[c].mask;
|
mask = conditions[c].mask;
|
||||||
if ((tty_condition_bits & mask) == mask) {
|
if ((tty_condition_bits & mask) == mask) {
|
||||||
x++; /* for spacer */
|
x++; /* for spacer */
|
||||||
x += (int) strlen(conditions[c].text[cond_shrinklvl]);
|
x += (int) strlen(conditions[c].text[cond_shrinklvl]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tty_status[NOW][BL_CONDITION].lth = x;
|
tty_status[NOW][BL_CONDITION].lth = x;
|
||||||
@@ -3941,7 +3941,7 @@ condition_size()
|
|||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
STATIC_OVL void
|
||||||
shrink_enc(lvl)
|
shrink_enc(lvl)
|
||||||
int lvl;
|
int lvl;
|
||||||
{
|
{
|
||||||
@@ -3953,24 +3953,19 @@ int lvl;
|
|||||||
tty_status[NOW][BL_CAP].lth = strlen(status_vals[BL_CAP]);
|
tty_status[NOW][BL_CAP].lth = strlen(status_vals[BL_CAP]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
STATIC_OVL void
|
||||||
shrink_dlvl(lvl)
|
shrink_dlvl(lvl)
|
||||||
int lvl;
|
int lvl;
|
||||||
{
|
{
|
||||||
/* try changing Dlvl: to Dl: */
|
/* try changing Dlvl: to Dl: */
|
||||||
char buf[BUFSZ];
|
char buf[BUFSZ];
|
||||||
char *levval =index(status_vals[BL_LEVELDESC], ':');
|
char *levval = index(status_vals[BL_LEVELDESC], ':');
|
||||||
|
|
||||||
if (levval) {
|
if (levval) {
|
||||||
if (lvl == 0)
|
Strcpy(buf, (lvl == 0) ? "Dlvl" : "Dl");
|
||||||
Strcpy(buf, "Dlvl");
|
|
||||||
else
|
|
||||||
Strcpy(buf, "Dl");
|
|
||||||
|
|
||||||
Strcat(buf, levval);
|
Strcat(buf, levval);
|
||||||
Strcpy(status_vals[BL_LEVELDESC], buf);
|
Strcpy(status_vals[BL_LEVELDESC], buf);
|
||||||
tty_status[NOW][BL_LEVELDESC].lth =
|
tty_status[NOW][BL_LEVELDESC].lth = strlen(status_vals[BL_LEVELDESC]);
|
||||||
strlen(status_vals[BL_LEVELDESC]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3978,12 +3973,12 @@ int lvl;
|
|||||||
* Ensure the underlying status window data start out
|
* Ensure the underlying status window data start out
|
||||||
* blank and null-terminated.
|
* blank and null-terminated.
|
||||||
*/
|
*/
|
||||||
boolean
|
STATIC_OVL boolean
|
||||||
check_windowdata(VOID_ARGS)
|
check_windowdata(VOID_ARGS)
|
||||||
{
|
{
|
||||||
if (WIN_STATUS == WIN_ERR || wins[WIN_STATUS] == (struct WinDesc *) 0) {
|
if (WIN_STATUS == WIN_ERR || wins[WIN_STATUS] == (struct WinDesc *) 0) {
|
||||||
paniclog("check_windowdata", " null status window.");
|
paniclog("check_windowdata", " null status window.");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
} else if (!windowdata_init) {
|
} else if (!windowdata_init) {
|
||||||
int i, n = wins[WIN_STATUS]->cols;
|
int i, n = wins[WIN_STATUS]->cols;
|
||||||
|
|
||||||
@@ -4003,7 +3998,8 @@ check_windowdata(VOID_ARGS)
|
|||||||
* Return what color this condition should
|
* Return what color this condition should
|
||||||
* be displayed in based on user settings.
|
* be displayed in based on user settings.
|
||||||
*/
|
*/
|
||||||
int condcolor(bm, bmarray)
|
STATIC_OVL int
|
||||||
|
condcolor(bm, bmarray)
|
||||||
long bm;
|
long bm;
|
||||||
unsigned long *bmarray;
|
unsigned long *bmarray;
|
||||||
{
|
{
|
||||||
@@ -4018,7 +4014,8 @@ unsigned long *bmarray;
|
|||||||
}
|
}
|
||||||
#endif /* TEXTCOLOR */
|
#endif /* TEXTCOLOR */
|
||||||
|
|
||||||
int condattr(bm, bmarray)
|
STATIC_OVL int
|
||||||
|
condattr(bm, bmarray)
|
||||||
long bm;
|
long bm;
|
||||||
unsigned long *bmarray;
|
unsigned long *bmarray;
|
||||||
{
|
{
|
||||||
@@ -4029,21 +4026,21 @@ unsigned long *bmarray;
|
|||||||
for (i = HL_ATTCLR_DIM; i < BL_ATTCLR_MAX; ++i) {
|
for (i = HL_ATTCLR_DIM; i < BL_ATTCLR_MAX; ++i) {
|
||||||
if (bmarray[i] && (bm & bmarray[i])) {
|
if (bmarray[i] && (bm & bmarray[i])) {
|
||||||
switch(i) {
|
switch(i) {
|
||||||
case HL_ATTCLR_DIM:
|
case HL_ATTCLR_DIM:
|
||||||
attr |= HL_DIM;
|
attr |= HL_DIM;
|
||||||
break;
|
break;
|
||||||
case HL_ATTCLR_BLINK:
|
case HL_ATTCLR_BLINK:
|
||||||
attr |= HL_BLINK;
|
attr |= HL_BLINK;
|
||||||
break;
|
break;
|
||||||
case HL_ATTCLR_ULINE:
|
case HL_ATTCLR_ULINE:
|
||||||
attr |= HL_ULINE;
|
attr |= HL_ULINE;
|
||||||
break;
|
break;
|
||||||
case HL_ATTCLR_INVERSE:
|
case HL_ATTCLR_INVERSE:
|
||||||
attr |= HL_INVERSE;
|
attr |= HL_INVERSE;
|
||||||
break;
|
break;
|
||||||
case HL_ATTCLR_BOLD:
|
case HL_ATTCLR_BOLD:
|
||||||
attr |= HL_BOLD;
|
attr |= HL_BOLD;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4052,50 +4049,56 @@ unsigned long *bmarray;
|
|||||||
}
|
}
|
||||||
|
|
||||||
#define Begin_Attr(m) \
|
#define Begin_Attr(m) \
|
||||||
if (m) { \
|
do { \
|
||||||
if ((m) & HL_BOLD) \
|
if (m) { \
|
||||||
term_start_attr(ATR_BOLD); \
|
if ((m) & HL_BOLD) \
|
||||||
if ((m) & HL_INVERSE) \
|
term_start_attr(ATR_BOLD); \
|
||||||
term_start_attr(ATR_INVERSE); \
|
if ((m) & HL_INVERSE) \
|
||||||
if ((m) & HL_ULINE) \
|
term_start_attr(ATR_INVERSE); \
|
||||||
term_start_attr(ATR_ULINE); \
|
if ((m) & HL_ULINE) \
|
||||||
if ((m) & HL_BLINK) \
|
term_start_attr(ATR_ULINE); \
|
||||||
term_start_attr(ATR_BLINK); \
|
if ((m) & HL_BLINK) \
|
||||||
if ((m) & HL_DIM) \
|
term_start_attr(ATR_BLINK); \
|
||||||
term_start_attr(ATR_DIM); \
|
if ((m) & HL_DIM) \
|
||||||
}
|
term_start_attr(ATR_DIM); \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#define End_Attr(m) \
|
#define End_Attr(m) \
|
||||||
if (m) { \
|
do { \
|
||||||
if ((m) & HL_DIM) \
|
if (m) { \
|
||||||
term_end_attr(ATR_DIM); \
|
if ((m) & HL_DIM) \
|
||||||
if ((m) & HL_BLINK) \
|
term_end_attr(ATR_DIM); \
|
||||||
term_end_attr(ATR_BLINK); \
|
if ((m) & HL_BLINK) \
|
||||||
if ((m) & HL_ULINE) \
|
term_end_attr(ATR_BLINK); \
|
||||||
term_end_attr(ATR_ULINE); \
|
if ((m) & HL_ULINE) \
|
||||||
if ((m) & HL_INVERSE) \
|
term_end_attr(ATR_ULINE); \
|
||||||
term_end_attr(ATR_INVERSE); \
|
if ((m) & HL_INVERSE) \
|
||||||
if ((m) & HL_BOLD) \
|
term_end_attr(ATR_INVERSE); \
|
||||||
term_end_attr(ATR_BOLD); \
|
if ((m) & HL_BOLD) \
|
||||||
}
|
term_end_attr(ATR_BOLD); \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
void
|
STATIC_OVL void
|
||||||
render_status(VOID_ARGS)
|
render_status(VOID_ARGS)
|
||||||
{
|
{
|
||||||
long mask = 0L;
|
long mask = 0L;
|
||||||
int i, c, row, attrmask = 0;
|
int i, c, row, attrmask = 0;
|
||||||
struct WinDesc *cw = 0;
|
struct WinDesc *cw = 0;
|
||||||
boolean do_color = FALSE, fit = FALSE;
|
boolean do_color =
|
||||||
struct tty_status_fields *nullfield = (struct tty_status_fields *)0;
|
|
||||||
|
|
||||||
#ifdef TEXTCOLOR
|
#ifdef TEXTCOLOR
|
||||||
do_color = TRUE;
|
TRUE
|
||||||
|
#else
|
||||||
|
FALSE
|
||||||
#endif
|
#endif
|
||||||
|
;
|
||||||
|
struct tty_status_fields *nullfield = (struct tty_status_fields *) 0;
|
||||||
|
|
||||||
if (WIN_STATUS == WIN_ERR
|
if (WIN_STATUS == WIN_ERR
|
||||||
|| (cw = wins[WIN_STATUS]) == (struct WinDesc *) 0) {
|
|| (cw = wins[WIN_STATUS]) == (struct WinDesc *) 0) {
|
||||||
paniclog("render_status", "WIN_ERR on status window.");
|
paniclog("render_status", "WIN_ERR on status window.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (row = 0; row < 2; ++row) {
|
for (row = 0; row < 2; ++row) {
|
||||||
@@ -4103,23 +4106,23 @@ render_status(VOID_ARGS)
|
|||||||
for (i = 0; fieldorder[row][i] != BL_FLUSH; ++i) {
|
for (i = 0; fieldorder[row][i] != BL_FLUSH; ++i) {
|
||||||
int fldidx = fieldorder[row][i];
|
int fldidx = fieldorder[row][i];
|
||||||
|
|
||||||
|
if (do_field_opt && !tty_status[NOW][fldidx].redraw)
|
||||||
|
continue;
|
||||||
|
/*
|
||||||
|
* Ignore zero length fields. check_fields() didn't count
|
||||||
|
* them in either.
|
||||||
|
*/
|
||||||
|
if (!tty_status[NOW][fldidx].lth && fldidx != BL_CONDITION)
|
||||||
|
continue;
|
||||||
|
|
||||||
if (status_activefields[fldidx]) {
|
if (status_activefields[fldidx]) {
|
||||||
int coloridx = tty_status[NOW][fldidx].color;
|
int coloridx = tty_status[NOW][fldidx].color;
|
||||||
int attridx = tty_status[NOW][fldidx].attr;
|
int attridx = tty_status[NOW][fldidx].attr;
|
||||||
int x = tty_status[NOW][fldidx].x;
|
int x = tty_status[NOW][fldidx].x;
|
||||||
int y = row;
|
int y = row;
|
||||||
char *text = status_vals[fldidx];
|
char *text = status_vals[fldidx];
|
||||||
boolean hitpointbar = (fldidx == BL_TITLE && iflags.wc2_hitpointbar);
|
boolean hitpointbar = (fldidx == BL_TITLE
|
||||||
|
&& iflags.wc2_hitpointbar);
|
||||||
if (do_field_opt && !tty_status[NOW][fldidx].redraw)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Ignore zero length fields. check_fields() didn't count
|
|
||||||
* them in either.
|
|
||||||
*/
|
|
||||||
if (!tty_status[NOW][fldidx].lth && fldidx != BL_CONDITION)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (fldidx == BL_CONDITION) {
|
if (fldidx == BL_CONDITION) {
|
||||||
/*
|
/*
|
||||||
@@ -4130,6 +4133,8 @@ render_status(VOID_ARGS)
|
|||||||
for (c = 0; c < SIZE(conditions); ++c) {
|
for (c = 0; c < SIZE(conditions); ++c) {
|
||||||
mask = conditions[c].mask;
|
mask = conditions[c].mask;
|
||||||
if ((tty_condition_bits & mask) == mask) {
|
if ((tty_condition_bits & mask) == mask) {
|
||||||
|
const char *condtext;
|
||||||
|
|
||||||
tty_putstatusfield(nullfield, " ", x++, y);
|
tty_putstatusfield(nullfield, " ", x++, y);
|
||||||
if (iflags.hilite_delta) {
|
if (iflags.hilite_delta) {
|
||||||
attrmask = condattr(mask, tty_colormasks);
|
attrmask = condattr(mask, tty_colormasks);
|
||||||
@@ -4141,10 +4146,11 @@ render_status(VOID_ARGS)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (x >= cw->cols && !truncation_expected)
|
if (x >= cw->cols && !truncation_expected)
|
||||||
impossible("Unexpected condition placement overflow");
|
impossible(
|
||||||
tty_putstatusfield(nullfield,
|
"Unexpected condition placement overflow");
|
||||||
conditions[c].text[cond_shrinklvl], x, y);
|
condtext = conditions[c].text[cond_shrinklvl];
|
||||||
x += (int) strlen(conditions[c].text[cond_shrinklvl]);
|
tty_putstatusfield(nullfield, condtext, x, y);
|
||||||
|
x += (int) strlen(condtext);
|
||||||
if (iflags.hilite_delta) {
|
if (iflags.hilite_delta) {
|
||||||
if (do_color && coloridx != NO_COLOR)
|
if (do_color && coloridx != NO_COLOR)
|
||||||
term_end_color();
|
term_end_color();
|
||||||
@@ -4210,8 +4216,8 @@ render_status(VOID_ARGS)
|
|||||||
tty_putstatusfield(nullfield, "]", x++, y);
|
tty_putstatusfield(nullfield, "]", x++, y);
|
||||||
} else {
|
} else {
|
||||||
tty_putstatusfield(&tty_status[NOW][fldidx],
|
tty_putstatusfield(&tty_status[NOW][fldidx],
|
||||||
(char *)0, x, y);
|
(char *) 0, x, y);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/*
|
/*
|
||||||
* +-----------------------------+
|
* +-----------------------------+
|
||||||
@@ -4228,15 +4234,15 @@ render_status(VOID_ARGS)
|
|||||||
Begin_Attr(attridx);
|
Begin_Attr(attridx);
|
||||||
if (do_color && coloridx != NO_COLOR
|
if (do_color && coloridx != NO_COLOR
|
||||||
&& coloridx != CLR_MAX)
|
&& coloridx != CLR_MAX)
|
||||||
term_start_color(coloridx);
|
term_start_color(coloridx);
|
||||||
}
|
}
|
||||||
tty_putstatusfield(&tty_status[NOW][fldidx],
|
tty_putstatusfield(&tty_status[NOW][fldidx],
|
||||||
text, x, y);
|
text, x, y);
|
||||||
if (iflags.hilite_delta) {
|
if (iflags.hilite_delta) {
|
||||||
if (do_color && coloridx != NO_COLOR)
|
if (do_color && coloridx != NO_COLOR)
|
||||||
term_end_color();
|
term_end_color();
|
||||||
End_Attr(attridx);
|
End_Attr(attridx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* reset .redraw and .dirty now that they've been rendered */
|
/* reset .redraw and .dirty now that they've been rendered */
|
||||||
tty_status[NOW][fldidx].dirty = FALSE;
|
tty_status[NOW][fldidx].dirty = FALSE;
|
||||||
@@ -4245,9 +4251,9 @@ render_status(VOID_ARGS)
|
|||||||
* Make a copy of the entire tty_status struct for comparison
|
* Make a copy of the entire tty_status struct for comparison
|
||||||
* of current and previous.
|
* of current and previous.
|
||||||
*/
|
*/
|
||||||
tty_status[BEFORE][fldidx] = tty_status[NOW][fldidx]; /* copy struct */
|
tty_status[BEFORE][fldidx] = tty_status[NOW][fldidx];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (cond_disp_width[NOW] < cond_width_at_shrink) {
|
if (cond_disp_width[NOW] < cond_width_at_shrink) {
|
||||||
cond_shrinklvl = 0; /* reset */
|
cond_shrinklvl = 0; /* reset */
|
||||||
|
|||||||
Reference in New Issue
Block a user