Open knz opened 7 years ago
I can see some usefulness while doing line redraw such as highlighting: but the flickering can be somewhat annoying. @chzyer Before I knew this project I wrote a similar one that had the same issue which I solved by: \r%s\033[K (%s being the content or prompt + content) unlike \033[2K which deletes entire line, I simple move cursor back '\r', overwrite the content and finally \033[K deleting the rest of the line, no more input flickering
although I'm not sure about \033[K support across the terminals
At CockroachDB we are now using expect to test the SQL shell and this shows all the characters sent by the program to the terminal. In our expect traces we see things like this:
What is happening here, is that after every character typed by the user (received by readline from the terminal), readline issues
\033[J\033[2K\r
to the terminal then redraws (re-outputs) the prompt and all the characters typed so far.This is sub-optimal: a redraw should only be necessary when characters previously present in the readline buffer are modified (e.g. when using left-arrow, up-arrow etc). During normal input of non-special characters, this redraw is unnecessary.
Also on slow terminals (like over slow ssh connections) this redraw becomes clearly noticeable to the user for very long inputs.