Open halloleo opened 4 years ago
What is the reason you are using a dumb terminal?
I believe the input should work fine, but the rendering output will not, because prompt_toolkit's rendering engine is made for a complex layout that can't be converted to what a dumb terminal expects.
What about solving it in your application the way you want to handle it?
if os.environ['TERM'] in ['dumb', 'unknown']:
text = input(...)
else:
text = prompt_toolkit.prompt(...)
What is the reason you are using a dumb terminal?
I have my shell in an Emacs shell-buffer which is very handy for all interaction beween shell and files/directories. However it provides a rather minimal termianl interface accepting the output as stream of simple lines and providing the input as line string.
I believe the input should work fine, but the rendering output will not, because prompt_toolkit's rendering engine is made for a complex layout that can't be converted to what a dumb terminal expects.
Yep, I guess the output is the problem.
What about solving it in your application the way you want to handle it?
Lots of libraries and application work on top of prompt_toolkit! If prompt-toolkit had an option to degrade gracefully on dumb terminals all these applications would automatically work! :-)
Hi @halloleo,
I think we can do it. Can you have a look at this PR and see whether that works? https://github.com/prompt-toolkit/python-prompt-toolkit/pull/1035 (I didn't test it yet.)
Wow, you are pretty quick with the fix!
I have tried it and it somewhat works. Examples like get-input.py
or regular-language.py
work fine and auto-suggestion.py
, autocorrection.py
and clock-input.py
degrade reasonably.
However I noticed two things:
confirmation-prompt.py
the print result is different: under vt100 terminals it is True
/False,
, under dumb terminals it is y
/n
.responds_to_cpr
in vt100.py
you still need to set the environment var PROMPT_TOOLKIT_NO_CPR
for better degradation. Is there a chance to check for PROMPT_TOOLKIT_NO_CPR
and for TERM=dumb
?Thanks heaps for looking into this!
Thanks for the feedback! I still have to look into fixing this.
No worries. Fully understand that there is more to it.
+1 for this! My main use case is Emacs as well.
+1 for the same case. Thanks!
My case involves debugging via PyCharm
On dumb terminals (TERM=dumb or TERM=unkown) prompt-toolkit behaves strangely: Some message are not displayed, it expects arrow key support, etc.
I was wondering whether it is possible to swap the
Vt100Input
class for a class which offers genuinely less capabilities (i.e. no cursor movement, no arrow keys, etc).