aboutsummaryrefslogtreecommitdiffstats
path: root/zellij-utils/src/plugin_api
diff options
context:
space:
mode:
authorAram Drevekenin <aram@poor.dev>2025-02-02 16:19:15 +0100
committerGitHub <noreply@github.com>2025-02-02 16:19:15 +0100
commit3267d365897be0cd9356a9db91ccf77c6694f844 (patch)
treeafde743624253274ffaddf8479790a8ef4e35237 /zellij-utils/src/plugin_api
parentdocs(changelog): plugin apis to open panes near plugin (diff)
downloadsl0ppij-3267d365897be0cd9356a9db91ccf77c6694f844.tar.gz
sl0ppij-3267d365897be0cd9356a9db91ccf77c6694f844.tar.xz
sl0ppij-3267d365897be0cd9356a9db91ccf77c6694f844.zip
feat(plugins): send info about $EDITOR and $SHELL (#3971)
* feat(plugins): send info about $EDITOR and $SHELL * fix(e2e): snapshot update
Diffstat (limited to 'zellij-utils/src/plugin_api')
-rw-r--r--zellij-utils/src/plugin_api/event.proto2
-rw-r--r--zellij-utils/src/plugin_api/event.rs12
2 files changed, 14 insertions, 0 deletions
diff --git a/zellij-utils/src/plugin_api/event.proto b/zellij-utils/src/plugin_api/event.proto
index 86f74bdf..5a55baf0 100644
--- a/zellij-utils/src/plugin_api/event.proto
+++ b/zellij-utils/src/plugin_api/event.proto
@@ -322,6 +322,8 @@ message ModeUpdatePayload {
bool arrow_fonts_support = 4;
optional string session_name = 5;
optional input_mode.InputMode base_mode = 6;
+ optional string editor = 7;
+ optional string shell = 8;
}
message InputModeKeybinds {
diff --git a/zellij-utils/src/plugin_api/event.rs b/zellij-utils/src/plugin_api/event.rs
index 9a6829d6..08db3d6e 100644
--- a/zellij-utils/src/plugin_api/event.rs
+++ b/zellij-utils/src/plugin_api/event.rs
@@ -1157,6 +1157,10 @@ impl TryFrom<ProtobufModeUpdatePayload> for ModeInfo {
.and_then(|m| m.try_into().ok())
.ok_or("malformed payload for mode_info")?;
let session_name = protobuf_mode_update_payload.session_name;
+ let editor = protobuf_mode_update_payload
+ .editor
+ .map(|e| PathBuf::from(e));
+ let shell = protobuf_mode_update_payload.shell.map(|s| PathBuf::from(s));
let capabilities = PluginCapabilities {
arrow_fonts: protobuf_mode_update_payload.arrow_fonts_support,
};
@@ -1167,6 +1171,8 @@ impl TryFrom<ProtobufModeUpdatePayload> for ModeInfo {
capabilities,
session_name,
base_mode,
+ editor,
+ shell,
};
Ok(mode_info)
}
@@ -1182,6 +1188,8 @@ impl TryFrom<ModeInfo> for ProtobufModeUpdatePayload {
let style: ProtobufStyle = mode_info.style.try_into()?;
let arrow_fonts_support: bool = mode_info.capabilities.arrow_fonts;
let session_name = mode_info.session_name;
+ let editor = mode_info.editor.map(|e| e.display().to_string());
+ let shell = mode_info.shell.map(|s| s.display().to_string());
let mut protobuf_input_mode_keybinds: Vec<ProtobufInputModeKeybinds> = vec![];
for (input_mode, input_mode_keybinds) in mode_info.keybinds {
let mode: ProtobufInputMode = input_mode.try_into()?;
@@ -1213,6 +1221,8 @@ impl TryFrom<ModeInfo> for ProtobufModeUpdatePayload {
arrow_fonts_support,
session_name,
base_mode: base_mode.map(|b_m| b_m as i32),
+ editor,
+ shell,
})
}
}
@@ -1455,6 +1465,8 @@ fn serialize_mode_update_event_with_non_default_values() {
capabilities: PluginCapabilities { arrow_fonts: false },
session_name: Some("my awesome test session".to_owned()),
base_mode: Some(InputMode::Locked),
+ editor: Some(PathBuf::from("my_awesome_editor")),
+ shell: Some(PathBuf::from("my_awesome_shell")),
});
let protobuf_event: ProtobufEvent = mode_update_event.clone().try_into().unwrap();
let serialized_protobuf_event = protobuf_event.encode_to_vec();