From ec1f23cf34b953e505e716b149632363958df20b Mon Sep 17 00:00:00 2001 From: sharkdp Date: Fri, 2 Jun 2017 21:54:21 +0200 Subject: [PATCH] Extend LS_COLORS parser --- src/lscolors/mod.rs | 111 ++++++++++++++++++++++++++++++-------------- 1 file changed, 76 insertions(+), 35 deletions(-) diff --git a/src/lscolors/mod.rs b/src/lscolors/mod.rs index 34976a4..0f1a3b4 100644 --- a/src/lscolors/mod.rs +++ b/src/lscolors/mod.rs @@ -33,51 +33,65 @@ impl LsColors { } } - /// Parse a single ANSI style like `38;5;10`. + fn parse_decoration(code: &str) -> Option Style> { + match code { + "0" | "00" => Some(Colour::normal), + "1" | "01" => Some(Colour::bold), + "3" | "03" => Some(Colour::italic), + "4" | "04" => Some(Colour::underline), + _ => None + } + } + + /// Parse ANSI escape sequences like `38;5;10;1`. fn parse_style(code: &str) -> Option