zellij/zellij-tile/src/lib.rs
spacemaison c9372212f6
feat(plugin): add manifest to allow for plugin configuration (#660)
* feat(plugins-manifest): Add a plugins manifest to allow for more configuration of plugins

* refactor(plugins-manifest): Better storage of plugin metadata in wasm_vm

* fix(plugins-manifest): Inherit permissions from run configuration

* refactor(plugins-manifest): Rename things for more clarity

- The Plugins/Plugin structs had "Config" appended to them to clarify
  that they're metadata about plugins, and not the plugins themselves.

- The PluginType::OncePerPane variant was renamed to be just
  PluginType::Pane, and the documentation clarified to explain what it
  is.

- The "service" nomenclature was completely removed in favor of
  "headless".

* refactor(plugins-manifest): Move security warning into start plugin

* refactor(plugins-manifest): Remove hack in favor of standard method

* refactor(plugins-manifest): Change display of plugin location

The only time that a plugin location is displayed in Zellij is the
border of the pane. Having `zellij:strider` display instead of just
`strider` was a little annoying, so we're stripping out the scheme
information from a locations display.

* refactor(plugins-manifest): Add a little more documentation

* fix(plugins-manifest): Formatting

Co-authored-by: Jesse Tuchsen <not@disclosing>
2021-09-22 18:13:21 +01:00

43 lines
999 B
Rust

pub mod data;
pub mod prelude;
pub mod shim;
use data::*;
#[allow(unused_variables)]
pub trait ZellijPlugin {
fn load(&mut self) {}
fn update(&mut self, event: Event) {}
fn render(&mut self, rows: usize, cols: usize) {}
}
#[macro_export]
macro_rules! register_plugin {
($t:ty) => {
thread_local! {
static STATE: std::cell::RefCell<$t> = std::cell::RefCell::new(Default::default());
}
fn main() {
STATE.with(|state| {
state.borrow_mut().load();
});
}
#[no_mangle]
pub fn update() {
STATE.with(|state| {
state
.borrow_mut()
.update($crate::shim::object_from_stdin().unwrap());
});
}
#[no_mangle]
pub fn render(rows: i32, cols: i32) {
STATE.with(|state| {
state.borrow_mut().render(rows as usize, cols as usize);
});
}
};
}