From 648bf5968bc1aa17f8f010553b2d8d315606e3c3 Mon Sep 17 00:00:00 2001 From: Mohammad AlSaleh Date: Tue, 21 Aug 2018 23:58:14 +0300 Subject: [PATCH] terminfo: Pretend to be xterm if Windows console supports ansi As mentioned in the comment, Windows people seem to be fine with this: https://github.com/Microsoft/WSL/issues/1446 I still think a precise terminfo file with the list of supported sequences documented in the below link would be ideal: https://docs.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences But I didn't find such a file. And I don't know how to generate one easily. Signed-off-by: Mohammad AlSaleh --- src/terminfo/mod.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/terminfo/mod.rs b/src/terminfo/mod.rs index d9d17bc4..d32e5627 100644 --- a/src/terminfo/mod.rs +++ b/src/terminfo/mod.rs @@ -18,6 +18,10 @@ use std::io; use std::io::BufReader; use std::path::Path; + +#[cfg(windows)] +use win; + use Attr; use color; use Terminal; @@ -67,6 +71,18 @@ impl TermInfo { } }) }); + + #[cfg(windows)] + let term_name = term_name.or_else(|| { + if win::conout_supports_ansi() { + // Microsoft people don't seem to mind, I think: + // https://github.com/Microsoft/WSL/issues/1446 + Some("xterm-256color") + } else { + None + } + }); + if let Some(term_name) = term_name { return TermInfo::from_name(term_name); } else {