summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJae-Heon Ji <32578710+jaeheonji@users.noreply.github.com>2021-11-26 18:44:43 +0900
committerGitHub <noreply@github.com>2021-11-26 10:44:43 +0100
commitc349586d84e63f9c752340246fc5ca7fa538795d (patch)
tree3bbbaf6884bc42ac35354d7bd92f692234bb376c
parentcbae0213db74bd2cc21588760db203948ebb12f5 (diff)
feat: provide the zellij version to plugins (#894)
* feat: add draft of feature * feat(wasm): add plugin API for getting of zellij version * feat(wasm): update feedback * delete unnecessary function
-rw-r--r--zellij-server/src/wasm_vm.rs7
-rw-r--r--zellij-tile/src/shim.rs6
2 files changed, 12 insertions, 1 deletions
diff --git a/zellij-server/src/wasm_vm.rs b/zellij-server/src/wasm_vm.rs
index 5e1b159d7..6ee37ad3e 100644
--- a/zellij-server/src/wasm_vm.rs
+++ b/zellij-server/src/wasm_vm.rs
@@ -28,7 +28,7 @@ use crate::{
};
use zellij_utils::{
- consts::ZELLIJ_PROJ_DIR,
+ consts::{VERSION, ZELLIJ_PROJ_DIR},
errors::{ContextType, PluginContext},
};
use zellij_utils::{
@@ -262,6 +262,7 @@ pub(crate) fn zellij_exports(store: &Store, plugin_env: &PluginEnv) -> ImportObj
host_unsubscribe,
host_set_selectable,
host_get_plugin_ids,
+ host_get_zellij_version,
host_open_file,
host_switch_tab_to,
host_set_timeout,
@@ -311,6 +312,10 @@ fn host_get_plugin_ids(plugin_env: &PluginEnv) {
wasi_write_object(&plugin_env.wasi_env, &ids);
}
+fn host_get_zellij_version(plugin_env: &PluginEnv) {
+ wasi_write_string(&plugin_env.wasi_env, VERSION);
+}
+
fn host_open_file(plugin_env: &PluginEnv) {
let path: PathBuf = wasi_read_object(&plugin_env.wasi_env);
plugin_env
diff --git a/zellij-tile/src/shim.rs b/zellij-tile/src/shim.rs
index c664d36b0..e3537053c 100644
--- a/zellij-tile/src/shim.rs
+++ b/zellij-tile/src/shim.rs
@@ -27,6 +27,11 @@ pub fn get_plugin_ids() -> PluginIds {
object_from_stdin().unwrap()
}
+pub fn get_zellij_version() -> String {
+ unsafe { host_get_zellij_version() };
+ object_from_stdin().unwrap()
+}
+
// Host Functions
pub fn open_file(path: &Path) {
@@ -66,6 +71,7 @@ extern "C" {
fn host_unsubscribe();
fn host_set_selectable(selectable: i32);
fn host_get_plugin_ids();
+ fn host_get_zellij_version();
fn host_open_file();
fn host_switch_tab_to(tab_idx: u32);
fn host_set_timeout(secs: f64);