Parcourir la source

fix(theme): colors in old ms command prompt

Signed-off-by: Christopher Plewright <chris@createng.com>
Christopher Plewright il y a 1 an
Parent
commit
9859548ef7
1 fichiers modifiés avec 13 ajouts et 0 suppressions
  1. 13 0
      src/theme/mod.rs

+ 13 - 0
src/theme/mod.rs

@@ -73,6 +73,19 @@ impl Options {
             let exts = Box::new(NoFileStyle);
             return Theme { ui, exts };
         };
+
+        #[cfg(windows)]
+        if nu_ansi_term::enable_ansi_support().is_err() {
+            // Failed to enable ansi support, probably because legacy mode console.
+            // No need to alert the user unless they explicitly set color=always
+            if self.use_colours == UseColours::Always {
+                eprintln!("eza: Ignoring option color=always in legacy console.");
+            }
+            let ui = UiStyles::plain();
+            let exts = Box::new(NoFileStyle);
+            return Theme { ui, exts };
+        }
+
         match self.theme_config {
             Some(ref theme) => {
                 if let Some(mut ui) = theme.to_theme() {