From 46282964b4af5fc495084cb66bb1ea108050c859 Mon Sep 17 00:00:00 2001 From: Jairo Llopis Date: Sun, 20 Sep 2020 10:05:53 +0200 Subject: [PATCH] Allow multiline input with custom lexer This should be enough for quick multiline answers where possibly the editor question type is too much. --- PyInquirer/prompts/input.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/PyInquirer/prompts/input.py b/PyInquirer/prompts/input.py index fce4ad8..638d60b 100644 --- a/PyInquirer/prompts/input.py +++ b/PyInquirer/prompts/input.py @@ -33,17 +33,26 @@ def validate(self, document): # TODO style defaults on detail level kwargs['style'] = kwargs.pop('style', default_style) qmark = kwargs.pop('qmark', '?') + kwargs.setdefault('lexer', SimpleLexer('class:answer')) def _get_prompt_tokens(): - return [ + result = [ ('class:questionmark', qmark), ('class:question', ' %s ' % message) ] + if kwargs.get('multiline'): + result += [ + ('class:instruction', 'Multiline; finish with '), + ('class:instruction reverse', 'Esc, ↵'), + ('class:instruction', ' or '), + ('class:instruction reverse', 'Alt+Enter'), + ('class:questionmark', '\n> '), + ] + return result return prompt( message=_get_prompt_tokens, - lexer=SimpleLexer('class:answer'), default=default, **kwargs )