diff options
author | Dan Davison <dandavison7@gmail.com> | 2019-07-21 22:30:50 -0400 |
---|---|---|
committer | Dan Davison <dandavison7@gmail.com> | 2019-07-21 22:30:50 -0400 |
commit | 3605b28509d3c9a4635e284109243e4ca3692718 (patch) | |
tree | 4ead47ac12a1836396de4e19d4159ccb2379eca5 /src/paint.rs | |
parent | 26bf4b60968375e8e26af5c4ef87759f37b29903 (diff) |
Painter struct constructor
Diffstat (limited to 'src/paint.rs')
-rw-r--r-- | src/paint.rs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/paint.rs b/src/paint.rs index 606dad25..131ac69d 100644 --- a/src/paint.rs +++ b/src/paint.rs @@ -4,6 +4,7 @@ use syntect::easy::HighlightLines; use syntect::highlighting::{Style, StyleModifier}; use syntect::parsing::SyntaxReference; +use crate::bat::assets::HighlightingAssets; use crate::config; use crate::edits; use crate::paint::superimpose_style_sections::superimpose_style_sections; @@ -20,6 +21,25 @@ pub struct Painter<'a> { } impl<'a> Painter<'a> { + pub fn new( + writer: &'a mut Write, + config: &'a config::Config, + assets: &HighlightingAssets, + ) -> Self { + Self { + minus_lines: Vec::new(), + plus_lines: Vec::new(), + output_buffer: String::new(), + writer: writer, + syntax: None, + highlighter: HighlightLines::new( + assets.syntax_set.find_syntax_by_extension("txt").unwrap(), + config.theme, + ), + config: config, + } + } + pub fn reset_highlighter(&mut self) { self.highlighter = HighlightLines::new(self.syntax.unwrap(), self.config.theme); } |