Remove old code
This commit is contained in:
committed by
Pasi Kallinen
parent
b763944fb4
commit
ba2c99f28c
@@ -98,17 +98,6 @@
|
|||||||
|
|
||||||
static int condcolor(long, unsigned long *);
|
static int condcolor(long, unsigned long *);
|
||||||
static int condattr(long, unsigned long *);
|
static int condattr(long, unsigned long *);
|
||||||
#if 0 /*RLC*/
|
|
||||||
static void HiliteField(Widget, int, int, int, XFontStruct **);
|
|
||||||
static void PrepStatusField(int, Widget, const char *);
|
|
||||||
static void DisplayCond(int, unsigned long *);
|
|
||||||
static int render_conditions(int, int);
|
|
||||||
#ifdef STATUS_HILITES
|
|
||||||
static void tt_reset_color(int, int, unsigned long *);
|
|
||||||
#endif
|
|
||||||
static void tt_status_fixup(void);
|
|
||||||
static Widget create_tty_status_field(int, int, Widget, Widget);
|
|
||||||
#endif /*RLC*/
|
|
||||||
static Widget create_tty_status(Widget, Widget);
|
static Widget create_tty_status(Widget, Widget);
|
||||||
static void stat_resized(Widget, XtPointer, XtPointer);
|
static void stat_resized(Widget, XtPointer, XtPointer);
|
||||||
static void update_fancy_status_field(int, int, int);
|
static void update_fancy_status_field(int, int, int);
|
||||||
@@ -136,11 +125,6 @@ static int X11_status_colors[MAXBLSTATS],
|
|||||||
old_field_colors[MAXBLSTATS],
|
old_field_colors[MAXBLSTATS],
|
||||||
old_cond_colors[32];
|
old_cond_colors[32];
|
||||||
static int hpbar_percent, hpbar_color;
|
static int hpbar_percent, hpbar_color;
|
||||||
/* Number of conditions displayed during this update and last update.
|
|
||||||
When the last update had more, the excess need to be erased. */
|
|
||||||
#if 0 /*RLC*/
|
|
||||||
static int next_cond_indx = 0, prev_cond_indx = 0;
|
|
||||||
#endif /*RLC*/
|
|
||||||
|
|
||||||
static enum statusfields X11_fieldorder_2[][18] = {
|
static enum statusfields X11_fieldorder_2[][18] = {
|
||||||
{ 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,
|
||||||
@@ -224,10 +208,6 @@ static struct tty_status_field X11_status_labels[MAXBLSTATS];
|
|||||||
static struct tty_cond_field X11_cond_labels[32]; /* Ugh */
|
static struct tty_cond_field X11_cond_labels[32]; /* Ugh */
|
||||||
static boolean blink;
|
static boolean blink;
|
||||||
static const unsigned long blink_interval = 500; /* milliseconds */
|
static const unsigned long blink_interval = 500; /* milliseconds */
|
||||||
#if 0 /*RLC*/
|
|
||||||
static XFontStruct *X11_status_font;
|
|
||||||
static Pixel X11_status_fg, X11_status_bg;
|
|
||||||
#endif /*RLC*/
|
|
||||||
|
|
||||||
struct xwindow *xw_status_win;
|
struct xwindow *xw_status_win;
|
||||||
|
|
||||||
@@ -327,369 +307,6 @@ cond_bm2idx(unsigned long bm)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if 0 /*RLC*/
|
|
||||||
/* highlight a tty-style status field (or condition) */
|
|
||||||
static void
|
|
||||||
HiliteField(Widget label,
|
|
||||||
int fld, int cond, int colrattr,
|
|
||||||
XFontStruct **font_p)
|
|
||||||
{
|
|
||||||
#ifdef STATUS_HILITES
|
|
||||||
static Pixel grayPxl, blackPxl, whitePxl;
|
|
||||||
Arg args[6];
|
|
||||||
Cardinal num_args;
|
|
||||||
XFontStruct *font = X11_status_font;
|
|
||||||
Pixel px, fg = X11_status_fg, bg = X11_status_bg;
|
|
||||||
struct xwindow *xw = xw_status_win;
|
|
||||||
int colr, attr;
|
|
||||||
|
|
||||||
if ((colrattr & 0x00ff) >= CLR_MAX)
|
|
||||||
colrattr = (colrattr & ~0x00ff) | NO_COLOR;
|
|
||||||
colr = colrattr & 0x00ff; /* guaranteed to be >= 0 and < CLR_MAX */
|
|
||||||
attr = (colrattr >> 8) & 0x00ff;
|
|
||||||
|
|
||||||
if (!grayPxl) {/* one-time init */
|
|
||||||
grayPxl = get_nhcolor(xw, CLR_GRAY).pixel;
|
|
||||||
blackPxl = get_nhcolor(xw, CLR_BLACK).pixel;
|
|
||||||
whitePxl = get_nhcolor(xw, CLR_WHITE).pixel;
|
|
||||||
}
|
|
||||||
/* [shouldn't be necessary; setting up gray will set up all colors] */
|
|
||||||
if (colr != NO_COLOR && !xw->nh_colors[colr].pixel)
|
|
||||||
(void) get_nhcolor(xw, colr);
|
|
||||||
|
|
||||||
/* handle highlighting if caller has specified that; set foreground,
|
|
||||||
background, and font even if not specified this time in case they
|
|
||||||
used modified values last time (which would stick if not reset) */
|
|
||||||
(void) memset((genericptr_t) args, 0, sizeof args);
|
|
||||||
num_args = 0;
|
|
||||||
if (colr != NO_COLOR)
|
|
||||||
fg = xw->nh_colors[colr].pixel;
|
|
||||||
if ((attr & HL_INVERSE) != 0) {
|
|
||||||
px = fg;
|
|
||||||
fg = bg;
|
|
||||||
bg = px;
|
|
||||||
}
|
|
||||||
/* foreground and background might both default to black, so we
|
|
||||||
need to force one to be different if/when they're the same
|
|
||||||
(actually, tt_status_fixup() takes care of that nowadays);
|
|
||||||
using gray to implement 'dim' only works for black and white
|
|
||||||
(or color+'inverse' when former background was black or white) */
|
|
||||||
if (fg == bg
|
|
||||||
|| ((attr & HL_DIM) != 0 && (fg == whitePxl || fg == blackPxl)))
|
|
||||||
fg = (fg != grayPxl) ? grayPxl
|
|
||||||
: (fg != blackPxl) ? blackPxl
|
|
||||||
: whitePxl;
|
|
||||||
XtSetArg(args[num_args], nhStr(XtNforeground), fg); num_args++;
|
|
||||||
XtSetArg(args[num_args], nhStr(XtNbackground), bg); num_args++;
|
|
||||||
if (attr & HL_BOLD) {
|
|
||||||
load_boldfont(xw_status_win, label);
|
|
||||||
if (xw_status_win->boldfs)
|
|
||||||
font = xw_status_win->boldfs;
|
|
||||||
}
|
|
||||||
XtSetArg(args[num_args], nhStr(XtNfont), font); num_args++;
|
|
||||||
XtSetValues(label, args, num_args);
|
|
||||||
|
|
||||||
/* return possibly modified font to caller so that text width
|
|
||||||
measurement can use it */
|
|
||||||
if (font_p)
|
|
||||||
*font_p = font;
|
|
||||||
#else /*!STATUS_HILITES*/
|
|
||||||
nhUse(label);
|
|
||||||
nhUse(font_p);
|
|
||||||
#endif /*?STATUS_HILITES*/
|
|
||||||
if (fld != BL_CONDITION)
|
|
||||||
old_field_colors[fld] = colrattr;
|
|
||||||
else
|
|
||||||
old_cond_colors[cond] = colrattr;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* set up a specific field other than 'condition'; its general location
|
|
||||||
was specified during widget creation but it might need adjusting */
|
|
||||||
static void
|
|
||||||
PrepStatusField(int fld, Widget label, const char *text)
|
|
||||||
{
|
|
||||||
Arg args[6];
|
|
||||||
Cardinal num_args;
|
|
||||||
Dimension lbl_wid;
|
|
||||||
XFontStruct *font = X11_status_font;
|
|
||||||
int colrattr = X11_status_colors[fld];
|
|
||||||
struct status_info_t *si = xw_status_win->Win_info.Status_info;
|
|
||||||
|
|
||||||
/* highlight if color and/or attribute(s) are different from last time */
|
|
||||||
if (colrattr != old_field_colors[fld])
|
|
||||||
HiliteField(label, fld, 0, colrattr, &font);
|
|
||||||
|
|
||||||
num_args = 0;
|
|
||||||
(void) memset((genericptr_t) args, 0, sizeof args);
|
|
||||||
/* set up the current text to be displayed */
|
|
||||||
if (text && *text) {
|
|
||||||
lbl_wid = 2 * si->in_wd + XTextWidth(font, text, (int) strlen(text));
|
|
||||||
} else {
|
|
||||||
text = "";
|
|
||||||
lbl_wid = 1;
|
|
||||||
}
|
|
||||||
XtSetArg(args[num_args], nhStr(XtNlabel), text); num_args++;
|
|
||||||
/*XtSetArg(args[num_args], nhStr(XtNwidth), lbl_wid); num_args++;*/
|
|
||||||
XtSetValues(label, args, num_args);
|
|
||||||
XtResizeWidget(label, lbl_wid, si->ht, si->brd);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* set up one status condition for tty-style status display */
|
|
||||||
static void
|
|
||||||
DisplayCond(
|
|
||||||
int c_idx, /* index into tt_condorder[] */
|
|
||||||
unsigned long *colormasks)
|
|
||||||
{
|
|
||||||
Widget label;
|
|
||||||
Arg args[6];
|
|
||||||
Cardinal num_args;
|
|
||||||
Dimension lbl_wid;
|
|
||||||
XFontStruct *font = X11_status_font;
|
|
||||||
int coloridx, attrmask, colrattr, idx;
|
|
||||||
unsigned long bm = tt_condorder[c_idx].mask;
|
|
||||||
const char *text = tt_condorder[c_idx].text;
|
|
||||||
struct status_info_t *si = xw_status_win->Win_info.Status_info;
|
|
||||||
|
|
||||||
if ((X11_condition_bits & bm) == 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
/* widgets have been created for every condition; we allocate them
|
|
||||||
from left to right rather than keeping their original assignments */
|
|
||||||
idx = next_cond_indx;
|
|
||||||
label = X11_cond_labels[idx];
|
|
||||||
|
|
||||||
/* handle highlighting if caller requests it */
|
|
||||||
coloridx = condcolor(bm, colormasks);
|
|
||||||
attrmask = condattr(bm, colormasks);
|
|
||||||
colrattr = (attrmask << 8) | coloridx;
|
|
||||||
if (colrattr != old_cond_colors[c_idx])
|
|
||||||
HiliteField(label, BL_CONDITION, c_idx, colrattr, &font);
|
|
||||||
|
|
||||||
(void) memset((genericptr_t) args, 0, sizeof args);
|
|
||||||
num_args = 0;
|
|
||||||
/* set the condition text and its width; this widget might have
|
|
||||||
been displaying a different condition last time around */
|
|
||||||
XtSetArg(args[num_args], nhStr(XtNlabel), text); num_args++;
|
|
||||||
/* measure width after maybe changing font [HiliteField()] */
|
|
||||||
lbl_wid = 2 * si->in_wd + XTextWidth(font, text, (int) strlen(text));
|
|
||||||
/*XtSetArg(args[num_args], nhStr(XtNwidth), lbl_wid); num_args++;*/
|
|
||||||
|
|
||||||
/* make this condition widget be ready for display */
|
|
||||||
XtSetValues(label, args, num_args);
|
|
||||||
XtResizeWidget(label, lbl_wid, si->ht, si->brd);
|
|
||||||
|
|
||||||
++next_cond_indx;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* display the tty-style status conditions; the number shown varies and
|
|
||||||
we might be showing more, same, or fewer than during previous status */
|
|
||||||
static int
|
|
||||||
render_conditions(int row, int dx)
|
|
||||||
{
|
|
||||||
Widget label;
|
|
||||||
Arg args[6];
|
|
||||||
Cardinal num_args;
|
|
||||||
Position lbl_x;
|
|
||||||
int i, gap = 5;
|
|
||||||
struct status_info_t *si = xw_status_win->Win_info.Status_info;
|
|
||||||
Dimension lbl_wid, brd_wid = si->brd;
|
|
||||||
|
|
||||||
for (i = 0; i < next_cond_indx; i++) {
|
|
||||||
label = X11_cond_labels[i];
|
|
||||||
|
|
||||||
/* width of this widget was set in DisplayCond(); fetch it */
|
|
||||||
(void) memset((genericptr_t) args, 0, sizeof args);
|
|
||||||
num_args = 0;
|
|
||||||
XtSetArg(args[num_args], nhStr(XtNwidth), &lbl_wid); num_args++;
|
|
||||||
XtGetValues(label, args, num_args);
|
|
||||||
|
|
||||||
/* figure out where to draw this widget and place it there */
|
|
||||||
lbl_x = (Position) (dx + 1 + gap);
|
|
||||||
|
|
||||||
XtConfigureWidget(label, lbl_x, si->y[row], lbl_wid, si->ht, brd_wid);
|
|
||||||
|
|
||||||
/* keep track of where the end of our text appears */
|
|
||||||
dx = (int) lbl_x + (int) (lbl_wid + 2 * brd_wid) - 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* if we have fewer conditions shown now than last time, set the
|
|
||||||
excess ones to blank; unlike the set drawn above, these haven't
|
|
||||||
been prepared in advance by DisplayCond because they aren't
|
|
||||||
being displayed; they might have been highlighted last time so
|
|
||||||
we need to specify more than just an empty text string */
|
|
||||||
if (next_cond_indx < prev_cond_indx) {
|
|
||||||
XFontStruct *font = X11_status_font;
|
|
||||||
Pixel fg = X11_status_fg, bg = X11_status_bg;
|
|
||||||
|
|
||||||
lbl_x = dx + 1;
|
|
||||||
lbl_wid = 1 + 2 * brd_wid;
|
|
||||||
for (i = next_cond_indx; i < prev_cond_indx; ++i) {
|
|
||||||
label = X11_cond_labels[i];
|
|
||||||
|
|
||||||
(void) memset((genericptr_t) args, 0, sizeof args);
|
|
||||||
num_args = 0;
|
|
||||||
XtSetArg(args[num_args], nhStr(XtNlabel), ""); num_args++;
|
|
||||||
XtSetArg(args[num_args], nhStr(XtNfont), font); num_args++;
|
|
||||||
XtSetArg(args[num_args], nhStr(XtNforeground), fg); num_args++;
|
|
||||||
XtSetArg(args[num_args], nhStr(XtNbackground), bg); num_args++;
|
|
||||||
/*XtSetArg(args[num_args], nhStr(XtNwidth), lbl_wid); num_args++;*/
|
|
||||||
/*XtSetArg(args[num_args], nhStr(XtNx), lbl_x); num_args++;*/
|
|
||||||
XtSetValues(label, args, num_args);
|
|
||||||
old_cond_colors[i] = NO_COLOR; /* fg, bg, font were just reset */
|
|
||||||
XtConfigureWidget(label, lbl_x, si->y[row], lbl_wid, si->ht, 0);
|
|
||||||
/* don't advance 'dx' here */
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return dx;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef STATUS_HILITES
|
|
||||||
/* reset status_hilite for BL_RESET; if highlighting has been disabled or
|
|
||||||
this field is disabled, clear highlighting for this field or condition */
|
|
||||||
static void
|
|
||||||
tt_reset_color(
|
|
||||||
int fld,
|
|
||||||
int cond,
|
|
||||||
unsigned long *colormasks)
|
|
||||||
{
|
|
||||||
Widget label;
|
|
||||||
int colrattr = NO_COLOR;
|
|
||||||
|
|
||||||
if (fld != BL_CONDITION) {
|
|
||||||
if (iflags.hilite_delta != 0L && status_activefields[fld])
|
|
||||||
colrattr = X11_status_colors[fld];
|
|
||||||
cond = 0;
|
|
||||||
label = X11_status_labels[fld];
|
|
||||||
} else {
|
|
||||||
unsigned long bm = tt_condorder[cond].mask;
|
|
||||||
|
|
||||||
if (iflags.hilite_delta != 0L && (X11_condition_bits & bm) != 0) {
|
|
||||||
/* BL_RESET before first BL_CONDITION will have colormasks==Null
|
|
||||||
but condcolor() and condattr() can cope with that */
|
|
||||||
colrattr = condcolor(bm, colormasks);
|
|
||||||
colrattr |= (condattr(bm, colormasks) << 8);
|
|
||||||
}
|
|
||||||
label = X11_cond_labels[cond];
|
|
||||||
}
|
|
||||||
HiliteField(label, fld, cond, colrattr, (XFontStruct **) 0);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* make sure foreground, background, and font have reasonable values,
|
|
||||||
then explicitly set them for all the status widgets;
|
|
||||||
also cache some geometry settings in (*xw_status_win).Status_info */
|
|
||||||
static void
|
|
||||||
tt_status_fixup(void)
|
|
||||||
{
|
|
||||||
Arg args[6];
|
|
||||||
Cardinal num_args;
|
|
||||||
Widget w;
|
|
||||||
Position lbl_y;
|
|
||||||
int x, y, ci, fld;
|
|
||||||
XFontStruct *font = 0;
|
|
||||||
Pixel fg = 0, bg = 0;
|
|
||||||
struct status_info_t *si = xw_status_win->Win_info.Status_info;
|
|
||||||
|
|
||||||
(void) memset((genericptr_t) args, 0, sizeof args);
|
|
||||||
num_args = 0;
|
|
||||||
XtSetArg(args[num_args], nhStr(XtNfont), &font); num_args++;
|
|
||||||
XtSetArg(args[num_args], nhStr(XtNforeground), &fg); num_args++;
|
|
||||||
XtSetArg(args[num_args], nhStr(XtNbackground), &bg); num_args++;
|
|
||||||
XtGetValues(X11_status_widget, args, num_args);
|
|
||||||
if (fg == bg) {
|
|
||||||
XColor black = get_nhcolor(xw_status_win, CLR_BLACK),
|
|
||||||
white = get_nhcolor(xw_status_win, CLR_WHITE);
|
|
||||||
|
|
||||||
fg = (bg == white.pixel) ? black.pixel : white.pixel;
|
|
||||||
}
|
|
||||||
X11_status_fg = si->fg = fg, X11_status_bg = si->bg = bg;
|
|
||||||
|
|
||||||
if (!font) {
|
|
||||||
w = X11_status_widget;
|
|
||||||
XtSetArg(args[0], nhStr(XtNfont), &font);
|
|
||||||
do {
|
|
||||||
XtGetValues(w, args, ONE);
|
|
||||||
} while (!font && (w = XtParent(w)) != 0);
|
|
||||||
|
|
||||||
if (!font) {
|
|
||||||
/* trial and error time -- this is where we've actually
|
|
||||||
been obtaining the font even though we aren't setting
|
|
||||||
it for any of the field widgets (until for(y,x) below) */
|
|
||||||
XtGetValues(X11_status_labels[0], args, ONE);
|
|
||||||
|
|
||||||
if (!font) { /* this bit is untested... */
|
|
||||||
/* write some text and hope Xaw sets up font for us */
|
|
||||||
XtSetArg(args[0], nhStr(XtNlabel), "NetHack");
|
|
||||||
XtSetValues(X11_status_labels[0], args, ONE);
|
|
||||||
(void) XFlush(XtDisplay(X11_status_labels[0]));
|
|
||||||
|
|
||||||
XtSetArg(args[0], nhStr(XtNfont), &font);
|
|
||||||
XtGetValues(X11_status_labels[0], args, ONE);
|
|
||||||
|
|
||||||
/* if still Null, XTextWidth() would crash so bail out */
|
|
||||||
if (!font)
|
|
||||||
panic("X11 status can't determine font.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
X11_status_font = si->fs = font;
|
|
||||||
|
|
||||||
/* amount of space to advance a widget's location by one space;
|
|
||||||
increase width a tiny bit beyond the actual space */
|
|
||||||
si->spacew = XTextWidth(X11_status_font, " ", 1) + (Dimension) 1;
|
|
||||||
|
|
||||||
(void) memset((genericptr_t) args, 0, sizeof args);
|
|
||||||
num_args = 0;
|
|
||||||
XtSetArg(args[num_args], nhStr(XtNfont), font); num_args++;
|
|
||||||
XtSetArg(args[num_args], nhStr(XtNforeground), fg); num_args++;
|
|
||||||
XtSetArg(args[num_args], nhStr(XtNbackground), bg); num_args++;
|
|
||||||
XtSetValues(X11_status_widget, args, num_args);
|
|
||||||
|
|
||||||
for (y = 0; y < X11_NUM_STATUS_LINES; y++) {
|
|
||||||
for (x = 0; x < X11_NUM_STATUS_FIELD; x++) {
|
|
||||||
fld = X11_fieldorder[y][x]; /* next field to handle */
|
|
||||||
if (fld <= BL_FLUSH)
|
|
||||||
continue; /* skip fieldorder[][] padding */
|
|
||||||
|
|
||||||
XtSetValues(X11_status_labels[fld], args, num_args);
|
|
||||||
old_field_colors[fld] = NO_COLOR;
|
|
||||||
|
|
||||||
if (fld == BL_CONDITION) {
|
|
||||||
for (ci = 0; ci < SIZE(X11_cond_labels); ++ci) { /* 0..31 */
|
|
||||||
XtSetValues(X11_cond_labels[ci], args, num_args);
|
|
||||||
old_cond_colors[ci] = NO_COLOR;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* cache the y coordinate of each row for XtConfigureWidget() */
|
|
||||||
(void) memset((genericptr_t) args, 0, sizeof args);
|
|
||||||
num_args = 0;
|
|
||||||
XtSetArg(args[0], nhStr(XtNy), &lbl_y); num_args++;
|
|
||||||
for (y = 0; y < X11_NUM_STATUS_LINES; y++) {
|
|
||||||
fld = X11_fieldorder[y][0];
|
|
||||||
XtGetValues(X11_status_labels[fld], args, num_args);
|
|
||||||
si->y[y] = lbl_y;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* cache height, borderWidth, and internalWidth for XtResizeWidget() */
|
|
||||||
(void) memset((genericptr_t) args, 0, sizeof args);
|
|
||||||
num_args = 0;
|
|
||||||
XtSetArg(args[num_args], nhStr(XtNheight), &si->ht); num_args++;
|
|
||||||
XtSetArg(args[num_args], nhStr(XtNborderWidth), &si->brd); num_args++;
|
|
||||||
XtSetArg(args[num_args], nhStr(XtNinternalWidth), &si->in_wd); num_args++;
|
|
||||||
XtGetValues(X11_status_labels[0], args, num_args);
|
|
||||||
|
|
||||||
/* X11_status_update_tty() wants this in order to right justify 'vers' */
|
|
||||||
if (!xw_status_win->pixel_width) {
|
|
||||||
XtSetArg(args[0], nhStr(XtNwidth), &xw_status_win->pixel_width);
|
|
||||||
XtGetValues(xw_status_win->w, args, ONE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif /*RLC*/
|
|
||||||
|
|
||||||
DISABLE_WARNING_FORMAT_NONLITERAL
|
DISABLE_WARNING_FORMAT_NONLITERAL
|
||||||
|
|
||||||
/* core requests updating one status field (or is indicating that it's time
|
/* core requests updating one status field (or is indicating that it's time
|
||||||
@@ -756,176 +373,6 @@ X11_status_update_tty(
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#if 0 /*RLC*/
|
|
||||||
static int xtra_space[MAXBLSTATS];
|
|
||||||
static unsigned long *cond_colormasks = (unsigned long *) 0;
|
|
||||||
|
|
||||||
Arg args[6];
|
|
||||||
Cardinal num_args;
|
|
||||||
Position lbl_x;
|
|
||||||
Dimension lbl_wid, brd_wid;
|
|
||||||
Widget label;
|
|
||||||
|
|
||||||
struct status_info_t *si;
|
|
||||||
char goldbuf[40];
|
|
||||||
const char *fmt;
|
|
||||||
const char *text;
|
|
||||||
unsigned long *condptr;
|
|
||||||
int f, x, y, dx;
|
|
||||||
|
|
||||||
if (X11_status_fg == X11_status_bg || !X11_status_font)
|
|
||||||
tt_status_fixup();
|
|
||||||
|
|
||||||
if (fld == BL_RESET) {
|
|
||||||
#ifdef STATUS_HILITES
|
|
||||||
for (y = 0; y < X11_NUM_STATUS_LINES; y++) {
|
|
||||||
for (x = 0; x < X11_NUM_STATUS_FIELD; x++) {
|
|
||||||
f = X11_fieldorder[y][x];
|
|
||||||
if (f <= BL_FLUSH)
|
|
||||||
continue; /* skip padding in the fieldorder[][] layout */
|
|
||||||
if (f != BL_CONDITION) {
|
|
||||||
tt_reset_color(f, 0, (unsigned long *) 0);
|
|
||||||
} else {
|
|
||||||
int c_i;
|
|
||||||
|
|
||||||
for (c_i = 0; c_i < SIZE(tt_condorder); ++c_i)
|
|
||||||
tt_reset_color(f, c_i, cond_colormasks);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
fld = BL_FLUSH;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fld == BL_CONDITION) {
|
|
||||||
condptr = (unsigned long *) ptr;
|
|
||||||
X11_condition_bits = *condptr;
|
|
||||||
cond_colormasks = colormasks; /* expected to be non-Null */
|
|
||||||
|
|
||||||
prev_cond_indx = next_cond_indx;
|
|
||||||
next_cond_indx = 0;
|
|
||||||
/* if any conditions are active, set up their widgets */
|
|
||||||
if (X11_condition_bits)
|
|
||||||
for (f = 0; f < SIZE(tt_condorder); ++f)
|
|
||||||
DisplayCond(f, cond_colormasks);
|
|
||||||
return;
|
|
||||||
|
|
||||||
} else if (fld != BL_FLUSH) {
|
|
||||||
/* set up a specific field other than 'condition' */
|
|
||||||
text = (char *) ptr;
|
|
||||||
if (fld == BL_GOLD)
|
|
||||||
text = decode_mixed(goldbuf, text);
|
|
||||||
xtra_space[fld] = 0;
|
|
||||||
if (status_activefields[fld]) {
|
|
||||||
fmt = (fld == BL_TITLE && iflags.wc2_hitpointbar) ? "%-30s"
|
|
||||||
: status_fieldfmt[fld] ? status_fieldfmt[fld] : "%s";
|
|
||||||
if (*fmt == ' ') {
|
|
||||||
++xtra_space[fld];
|
|
||||||
++fmt;
|
|
||||||
}
|
|
||||||
Sprintf(status_vals[fld], fmt, text);
|
|
||||||
} else {
|
|
||||||
/* don't expect this since core won't call status_update()
|
|
||||||
for a field which isn't active */
|
|
||||||
*status_vals[fld] = '\0';
|
|
||||||
}
|
|
||||||
#ifdef STATUS_HILITES
|
|
||||||
if (!iflags.hilite_delta)
|
|
||||||
color = NO_COLOR;
|
|
||||||
#endif
|
|
||||||
X11_status_colors[fld] = color;
|
|
||||||
if (iflags.wc2_hitpointbar && fld == BL_HP) {
|
|
||||||
hpbar_percent = percent;
|
|
||||||
hpbar_color = color;
|
|
||||||
}
|
|
||||||
|
|
||||||
label = X11_status_labels[fld];
|
|
||||||
text = status_vals[fld];
|
|
||||||
PrepStatusField(fld, label, text);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* BL_FLUSH: draw all the status fields.
|
|
||||||
*/
|
|
||||||
si = xw_status_win->Win_info.Status_info; /* for cached geometry */
|
|
||||||
|
|
||||||
for (y = 0; y < X11_NUM_STATUS_LINES; y++) { /* row */
|
|
||||||
dx = 0; /* no pixels written to this row yet */
|
|
||||||
|
|
||||||
for (x = 0; x < X11_NUM_STATUS_FIELD; x++) { /* 'column' */
|
|
||||||
f = X11_fieldorder[y][x];
|
|
||||||
if (f <= BL_FLUSH)
|
|
||||||
continue; /* skip padding in the fieldorder[][] layout */
|
|
||||||
|
|
||||||
if (f == BL_CONDITION) {
|
|
||||||
if (next_cond_indx > 0 || prev_cond_indx > 0)
|
|
||||||
dx = render_conditions(y, dx);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
label = X11_status_labels[f];
|
|
||||||
text = status_vals[f];
|
|
||||||
|
|
||||||
(void) memset((genericptr_t) args, 0, sizeof args);
|
|
||||||
num_args = 0;
|
|
||||||
XtSetArg(args[num_args], nhStr(XtNwidth), &lbl_wid); num_args++;
|
|
||||||
XtGetValues(label, args, num_args);
|
|
||||||
brd_wid = si->brd;
|
|
||||||
|
|
||||||
/* for a field which shouldn't be shown, we can't just skip
|
|
||||||
it because we might need to remove its previous content
|
|
||||||
if it has just been toggled off */
|
|
||||||
if (!status_activefields[f]) {
|
|
||||||
if (lbl_wid <= 1)
|
|
||||||
continue;
|
|
||||||
text = "";
|
|
||||||
lbl_wid = (Dimension) 1;
|
|
||||||
brd_wid = (Dimension) 0;
|
|
||||||
} else if (xtra_space[f]) {
|
|
||||||
/* if this field was to be formatted with a leading space
|
|
||||||
to separate it from the preceding field, we suppressed
|
|
||||||
that space during formatting; insert separation between
|
|
||||||
fields here; this prevents inverse video highlighting
|
|
||||||
from inverting the separating space along with the text */
|
|
||||||
dx += xtra_space[f] * si->spacew;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* where to display the current widget */
|
|
||||||
lbl_x = (Position) (dx + 1);
|
|
||||||
if (f == BL_VERS) {
|
|
||||||
Dimension win_wid = xw_status_win->pixel_width,
|
|
||||||
fld_wid = lbl_wid + 2 * brd_wid;
|
|
||||||
|
|
||||||
/* in case the doodad for resizing the window via click and
|
|
||||||
drag is in the lower right corner; justifying all the way
|
|
||||||
to the edge results in the last character being obscured;
|
|
||||||
avoid that by treating the 'vers' widget as one char
|
|
||||||
bigger than it actually is (an implicit trailing space) */
|
|
||||||
fld_wid += si->spacew;
|
|
||||||
/* right justify if there's room */
|
|
||||||
if (dx < win_wid - fld_wid)
|
|
||||||
lbl_x = win_wid - fld_wid;
|
|
||||||
}
|
|
||||||
|
|
||||||
(void) memset((genericptr_t) args, 0, sizeof args);
|
|
||||||
num_args = 0;
|
|
||||||
XtSetArg(args[num_args], nhStr(XtNlabel), text); num_args++;
|
|
||||||
/*XtSetArg(args[num_args], nhStr(XtNwidth), lbl_wid); num_args++;*/
|
|
||||||
/*XtSetArg(args[num_args], nhStr(XtNx), lbl_x); num_args++;*/
|
|
||||||
XtSetValues(label, args, num_args);
|
|
||||||
XtConfigureWidget(label, lbl_x, si->y[y],
|
|
||||||
lbl_wid, si->ht, brd_wid);
|
|
||||||
|
|
||||||
/* track the right-most pixel written so far */
|
|
||||||
dx = (int) lbl_x + (int) (lbl_wid + 2 * brd_wid) - 1;
|
|
||||||
} /* [x] fields/columns in current row */
|
|
||||||
} /* [y] rows */
|
|
||||||
|
|
||||||
/* this probably doesn't buy us anything but it isn't a sure thing
|
|
||||||
that nethack will immediately ask for input (triggering auto-flush) */
|
|
||||||
(void) XFlush(XtDisplay(X11_status_labels[0]));
|
|
||||||
#endif /*RLC*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RESTORE_WARNING_FORMAT_NONLITERAL
|
RESTORE_WARNING_FORMAT_NONLITERAL
|
||||||
@@ -1045,63 +492,14 @@ X11_status_update(
|
|||||||
X11_status_update_tty(fld, ptr, chg, percent, color, colormasks);
|
X11_status_update_tty(fld, ptr, chg, percent, color, colormasks);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0 /*RLC*/
|
|
||||||
/* create a widget for a particular status field or potential condition */
|
|
||||||
static Widget
|
|
||||||
create_tty_status_field(int fld, int condindx, Widget above, Widget left)
|
|
||||||
{
|
|
||||||
Arg args[16];
|
|
||||||
Cardinal num_args;
|
|
||||||
char labelname[40];
|
|
||||||
int gap = condindx ? 5 : 0;
|
|
||||||
|
|
||||||
if (!condindx)
|
|
||||||
Sprintf(labelname, "label_%s", bl_idx_to_fldname(fld));
|
|
||||||
else
|
|
||||||
Sprintf(labelname, "cond_%02d", condindx);
|
|
||||||
|
|
||||||
/* set up widget attributes which (mostly) aren't going to be changing */
|
|
||||||
(void) memset((genericptr_t) args, 0, sizeof args);
|
|
||||||
num_args = 0;
|
|
||||||
if (above) {
|
|
||||||
XtSetArg(args[num_args], nhStr(XtNfromVert), above); num_args++;
|
|
||||||
}
|
|
||||||
if (left) {
|
|
||||||
XtSetArg(args[num_args], nhStr(XtNfromHoriz), left); num_args++;
|
|
||||||
}
|
|
||||||
|
|
||||||
XtSetArg(args[num_args], nhStr(XtNhorizDistance), gap); num_args++;
|
|
||||||
XtSetArg(args[num_args], nhStr(XtNvertDistance), 0); num_args++;
|
|
||||||
|
|
||||||
XtSetArg(args[num_args], nhStr(XtNtopMargin), 0); num_args++;
|
|
||||||
XtSetArg(args[num_args], nhStr(XtNbottomMargin), 0); num_args++;
|
|
||||||
XtSetArg(args[num_args], nhStr(XtNleftMargin), 0); num_args++;
|
|
||||||
XtSetArg(args[num_args], nhStr(XtNrightMargin), 0); num_args++;
|
|
||||||
XtSetArg(args[num_args], nhStr(XtNjustify), XtJustifyLeft); num_args++;
|
|
||||||
/* internalWidth: default is 4; cut that it half and adjust regular
|
|
||||||
width to have it on both left and right instead of just on the left */
|
|
||||||
XtSetArg(args[num_args], nhStr(XtNinternalWidth), 2); num_args++;
|
|
||||||
XtSetArg(args[num_args], nhStr(XtNborderWidth), 0); num_args++;
|
|
||||||
XtSetArg(args[num_args], nhStr(XtNlabel), ""); num_args++;
|
|
||||||
return XtCreateManagedWidget(labelname, labelWidgetClass,
|
|
||||||
X11_status_widget, args, num_args);
|
|
||||||
}
|
|
||||||
#endif /*RLC*/
|
|
||||||
|
|
||||||
/* create an overall status widget (X11_status_widget) and also
|
/* create an overall status widget (X11_status_widget) and also
|
||||||
separate widgets for all status fields and potential conditions */
|
separate widgets for all status fields and potential conditions */
|
||||||
static Widget
|
static Widget
|
||||||
create_tty_status(Widget parent, Widget top)
|
create_tty_status(Widget parent, Widget top)
|
||||||
{
|
{
|
||||||
Widget form; /* viewport that holds the form that surrounds everything */
|
Widget form; /* viewport that holds the form that surrounds everything */
|
||||||
#if 0 /*RLC*/
|
|
||||||
Widget w, over_w, prev_w;
|
|
||||||
#endif /*RLC*/
|
|
||||||
Arg args[6];
|
Arg args[6];
|
||||||
Cardinal num_args;
|
Cardinal num_args;
|
||||||
#if 0 /*RLC*/
|
|
||||||
int x, y, i, fld;
|
|
||||||
#endif /*RLC*/
|
|
||||||
|
|
||||||
(void) memset((genericptr_t) args, 0, sizeof args);
|
(void) memset((genericptr_t) args, 0, sizeof args);
|
||||||
num_args = 0;
|
num_args = 0;
|
||||||
@@ -1133,31 +531,6 @@ create_tty_status(Widget parent, Widget top)
|
|||||||
XtAppAddTimeOut(app_context, blink_interval, tty_status_blink,
|
XtAppAddTimeOut(app_context, blink_interval, tty_status_blink,
|
||||||
(XtPointer) X11_status_widget);
|
(XtPointer) X11_status_widget);
|
||||||
|
|
||||||
#if 0 /*RLC*/
|
|
||||||
for (y = 0; y < X11_NUM_STATUS_LINES; y++) {
|
|
||||||
fld = (y > 0) ? X11_fieldorder[y - 1][0] : 0; /* temp, for over_w */
|
|
||||||
/* for row(s) beyond the first, pick a widget in the previous
|
|
||||||
row to put this one underneath (in 'y' terms; 'x' is fluid) */
|
|
||||||
over_w = (y > 0) ? X11_status_labels[fld] : (Widget) 0;
|
|
||||||
/* widget on current row to put the next one to the right of ('x') */
|
|
||||||
prev_w = (Widget) 0;
|
|
||||||
for (x = 0; x < X11_NUM_STATUS_FIELD; x++) {
|
|
||||||
fld = X11_fieldorder[y][x]; /* next field to handle */
|
|
||||||
if (fld <= BL_FLUSH)
|
|
||||||
continue; /* skip fieldorder[][] padding */
|
|
||||||
|
|
||||||
w = create_tty_status_field(fld, 0, over_w, prev_w);
|
|
||||||
X11_status_labels[fld] = prev_w = w;
|
|
||||||
|
|
||||||
if (fld == BL_CONDITION) {
|
|
||||||
for (i = 1; i <= SIZE(X11_cond_labels); ++i) { /* 1..32 */
|
|
||||||
w = create_tty_status_field(fld, i, over_w, prev_w);
|
|
||||||
X11_cond_labels[i - 1] = prev_w = w;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif /*RLC*/
|
|
||||||
return X11_status_widget;
|
return X11_status_widget;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user