"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/terminal.rs" between
bat-0.15.0.tar.gz and bat-0.15.1.tar.gz

About: bat is a cat(1) clone "with wings" (syntax highlighting and Git integration).

terminal.rs  (bat-0.15.0):terminal.rs  (bat-0.15.1)
use ansi_term::Color::{self, Fixed, RGB}; use ansi_term::Color::{self, Fixed, RGB};
use ansi_term::{self, Style}; use ansi_term::{self, Style};
use syntect::highlighting::{self, FontStyle}; use syntect::highlighting::{self, FontStyle};
pub fn to_ansi_color(color: highlighting::Color, true_color: bool) -> ansi_term: :Color { pub fn to_ansi_color(color: highlighting::Color, true_color: bool) -> ansi_term: :Color {
if color.a == 0 { if color.a == 0 {
// Themes can specify one of the user-configurable terminal colors by // Themes can specify one of the user-configurable terminal colors by
// encoding them as #RRGGBBAA with AA set to 00 (transparent) and RR set // 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. // ansi-dark, and base16 use this.
Fixed(color.r)
} else if color.a == 0x0f {
match color.r { 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, 0x00 => Color::Black,
0x01 => Color::Red, 0x01 => Color::Red,
0x02 => Color::Green, 0x02 => Color::Green,
0x03 => Color::Yellow, 0x03 => Color::Yellow,
0x04 => Color::Blue, 0x04 => Color::Blue,
0x05 => Color::Purple, 0x05 => Color::Purple,
0x06 => Color::Cyan, 0x06 => Color::Cyan,
0x07 => Color::White, 0x07 => Color::White,
// TODO: the following should be high-intensity variants of // For all other colors, use Fixed to produce escape sequences using
// these colors ("bright black", "bright red", ...). // codes 38;5 (foreground) and 48;5 (background). For example,
0x08 => Color::Black, // bright red foreground is \x1b[38;5;9m. This only works on
0x09 => Color::Red, // terminals with 256-color support.
0x0a => Color::Green, //
0x0b => Color::Yellow, // TODO: When ansi_term adds support for bright variants using codes
0x0c => Color::Blue, // 90-97 (foreground) and 100-107 (background), we should use those
0x0d => Color::Purple, // for values 0x08 to 0x0f and only use Fixed for 0x10 to 0xff.
0x0e => Color::Cyan, n => Fixed(n),
0x0f => Color::White,
_ => unreachable!("The 0x0f color encoding does not allow for codes
higher than 0x0f"),
} }
} else if true_color { } else if true_color {
RGB(color.r, color.g, color.b) RGB(color.r, color.g, color.b)
} else { } else {
Fixed(ansi_colours::ansi256_from_rgb((color.r, color.g, color.b))) Fixed(ansi_colours::ansi256_from_rgb((color.r, color.g, color.b)))
} }
} }
pub fn as_terminal_escaped( pub fn as_terminal_escaped(
style: highlighting::Style, style: highlighting::Style,
 End of changes. 4 change blocks. 
15 lines changed or deleted 14 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)