summaryrefslogtreecommitdiffstats
path: root/src/terminal.rs
diff options
context:
space:
mode:
authorMitchell Kember <mk12360@gmail.com>2019-04-27 12:48:56 -0400
committerDavid Peter <sharkdp@users.noreply.github.com>2019-05-08 07:35:43 -0500
commitbb6594e69188a457239654d5d7f7f08fbfef6629 (patch)
treecd9fc22de7e43004684417905c70a01ab9d839ce /src/terminal.rs
parente7c5561df736d42734c39712c52abc19ec9aa8d5 (diff)
Add 3 new themes: ansi-light, ansi-dark, base16
Also, interpret transparent colors (#RRGGBB00) as specifying a terminal color palette number with RR. The three new themes use this.
Diffstat (limited to 'src/terminal.rs')
-rw-r--r--src/terminal.rs8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/terminal.rs b/src/terminal.rs
index f01e9d60..b02e8618 100644
--- a/src/terminal.rs
+++ b/src/terminal.rs
@@ -6,7 +6,13 @@ use ansi_term::{self, Style};
use syntect::highlighting::{self, FontStyle};
pub fn to_ansi_color(color: highlighting::Color, true_color: bool) -> ansi_term::Colour {
- if true_color {
+ 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,
+ // ansi-dark, and base16 use this.
+ Fixed(color.r)
+ } else if true_color {
RGB(color.r, color.g, color.b)
} else {
Fixed(ansi_colours::ansi256_from_rgb((color.r, color.g, color.b)))