@@ -7,6 +7,7 @@ use ansi_term::Style;
7use console::AnsiCodeIterator;
7use console::AnsiCodeIterator;
9use syntect::easy::HighlightLines;
9use syntect::easy::HighlightLines;
10+use syntect::highlighting::Color;
10use syntect::highlighting::Theme;
11use syntect::highlighting::Theme;
11use syntect::parsing::SyntaxSet;
12use syntect::parsing::SyntaxSet;
@@ -79,6 +80,7 @@ pub struct InteractivePrinter<'a> {
79 pub line_changes: Option<LineChanges>,
80 pub line_changes: Option<LineChanges>,
80 highlighter: Option<HighlightLines<'a>>,
81 highlighter: Option<HighlightLines<'a>>,
81 syntax_set: &'a SyntaxSet,
82 syntax_set: &'a SyntaxSet,
83+ background_color_highlight: Option<Color>,
84impl<'a> InteractivePrinter<'a> {
86impl<'a> InteractivePrinter<'a> {
@@ -90,6 +92,8 @@ impl<'a> InteractivePrinter<'a> {
90 ) -> Self {
92 ) -> Self {
91 let theme = assets.get_theme(&config.theme);
93 let theme = assets.get_theme(&config.theme);
95+ let background_color_highlight = theme.settings.line_highlight;
93 let colors = if config.colored_output {
97 let colors = if config.colored_output {
94 Colors::colored(theme, config.true_color)
98 Colors::colored(theme, config.true_color)
@@ -156,6 +160,7 @@ impl<'a> InteractivePrinter<'a> {
156 line_changes,
160 line_changes,
157 highlighter,
161 highlighter,
158 syntax_set: &assets.syntax_set,
162 syntax_set: &assets.syntax_set,
163+ background_color_highlight,
@@ -287,6 +292,17 @@ impl<'a> Printer for InteractivePrinter<'a> {
287 let mut cursor_total: usize = 0;
292 let mut cursor_total: usize = 0;
288 let mut panel_wrap: Option<String> = None;
293 let mut panel_wrap: Option<String> = None;
295+ // Line highlighting
296+ let highlight_this_line = self
300+ .any(|&l| l == line_number);
302+ let background_color = self
303+ .background_color_highlight
304+ .filter(|_| highlight_this_line);
290 // Line decorations.
306 // Line decorations.
291 if self.panel_width > 0 {
307 if self.panel_width > 0 {
292 let decorations = self
308 let decorations = self
@@ -313,9 +329,29 @@ impl<'a> Printer for InteractivePrinter<'a> {
316− as_terminal_escaped(style, text_trimmed, true_color, colored_output, italics,)
332+ as_terminal_escaped(
342+ if text.len() != text_trimmed.len() {
343+ if let Some(background_color) = background_color {
344+ let mut ansi_style = Style::default();
345+ ansi_style.background = Some(to_ansi_color(background_color, true_color));
346+ let width = if cursor_total <= cursor_max {
347+ cursor_max - cursor_total + 1
351+ write!(handle, "{}", ansi_style.paint(" ".repeat(width)))?;
318− write!(handle, "{}", &text[text_trimmed.len()..])?;
353+ write!(handle, "{}", &text[text_trimmed.len()..])?;
321 if line.bytes().next_back() != Some(b'\n') {
357 if line.bytes().next_back() != Some(b'\n') {
@@ -370,7 +406,8 @@ impl<'a> Printer for InteractivePrinter<'a> {
371 self.config.true_color,
407 self.config.true_color,
372 self.config.colored_output,
408 self.config.colored_output,
373− self.config.use_italic_text
409+ self.config.use_italic_text,
@@ -410,7 +447,8 @@ impl<'a> Printer for InteractivePrinter<'a> {
411 self.config.true_color,
448 self.config.true_color,
412 self.config.colored_output,
449 self.config.colored_output,
413− self.config.use_italic_text
450+ self.config.use_italic_text,
415 panel_wrap.clone().unwrap()
453 panel_wrap.clone().unwrap()
@@ -423,6 +461,17 @@ impl<'a> Printer for InteractivePrinter<'a> {
464+ if let Some(background_color) = background_color {
465+ let mut ansi_style = Style::default();
466+ ansi_style.background =
467+ Some(to_ansi_color(background_color, self.config.true_color));
472+ ansi_style.paint(" ".repeat(cursor_max - cursor))
426 write!(handle, "\n")?;
475 write!(handle, "\n")?;