prompt-toolkit / python-prompt-toolkit

Library for building powerful interactive command line applications in Python
https://python-prompt-toolkit.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
9.11k stars 717 forks source link

How to change text and cursor position after selecting suggestion? #1772

Open grundic opened 11 months ago

grundic commented 11 months ago

Hi,

First of all, thank you very much for your amazing work, @jonathanslenders, bravo!

So I have a small question: I'm trying to implement a CLI editor for key/value pairs. I would like to modify the selected text, add double quotes and put cursor between them, so that user would immediately start typing a value. But I don't want to display those extra characters in the suggestion list. Could you please give me some pointers how such behaviour might be implemented?

E.g. if we have a list of options Foo, Bar, Baz and user selects Bar, that's how it would look (_ is cursor position after selecting the suggestion):

> Bar: "_"

Thank you very much!