Merge branch 'master' into mac-build-tty-pkg

This commit is contained in:
Haoyang Wang
2015-11-18 13:23:35 -08:00
81 changed files with 7244 additions and 6478 deletions

View File

@@ -1,18 +1,18 @@
/* NetHack 3.6 winmap.c $NHDT-Date: 1435002689 2015/06/22 19:51:29 $ $NHDT-Branch: master $:$NHDT-Revision: 1.24 $ */
/* Copyright (c) Dean Luick, 1992 */
/* NetHack 3.6 winmap.c $NHDT-Date: 1447844616 2015/11/18 11:03:36 $ $NHDT-Branch: master $:$NHDT-Revision: 1.25 $ */
/* Copyright (c) Dean Luick, 1992 */
/* NetHack may be freely redistributed. See license for details. */
/*
* This file contains:
* + global functions print_glyph() and cliparound()
* + the map window routines
* + the char and pointer input routines
* + global functions print_glyph() and cliparound()
* + the map window routines
* + the char and pointer input routines
*
* Notes:
* + We don't really have a good way to get the compiled ROWNO and
* COLNO as defaults. They are hardwired to the current "correct"
* values in the Window widget. I am _not_ in favor of including
* some nethack include file for Window.c.
* + We don't really have a good way to get the compiled ROWNO and
* COLNO as defaults. They are hardwired to the current "correct"
* values in the Window widget. I am _not_ in favor of including
* some nethack include file for Window.c.
*/
#ifndef SYSV
@@ -58,8 +58,8 @@ extern int total_tiles_used;
static boolean FDECL(init_tiles, (struct xwindow *));
static void FDECL(set_button_values, (Widget, int, int, unsigned));
static void FDECL(map_check_size_change, (struct xwindow *));
static void FDECL(map_update,
(struct xwindow *, int, int, int, int, BOOLEAN_P));
static void FDECL(map_update, (struct xwindow *, int, int, int, int,
BOOLEAN_P));
static void FDECL(init_text, (struct xwindow *));
static void FDECL(map_exposed, (Widget, XtPointer, XtPointer));
static void FDECL(set_gc, (Widget, Font, const char *, Pixel, GC *, GC *));
@@ -67,14 +67,14 @@ static void FDECL(get_text_gc, (struct xwindow *, Font));
static void FDECL(get_char_info, (struct xwindow *));
static void FDECL(display_cursor, (struct xwindow *));
/* Global functions ========================================================
*/
/* Global functions ======================================================= */
void
X11_print_glyph(window, x, y, glyph, bkglyph)
winid window;
xchar x, y;
int glyph, bkglyph;
int glyph;
int bkglyph UNUSED;
{
struct map_info_t *map_info;
boolean update_bbox = FALSE;
@@ -104,6 +104,7 @@ int glyph, bkglyph;
#ifdef TEXTCOLOR
register unsigned char *co_ptr;
#endif
/* map glyph to character and color */
(void) mapglyph(glyph, &och, &color, &special, x, y);
ch = (uchar) och;
@@ -156,8 +157,7 @@ int x, y;
}
#endif /* CLIPPING */
/* End global functions ====================================================
*/
/* End global functions =================================================== */
#include "tile2x11.h"
@@ -199,6 +199,7 @@ Pixel colorpixel;
&annotation->bitmap, &annotation->hotx,
&annotation->hoty)) {
char buf[BUFSZ];
Sprintf(buf, "Failed to load %s", filename);
X11_raw_print(buf);
}
@@ -327,10 +328,9 @@ struct xwindow *wp;
/* assume a fixed number of tiles per row */
if (tile_image->width % TILES_PER_ROW != 0
|| tile_image->width <= TILES_PER_ROW) {
Sprintf(
buf,
"%s is not a multiple of %d (number of tiles/row) pixels wide",
appResources.tile_file, TILES_PER_ROW);
Sprintf(buf,
"%s is not a multiple of %d (number of tiles/row) pixels wide",
appResources.tile_file, TILES_PER_ROW);
X11_raw_print(buf);
XDestroyImage(tile_image);
tile_image = 0;
@@ -348,7 +348,7 @@ struct xwindow *wp;
}
tile_width = image_width / TILES_PER_ROW;
tile_height = image_height / (tile_count / TILES_PER_ROW);
#else
#else /* !USE_XPM */
/* any less than 16 colours makes tiles useless */
ddepth = DefaultDepthOfScreen(screen);
if (ddepth < 4) {
@@ -377,11 +377,11 @@ struct xwindow *wp;
result = FALSE;
goto tiledone;
}
#ifdef VERBOSE
fprintf(stderr, "X11 tile file:\n version %ld\n ncolors %ld\n "
"tile width %ld\n tile height %ld\n per row %ld\n "
" ntiles %ld\n",
fprintf(stderr, "\
X11 tile file:\n version %ld\n ncolors %ld\n \
tile width %ld\n tile height %ld\n per row %ld\n \
ntiles %ld\n",
header.version, header.ncolors, header.tile_width,
header.tile_height, header.per_row, header.ntiles);
#endif
@@ -458,15 +458,15 @@ struct xwindow *wp;
else
bitmap_pad = 8;
tile_image =
XCreateImage(dpy, DefaultVisualOfScreen(screen), ddepth, /* depth */
ZPixmap, /* format */
0, /* offset */
0, /* data */
image_width, /* width */
image_height, /* height */
bitmap_pad, /* bit pad */
0); /* bytes_per_line */
tile_image = XCreateImage(dpy, DefaultVisualOfScreen(screen),
ddepth, /* depth */
ZPixmap, /* format */
0, /* offset */
(char *) 0, /* data */
image_width, /* width */
image_height, /* height */
bitmap_pad, /* bit pad */
0); /* bytes_per_line */
if (!tile_image)
impossible("init_tiles: insufficient memory to create image");
@@ -499,9 +499,9 @@ struct xwindow *wp;
for (x = 0; x < (int) image_width; x++, tb++)
XPutPixel(tile_image, x, y, colors[*tb].pixel);
}
#endif /* USE_XPM */
#endif /* ?USE_XPM */
/* fake an inverted tile by drawing a border around the edges */
/* fake an inverted tile by drawing a border around the edges */
#ifdef USE_WHITE
/* use white or black as the border */
mask = GCFunction | GCForeground | GCGraphicsExposures;
@@ -872,7 +872,7 @@ struct xwindow *wp;
/* changed map display mode, re-display the full map */
(void) memset((genericptr_t) map_info->t_start, (char) 0,
sizeof(map_info->t_start));
(void) memset((genericptr_t) map_info->t_stop, (char) COLNO - 1,
(void) memset((genericptr_t) map_info->t_stop, (char) (COLNO - 1),
sizeof(map_info->t_stop));
map_info->is_tile = iflags.wc_tiled_map && !Is_rogue_level(&u.uz);
XClearWindow(XtDisplay(wp->w), XtWindow(wp->w));
@@ -911,9 +911,8 @@ static void
map_all_stone(map_info)
struct map_info_t *map_info;
{
int x,y;
unsigned short *sp, stone;
stone = cmap_to_glyph(S_stone);
int x, y;
unsigned short stone = cmap_to_glyph(S_stone);
for (x = 0; x < COLNO; x++)
for (y = 0; y < ROWNO; y++) {
@@ -1122,8 +1121,8 @@ unsigned int button;
click_y = y / map_info->text_map.square_height;
}
/* The values can be out of range if the map window has been resized */
/* to be larger than the max size. */
/* The values can be out of range if the map window has been resized
to be larger than the max size. */
if (click_x >= COLNO)
click_x = COLNO - 1;
if (click_y >= ROWNO)
@@ -1202,8 +1201,8 @@ XtPointer widget_data; /* expose event from Window widget */
t_width, start_row, stop_row, start_col, stop_col);
#endif
/* Out of range values are possible if the map window is resized to be */
/* bigger than the largest expected value. */
/* Out of range values are possible if the map window is resized to be
bigger than the largest expected value. */
if (stop_row >= ROWNO)
stop_row = ROWNO - 1;
if (stop_col >= COLNO)
@@ -1294,8 +1293,9 @@ boolean inverted;
XSetClipMask(dpy, tile_map->black_gc,
pile_annotation.bitmap);
XCopyPlane(dpy, pile_annotation.bitmap, XtWindow(wp->w),
tile_map->black_gc, 0, 0, pile_annotation.width,
pile_annotation.height, dest_x, dest_y, 1);
tile_map->black_gc, 0, 0,
pile_annotation.width, pile_annotation.height,
dest_x, dest_y, 1);
XSetClipOrigin(dpy, tile_map->black_gc, 0, 0);
XSetClipMask(dpy, tile_map->black_gc, None);
XSetForeground(dpy, tile_map->black_gc,
@@ -1305,19 +1305,20 @@ boolean inverted;
}
if (inverted) {
XDrawRectangle(
XtDisplay(wp->w), XtWindow(wp->w),
XDrawRectangle(XtDisplay(wp->w), XtWindow(wp->w),
#ifdef USE_WHITE
/* kludge for white square... */
tile_map->glyphs[start_row][start_col].glyph == cmap_to_glyph(S_ice)
? tile_map->black_gc
: tile_map->white_gc,
/* kludge for white square... */
(tile_map->glyphs[start_row][start_col].glyph
== cmap_to_glyph(S_ice))
? tile_map->black_gc
: tile_map->white_gc,
#else
tile_map->white_gc,
tile_map->white_gc,
#endif
start_col * tile_map->square_width,
start_row * tile_map->square_height,
tile_map->square_width - 1, tile_map->square_height - 1);
start_col * tile_map->square_width,
start_row * tile_map->square_height,
tile_map->square_width - 1,
tile_map->square_height - 1);
}
} else {
struct text_map_info_t *text_map = &map_info->text_map;
@@ -1366,20 +1367,22 @@ boolean inverted;
{
int win_row, win_xstart;
/* We always start at the same x window position and have */
/* the same character count. */
/* We always start at the same x window position and have
the same character count. */
win_xstart = text_map->square_lbearing
+ (win_start_col * text_map->square_width);
count = stop_col - start_col + 1;
for (row = start_row, win_row = win_start_row; row <= stop_row;
row++, win_row++) {
XDrawImageString(
XtDisplay(wp->w), XtWindow(wp->w),
inverted ? text_map->inv_copy_gc : text_map->copy_gc,
win_xstart, text_map->square_ascent
XDrawImageString(XtDisplay(wp->w), XtWindow(wp->w),
inverted ? text_map->inv_copy_gc
: text_map->copy_gc,
win_xstart,
text_map->square_ascent
+ (win_row * text_map->square_height),
(char *) &(text_map->text[row][start_col]), count);
(char *) &(text_map->text[row][start_col]),
count);
}
}
}
@@ -1432,7 +1435,7 @@ static char map_translations[] = "#override\n\
<Key>Right: scroll(6)\n\
<Key>Up: scroll(8)\n\
<Key>Down: scroll(2)\n\
<Key>: input() \
<Key>: input() \
";
/*
@@ -1463,8 +1466,9 @@ Widget parent;
XtSetArg(args[num_args], XtNinput, False);
num_args++;
wp->popup = parent = XtCreatePopupShell(
"nethack", topLevelShellWidgetClass, toplevel, args, num_args);
wp->popup = parent = XtCreatePopupShell("nethack",
topLevelShellWidgetClass,
toplevel, args, num_args);
/*
* If we're here, then this is an auxiliary map window. If we're
* cancelled via a delete window message, we should just pop down.
@@ -1476,18 +1480,20 @@ Widget parent;
num_args++;
XtSetArg(args[num_args], XtNallowVert, True);
num_args++;
/* XtSetArg(args[num_args], XtNforceBars, True); num_args++; */
#if 0
XtSetArg(args[num_args], XtNforceBars, True);
num_args++;
#endif
XtSetArg(args[num_args], XtNuseBottom, True);
num_args++;
XtSetArg(args[num_args], XtNtranslations,
XtParseTranslationTable(map_translations));
num_args++;
viewport = XtCreateManagedWidget(
"map_viewport", /* name */
viewportWidgetClass, /* widget class from Window.h */
parent, /* parent widget */
args, /* set some values */
num_args); /* number of values to set */
viewport = XtCreateManagedWidget("map_viewport", /* name */
viewportWidgetClass, /* from Window.h */
parent, /* parent widget */
args, /* set some values */
num_args); /* number of values to set */
/*
* Create a map window. We need to set the width and height to some
@@ -1607,13 +1613,15 @@ struct xwindow *wp;
}
boolean exit_x_event; /* exit condition for the event loop */
/*******
#if 0 /*******/
void
pkey(k)
int k;
int k;
{
printf("key = '%s%c'\n", (k<32) ? "^":"", (k<32) ? '@'+k : k);
printf("key = '%s%c'\n", (k < 32) ? "^" : "", (k < 32) ? '@' + k : k);
}
******/
#endif /***0***/
/*
* Main X event loop. Here we accept and dispatch X events. We only exit
@@ -1650,6 +1658,7 @@ int exit_condition;
switch (exit_condition) {
case EXIT_ON_SENT_EVENT: {
XAnyEvent *any = (XAnyEvent *) &event;
if (any->send_event) {
retval = 0;
keep_going = FALSE;

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 tilemap.c $NHDT-Date: 1432512803 2015/05/25 00:13:23 $ $NHDT-Branch: master $:$NHDT-Revision: 1.24 $ */
/* NetHack 3.6 tilemap.c $NHDT-Date: 1447306925 2015/11/12 05:42:05 $ $NHDT-Branch: master $:$NHDT-Revision: 1.25 $ */
/* NetHack may be freely redistributed. See license for details. */
/*
@@ -28,6 +28,8 @@ extern void FDECL(exit, (int));
#define OBJ_GLYPH 2
#define OTH_GLYPH 3 /* fortunately unnecessary */
#define EXTRA_SCROLL_DESCR_COUNT ((SCR_BLANK_PAPER - SCR_STINKING_CLOUD) - 1)
/* note that the ifdefs here should be the opposite sense from monst.c/
* objects.c/rm.h
*/
@@ -64,7 +66,7 @@ struct conditionals {
* don't know what a slime mold should look like when renamed anyway
*/
#ifndef MAIL
{ OBJ_GLYPH, SCR_STINKING_CLOUD + 4, "stamped / mail" },
{ OBJ_GLYPH, SCR_STINKING_CLOUD + EXTRA_SCROLL_DESCR_COUNT, "stamped / mail" },
#endif
{ 0, 0, 0 }
};

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 termcap.c $NHDT-Date: 1446856761 2015/11/07 00:39:21 $ $NHDT-Branch: master $:$NHDT-Revision: 1.22 $ */
/* NetHack 3.6 termcap.c $NHDT-Date: 1447234979 2015/11/11 09:42:59 $ $NHDT-Branch: master $:$NHDT-Revision: 1.23 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
@@ -30,8 +30,7 @@ static void NDECL(init_hilite);
static void NDECL(kill_hilite);
#endif
/* (see tcap.h) -- nh_CM, nh_ND, nh_CD, nh_HI,nh_HE, nh_US,nh_UE,
ul_hack */
/* (see tcap.h) -- nh_CM, nh_ND, nh_CD, nh_HI,nh_HE, nh_US,nh_UE, ul_hack */
struct tc_lcl_data tc_lcl_data = { 0, 0, 0, 0, 0, 0, 0, FALSE };
STATIC_VAR char *HO, *CL, *CE, *UP, *XD, *BC, *SO, *SE, *TI, *TE;
@@ -44,6 +43,7 @@ STATIC_VAR char *MD; /* may already be in use below */
#endif
#ifdef TERMLIB
boolean dynamic_HIHE = FALSE;
#ifdef TEXTCOLOR
STATIC_VAR char *MD;
#endif
@@ -152,9 +152,9 @@ int *wid, *hgt;
nh_US = "\033[4m";
MR = "\033[7m";
TI = nh_HE = ME = SE = nh_UE = "\033[0m";
/* strictly, SE should be 2, and nh_UE should be 24,
but we can't trust all ANSI emulators to be
that complete. -3. */
/* strictly, SE should be 2, and nh_UE should be 24,
but we can't trust all ANSI emulators to be
that complete. -3. */
#ifndef MICRO
AS = "\016";
AE = "\017";
@@ -221,11 +221,11 @@ int *wid, *hgt;
#else
HO = Tgetstr("ho");
#endif
/*
* LI and CO are set in ioctl.c via a TIOCGWINSZ if available. If
* the kernel has values for either we should use them rather than
* the values from TERMCAP ...
*/
/*
* LI and CO are set in ioctl.c via a TIOCGWINSZ if available. If
* the kernel has values for either we should use them rather than
* the values from TERMCAP ...
*/
#ifndef MICRO
if (!CO)
CO = tgetnum("co");
@@ -233,18 +233,17 @@ int *wid, *hgt;
LI = tgetnum("li");
#else
#if defined(TOS) && defined(__GNUC__)
if (!strcmp(term, "builtin"))
if (!strcmp(term, "builtin")) {
get_scr_size();
else {
} else
#endif
{
CO = tgetnum("co");
LI = tgetnum("li");
if (!LI || !CO) /* if we don't override it */
get_scr_size();
#if defined(TOS) && defined(__GNUC__)
}
#endif
#endif
#endif /* ?MICRO */
#ifdef CLIPPING
if (CO < COLNO || LI < ROWNO + 3)
setclipped();
@@ -298,16 +297,14 @@ int *wid, *hgt;
* pager as a string - so how can you send it NULs???
* -jsb
*/
nh_HI = (char *) alloc((unsigned) (strlen(SO) + 1));
nh_HE = (char *) alloc((unsigned) (strlen(ME) + 1));
i = 0;
while (digit(SO[i]))
i++;
Strcpy(nh_HI, &SO[i]);
i = 0;
while (digit(ME[i]))
i++;
Strcpy(nh_HE, &ME[i]);
for (i = 0; digit(SO[i]); ++i)
continue;
nh_HI = dupstr(&SO[i]);
for (i = 0; digit(ME[i]); ++i)
continue;
nh_HE = dupstr(&ME[i]);
dynamic_HIHE = TRUE;
AS = Tgetstr("as");
AE = Tgetstr("ae");
nh_CD = Tgetstr("cd");
@@ -340,10 +337,17 @@ int *wid, *hgt;
void
tty_shutdown()
{
#if defined(TEXTCOLOR) && defined(TERMLIB)
/* we only attempt to clean up a few individual termcap variables */
#ifdef TERMLIB
#ifdef TEXTCOLOR
kill_hilite();
#endif
/* we don't attempt to clean up individual termcap variables [yet?] */
if (dynamic_HIHE) {
free((genericptr_t) nh_HI), nh_HI = (char *) 0;
free((genericptr_t) nh_HE), nh_HE = (char *) 0;
dynamic_HIHE = FALSE;
}
#endif
return;
}
@@ -570,7 +574,8 @@ register int x, y;
}
/* See note above. xputc() is a special function. */
void xputc(c)
void
xputc(c)
#if defined(apollo)
int c;
#else
@@ -758,7 +763,7 @@ tty_delay_output()
#else /* MICRO */
/* BUG: if the padding character is visible, as it is on the 5620
then this looks terrible. */
if (flags.null)
if (flags.null) {
#ifdef TERMINFO
/* cbosgd!cbcephus!pds for SYS V R2 */
#ifdef NHSTDC
@@ -774,7 +779,7 @@ tty_delay_output()
#endif
#endif
else if (ospeed > 0 && ospeed < SIZE(tmspc10) && nh_CM) {
} else if (ospeed > 0 && ospeed < SIZE(tmspc10) && nh_CM) {
/* delay by sending cm(here) an appropriate number of times */
register int cmlen =
strlen(tgoto(nh_CM, ttyDisplay->curx, ttyDisplay->cury));
@@ -788,13 +793,15 @@ tty_delay_output()
#endif /* MICRO */
}
void cl_eos() /* free after Robert Viduya */
{ /* must only be called with curx = 1 */
if (nh_CD)
/* must only be called with curx = 1 */
void
cl_eos() /* free after Robert Viduya */
{
if (nh_CD) {
xputs(nh_CD);
else {
} else {
register int cy = ttyDisplay->cury + 1;
while (cy <= LI - 2) {
cl_end();
xputc('\n');

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 wintty.c $NHDT-Date: 1446856765 2015/11/07 00:39:25 $ $NHDT-Branch: master $:$NHDT-Revision: 1.110 $ */
/* NetHack 3.6 wintty.c $NHDT-Date: 1447630543 2015/11/15 23:35:43 $ $NHDT-Branch: master $:$NHDT-Revision: 1.115 $ */
/* Copyright (c) David Cohrs, 1991 */
/* NetHack may be freely redistributed. See license for details. */
@@ -1189,17 +1189,36 @@ const char *str;
winid i;
tty_suspend_nhwindows(str);
/* Just forget any windows existed, since we're about to exit anyway.
/*
* Disable windows to avoid calls to window routines.
*/
for (i = 0; i < MAXWIN; i++)
if (wins[i] && (i != BASE_WINDOW)) {
free_pickinv_cache(); /* reset its state as well as tear down window */
for (i = 0; i < MAXWIN; i++) {
if (i == BASE_WINDOW)
continue; /* handle wins[BASE_WINDOW] last */
if (wins[i]) {
#ifdef FREE_ALL_MEMORY
free_window_info(wins[i], TRUE);
free((genericptr_t) wins[i]);
#endif
wins[i] = 0;
wins[i] = (struct WinDesc *) 0;
}
}
WIN_MAP = WIN_MESSAGE = WIN_INVEN = WIN_ERR; /* these are all gone now */
#ifndef STATUS_VIA_WINDOWPORT
WIN_STATUS = WIN_ERR;
#endif
#ifdef FREE_ALL_MEMORY
if (BASE_WINDOW != WIN_ERR && wins[BASE_WINDOW]) {
free_window_info(wins[BASE_WINDOW], TRUE);
free((genericptr_t) wins[BASE_WINDOW]);
wins[BASE_WINDOW] = (struct WinDesc *) 0;
BASE_WINDOW = WIN_ERR;
}
free((genericptr_t) ttyDisplay);
ttyDisplay = (struct DisplayDesc *) 0;
#endif
#ifndef NO_TERMS /*(until this gets added to the window interface)*/
tty_shutdown(); /* cleanup termcap/terminfo/whatever */
#endif
@@ -1298,9 +1317,10 @@ int type;
newwin->datlen =
(short *) alloc(sizeof(short) * (unsigned) newwin->maxrow);
if (newwin->maxcol) {
/* WIN_STATUS */
for (i = 0; i < newwin->maxrow; i++) {
newwin->data[i] = (char *) alloc((unsigned) newwin->maxcol);
newwin->datlen[i] = newwin->maxcol;
newwin->datlen[i] = (short) newwin->maxcol;
}
} else {
for (i = 0; i < newwin->maxrow; i++) {
@@ -2017,6 +2037,7 @@ winid window;
boolean blocking; /* with ttys, all windows are blocking */
{
register struct WinDesc *cw = 0;
short s_maxcol;
if (window == WIN_ERR || (cw = wins[window]) == (struct WinDesc *) 0)
panic(winpanicstr, window);
@@ -2053,15 +2074,18 @@ boolean blocking; /* with ttys, all windows are blocking */
/*FALLTHRU*/
case NHW_MENU:
cw->active = 1;
/* cw->maxcol is a long, but its value is constrained to
be <= ttyDisplay->cols, so is sure to fit within a short */
s_maxcol = (short) cw->maxcol;
#ifdef H2344_BROKEN
cw->offx = (cw->type == NHW_TEXT)
? 0
: min(min(82, ttyDisplay->cols / 2),
ttyDisplay->cols - cw->maxcol - 1);
ttyDisplay->cols - s_maxcol - 1);
#else
/* avoid converting to uchar before calculations are finished */
cw->offx = (uchar)(int) max(
(int) 10, (int) (ttyDisplay->cols - cw->maxcol - 1));
cw->offx = (uchar) max((int) 10,
(int) (ttyDisplay->cols - s_maxcol - 1));
#endif
if (cw->offx < 0)
cw->offx = 0;
@@ -3008,7 +3032,8 @@ void
tty_print_glyph(window, x, y, glyph, bkglyph)
winid window;
xchar x, y;
int glyph, bkglyph;
int glyph;
int bkglyph UNUSED;
{
int ch;
boolean reverse_on = FALSE;
@@ -3298,12 +3323,12 @@ genericptr_t ptr;
long cond, *condptr = (long *) ptr;
register int i;
char *text = (char *) ptr;
/* Mapping BL attributes to tty attributes
* BL_HILITE_NONE -1 + 3 = 2 (statusattr[2])
* BL_HILITE_INVERSE -2 + 3 = 1 (statusattr[1])
* BL_HILITE_BOLD -3 + 3 = 0 (statusattr[0])
*/
int statusattr[] = {ATR_BOLD, ATR_INVERSE, ATR_NONE};
/* Mapping BL attributes to tty attributes
* BL_HILITE_NONE -1 + 3 = 2 (statusattr[2])
* BL_HILITE_INVERSE -2 + 3 = 1 (statusattr[1])
* BL_HILITE_BOLD -3 + 3 = 0 (statusattr[0])
*/
int statusattr[] = { ATR_BOLD, ATR_INVERSE, ATR_NONE };
int attridx = 0;
long value = -1L;
static boolean beenhere = FALSE;
@@ -3342,18 +3367,16 @@ genericptr_t ptr;
default:
value = atol(text);
Sprintf(status_vals[fldidx],
status_fieldfmt[fldidx] ? status_fieldfmt[fldidx] :
"%s", text);
status_fieldfmt[fldidx] ? status_fieldfmt[fldidx] : "%s",
text);
break;
}
}
#ifdef STATUS_HILITES
switch (tty_status_hilites[fldidx].behavior) {
switch (tty_status_hilites[fldidx].behavior) {
case BL_TH_NONE:
tty_status_colors[fldidx] = NO_COLOR;
break;
case BL_TH_UPDOWN:
if (chg > 0)
tty_status_colors[fldidx] = tty_status_hilites[fldidx].over;
@@ -3362,29 +3385,27 @@ genericptr_t ptr;
else
tty_status_colors[fldidx] = NO_COLOR;
break;
case BL_TH_VAL_PERCENTAGE:
{
case BL_TH_VAL_PERCENTAGE: {
int pct_th = 0;
if (tty_status_hilites[fldidx].thresholdtype != ANY_INT) {
impossible(
"tty_status_update: unsupported percentage threshold type %d",
tty_status_hilites[fldidx].thresholdtype);
break;
} else {
pct_th = tty_status_hilites[fldidx].threshold.a_int;
tty_status_colors[fldidx] = (percent >= pct_th)
? tty_status_hilites[fldidx].over
: tty_status_hilites[fldidx].under;
}
pct_th = tty_status_hilites[fldidx].threshold.a_int;
tty_status_colors[fldidx] = (percent >= pct_th)
? tty_status_hilites[fldidx].over
: tty_status_hilites[fldidx].under;
}
break;
case BL_TH_VAL_ABSOLUTE:
{
break;
}
case BL_TH_VAL_ABSOLUTE: {
int c = NO_COLOR;
int o = tty_status_hilites[fldidx].over;
int u = tty_status_hilites[fldidx].under;
anything *t = &tty_status_hilites[fldidx].threshold;
switch (tty_status_hilites[fldidx].thresholdtype) {
case ANY_LONG:
c = (value >= t->a_long) ? o : u;
@@ -3404,14 +3425,15 @@ genericptr_t ptr;
default:
impossible(
"tty_status_update: unsupported absolute threshold type %d\n",
tty_status_hilites[fldidx].thresholdtype);
break;
tty_status_hilites[fldidx].thresholdtype);
break;
}
tty_status_colors[fldidx] = c;
}
break;
}
break;
} /* case */
} /* switch */
#endif /* STATUS_HILITES */
}
/* For now, this version copied from the genl_ version currently
* updates everything on the display, everytime