mirror of
https://github.com/notohh/rustlings.git
synced 2024-11-21 21:42:23 -05:00
Prevent unneeded redraws
This commit is contained in:
parent
372290a796
commit
c4897139ae
1 changed files with 7 additions and 5 deletions
12
src/list.rs
12
src/list.rs
|
@ -80,7 +80,13 @@ pub fn list(state: &State, exercises: &[Exercise]) -> Result<()> {
|
||||||
|
|
||||||
let key = loop {
|
let key = loop {
|
||||||
match event::read()? {
|
match event::read()? {
|
||||||
Event::Key(key) => break key,
|
Event::Key(key) => {
|
||||||
|
if key.kind != KeyEventKind::Press {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
break key;
|
||||||
|
}
|
||||||
// Redraw
|
// Redraw
|
||||||
Event::Resize(_, _) => continue 'outer,
|
Event::Resize(_, _) => continue 'outer,
|
||||||
// Ignore
|
// Ignore
|
||||||
|
@ -88,10 +94,6 @@ pub fn list(state: &State, exercises: &[Exercise]) -> Result<()> {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if key.kind != KeyEventKind::Press {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
match key.code {
|
match key.code {
|
||||||
KeyCode::Char('q') => break,
|
KeyCode::Char('q') => break,
|
||||||
KeyCode::Down | KeyCode::Char('j') => {
|
KeyCode::Down | KeyCode::Char('j') => {
|
||||||
|
|
Loading…
Reference in a new issue