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

Using multiple lexers in prompts? #1755

Open deeplook opened 1 year ago

deeplook commented 1 year ago

I need a prompt where users can input text in multiple languages, say Python and Bash, and I want it to be highlighted accordingly while the user is typing. Detecting the languages is pretty easy with Python and Bash ASTs (using bashlex). But I wonder how to implement some mechanism for switching lexers dynamically? In principle xonsh should be doing exactly that. I'd be grateful for specific advice, though. Maybe it's also an interesting feature to add to the docs.