From 2b005590418626bdd3b4151fb8d98fd688c8cd08 Mon Sep 17 00:00:00 2001 From: Ora9 Date: Wed, 22 Jul 2026 00:49:26 +0200 Subject: [PATCH] feat: shift-tab make switch modes in reverse order --- src/app.rs | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/src/app.rs b/src/app.rs index 689a19a..7c79017 100644 --- a/src/app.rs +++ b/src/app.rs @@ -27,6 +27,24 @@ pub enum CurrentDisplayMode { Spectroscope, } +impl CurrentDisplayMode { + pub fn switch(&self) -> Self { + match self { + Self::Oscilloscope => Self::Vectorscope, + Self::Vectorscope => Self::Spectroscope, + Self::Spectroscope => Self::Oscilloscope, + } + } + + pub fn switch_reverse(&self) -> Self { + match self { + Self::Oscilloscope => Self::Spectroscope, + Self::Spectroscope => Self::Vectorscope, + Self::Vectorscope => Self::Oscilloscope, + } + } +} + pub struct App { #[allow(unused)] channels: u8, @@ -202,20 +220,8 @@ impl App { KeyCode::Char('s') => self.graph.scatter = !self.graph.scatter, KeyCode::Char('h') => self.graph.show_ui = !self.graph.show_ui, KeyCode::Char('r') => self.graph.references = !self.graph.references, - KeyCode::Tab => { - // switch modes - match self.mode { - CurrentDisplayMode::Oscilloscope => { - self.mode = CurrentDisplayMode::Vectorscope - } - CurrentDisplayMode::Vectorscope => { - self.mode = CurrentDisplayMode::Spectroscope - } - CurrentDisplayMode::Spectroscope => { - self.mode = CurrentDisplayMode::Oscilloscope - } - } - } + KeyCode::Tab => self.mode = self.mode.switch(), + KeyCode::BackTab => self.mode = self.mode.switch_reverse(), KeyCode::Esc => { self.graph.samples = self.graph.width; self.graph.scale = 1.;