@@ -7,6 +7,7 @@ use ansi_term::Style;
77use console::AnsiCodeIterator;
88
99use syntect::easy::HighlightLines;
10+use syntect::highlighting::Color;
1011use syntect::highlighting::Theme;
1112use syntect::parsing::SyntaxSet;
1213
@@ -79,6 +80,7 @@ pub struct InteractivePrinter<'a> {
7980 pub line_changes: Option<LineChanges>,
8081 highlighter: Option<HighlightLines<'a>>,
8182 syntax_set: &'a SyntaxSet,
83+ background_color_highlight: Option<Color>,
8284}
8385
8486impl<'a> InteractivePrinter<'a> {
@@ -90,6 +92,8 @@ impl<'a> InteractivePrinter<'a> {
9092 ) -> Self {
9193 let theme = assets.get_theme(&config.theme);
9294
95+ let background_color_highlight = theme.settings.line_highlight;
96+
9397 let colors = if config.colored_output {
9498 Colors::colored(theme, config.true_color)
9599 } else {
@@ -156,6 +160,7 @@ impl<'a> InteractivePrinter<'a> {
156160 line_changes,
157161 highlighter,
158162 syntax_set: &assets.syntax_set,
163+ background_color_highlight,
159164 }
160165 }
161166
@@ -287,6 +292,17 @@ impl<'a> Printer for InteractivePrinter<'a> {
287292 let mut cursor_total: usize = 0;
288293 let mut panel_wrap: Option<String> = None;
289294
295+ // Line highlighting
296+ let highlight_this_line = self
297+ .config
298+ .highlight_lines
299+ .iter()
300+ .any(|&l| l == line_number);
301+
302+ let background_color = self
303+ .background_color_highlight
304+ .filter(|_| highlight_this_line);
305+
290306 // Line decorations.
291307 if self.panel_width > 0 {
292308 let decorations = self
@@ -313,9 +329,29 @@ impl<'a> Printer for InteractivePrinter<'a> {
313329 write!(
314330 handle,
315331 "{}",
316− as_terminal_escaped(style, text_trimmed, true_color, colored_output, italics,)
332+ as_terminal_escaped(
333+ style,
334+ text_trimmed,
335+ true_color,
336+ colored_output,
337+ italics,
338+ background_color
339+ )
317340 )?;
318− write!(handle, "{}", &text[text_trimmed.len()..])?;
341+
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
348+ } else {
349+ 0
350+ };
351+ write!(handle, "{}", ansi_style.paint(" ".repeat(width)))?;
352+ }
353+ write!(handle, "{}", &text[text_trimmed.len()..])?;
354+ }
319355 }
320356
321357 if line.bytes().next_back() != Some(b'\n') {
@@ -370,7 +406,8 @@ impl<'a> Printer for InteractivePrinter<'a> {
370406 ),
371407 self.config.true_color,
372408 self.config.colored_output,
373− self.config.use_italic_text
409+ self.config.use_italic_text,
410+ background_color
374411 )
375412 )?;
376413 break;
@@ -410,7 +447,8 @@ impl<'a> Printer for InteractivePrinter<'a> {
410447 ),
411448 self.config.true_color,
412449 self.config.colored_output,
413− self.config.use_italic_text
450+ self.config.use_italic_text,
451+ background_color
414452 ),
415453 panel_wrap.clone().unwrap()
416454 )?;
@@ -423,6 +461,17 @@ impl<'a> Printer for InteractivePrinter<'a> {
423461 }
424462 }
425463
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));
468+
469+ write!(
470+ handle,
471+ "{}",
472+ ansi_style.paint(" ".repeat(cursor_max - cursor))
473+ )?;
474+ }
426475 write!(handle, "\n")?;
427476 }
428477