mirror of
https://github.com/rust-lang/rustlings.git
synced 2024-12-27 00:00:03 +03:00
Don't listen on keys with modifiers
This commit is contained in:
parent
2e1a87d7d3
commit
e79bc727f0
12
src/list.rs
12
src/list.rs
|
@ -1,6 +1,6 @@
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use crossterm::{
|
use crossterm::{
|
||||||
event::{self, Event, KeyCode, KeyEventKind},
|
event::{self, Event, KeyCode, KeyEventKind, KeyModifiers},
|
||||||
terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen},
|
terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen},
|
||||||
ExecutableCommand,
|
ExecutableCommand,
|
||||||
};
|
};
|
||||||
|
@ -28,10 +28,16 @@ pub fn list(app_state: &mut AppState) -> Result<()> {
|
||||||
|
|
||||||
let key = loop {
|
let key = loop {
|
||||||
match event::read()? {
|
match event::read()? {
|
||||||
Event::Key(key) => match key.kind {
|
Event::Key(key) => {
|
||||||
|
if key.modifiers != KeyModifiers::NONE {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
match key.kind {
|
||||||
KeyEventKind::Press | KeyEventKind::Repeat => break key,
|
KeyEventKind::Press | KeyEventKind::Repeat => break key,
|
||||||
KeyEventKind::Release => (),
|
KeyEventKind::Release => (),
|
||||||
},
|
}
|
||||||
|
}
|
||||||
// Redraw
|
// Redraw
|
||||||
Event::Resize(_, _) => continue 'outer,
|
Event::Resize(_, _) => continue 'outer,
|
||||||
// Ignore
|
// Ignore
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use crossterm::event::{self, Event, KeyCode, KeyEventKind};
|
use crossterm::event::{self, Event, KeyCode, KeyEventKind, KeyModifiers};
|
||||||
use std::sync::mpsc::Sender;
|
use std::sync::mpsc::Sender;
|
||||||
|
|
||||||
use super::WatchEvent;
|
use super::WatchEvent;
|
||||||
|
@ -26,6 +26,10 @@ pub fn terminal_event_handler(tx: Sender<WatchEvent>) {
|
||||||
|
|
||||||
match terminal_event {
|
match terminal_event {
|
||||||
Event::Key(key) => {
|
Event::Key(key) => {
|
||||||
|
if key.modifiers != KeyModifiers::NONE {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
match key.kind {
|
match key.kind {
|
||||||
KeyEventKind::Release => continue,
|
KeyEventKind::Release => continue,
|
||||||
KeyEventKind::Press | KeyEventKind::Repeat => (),
|
KeyEventKind::Press | KeyEventKind::Repeat => (),
|
||||||
|
|
Loading…
Reference in a new issue