mirror of
https://github.com/apognu/tuigreet.git
synced 2024-09-11 07:25:29 +03:00
Add a previous buffer to not lose current entry when cycling through a popup.
This commit is contained in:
parent
d215a2f390
commit
a6da45b640
@ -104,6 +104,9 @@ pub struct Greeter {
|
||||
pub cursor_offset: i16,
|
||||
|
||||
// Buffer to be used as a temporary editing zone for the various modes.
|
||||
// Previous buffer is saved when a transient screen has to use the buffer, to
|
||||
// be able to restore it when leaving the transient screen.
|
||||
pub previous_buffer: Option<String>,
|
||||
pub buffer: String,
|
||||
|
||||
// Define the selected session and how to resolve it.
|
||||
|
@ -53,7 +53,12 @@ pub async fn handle(greeter: Arc<RwLock<Greeter>>, input: KeyEvent, ipc: Ipc) ->
|
||||
// previous mode (close a popup, for example), or cancel the `greetd`
|
||||
// session.
|
||||
KeyEvent { code: KeyCode::Esc, .. } => match greeter.mode {
|
||||
Mode::Users | Mode::Command | Mode::Sessions | Mode::Power => {
|
||||
Mode::Command => {
|
||||
greeter.mode = greeter.previous_mode;
|
||||
greeter.buffer = greeter.previous_buffer.take().unwrap_or_default();
|
||||
}
|
||||
|
||||
Mode::Users | Mode::Sessions | Mode::Power => {
|
||||
greeter.mode = greeter.previous_mode;
|
||||
}
|
||||
|
||||
@ -77,6 +82,7 @@ pub async fn handle(greeter: Arc<RwLock<Greeter>>, input: KeyEvent, ipc: Ipc) ->
|
||||
};
|
||||
|
||||
// Set the edition buffer to the current command.
|
||||
greeter.previous_buffer = Some(greeter.buffer.clone());
|
||||
greeter.buffer = greeter.session_source.command(&greeter).map(str::to_string).unwrap_or_default();
|
||||
greeter.mode = Mode::Command;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user