# Add \`File.getOrEnableAnsiEscapeSupport\` and use it · gitcafe/zig

[View on GitCafe](https://git.cafe/gitcafe/zig/commit/337f09e93297f8097e7b5093ea138b60f2c52e5f)

Repository: [gitcafe/zig](https://git.cafe/gitcafe/zig)

Visibility: public

Requested revision: 337f09e93297f8097e7b5093ea138b60f2c52e5f

Requested commit: 337f09e93297f8097e7b5093ea138b60f2c52e5f

Commit: 337f09e93297f8097e7b5093ea138b60f2c52e5f

Tree: 08dabdb8d902c88de29ab40ab5d3074934e84e8d

Author: Ryan Liptak

Committer: Ryan Liptak

## Message

```
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.

```

## Parents

- [17dc93934689235ac16b3354c3eb932420a88e85](https://git.cafe/gitcafe/zig/commit/17dc93934689235ac16b3354c3eb932420a88e85?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zig/tree/337f09e93297f8097e7b5093ea138b60f2c52e5f?format=markdown)
