tty menu coloring
There was a report during beta testing that menu lines which were displayed in color showed the whole line in color, unless/until an item was selected or unselected, in which case the '-', '+', or '#' was rendered in monochrome. The suggestion then was to redraw the selection character in color, but I went the other way. Menu entries will render the selector letter and selection indicator in monochrome all the time, and only the text of the menu entry will honor menucolors.
This commit is contained in:
@@ -205,6 +205,7 @@ tty: responding with <return> or <enter> during role, race, &c selection
|
|||||||
behaved same as <escape> to quit; now it will pick [random] instead
|
behaved same as <escape> to quit; now it will pick [random] instead
|
||||||
tty: rename struct variable 'filter' (role.c) and function 'winch()' (wintty.c)
|
tty: rename struct variable 'filter' (role.c) and function 'winch()' (wintty.c)
|
||||||
to avoid conflicts with <curses.h>
|
to avoid conflicts with <curses.h>
|
||||||
|
tty: skip selector letter and selection indicator (-,+,#) during menu coloring
|
||||||
unix/X11: in top level Makefile, some commented out definitions of VARDATND
|
unix/X11: in top level Makefile, some commented out definitions of VARDATND
|
||||||
misspelled pilemark.xbm (as pilemark.xpm)
|
misspelled pilemark.xbm (as pilemark.xpm)
|
||||||
unix: options file with CR+LF line ends and an invalid option line resulted in
|
unix: options file with CR+LF line ends and an invalid option line resulted in
|
||||||
|
|||||||
103
win/tty/wintty.c
103
win/tty/wintty.c
@@ -152,14 +152,15 @@ STATIC_DCL void FDECL(erase_menu_or_text,
|
|||||||
STATIC_DCL void FDECL(free_window_info, (struct WinDesc *, BOOLEAN_P));
|
STATIC_DCL void FDECL(free_window_info, (struct WinDesc *, BOOLEAN_P));
|
||||||
STATIC_DCL void FDECL(dmore, (struct WinDesc *, const char *));
|
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_item_state, (winid, int, tty_menu_item *));
|
||||||
STATIC_DCL void FDECL(set_all_on_page,
|
STATIC_DCL void FDECL(set_all_on_page, (winid, tty_menu_item *,
|
||||||
(winid, tty_menu_item *, tty_menu_item *));
|
tty_menu_item *));
|
||||||
STATIC_DCL void FDECL(unset_all_on_page,
|
STATIC_DCL void FDECL(unset_all_on_page, (winid, tty_menu_item *,
|
||||||
(winid, tty_menu_item *, tty_menu_item *));
|
tty_menu_item *));
|
||||||
STATIC_DCL void FDECL(invert_all_on_page,
|
STATIC_DCL void FDECL(invert_all_on_page, (winid, tty_menu_item *,
|
||||||
(winid, tty_menu_item *, tty_menu_item *, CHAR_P));
|
tty_menu_item *, CHAR_P));
|
||||||
STATIC_DCL void FDECL(invert_all,
|
STATIC_DCL void FDECL(invert_all, (winid, tty_menu_item *,
|
||||||
(winid, tty_menu_item *, tty_menu_item *, CHAR_P));
|
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_menu_window, (winid, struct WinDesc *));
|
||||||
STATIC_DCL void FDECL(process_text_window, (winid, struct WinDesc *));
|
STATIC_DCL void FDECL(process_text_window, (winid, struct WinDesc *));
|
||||||
STATIC_DCL tty_menu_item *FDECL(reverse, (tty_menu_item *));
|
STATIC_DCL tty_menu_item *FDECL(reverse, (tty_menu_item *));
|
||||||
@@ -1697,6 +1698,31 @@ char acc; /* group accelerator, 0 => all */
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* 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
|
STATIC_OVL void
|
||||||
process_menu_window(window, cw)
|
process_menu_window(window, cw)
|
||||||
winid window;
|
winid window;
|
||||||
@@ -1704,7 +1730,7 @@ struct WinDesc *cw;
|
|||||||
{
|
{
|
||||||
tty_menu_item *page_start, *page_end, *curr;
|
tty_menu_item *page_start, *page_end, *curr;
|
||||||
long count;
|
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;
|
boolean finished, counting, reset_count;
|
||||||
char *cp, *rp, resp[QBUFSZ], gacc[QBUFSZ], *msave, *morestr, really_morc;
|
char *cp, *rp, resp[QBUFSZ], gacc[QBUFSZ], *msave, *morestr, really_morc;
|
||||||
#define MENU_EXPLICIT_CHOICE 0x7f /* pseudo menu manipulation char */
|
#define MENU_EXPLICIT_CHOICE 0x7f /* pseudo menu manipulation char */
|
||||||
@@ -1775,8 +1801,8 @@ struct WinDesc *cw;
|
|||||||
page_end = cw->plist[curr_page + 1];
|
page_end = cw->plist[curr_page + 1];
|
||||||
for (page_lines = 0, curr = page_start; curr != page_end;
|
for (page_lines = 0, curr = page_start; curr != page_end;
|
||||||
page_lines++, curr = curr->next) {
|
page_lines++, curr = curr->next) {
|
||||||
int color = NO_COLOR, attr = ATR_NONE;
|
int attr, color = NO_COLOR;
|
||||||
boolean menucolr = FALSE;
|
|
||||||
if (curr->selector)
|
if (curr->selector)
|
||||||
*rp++ = curr->selector;
|
*rp++ = curr->selector;
|
||||||
|
|
||||||
@@ -1786,6 +1812,21 @@ struct WinDesc *cw;
|
|||||||
|
|
||||||
(void) putchar(' ');
|
(void) putchar(' ');
|
||||||
++ttyDisplay->curx;
|
++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
|
* Don't use xputs() because (1) under unix it calls
|
||||||
* tputstr() which will interpret a '*' as some kind
|
* tputstr() which will interpret a '*' as some kind
|
||||||
@@ -1793,27 +1834,20 @@ struct WinDesc *cw;
|
|||||||
* actually output the character. We're faster doing
|
* actually output the character. We're faster doing
|
||||||
* this.
|
* 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;
|
for (n = 0, cp = curr->str;
|
||||||
|
*cp &&
|
||||||
#ifndef WIN32CON
|
#ifndef WIN32CON
|
||||||
*cp
|
(int) ++ttyDisplay->curx < (int) ttyDisplay->cols;
|
||||||
&& (int) ++ttyDisplay->curx < (int) ttyDisplay->cols;
|
|
||||||
cp++, n++)
|
|
||||||
#else
|
#else
|
||||||
*cp
|
(int) ttyDisplay->curx < (int) ttyDisplay->cols;
|
||||||
&& (int) ttyDisplay->curx < (int) ttyDisplay->cols;
|
ttyDisplay->curx++,
|
||||||
cp++, n++, ttyDisplay->curx++)
|
|
||||||
#endif
|
#endif
|
||||||
if (n == 2 && curr->identifier.a_void != 0
|
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) {
|
&& curr->selected) {
|
||||||
if (curr->count == -1L)
|
if (curr->count == -1L)
|
||||||
(void) putchar('+'); /* all selected */
|
(void) putchar('+'); /* all selected */
|
||||||
@@ -1821,15 +1855,10 @@ struct WinDesc *cw;
|
|||||||
(void) putchar('#'); /* count selected */
|
(void) putchar('#'); /* count selected */
|
||||||
} else
|
} else
|
||||||
(void) putchar(*cp);
|
(void) putchar(*cp);
|
||||||
if (iflags.use_menu_color && menucolr) {
|
} /* for *cp */
|
||||||
#ifdef TEXTCOLOR
|
if (n > attr_n && (color != NO_COLOR || attr != ATR_NONE))
|
||||||
if (color != NO_COLOR)
|
toggle_menu_attr(FALSE, color, attr);
|
||||||
term_end_color();
|
} /* if npages > 0 */
|
||||||
#endif
|
|
||||||
term_end_attr(attr);
|
|
||||||
} else
|
|
||||||
term_end_attr(curr->attr);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
page_start = 0;
|
page_start = 0;
|
||||||
page_end = 0;
|
page_end = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user