Skip to content

Commit 3de5f6e

Browse files
committed
Simplifies the CLI color code
1 parent b8015ef commit 3de5f6e

File tree

1 file changed

+9
-23
lines changed

1 file changed

+9
-23
lines changed

src/executeCommandLine/executeCommandLine.ts

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -100,42 +100,28 @@ namespace ts {
100100
};
101101
}
102102

103-
// There are ~3 types of terminal color support: 16 colors, 256 and 16m colors
104-
// If there is richer color support, e.g. 256+ we can use extended ANSI codes which are not just generic 'blue'
105-
// but a 'lighter blue' which is closer to the blue in the TS logo.
106-
const supportsRicherColors = sys.getEnvironmentVariable("COLORTERM") === "truecolor" || sys.getEnvironmentVariable("TERM") === "xterm-256color";
107-
108103
function bold(str: string) {
109104
return `\x1b[1m${str}\x1b[22m`;
110105
}
106+
111107
function blue(str: string) {
112-
if (supportsRicherColors) {
113-
// https://jonasjacek.github.io/colors/ - SteelBlue3 ANSI 68
114-
return `\x1B[38;5;68m${str}\x1B[39;49m`;
115-
}
116-
else {
117-
// This should probably only hit both Console and Powershell on Windows, as anything more modern supports more colors.
118-
// Those two colorthemes treat 'blue' as navy blue against a black background.
119-
// https://en.wikipedia.org/wiki/ANSI_escape_code#3-bit_and_4-bit
120-
const useThemeBlue = sys.getEnvironmentVariable("OS") && stringContains(sys.getEnvironmentVariable("OS").toLowerCase(), "windows");
121-
if (useThemeBlue) {
122-
return `\x1b[44m${str}\x1b[39m`;
123-
}
124-
else {
125-
return `\x1b[94m${str}\x1b[39m`;
126-
}
127-
}
108+
return `\x1b[94m${str}\x1b[39m`;
128109
}
110+
111+
// There are ~3 types of terminal color support: 16 colors, 256 and 16m colors
112+
// If there is richer color support, e.g. 256+ we can use extended ANSI codes which are not just generic 'blue'
113+
// but a 'lighter blue' which is closer to the blue in the TS logo.
114+
const supportsRicherColors = sys.getEnvironmentVariable("COLORTERM") === "truecolor" || sys.getEnvironmentVariable("TERM") === "xterm-256color";
129115
function blueBackground(str: string) {
130116
if (supportsRicherColors) {
131117
return `\x1B[48;5;68m${str}\x1B[39;49m`;
132118
}
133119
else {
134-
return `\x1b[44m${str}\x1b[49m`;
120+
return `\x1b[44m${str}\x1B[39;49m`;
135121
}
136122
}
137123
function white(str: string) {
138-
return `\x1b[37m${str}\x1b[39m`;
124+
return `\x1b[97m${str}\x1b[39m`;
139125
}
140126
return {
141127
bold,

0 commit comments

Comments
 (0)