ESC now resets the form and session.

This commit is contained in:
Antoine POPINEAU 2021-06-23 11:53:35 +02:00
parent 0c5b66df2d
commit 0b21921b4d
No known key found for this signature in database
GPG Key ID: A78AC64694F84063
3 changed files with 10 additions and 1 deletions

View File

@ -1,4 +1,4 @@
name: Development unpublished build
name: Development build
on:
push:

View File

@ -6,6 +6,7 @@ use termion::event::Key;
use crate::{
event::{Event, Events},
ipc::cancel,
ui::{PowerOption, POWER_OPTIONS},
Greeter, Mode,
};
@ -13,6 +14,11 @@ use crate::{
pub fn handle(greeter: &mut Greeter, events: &Events) -> Result<(), Box<dyn Error>> {
if let Event::Input(input) = events.next()? {
match input {
Key::Esc => {
cancel(greeter);
greeter.reset();
}
Key::Left => greeter.cursor_offset -= 1,
Key::Right => greeter.cursor_offset += 1,

View File

@ -24,6 +24,7 @@ use crate::{info::capslock_status, Greeter, Mode};
pub use self::power::{Option as PowerOption, OPTIONS as POWER_OPTIONS};
const RESET: &str = "Reset";
const SESSIONS: &str = "Choose session";
const CHANGE_COMMAND: &str = "Change command";
const COMMAND: &str = "COMMAND";
@ -80,6 +81,8 @@ pub fn draw(terminal: &mut Terminal<TermionBackend<RawTerminal<io::Stdout>>>, gr
let command = greeter.command.clone().unwrap_or_else(|| "-".to_string());
let status_left_text = Spans::from(vec![
status_label("ESC"),
status_value(RESET),
status_label("F2"),
status_value(CHANGE_COMMAND),
status_label("F3"),