MCPcopy Create free account
hub / github.com/NetHack/NetHack / DisplayCond

Function DisplayCond

win/X11/winstat.c:400–444  ·  view source on GitHub ↗

set up one status condition for tty-style status display */

Source from the content-addressed store, hash-verified

398
399/* set up one status condition for tty-style status display */
400static void
401DisplayCond(
402 int c_idx, /* index into tt_condorder[] */
403 unsigned long *colormasks)
404{
405 Widget label;
406 Arg args[6];
407 Cardinal num_args;
408 Dimension lbl_wid;
409 XFontStruct *font = X11_status_font;
410 int coloridx, attrmask, colrattr, idx;
411 unsigned long bm = tt_condorder[c_idx].mask;
412 const char *text = tt_condorder[c_idx].text;
413 struct status_info_t *si = xw_status_win->Win_info.Status_info;
414
415 if ((X11_condition_bits & bm) == 0)
416 return;
417
418 /* widgets have been created for every condition; we allocate them
419 from left to right rather than keeping their original assignments */
420 idx = next_cond_indx;
421 label = X11_cond_labels[idx];
422
423 /* handle highlighting if caller requests it */
424 coloridx = condcolor(bm, colormasks);
425 attrmask = condattr(bm, colormasks);
426 colrattr = (attrmask << 8) | coloridx;
427 if (colrattr != old_cond_colors[c_idx])
428 HiliteField(label, BL_CONDITION, c_idx, colrattr, &font);
429
430 (void) memset((genericptr_t) args, 0, sizeof args);
431 num_args = 0;
432 /* set the condition text and its width; this widget might have
433 been displaying a different condition last time around */
434 XtSetArg(args[num_args], nhStr(XtNlabel), text); num_args++;
435 /* measure width after maybe changing font [HiliteField()] */
436 lbl_wid = 2 * si->in_wd + XTextWidth(font, text, (int) strlen(text));
437 /*XtSetArg(args[num_args], nhStr(XtNwidth), lbl_wid); num_args++;*/
438
439 /* make this condition widget be ready for display */
440 XtSetValues(label, args, num_args);
441 XtResizeWidget(label, lbl_wid, si->ht, si->brd);
442
443 ++next_cond_indx;
444}
445
446/* display the tty-style status conditions; the number shown varies and
447 we might be showing more, same, or fewer than during previous status */

Callers 1

X11_status_update_ttyFunction · 0.85

Calls 3

HiliteFieldFunction · 0.85
condcolorFunction · 0.70
condattrFunction · 0.70

Tested by

no test coverage detected