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

Function render_conditions

win/X11/winstat.c:448–507  ·  view source on GitHub ↗

display the tty-style status conditions; the number shown varies and we might be showing more, same, or fewer than during previous status */

Source from the content-addressed store, hash-verified

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 */
448static int
449render_conditions(int row, int dx)
450{
451 Widget label;
452 Arg args[6];
453 Cardinal num_args;
454 Position lbl_x;
455 int i, gap = 5;
456 struct status_info_t *si = xw_status_win->Win_info.Status_info;
457 Dimension lbl_wid, brd_wid = si->brd;
458
459 for (i = 0; i < next_cond_indx; i++) {
460 label = X11_cond_labels[i];
461
462 /* width of this widget was set in DisplayCond(); fetch it */
463 (void) memset((genericptr_t) args, 0, sizeof args);
464 num_args = 0;
465 XtSetArg(args[num_args], nhStr(XtNwidth), &lbl_wid); num_args++;
466 XtGetValues(label, args, num_args);
467
468 /* figure out where to draw this widget and place it there */
469 lbl_x = (Position) (dx + 1 + gap);
470
471 XtConfigureWidget(label, lbl_x, si->y[row], lbl_wid, si->ht, brd_wid);
472
473 /* keep track of where the end of our text appears */
474 dx = (int) lbl_x + (int) (lbl_wid + 2 * brd_wid) - 1;
475 }
476
477 /* if we have fewer conditions shown now than last time, set the
478 excess ones to blank; unlike the set drawn above, these haven't
479 been prepared in advance by DisplayCond because they aren't
480 being displayed; they might have been highlighted last time so
481 we need to specify more than just an empty text string */
482 if (next_cond_indx < prev_cond_indx) {
483 XFontStruct *font = X11_status_font;
484 Pixel fg = X11_status_fg, bg = X11_status_bg;
485
486 lbl_x = dx + 1;
487 lbl_wid = 1 + 2 * brd_wid;
488 for (i = next_cond_indx; i < prev_cond_indx; ++i) {
489 label = X11_cond_labels[i];
490
491 (void) memset((genericptr_t) args, 0, sizeof args);
492 num_args = 0;
493 XtSetArg(args[num_args], nhStr(XtNlabel), ""); num_args++;
494 XtSetArg(args[num_args], nhStr(XtNfont), font); num_args++;
495 XtSetArg(args[num_args], nhStr(XtNforeground), fg); num_args++;
496 XtSetArg(args[num_args], nhStr(XtNbackground), bg); num_args++;
497 /*XtSetArg(args[num_args], nhStr(XtNwidth), lbl_wid); num_args++;*/
498 /*XtSetArg(args[num_args], nhStr(XtNx), lbl_x); num_args++;*/
499 XtSetValues(label, args, num_args);
500 old_cond_colors[i] = NO_COLOR; /* fg, bg, font were just reset */
501 XtConfigureWidget(label, lbl_x, si->y[row], lbl_wid, si->ht, 0);
502 /* don't advance 'dx' here */
503 }
504 }
505

Callers 1

X11_status_update_ttyFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected