windowsApiMoveToMarker
Function parameters
Parameters
- nl_n:usize
Type definitions in this namespace
Types
- Node
- Represents one unit of progress.
Initializes a global Progress instance.
Functions
- start
- Initializes a global Progress instance.
- lockStdErr
- Allows the caller to freely write to stderr until `unlockStdErr` is called.
- lockStderrWriter
- Allows the caller to freely write to the returned `Writer`,
= switch (builtin.os.tag) { .wasi, .freestanding, .windows => false, else => true, }
Values
- have_ipc
- = switch (builtin.os.tag) { .wasi, .freestanding, .windows => false, else => true, }
Source
Implementation
fn windowsApiMoveToMarker(nl_n: usize) error{Unexpected}!void {
const handle = global_progress.terminal.handle;
var console_info: windows.CONSOLE_SCREEN_BUFFER_INFO = undefined;
if (windows.kernel32.GetConsoleScreenBufferInfo(handle, &console_info) == 0) {
return error.Unexpected;
}
const cursor_pos = console_info.dwCursorPosition;
const expected_y = cursor_pos.Y - @as(i16, @intCast(nl_n));
var start_pos: windows.COORD = .{ .X = 0, .Y = expected_y };
while (start_pos.Y >= 0) {
var wchar: [1]u16 = undefined;
var num_console_chars_read: windows.DWORD = undefined;
if (windows.kernel32.ReadConsoleOutputCharacterW(handle, &wchar, wchar.len, start_pos, &num_console_chars_read) == 0) {
return error.Unexpected;
}
if (wchar[0] == windows_api_start_marker) break;
start_pos.Y -= 1;
} else {
// If we couldn't find the marker, then just assume that no lines wrapped
start_pos = .{ .X = 0, .Y = expected_y };
}
if (windows.kernel32.SetConsoleCursorPosition(handle, start_pos) == 0) {
return error.Unexpected;
}
}