aboutsummaryrefslogtreecommitdiffstats
path: root/src/main.rs
diff options
context:
space:
mode:
authorBrooks J Rady <b.j.rady@gmail.com>2021-01-10 23:02:41 +0000
committerBrooks J Rady <b.j.rady@gmail.com>2021-01-10 23:02:41 +0000
commit7e308515e5af960857504fc583b5900b3dc4edd4 (patch)
tree3c8728db22ca457fc430dd73ab05e387b1f378d5 /src/main.rs
parentAdd support for layouts with parts of a fixed or unspecified size (diff)
downloadsl0ppij-7e308515e5af960857504fc583b5900b3dc4edd4.tar.gz
sl0ppij-7e308515e5af960857504fc583b5900b3dc4edd4.tar.xz
sl0ppij-7e308515e5af960857504fc583b5900b3dc4edd4.zip
Add a plugin callback for global keypresses
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs27
1 files changed, 16 insertions, 11 deletions
diff --git a/src/main.rs b/src/main.rs
index 84dfac62..6800691d 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -458,17 +458,22 @@ pub fn start(mut os_input: Box<dyn OsApi>, opts: CliArgs) {
buf_tx.send(wasi_stdout(&plugin_env.wasi_env)).unwrap();
}
PluginInstruction::Input(pid, input_bytes) => {
- let (instance, plugin_env) = plugin_map.get(&pid).unwrap();
-
- let handle_key =
- instance.exports.get_function("handle_key").unwrap();
- for key in input_bytes.keys() {
- if let Ok(key) = key {
- wasi_write_string(
- &plugin_env.wasi_env,
- &serde_json::to_string(&key).unwrap(),
- );
- handle_key.call(&[]).unwrap();
+ // FIXME: Set up an event subscription system, and timed callbacks
+ for (&id, (instance, plugin_env)) in &plugin_map {
+ let handler = if PaneId::Plugin(id) == pid {
+ "handle_key"
+ } else {
+ "handle_global_key"
+ };
+ let handler = instance.exports.get_function(handler).unwrap();
+ for key in input_bytes.keys() {
+ if let Ok(key) = key {
+ wasi_write_string(
+ &plugin_env.wasi_env,
+ &serde_json::to_string(&key).unwrap(),
+ );
+ handler.call(&[]).unwrap();
+ }
}
}