diff options
Diffstat (limited to 'platforms/tortuise-script-wasm/src')
| -rw-r--r-- | platforms/tortuise-script-wasm/src/buffer.rs | 46 | ||||
| -rw-r--r-- | platforms/tortuise-script-wasm/src/storage.rs | 4 |
2 files changed, 48 insertions, 2 deletions
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()); } } |
