aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src/ui
diff options
context:
space:
mode:
Diffstat (limited to 'helix-term/src/ui')
-rw-r--r--helix-term/src/ui/completion.rs2
-rw-r--r--helix-term/src/ui/editor.rs23
-rw-r--r--helix-term/src/ui/menu.rs4
-rw-r--r--helix-term/src/ui/overlay.rs2
-rw-r--r--helix-term/src/ui/picker.rs20
-rw-r--r--helix-term/src/ui/popup.rs4
-rw-r--r--helix-term/src/ui/prompt.rs8
7 files changed, 45 insertions, 18 deletions
diff --git a/helix-term/src/ui/completion.rs b/helix-term/src/ui/completion.rs
index 6a743632..87913a8c 100644
--- a/helix-term/src/ui/completion.rs
+++ b/helix-term/src/ui/completion.rs
@@ -298,7 +298,7 @@ impl Completion {
}
impl Component for Completion {
- fn handle_event(&mut self, event: Event, cx: &mut Context) -> EventResult {
+ fn handle_event(&mut self, event: &Event, cx: &mut Context) -> EventResult {
// let the Editor handle Esc instead
if let Event::Key(KeyEvent {
code: KeyCode::Esc, ..
diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs
index 60cab905..7326b70d 100644
--- a/helix-term/src/ui/editor.rs
+++ b/helix-term/src/ui/editor.rs
@@ -936,7 +936,7 @@ impl EditorView {
impl EditorView {
fn handle_mouse_event(
&mut self,
- event: MouseEvent,
+ event: &MouseEvent,
cxt: &mut commands::Context,
) -> EventResult {
let config = cxt.editor.config();
@@ -946,7 +946,7 @@ impl EditorView {
column,
modifiers,
..
- } = event;
+ } = *event;
let pos_and_view = |editor: &Editor, row, column| {
editor.tree.views().find_map(|(view, _focus)| {
@@ -1115,7 +1115,7 @@ impl EditorView {
impl Component for EditorView {
fn handle_event(
&mut self,
- event: Event,
+ event: &Event,
context: &mut crate::compositor::Context,
) -> EventResult {
let mut cx = commands::Context {
@@ -1128,6 +1128,23 @@ impl Component for EditorView {
};
match event {
+ Event::Paste(contents) => {
+ cx.count = cx.editor.count;
+ commands::paste_bracketed_value(&mut cx, contents.clone());
+ cx.editor.count = None;
+
+ let config = cx.editor.config();
+ let (view, doc) = current!(cx.editor);
+ view.ensure_cursor_in_view(doc, config.scrolloff);
+
+ // Store a history state if not in insert mode. Otherwise wait till we exit insert
+ // to include any edits to the paste in the history state.
+ if doc.mode() != Mode::Insert {
+ doc.append_changes_to_history(view.id);
+ }
+
+ EventResult::Consumed(None)
+ }
Event::Resize(_width, _height) => {
// Ignore this event, we handle resizing just before rendering to screen.
// Handling it here but not re-rendering will cause flashing
diff --git a/helix-term/src/ui/menu.rs b/helix-term/src/ui/menu.rs
index ce51ecbc..1d247b1a 100644
--- a/helix-term/src/ui/menu.rs
+++ b/helix-term/src/ui/menu.rs
@@ -225,9 +225,9 @@ impl<T: Item> Menu<T> {
use super::PromptEvent as MenuEvent;
impl<T: Item + 'static> Component for Menu<T> {
- fn handle_event(&mut self, event: Event, cx: &mut Context) -> EventResult {
+ fn handle_event(&mut self, event: &Event, cx: &mut Context) -> EventResult {
let event = match event {
- Event::Key(event) => event,
+ Event::Key(event) => *event,
_ => return EventResult::Ignored(None),
};
diff --git a/helix-term/src/ui/overlay.rs b/helix-term/src/ui/overlay.rs
index 1cd60be5..0b8a93ae 100644
--- a/helix-term/src/ui/overlay.rs
+++ b/helix-term/src/ui/overlay.rs
@@ -61,7 +61,7 @@ impl<T: Component + 'static> Component for Overlay<T> {
Some((width, height))
}
- fn handle_event(&mut self, event: Event, ctx: &mut Context) -> EventResult {
+ fn handle_event(&mut self, event: &Event, ctx: &mut Context) -> EventResult {
self.content.handle_event(event, ctx)
}
diff --git a/helix-term/src/ui/picker.rs b/helix-term/src/ui/picker.rs
index 169aeadd..2878fc90 100644
--- a/helix-term/src/ui/picker.rs
+++ b/helix-term/src/ui/picker.rs
@@ -260,7 +260,7 @@ impl<T: Item + 'static> Component for FilePicker<T> {
}
}
- fn handle_event(&mut self, event: Event, ctx: &mut Context) -> EventResult {
+ fn handle_event(&mut self, event: &Event, ctx: &mut Context) -> EventResult {
// TODO: keybinds for scrolling preview
self.picker.handle_event(event, ctx)
}
@@ -476,6 +476,14 @@ impl<T: Item> Picker<T> {
pub fn toggle_preview(&mut self) {
self.show_preview = !self.show_preview;
}
+
+ fn prompt_handle_event(&mut self, event: &Event, cx: &mut Context) -> EventResult {
+ if let EventResult::Consumed(_) = self.prompt.handle_event(event, cx) {
+ // TODO: recalculate only if pattern changed
+ self.score();
+ }
+ EventResult::Consumed(None)
+ }
}
// process:
@@ -489,9 +497,10 @@ impl<T: Item + 'static> Component for Picker<T> {
Some(viewport)
}
- fn handle_event(&mut self, event: Event, cx: &mut Context) -> EventResult {
+ fn handle_event(&mut self, event: &Event, cx: &mut Context) -> EventResult {
let key_event = match event {
- Event::Key(event) => event,
+ Event::Key(event) => *event,
+ Event::Paste(..) => return self.prompt_handle_event(event, cx),
Event::Resize(..) => return EventResult::Consumed(None),
_ => return EventResult::Ignored(None),
};
@@ -548,10 +557,7 @@ impl<T: Item + 'static> Component for Picker<T> {
self.toggle_preview();
}
_ => {
- if let EventResult::Consumed(_) = self.prompt.handle_event(event, cx) {
- // TODO: recalculate only if pattern changed
- self.score();
- }
+ self.prompt_handle_event(event, cx);
}
}
diff --git a/helix-term/src/ui/popup.rs b/helix-term/src/ui/popup.rs
index af8e53c5..3c140da4 100644
--- a/helix-term/src/ui/popup.rs
+++ b/helix-term/src/ui/popup.rs
@@ -138,9 +138,9 @@ impl<T: Component> Popup<T> {
}
impl<T: Component> Component for Popup<T> {
- fn handle_event(&mut self, event: Event, cx: &mut Context) -> EventResult {
+ fn handle_event(&mut self, event: &Event, cx: &mut Context) -> EventResult {
let key = match event {
- Event::Key(event) => event,
+ Event::Key(event) => *event,
Event::Resize(_, _) => {
// TODO: calculate inner area, call component's handle_event with that area
return EventResult::Ignored(None);
diff --git a/helix-term/src/ui/prompt.rs b/helix-term/src/ui/prompt.rs
index 4cb38fb0..5e8cd1f5 100644
--- a/helix-term/src/ui/prompt.rs
+++ b/helix-term/src/ui/prompt.rs
@@ -466,9 +466,13 @@ impl Prompt {
}
impl Component for Prompt {
- fn handle_event(&mut self, event: Event, cx: &mut Context) -> EventResult {
+ fn handle_event(&mut self, event: &Event, cx: &mut Context) -> EventResult {
let event = match event {
- Event::Key(event) => event,
+ Event::Paste(data) => {
+ self.insert_str(data);
+ return EventResult::Consumed(None);
+ }
+ Event::Key(event) => *event,
Event::Resize(..) => return EventResult::Consumed(None),
_ => return EventResult::Ignored(None),
};