summaryrefslogtreecommitdiffstats
path: root/zellij-tile/src
diff options
context:
space:
mode:
authorBrooks J Rady <b.j.rady@gmail.com>2021-04-27 14:57:54 +0100
committerBrooks J Rady <b.j.rady@gmail.com>2021-04-27 14:57:54 +0100
commit2814c3027271d15b4af345bdde03591bb189cbce (patch)
tree192290907893d4454c23360f1c5f6f66118af30d /zellij-tile/src
parentea1a7dfc7d35585232193f7da30466ce8ee575dc (diff)
feat(plugin): added the `get_plugin_ids()` query function
Diffstat (limited to 'zellij-tile/src')
-rw-r--r--zellij-tile/src/data.rs14
-rw-r--r--zellij-tile/src/shim.rs13
2 files changed, 21 insertions, 6 deletions
diff --git a/zellij-tile/src/data.rs b/zellij-tile/src/data.rs
index 85d12245b..e7ddb319c 100644
--- a/zellij-tile/src/data.rs
+++ b/zellij-tile/src/data.rs
@@ -23,7 +23,9 @@ pub enum Key {
Esc,
}
-#[derive(Debug, Clone, EnumDiscriminants, ToString, Serialize, Deserialize)]
+#[derive(
+ Debug, Clone, PartialEq, Eq, Hash, EnumDiscriminants, ToString, Serialize, Deserialize,
+)]
#[strum_discriminants(derive(EnumString, Hash, Serialize, Deserialize))]
#[strum_discriminants(name(EventType))]
pub enum Event {
@@ -68,17 +70,23 @@ impl Default for InputMode {
/// Represents the contents of the help message that is printed in the status bar,
/// which indicates the current [`InputMode`] and what the keybinds for that mode
/// are. Related to the default `status-bar` plugin.
-#[derive(Default, Debug, Clone, Serialize, Deserialize)]
+#[derive(Default, Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct ModeInfo {
pub mode: InputMode,
// FIXME: This should probably return Keys and Actions, then sort out strings plugin-side
pub keybinds: Vec<(String, String)>, // <shortcut> => <shortcut description>
}
-#[derive(Debug, Default, Clone, Deserialize, Serialize)]
+#[derive(Debug, Default, Clone, PartialEq, Eq, Hash, Deserialize, Serialize)]
pub struct TabInfo {
/* subset of fields to publish to plugins */
pub position: usize,
pub name: String,
pub active: bool,
}
+
+#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, Deserialize, Serialize)]
+pub struct PluginIds {
+ pub plugin_id: u32,
+ pub zellij_pid: u32,
+}
diff --git a/zellij-tile/src/shim.rs b/zellij-tile/src/shim.rs
index 42a646a1f..ca15919fe 100644
--- a/zellij-tile/src/shim.rs
+++ b/zellij-tile/src/shim.rs
@@ -21,12 +21,18 @@ pub fn set_max_height(max_height: i32) {
unsafe { host_set_max_height(max_height) };
}
+pub fn set_selectable(selectable: bool) {
+ unsafe { host_set_selectable(if selectable { 1 } else { 0 }) };
+}
+
pub fn set_invisible_borders(invisible_borders: bool) {
unsafe { host_set_invisible_borders(if invisible_borders { 1 } else { 0 }) };
}
-pub fn set_selectable(selectable: bool) {
- unsafe { host_set_selectable(if selectable { 1 } else { 0 }) };
+// Query Functions
+pub fn get_plugin_ids() -> PluginIds {
+ unsafe { host_get_plugin_ids() };
+ object_from_stdin()
}
// Host Functions
@@ -49,8 +55,9 @@ pub fn object_from_stdin<T: DeserializeOwned>() -> T {
extern "C" {
fn host_subscribe();
fn host_unsubscribe();
- fn host_open_file();
fn host_set_max_height(max_height: i32);
fn host_set_selectable(selectable: i32);
fn host_set_invisible_borders(invisible_borders: i32);
+ fn host_get_plugin_ids();
+ fn host_open_file();
}