Yes/No dialogs are now answerable by pressing Y or N on your keyboard

This commit is contained in:
veeso
2022-08-30 15:29:34 +02:00
parent 96df152220
commit 6a5c248d35
7 changed files with 103 additions and 5 deletions

View File

@@ -6,7 +6,7 @@ use super::{CommonMsg, Msg, ViewLayout};
use tui_realm_stdlib::{List, Paragraph, Radio, Span};
use tuirealm::command::{Cmd, CmdResult, Direction, Position};
use tuirealm::event::{Key, KeyEvent};
use tuirealm::event::{Key, KeyEvent, KeyModifiers};
use tuirealm::props::{Alignment, BorderSides, BorderType, Borders, Color, TableBuilder, TextSpan};
use tuirealm::{Component, Event, MockComponent, NoUserEvent, State, StateValue};
@@ -296,6 +296,14 @@ impl Component<Msg, NoUserEvent> for SavePopup {
self.perform(Cmd::Move(Direction::Right));
Some(Msg::None)
}
Event::Keyboard(KeyEvent {
code: Key::Char('y'),
modifiers: KeyModifiers::NONE,
}) => Some(Msg::Common(CommonMsg::SaveConfig)),
Event::Keyboard(KeyEvent {
code: Key::Char('n'),
modifiers: KeyModifiers::NONE,
}) => Some(Msg::Common(CommonMsg::CloseSavePopup)),
Event::Keyboard(KeyEvent {
code: Key::Enter, ..
}) => {

View File

@@ -58,6 +58,14 @@ impl Component<Msg, NoUserEvent> for DelSshKeyPopup {
self.perform(Cmd::Move(Direction::Right));
Some(Msg::None)
}
Event::Keyboard(KeyEvent {
code: Key::Char('y'),
modifiers: KeyModifiers::NONE,
}) => Some(Msg::Ssh(SshMsg::DeleteSshKey)),
Event::Keyboard(KeyEvent {
code: Key::Char('n'),
modifiers: KeyModifiers::NONE,
}) => Some(Msg::Ssh(SshMsg::CloseDelSshKeyPopup)),
Event::Keyboard(KeyEvent {
code: Key::Enter, ..
}) => {

View File

@@ -20,8 +20,6 @@ impl SetupActivity {
self.new_app(ViewLayout::SshKeys);
// Load keys
self.reload_ssh_keys();
// Give focus
assert!(self.app.active(&Id::Ssh(IdSsh::SshKeys)).is_ok());
}
pub(crate) fn view_ssh_keys(&mut self) {
@@ -137,5 +135,6 @@ impl SetupActivity {
vec![]
)
.is_ok());
assert!(self.app.active(&Id::Ssh(IdSsh::SshKeys)).is_ok());
}
}