mirror of
https://github.com/xvxx/phetch
synced 2024-11-15 00:12:50 +00:00
quit, at least
This commit is contained in:
parent
add433141a
commit
2750aec73a
12
src/page.rs
12
src/page.rs
@ -46,18 +46,6 @@ impl View for PageView {
|
|||||||
self.input.pop();
|
self.input.pop();
|
||||||
Action::None
|
Action::None
|
||||||
}
|
}
|
||||||
Key::Backspace => {
|
|
||||||
if self.input.is_empty() {
|
|
||||||
Action::Back
|
|
||||||
} else {
|
|
||||||
self.input.pop();
|
|
||||||
Action::None
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Key::Delete => {
|
|
||||||
self.input.pop();
|
|
||||||
Action::None
|
|
||||||
}
|
|
||||||
Key::Ctrl('c') => {
|
Key::Ctrl('c') => {
|
||||||
if self.input.len() > 0 {
|
if self.input.len() > 0 {
|
||||||
self.input.clear();
|
self.input.clear();
|
||||||
|
@ -88,14 +88,17 @@ impl UI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn respond_to_user(&mut self) {
|
fn respond_to_user(&mut self) {
|
||||||
self.process_input();
|
match self.process_input() {
|
||||||
|
Action::Quit => std::process::exit(1),
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn process_input(&mut self) -> Action {
|
fn process_input(&mut self) -> Action {
|
||||||
let stdin = stdin();
|
let stdin = stdin();
|
||||||
let mut stdout = stdout().into_raw_mode().unwrap();
|
let mut stdout = stdout().into_raw_mode().unwrap();
|
||||||
stdout.flush().unwrap();
|
stdout.flush().unwrap();
|
||||||
let mut page = self.mut_view().expect("expected page to be loaded");
|
let page = self.mut_view().expect("expected page to be loaded");
|
||||||
|
|
||||||
for c in stdin.keys() {
|
for c in stdin.keys() {
|
||||||
let key = c.expect("UI error on stdin.keys");
|
let key = c.expect("UI error on stdin.keys");
|
||||||
|
Loading…
Reference in New Issue
Block a user