summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Hebden <peterhebden6@gmail.com>2023-07-09 01:20:58 +0100
committerDavid Peter <david.peter@bosch.com>2023-09-01 20:52:55 +0200
commitd929becefcdc528706ab0d6d4407e64999c6ad45 (patch)
tree33d485f27c3010d8995fba6af8d040b9a198b633
parent103a2f0d9b4dd8bb9202de49bc8d7bd641cda149 (diff)
Fix signatures
-rw-r--r--src/bin/bat/main.rs4
-rw-r--r--src/controller.rs14
-rw-r--r--src/printer.rs34
3 files changed, 28 insertions, 24 deletions
diff --git a/src/bin/bat/main.rs b/src/bin/bat/main.rs
index 385140e6..43e9d288 100644
--- a/src/bin/bat/main.rs
+++ b/src/bin/bat/main.rs
@@ -206,7 +206,7 @@ pub fn list_themes(cfg: &Config, config_dir: &Path, cache_dir: &Path) -> Result<
)?;
config.theme = theme.to_string();
Controller::new(&config, &assets)
- .run(vec![theme_preview_file()])
+ .run(vec![theme_preview_file()], None)
.ok();
writeln!(stdout)?;
}
@@ -230,7 +230,7 @@ pub fn list_themes(cfg: &Config, config_dir: &Path, cache_dir: &Path) -> Result<
fn run_controller(inputs: Vec<Input>, config: &Config, cache_dir: &Path) -> Result<bool> {
let assets = assets_from_cache_or_binary(config.use_custom_assets, cache_dir)?;
let controller = Controller::new(config, &assets);
- controller.run(inputs)
+ controller.run(inputs, None)
}
#[cfg(feature = "bugreport")]
diff --git a/src/controller.rs b/src/controller.rs
index 51581677..259a8a6f 100644
--- a/src/controller.rs
+++ b/src/controller.rs
@@ -80,7 +80,7 @@ impl<'b> Controller<'b> {
};
//let writer = output_type.handle()?;
- let writer = output_buffer.map_or_else(
+ let mut writer = output_buffer.map_or_else(
|| OutputHandle::IoWrite(output_type.handle().unwrap()),
|buf| OutputHandle::FmtWrite(buf),
);
@@ -91,15 +91,15 @@ impl<'b> Controller<'b> {
let identifier = stdout_identifier.as_ref();
let is_first = index == 0;
let result = if input.is_stdin() {
- self.print_input(input, writer, io::stdin().lock(), identifier, is_first)
+ self.print_input(input, &mut writer, io::stdin().lock(), identifier, is_first)
} else {
// Use dummy stdin since stdin is actually not used (#1902)
- self.print_input(input, writer, io::empty(), identifier, is_first)
+ self.print_input(input, &mut writer, io::empty(), identifier, is_first)
};
if let Err(error) = result {
match writer {
OutputHandle::FmtWrite(writer) => todo!(),
- OutputHandle::IoWrite(writer) => {
+ OutputHandle::IoWrite(ref mut writer) => {
if attached_to_pager {
handle_error(&error, writer);
} else {
@@ -117,7 +117,7 @@ impl<'b> Controller<'b> {
fn print_input<R: BufRead>(
&self,
input: Input,
- writer: OutputHandle,
+ writer: &mut OutputHandle,
stdin: R,
stdout_identifier: Option<&Identifier>,
is_first: bool,
@@ -178,7 +178,7 @@ impl<'b> Controller<'b> {
fn print_file(
&self,
printer: &mut dyn Printer,
- writer: OutputHandle,
+ writer: &mut OutputHandle,
input: &mut OpenedInput,
add_header_padding: bool,
#[cfg(feature = "git")] line_changes: &Option<LineChanges>,
@@ -216,7 +216,7 @@ impl<'b> Controller<'b> {
fn print_file_ranges(
&self,
printer: &mut dyn Printer,
- writer: OutputHandle,
+ writer: &mut OutputHandle,
reader: &mut InputReader,
line_ranges: &LineRanges,
) -> Result<()> {
diff --git a/src/printer.rs b/src/printer.rs
index 328b993c..deeebe49 100644
--- a/src/printer.rs
+++ b/src/printer.rs
@@ -71,18 +71,18 @@ macro_rules! writeln_handle {
pub(crate) trait Printer {
fn print_header(
&mut self,
- handle: OutputHandle,
+ handle: &mut OutputHandle,
input: &OpenedInput,
add_header_padding: bool,
) -> Result<()>;
- fn print_footer(&mut self, handle: OutputHandle, input: &OpenedInput) -> Result<()>;
+ fn print_footer(&mut self, handle: &mut OutputHandle, input: &OpenedInput) -> Result<()>;
- fn print_snip(&mut self, handle: OutputHandle) -> Result<()>;
+ fn print_snip(&mut self, handle: &mut OutputHandle) -> Result<()>;
fn print_line(
&mut self,
out_of_range: bool,
- handle: OutputHandle,
+ handle: &mut OutputHandle,
line_number: usize,
line_buffer: &[u8],
) -> Result<()>;
@@ -101,25 +101,25 @@ impl<'a> SimplePrinter<'a> {
impl<'a> Printer for SimplePrinter<'a> {
fn print_header(
&mut self,
- _handle: OutputHandle,
+ _handle: &mut OutputHandle,
_input: &OpenedInput,
_add_header_padding: bool,
) -> Result<()> {
Ok(())
}
- fn print_footer(&mut self, _handle: OutputHandle, _input: &OpenedInput) -> Result<()> {
+ fn print_footer(&mut self, _handle: &mut OutputHandle, _input: &OpenedInput) -> Result<()> {
Ok(())
}
- fn print_snip(&mut self, _handle: OutputHandle) -> Result<()> {
+ fn print_snip(&mut self, _handle: &mut OutputHandle) -> Result<()> {
Ok(())
}
fn print_line(
&mut self,
out_of_range: bool,
- handle: OutputHandle,
+ handle: &mut OutputHandle,
_line_number: usize,
line_buffer: &[u8],
) -> Result<()> {
@@ -253,7 +253,11 @@ impl<'a> InteractivePrinter<'a> {
})
}
- fn print_horizontal_line_term(&mut self, handle: OutputHandle, style: Style) -> Result<()> {
+ fn print_horizontal_line_term(
+ &mut self,
+ handle: &mut OutputHandle,
+ style: Style,
+ ) -> Result<()> {
writeln_handle!(
handle,
"{}",
@@ -262,7 +266,7 @@ impl<'a> InteractivePrinter<'a> {
Ok(())
}
- fn print_horizontal_line(&mut self, handle: OutputHandle, grid_char: char) -> Result<()> {
+ fn print_horizontal_line(&mut self, handle: &mut OutputHandle, grid_char: char) -> Result<()> {
if self.panel_width == 0 {
self.print_horizontal_line_term(handle, self.colors.grid)?;
} else {
@@ -292,7 +296,7 @@ impl<'a> InteractivePrinter<'a> {
}
}
- fn print_header_component_indent(&mut self, handle: OutputHandle) -> Result<()> {
+ fn print_header_component_indent(&mut self, handle: &mut OutputHandle) -> Result<()> {
if self.config.style_components.grid() {
write_handle!(
handle,
@@ -320,7 +324,7 @@ impl<'a> InteractivePrinter<'a> {
impl<'a> Printer for InteractivePrinter<'a> {
fn print_header(
&mut self,
- handle: OutputHandle,
+ handle: &mut OutputHandle,
input: &OpenedInput,
add_header_padding: bool,
) -> Result<()> {
@@ -419,7 +423,7 @@ impl<'a> Printer for InteractivePrinter<'a> {
Ok(())
}
- fn print_footer(&mut self, handle: OutputHandle, _input: &OpenedInput) -> Result<()> {
+ fn print_footer(&mut self, handle: &mut OutputHandle, _input: &OpenedInput) -> Result<()> {
if self.config.style_components.grid()
&& (self.content_type.map_or(false, |c| c.is_text()) || self.config.show_nonprintable)
{
@@ -429,7 +433,7 @@ impl<'a> Printer for InteractivePrinter<'a> {
}
}
- fn print_snip(&mut self, handle: OutputHandle) -> Result<()> {
+ fn print_snip(&mut self, handle: &mut OutputHandle) -> Result<()> {
let panel = self.create_fake_panel(" ...");
let panel_count = panel.chars().count();
@@ -456,7 +460,7 @@ impl<'a> Printer for InteractivePrinter<'a> {
fn print_line(
&mut self,
out_of_range: bool,
- handle: OutputHandle,
+ handle: &mut OutputHandle,
line_number: usize,
line_buffer: &[u8],
) -> Result<()> {