summaryrefslogtreecommitdiffstats
path: root/zellij-tile/src
diff options
context:
space:
mode:
authorspacemaison <tuchsen@protonmail.com>2021-09-22 10:13:21 -0700
committerGitHub <noreply@github.com>2021-09-22 18:13:21 +0100
commitc9372212f68fed52d45590b2dac271ab6270d943 (patch)
tree031f384ab012817656876b5db020b9e9c6a41a1f /zellij-tile/src
parentc39f02181052f1c0948001d4ae419009fc0df677 (diff)
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>
Diffstat (limited to 'zellij-tile/src')
-rw-r--r--zellij-tile/src/data.rs23
-rw-r--r--zellij-tile/src/lib.rs4
-rw-r--r--zellij-tile/src/shim.rs6
3 files changed, 29 insertions, 4 deletions
diff --git a/zellij-tile/src/data.rs b/zellij-tile/src/data.rs
index 44708627f..6ca70c28d 100644
--- a/zellij-tile/src/data.rs
+++ b/zellij-tile/src/data.rs
@@ -1,4 +1,5 @@
use serde::{Deserialize, Serialize};
+use std::fmt;
use std::str::FromStr;
use strum_macros::{EnumDiscriminants, EnumIter, EnumString, ToString};
@@ -169,6 +170,28 @@ pub struct PluginIds {
pub zellij_pid: u32,
}
+/// Tag used to identify the plugin in layout and config yaml files
+#[derive(Debug, Default, Clone, PartialEq, Eq, Hash, Deserialize, Serialize)]
+pub struct PluginTag(String);
+
+impl PluginTag {
+ pub fn new(url: impl Into<String>) -> Self {
+ PluginTag(url.into())
+ }
+}
+
+impl From<PluginTag> for String {
+ fn from(tag: PluginTag) -> Self {
+ tag.0
+ }
+}
+
+impl fmt::Display for PluginTag {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ write!(f, "{}", self.0)
+ }
+}
+
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, Deserialize, Serialize)]
pub struct PluginCapabilities {
pub arrow_fonts: bool,
diff --git a/zellij-tile/src/lib.rs b/zellij-tile/src/lib.rs
index af7d8ca12..96483c3c3 100644
--- a/zellij-tile/src/lib.rs
+++ b/zellij-tile/src/lib.rs
@@ -27,7 +27,9 @@ macro_rules! register_plugin {
#[no_mangle]
pub fn update() {
STATE.with(|state| {
- state.borrow_mut().update($crate::shim::object_from_stdin());
+ state
+ .borrow_mut()
+ .update($crate::shim::object_from_stdin().unwrap());
});
}
diff --git a/zellij-tile/src/shim.rs b/zellij-tile/src/shim.rs
index bdd6f4fb1..6904d3f7d 100644
--- a/zellij-tile/src/shim.rs
+++ b/zellij-tile/src/shim.rs
@@ -24,7 +24,7 @@ pub fn set_selectable(selectable: bool) {
// Query Functions
pub fn get_plugin_ids() -> PluginIds {
unsafe { host_get_plugin_ids() };
- object_from_stdin()
+ object_from_stdin().unwrap()
}
// Host Functions
@@ -45,10 +45,10 @@ pub fn exec_cmd(cmd: &[&str]) {
// Internal Functions
#[doc(hidden)]
-pub fn object_from_stdin<T: DeserializeOwned>() -> T {
+pub fn object_from_stdin<T: DeserializeOwned>() -> Result<T, serde_json::Error> {
let mut json = String::new();
io::stdin().read_line(&mut json).unwrap();
- serde_json::from_str(&json).unwrap()
+ serde_json::from_str(&json)
}
#[doc(hidden)]