This repository was archived by the owner on Aug 1, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,14 @@ const uri = @import("uri");
5
5
6
6
const assert = std .debug .assert ;
7
7
8
+ const is_windows = builtin .os .tag == .windows ;
9
+
10
+ const w32 = if (is_windows ) struct {
11
+ extern "kernel32" fn SetConsoleMode (console : ? * anyopaque , mode : std.os.windows.DWORD ) callconv (std .os .windows .WINAPI ) u32 ;
12
+ } else undefined ;
13
+
14
+ var w32_mode : if (is_windows ) std .os .windows .DWORD else void = undefined ;
15
+
8
16
pub const Size = struct {
9
17
rows : usize ,
10
18
cols : usize ,
@@ -131,6 +139,12 @@ pub fn init(location: *Self, allocator: std.mem.Allocator) !void {
131
139
132
140
size .rows = @intCast (usize , csbi .srWindow .Bottom - csbi .srWindow .Top + 1 );
133
141
size .cols = @intCast (usize , csbi .srWindow .Right - csbi .srWindow .Left + 1 );
142
+
143
+ const h = c .GetStdHandle (c .STD_OUTPUT_HANDLE );
144
+ if (c .GetConsoleMode (h , & w32_mode ) != 0 ) {
145
+ w32_mode |= c .ENABLE_VIRTUAL_TERMINAL_PROCESSING ;
146
+ w32_mode = w32 .SetConsoleMode (h , w32_mode );
147
+ }
134
148
},
135
149
else = > {
136
150
const c = @cImport ({
@@ -208,6 +222,14 @@ pub fn deinit(self: *Self) void {
208
222
ansi .arena .deinit ();
209
223
},
210
224
}
225
+
226
+ if (builtin .os .tag == .windows ) {
227
+ const c = @cImport ({
228
+ @cInclude ("windows.h" );
229
+ });
230
+ const h = c .GetStdHandle (c .STD_OUTPUT_HANDLE );
231
+ _ = w32 .SetConsoleMode (h , w32_mode );
232
+ }
211
233
}
212
234
213
235
pub fn log (
You can’t perform that action at this time.
0 commit comments