Split WASM and native versions, and move iced support code to native

This commit is contained in:
2026-03-27 00:27:34 -05:00
parent 3010469c8a
commit b433148843
23 changed files with 2330 additions and 1012 deletions

View File

@@ -2,6 +2,7 @@ use std::num::NonZeroUsize;
#[derive(Debug, Clone)]
pub struct DebugLog {
enabled: bool,
current: String,
history: Vec<String>,
max_history: Option<NonZeroUsize>,
@@ -11,6 +12,7 @@ pub struct DebugLog {
impl DebugLog {
pub fn new() -> Self {
Self {
enabled: false,
current: String::new(),
history: vec![],
max_history: None,
@@ -47,25 +49,41 @@ impl DebugLog {
pub fn pop(&mut self) -> Option<String> {
self.history.pop()
}
pub fn enable(&mut self) {
self.enabled = true;
}
}
impl std::fmt::Write for DebugLog {
fn write_str(&mut self, s: &str) -> std::fmt::Result {
let tmp = self.current.write_str(s);
self.rotate();
tmp
if self.enabled {
let tmp = self.current.write_str(s);
self.rotate();
tmp
} else {
Ok(())
}
}
fn write_char(&mut self, c: char) -> std::fmt::Result {
let tmp = self.current.write_char(c);
self.rotate();
tmp
if self.enabled {
let tmp = self.current.write_char(c);
self.rotate();
tmp
} else {
Ok(())
}
}
fn write_fmt(&mut self, args: std::fmt::Arguments<'_>) -> std::fmt::Result {
let tmp = self.current.write_fmt(args);
self.rotate();
tmp
if self.enabled {
let tmp = self.current.write_fmt(args);
self.rotate();
tmp
} else {
Ok(())
}
}
}