summaryrefslogtreecommitdiffstats
path: root/src/paint.rs
diff options
context:
space:
mode:
authorDan Davison <dandavison7@gmail.com>2020-07-08 15:15:46 -0400
committerDan Davison <dandavison7@gmail.com>2020-07-08 15:15:46 -0400
commit4bdabfd64b772dcb3cb146cae0d5f09897bed890 (patch)
tree033ff0183d0a5516347e151d98ef56449fd30293 /src/paint.rs
parent8552a1f5c6e4b4e6380fed8cc6ca962a62878a35 (diff)
Refactor: Painter::paint_zero_line
Diffstat (limited to 'src/paint.rs')
-rw-r--r--src/paint.rs32
1 files changed, 31 insertions, 1 deletions
diff --git a/src/paint.rs b/src/paint.rs
index 979b9c75..8f37cbc3 100644
--- a/src/paint.rs
+++ b/src/paint.rs
@@ -8,7 +8,7 @@ use syntect::highlighting::Style as SyntectStyle;
use syntect::parsing::{SyntaxReference, SyntaxSet};
use crate::config::{self, delta_unreachable};
-use crate::delta::State;
+use crate::delta::{self, State};
use crate::edits;
use crate::features::line_numbers;
use crate::paint::superimpose_style_sections::superimpose_style_sections;
@@ -137,6 +137,36 @@ impl<'a> Painter<'a> {
self.plus_lines.clear();
}
+ pub fn paint_zero_line(&mut self, line: &str) {
+ let prefix = if self.config.keep_plus_minus_markers && !line.is_empty() {
+ &line[..1]
+ } else {
+ ""
+ };
+ let lines = vec![delta::prepare(line, true, self.config)];
+ let syntax_style_sections = Painter::get_syntax_style_sections_for_lines(
+ &lines,
+ &State::HunkZero,
+ &mut self.highlighter,
+ &self.config,
+ );
+ let diff_style_sections = vec![(self.config.zero_style, lines[0].as_str())];
+
+ Painter::paint_lines(
+ syntax_style_sections,
+ vec![diff_style_sections],
+ &State::HunkZero,
+ &mut self.output_buffer,
+ self.config,
+ &mut Some(&mut self.line_numbers_data),
+ prefix,
+ self.config.zero_style,
+ self.config.zero_style,
+ None,
+ None,
+ );
+ }
+
/// Superimpose background styles and foreground syntax
/// highlighting styles, and write colored lines to output buffer.
pub fn paint_lines(