|
| 1 | +pubmod styles; |
| 2 | + |
| 3 | +usesuper::RendererasRendererTrait; |
| 4 | +usecrate::display_list::line::DisplayLine; |
| 5 | +usecrate::display_list::line::DisplayRawLine; |
| 6 | +usecrate::DisplayList; |
| 7 | +use std::io::Write; |
| 8 | +use std::marker::PhantomData; |
| 9 | +use styles::StyleasStyleTrait; |
| 10 | + |
| 11 | +pubstructRenderer<S:StyleTrait>{ |
| 12 | +style:PhantomData<S>, |
| 13 | +} |
| 14 | + |
| 15 | +impl<S:StyleTrait>Renderer<S>{ |
| 16 | +pubfnnew() ->Self{ |
| 17 | +Renderer{style:PhantomData} |
| 18 | +} |
| 19 | + |
| 20 | +pubfnfmt(&self,w:&mutimplWrite,dl:&DisplayList) -> std::io::Result<()>{ |
| 21 | +for linein&dl.body{ |
| 22 | +self.fmt_line(w, line)?; |
| 23 | +} |
| 24 | +Ok(()) |
| 25 | +} |
| 26 | + |
| 27 | +fnfmt_line(&self,w:&mutimplWrite,line:&DisplayLine) -> std::io::Result<()>{ |
| 28 | +match line{ |
| 29 | +DisplayLine::Raw(l) =>self.fmt_raw_line(w, l), |
| 30 | + _ =>Ok(()), |
| 31 | +} |
| 32 | +} |
| 33 | + |
| 34 | +fnfmt_raw_line( |
| 35 | +&self, |
| 36 | +w:&mutimpl std::io::Write, |
| 37 | +line:&DisplayRawLine, |
| 38 | +) -> std::io::Result<()>{ |
| 39 | +match line{ |
| 40 | +DisplayRawLine::Origin{ path, ..} =>{ |
| 41 | +let _lineno_max =1; |
| 42 | +S::fmt(w, path) |
| 43 | +//write!(w, "{:>1$}", "", lineno_max)?; |
| 44 | +//write!(w, "--> {}", path)?; |
| 45 | +//if let Some(line) = pos.0 { |
| 46 | +//write!(w, ":{}", line)?; |
| 47 | +//} |
| 48 | +//w.write_char('\n') |
| 49 | +} |
| 50 | + _ =>Ok(()), |
| 51 | +} |
| 52 | +} |
| 53 | +} |
| 54 | + |
| 55 | +impl<S:StyleTrait>RendererTraitforRenderer<S>{ |
| 56 | +fnfmt(&self,w:&mutimplWrite,dl:&DisplayList) -> std::io::Result<()>{ |
| 57 | +Renderer::fmt(self, w, dl) |
| 58 | +} |
| 59 | +} |