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.35k stars 716 forks source link

soft line wrap by the terminal #709

Open randy3k opened 6 years ago

randy3k commented 6 years ago

I notice that prompt-toolkit will soft-wrap lines in prompt which is too long. Is there any way to stop the wrap lines feature of prompt-toolkit and let the terminal emulator do the soft wrap (just like what GNU readline does)? This'll make copying long line more seamlessly if the wrapping is done by the temrinal.

PS: wrap_lines=False is not what I am asking, with this settings, it not only stop the wrap but creates a horizontal scrollable textarea.

jonathanslenders commented 6 years ago

Hi @randy3k,

This is not easy. @asmeurer asked the question before: https://github.com/jonathanslenders/python-prompt-toolkit/issues/493

It requires at least some changes to the renderer. What I think is that it can work for some applications (like very simple single line prompts), but not for others. It needs some further experimenting. Things to keep into account are how the terminal does automatic reflow of wrapped lines if the width changes (like tmux does), how CPRs (cursor position responses) work when we use this, how vertical cursor movement works and how this would effect the render performance.