Remove all dependencies on showbits-common
This commit is contained in:
parent
de7ae63a5e
commit
6e6dfb2b66
8 changed files with 26 additions and 28 deletions
|
|
@ -1,20 +1,14 @@
|
|||
mod backlog;
|
||||
mod new_typst;
|
||||
|
||||
use showbits_common::widgets::{FontStuff, HasFontStuff};
|
||||
use tokio::sync::mpsc;
|
||||
|
||||
use crate::persistent_printer::PersistentPrinter;
|
||||
|
||||
pub use self::{backlog::BacklogDrawing, new_typst::NewTypstDrawing};
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct Context {
|
||||
font_stuff: FontStuff,
|
||||
}
|
||||
|
||||
pub trait Drawing {
|
||||
fn draw(&self, printer: &mut PersistentPrinter, ctx: &mut Context) -> anyhow::Result<()>;
|
||||
fn draw(&self, printer: &mut PersistentPrinter) -> anyhow::Result<()>;
|
||||
}
|
||||
|
||||
pub struct Command(Box<dyn Drawing + Send>);
|
||||
|
|
@ -25,30 +19,19 @@ impl Command {
|
|||
}
|
||||
}
|
||||
|
||||
impl HasFontStuff for Context {
|
||||
fn font_stuff(&mut self) -> &mut FontStuff {
|
||||
&mut self.font_stuff
|
||||
}
|
||||
}
|
||||
|
||||
pub struct Drawer {
|
||||
rx: mpsc::Receiver<Command>,
|
||||
printer: PersistentPrinter,
|
||||
ctx: Context,
|
||||
}
|
||||
|
||||
impl Drawer {
|
||||
pub fn new(rx: mpsc::Receiver<Command>, printer: PersistentPrinter) -> Self {
|
||||
Self {
|
||||
rx,
|
||||
printer,
|
||||
ctx: Context::default(),
|
||||
}
|
||||
Self { rx, printer }
|
||||
}
|
||||
|
||||
pub fn run(&mut self) -> anyhow::Result<()> {
|
||||
while let Some(command) = self.rx.blocking_recv() {
|
||||
command.0.draw(&mut self.printer, &mut self.ctx)?;
|
||||
command.0.draw(&mut self.printer)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue