Reimplement text command
This commit is contained in:
parent
638a449343
commit
5cdc62bd29
1 changed files with 24 additions and 12 deletions
|
|
@ -1,8 +1,7 @@
|
||||||
use palette::Srgba;
|
|
||||||
use showbits_common::{
|
use showbits_common::{
|
||||||
color,
|
color::{BLACK, WHITE},
|
||||||
widgets::{Block, FontStuff, HasFontStuff, Text},
|
widgets::{Block, FontStuff, HasFontStuff, Text},
|
||||||
Tree, WidgetExt,
|
Node, Tree, WidgetExt,
|
||||||
};
|
};
|
||||||
use taffy::style_helpers::{length, percent};
|
use taffy::style_helpers::{length, percent};
|
||||||
use tokio::sync::mpsc;
|
use tokio::sync::mpsc;
|
||||||
|
|
@ -59,14 +58,14 @@ impl Drawer {
|
||||||
Command::Stop => {} // Already handled one level above
|
Command::Stop => {} // Already handled one level above
|
||||||
Command::Rip => self.printer.rip()?,
|
Command::Rip => self.printer.rip()?,
|
||||||
Command::Test => self.on_test()?,
|
Command::Test => self.on_test()?,
|
||||||
Command::Text(_) => todo!(),
|
Command::Text(text) => self.on_text(text)?,
|
||||||
Command::ChatMessage { username, content } => todo!(),
|
Command::ChatMessage { username, content } => todo!(),
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn on_test(&mut self) -> anyhow::Result<()> {
|
fn on_test(&mut self) -> anyhow::Result<()> {
|
||||||
let mut tree = Tree::<Context>::new(Srgba::new(1.0, 1.0, 1.0, 1.0));
|
let mut tree = Tree::<Context>::new(WHITE);
|
||||||
|
|
||||||
let text = Text::new()
|
let text = Text::new()
|
||||||
.with_metrics(Text::default_metrics().scale(2.0))
|
.with_metrics(Text::default_metrics().scale(2.0))
|
||||||
|
|
@ -78,14 +77,14 @@ impl Drawer {
|
||||||
.register(&mut tree)?;
|
.register(&mut tree)?;
|
||||||
|
|
||||||
let wrap = Block::new()
|
let wrap = Block::new()
|
||||||
.with_border(color::BLACK)
|
.with_border(BLACK)
|
||||||
.node()
|
.node()
|
||||||
.with_border_all(length(2.0))
|
.with_border_all(length(2.0))
|
||||||
.and_child(text)
|
.and_child(text)
|
||||||
.register(&mut tree)?;
|
.register(&mut tree)?;
|
||||||
|
|
||||||
let root = Block::new()
|
let root = Block::new()
|
||||||
.with_border(color::BLACK)
|
.with_border(BLACK)
|
||||||
.node()
|
.node()
|
||||||
.with_size_width(percent(1.0))
|
.with_size_width(percent(1.0))
|
||||||
.with_border_all(length(2.0))
|
.with_border_all(length(2.0))
|
||||||
|
|
@ -97,11 +96,24 @@ impl Drawer {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
// fn on_text(&mut self, text: String) -> anyhow::Result<()> {
|
fn on_text(&mut self, text: String) -> anyhow::Result<()> {
|
||||||
// let text = util::sanitize(&text);
|
let mut tree = Tree::<Context>::new(WHITE);
|
||||||
// self.printer.init()?.write(&text)?.print()?;
|
|
||||||
// Ok(())
|
let text = Text::new()
|
||||||
// }
|
.with_metrics(Text::default_metrics().scale(2.0))
|
||||||
|
.and_plain(text)
|
||||||
|
.widget(&mut self.ctx.font_stuff)
|
||||||
|
.node()
|
||||||
|
.register(&mut tree)?;
|
||||||
|
|
||||||
|
let root = Node::empty()
|
||||||
|
.with_size_width(percent(1.0))
|
||||||
|
.and_child(text)
|
||||||
|
.register(&mut tree)?;
|
||||||
|
|
||||||
|
self.printer.print_tree(&mut tree, &mut self.ctx, root)?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
// fn on_chat_message(&mut self, username: String, content: String) -> anyhow::Result<()> {
|
// fn on_chat_message(&mut self, username: String, content: String) -> anyhow::Result<()> {
|
||||||
// let username = util::sanitize(&username);
|
// let username = util::sanitize(&username);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue