diff options
| author | Brooks J Rady <b.j.rady@gmail.com> | 2021-01-10 22:58:48 +0000 |
|---|---|---|
| committer | Brooks J Rady <b.j.rady@gmail.com> | 2021-01-10 22:58:48 +0000 |
| commit | d79db4acb33f14c93c4f4b1e18c09ffb702212e1 (patch) | |
| tree | e5c811046d12734d85f5d807d38d42a74d58f75b | |
| parent | Version bump! (diff) | |
| download | sl0ppij-d79db4acb33f14c93c4f4b1e18c09ffb702212e1.tar.gz sl0ppij-d79db4acb33f14c93c4f4b1e18c09ffb702212e1.tar.xz sl0ppij-d79db4acb33f14c93c4f4b1e18c09ffb702212e1.zip | |
Add a global key callback
| -rw-r--r-- | Cargo.toml | 2 | ||||
| -rw-r--r-- | src/lib.rs | 16 |
2 files changed, 13 insertions, 5 deletions
@@ -1,6 +1,6 @@ [package] name = "mosaic-tile" -version = "0.2.1" +version = "0.2.2" authors = ["Brooks J Rady <b.j.rady@gmail.com>"] edition = "2018" description = "A small client-side library for writing mosaic plugins (tiles)" @@ -1,11 +1,12 @@ mod shim; pub use shim::*; - +#[allow(unused_variables)] pub trait MosaicTile { - fn init(&mut self); - fn draw(&mut self, rows: usize, cols: usize); - fn handle_key(&mut self, key: Key); + fn init(&mut self) {} + fn draw(&mut self, rows: usize, cols: usize) {} + fn handle_key(&mut self, key: Key) {} + fn handle_global_key(&mut self, key: Key) {} } #[macro_export] @@ -37,5 +38,12 @@ macro_rules! register_tile { state.borrow_mut().handle_key(get_key()); }); } + + #[no_mangle] + pub fn handle_global_key() { + STATE.with(|state| { + state.borrow_mut().handle_global_key(get_key()); + }); + } }; } |
