Skip to content

Commit 52cf6fd

Browse files
committed
Update to crossterm-0.25
1 parent d773a6e commit 52cf6fd

File tree

7 files changed

+36
-6
lines changed

7 files changed

+36
-6
lines changed

Cargo.lock

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

helix-term/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ which = "4.2"
3838

3939
tokio = { version = "1", features = ["rt", "rt-multi-thread", "io-util", "io-std", "time", "process", "macros", "fs", "parking_lot"] }
4040
tui = { 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"] }
4242
signal-hook = "0.3"
4343
tokio-stream = "0.1"
4444
futures-util = { version = "0.3", features = ["std", "async-await"], default-features = false }

helix-term/src/ui/editor.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1249,6 +1249,7 @@ impl Component for EditorView {
12491249
}
12501250

12511251
Event::Mouse(event) => self.handle_mouse_event(event, &mut cx),
1252+
Event::FocusGained | Event::FocusLost => EventResult::Ignored(None),
12521253
}
12531254
}
12541255

helix-tui/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ default = ["crossterm"]
1919
bitflags = "1.3"
2020
cassowary = "0.3"
2121
unicode-segmentation = "1.9"
22-
crossterm = { version = "0.24", optional = true }
22+
crossterm = { version = "0.25", optional = true }
2323
serde = { version = "1", "optional" = true, features = ["derive"]}
2424
helix-view = { version = "0.6", path = "../helix-view", features = ["term"] }
2525
helix-core = { version = "0.6", path = "../helix-core" }

helix-view/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ anyhow = "1"
1919
helix-core = { version = "0.6", path = "../helix-core" }
2020
helix-lsp = { version = "0.6", path = "../helix-lsp" }
2121
helix-dap = { version = "0.6", path = "../helix-dap" }
22-
crossterm = { version = "0.24", optional = true }
22+
crossterm = { version = "0.25", optional = true }
2323

2424
# Conversion traits
2525
once_cell = "1.13"

helix-view/src/input.rs

+19-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ pub use crate::keyboard::{KeyCode, KeyModifiers};
88

99
#[derive(Debug, PartialOrd, PartialEq, Eq, Clone, Copy, Hash)]
1010
pub enum Event {
11+
FocusGained,
12+
FocusLost,
1113
Key(KeyEvent),
1214
Mouse(MouseEvent),
1315
Resize(u16, u16),
@@ -271,6 +273,11 @@ impl From<crossterm::event::Event> for Event {
271273
crossterm::event::Event::Key(key) => Self::Key(key.into()),
272274
crossterm::event::Event::Mouse(mouse) => Self::Mouse(mouse.into()),
273275
crossterm::event::Event::Resize(w, h) => Self::Resize(w, h),
276+
crossterm::event::Event::FocusGained => Self::FocusGained,
277+
crossterm::event::Event::FocusLost => Self::FocusLost,
278+
crossterm::event::Event::Paste(_) => {
279+
unreachable!("crossterm shouldn't emit Paste events without them being enabled")
280+
}
274281
}
275282
}
276283
}
@@ -321,7 +328,14 @@ impl From<crossterm::event::MouseButton> for MouseButton {
321328

322329
#[cfg(feature = "term")]
323330
impl From<crossterm::event::KeyEvent> for KeyEvent {
324-
fn from(crossterm::event::KeyEvent { code, modifiers }: crossterm::event::KeyEvent) -> Self {
331+
fn from(
332+
crossterm::event::KeyEvent {
333+
code,
334+
modifiers,
335+
kind: _,
336+
state: _,
337+
}: crossterm::event::KeyEvent,
338+
) -> Self {
325339
if code == crossterm::event::KeyCode::BackTab {
326340
// special case for BackTab -> Shift-Tab
327341
let mut modifiers: KeyModifiers = modifiers.into();
@@ -349,11 +363,15 @@ impl From<KeyEvent> for crossterm::event::KeyEvent {
349363
crossterm::event::KeyEvent {
350364
code: crossterm::event::KeyCode::BackTab,
351365
modifiers: modifiers.into(),
366+
kind: crossterm::event::KeyEventKind::Press,
367+
state: crossterm::event::KeyEventState::NONE,
352368
}
353369
} else {
354370
crossterm::event::KeyEvent {
355371
code: code.into(),
356372
modifiers: modifiers.into(),
373+
kind: crossterm::event::KeyEventKind::Press,
374+
state: crossterm::event::KeyEventState::NONE,
357375
}
358376
}
359377
}

helix-view/src/keyboard.rs

+11
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,17 @@ impl From<crossterm::event::KeyCode> for KeyCode {
147147
CKeyCode::Char(character) => KeyCode::Char(character),
148148
CKeyCode::Null => KeyCode::Null,
149149
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+
),
150161
}
151162
}
152163
}

0 commit comments

Comments
 (0)