Highlight the default choice in yellow

This commit is contained in:
Kovid Goyal 2022-01-22 11:45:01 +05:30
parent 1bbab217d0
commit 9419125387
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -150,8 +150,8 @@ def __init__(self, cli_opts: AskCLIOptions) -> None:
else:
allowed = []
for choice in cli_opts.choices:
color = 'green'
letter, text = choice.split(':', maxsplit=1)
color = ''
if ';' in letter:
letter, color = letter.split(';', maxsplit=1)
letter = letter.lower()
@ -215,7 +215,8 @@ def commit_line(end: str = '\r\n') -> None:
for letter, choice in self.choices.items():
text = choice.text[:choice.idx]
text += styled(choice.text[choice.idx], fg=choice.color)
color = choice.color or ('yellow' if letter == self.response else 'green')
text += styled(choice.text[choice.idx], fg=color)
text += choice.text[choice.idx + 1:]
text += ' '
sz = wcswidth(text)