diff --git a/assets/themes/base16.tmTheme b/assets/themes/base16.tmTheme index bb8e6a80..eff2eba4 100644 --- a/assets/themes/base16.tmTheme +++ b/assets/themes/base16.tmTheme @@ -3,8 +3,8 @@ author @@ -19,21 +19,21 @@ settings background - #0000000f + #00000000 caret - #0700000f + #07000000 foreground - #0700000f + #07000000 invisibles - #0800000f + #08000000 lineHighlight - #0800000f + #08000000 selection - #0b00000f + #0b000000 gutter - #0a00000f + #0a000000 gutterForeground - #0800000f + #08000000 @@ -44,7 +44,7 @@ settings foreground - #0700000f + #07000000 @@ -55,7 +55,7 @@ settings foreground - #0800000f + #08000000 @@ -66,7 +66,7 @@ settings foreground - #0700000f + #07000000 @@ -77,7 +77,7 @@ settings foreground - #0700000f + #07000000 @@ -88,7 +88,7 @@ settings foreground - #0700000f + #07000000 @@ -99,7 +99,7 @@ settings foreground - #0500000f + #05000000 @@ -110,7 +110,7 @@ settings foreground - #0700000f + #07000000 @@ -121,7 +121,7 @@ settings foreground - #0400000f + #04000000 @@ -132,7 +132,7 @@ settings foreground - #0e00000f + #0e000000 @@ -143,7 +143,7 @@ settings foreground - #0300000f + #03000000 @@ -154,7 +154,7 @@ settings foreground - #0f00000f + #0f000000 @@ -165,7 +165,7 @@ settings foreground - #0400000f + #04000000 @@ -176,7 +176,7 @@ settings foreground - #0500000f + #05000000 @@ -187,7 +187,7 @@ settings foreground - #0600000f + #06000000 @@ -198,7 +198,7 @@ settings foreground - #0200000f + #02000000 @@ -209,7 +209,7 @@ settings foreground - #0900000f + #09000000 @@ -220,7 +220,7 @@ settings foreground - #0900000f + #09000000 @@ -231,7 +231,7 @@ settings foreground - #0900000f + #09000000 @@ -242,7 +242,7 @@ settings foreground - #0900000f + #09000000 @@ -253,7 +253,7 @@ settings foreground - #0100000f + #01000000 @@ -264,7 +264,7 @@ settings foreground - #0900000f + #09000000 @@ -275,7 +275,7 @@ settings foreground - #0400000f + #04000000 @@ -286,7 +286,7 @@ settings foreground - #0500000f + #05000000 @@ -297,7 +297,7 @@ settings foreground - #0900000f + #09000000 @@ -310,7 +310,7 @@ fontStyle foreground - #0400000f + #04000000 @@ -321,7 +321,7 @@ settings foreground - #0900000f + #09000000 @@ -334,7 +334,7 @@ fontStyle bold foreground - #0300000f + #03000000 @@ -347,7 +347,7 @@ fontStyle italic foreground - #0500000f + #05000000 @@ -358,7 +358,7 @@ settings foreground - #0200000f + #02000000 @@ -369,7 +369,7 @@ settings foreground - #0100000f + #01000000 @@ -380,7 +380,7 @@ settings foreground - #0900000f + #09000000 @@ -391,7 +391,7 @@ settings foreground - #0900000f + #09000000 @@ -402,9 +402,9 @@ settings background - #0b00000f + #0b000000 foreground - #0700000f + #07000000 @@ -415,7 +415,7 @@ settings foreground - #0200000f + #02000000 @@ -426,7 +426,7 @@ settings foreground - #0100000f + #01000000 @@ -437,7 +437,7 @@ settings foreground - #0500000f + #05000000 @@ -448,7 +448,7 @@ settings foreground - #0600000f + #06000000 @@ -459,7 +459,7 @@ settings foreground - #0600000f + #06000000 @@ -470,7 +470,7 @@ settings foreground - #0600000f + #06000000 @@ -481,7 +481,7 @@ settings foreground - #0500000f + #05000000 @@ -492,9 +492,9 @@ settings background - #0100000f + #01000000 foreground - #0f00000f + #0f000000 @@ -505,9 +505,9 @@ settings background - #0900000f + #09000000 foreground - #0000000f + #00000000 @@ -518,9 +518,9 @@ settings background - #0e00000f + #0e000000 foreground - #0f00000f + #0f000000 @@ -531,9 +531,9 @@ settings background - #0800000f + #08000000 foreground - #0f00000f + #0f000000 diff --git a/src/terminal.rs b/src/terminal.rs index 77945d99..c8e2cd48 100644 --- a/src/terminal.rs +++ b/src/terminal.rs @@ -7,11 +7,13 @@ pub fn to_ansi_color(color: highlighting::Color, true_color: bool) -> ansi_term: if color.a == 0 { // Themes can specify one of the user-configurable terminal colors by // encoding them as #RRGGBBAA with AA set to 00 (transparent) and RR set - // to the color palette number. The built-in themes ansi-light, + // to the 8-bit color palette number. The built-in themes ansi-light, // ansi-dark, and base16 use this. - Fixed(color.r) - } else if color.a == 0x0f { match color.r { + // For the first 8 colors, use the Color enum to produce ANSI escape + // sequences using codes 30-37 (foreground) and 40-47 (background). + // For example, red foreground is \x1b[31m. This works on terminals + // without 256-color support. 0x00 => Color::Black, 0x01 => Color::Red, 0x02 => Color::Green, @@ -20,17 +22,15 @@ pub fn to_ansi_color(color: highlighting::Color, true_color: bool) -> ansi_term: 0x05 => Color::Purple, 0x06 => Color::Cyan, 0x07 => Color::White, - // TODO: the following should be high-intensity variants of - // these colors ("bright black", "bright red", ...). - 0x08 => Color::Black, - 0x09 => Color::Red, - 0x0a => Color::Green, - 0x0b => Color::Yellow, - 0x0c => Color::Blue, - 0x0d => Color::Purple, - 0x0e => Color::Cyan, - 0x0f => Color::White, - _ => unreachable!("The 0x0f color encoding does not allow for codes higher than 0x0f"), + // For all other colors, use Fixed to produce escape sequences using + // codes 38;5 (foreground) and 48;5 (background). For example, + // bright red foreground is \x1b[38;5;9m. This only works on + // terminals with 256-color support. + // + // TODO: When ansi_term adds support for bright variants using codes + // 90-97 (foreground) and 100-107 (background), we should use those + // for values 0x08 to 0x0f and only use Fixed for 0x10 to 0xff. + n => Fixed(n), } } else if true_color { RGB(color.r, color.g, color.b)