@@ -2,19 +2,15 @@ use std::ffi::OsStr;
22use std::io::Read;
33
44use crate::{
5− config::{
6− Config, HighlightedLineRanges, LineRanges, StyleComponents, SyntaxMapping, WrappingMode,
7− },
8− errors::Result,
9− input::{Input, InputKind, OpenedInput},
10− Controller, HighlightingAssets,
5+ assets::HighlightingAssets, config::Config, controller::Controller, errors::Result,
6+ input::Input, HighlightedLineRanges, LineRanges, StyleComponents, SyntaxMapping, WrappingMode,
117};
128
139#[cfg(feature = "paging")]
1410use crate::config::PagingMode;
1511
1612pub struct PrettyPrinter<'a> {
17− inputs: Vec<Input>,
13+ inputs: Vec<Input<'a>>,
1814 config: Config<'a>,
1915 assets: HighlightingAssets,
2016}
@@ -35,8 +31,7 @@ impl<'a> PrettyPrinter<'a> {
3531
3632 /// Add a file which should be pretty-printed
3733 pub fn input_file(&mut self, path: &OsStr) -> &mut Self {
38− // self.inputs
39− // .push(Input::Ordinary(OrdinaryFile::from_path(path)));
34+ self.inputs.push(Input::ordinary_file(path));
4035 self
4136 }
4237
@@ -47,21 +42,25 @@ impl<'a> PrettyPrinter<'a> {
4742 P: AsRef<OsStr>,
4843 {
4944 for path in paths {
50− // self.inputs
51− // .push(Input::Ordinary(OrdinaryFile::from_path(path.as_ref())));
45+ self.inputs.push(Input::ordinary_file(path.as_ref()));
5246 }
5347 self
5448 }
5549
5650 /// Add STDIN as an input
5751 pub fn input_stdin(&mut self) -> &mut Self {
58− // self.inputs.push(Input::StdIn(None));
52+ self.inputs.push(Input::stdin());
5953 self
6054 }
6155
56+ /// Use a string as an input
57+ pub fn input_from_bytes(&mut self, content: &'a [u8]) -> &mut Self {
58+ self.input_from_reader(content)
59+ }
60+
6261 /// Add a custom reader as an input
63− pub fn input_reader(&mut self, reader: impl Read) -> &mut Self {
64− //self.inputs.push(Input::FromReader(Box::new(reader), None));
62+ pub fn input_from_reader<R: Read + 'a>(&mut self, reader: R) -> &mut Self {
63+ self.inputs.push(Input::from_reader(Box::new(reader)));
6564 self
6665 }
6766