1
0
mirror of https://github.com/sharkdp/bat.git synced 2025-03-13 22:28:26 +00:00

Fix signatures

This commit is contained in:
Peter Hebden 2023-07-09 01:20:58 +01:00 committed by David Peter
parent 103a2f0d9b
commit d929becefc
3 changed files with 28 additions and 24 deletions

View File

@ -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")]

View File

@ -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<()> {

View File

@ -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<()> {