Tinyrl - Sending "Erase down" escape codes after each typed character
Original Message from Corentin:
--What steps will reproduce the problem?
1. Open Klish with a fake TTY (pexpect?)
2. type a command
3. Command that shows up is:
--What is the expected output? What do you see instead?
I would expect:
--What version of the product are you using? On what operating system?
1.6.8, linux Debian
--Please provide any additional information below.
I would agree that Fake TTY should not open Klish interactively.. One of our user uses a fake TTY to open the shell in a webinterface... Their product is quite limited and doesn't understand escape sequences.
The terminal sends only command in one block and carriage return.
It can also send ^C to interrupt the command. That's it!
When using Bash, they have no issue since bash doesn't send any escape sequence for just typing a command.
I've been digging in the code. I see that tinyrl_redisplay is called for pretty much everything over there.
I have couple questions and suggestions:
1/ I am going to see if I can make Klish less call on "redisplay", or if I can have redisplay call erase down only when necessary.
2/ q: Should we have Klish support multiple types of $TERM? VT100 is good since pretty wide, but ANSI could be interesting as well...
3/ q: Would it be interesting/possible to leverage readline? The advantage would be that Klish could leverage features from a well known open source tool and plug its own on top.
I will update this issue with a potential patch...
Attached is a patch that solves my issue.
That patch adds a variable that keeps in mind the length of the previous line
written. If it is greater than the current one, it erases down to eliminate
extra characters. If it is smaller, no need since the new line will overwrite
the smaller line.
Original Reply from Serj:
Yes. It's a real problem with fake ttys. We have it too.
I will think about the right way to solve it. The patch is a workaround only. And I think it will fail when you press Up arrow or something else to get history. The redisplay() doesn't delete the whole line. It delete only difference beetween previous and current line.
Probably klish needs ANSI.
I don't think the readline is appropriate. May be it's not good but now klish has too much dependencies with tynirl and the tinyrl is not general.
P.S. Please post the issues to the new issue tracker.
This issue was first added on googlecode and copied/pasted here.
#1 Updated by Serj Kalichev over 3 years ago
I'm sorry. The patch is good enough. It was applied with minimal naming changes. Thanks.
Do you really need ANSI terminal? What the purpose?
I have find out that fake ttys don't understand any escape sequences. In a case of ANSI terminal you will get something like "[K" (or something else) instead "[J".
When we use a terminal emulator the VT100 is always accessible.