@@ -32,6 +32,9 @@ use crate::terminal::{as_terminal_escaped, to_ansi_color};
3232pub trait Printer {
3333 fn print_header(&mut self, handle: &mut dyn Write, file: InputFile) -> Result<()>;
3434 fn print_footer(&mut self, handle: &mut dyn Write) -> Result<()>;
35+
36+ fn print_snip(&mut self, handle: &mut dyn Write) -> Result<()>;
37+
3538 fn print_line(
3639 &mut self,
3740 out_of_range: bool,
@@ -58,6 +61,10 @@ impl Printer for SimplePrinter {
5861 Ok(())
5962 }
6063
64+ fn print_snip(&mut self, _handle: &mut Write) -> Result<()> {
65+ Ok(())
66+ }
67+
6168 fn print_line(
6269 &mut self,
6370 out_of_range: bool,
@@ -182,6 +189,24 @@ impl<'a> InteractivePrinter<'a> {
182189 Ok(())
183190 }
184191
192+ fn create_fake_panel(&self, text: &str) -> String {
193+ if self.panel_width == 0 {
194+ "".to_string()
195+ } else {
196+ let text_truncated: String = text.chars().take(self.panel_width - 1).collect();
197+ let text_filled: String = format!(
198+ "{}{}",
199+ text_truncated,
200+ " ".repeat(self.panel_width - 1 - text_truncated.len())
201+ );
202+ if self.config.output_components.grid() {
203+ format!("{} │ ", text_filled)
204+ } else {
205+ format!("{}", text_filled)
206+ }
207+ }
208+ }
209+
185210 fn preprocess(&self, text: &str, cursor: &mut usize) -> String {
186211 if self.config.tab_width > 0 {
187212 expand_tabs(text, self.config.tab_width, cursor)
@@ -271,6 +296,31 @@ impl<'a> Printer for InteractivePrinter<'a> {
271296 }
272297 }
273298
299+ fn print_snip(&mut self, handle: &mut Write) -> Result<()> {
300+ let panel = self.create_fake_panel(" ...");
301+ let panel_count = panel.chars().count();
302+
303+ let title = "8<";
304+ let title_count = title.chars().count();
305+
306+ let snip_left =
307+ "─ ".repeat((self.config.term_width - panel_count - (title_count / 2)) / 4);
308+ let snip_left_count = snip_left.chars().count(); // Can't use .len() with Unicode.
309+
310+ let snip_right = " ─"
311+ .repeat((self.config.term_width - panel_count - snip_left_count - title_count) / 2);
312+
313+ write!(
314+ handle,
315+ "{}\n",
316+ self.colors
317+ .grid
318+ .paint(format!("{}{}{}{}", panel, snip_left, title, snip_right))
319+ )?;
320+
321+ Ok(())
322+ }
323+
274324 fn print_line(
275325 &mut self,
276326 out_of_range: bool,