Skip to content
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

Erase in Line CSI sequence does not erase line content beyond the terminal width #480

Closed
rprichard opened this issue Sep 29, 2015 · 5 comments

Comments

@rprichard
Copy link

I noticed that with mintty, the Erase in Line CSI sequence (\x1b[<n>K) only erases the currently visible part of the line. If the line extends past the right end of the window, those characters aren't erased. If the window is later expanded horizontally, the previously invisible part of the erased line comes back into view.

This behavior seems wrong to me. It also doesn't match what other terminals do (particularly, xterm, VTE, and Konsole).

Like mintty, xterm also keeps track of obscured line content beyond the right edge of the terminal, but both \x1b[0K and \x1b[2K erase the obscured characters.

Example:

  • Resize a terminal to (say) 50x50.
  • Run: echo -e '\x1b[2J\x1b[1;1HAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'
  • Reduce the terminal's width so that the AAA string is truncated.
  • Run: echo -e '\x1b[1;1H\x1b[2K'
  • Increase the terminal's width.

FWIW: This issue is affecting my winpty project, which frequently rewrites lines when the terminal/console is resized.

@rprichard
Copy link
Author

(particularly, xterm, VTE, and Konsole)

I retested, and I was wrong about xterm. Actually, it doesn't restore truncated line content when shrinking and expanding a terminal, so it's not relevant to this issue.

@mintty
Copy link
Owner

mintty commented Sep 29, 2015

Fixed:
CSI K Erase in Line
CSI J Erase in Display
CSI X Erase Characters
CSI @ Insert Characters
CSI P Delete Characters
CSI 4 h/l Insert Mode

test script:

#! /bin/sh

# mintty issue #480
# Erase in Line CSI sequence does not erase line content beyond the terminal width

echo -en "\e[8;;88t"
echo -en "\e[2J"
o40="ooooo______________________________ooooo"
for n in 1 2 3 4 5 6 7 8 9 0
do  echo; echo; echo; echo
done
echo -en "\e[1G${o40}XXXXX______________________________________XXXXX"
echo -en "\e[1;1H"

echo -en "\e[1;1H${o40}XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
echo -en "\e[2;1H${o40}123456789012345678901234567890123456789012345678"
echo -en "\e[3;1H${o40}XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
echo -en "\e[4;1H${o40}123456789012345678901234567890123456789012345678"
echo -en "\e[5;1H${o40}XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
echo -en "\e[6;1H${o40}12345678901234567890123456789012345678901睷4睷78"
echo -en "\e[7;1H${o40}12345678901234567890123456789012345678901睷4睷78"
echo -en "\e[8;1H${o40}XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
echo -en "\e[9;1H${o40}睷睷睷睷睷睷睷睷睷睷睷睷睷睷睷睷睷睷睷睷睷睷睷睷"
echo -en "\e[10;1H${o40} 睷睷睷睷睷睷睷睷睷睷睷睷睷睷睷睷睷睷睷睷睷睷睷"
echo -en "\e[11;1H"
sleep 1
echo -en "\e[8;;80t"
sleep 1

echo -en "\e[2;40H\e[1J"
sleep 1
echo -en "\e[3;41H\e[K"
sleep 1
echo -en "\e[4;77H\e[4hii\e[4l"
sleep 1
echo -en "\e[5;77H\e[8X"
sleep 1
echo -en "\e[6;77H\e[2@"
sleep 1
echo -en "\e[7;77H\e[2P"
sleep 1
echo -en "\e[8;41H\e[J"

sleep 1
echo -en "\e[8;;88t"
echo -en "\e[11;1H"

@rprichard
Copy link
Author

Looks good to me. Thanks.

I also looked at how Konsole and gnome-terminal (an old version that didn't rewrap lines) handled some of the other CSI sequences, and curiously, Delete Characters (P) would slide obscured content into view, but Insert Characters (@) and insert mode (h/l) instead cleared the obscured characters. The two terminals handled Erase Characters (X) differently, with gnome-terminal matching the new mintty behavior, and Konsole clearing all the obscured characters. I have no idea if behavior is intentional. The new mintty behavior seems fine to me.

@mintty
Copy link
Owner

mintty commented Sep 30, 2015

Thanks for the feedback.

@mintty mintty closed this as completed Sep 30, 2015
@mintty
Copy link
Owner

mintty commented Nov 3, 2015

Released in 2.2.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants