Skip to content
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

Add File.getOrEnableAnsiEscapeSupport and use it #20172

Merged
merged 2 commits into from
Jun 3, 2024

Commits on Jun 2, 2024

  1. lib/std/fs/File: enable VT seq support for Windows Console

    * Newer versions of Windows added VT seq support not only in Windows Terminal, but also in the old-fashioned Windows Console (standalone conhost.exe), though not enabled by default.
    * Try setting the newer console mode flags provides better experience for Windows Console users.
    
    Co-authored-by: Kexy Biscuit <kexybiscuit@biscuitt.in>
    2 people authored and squeek502 committed Jun 2, 2024
    Configuration menu
    Copy the full SHA
    17dc939 View commit details
    Browse the repository at this point in the history
  2. Add File.getOrEnableAnsiEscapeSupport and use it

    On Windows, the console mode flag `ENABLE_VIRTUAL_TERMINAL_PROCESSING` determines whether or not ANSI escape codes are parsed/acted on. On the newer Windows Terminal, this flag is set by default, but on the older Windows Console, it is not set by default, but *can* be enabled (since Windows 10 RS1 from June 2016).
    
    The new `File.getOrEnableAnsiEscapeSupport` function will get the current status of ANSI escape code support, but will also attempt to enable `ENABLE_VIRTUAL_TERMINAL_PROCESSING` on Windows if necessary which will provide better/more consistent results for things like `std.Progress` and `std.io.tty`.
    
    This type of change was not done previously due to a mistaken assumption (on my part) that the console mode would persist after the run of a program. However, it turns out that the console mode is always reset to the default for each program run in a console session.
    squeek502 committed Jun 2, 2024
    Configuration menu
    Copy the full SHA
    337f09e View commit details
    Browse the repository at this point in the history