struggling with printing contexts, what a mess
This commit is contained in:
@@ -58,6 +58,24 @@ impl<W: io::Write> Printer<W> {
|
||||
self.write(b"\n");
|
||||
}
|
||||
|
||||
pub fn context<P: AsRef<Path>>(
|
||||
&mut self,
|
||||
path: P,
|
||||
buf: &[u8],
|
||||
start: usize,
|
||||
end: usize,
|
||||
line_number: Option<u64>,
|
||||
) {
|
||||
self.write(path.as_ref().to_string_lossy().as_bytes());
|
||||
self.write(b"-");
|
||||
if let Some(line_number) = line_number {
|
||||
self.write(line_number.to_string().as_bytes());
|
||||
self.write(b"-");
|
||||
}
|
||||
self.write(&buf[start..end]);
|
||||
self.write(b"\n");
|
||||
}
|
||||
|
||||
pub fn binary_matched<P: AsRef<Path>>(&mut self, path: P) {
|
||||
wln!(&mut self.wtr, "binary file {} matches", path.as_ref().display());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user