@@ -10,7 +10,7 @@ use console::AnsiCodeIterator;
1010use syntect::easy::HighlightLines;
1111use syntect::highlighting::Theme;
1212
13−use app::Config;
13+use app::{Config, InputFile};
1414use assets::HighlightingAssets;
1515use decorations::{Decoration, GridBorderDecoration, LineChangesDecoration, LineNumberDecoration};
1616use diff::get_git_diff;
@@ -20,7 +20,7 @@ use style::OutputWrap;
2020use terminal::{as_terminal_escaped, to_ansi_color};
2121
2222pub trait Printer {
23− fn print_header(&mut self, handle: &mut Write, filename: Option<&str>) -> Result<()>;
23+ fn print_header(&mut self, handle: &mut Write, file: InputFile) -> Result<()>;
2424 fn print_footer(&mut self, handle: &mut Write) -> Result<()>;
2525 fn print_line(
2626 &mut self,
@@ -40,7 +40,7 @@ impl SimplePrinter {
4040}
4141
4242impl Printer for SimplePrinter {
43− fn print_header(&mut self, _handle: &mut Write, _filename: Option<&str>) -> Result<()> {
43+ fn print_header(&mut self, _handle: &mut Write, _file: InputFile) -> Result<()> {
4444 Ok(())
4545 }
4646
@@ -73,7 +73,7 @@ pub struct InteractivePrinter<'a> {
7373}
7474
7575impl<'a> InteractivePrinter<'a> {
76− pub fn new(config: &'a Config, assets: &'a HighlightingAssets, filename: Option<&str>) -> Self {
76+ pub fn new(config: &'a Config, assets: &'a HighlightingAssets, file: InputFile) -> Self {
7777 let theme = assets.get_theme(&config.theme);
7878
7979 let colors = if config.colored_output {
@@ -113,10 +113,13 @@ impl<'a> InteractivePrinter<'a> {
113113 }
114114
115115 // Get the Git modifications
116− let line_changes = filename.and_then(|file| get_git_diff(file));
116+ let line_changes = match file {
117+ InputFile::Ordinary(filename) => get_git_diff(filename),
118+ _ => None,
119+ };
117120
118121 // Determine the type of syntax for highlighting
119− let syntax = assets.get_syntax(config.language, filename);
122+ let syntax = assets.get_syntax(config.language, file);
120123 let highlighter = HighlightLines::new(syntax, theme);
121124
122125 InteractivePrinter {
@@ -148,7 +151,7 @@ impl<'a> InteractivePrinter<'a> {
148151}
149152
150153impl<'a> Printer for InteractivePrinter<'a> {
151− fn print_header(&mut self, handle: &mut Write, filename: Option<&str>) -> Result<()> {
154+ fn print_header(&mut self, handle: &mut Write, file: InputFile) -> Result<()> {
152155 if !self.config.output_components.header() {
153156 return Ok(());
154157 }
@@ -168,12 +171,12 @@ impl<'a> Printer for InteractivePrinter<'a> {
168171 write!(handle, "{}", " ".repeat(self.panel_width))?;
169172 }
170173
171− writeln!(
172− handle,
173− "{}{}",
174− filename.map_or("", |_| "File: "),
175− self.colors.filename.paint(filename.unwrap_or("STDIN"))
176− )?;
174+ let (prefix, name) = match file {
175+ InputFile::Ordinary(filename) => ("File: ", filename),
176+ _ => ("", "STDIN"),
177+ };
178+
179+ writeln!(handle, "{}{}", prefix, self.colors.filename.paint(name))?;
177180
178181 if self.config.output_components.grid() {
179182 self.print_horizontal_line(handle, '┼')?;