mirror of
https://github.com/sharkdp/bat.git
synced 2025-09-12 00:02:28 +01:00
Rename InputFile => Input
This commit is contained in:
@@ -27,14 +27,14 @@ use crate::decorations::{Decoration, GridBorderDecoration, LineNumberDecoration}
|
||||
#[cfg(feature = "git")]
|
||||
use crate::diff::{get_git_diff, LineChanges};
|
||||
use crate::errors::*;
|
||||
use crate::inputfile::{InputFile, InputFileReader};
|
||||
use crate::input::{Input, InputReader};
|
||||
use crate::line_range::RangeCheckResult;
|
||||
use crate::preprocessor::{expand_tabs, replace_nonprintable};
|
||||
use crate::terminal::{as_terminal_escaped, to_ansi_color};
|
||||
use crate::wrap::WrappingMode;
|
||||
|
||||
pub trait Printer {
|
||||
fn print_header(&mut self, handle: &mut dyn Write, file: &InputFile) -> Result<()>;
|
||||
fn print_header(&mut self, handle: &mut dyn Write, file: &Input) -> Result<()>;
|
||||
fn print_footer(&mut self, handle: &mut dyn Write) -> Result<()>;
|
||||
|
||||
fn print_snip(&mut self, handle: &mut dyn Write) -> Result<()>;
|
||||
@@ -57,7 +57,7 @@ impl SimplePrinter {
|
||||
}
|
||||
|
||||
impl Printer for SimplePrinter {
|
||||
fn print_header(&mut self, _handle: &mut dyn Write, _file: &InputFile) -> Result<()> {
|
||||
fn print_header(&mut self, _handle: &mut dyn Write, _file: &Input) -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -101,8 +101,8 @@ impl<'a> InteractivePrinter<'a> {
|
||||
pub fn new(
|
||||
config: &'a Config,
|
||||
assets: &'a HighlightingAssets,
|
||||
file: &InputFile,
|
||||
reader: &mut InputFileReader,
|
||||
file: &Input,
|
||||
reader: &mut InputReader,
|
||||
) -> Self {
|
||||
let theme = assets.get_theme(&config.theme);
|
||||
|
||||
@@ -160,7 +160,7 @@ impl<'a> InteractivePrinter<'a> {
|
||||
#[cfg(feature = "git")]
|
||||
{
|
||||
if config.style_components.changes() {
|
||||
if let InputFile::Ordinary(ofile) = file {
|
||||
if let Input::Ordinary(ofile) = file {
|
||||
line_changes = get_git_diff(ofile.provided_path());
|
||||
}
|
||||
}
|
||||
@@ -230,23 +230,23 @@ impl<'a> InteractivePrinter<'a> {
|
||||
}
|
||||
|
||||
impl<'a> Printer for InteractivePrinter<'a> {
|
||||
fn print_header(&mut self, handle: &mut dyn Write, file: &InputFile) -> Result<()> {
|
||||
fn print_header(&mut self, handle: &mut dyn Write, file: &Input) -> Result<()> {
|
||||
if !self.config.style_components.header() {
|
||||
if Some(ContentType::BINARY) == self.content_type && !self.config.show_nonprintable {
|
||||
let input = match file {
|
||||
InputFile::Ordinary(ofile) => {
|
||||
Input::Ordinary(ofile) => {
|
||||
format!("file '{}'", &ofile.provided_path().to_string_lossy())
|
||||
}
|
||||
InputFile::StdIn(Some(name)) => format!(
|
||||
Input::StdIn(Some(name)) => format!(
|
||||
"STDIN (with name '{}')",
|
||||
name.to_string_lossy().into_owned()
|
||||
),
|
||||
InputFile::StdIn(None) => "STDIN".to_owned(),
|
||||
InputFile::ThemePreviewFile => "".to_owned(),
|
||||
InputFile::FromReader(_, Some(name)) => {
|
||||
Input::StdIn(None) => "STDIN".to_owned(),
|
||||
Input::ThemePreviewFile => "".to_owned(),
|
||||
Input::FromReader(_, Some(name)) => {
|
||||
format!("file '{}'", name.to_string_lossy())
|
||||
}
|
||||
InputFile::FromReader(_, None) => "READER".to_owned(),
|
||||
Input::FromReader(_, None) => "READER".to_owned(),
|
||||
};
|
||||
|
||||
writeln!(
|
||||
@@ -281,19 +281,17 @@ impl<'a> Printer for InteractivePrinter<'a> {
|
||||
}
|
||||
|
||||
let (prefix, name) = match file {
|
||||
InputFile::Ordinary(ofile) => (
|
||||
Input::Ordinary(ofile) => (
|
||||
"File: ",
|
||||
Cow::from(ofile.provided_path().to_string_lossy().to_owned()),
|
||||
),
|
||||
InputFile::StdIn(Some(name)) => {
|
||||
Input::StdIn(Some(name)) => ("File: ", Cow::from(name.to_string_lossy().to_owned())),
|
||||
Input::StdIn(None) => ("File: ", Cow::from("STDIN".to_owned())),
|
||||
Input::ThemePreviewFile => ("", Cow::from("")),
|
||||
Input::FromReader(_, Some(name)) => {
|
||||
("File: ", Cow::from(name.to_string_lossy().to_owned()))
|
||||
}
|
||||
InputFile::StdIn(None) => ("File: ", Cow::from("STDIN".to_owned())),
|
||||
InputFile::ThemePreviewFile => ("", Cow::from("")),
|
||||
InputFile::FromReader(_, Some(name)) => {
|
||||
("File: ", Cow::from(name.to_string_lossy().to_owned()))
|
||||
}
|
||||
InputFile::FromReader(_, None) => ("File: ", Cow::from("READER".to_owned())),
|
||||
Input::FromReader(_, None) => ("File: ", Cow::from("READER".to_owned())),
|
||||
};
|
||||
|
||||
let mode = match self.content_type {
|
||||
|
Reference in New Issue
Block a user