aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBrooks J Rady <b.j.rady@gmail.com>2021-03-25 15:51:39 +0000
committerBrooks J Rady <b.j.rady@gmail.com>2021-03-25 15:51:39 +0000
commit84a5cf95d1168db47931f81774e1210e1f022a69 (patch)
tree9060e6e63e5958e6979807da310e61090492da13 /src
parentRemoved AppState and the unneeded get_help() function (diff)
downloadsl0ppij-84a5cf95d1168db47931f81774e1210e1f022a69.tar.gz
sl0ppij-84a5cf95d1168db47931f81774e1210e1f022a69.tar.xz
sl0ppij-84a5cf95d1168db47931f81774e1210e1f022a69.zip
Converted tab updates to the new generic update() function
Diffstat (limited to 'src')
-rw-r--r--src/common/errors.rs2
-rw-r--r--src/common/mod.rs16
-rw-r--r--src/common/screen.rs4
-rw-r--r--src/common/wasm_vm.rs3
4 files changed, 4 insertions, 21 deletions
diff --git a/src/common/errors.rs b/src/common/errors.rs
index 7b194f5d..83860a59 100644
--- a/src/common/errors.rs
+++ b/src/common/errors.rs
@@ -285,7 +285,6 @@ pub enum PluginContext {
Input,
Unload,
Quit,
- Tabs,
}
impl From<&PluginInstruction> for PluginContext {
@@ -297,7 +296,6 @@ impl From<&PluginInstruction> for PluginContext {
PluginInstruction::Input(..) => PluginContext::Input,
PluginInstruction::Unload(_) => PluginContext::Unload,
PluginInstruction::Quit => PluginContext::Quit,
- PluginInstruction::UpdateTabs(..) => PluginContext::Tabs,
}
}
}
diff --git a/src/common/mod.rs b/src/common/mod.rs
index f291eb19..15a28d96 100644
--- a/src/common/mod.rs
+++ b/src/common/mod.rs
@@ -524,7 +524,7 @@ pub fn start(mut os_input: Box<dyn OsApi>, opts: CliArgs) {
let subs = plugin_env.subscriptions.lock().unwrap();
// FIXME: This is very janky... Maybe I should write my own macro for Event -> EventType?
let event_type = EventType::from_str(&event.to_string()).unwrap();
- if pid.is_none() || pid == Some(i) && subs.contains(&event_type) {
+ if (pid.is_none() || pid == Some(i)) && subs.contains(&event_type) {
let update = instance.exports.get_function("update").unwrap();
wasi_write_string(
&plugin_env.wasi_env,
@@ -546,20 +546,6 @@ pub fn start(mut os_input: Box<dyn OsApi>, opts: CliArgs) {
buf_tx.send(wasi_stdout(&plugin_env.wasi_env)).unwrap();
}
- PluginInstruction::UpdateTabs(mut tabs) => {
- for (instance, plugin_env) in plugin_map.values() {
- if !plugin_env.events.contains(&NaughtyEventType::Tab) {
- continue;
- }
- let handler = instance.exports.get_function("update_tabs").unwrap();
- tabs.sort_by(|a, b| a.position.cmp(&b.position));
- wasi_write_string(
- &plugin_env.wasi_env,
- &serde_json::to_string(&tabs).unwrap(),
- );
- handler.call(&[]).unwrap();
- }
- }
// FIXME: Deduplicate this with the callback below!
PluginInstruction::Input(input_type, input_bytes) => {
let PluginInputType::Event(event) = input_type;
diff --git a/src/common/screen.rs b/src/common/screen.rs
index 89205f73..e902099c 100644
--- a/src/common/screen.rs
+++ b/src/common/screen.rs
@@ -13,7 +13,7 @@ use crate::tab::Tab;
use crate::{errors::ErrorContext, wasm_vm::PluginInstruction};
use crate::{layout::Layout, panes::PaneId};
-use zellij_tile::data::{InputMode, TabInfo};
+use zellij_tile::data::{Event, InputMode, TabInfo};
/// Instructions that can be sent to the [`Screen`].
#[derive(Debug, Clone)]
@@ -282,7 +282,7 @@ impl Screen {
});
}
self.send_plugin_instructions
- .send(PluginInstruction::UpdateTabs(tab_data))
+ .send(PluginInstruction::Update(None, Event::TabUpdate(tab_data)))
.unwrap();
}
diff --git a/src/common/wasm_vm.rs b/src/common/wasm_vm.rs
index d6334e56..249ad9ca 100644
--- a/src/common/wasm_vm.rs
+++ b/src/common/wasm_vm.rs
@@ -6,7 +6,7 @@ use std::{
};
use wasmer::{imports, Function, ImportObject, Store, WasmerEnv};
use wasmer_wasi::WasiEnv;
-use zellij_tile::data::{Event, EventType, TabInfo};
+use zellij_tile::data::{Event, EventType};
use super::{
pty_bus::PtyInstruction, screen::ScreenInstruction, AppInstruction, PaneId, SenderWithContext,
@@ -29,7 +29,6 @@ pub enum PluginInstruction {
Render(Sender<String>, u32, usize, usize), // String buffer, plugin id, rows, cols
Input(PluginInputType, Vec<u8>), // plugin id, input bytes
Unload(u32),
- UpdateTabs(Vec<TabInfo>), // num tabs, active tab
Quit,
}