-
Notifications
You must be signed in to change notification settings - Fork 4.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
Use E3 to completely clear console on Unix when possible #88487
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -75,22 +75,22 @@ public void VerifyTermInfoSupportsNewAndLegacyNcurses() | |||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
[Theory] | ||||||||||||||||||||||||||||||
[PlatformSpecific(TestPlatforms.AnyUnix)] // Tests TermInfo | ||||||||||||||||||||||||||||||
[InlineData("xterm-256color", "\u001B\u005B\u00330m", "\u001B\u005B\u00340m", 0)] | ||||||||||||||||||||||||||||||
[InlineData("xterm-256color", "\u001B\u005B\u00331m", "\u001B\u005B\u00341m", 1)] | ||||||||||||||||||||||||||||||
[InlineData("xterm-256color", "\u001B\u005B90m", "\u001B\u005B100m", 8)] | ||||||||||||||||||||||||||||||
[InlineData("screen", "\u001B\u005B\u00330m", "\u001B\u005B\u00340m", 0)] | ||||||||||||||||||||||||||||||
[InlineData("screen", "\u001B\u005B\u00332m", "\u001B\u005B\u00342m", 2)] | ||||||||||||||||||||||||||||||
[InlineData("screen", "\u001B\u005B\u00339m", "\u001B\u005B\u00349m", 9)] | ||||||||||||||||||||||||||||||
[InlineData("Eterm", "\u001B\u005B\u00330m", "\u001B\u005B\u00340m", 0)] | ||||||||||||||||||||||||||||||
[InlineData("Eterm", "\u001B\u005B\u00333m", "\u001B\u005B\u00343m", 3)] | ||||||||||||||||||||||||||||||
[InlineData("Eterm", "\u001B\u005B\u003310m", "\u001B\u005B\u003410m", 10)] | ||||||||||||||||||||||||||||||
[InlineData("wsvt25", "\u001B\u005B\u00330m", "\u001B\u005B\u00340m", 0)] | ||||||||||||||||||||||||||||||
[InlineData("wsvt25", "\u001B\u005B\u00334m", "\u001B\u005B\u00344m", 4)] | ||||||||||||||||||||||||||||||
[InlineData("wsvt25", "\u001B\u005B\u003311m", "\u001B\u005B\u003411m", 11)] | ||||||||||||||||||||||||||||||
[InlineData("mach-color", "\u001B\u005B\u00330m", "\u001B\u005B\u00340m", 0)] | ||||||||||||||||||||||||||||||
[InlineData("mach-color", "\u001B\u005B\u00335m", "\u001B\u005B\u00345m", 5)] | ||||||||||||||||||||||||||||||
[InlineData("mach-color", "\u001B\u005B\u003312m", "\u001B\u005B\u003412m", 12)] | ||||||||||||||||||||||||||||||
public void TermInfoVerification(string termToTest, string expectedForeground, string expectedBackground, int colorValue) | ||||||||||||||||||||||||||||||
[InlineData("xterm-256color", "\u001B\u005B\u00330m", "\u001B\u005B\u00340m", 0, true)] | ||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the test failures indicate that E3 is missing on xterm-256color, but only macOS. I wonder why: does macOS simply not provide it or it has a different name? Please let me know if you need a copy of macOS terminfo file.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. According to https://github.com/watchexec/clearscreen/blob/main/TERMINALS.md#platforms macOS doesn't include E3 in terminfo. That seems to be true on the mac I have access to -- and the I'll take a look at the |
||||||||||||||||||||||||||||||
[InlineData("xterm-256color", "\u001B\u005B\u00331m", "\u001B\u005B\u00341m", 1, true)] | ||||||||||||||||||||||||||||||
[InlineData("xterm-256color", "\u001B\u005B90m", "\u001B\u005B100m", 8, true)] | ||||||||||||||||||||||||||||||
[InlineData("screen", "\u001B\u005B\u00330m", "\u001B\u005B\u00340m", 0, false)] | ||||||||||||||||||||||||||||||
[InlineData("screen", "\u001B\u005B\u00332m", "\u001B\u005B\u00342m", 2, false)] | ||||||||||||||||||||||||||||||
[InlineData("screen", "\u001B\u005B\u00339m", "\u001B\u005B\u00349m", 9, false)] | ||||||||||||||||||||||||||||||
[InlineData("Eterm", "\u001B\u005B\u00330m", "\u001B\u005B\u00340m", 0, false)] | ||||||||||||||||||||||||||||||
[InlineData("Eterm", "\u001B\u005B\u00333m", "\u001B\u005B\u00343m", 3, false)] | ||||||||||||||||||||||||||||||
[InlineData("Eterm", "\u001B\u005B\u003310m", "\u001B\u005B\u003410m", 10, false)] | ||||||||||||||||||||||||||||||
[InlineData("wsvt25", "\u001B\u005B\u00330m", "\u001B\u005B\u00340m", 0, false)] | ||||||||||||||||||||||||||||||
[InlineData("wsvt25", "\u001B\u005B\u00334m", "\u001B\u005B\u00344m", 4, false)] | ||||||||||||||||||||||||||||||
[InlineData("wsvt25", "\u001B\u005B\u003311m", "\u001B\u005B\u003411m", 11, false)] | ||||||||||||||||||||||||||||||
[InlineData("mach-color", "\u001B\u005B\u00330m", "\u001B\u005B\u00340m", 0, false)] | ||||||||||||||||||||||||||||||
[InlineData("mach-color", "\u001B\u005B\u00335m", "\u001B\u005B\u00345m", 5, false)] | ||||||||||||||||||||||||||||||
[InlineData("mach-color", "\u001B\u005B\u003312m", "\u001B\u005B\u003412m", 12, false)] | ||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it's a pity that it's not supported by more terminals. FWIW we have
runtime/src/libraries/System.Console/tests/KeyParserTests.cs Lines 16 to 26 in 104752a
if you want to check anything related to this terminals you can just hack these tests, the runtime/src/libraries/System.Console/tests/KeyParserTests.cs Lines 431 to 432 in 104752a
You can even debug that on Windows, as these tests are platform-independent. |
||||||||||||||||||||||||||||||
public void TermInfoVerification(string termToTest, string expectedForeground, string expectedBackground, int colorValue, bool expectedScrollbackClearSupport) | ||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||
TermInfo.Database db = TermInfo.DatabaseFactory.ReadDatabase(termToTest); | ||||||||||||||||||||||||||||||
if (db != null) | ||||||||||||||||||||||||||||||
|
@@ -99,6 +99,7 @@ public void TermInfoVerification(string termToTest, string expectedForeground, s | |||||||||||||||||||||||||||||
Assert.Equal(expectedForeground, TermInfo.ParameterizedStrings.Evaluate(info.Foreground, colorValue)); | ||||||||||||||||||||||||||||||
Assert.Equal(expectedBackground, TermInfo.ParameterizedStrings.Evaluate(info.Background, colorValue)); | ||||||||||||||||||||||||||||||
Assert.InRange(info.MaxColors, 1, int.MaxValue); | ||||||||||||||||||||||||||||||
Assert.Equal(expectedScrollbackClearSupport, !string.IsNullOrEmpty(info.ClearScrollbackBuffer)); | ||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
|
@@ -108,7 +109,7 @@ public void EmuTermInfoDoesntBreakParser() | |||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||
// This file (available by default on OS X) is called out specifically since it contains a format where it has %i | ||||||||||||||||||||||||||||||
// but only one variable instead of two. Make sure we don't break in this case | ||||||||||||||||||||||||||||||
TermInfoVerification("emu", "\u001Br1;", "\u001Bs1;", 0); | ||||||||||||||||||||||||||||||
TermInfoVerification("emu", "\u001Br1;", "\u001Bs1;", 0, false); | ||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
[Fact] | ||||||||||||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
according to https://unix.stackexchange.com/a/375784 we should do E3 before clear:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The snippet of
clear
shared in the issue had E3 being issued after clear, but I'm not sure it matters either way. I'll switch the order.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume we manually validated the behavior on at least some system with the E3 and then clear?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@stephentoub I had tested before, but unfortunately just assumed the switched order was okay per the linked answer. I just ran my manual test again and having E3 issued before clear does not clear the scrollback buffer.
That means this order needs reversed back to the original: Clear, then E3. Would you mind making that change on your PR? Or do you want me to submit a new PR with the optimization mentioned below + this fix?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No problem; I switched the order back.