aboutsummaryrefslogtreecommitdiffstats
path: root/zellij-utils/src/plugin_api
diff options
context:
space:
mode:
authorAram Drevekenin <aram@poor.dev>2025-06-03 17:15:32 +0200
committerGitHub <noreply@github.com>2025-06-03 17:15:32 +0200
commita9f8bbcd197c8d14832fc1ab1fbe4d4111a2014d (patch)
tree6d354fdd36cf534d73e0cb81a7cacd3fedc1ebb9 /zellij-utils/src/plugin_api
parentdocs(changelog): theme fixes (diff)
downloadsl0ppij-a9f8bbcd197c8d14832fc1ab1fbe4d4111a2014d.tar.gz
sl0ppij-a9f8bbcd197c8d14832fc1ab1fbe4d4111a2014d.tar.xz
sl0ppij-a9f8bbcd197c8d14832fc1ab1fbe4d4111a2014d.zip
feat(ux): improve multiple select (#4221)
* intercept/clear-intercept key APIs * allow opening a pinned unfocused floating pane * rework plugin * improve some apis * fix tests * tests for pane groups * more exact placement and tests * plugin command permission and cleanup * improve some multiselect ux * improve plugin ui * remove old status indicator * allow moving plugin out of the way * style(fmt): rustfmt * update plugins * remove old keybinding * cleanups * fix: only rename pane if needed * changelog and some cleanups * style(fmt): rustfmt
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
-rw-r--r--zellij-utils/src/plugin_api/plugin_command.proto2
-rw-r--r--zellij-utils/src/plugin_api/plugin_command.rs16
-rw-r--r--zellij-utils/src/plugin_api/plugin_permission.proto1
-rw-r--r--zellij-utils/src/plugin_api/plugin_permission.rs2
6 files changed, 35 insertions, 0 deletions
diff --git a/zellij-utils/src/plugin_api/event.proto b/zellij-utils/src/plugin_api/event.proto
index 9b0e4d2f..760aee0b 100644
--- a/zellij-utils/src/plugin_api/event.proto
+++ b/zellij-utils/src/plugin_api/event.proto
@@ -55,6 +55,7 @@ enum EventType {
PastedText = 29;
ConfigWasWrittenToDisk = 30;
BeforeClose = 31;
+ InterceptedKeyPress = 32;
}
message EventNameList {
@@ -89,6 +90,7 @@ message Event {
HostFolderChangedPayload host_folder_changed_payload = 24;
FailedToChangeHostFolderPayload failed_to_change_host_folder_payload = 25;
PastedTextPayload pasted_text_payload = 26;
+ key.Key intercepted_key_payload = 27;
}
}
diff --git a/zellij-utils/src/plugin_api/event.rs b/zellij-utils/src/plugin_api/event.rs
index 88c55827..a853e12d 100644
--- a/zellij-utils/src/plugin_api/event.rs
+++ b/zellij-utils/src/plugin_api/event.rs
@@ -363,6 +363,12 @@ impl TryFrom<ProtobufEvent> for Event {
None => Ok(Event::BeforeClose),
_ => Err("Malformed payload for the BeforeClose Event"),
},
+ Some(ProtobufEventType::InterceptedKeyPress) => match protobuf_event.payload {
+ Some(ProtobufEventPayload::KeyPayload(protobuf_key)) => {
+ Ok(Event::InterceptedKeyPress(protobuf_key.try_into()?))
+ },
+ _ => Err("Malformed payload for the InterceptedKeyPress Event"),
+ },
None => Err("Unknown Protobuf Event"),
}
}
@@ -741,6 +747,10 @@ impl TryFrom<Event> for ProtobufEvent {
name: ProtobufEventType::BeforeClose as i32,
payload: None,
}),
+ Event::InterceptedKeyPress(key) => Ok(ProtobufEvent {
+ name: ProtobufEventType::InterceptedKeyPress as i32,
+ payload: Some(event::Payload::KeyPayload(key.try_into()?)),
+ }),
}
}
}
@@ -1376,6 +1386,7 @@ impl TryFrom<ProtobufEventType> for EventType {
ProtobufEventType::PastedText => EventType::PastedText,
ProtobufEventType::ConfigWasWrittenToDisk => EventType::ConfigWasWrittenToDisk,
ProtobufEventType::BeforeClose => EventType::BeforeClose,
+ ProtobufEventType::InterceptedKeyPress => EventType::InterceptedKeyPress,
})
}
}
@@ -1416,6 +1427,7 @@ impl TryFrom<EventType> for ProtobufEventType {
EventType::PastedText => ProtobufEventType::PastedText,
EventType::ConfigWasWrittenToDisk => ProtobufEventType::ConfigWasWrittenToDisk,
EventType::BeforeClose => ProtobufEventType::BeforeClose,
+ EventType::InterceptedKeyPress => ProtobufEventType::InterceptedKeyPress,
})
}
}
diff --git a/zellij-utils/src/plugin_api/plugin_command.proto b/zellij-utils/src/plugin_api/plugin_command.proto
index 3a63b0c8..621b5de6 100644
--- a/zellij-utils/src/plugin_api/plugin_command.proto
+++ b/zellij-utils/src/plugin_api/plugin_command.proto
@@ -145,6 +145,8 @@ enum CommandName {
CloseMultiplePanes = 129;
FloatMultiplePanes = 130;
EmbedMultiplePanes = 131;
+ InterceptKeyPresses = 132;
+ ClearKeyPressesIntercepts = 133;
}
message PluginCommand {
diff --git a/zellij-utils/src/plugin_api/plugin_command.rs b/zellij-utils/src/plugin_api/plugin_command.rs
index 833d6270..08a9545e 100644
--- a/zellij-utils/src/plugin_api/plugin_command.rs
+++ b/zellij-utils/src/plugin_api/plugin_command.rs
@@ -1614,6 +1614,14 @@ impl TryFrom<ProtobufPluginCommand> for PluginCommand {
},
_ => Err("Mismatched payload for EmbedMultiplePanes"),
},
+ Some(CommandName::InterceptKeyPresses) => match protobuf_plugin_command.payload {
+ Some(_) => Err("InterceptKeyPresses should have no payload, found a payload"),
+ None => Ok(PluginCommand::InterceptKeyPresses),
+ },
+ Some(CommandName::ClearKeyPressesIntercepts) => match protobuf_plugin_command.payload {
+ Some(_) => Err("ClearKeyPressesIntercepts should have no payload, found a payload"),
+ None => Ok(PluginCommand::ClearKeyPressesIntercepts),
+ },
None => Err("Unrecognized plugin command"),
}
}
@@ -2684,6 +2692,14 @@ impl TryFrom<PluginCommand> for ProtobufPluginCommand {
},
)),
}),
+ PluginCommand::InterceptKeyPresses => Ok(ProtobufPluginCommand {
+ name: CommandName::InterceptKeyPresses as i32,
+ payload: None,
+ }),
+ PluginCommand::ClearKeyPressesIntercepts => Ok(ProtobufPluginCommand {
+ name: CommandName::ClearKeyPressesIntercepts as i32,
+ payload: None,
+ }),
}
}
}
diff --git a/zellij-utils/src/plugin_api/plugin_permission.proto b/zellij-utils/src/plugin_api/plugin_permission.proto
index 4f1f90f9..72c5b0f9 100644
--- a/zellij-utils/src/plugin_api/plugin_permission.proto
+++ b/zellij-utils/src/plugin_api/plugin_permission.proto
@@ -14,4 +14,5 @@ enum PermissionType {
MessageAndLaunchOtherPlugins = 8;
Reconfigure = 9;
FullHdAccess = 10;
+ InterceptInput = 11;
}
diff --git a/zellij-utils/src/plugin_api/plugin_permission.rs b/zellij-utils/src/plugin_api/plugin_permission.rs
index 5b6a831f..ad64b499 100644
--- a/zellij-utils/src/plugin_api/plugin_permission.rs
+++ b/zellij-utils/src/plugin_api/plugin_permission.rs
@@ -26,6 +26,7 @@ impl TryFrom<ProtobufPermissionType> for PermissionType {
},
ProtobufPermissionType::Reconfigure => Ok(PermissionType::Reconfigure),
ProtobufPermissionType::FullHdAccess => Ok(PermissionType::FullHdAccess),
+ ProtobufPermissionType::InterceptInput => Ok(PermissionType::InterceptInput),
}
}
}
@@ -53,6 +54,7 @@ impl TryFrom<PermissionType> for ProtobufPermissionType {
},
PermissionType::Reconfigure => Ok(ProtobufPermissionType::Reconfigure),
PermissionType::FullHdAccess => Ok(ProtobufPermissionType::FullHdAccess),
+ PermissionType::InterceptInput => Ok(ProtobufPermissionType::InterceptInput),
}
}
}