1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

builtin: make the C. WIN32 API declarations more precise, to catch errors earlier (#16090)

This commit is contained in:
Delyan Angelov
2022-10-17 20:23:33 +03:00
committed by GitHub
parent 126c4c5751
commit 71bff213ef
3 changed files with 26 additions and 27 deletions

View File

@@ -45,17 +45,17 @@ pub fn init(cfg Config) &Context {
panic('could not get stdin handle')
}
// save the current input mode, to be restored on exit
if C.GetConsoleMode(stdin_handle, &ui.stdin_at_startup) == 0 {
if !C.GetConsoleMode(stdin_handle, &ui.stdin_at_startup) {
panic('could not get stdin console mode')
}
// enable extended input flags (see https://stackoverflow.com/a/46802726)
// 0x80 == C.ENABLE_EXTENDED_FLAGS
if C.SetConsoleMode(stdin_handle, 0x80) == 0 {
if !C.SetConsoleMode(stdin_handle, 0x80) {
panic('could not set raw input mode')
}
// enable window and mouse input events.
if C.SetConsoleMode(stdin_handle, C.ENABLE_WINDOW_INPUT | C.ENABLE_MOUSE_INPUT) == 0 {
if !C.SetConsoleMode(stdin_handle, C.ENABLE_WINDOW_INPUT | C.ENABLE_MOUSE_INPUT) {
panic('could not set raw input mode')
}
// store the current title, so restore_terminal_state can get it back