From d4958e4a715eab518a3826bad2da29a698170bbc Mon Sep 17 00:00:00 2001 From: Matt Paras Date: Fri, 20 Jun 2025 08:14:21 -0700 Subject: [PATCH] expose paste events in components --- helix-term/src/commands/engine/components.rs | 35 ++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/helix-term/src/commands/engine/components.rs b/helix-term/src/commands/engine/components.rs index 07d7a6773..18161b2f1 100644 --- a/helix-term/src/commands/engine/components.rs +++ b/helix-term/src/commands/engine/components.rs @@ -1366,6 +1366,41 @@ value : any? "# ); + // TODO: Register this differently so it doesn't clone the pasted text unnecessarily + register!( + "paste-event?", + |event: Event| { matches!(event, Event::Paste(_)) }, + r#"Checks if the given event is a paste event. + +```scheme +(paste-event? event) -> bool? +``` + +* event : Event? + + "# + ); + + register!( + "paste-event-string", + |event: Event| { + if let Event::Paste(p) = event { + Some(p) + } else { + None + } + }, + r#"Get the string from the paste event, if it is a paste event. + +```scheme +(paste-event-string event) -> (or string? #false) +``` + +* event : Event? + + "# + ); + register!( "key-event?", |event: Event| { matches!(event, Event::Key(_)) },