Skip to content

lib/std/os/windows/kernel32: add signature for SetConsoleMode #18715

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 9, 2024

Conversation

Garfield550
Copy link
Contributor

- From lib/libc/include/any-windows-any/wincon.h#L235
- See also https://learn.microsoft.com/en-us/windows/console/setconsolemode
- Also add DISABLE_NEWLINE_AUTO_RETURN constant which will be used by SetConsoleMode in lib/std/os/windows.
@squeek502
Copy link
Collaborator

Note that there were previous PRs adding SetConsoleMode that were closed:

I don't have strong feelings one way or the other, but I can see the merit for having this in the standard library even if Zig doesn't use it internally (#4426). From #15039 (comment):

[Trying to implement SetConsoleMode in terms of ntdll] is almost guaranteed to run into the same problems encountered in #14411 (specifically #14411 (comment) and #14411 (comment)). Running NtTrace on a program that calls SetConsoleMode shows that it also uses NtDeviceIoControlFile internally, meaning what it provides/expects will likely be implementation defined and Windows/React/Wine will all use different input structs for the same methods.

That is, AFAICT #1840 probably can't realistically apply to things that use NtDeviceIoControlFile internally, which both GetConsoleMode and SetConsoleMode do.

@der-teufel-programming
Copy link
Contributor

I think that since we have GetConsoleMode we should also have the complementary SetConsoleMode

@andrewrk andrewrk merged commit e69caaa into ziglang:master May 9, 2024
@Garfield550 Garfield550 deleted the windows-console-api branch May 10, 2024 15:56
nrdave added a commit to nrdave/zmatrix that referenced this pull request May 14, 2024
Zig 0.12.0 doesn't have the SetConsoleMode function implemented in the
standard library, but this PR - which was accepted recently
(ziglang/zig#18715) adds it. So, I just have to
wait (don't want to use Zig master)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants