From bc0c7217a59e432bdb64c9f6cbd3de1803d6919e Mon Sep 17 00:00:00 2001 From: Leonardo Cunha Date: Thu, 15 Feb 2024 18:16:30 -0300 Subject: [PATCH] Merge styles with Choice custom styles Allow selected and highlighted styles to work with Choice custom styles. --- questionary/prompts/common.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/questionary/prompts/common.py b/questionary/prompts/common.py index 827629db..e57416a4 100644 --- a/questionary/prompts/common.py +++ b/questionary/prompts/common.py @@ -410,7 +410,12 @@ def append(index: int, choice: Choice): tokens.append(("class:text", "{}".format(indicator))) if isinstance(choice.title, list): - tokens.extend(choice.title) + if selected: + tokens.extend(map(lambda title : (title[0] + " class:selected", title[1]) , choice.title)) + elif index == self.pointed_at: + tokens.extend(map(lambda title : (title[0] + " class:highlighted", title[1]) , choice.title)) + else: + tokens.extend(choice.title) elif selected: tokens.append( ("class:selected", "{}{}".format(shortcut, choice.title))