File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change 9
9
*/
10
10
11
11
import TSCLibc
12
+ #if os(Windows)
13
+ import MSVCRT
14
+ #endif
12
15
13
16
/// A class to have better control on tty output streams: standard output and standard error.
14
17
/// Allows operations like cursor movement and colored text output on tty.
@@ -84,6 +87,18 @@ public final class TerminalController {
84
87
} else {
85
88
width = 80
86
89
}
90
+
91
+ #if os(Windows)
92
+ // Enable VT100 interpretation
93
+ let hOut = GetStdHandle ( STD_OUTPUT_HANDLE)
94
+ var dwMode : DWORD = 0
95
+
96
+ guard hOut != INVALID_HANDLE_VALUE else { return nil }
97
+ guard GetConsoleMode ( hOut, & dwMode) else { return nil }
98
+
99
+ dwMode |= DWORD ( ENABLE_VIRTUAL_TERMINAL_PROCESSING)
100
+ guard SetConsoleMode ( hOut, dwMode) else { return nil }
101
+ #endif
87
102
self . stream = stream
88
103
}
89
104
You can’t perform that action at this time.
0 commit comments