Make "before" context work.

No line numbers. And match inverting is broken.

This is awful.
This commit is contained in:
Andrew Gallant
2016-09-01 21:56:23 -04:00
parent 5aa3b9bc58
commit 5450aed9a8
4 changed files with 125 additions and 44 deletions

View File

@@ -15,15 +15,21 @@ macro_rules! w {
pub struct Printer<W> {
wtr: W,
has_printed: bool,
}
impl<W: io::Write> Printer<W> {
pub fn new(wtr: W) -> Printer<W> {
Printer {
wtr: wtr,
has_printed: false,
}
}
pub fn has_printed(&self) -> bool {
self.has_printed
}
pub fn into_inner(self) -> W {
self.wtr
}
@@ -40,6 +46,10 @@ impl<W: io::Write> Printer<W> {
wln!(&mut self.wtr, "{}", count);
}
pub fn context_separator(&mut self) {
wln!(&mut self.wtr, "--");
}
pub fn matched<P: AsRef<Path>>(
&mut self,
path: P,
@@ -81,6 +91,7 @@ impl<W: io::Write> Printer<W> {
}
fn write(&mut self, buf: &[u8]) {
self.has_printed = true;
let _ = self.wtr.write_all(buf);
}
}