forked from trinitrix/core
1
0
Fork 0

feature (ui): implemented reverse plane cycling using <Shift>+<Tab> as requested in #5

This commit is contained in:
antifallobst 2023-07-09 23:04:59 +02:00
parent 7347d0c4f1
commit 8d6e7c976e
Signed by: antifallobst
GPG Key ID: 2B4F402172791BAF
2 changed files with 51 additions and 0 deletions

View File

@ -126,6 +126,12 @@ impl Event {
}) => {
app.ui.cycle_main_input_position();
}
crossterm::event::Event::Key(KeyEvent {
code: KeyCode::BackTab,
..
}) => {
app.ui.cycle_main_input_position_rev();
}
input => match app.ui.input_position() {
ui::MainInputPosition::MessageCompose => {
match input {
@ -256,6 +262,12 @@ impl Event {
}) => {
ui.cycle_input_position();
}
crossterm::event::Event::Key(KeyEvent {
code: KeyCode::BackTab,
..
}) => {
ui.cycle_input_position_rev();
}
crossterm::event::Event::Key(KeyEvent {
code: KeyCode::Enter,
..

View File

@ -155,6 +155,35 @@ impl SetupUI<'_> {
};
}
pub fn cycle_input_position_rev(&mut self) {
self.input_position = match self.input_position {
SetupInputPosition::Homeserver => {
textarea_inactivate(&mut self.homeserver);
textarea_inactivate(&mut self.username);
textarea_inactivate(&mut self.password);
SetupInputPosition::Ok
}
SetupInputPosition::Username => {
textarea_activate(&mut self.homeserver);
textarea_inactivate(&mut self.username);
textarea_inactivate(&mut self.password);
SetupInputPosition::Homeserver
}
SetupInputPosition::Password => {
textarea_inactivate(&mut self.homeserver);
textarea_activate(&mut self.username);
textarea_inactivate(&mut self.password);
SetupInputPosition::Username
}
SetupInputPosition::Ok => {
textarea_inactivate(&mut self.homeserver);
textarea_inactivate(&mut self.username);
textarea_activate(&mut self.password);
SetupInputPosition::Password
}
};
}
pub fn input_position(&self) -> &SetupInputPosition {
&self.input_position
}
@ -251,6 +280,16 @@ impl UI<'_> {
};
}
pub fn cycle_main_input_position_rev(&mut self) {
self.input_position = match self.input_position {
MainInputPosition::Status => MainInputPosition::RoomInfo,
MainInputPosition::Rooms => MainInputPosition::Status,
MainInputPosition::Messages => MainInputPosition::Rooms,
MainInputPosition::MessageCompose => MainInputPosition::Messages,
MainInputPosition::RoomInfo => MainInputPosition::MessageCompose,
};
}
pub fn input_position(&self) -> &MainInputPosition {
&self.input_position
}