I'm sorry for the duplicate, it looks like I messed up my config while
testing patches and didn't use list-reply properly last time.
> I've only taken a quick look at the patch - I don't have time to look
> closely or test right now.
>
> It looks like this version is now changing behavior with $cursor_overlay
> unset. The tree colors should not be drawn (with $arrow_cursor unset)
> in that case. Would you confirm that is still the case.
It is. If use_indicator is set, then everything is drawn as indicator
(fallback from mutt_merge_colors), else tree colors are used.
And use_indicator (please, note: this is not the same as is_current)
itself is set by callers when there is no $arrow_cursor and item is
current.
> However if the $cursor_overlay is now going to affect tree drawing too,
> it may be more appropriate the name the option $color_overlay. What do
> you think?
Makes sense. Tree is combined even on regular menu items. Can you
think of other instances where overlaying colors might be appropriate?
Maybe search? I think, mutt doesn't do any search highlighting in the
menu (yet?). Search colors in the pager may be merged with containing
text, header or quote. I'll investigate that next.
> Personally I'd rather leave it as before, with mutt_merge_colors() doing
> what it is told, in case that needs to be used in other places. Whereas
> mutt_attrset_cursor() sets the cursor how is should based on options.
This was my concern also. I reverted this change. I also moved all
appropriate checks back into print_enriched_string(). Logic stays the
same as last time. This is temporary, I think. If we're going to add
more uses of mutt_merge_colors(), something like int
mutt_color_overlay(int base, int overlay) should be added to obtain
merged color based on overlay setting. I'm not sure if it's going to
be needed and how it's going to look just yet.
diff --git a/menu.c b/menu.c
index 2da07c25..0607d16d 100644
--- a/menu.c
+++ b/menu.c
@@ -35,20 +35,39 @@ static size_t MenuStackCount = 0;
static size_t MenuStackLen = 0;
static MUTTMENU **MenuStack = NULL;
-static void print_enriched_string (int attr, unsigned char *s, int do_color)
+static void print_enriched_string (int base_color, unsigned char *s, int
use_indicator)
{
wchar_t wc;
size_t k;
size_t n = mutt_strlen ((char *)s);
mbstate_t mbstate;
+ int tree_color;
+
+ if (option (OPTCURSOROVERLAY))
+ {
+ tree_color = mutt_merge_colors (base_color, ColorDefs[MT_COLOR_TREE]);
+ if (use_indicator)
+ {
+ tree_color = mutt_merge_colors (tree_color,
ColorDefs[MT_COLOR_INDICATOR]);
+ base_color = mutt_merge_colors (base_color,
ColorDefs[MT_COLOR_INDICATOR]);
+ }
+ }
+ else
+ {
+ tree_color = ColorDefs[MT_COLOR_TREE];
+ if (use_indicator)
+ {
+ tree_color = ColorDefs[MT_COLOR_INDICATOR];
+ base_color = ColorDefs[MT_COLOR_INDICATOR];
+ }
+ }
memset (&mbstate, 0, sizeof (mbstate));
while (*s)
{
if (*s < MUTT_TREE_MAX)
{
- if (do_color)
- SETCOLOR (MT_COLOR_TREE);
+ ATTRSET (tree_color);
while (*s && *s < MUTT_TREE_MAX)
{
switch (*s)
@@ -165,7 +184,7 @@ static void print_enriched_string (int attr, unsigned char
*s, int do_color)
}
s++, n--;
}
- if (do_color) ATTRSET(attr);
+ ATTRSET(base_color);
}
else if ((k = mbrtowc (&wc, (char *)s, n, &mbstate)) > 0)
{
@@ -251,7 +270,6 @@ void menu_redraw_index (MUTTMENU *menu)
{
char buf[LONG_STRING];
int i;
- int do_color;
int attr;
for (i = menu->top; i < menu->top + menu->pagelen; i++)
@@ -265,24 +283,31 @@ void menu_redraw_index (MUTTMENU *menu)
ATTRSET(attr);
mutt_window_move (menu->indexwin, i - menu->top + menu->offset, 0);
- do_color = 1;
if (i == menu->current)
{
- mutt_attrset_cursor (attr, ColorDefs[MT_COLOR_INDICATOR]);
if (option(OPTARROWCURSOR))
{
+ SETCOLOR(MT_COLOR_INDICATOR);
addstr ("->");
ATTRSET(attr);
addch (' ');
+ print_enriched_string (attr, (unsigned char *) buf, 0);
}
else
- do_color = 0;
+ {
+ mutt_attrset_cursor (attr, ColorDefs[MT_COLOR_INDICATOR]);
+ print_enriched_string (attr, (unsigned char *) buf, 1);
+ }
+ }
+ else
+ {
+ if (option(OPTARROWCURSOR))
+ {
+ addstr(" ");
+ }
+ print_enriched_string (attr, (unsigned char *) buf, 0);
}
- else if (option(OPTARROWCURSOR))
- addstr(" ");
-
- print_enriched_string (attr, (unsigned char *) buf, do_color);
}
else
{
@@ -325,11 +350,11 @@ void menu_redraw_motion (MUTTMENU *menu)
menu_make_entry (buf, sizeof (buf), menu, menu->oldcurrent);
menu_pad_string (menu, buf, sizeof (buf));
mutt_window_move (menu->indexwin, menu->oldcurrent + menu->offset -
menu->top, 3);
- print_enriched_string (old_color, (unsigned char *) buf, 1);
+ print_enriched_string (old_color, (unsigned char *) buf, 0);
}
/* now draw it in the new location */
- mutt_attrset_cursor (cur_color, ColorDefs[MT_COLOR_INDICATOR]);
+ SETCOLOR(MT_COLOR_INDICATOR);
mutt_window_mvaddstr (menu->indexwin, menu->current + menu->offset -
menu->top, 0, "->");
}
else
@@ -337,14 +362,14 @@ void menu_redraw_motion (MUTTMENU *menu)
/* erase the current indicator */
menu_make_entry (buf, sizeof (buf), menu, menu->oldcurrent);
menu_pad_string (menu, buf, sizeof (buf));
- print_enriched_string (old_color, (unsigned char *) buf, 1);
+ print_enriched_string (old_color, (unsigned char *) buf, 0);
/* now draw the new one to reflect the change */
menu_make_entry (buf, sizeof (buf), menu, menu->current);
menu_pad_string (menu, buf, sizeof (buf));
mutt_attrset_cursor (cur_color, ColorDefs[MT_COLOR_INDICATOR]);
mutt_window_move (menu->indexwin, menu->current + menu->offset -
menu->top, 0);
- print_enriched_string (cur_color, (unsigned char *) buf, 0);
+ print_enriched_string (cur_color, (unsigned char *) buf, 1);
}
menu->redraw &= REDRAW_STATUS;
NORMAL_COLOR;
@@ -359,17 +384,21 @@ void menu_redraw_current (MUTTMENU *menu)
menu_make_entry (buf, sizeof (buf), menu, menu->current);
menu_pad_string (menu, buf, sizeof (buf));
- mutt_attrset_cursor (attr, ColorDefs[MT_COLOR_INDICATOR]);
if (option (OPTARROWCURSOR))
{
+ SETCOLOR(MT_COLOR_INDICATOR);
addstr ("->");
ATTRSET(attr);
addch (' ');
menu_pad_string (menu, buf, sizeof (buf));
- print_enriched_string (attr, (unsigned char *) buf, 1);
+ print_enriched_string (attr, (unsigned char *) buf, 0);
}
else
- print_enriched_string (attr, (unsigned char *) buf, 0);
+ {
+ mutt_attrset_cursor (attr, ColorDefs[MT_COLOR_INDICATOR]);
+ print_enriched_string (attr, (unsigned char *) buf, 1);
+ }
+
menu->redraw &= REDRAW_STATUS;
NORMAL_COLOR;
}