summaryrefslogtreecommitdiffstats
path: root/zellij-utils
diff options
context:
space:
mode:
authorAram Drevekenin <aram@poor.dev>2024-03-26 18:44:56 +0100
committerGitHub <noreply@github.com>2024-03-26 18:44:56 +0100
commit2eaa50cc44284bdfd47a98770625f380c15fd51d (patch)
treee86909cdfce996d08442c5152fa4bacdbf203745 /zellij-utils
parentb24dd87b8044be59a9897bb19604deee85b236b0 (diff)
feat(plugins): add api to dump the current session layout to a plugin (#3227)
Diffstat (limited to 'zellij-utils')
-rw-r--r--zellij-utils/assets/prost/api.plugin_command.rs3
-rw-r--r--zellij-utils/src/data.rs1
-rw-r--r--zellij-utils/src/errors.rs3
-rw-r--r--zellij-utils/src/plugin_api/plugin_command.proto1
-rw-r--r--zellij-utils/src/plugin_api/plugin_command.rs8
5 files changed, 16 insertions, 0 deletions
diff --git a/zellij-utils/assets/prost/api.plugin_command.rs b/zellij-utils/assets/prost/api.plugin_command.rs
index 5ec93e2e1..ca067fd97 100644
--- a/zellij-utils/assets/prost/api.plugin_command.rs
+++ b/zellij-utils/assets/prost/api.plugin_command.rs
@@ -420,6 +420,7 @@ pub enum CommandName {
KillSessions = 81,
ScanHostFolder = 82,
WatchFilesystem = 83,
+ DumpSessionLayout = 84,
}
impl CommandName {
/// String value of the enum field names used in the ProtoBuf definition.
@@ -512,6 +513,7 @@ impl CommandName {
CommandName::KillSessions => "KillSessions",
CommandName::ScanHostFolder => "ScanHostFolder",
CommandName::WatchFilesystem => "WatchFilesystem",
+ CommandName::DumpSessionLayout => "DumpSessionLayout",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
@@ -601,6 +603,7 @@ impl CommandName {
"KillSessions" => Some(Self::KillSessions),
"ScanHostFolder" => Some(Self::ScanHostFolder),
"WatchFilesystem" => Some(Self::WatchFilesystem),
+ "DumpSessionLayout" => Some(Self::DumpSessionLayout),
_ => None,
}
}
diff --git a/zellij-utils/src/data.rs b/zellij-utils/src/data.rs
index 379fb126f..78fbbd770 100644
--- a/zellij-utils/src/data.rs
+++ b/zellij-utils/src/data.rs
@@ -1378,4 +1378,5 @@ pub enum PluginCommand {
KillSessions(Vec<String>), // one or more session names
ScanHostFolder(PathBuf), // TODO: rename to ScanHostFolder
WatchFilesystem,
+ DumpSessionLayout,
}
diff --git a/zellij-utils/src/errors.rs b/zellij-utils/src/errors.rs
index d05df3a25..51174b756 100644
--- a/zellij-utils/src/errors.rs
+++ b/zellij-utils/src/errors.rs
@@ -351,6 +351,7 @@ pub enum ScreenContext {
NewInPlacePluginPane,
DumpLayoutToHd,
RenameSession,
+ DumpLayoutToPlugin,
}
/// Stack call representations corresponding to the different types of [`PtyInstruction`]s.
@@ -371,6 +372,7 @@ pub enum PtyContext {
DumpLayout,
LogLayoutToHd,
FillPluginCwd,
+ DumpLayoutToPlugin,
Exit,
}
@@ -402,6 +404,7 @@ pub enum PluginContext {
UnblockCliPipes,
WatchFilesystem,
KeybindPipe,
+ DumpLayoutToPlugin,
}
/// Stack call representations corresponding to the different types of [`ClientInstruction`]s.
diff --git a/zellij-utils/src/plugin_api/plugin_command.proto b/zellij-utils/src/plugin_api/plugin_command.proto
index c95111e59..b05c8ac8a 100644
--- a/zellij-utils/src/plugin_api/plugin_command.proto
+++ b/zellij-utils/src/plugin_api/plugin_command.proto
@@ -95,6 +95,7 @@ enum CommandName {
KillSessions = 81;
ScanHostFolder = 82;
WatchFilesystem = 83;
+ DumpSessionLayout = 84;
}
message PluginCommand {
diff --git a/zellij-utils/src/plugin_api/plugin_command.rs b/zellij-utils/src/plugin_api/plugin_command.rs
index e452e53cc..232a9f2dc 100644
--- a/zellij-utils/src/plugin_api/plugin_command.rs
+++ b/zellij-utils/src/plugin_api/plugin_command.rs
@@ -867,6 +867,10 @@ impl TryFrom<ProtobufPluginCommand> for PluginCommand {
Some(_) => Err("WatchFilesystem should have no payload, found a payload"),
None => Ok(PluginCommand::WatchFilesystem),
},
+ Some(CommandName::DumpSessionLayout) => match protobuf_plugin_command.payload {
+ Some(_) => Err("DumpSessionLayout should have no payload, found a payload"),
+ None => Ok(PluginCommand::DumpSessionLayout),
+ },
None => Err("Unrecognized plugin command"),
}
}
@@ -1381,6 +1385,10 @@ impl TryFrom<PluginCommand> for ProtobufPluginCommand {
name: CommandName::WatchFilesystem as i32,
payload: None,
}),
+ PluginCommand::DumpSessionLayout => Ok(ProtobufPluginCommand {
+ name: CommandName::DumpSessionLayout as i32,
+ payload: None,
+ }),
}
}
}