STATIC_DCL void FDECL(free_window_info, (struct WinDesc *, BOOLEAN_P));
STATIC_DCL void FDECL(dmore, (struct WinDesc *, const char *));
STATIC_DCL void FDECL(set_item_state, (winid, int, tty_menu_item *));
-STATIC_DCL void FDECL(set_all_on_page,
- (winid, tty_menu_item *, tty_menu_item *));
-STATIC_DCL void FDECL(unset_all_on_page,
- (winid, tty_menu_item *, tty_menu_item *));
-STATIC_DCL void FDECL(invert_all_on_page,
- (winid, tty_menu_item *, tty_menu_item *, CHAR_P));
-STATIC_DCL void FDECL(invert_all,
- (winid, tty_menu_item *, tty_menu_item *, CHAR_P));
+STATIC_DCL void FDECL(set_all_on_page, (winid, tty_menu_item *,
+ tty_menu_item *));
+STATIC_DCL void FDECL(unset_all_on_page, (winid, tty_menu_item *,
+ tty_menu_item *));
+STATIC_DCL void FDECL(invert_all_on_page, (winid, tty_menu_item *,
+ tty_menu_item *, CHAR_P));
+STATIC_DCL void FDECL(invert_all, (winid, tty_menu_item *,
+ tty_menu_item *, CHAR_P));
+STATIC_DCL void FDECL(toggle_menu_attr, (BOOLEAN_P, int, int));
STATIC_DCL void FDECL(process_menu_window, (winid, struct WinDesc *));
STATIC_DCL void FDECL(process_text_window, (winid, struct WinDesc *));
STATIC_DCL tty_menu_item *FDECL(reverse, (tty_menu_item *));
}
}
+/* support menucolor in addition to caller-supplied attribute */
+STATIC_OVL void
+toggle_menu_attr(on, color, attr)
+boolean on;
+int color, attr;
+{
+ if (on) {
+ term_start_attr(attr);
+#ifdef TEXTCOLOR
+ if (color != NO_COLOR)
+ term_start_color(color);
+#endif
+ } else {
+#ifdef TEXTCOLOR
+ if (color != NO_COLOR)
+ term_end_color();
+#endif
+ term_end_attr(attr);
+ }
+
+#ifndef TEXTCOLOR
+ nhUse(color);
+#endif
+}
+
STATIC_OVL void
process_menu_window(window, cw)
winid window;
{
tty_menu_item *page_start, *page_end, *curr;
long count;
- int n, curr_page, page_lines, resp_len;
+ int n, attr_n, curr_page, page_lines, resp_len;
boolean finished, counting, reset_count;
char *cp, *rp, resp[QBUFSZ], gacc[QBUFSZ], *msave, *morestr, really_morc;
#define MENU_EXPLICIT_CHOICE 0x7f /* pseudo menu manipulation char */
page_end = cw->plist[curr_page + 1];
for (page_lines = 0, curr = page_start; curr != page_end;
page_lines++, curr = curr->next) {
- int color = NO_COLOR, attr = ATR_NONE;
- boolean menucolr = FALSE;
+ int attr, color = NO_COLOR;
+
if (curr->selector)
*rp++ = curr->selector;
(void) putchar(' ');
++ttyDisplay->curx;
+
+ if (!iflags.use_menu_color
+ || !get_menu_coloring(curr->str, &color, &attr))
+ attr = curr->attr;
+
+ /* which character to start attribute highlighting;
+ whole line for headers and such, after the selector
+ character and space and selection indicator for menu
+ lines (including fake ones that simulate grayed-out
+ entries, so we don't rely on curr->identifier here) */
+ attr_n = 0; /* whole line */
+ if (curr->str[0] && curr->str[1] && curr->str[2]
+ && curr->str[1] == ' ' && index("-+#", curr->str[2]))
+ attr_n = 2 + 1; /* after selection indicator */
+
/*
* Don't use xputs() because (1) under unix it calls
* tputstr() which will interpret a '*' as some kind
* actually output the character. We're faster doing
* this.
*/
- if (iflags.use_menu_color
- && (menucolr = get_menu_coloring(curr->str, &color,
- &attr))) {
- term_start_attr(attr);
-#ifdef TEXTCOLOR
- if (color != NO_COLOR)
- term_start_color(color);
-#endif
- } else
- term_start_attr(curr->attr);
for (n = 0, cp = curr->str;
+ *cp &&
#ifndef WIN32CON
- *cp
- && (int) ++ttyDisplay->curx < (int) ttyDisplay->cols;
- cp++, n++)
+ (int) ++ttyDisplay->curx < (int) ttyDisplay->cols;
#else
- *cp
- && (int) ttyDisplay->curx < (int) ttyDisplay->cols;
- cp++, n++, ttyDisplay->curx++)
-#endif
- if (n == 2 && curr->identifier.a_void != 0
+ (int) ttyDisplay->curx < (int) ttyDisplay->cols;
+ ttyDisplay->curx++,
+#endif
+ cp++, n++) {
+ if (n == attr_n && (color != NO_COLOR
+ || attr != ATR_NONE))
+ toggle_menu_attr(TRUE, color, attr);
+ if (n == 2
+ && curr->identifier.a_void != 0
&& curr->selected) {
if (curr->count == -1L)
(void) putchar('+'); /* all selected */
(void) putchar('#'); /* count selected */
} else
(void) putchar(*cp);
- if (iflags.use_menu_color && menucolr) {
-#ifdef TEXTCOLOR
- if (color != NO_COLOR)
- term_end_color();
-#endif
- term_end_attr(attr);
- } else
- term_end_attr(curr->attr);
- }
+ } /* for *cp */
+ if (n > attr_n && (color != NO_COLOR || attr != ATR_NONE))
+ toggle_menu_attr(FALSE, color, attr);
+ } /* if npages > 0 */
} else {
page_start = 0;
page_end = 0;