Skip to content

is_windows_10 documentation somewhat incorrect #41

@DHowett

Description

@DHowett

Hi! Windows Console Subsystem maintainer here :)

is_windows_10 is documented implying that you cannot use ENABLE_VIRTUAL_TERMINAL_PROCESSING without first checking that you're on Windows 10, and goes to great lengths to explain how versioning is handled.

None of that is strictly necessary! If you call SetConsoleMode(..., ENABLE_VIRTUAL_TERMINAL_PROCESSING) and the console host does not support it, regardless of the version of Windows, it will give you a status code and ignore you.

I know we haven't made this very easily discoverable. Sorry :/.

That means you can collapse all your version checking logic into "does the console host support VT processing?" In so doing, you get is_microsoft_terminal for free (since it does support VT processing) and the handful of custom console hosts that exist for Windows 8 which also support VT processing. You can collapse every micosoft_terminal and Windows case to "get mode, check VT_PROCESSING, try to set it, bail out1 if it's rejected."

To put a finer point on it... here's a console on Windows 8.1 displaying Sixels, a nominally "Windows 11+" feature which requires VIRTUAL_TERMINAL_PROCESSING (side by side with one that doesn't support that mode!)

Image

Footnotes

  1. bail out and do it the legacy way, FWIW.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions