Open halloleo opened 3 years ago
Hi @halloleo,
This should be possible if you wrap the prompt in an ANSI
object: https://python-prompt-toolkit.readthedocs.io/en/master/pages/reference.html#prompt_toolkit.formatted_text.ANSI
Just makes sure to wrap the special characters that prompt_toolkit doesn't recognize as color between \001
and \002
.
Thanks for the suggestion, @jonathanslenders!
Now I tried to built a mini prompt-toolkit repl with the following code:
while True:
p_str = ANSI('> \x1b]51;A{}\x1b\\'.format('my hidden text'))
text = session.prompt(p_str)
print_formatted_text('You entered: ', text)
But this still shows "my hidden text" visibly in the terminal.
Somehow the ANSI sequences are stripped out again. :-(
PS: In a bash REPL with a prompt set via a function like this:
my_print(){
printf "\e]51;A%s\e\\" "my hidden text"
}
export PS1='> \[$(my_print)\]'
it works perfectly.
I using the emacs-libvterm terminal emulator and run a prompt-toolkit based REPL inside it.
For interaction with the terminal "host" I need to issue special vt100 sequences at the end of each prompt-toolkit prompt. I try to issue these sequences lkie this:
However
prompt_toolkit
seems to filter out the escape bits of it, so that the information is not hidden as the terminal requires it.How can I send exactly these escape sequences at the end of each prompt?