summaryrefslogtreecommitdiffstats
path: root/src/paint.rs
diff options
context:
space:
mode:
authorDan Davison <dandavison7@gmail.com>2019-10-01 12:10:06 +0100
committerDan Davison <dandavison7@gmail.com>2019-10-01 19:09:10 +0100
commita6d16c315f14243f23c8a59f37ad26088fb71fb4 (patch)
tree434449033093044ff5abc9ff0189c840159e6901 /src/paint.rs
parente2b6da0dd429339ccfd6a67739fc1595afad41c7 (diff)
Support --theme=none
Fixes #14
Diffstat (limited to 'src/paint.rs')
-rw-r--r--src/paint.rs17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/paint.rs b/src/paint.rs
index bf873727..543eef95 100644
--- a/src/paint.rs
+++ b/src/paint.rs
@@ -25,24 +25,27 @@ impl<'a> Painter<'a> {
pub fn new(
writer: &'a mut Write,
config: &'a config::Config,
- assets: &HighlightingAssets,
+ assets: &'a HighlightingAssets,
) -> Self {
+ let dummy_highlighter = HighlightLines::new(
+ assets.syntax_set.find_syntax_by_extension("txt").unwrap(),
+ &assets.theme_set.themes[style::DEFAULT_LIGHT_THEME],
+ );
Self {
minus_lines: Vec::new(),
plus_lines: Vec::new(),
output_buffer: String::new(),
syntax: None,
- highlighter: HighlightLines::new(
- assets.syntax_set.find_syntax_by_extension("txt").unwrap(),
- config.theme,
- ),
+ highlighter: dummy_highlighter,
writer,
config,
}
}
pub fn reset_highlighter(&mut self) {
- self.highlighter = HighlightLines::new(self.syntax.unwrap(), self.config.theme);
+ if let Some(theme) = self.config.theme {
+ self.highlighter = HighlightLines::new(self.syntax.unwrap(), theme)
+ };
}
pub fn paint_buffered_lines(&mut self) {
@@ -165,7 +168,7 @@ impl<'a> Painter<'a> {
config: &config::Config,
should_syntax_highlight: bool,
) -> Vec<(Style, &'a str)> {
- if should_syntax_highlight {
+ if should_syntax_highlight && config.theme.is_some() {
highlighter.highlight(line, &config.syntax_set)
} else {
vec![(config.no_style, line)]