The color syntax highlight breaks when the line buffer falls in the wrong place
There is nothing we can currently do about this, but I'm hoping someone will come up with an inventive fix.
To be clearer, if perl/expect receives 100bytes from the ssh program, the ending byte might be in the middle of a statement we want to match.
Let's say we wanted to match "Total output drops: (\d+)" but the end of the buffer was "Total output".
With short commands this never happens because the buffer is smaller than the maximum ssh allows, so it pauses at the prompt. One way to reduce this would be to increase the size of the buffer. I think I tried it but couldn't find a way to do it. Another method to handle this would be to hold the buffer and glue them together. The problem there is we need to output to the screen as soon as we get and process data, or the user will wonder where all the text is.
A third choice is to be more aware of the screen handling. We could print text immediately, then somehow yank it back to fix issues. There are a couple of problems with this
- This might mess up log files
- I don't know how to do it
If I had to guess how it could be done, we could hold the last line of the old buffer. We might need to make certain the router wasn't at a prompt (this might not matter). Once we got the next buffer, we glue the two together and rerun the regex for that line. Then use \r to reset the current line and print it again.