on master help sign in
Update to crossterm-0.25 (#3390)
18909aaCharlie Groves
Cargo.lock+2−2
@@ -152,9 +152,9 @@ dependencies = [
152
152
153[[package]]
153[[package]]
154name = "crossterm"
154name = "crossterm"
155−version = "0.24.0"
155+version = "0.25.0"
156source = "registry+https://github.com/rust-lang/crates.io-index"
156source = "registry+https://github.com/rust-lang/crates.io-index"
157−checksum = "ab9f7409c70a38a56216480fba371ee460207dd8926ccf5b4160591759559170"
157+checksum = "e64e6c0fbe2c17357405f7c758c1ef960fce08bdfb2c03d88d2a18d7e09c4b67"
158dependencies = [
158dependencies = [
159 "bitflags",
159 "bitflags",
160 "crossterm_winapi",
160 "crossterm_winapi",
helix-term/Cargo.toml+1−1
@@ -38,7 +38,7 @@ which = "4.2"
38
38
39tokio = { version = "1", features = ["rt", "rt-multi-thread", "io-util", "io-std", "time", "process", "macros", "fs", "parking_lot"] }
39tokio = { version = "1", features = ["rt", "rt-multi-thread", "io-util", "io-std", "time", "process", "macros", "fs", "parking_lot"] }
40tui = { path = "../helix-tui", package = "helix-tui", default-features = false, features = ["crossterm"] }
40tui = { path = "../helix-tui", package = "helix-tui", default-features = false, features = ["crossterm"] }
41−crossterm = { version = "0.24", features = ["event-stream"] }
41+crossterm = { version = "0.25", features = ["event-stream"] }
42signal-hook = "0.3"
42signal-hook = "0.3"
43tokio-stream = "0.1"
43tokio-stream = "0.1"
44futures-util = { version = "0.3", features = ["std", "async-await"], default-features = false }
44futures-util = { version = "0.3", features = ["std", "async-await"], default-features = false }
helix-term/src/ui/editor.rs+1
@@ -1253,6 +1253,7 @@ impl Component for EditorView {
1253 }
1253 }
1254
1254
1255 Event::Mouse(event) => self.handle_mouse_event(event, &mut cx),
1255 Event::Mouse(event) => self.handle_mouse_event(event, &mut cx),
1256+ Event::FocusGained | Event::FocusLost => EventResult::Ignored(None),
1256 }
1257 }
1257 }
1258 }
1258
1259
helix-tui/Cargo.toml+1−1
@@ -19,7 +19,7 @@ default = ["crossterm"]
19bitflags = "1.3"
19bitflags = "1.3"
20cassowary = "0.3"
20cassowary = "0.3"
21unicode-segmentation = "1.9"
21unicode-segmentation = "1.9"
22−crossterm = { version = "0.24", optional = true }
22+crossterm = { version = "0.25", optional = true }
23serde = { version = "1", "optional" = true, features = ["derive"]}
23serde = { version = "1", "optional" = true, features = ["derive"]}
24helix-view = { version = "0.6", path = "../helix-view", features = ["term"] }
24helix-view = { version = "0.6", path = "../helix-view", features = ["term"] }
25helix-core = { version = "0.6", path = "../helix-core" }
25helix-core = { version = "0.6", path = "../helix-core" }
helix-view/Cargo.toml+1−1
@@ -19,7 +19,7 @@ anyhow = "1"
19helix-core = { version = "0.6", path = "../helix-core" }
19helix-core = { version = "0.6", path = "../helix-core" }
20helix-lsp = { version = "0.6", path = "../helix-lsp" }
20helix-lsp = { version = "0.6", path = "../helix-lsp" }
21helix-dap = { version = "0.6", path = "../helix-dap" }
21helix-dap = { version = "0.6", path = "../helix-dap" }
22−crossterm = { version = "0.24", optional = true }
22+crossterm = { version = "0.25", optional = true }
23
23
24# Conversion traits
24# Conversion traits
25once_cell = "1.13"
25once_cell = "1.13"
helix-view/src/input.rs+17−1
@@ -8,6 +8,8 @@ pub use crate::keyboard::{KeyCode, KeyModifiers};
8
8
9#[derive(Debug, PartialOrd, PartialEq, Eq, Clone, Copy, Hash)]
9#[derive(Debug, PartialOrd, PartialEq, Eq, Clone, Copy, Hash)]
10pub enum Event {
10pub enum Event {
11+ FocusGained,
12+ FocusLost,
11 Key(KeyEvent),
13 Key(KeyEvent),
12 Mouse(MouseEvent),
14 Mouse(MouseEvent),
13 Resize(u16, u16),
15 Resize(u16, u16),
@@ -57,6 +59,7 @@ pub enum MouseButton {
57pub struct KeyEvent {
59pub struct KeyEvent {
58 pub code: KeyCode,
60 pub code: KeyCode,
59 pub modifiers: KeyModifiers,
61 pub modifiers: KeyModifiers,
62+ // TODO: crossterm now supports kind & state if terminal supports kitty's extended protocol
60}
63}
61
64
62impl KeyEvent {
65impl KeyEvent {
@@ -271,6 +274,11 @@ impl From<crossterm::event::Event> for Event {
271 crossterm::event::Event::Key(key) => Self::Key(key.into()),
274 crossterm::event::Event::Key(key) => Self::Key(key.into()),
272 crossterm::event::Event::Mouse(mouse) => Self::Mouse(mouse.into()),
275 crossterm::event::Event::Mouse(mouse) => Self::Mouse(mouse.into()),
273 crossterm::event::Event::Resize(w, h) => Self::Resize(w, h),
276 crossterm::event::Event::Resize(w, h) => Self::Resize(w, h),
277+ crossterm::event::Event::FocusGained => Self::FocusGained,
278+ crossterm::event::Event::FocusLost => Self::FocusLost,
279+ crossterm::event::Event::Paste(_) => {
280+ unreachable!("crossterm shouldn't emit Paste events without them being enabled")
281+ }
274 }
282 }
275 }
283 }
276}
284}
@@ -321,7 +329,11 @@ impl From<crossterm::event::MouseButton> for MouseButton {
321
329
322#[cfg(feature = "term")]
330#[cfg(feature = "term")]
323impl From<crossterm::event::KeyEvent> for KeyEvent {
331impl From<crossterm::event::KeyEvent> for KeyEvent {
332+ fn from(
324− fn from(crossterm::event::KeyEvent { code, modifiers }: crossterm::event::KeyEvent) -> Self {
333+ crossterm::event::KeyEvent {
334+ code, modifiers, ..
335+ }: crossterm::event::KeyEvent,
336+ ) -> Self {
325 if code == crossterm::event::KeyCode::BackTab {
337 if code == crossterm::event::KeyCode::BackTab {
326 // special case for BackTab -> Shift-Tab
338 // special case for BackTab -> Shift-Tab
327 let mut modifiers: KeyModifiers = modifiers.into();
339 let mut modifiers: KeyModifiers = modifiers.into();
@@ -349,11 +361,15 @@ impl From<KeyEvent> for crossterm::event::KeyEvent {
349 crossterm::event::KeyEvent {
361 crossterm::event::KeyEvent {
350 code: crossterm::event::KeyCode::BackTab,
362 code: crossterm::event::KeyCode::BackTab,
351 modifiers: modifiers.into(),
363 modifiers: modifiers.into(),
364+ kind: crossterm::event::KeyEventKind::Press,
365+ state: crossterm::event::KeyEventState::NONE,
352 }
366 }
353 } else {
367 } else {
354 crossterm::event::KeyEvent {
368 crossterm::event::KeyEvent {
355 code: code.into(),
369 code: code.into(),
356 modifiers: modifiers.into(),
370 modifiers: modifiers.into(),
371+ kind: crossterm::event::KeyEventKind::Press,
372+ state: crossterm::event::KeyEventState::NONE,
357 }
373 }
358 }
374 }
359 }
375 }
helix-view/src/keyboard.rs+11
@@ -147,6 +147,17 @@ impl From<crossterm::event::KeyCode> for KeyCode {
147 CKeyCode::Char(character) => KeyCode::Char(character),
147 CKeyCode::Char(character) => KeyCode::Char(character),
148 CKeyCode::Null => KeyCode::Null,
148 CKeyCode::Null => KeyCode::Null,
149 CKeyCode::Esc => KeyCode::Esc,
149 CKeyCode::Esc => KeyCode::Esc,
150+ CKeyCode::CapsLock
151+ | CKeyCode::ScrollLock
152+ | CKeyCode::NumLock
153+ | CKeyCode::PrintScreen
154+ | CKeyCode::Pause
155+ | CKeyCode::Menu
156+ | CKeyCode::KeypadBegin
157+ | CKeyCode::Media(_)
158+ | CKeyCode::Modifier(_) => unreachable!(
159+ "Shouldn't get this key without enabling DISAMBIGUATE_ESCAPE_CODES in crossterm"
160+ ),
150 }
161 }
151 }
162 }
152}
163}