1extern crate ansi_colours;
3use ansi_term::Colour::{Fixed, RGB};
4use ansi_term::{self, Style};
6use syntect::highlighting::{self, FontStyle};
8pub fn to_ansi_color(color: highlighting::Color, true_color: bool) -> ansi_term::Colour {
10 // Themes can specify one of the user-configurable terminal colors by
11 // encoding them as #RRGGBBAA with AA set to 00 (transparent) and RR set
12 // to the color palette number. The built-in themes ansi-light,
13 // ansi-dark, and base16 use this.
15 } else if true_color {
16 RGB(color.r, color.g, color.b)
18 Fixed(ansi_colours::ansi256_from_rgb((color.r, color.g, color.b)))
22pub fn as_terminal_escaped(
23 style: highlighting::Style,
28 background_color: Option<highlighting::Color>,
30 let mut style = if !colored {
33 let color = to_ansi_color(style.foreground, true_color);
35 if style.font_style.contains(FontStyle::BOLD) {
37 } else if style.font_style.contains(FontStyle::UNDERLINE) {
39 } else if italics && style.font_style.contains(FontStyle::ITALIC) {
46 style.background = background_color.map(|c| to_ansi_color(c, true_color));
47 style.paint(text).to_string()
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list