Merge pull request #4058 from zloylos:support-kitty-term
PiperOrigin-RevId: 488463135 Change-Id: I4180d766dabbe438210904e743e6e963122540f5
This commit is contained in:
commit
0e6aac2571
@ -3252,15 +3252,16 @@ bool ShouldUseColor(bool stdout_is_tty) {
|
|||||||
#else
|
#else
|
||||||
// On non-Windows platforms, we rely on the TERM variable.
|
// On non-Windows platforms, we rely on the TERM variable.
|
||||||
const char* const term = posix::GetEnv("TERM");
|
const char* const term = posix::GetEnv("TERM");
|
||||||
const bool term_supports_color = term != nullptr && (
|
const bool term_supports_color =
|
||||||
String::CStringEquals(term, "xterm") ||
|
term != nullptr && (String::CStringEquals(term, "xterm") ||
|
||||||
String::CStringEquals(term, "xterm-color") ||
|
String::CStringEquals(term, "xterm-color") ||
|
||||||
String::CStringEquals(term, "screen") ||
|
String::CStringEquals(term, "xterm-kitty") ||
|
||||||
String::CStringEquals(term, "tmux") ||
|
String::CStringEquals(term, "screen") ||
|
||||||
String::CStringEquals(term, "rxvt-unicode") ||
|
String::CStringEquals(term, "tmux") ||
|
||||||
String::CStringEquals(term, "linux") ||
|
String::CStringEquals(term, "rxvt-unicode") ||
|
||||||
String::CStringEquals(term, "cygwin") ||
|
String::CStringEquals(term, "linux") ||
|
||||||
String::EndsWithCaseInsensitive(term, "-256color"));
|
String::CStringEquals(term, "cygwin") ||
|
||||||
|
String::EndsWithCaseInsensitive(term, "-256color"));
|
||||||
return stdout_is_tty && term_supports_color;
|
return stdout_is_tty && term_supports_color;
|
||||||
#endif // GTEST_OS_WINDOWS
|
#endif // GTEST_OS_WINDOWS
|
||||||
}
|
}
|
||||||
|
@ -78,6 +78,7 @@ class GTestColorTest(gtest_test_utils.TestCase):
|
|||||||
self.assert_(UsesColor('cygwin', None, None))
|
self.assert_(UsesColor('cygwin', None, None))
|
||||||
self.assert_(UsesColor('xterm', None, None))
|
self.assert_(UsesColor('xterm', None, None))
|
||||||
self.assert_(UsesColor('xterm-color', None, None))
|
self.assert_(UsesColor('xterm-color', None, None))
|
||||||
|
self.assert_(UsesColor('xterm-kitty', None, None))
|
||||||
self.assert_(UsesColor('xterm-256color', None, None))
|
self.assert_(UsesColor('xterm-256color', None, None))
|
||||||
|
|
||||||
def testFlagOnly(self):
|
def testFlagOnly(self):
|
||||||
|
@ -6636,6 +6636,9 @@ TEST(ColoredOutputTest, UsesColorsWhenTermSupportsColors) {
|
|||||||
SetEnv("TERM", "xterm-color"); // TERM supports colors.
|
SetEnv("TERM", "xterm-color"); // TERM supports colors.
|
||||||
EXPECT_TRUE(ShouldUseColor(true)); // Stdout is a TTY.
|
EXPECT_TRUE(ShouldUseColor(true)); // Stdout is a TTY.
|
||||||
|
|
||||||
|
SetEnv("TERM", "xterm-kitty"); // TERM supports colors.
|
||||||
|
EXPECT_TRUE(ShouldUseColor(true)); // Stdout is a TTY.
|
||||||
|
|
||||||
SetEnv("TERM", "xterm-256color"); // TERM supports colors.
|
SetEnv("TERM", "xterm-256color"); // TERM supports colors.
|
||||||
EXPECT_TRUE(ShouldUseColor(true)); // Stdout is a TTY.
|
EXPECT_TRUE(ShouldUseColor(true)); // Stdout is a TTY.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user