-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Alternate buffer improvement #1764
Conversation
Do you have an example program that illustrates the bad behavior inside xterm.js? |
alt_test.txt |
Some smaller tests... Fix cursor movement when swapping buffersI made xterm.js follow xterm behavior in this test on a cleared buffer: for x in 47 1047 1049 1048 9999; do
echo -e "\E[0m== ${x} ==\n\E[?${x}h\n\E[31mJUNK\E[?${x}lTEST\E[0m\n"; done If 1049 comes back with TEST being red, it means that the attributes of the normal buffer are affected when I enter and exit vim. The result of this can be unpleasant. Each buffer needs its own saved cursor attributesOn running the following in a bash shell, TEST should not be red. echo -e '\E[0m\E[?1049h\E[31m\E[s\E[?1049lTEST\E[0m' Clear alt buffer with erase attributes upon enteringIn most terminals, this will cause the entire buffer to flash green for a second: echo -ne '\E[0m\E[42m\E[?1049h'; sleep 1; echo -ne '\E[?1049l\E[0m' |
@whydoubt Thanks alot for fixing this, LGTM 👍 . I think we should have a few test cases that cover the alt buffer switch behavior rather than relying on external scripts, maybe you could add those under |
I have updated the commits to include relevant tests. |
The changes seem good, just want some clarification on what the first test is meant to do: for x in 47 1047 1049 1048 9999; do echo -e "\033[0m== ${x} ==\n\033[?${x}h\n\033[31mJUNK\033[?${x}lTEST\033[0m\n"; done This screenshot shows macOS programs in this order (left to right): This PR, iTerm2, Terminal.app, xterm.js based on master: |
The key parts in pseudo-code: {print header} {enter alt} {print newline} {text red} {print 'JUNK'} {leave alt} {print 'TEST'}.
|
@whydoubt Wow nice test cases! About correctness - only "spec" I can find about those higher set mode numbers is from xterm and this clearly states when to store/restore cursor attrs and when not. Guess the other emulators do it wrong? Maybe @egmontkob also wants to have a look at this. Since it now works as stated in the xterm doc I am fine with adding it as it is. |
@whydoubt Many thanks for this PR! We gonna add it as it is since it is line with xterm doc/behavior. Also we can easily switch to different behavior if we find it not suitable for whatever reason. |
Alternate buffer handling in xterm.js is lacking in a few areas compared with most other terminals. One is how the cursor color and position is saved and restored. Another is how clearing is done when entering the alternate buffer.
These changes help xterm.js better replicate the behavior of other terminals.