inquirer-rs icon indicating copy to clipboard operation
inquirer-rs copied to clipboard

Windows support

Open retep998 opened this issue 9 years ago • 4 comments

Please support the Windows console. Please think about how you're going to support it before you commit to certain API design choices. In order to provide formatting in the Windows console, you have to control how stuff is written to the console. println! will not work. No ansi escape codes (unless you're on Windows 10 with a certain console mode enabled, which offers some escape codes).

retep998 avatar Jul 15 '16 16:07 retep998

That's a very good point @retep998. Unfortunately, I'm not very familiar with formatting in the Windows console. Do you know of any good resources?

Munksgaard avatar Jul 15 '16 16:07 Munksgaard

Well, I am actually working on an API for interacting with the console in wio. You can see an example of it here.

Basically the console is just a 2D grid buffer of u16 characters and each cell has a background and a foreground color (you can only choose from a palette of 16 colors although that palette can be any 24-bit RGB colors you want), no other formatting. Note that you can create multiple such buffers with different sizes and palettes and swap between them easily, but only one buffer is active (visible) at a given time. All output is done by interacting with such a buffer through API calls.

retep998 avatar Jul 15 '16 17:07 retep998

@retep998, do you think it'd be possible to implement Windows support in termion? I'm not sure what features it currently supports (and which of these are available on Windows).

killercup avatar Jul 17 '16 14:07 killercup

@killercup Look at the code from the example.

    let stdout = io::stdout();
    let mut stdout = stdout.lock();

    stdout.color(color::Red).unwrap();

In order to do colors in the windows console you need the stdout handle. Unfortunately libstd does not allow access to the underlying handle. As a result, this API as it stands right now is not compatible with the windows console. If you get the handle via GetStdHandle, then it isn't compatible with libtest stdout redirection, and also would require flushing rust's stdout before each windows console api function.

retep998 avatar Jul 17 '16 18:07 retep998