| 1074 | extern int cond_idx[CONDITION_COUNT]; |
| 1075 | |
| 1076 | DISABLE_WARNING_FORMAT_NONLITERAL |
| 1077 | |
| 1078 | static void |
| 1079 | curs_stat_conds( |
| 1080 | int vert_cond, /* 0 => horizontal, 1 => vertical */ |
| 1081 | int per_line, /* for vertical, number of conditions per line */ |
| 1082 | int *x, int *y, /* real for vertical, ignored otherwise */ |
| 1083 | char *condbuf, /* optional output; collect string of conds */ |
| 1084 | boolean *nohilite) /* optional output; indicates whether -*/ |
| 1085 | { /*+ condbuf[] could be used as-is */ |
| 1086 | char condnam[20]; |
| 1087 | int i, ci; |
| 1088 | long bitmsk; |
| 1089 | |
| 1090 | if (condbuf) { |
| 1091 | /* construct string " cond1 cond2 cond3" of all active conditions; |
| 1092 | if none of them specify highlighting, set the nohilite flag so |
| 1093 | caller can output the string as is; otherwise its length can be |
| 1094 | used to decide how to position prior to calling us back without |
| 1095 | 'condbuf' in order to perform cond by cond output */ |
| 1096 | condbuf[0] = '\0'; |
| 1097 | if (nohilite) |
| 1098 | *nohilite = TRUE; /* assume ok */ |
| 1099 | for (i = 0; i < CONDITION_COUNT; ++i) { |
| 1100 | ci = cond_idx[i]; |
| 1101 | bitmsk = conditions[ci].mask; |
| 1102 | if (curses_condition_bits & bitmsk) { |
| 1103 | Strcpy(condnam, conditions[ci].text[0]); |
| 1104 | Strcat(strcat(condbuf, " "), upstart(condnam)); |
| 1105 | #ifdef STATUS_HILITES |
| 1106 | if (nohilite && *nohilite |
| 1107 | && (condcolor(bitmsk, curses_colormasks) != NO_COLOR |
| 1108 | || condattr(bitmsk, curses_colormasks) != 0)) |
| 1109 | *nohilite = FALSE; |
| 1110 | #endif /* STATUS_HILITES */ |
| 1111 | } |
| 1112 | } |
| 1113 | } else if (curses_condition_bits) { |
| 1114 | unsigned long cond_bits; |
| 1115 | const char *vert_fmt = 0; |
| 1116 | int height = 0, width, cx, cy, cy0, cndlen; |
| 1117 | #ifdef STATUS_HILITES |
| 1118 | int attrmask = 0, color = NO_COLOR; |
| 1119 | #endif /* STATUS_HILITES */ |
| 1120 | boolean border, do_vert = (vert_cond != 0); |
| 1121 | WINDOW *win = curses_get_nhwin(STATUS_WIN); |
| 1122 | |
| 1123 | getmaxyx(win, height, width); |
| 1124 | border = curses_window_has_border(STATUS_WIN); |
| 1125 | cy0 = height - (border ? 2 : 1); |
| 1126 | if (vert_cond) |
| 1127 | vert_fmt = (per_line == 2) ? "%-12.12s" : "%-8.8s"; |
| 1128 | |
| 1129 | cond_bits = curses_condition_bits; |
| 1130 | /* show active conditions directly; for vertical, 2 or 3 per line */ |
| 1131 | for (i = 0; i < CONDITION_COUNT; ++i) { |
| 1132 | ci = cond_idx[i]; |
| 1133 | bitmsk = conditions[ci].mask; |
no test coverage detected