From a25e55e2880e6059a667ad85ad806a5da524755c Mon Sep 17 00:00:00 2001 From: ryt <0x747972@gmail.com> Date: Fri, 22 Mar 2019 15:11:40 +0000 Subject: [PATCH] Style Menu Options Closes: #1181 Co-authored-by: Mehdi Abaakouk Co-authored-by: Pietro Cerutti --- color.c | 1 + curs_lib.c | 35 ++++++++++++++++++++++++++++++++--- doc/manual.xml.head | 5 +++++ mutt_curses.h | 1 + 4 files changed, 39 insertions(+), 3 deletions(-) diff --git a/color.c b/color.c index 801485f6d..61d77c1c0 100644 --- a/color.c +++ b/color.c @@ -135,6 +135,7 @@ static const struct Mapping Fields[] = { { "markers", MT_COLOR_MARKERS }, { "message", MT_COLOR_MESSAGE }, { "normal", MT_COLOR_NORMAL }, + { "options", MT_COLOR_OPTIONS }, { "progress", MT_COLOR_PROGRESS }, { "prompt", MT_COLOR_PROMPT }, { "quoted", MT_COLOR_QUOTED }, diff --git a/curs_lib.c b/curs_lib.c index 602a324ac..fac1b8e47 100644 --- a/curs_lib.c +++ b/curs_lib.c @@ -795,7 +795,6 @@ int mutt_multi_choice(const char *prompt, const char *letters) int choice; bool redraw = true; int prompt_lines = 1; - char *p = NULL; while (true) { @@ -821,9 +820,39 @@ int mutt_multi_choice(const char *prompt, const char *letters) mutt_menu_current_redraw(); } + mutt_window_move(MuttMessageWindow, 0, 0); + + if ((ColorDefs[MT_COLOR_OPTIONS] != 0) && + (ColorDefs[MT_COLOR_OPTIONS] != ColorDefs[MT_COLOR_PROMPT])) + { + char *cur = NULL; + + while ((cur = strchr(prompt, '('))) + { + // write the part between prompt and cur using MT_COLOR_PROMPT + SETCOLOR(MT_COLOR_PROMPT); + addnstr(prompt, cur - prompt); + + if (isalnum(cur[1]) && cur[2] == ')') + { + // we have a single letter within parentheses + SETCOLOR(MT_COLOR_OPTIONS); + addch(cur[1]); + prompt = cur + 3; + } + else + { + // we have a parenthesis followed by something else + addch(cur[0]); + prompt = cur + 1; + } + } + } + SETCOLOR(MT_COLOR_PROMPT); - mutt_window_mvaddstr(MuttMessageWindow, 0, 0, prompt); + addstr(prompt); NORMAL_COLOR; + mutt_window_clrtoeol(MuttMessageWindow); } @@ -842,7 +871,7 @@ int mutt_multi_choice(const char *prompt, const char *letters) } else { - p = strchr(letters, ch.ch); + char *p = strchr(letters, ch.ch); if (p) { choice = p - letters + 1; diff --git a/doc/manual.xml.head b/doc/manual.xml.head index a4a3e9855..486d0dc0a 100644 --- a/doc/manual.xml.head +++ b/doc/manual.xml.head @@ -4628,6 +4628,11 @@ folder-hook work "set sort=threads" normal + + + options (the key letters in multi-choice questions) + + progress (visual progress bar) diff --git a/mutt_curses.h b/mutt_curses.h index 2650c1197..5fa89010a 100644 --- a/mutt_curses.h +++ b/mutt_curses.h @@ -170,6 +170,7 @@ enum ColorId MT_COLOR_COMPOSE_SECURITY_SIGN, ///< Mail will be signed MT_COLOR_COMPOSE_SECURITY_BOTH, ///< Mail will be encrypted and signed MT_COLOR_COMPOSE_SECURITY_NONE, ///< Mail will not be encrypted or signed + MT_COLOR_OPTIONS, ///< Options in prompt MT_COLOR_MAX, }; -- 2.40.0