diff options
| author | Aram Drevekenin <aram@poor.dev> | 2025-01-31 16:49:24 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-01-31 16:49:24 +0100 |
| commit | af120de6dba440bd901f3ce940415aa61dbccdf8 (patch) | |
| tree | 8053de2e2bceb7b451c53101e369fea16ced2f86 /zellij-utils/src/plugin_api | |
| parent | fix(tiled-panes): opening panes from the cli (#3963) (diff) | |
| download | sl0ppij-af120de6dba440bd901f3ce940415aa61dbccdf8.tar.gz sl0ppij-af120de6dba440bd901f3ce940415aa61dbccdf8.tar.xz sl0ppij-af120de6dba440bd901f3ce940415aa61dbccdf8.zip | |
feat(plugins): add `PastedText` Event (#3962)
* working with text paste
* handle utf8 conversion error
* feat(plugins): add PastedText Event
Diffstat (limited to 'zellij-utils/src/plugin_api')
| -rw-r--r-- | zellij-utils/src/plugin_api/event.proto | 6 | ||||
| -rw-r--r-- | zellij-utils/src/plugin_api/event.rs | 14 |
2 files changed, 20 insertions, 0 deletions
diff --git a/zellij-utils/src/plugin_api/event.proto b/zellij-utils/src/plugin_api/event.proto index d39edb23..86f74bdf 100644 --- a/zellij-utils/src/plugin_api/event.proto +++ b/zellij-utils/src/plugin_api/event.proto @@ -52,6 +52,7 @@ enum EventType { ListClients = 26; HostFolderChanged = 27; FailedToChangeHostFolder = 28; + PastedText = 29; } message EventNameList { @@ -85,9 +86,14 @@ message Event { ListClientsPayload list_clients_payload = 23; HostFolderChangedPayload host_folder_changed_payload = 24; FailedToChangeHostFolderPayload failed_to_change_host_folder_payload = 25; + PastedTextPayload pasted_text_payload = 26; } } +message PastedTextPayload { + string pasted_text = 1; +} + message FailedToChangeHostFolderPayload { optional string error_message = 1; } diff --git a/zellij-utils/src/plugin_api/event.rs b/zellij-utils/src/plugin_api/event.rs index b525c76c..9a6829d6 100644 --- a/zellij-utils/src/plugin_api/event.rs +++ b/zellij-utils/src/plugin_api/event.rs @@ -349,6 +349,12 @@ impl TryFrom<ProtobufEvent> for Event { )), _ => Err("Malformed payload for the FailedToChangeHostFolder Event"), }, + Some(ProtobufEventType::PastedText) => match protobuf_event.payload { + Some(ProtobufEventPayload::PastedTextPayload(pasted_text_payload)) => { + Ok(Event::PastedText(pasted_text_payload.pasted_text)) + }, + _ => Err("Malformed payload for the PastedText Event"), + }, None => Err("Unknown Protobuf Event"), } } @@ -713,6 +719,12 @@ impl TryFrom<Event> for ProtobufEvent { FailedToChangeHostFolderPayload { error_message }, )), }), + Event::PastedText(pasted_text) => Ok(ProtobufEvent { + name: ProtobufEventType::PastedText as i32, + payload: Some(event::Payload::PastedTextPayload(PastedTextPayload { + pasted_text, + })), + }), } } } @@ -1268,6 +1280,7 @@ impl TryFrom<ProtobufEventType> for EventType { ProtobufEventType::ListClients => EventType::ListClients, ProtobufEventType::HostFolderChanged => EventType::HostFolderChanged, ProtobufEventType::FailedToChangeHostFolder => EventType::FailedToChangeHostFolder, + ProtobufEventType::PastedText => EventType::PastedText, }) } } @@ -1305,6 +1318,7 @@ impl TryFrom<EventType> for ProtobufEventType { EventType::ListClients => ProtobufEventType::ListClients, EventType::HostFolderChanged => ProtobufEventType::HostFolderChanged, EventType::FailedToChangeHostFolder => ProtobufEventType::FailedToChangeHostFolder, + EventType::PastedText => ProtobufEventType::PastedText, }) } } |
