mirage / alcotest

A lightweight and colourful test framework
ISC License
456 stars 80 forks source link

Open Windows console handle to retreive dimensions #396

Closed MisterDA closed 1 year ago

MisterDA commented 1 year ago

If stdout is redirected on Windows, the dimensions of the terminal won't be correctly retrieved. Open the console instead, using the special filename CONOUT$, and ask the dimensions of this handle. Keep a fallback to stdout if the console can't be opened, because you can never be too cautious with this OS.

(this is akin to opening /dev/tty on Unix).

https://learn.microsoft.com/en-us/windows/console/console-handles