Adapt prompt_toolkit call because now using the v3.x of the lib

This commit is contained in:
Alexandre Aubin 2021-10-19 20:18:20 +02:00 committed by GitHub
parent 824a9ed42e
commit d901d28add
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -550,35 +550,36 @@ class Interface:
if not is_multiline: if not is_multiline:
import prompt_toolkit import prompt_toolkit
from prompt_toolkit.contrib.completers import WordCompleter from prompt_toolkit.completion import WordCompleter
from prompt_toolkit.styles import Style
from pygments.token import Token from pygments.token import Token
autocomplete_ = WordCompleter(autocomplete) autocomplete_ = WordCompleter(autocomplete)
style = prompt_toolkit.styles.style_from_dict( style = Style.from_dict(
{ {
Token.Message: f"#ansi{color} bold", "": "",
"message": f"#ansi{color} bold",
} }
) )
def get_bottom_toolbar_tokens(cli): def bottom_toolbar():
if help: if help:
return [(Token, help)] return [("class:", help)]
else: else:
return [] return []
def get_tokens(cli): colored_message = [
return [ ("class:message", message),
(Token.Message, message), ("class:", ": "),
(Token, ": "), ]
]
return prompt_toolkit.prompt( return prompt_toolkit.prompt(
get_prompt_tokens=get_tokens, colored_message,
get_bottom_toolbar_tokens=get_bottom_toolbar_tokens, bottom_toolbar=bottom_toolbar,
style=style, style=style,
default=prefill, default=prefill,
true_color=True,
completer=autocomplete_, completer=autocomplete_,
complete_while_typing=True,
is_password=is_password, is_password=is_password,
) )