diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-05 04:45:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-05 04:45:14 +0000 |
commit | 437643bd908d99924e3003db4d9d3718d9df5813 (patch) | |
tree | 9752c4e8ebd3ae23f7a586066a874bd4418feeaa /examples/prompts/auto-completion | |
parent | Adding debian version 3.0.43-2. (diff) | |
download | prompt-toolkit-437643bd908d99924e3003db4d9d3718d9df5813.tar.xz prompt-toolkit-437643bd908d99924e3003db4d9d3718d9df5813.zip |
Merging upstream version 3.0.46.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'examples/prompts/auto-completion')
12 files changed, 21 insertions, 9 deletions
diff --git a/examples/prompts/auto-completion/autocomplete-with-control-space.py b/examples/prompts/auto-completion/autocomplete-with-control-space.py index 61160a3..238f908 100755 --- a/examples/prompts/auto-completion/autocomplete-with-control-space.py +++ b/examples/prompts/auto-completion/autocomplete-with-control-space.py @@ -2,6 +2,7 @@ """ Example of using the control-space key binding for auto completion. """ + from prompt_toolkit import prompt from prompt_toolkit.completion import WordCompleter from prompt_toolkit.key_binding import KeyBindings @@ -68,7 +69,7 @@ def main(): complete_while_typing=False, key_bindings=kb, ) - print("You said: %s" % text) + print(f"You said: {text}") if __name__ == "__main__": diff --git a/examples/prompts/auto-completion/autocompletion-like-readline.py b/examples/prompts/auto-completion/autocompletion-like-readline.py index 613d3e7..eac0edd 100755 --- a/examples/prompts/auto-completion/autocompletion-like-readline.py +++ b/examples/prompts/auto-completion/autocompletion-like-readline.py @@ -3,6 +3,7 @@ Autocompletion example that displays the autocompletions like readline does by binding a custom handler to the Tab key. """ + from prompt_toolkit.completion import WordCompleter from prompt_toolkit.shortcuts import CompleteStyle, prompt @@ -51,7 +52,7 @@ def main(): completer=animal_completer, complete_style=CompleteStyle.READLINE_LIKE, ) - print("You said: %s" % text) + print(f"You said: {text}") if __name__ == "__main__": diff --git a/examples/prompts/auto-completion/autocompletion.py b/examples/prompts/auto-completion/autocompletion.py index fc9dda0..ea5727f 100755 --- a/examples/prompts/auto-completion/autocompletion.py +++ b/examples/prompts/auto-completion/autocompletion.py @@ -7,6 +7,7 @@ Press [Tab] to complete the current word. and shows all the completions. (In the menu) - Any following tab press cycles through all the possible completions. """ + from prompt_toolkit import prompt from prompt_toolkit.completion import WordCompleter @@ -53,7 +54,7 @@ def main(): text = prompt( "Give some animals: ", completer=animal_completer, complete_while_typing=False ) - print("You said: %s" % text) + print(f"You said: {text}") if __name__ == "__main__": diff --git a/examples/prompts/auto-completion/colored-completions-with-formatted-text.py b/examples/prompts/auto-completion/colored-completions-with-formatted-text.py index 8a89c7a..eeff259 100755 --- a/examples/prompts/auto-completion/colored-completions-with-formatted-text.py +++ b/examples/prompts/auto-completion/colored-completions-with-formatted-text.py @@ -4,6 +4,7 @@ Demonstration of a custom completer class and the possibility of styling completions independently by passing formatted text objects to the "display" and "display_meta" arguments of "Completion". """ + from prompt_toolkit.completion import Completer, Completion from prompt_toolkit.formatted_text import HTML from prompt_toolkit.shortcuts import CompleteStyle, prompt diff --git a/examples/prompts/auto-completion/colored-completions.py b/examples/prompts/auto-completion/colored-completions.py index 9c5cba3..1295e7d 100755 --- a/examples/prompts/auto-completion/colored-completions.py +++ b/examples/prompts/auto-completion/colored-completions.py @@ -3,6 +3,7 @@ Demonstration of a custom completer class and the possibility of styling completions independently. """ + from prompt_toolkit.completion import Completer, Completion from prompt_toolkit.output.color_depth import ColorDepth from prompt_toolkit.shortcuts import CompleteStyle, prompt diff --git a/examples/prompts/auto-completion/combine-multiple-completers.py b/examples/prompts/auto-completion/combine-multiple-completers.py index 511988b..7c21078 100755 --- a/examples/prompts/auto-completion/combine-multiple-completers.py +++ b/examples/prompts/auto-completion/combine-multiple-completers.py @@ -2,6 +2,7 @@ """ Example of multiple individual completers that are combined into one. """ + from prompt_toolkit import prompt from prompt_toolkit.completion import WordCompleter, merge_completers @@ -69,7 +70,7 @@ def main(): text = prompt( "Give some animals: ", completer=completer, complete_while_typing=False ) - print("You said: %s" % text) + print(f"You said: {text}") if __name__ == "__main__": diff --git a/examples/prompts/auto-completion/fuzzy-custom-completer.py b/examples/prompts/auto-completion/fuzzy-custom-completer.py index fd9a7d7..ca763c7 100755 --- a/examples/prompts/auto-completion/fuzzy-custom-completer.py +++ b/examples/prompts/auto-completion/fuzzy-custom-completer.py @@ -3,6 +3,7 @@ Demonstration of a custom completer wrapped in a `FuzzyCompleter` for fuzzy matching. """ + from prompt_toolkit.completion import Completer, Completion, FuzzyCompleter from prompt_toolkit.shortcuts import CompleteStyle, prompt diff --git a/examples/prompts/auto-completion/fuzzy-word-completer.py b/examples/prompts/auto-completion/fuzzy-word-completer.py index 329c0c1..0ea059e 100755 --- a/examples/prompts/auto-completion/fuzzy-word-completer.py +++ b/examples/prompts/auto-completion/fuzzy-word-completer.py @@ -7,6 +7,7 @@ Press [Tab] to complete the current word. and shows all the completions. (In the menu) - Any following tab press cycles through all the possible completions. """ + from prompt_toolkit.completion import FuzzyWordCompleter from prompt_toolkit.shortcuts import prompt @@ -52,7 +53,7 @@ def main(): text = prompt( "Give some animals: ", completer=animal_completer, complete_while_typing=True ) - print("You said: %s" % text) + print(f"You said: {text}") if __name__ == "__main__": diff --git a/examples/prompts/auto-completion/multi-column-autocompletion-with-meta.py b/examples/prompts/auto-completion/multi-column-autocompletion-with-meta.py index 5ba3ab5..c748837 100755 --- a/examples/prompts/auto-completion/multi-column-autocompletion-with-meta.py +++ b/examples/prompts/auto-completion/multi-column-autocompletion-with-meta.py @@ -2,6 +2,7 @@ """ Autocompletion example that shows meta-information alongside the completions. """ + from prompt_toolkit.completion import WordCompleter from prompt_toolkit.shortcuts import CompleteStyle, prompt @@ -43,7 +44,7 @@ def main(): completer=animal_completer, complete_style=CompleteStyle.MULTI_COLUMN, ) - print("You said: %s" % text) + print(f"You said: {text}") if __name__ == "__main__": diff --git a/examples/prompts/auto-completion/multi-column-autocompletion.py b/examples/prompts/auto-completion/multi-column-autocompletion.py index 7fcfc52..9b24622 100755 --- a/examples/prompts/auto-completion/multi-column-autocompletion.py +++ b/examples/prompts/auto-completion/multi-column-autocompletion.py @@ -2,6 +2,7 @@ """ Similar to the autocompletion example. But display all the completions in multiple columns. """ + from prompt_toolkit.completion import WordCompleter from prompt_toolkit.shortcuts import CompleteStyle, prompt @@ -50,7 +51,7 @@ def main(): completer=animal_completer, complete_style=CompleteStyle.MULTI_COLUMN, ) - print("You said: %s" % text) + print(f"You said: {text}") if __name__ == "__main__": diff --git a/examples/prompts/auto-completion/nested-autocompletion.py b/examples/prompts/auto-completion/nested-autocompletion.py index cd85b8c..e56e82e 100755 --- a/examples/prompts/auto-completion/nested-autocompletion.py +++ b/examples/prompts/auto-completion/nested-autocompletion.py @@ -2,6 +2,7 @@ """ Example of nested autocompletion. """ + from prompt_toolkit import prompt from prompt_toolkit.completion import NestedCompleter @@ -15,7 +16,7 @@ completer = NestedCompleter.from_nested_dict( def main(): text = prompt("Type a command: ", completer=completer) - print("You said: %s" % text) + print(f"You said: {text}") if __name__ == "__main__": diff --git a/examples/prompts/auto-completion/slow-completions.py b/examples/prompts/auto-completion/slow-completions.py index cce9d59..0c9cc11 100755 --- a/examples/prompts/auto-completion/slow-completions.py +++ b/examples/prompts/auto-completion/slow-completions.py @@ -12,6 +12,7 @@ An example of how to deal with slow auto completion code. - We also set a `loading` boolean in the completer function to keep track of when the completer is running, and display this in the toolbar. """ + import time from prompt_toolkit.completion import Completer, Completion @@ -96,7 +97,7 @@ def main(): bottom_toolbar=bottom_toolbar, complete_style=CompleteStyle.MULTI_COLUMN, ) - print("You said: %s" % text) + print(f"You said: {text}") if __name__ == "__main__": |