aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src/ui/editor.rs
diff options
context:
space:
mode:
authorGokul Soumya2022-08-09 01:31:26 +0000
committerGitHub2022-08-09 01:31:26 +0000
commit634b6d455f064116c609e7cfa1b2b45e51f40029 (patch)
treead06ce4c4f0131d74cc19b6beed000ff043664d8 /helix-term/src/ui/editor.rs
parent4ce5a94552d887b9b14000dfdd1abe76a6d5f315 (diff)
Add custom event type replacing crossterm's Event (#3169)
Ported over from 61365dfbf3 in the `gui` branch. This will allow adding our own events, most notably an idle timer event (useful for adding debounced input in [dynamic pickers][1] used by interactive global search and workspace symbols). [1]: https://github.com/helix-editor/helix/pull/3110 Co-authored-by: Blaž Hrastnik <blaz@mxxn.io>
Diffstat (limited to 'helix-term/src/ui/editor.rs')
-rw-r--r--helix-term/src/ui/editor.rs14
1 files changed, 6 insertions, 8 deletions
diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs
index 6b316374..401d284e 100644
--- a/helix-term/src/ui/editor.rs
+++ b/helix-term/src/ui/editor.rs
@@ -1,6 +1,6 @@
use crate::{
commands,
- compositor::{Component, Context, EventResult},
+ compositor::{Component, Context, Event, EventResult},
job, key,
keymap::{KeymapResult, Keymaps},
ui::{Completion, ProgressSpinners},
@@ -19,13 +19,12 @@ use helix_view::{
document::Mode,
editor::{CompleteAction, CursorShapeConfig},
graphics::{Color, CursorKind, Modifier, Rect, Style},
- input::KeyEvent,
+ input::{KeyEvent, MouseButton, MouseEvent, MouseEventKind},
keyboard::{KeyCode, KeyModifiers},
Document, Editor, Theme, View,
};
use std::borrow::Cow;
-use crossterm::event::{Event, MouseButton, MouseEvent, MouseEventKind};
use tui::buffer::Buffer as Surface;
use super::lsp::SignatureHelp;
@@ -966,7 +965,7 @@ impl EditorView {
if let Some((pos, view_id)) = pos_and_view(editor, row, column) {
let doc = editor.document_mut(editor.tree.get(view_id).doc).unwrap();
- if modifiers == crossterm::event::KeyModifiers::ALT {
+ if modifiers == KeyModifiers::ALT {
let selection = doc.selection(view_id).clone();
doc.set_selection(view_id, selection.push(Range::point(pos)));
} else {
@@ -1068,7 +1067,7 @@ impl EditorView {
let line = coords.row + view.offset.row;
if let Ok(pos) = doc.text().try_line_to_char(line) {
doc.set_selection(view_id, Selection::point(pos));
- if modifiers == crossterm::event::KeyModifiers::ALT {
+ if modifiers == KeyModifiers::ALT {
commands::MappableCommand::dap_edit_log.execute(cxt);
} else {
commands::MappableCommand::dap_edit_condition.execute(cxt);
@@ -1087,7 +1086,7 @@ impl EditorView {
return EventResult::Ignored(None);
}
- if modifiers == crossterm::event::KeyModifiers::ALT {
+ if modifiers == KeyModifiers::ALT {
commands::MappableCommand::replace_selections_with_primary_clipboard
.execute(cxt);
@@ -1132,9 +1131,8 @@ impl Component for EditorView {
// Handling it here but not re-rendering will cause flashing
EventResult::Consumed(None)
}
- Event::Key(key) => {
+ Event::Key(mut key) => {
cx.editor.reset_idle_timer();
- let mut key = KeyEvent::from(key);
canonicalize_key(&mut key);
// clear status