Typstify /chat_message to /chat

This commit is contained in:
Joscha 2025-03-01 23:11:49 +01:00
parent 8bece23baf
commit de7ae63a5e
13 changed files with 93 additions and 153 deletions

View file

@ -3,8 +3,6 @@ use std::{fs, io::ErrorKind, path::PathBuf};
use anyhow::{Context, bail};
use image::RgbaImage;
use jiff::Timestamp;
use showbits_common::Tree;
use taffy::{AvailableSpace, NodeId, Size};
use crate::printer::Printer;
@ -30,20 +28,6 @@ impl PersistentPrinter {
}
}
fn render_tree_to_image<C>(
tree: &mut Tree<C>,
ctx: &mut C,
root: NodeId,
) -> anyhow::Result<RgbaImage> {
let available = Size {
width: AvailableSpace::Definite(Printer::WIDTH as f32),
// TODO Maybe MinContent? If not, why not?
height: AvailableSpace::MaxContent,
};
tree.render(ctx, root, available)
}
fn print_image_immediately(&mut self, image: &RgbaImage) -> anyhow::Result<()> {
let Some(printer) = &mut self.printer else {
bail!("no printer found");
@ -93,17 +77,6 @@ impl PersistentPrinter {
Ok(())
}
pub fn print_tree<C>(
&mut self,
tree: &mut Tree<C>,
ctx: &mut C,
root: NodeId,
) -> anyhow::Result<()> {
let image = Self::render_tree_to_image(tree, ctx, root)?;
self.print_image(&image)?;
Ok(())
}
pub fn print_backlog(&mut self) -> anyhow::Result<()> {
// Don't try to print if the chances of success are zero.
if let Some(file) = &self.printer_file {