diff options
| author | Mica White <botahamec@outlook.com> | 2026-10-31 12:19:17 -0400 |
|---|---|---|
| committer | Mica White <botahamec@outlook.com> | 2026-10-31 12:19:17 -0400 |
| commit | c2dfde109b8cd59946081ff2665bd1e75a6d116f (patch) | |
| tree | 9a889a42b9a67fba8851318a79d33a956f8afad1 /platforms/tortuise-script-wasm | |
| parent | ec40f6e3acc7874b82709ab81b254c741529fdff (diff) | |
Fix import
Diffstat (limited to 'platforms/tortuise-script-wasm')
| -rw-r--r-- | platforms/tortuise-script-wasm/Cargo.toml | 2 | ||||
| -rw-r--r-- | platforms/tortuise-script-wasm/src/buffer.rs | 46 | ||||
| -rw-r--r-- | platforms/tortuise-script-wasm/src/storage.rs | 4 |
3 files changed, 49 insertions, 3 deletions
diff --git a/platforms/tortuise-script-wasm/Cargo.toml b/platforms/tortuise-script-wasm/Cargo.toml index 768cdfe..deee369 100644 --- a/platforms/tortuise-script-wasm/Cargo.toml +++ b/platforms/tortuise-script-wasm/Cargo.toml @@ -10,4 +10,4 @@ rand = { version = "0.10", default-features = false } serde = "1" spin = { version = "0.12", features=["lock_api"] } talc = "5" -toml = "1" +serde_json = { version = "1", default-features = false, features=["alloc"] } diff --git a/platforms/tortuise-script-wasm/src/buffer.rs b/platforms/tortuise-script-wasm/src/buffer.rs index bbcb3ca..fbb63f8 100644 --- a/platforms/tortuise-script-wasm/src/buffer.rs +++ b/platforms/tortuise-script-wasm/src/buffer.rs @@ -15,6 +15,26 @@ mod tortuise { underline_color: u32, attributes: u32, ); + pub safe fn add_eternal_cell( + context: u64, + character: u32, + location: u32, + z: u32, + foreground_color: u32, + background_color: u32, + underline_color: u32, + attributes: u32, + ); + pub safe fn remove_eternal_cell( + context: u64, + character: u32, + location: u32, + z: u32, + foreground_color: u32, + background_color: u32, + underline_color: u32, + attributes: u32, + ); pub safe fn window_size(context: u64) -> u32; pub safe fn set_framerate_limit(context: u64, limit: u32); } @@ -226,6 +246,32 @@ impl ScriptContext<'_> { ); } + pub fn add_eternal_cell(&mut self, cell: Cell) { + tortuise::add_eternal_cell( + self.0, + cell.character as u32, + (cell.x as u32) << 16 | cell.y as u32, + cell.z as u32, + color_to_u32(cell.foreground_color), + color_to_u32(cell.background_color), + color_to_u32(cell.underline_color), + cell.attributes.0, + ); + } + + pub fn remove_eternal_cell(&mut self, cell: Cell) { + tortuise::remove_eternal_cell( + self.0, + cell.character as u32, + (cell.x as u32) << 16 | cell.y as u32, + cell.z as u32, + color_to_u32(cell.foreground_color), + color_to_u32(cell.background_color), + color_to_u32(cell.underline_color), + cell.attributes.0, + ); + } + pub fn window_size(&self) -> WindowSize { let size = tortuise::window_size(self.0); WindowSize { diff --git a/platforms/tortuise-script-wasm/src/storage.rs b/platforms/tortuise-script-wasm/src/storage.rs index 2606e2b..ad48e23 100644 --- a/platforms/tortuise-script-wasm/src/storage.rs +++ b/platforms/tortuise-script-wasm/src/storage.rs @@ -58,7 +58,7 @@ fn load_config<T: DeserializeOwned>(context: u64) -> Option<T> { let ptr = alloc(layout); tortuise::load_config(context, ptr); let data = core::slice::from_raw_parts(ptr, size); - let data = toml::from_slice(data).ok()?; + let data = serde_json::from_slice(data).ok()?; dealloc(ptr, layout); Some(data) } @@ -66,7 +66,7 @@ fn load_config<T: DeserializeOwned>(context: u64) -> Option<T> { fn save_config<T: Serialize>(context: u64, state: &T) { unsafe { - let data = toml::to_string(state).unwrap(); + let data = serde_json::to_vec_pretty(state).unwrap(); tortuise::save_config(context, data.as_ptr(), data.len()); } } |
