From 8d6e7c976e9ecf3b99a8b99da0af0e4fa2720d29 Mon Sep 17 00:00:00 2001 From: antifallobst Date: Sun, 9 Jul 2023 23:04:59 +0200 Subject: [PATCH] feature (ui): implemented reverse plane cycling using + as requested in #5 --- src/app/event.rs | 12 ++++++++++++ src/ui/mod.rs | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) diff --git a/src/app/event.rs b/src/app/event.rs index 32e519f..e5fa8b7 100644 --- a/src/app/event.rs +++ b/src/app/event.rs @@ -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, .. diff --git a/src/ui/mod.rs b/src/ui/mod.rs index 9878c30..b4f6356 100644 --- a/src/ui/mod.rs +++ b/src/ui/mod.rs @@ -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 }