diff --git a/src/app/app_tests.rs b/src/app/app_tests.rs index 6c2e921..f24d356 100644 --- a/src/app/app_tests.rs +++ b/src/app/app_tests.rs @@ -98,7 +98,7 @@ mod tests { assert!(!app.is_loading); assert!(!app.is_routing); assert!(!app.should_refresh); - assert!(!app.should_ignore_quit_key); + assert!(!app.ignore_special_keys_for_textbox_input); assert!(!app.cli_mode); } @@ -118,7 +118,7 @@ mod tests { assert!(!app.is_loading); assert!(!app.is_routing); assert!(!app.should_refresh); - assert!(!app.should_ignore_quit_key); + assert!(!app.ignore_special_keys_for_textbox_input); assert!(!app.cli_mode); } diff --git a/src/app/key_binding.rs b/src/app/key_binding.rs index f032b63..7a4d94d 100644 --- a/src/app/key_binding.rs +++ b/src/app/key_binding.rs @@ -76,7 +76,7 @@ pub const DEFAULT_KEYBINDINGS: KeyBindings = KeyBindings { }, backspace: KeyBinding { key: Key::Backspace, - alt: None, + alt: Some(Key::Ctrl('h')), desc: "backspace", }, next_servarr: KeyBinding { @@ -215,9 +215,9 @@ macro_rules! matches_key { .unwrap() == $key) }; - ($binding:ident, $key:expr, $ignore_alt_navigation:expr) => { + ($binding:ident, $key:expr, $ignore_special_keys:expr) => { $crate::app::key_binding::DEFAULT_KEYBINDINGS.$binding.key == $key - || !$ignore_alt_navigation + || !$ignore_special_keys && ($crate::app::key_binding::DEFAULT_KEYBINDINGS .$binding .alt diff --git a/src/app/key_binding_tests.rs b/src/app/key_binding_tests.rs index cc34a5c..9521098 100644 --- a/src/app/key_binding_tests.rs +++ b/src/app/key_binding_tests.rs @@ -5,44 +5,85 @@ mod test { use crate::app::key_binding::{KeyBinding, DEFAULT_KEYBINDINGS}; use crate::event::Key; + use crate::matches_key; #[rstest] - #[case(DEFAULT_KEYBINDINGS.add, Key::Char('a'), "add")] - #[case(DEFAULT_KEYBINDINGS.up, Key::Up, "up")] - #[case(DEFAULT_KEYBINDINGS.down, Key::Down, "down")] - #[case(DEFAULT_KEYBINDINGS.left, Key::Left, "left")] - #[case(DEFAULT_KEYBINDINGS.right, Key::Right, "right")] - #[case(DEFAULT_KEYBINDINGS.backspace, Key::Backspace, "backspace")] - #[case(DEFAULT_KEYBINDINGS.next_servarr, Key::Tab, "next servarr")] - #[case(DEFAULT_KEYBINDINGS.previous_servarr, Key::BackTab, "previous servarr")] - #[case(DEFAULT_KEYBINDINGS.clear, Key::Char('c'), "clear")] - #[case(DEFAULT_KEYBINDINGS.auto_search, Key::Char('S'), "auto search")] - #[case(DEFAULT_KEYBINDINGS.search, Key::Char('s'), "search")] - #[case(DEFAULT_KEYBINDINGS.settings, Key::Char('S'), "settings")] - #[case(DEFAULT_KEYBINDINGS.filter, Key::Char('f'), "filter")] - #[case(DEFAULT_KEYBINDINGS.sort, Key::Char('o'), "sort")] - #[case(DEFAULT_KEYBINDINGS.edit, Key::Char('e'), "edit")] - #[case(DEFAULT_KEYBINDINGS.events, Key::Char('e'), "events")] - #[case(DEFAULT_KEYBINDINGS.logs, Key::Char('L'), "logs")] - #[case(DEFAULT_KEYBINDINGS.tasks, Key::Char('t'), "tasks")] - #[case(DEFAULT_KEYBINDINGS.test, Key::Char('t'), "test")] - #[case(DEFAULT_KEYBINDINGS.test_all, Key::Char('T'), "test all")] - #[case(DEFAULT_KEYBINDINGS.toggle_monitoring, Key::Char('m'), "toggle monitoring")] - #[case(DEFAULT_KEYBINDINGS.refresh, Key::Ctrl('r'), "refresh")] - #[case(DEFAULT_KEYBINDINGS.update, Key::Char('u'), "update")] - #[case(DEFAULT_KEYBINDINGS.home, Key::Home, "home")] - #[case(DEFAULT_KEYBINDINGS.end, Key::End, "end")] - #[case(DEFAULT_KEYBINDINGS.delete, Key::Delete, "delete")] - #[case(DEFAULT_KEYBINDINGS.submit, Key::Enter, "submit")] - #[case(DEFAULT_KEYBINDINGS.confirm, Key::Ctrl('s'), "submit")] - #[case(DEFAULT_KEYBINDINGS.quit, Key::Char('q'), "quit")] - #[case(DEFAULT_KEYBINDINGS.esc, Key::Esc, "close")] + #[case(DEFAULT_KEYBINDINGS.add, Key::Char('a'), None, "add")] + #[case(DEFAULT_KEYBINDINGS.up, Key::Up, Some(Key::Char('k')), "up")] + #[case(DEFAULT_KEYBINDINGS.down, Key::Down, Some(Key::Char('j')), "down")] + #[case(DEFAULT_KEYBINDINGS.left, Key::Left, Some(Key::Char('h')), "left")] + #[case(DEFAULT_KEYBINDINGS.right, Key::Right, Some(Key::Char('l')), "right")] + #[case(DEFAULT_KEYBINDINGS.backspace, Key::Backspace, Some(Key::Ctrl('h')), "backspace")] + #[case(DEFAULT_KEYBINDINGS.next_servarr, Key::Tab, None, "next servarr")] + #[case(DEFAULT_KEYBINDINGS.previous_servarr, Key::BackTab, None, "previous servarr")] + #[case(DEFAULT_KEYBINDINGS.clear, Key::Char('c'), None, "clear")] + #[case(DEFAULT_KEYBINDINGS.auto_search, Key::Char('S'), None, "auto search")] + #[case(DEFAULT_KEYBINDINGS.search, Key::Char('s'), None, "search")] + #[case(DEFAULT_KEYBINDINGS.settings, Key::Char('S'), None, "settings")] + #[case(DEFAULT_KEYBINDINGS.filter, Key::Char('f'), None, "filter")] + #[case(DEFAULT_KEYBINDINGS.sort, Key::Char('o'), None, "sort")] + #[case(DEFAULT_KEYBINDINGS.edit, Key::Char('e'), None, "edit")] + #[case(DEFAULT_KEYBINDINGS.events, Key::Char('e'), None, "events")] + #[case(DEFAULT_KEYBINDINGS.logs, Key::Char('L'), None, "logs")] + #[case(DEFAULT_KEYBINDINGS.tasks, Key::Char('t'), None, "tasks")] + #[case(DEFAULT_KEYBINDINGS.test, Key::Char('t'), None, "test")] + #[case(DEFAULT_KEYBINDINGS.test_all, Key::Char('T'), None, "test all")] + #[case(DEFAULT_KEYBINDINGS.toggle_monitoring, Key::Char('m'), None, "toggle monitoring")] + #[case(DEFAULT_KEYBINDINGS.refresh, Key::Ctrl('r'), None, "refresh")] + #[case(DEFAULT_KEYBINDINGS.update, Key::Char('u'), None, "update")] + #[case(DEFAULT_KEYBINDINGS.home, Key::Home, None, "home")] + #[case(DEFAULT_KEYBINDINGS.end, Key::End, None, "end")] + #[case(DEFAULT_KEYBINDINGS.delete, Key::Delete, None, "delete")] + #[case(DEFAULT_KEYBINDINGS.submit, Key::Enter, None, "submit")] + #[case(DEFAULT_KEYBINDINGS.confirm, Key::Ctrl('s'), None, "submit")] + #[case(DEFAULT_KEYBINDINGS.quit, Key::Char('q'), None, "quit")] + #[case(DEFAULT_KEYBINDINGS.esc, Key::Esc, None, "close")] fn test_default_key_bindings_and_descriptions( #[case] key_binding: KeyBinding, #[case] expected_key: Key, + #[case] expected_alt_key: Option, #[case] expected_desc: &str, ) { assert_eq!(key_binding.key, expected_key); + assert_eq!(key_binding.alt, expected_alt_key); assert_str_eq!(key_binding.desc, expected_desc); } + + #[test] + fn test_matches_key_macro() { + let key = Key::Char('t'); + + assert!(matches_key!(test, key)); + assert!(!matches_key!(test, Key::Char('T'))); + } + + #[test] + fn test_matches_key_macro_with_alt_keybinding() { + let alt_key = Key::Char('k'); + let key = Key::Up; + + assert!(matches_key!(up, key)); + assert!(matches_key!(up, alt_key)); + assert!(!matches_key!(up, Key::Char('t'))); + } + + #[test] + fn test_matches_key_macro_with_alt_keybinding_uses_alt_key_when_ignore_special_keys_is_false() { + let alt_key = Key::Char('k'); + let key = Key::Up; + + assert!(matches_key!(up, key, false)); + assert!(matches_key!(up, alt_key, false)); + assert!(!matches_key!(up, Key::Char('t'), false)); + } + + #[test] + fn test_matches_key_macro_with_alt_keybinding_ignores_alt_key_when_ignore_special_keys_is_true() { + let alt_key = Key::Char('k'); + let key = Key::Up; + + assert!(matches_key!(up, key, true)); + assert!(!matches_key!(up, alt_key, true)); + assert!(!matches_key!(up, Key::Char('t'), true)); + } } diff --git a/src/app/mod.rs b/src/app/mod.rs index 7ea638b..d1cfbaa 100644 --- a/src/app/mod.rs +++ b/src/app/mod.rs @@ -39,7 +39,7 @@ pub struct App<'a> { pub is_routing: bool, pub is_loading: bool, pub should_refresh: bool, - pub should_ignore_quit_key: bool, + pub ignore_special_keys_for_textbox_input: bool, pub cli_mode: bool, pub data: Data<'a>, } @@ -224,7 +224,7 @@ impl Default for App<'_> { is_loading: false, is_routing: false, should_refresh: false, - should_ignore_quit_key: false, + ignore_special_keys_for_textbox_input: false, cli_mode: false, data: Data::default(), } diff --git a/src/handlers/mod.rs b/src/handlers/mod.rs index c359717..aea66f5 100644 --- a/src/handlers/mod.rs +++ b/src/handlers/mod.rs @@ -22,12 +22,12 @@ pub trait KeyEventHandler<'a, 'b, T: Into + Copy> { fn handle_key_event(&mut self) { let key = self.get_key(); match key { - _ if matches_key!(up, key, self.ignore_alt_navigation()) => { + _ if matches_key!(up, key, self.ignore_special_keys()) => { if self.is_ready() { self.handle_scroll_up(); } } - _ if matches_key!(down, key, self.ignore_alt_navigation()) => { + _ if matches_key!(down, key, self.ignore_special_keys()) => { if self.is_ready() { self.handle_scroll_down(); } @@ -47,8 +47,8 @@ pub trait KeyEventHandler<'a, 'b, T: Into + Copy> { self.handle_delete(); } } - _ if matches_key!(left, key, self.ignore_alt_navigation()) - || matches_key!(right, key, self.ignore_alt_navigation()) => + _ if matches_key!(left, key, self.ignore_special_keys()) + || matches_key!(right, key, self.ignore_special_keys()) => { self.handle_left_right_action() } @@ -73,7 +73,7 @@ pub trait KeyEventHandler<'a, 'b, T: Into + Copy> { fn accepts(active_block: T) -> bool; fn new(key: Key, app: &'a mut App<'b>, active_block: T, context: Option) -> Self; fn get_key(&self) -> Key; - fn ignore_alt_navigation(&self) -> bool; + fn ignore_special_keys(&self) -> bool; fn is_ready(&self) -> bool; fn handle_scroll_up(&mut self); fn handle_scroll_down(&mut self); diff --git a/src/handlers/radarr_handlers/blocklist/blocklist_handler_tests.rs b/src/handlers/radarr_handlers/blocklist/blocklist_handler_tests.rs index 9389285..bc76578 100644 --- a/src/handlers/radarr_handlers/blocklist/blocklist_handler_tests.rs +++ b/src/handlers/radarr_handlers/blocklist/blocklist_handler_tests.rs @@ -543,11 +543,11 @@ mod tests { } #[rstest] - fn test_blocklist_handler_ignore_alt_navigation( - #[values(true, false)] should_ignore_quit_key: bool, + fn test_blocklist_handler_ignore_special_keys( + #[values(true, false)] ignore_special_keys_for_textbox_input: bool, ) { let mut app = App::test_default(); - app.should_ignore_quit_key = should_ignore_quit_key; + app.ignore_special_keys_for_textbox_input = ignore_special_keys_for_textbox_input; let handler = BlocklistHandler::new( DEFAULT_KEYBINDINGS.esc.key, &mut app, @@ -555,7 +555,10 @@ mod tests { None, ); - assert_eq!(handler.ignore_alt_navigation(), should_ignore_quit_key); + assert_eq!( + handler.ignore_special_keys(), + ignore_special_keys_for_textbox_input + ); } #[test] diff --git a/src/handlers/radarr_handlers/blocklist/mod.rs b/src/handlers/radarr_handlers/blocklist/mod.rs index 4202814..1160781 100644 --- a/src/handlers/radarr_handlers/blocklist/mod.rs +++ b/src/handlers/radarr_handlers/blocklist/mod.rs @@ -50,8 +50,8 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for BlocklistHandler<'a, BLOCKLIST_BLOCKS.contains(&active_block) } - fn ignore_alt_navigation(&self) -> bool { - self.app.should_ignore_quit_key + fn ignore_special_keys(&self) -> bool { + self.app.ignore_special_keys_for_textbox_input } fn new( diff --git a/src/handlers/radarr_handlers/collections/collection_details_handler.rs b/src/handlers/radarr_handlers/collections/collection_details_handler.rs index bf2f8ae..70af277 100644 --- a/src/handlers/radarr_handlers/collections/collection_details_handler.rs +++ b/src/handlers/radarr_handlers/collections/collection_details_handler.rs @@ -45,8 +45,8 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for CollectionDetailsHan COLLECTION_DETAILS_BLOCKS.contains(&active_block) } - fn ignore_alt_navigation(&self) -> bool { - self.app.should_ignore_quit_key + fn ignore_special_keys(&self) -> bool { + self.app.ignore_special_keys_for_textbox_input } fn new( diff --git a/src/handlers/radarr_handlers/collections/collection_details_handler_tests.rs b/src/handlers/radarr_handlers/collections/collection_details_handler_tests.rs index 745b3bb..62fec18 100644 --- a/src/handlers/radarr_handlers/collections/collection_details_handler_tests.rs +++ b/src/handlers/radarr_handlers/collections/collection_details_handler_tests.rs @@ -280,11 +280,11 @@ mod tests { } #[rstest] - fn test_collection_details_handler_ignore_alt_navigation( - #[values(true, false)] should_ignore_quit_key: bool, + fn test_collection_details_handler_ignore_special_keys( + #[values(true, false)] ignore_special_keys_for_textbox_input: bool, ) { let mut app = App::test_default(); - app.should_ignore_quit_key = should_ignore_quit_key; + app.ignore_special_keys_for_textbox_input = ignore_special_keys_for_textbox_input; let handler = CollectionDetailsHandler::new( DEFAULT_KEYBINDINGS.esc.key, &mut app, @@ -292,7 +292,10 @@ mod tests { None, ); - assert_eq!(handler.ignore_alt_navigation(), should_ignore_quit_key); + assert_eq!( + handler.ignore_special_keys(), + ignore_special_keys_for_textbox_input + ); } #[test] diff --git a/src/handlers/radarr_handlers/collections/collections_handler_tests.rs b/src/handlers/radarr_handlers/collections/collections_handler_tests.rs index 9701226..9d59c57 100644 --- a/src/handlers/radarr_handlers/collections/collections_handler_tests.rs +++ b/src/handlers/radarr_handlers/collections/collections_handler_tests.rs @@ -590,11 +590,11 @@ mod tests { } #[rstest] - fn test_collections_handler_ignore_alt_navigation( - #[values(true, false)] should_ignore_quit_key: bool, + fn test_collections_handler_ignore_special_keys( + #[values(true, false)] ignore_special_keys_for_textbox_input: bool, ) { let mut app = App::test_default(); - app.should_ignore_quit_key = should_ignore_quit_key; + app.ignore_special_keys_for_textbox_input = ignore_special_keys_for_textbox_input; let handler = CollectionsHandler::new( DEFAULT_KEYBINDINGS.esc.key, &mut app, @@ -602,7 +602,10 @@ mod tests { None, ); - assert_eq!(handler.ignore_alt_navigation(), should_ignore_quit_key); + assert_eq!( + handler.ignore_special_keys(), + ignore_special_keys_for_textbox_input + ); } #[test] diff --git a/src/handlers/radarr_handlers/collections/edit_collection_handler.rs b/src/handlers/radarr_handlers/collections/edit_collection_handler.rs index 6936014..77426b9 100644 --- a/src/handlers/radarr_handlers/collections/edit_collection_handler.rs +++ b/src/handlers/radarr_handlers/collections/edit_collection_handler.rs @@ -68,8 +68,8 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for EditCollectionHandle EDIT_COLLECTION_BLOCKS.contains(&active_block) } - fn ignore_alt_navigation(&self) -> bool { - self.app.should_ignore_quit_key + fn ignore_special_keys(&self) -> bool { + self.app.ignore_special_keys_for_textbox_input } fn new( @@ -265,7 +265,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for EditCollectionHandle ) .into(), ); - self.app.should_ignore_quit_key = true; + self.app.ignore_special_keys_for_textbox_input = true; } ActiveRadarrBlock::EditCollectionToggleMonitored => { self @@ -314,7 +314,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for EditCollectionHandle | ActiveRadarrBlock::EditCollectionSelectQualityProfile => self.app.pop_navigation_stack(), ActiveRadarrBlock::EditCollectionRootFolderPathInput => { self.app.pop_navigation_stack(); - self.app.should_ignore_quit_key = false; + self.app.ignore_special_keys_for_textbox_input = false; } _ => (), } @@ -324,7 +324,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for EditCollectionHandle match self.active_radarr_block { ActiveRadarrBlock::EditCollectionRootFolderPathInput => { self.app.pop_navigation_stack(); - self.app.should_ignore_quit_key = false; + self.app.ignore_special_keys_for_textbox_input = false; } ActiveRadarrBlock::EditCollectionPrompt => { self.app.pop_navigation_stack(); diff --git a/src/handlers/radarr_handlers/collections/edit_collection_handler_tests.rs b/src/handlers/radarr_handlers/collections/edit_collection_handler_tests.rs index 5526ea8..8e9a0d4 100644 --- a/src/handlers/radarr_handlers/collections/edit_collection_handler_tests.rs +++ b/src/handlers/radarr_handlers/collections/edit_collection_handler_tests.rs @@ -458,7 +458,7 @@ mod tests { #[test] fn test_edit_collection_root_folder_path_input_submit() { let mut app = App::test_default(); - app.should_ignore_quit_key = true; + app.ignore_special_keys_for_textbox_input = true; app.data.radarr_data.edit_collection_modal = Some(EditCollectionModal { path: "Test Path".into(), ..EditCollectionModal::default() @@ -474,7 +474,7 @@ mod tests { ) .handle(); - assert!(!app.should_ignore_quit_key); + assert!(!app.ignore_special_keys_for_textbox_input); assert!(!app .data .radarr_data @@ -760,7 +760,7 @@ mod tests { assert_eq!(app.data.radarr_data.prompt_confirm_action, None); if selected_block == ActiveRadarrBlock::EditCollectionRootFolderPathInput { - assert!(app.should_ignore_quit_key); + assert!(app.ignore_special_keys_for_textbox_input); } } @@ -792,7 +792,7 @@ mod tests { ); if active_radarr_block == ActiveRadarrBlock::EditCollectionRootFolderPathInput { - assert!(!app.should_ignore_quit_key); + assert!(!app.ignore_special_keys_for_textbox_input); } } } @@ -812,7 +812,7 @@ mod tests { let mut app = App::test_default(); app.data.radarr_data = create_test_radarr_data(); app.data.radarr_data.edit_collection_modal = Some(EditCollectionModal::default()); - app.should_ignore_quit_key = true; + app.ignore_special_keys_for_textbox_input = true; app.push_navigation_stack(ActiveRadarrBlock::EditCollectionPrompt.into()); app.push_navigation_stack(ActiveRadarrBlock::EditCollectionRootFolderPathInput.into()); @@ -824,7 +824,7 @@ mod tests { ) .handle(); - assert!(!app.should_ignore_quit_key); + assert!(!app.ignore_special_keys_for_textbox_input); assert_eq!( app.get_current_route(), ActiveRadarrBlock::EditCollectionPrompt.into() @@ -1021,11 +1021,11 @@ mod tests { } #[rstest] - fn test_edit_collection_handler_ignore_alt_navigation( - #[values(true, false)] should_ignore_quit_key: bool, + fn test_edit_collection_handler_ignore_special_keys( + #[values(true, false)] ignore_special_keys_for_textbox_input: bool, ) { let mut app = App::test_default(); - app.should_ignore_quit_key = should_ignore_quit_key; + app.ignore_special_keys_for_textbox_input = ignore_special_keys_for_textbox_input; let handler = EditCollectionHandler::new( DEFAULT_KEYBINDINGS.esc.key, &mut app, @@ -1033,7 +1033,10 @@ mod tests { None, ); - assert_eq!(handler.ignore_alt_navigation(), should_ignore_quit_key); + assert_eq!( + handler.ignore_special_keys(), + ignore_special_keys_for_textbox_input + ); } #[test] diff --git a/src/handlers/radarr_handlers/collections/mod.rs b/src/handlers/radarr_handlers/collections/mod.rs index e8b79b8..2164080 100644 --- a/src/handlers/radarr_handlers/collections/mod.rs +++ b/src/handlers/radarr_handlers/collections/mod.rs @@ -72,8 +72,8 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for CollectionsHandler<' || COLLECTIONS_BLOCKS.contains(&active_block) } - fn ignore_alt_navigation(&self) -> bool { - self.app.should_ignore_quit_key + fn ignore_special_keys(&self) -> bool { + self.app.ignore_special_keys_for_textbox_input } fn new( diff --git a/src/handlers/radarr_handlers/downloads/downloads_handler_tests.rs b/src/handlers/radarr_handlers/downloads/downloads_handler_tests.rs index 6f447b1..bbdd673 100644 --- a/src/handlers/radarr_handlers/downloads/downloads_handler_tests.rs +++ b/src/handlers/radarr_handlers/downloads/downloads_handler_tests.rs @@ -389,11 +389,11 @@ mod tests { } #[rstest] - fn test_downloads_handler_ignore_alt_navigation( - #[values(true, false)] should_ignore_quit_key: bool, + fn test_downloads_handler_ignore_special_keys( + #[values(true, false)] ignore_special_keys_for_textbox_input: bool, ) { let mut app = App::test_default(); - app.should_ignore_quit_key = should_ignore_quit_key; + app.ignore_special_keys_for_textbox_input = ignore_special_keys_for_textbox_input; let handler = DownloadsHandler::new( DEFAULT_KEYBINDINGS.esc.key, &mut app, @@ -401,7 +401,10 @@ mod tests { None, ); - assert_eq!(handler.ignore_alt_navigation(), should_ignore_quit_key); + assert_eq!( + handler.ignore_special_keys(), + ignore_special_keys_for_textbox_input + ); } #[test] diff --git a/src/handlers/radarr_handlers/downloads/mod.rs b/src/handlers/radarr_handlers/downloads/mod.rs index bf2f23c..173019f 100644 --- a/src/handlers/radarr_handlers/downloads/mod.rs +++ b/src/handlers/radarr_handlers/downloads/mod.rs @@ -46,8 +46,8 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for DownloadsHandler<'a, DOWNLOADS_BLOCKS.contains(&active_block) } - fn ignore_alt_navigation(&self) -> bool { - self.app.should_ignore_quit_key + fn ignore_special_keys(&self) -> bool { + self.app.ignore_special_keys_for_textbox_input } fn new( diff --git a/src/handlers/radarr_handlers/indexers/edit_indexer_handler.rs b/src/handlers/radarr_handlers/indexers/edit_indexer_handler.rs index 5e5eed5..d9ba23c 100644 --- a/src/handlers/radarr_handlers/indexers/edit_indexer_handler.rs +++ b/src/handlers/radarr_handlers/indexers/edit_indexer_handler.rs @@ -66,8 +66,8 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for EditIndexerHandler<' EDIT_INDEXER_BLOCKS.contains(&active_block) } - fn ignore_alt_navigation(&self) -> bool { - self.app.should_ignore_quit_key + fn ignore_special_keys(&self) -> bool { + self.app.ignore_special_keys_for_textbox_input } fn new( @@ -361,7 +361,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for EditIndexerHandler<' | ActiveRadarrBlock::EditIndexerSeedRatioInput | ActiveRadarrBlock::EditIndexerTagsInput => { self.app.push_navigation_stack(selected_block.into()); - self.app.should_ignore_quit_key = true; + self.app.ignore_special_keys_for_textbox_input = true; } ActiveRadarrBlock::EditIndexerPriorityInput => self .app @@ -407,7 +407,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for EditIndexerHandler<' | ActiveRadarrBlock::EditIndexerSeedRatioInput | ActiveRadarrBlock::EditIndexerTagsInput => { self.app.pop_navigation_stack(); - self.app.should_ignore_quit_key = false; + self.app.ignore_special_keys_for_textbox_input = false; } ActiveRadarrBlock::EditIndexerPriorityInput => self.app.pop_navigation_stack(), _ => (), @@ -428,7 +428,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for EditIndexerHandler<' | ActiveRadarrBlock::EditIndexerPriorityInput | ActiveRadarrBlock::EditIndexerTagsInput => { self.app.pop_navigation_stack(); - self.app.should_ignore_quit_key = false; + self.app.ignore_special_keys_for_textbox_input = false; } _ => self.app.pop_navigation_stack(), } diff --git a/src/handlers/radarr_handlers/indexers/edit_indexer_handler_tests.rs b/src/handlers/radarr_handlers/indexers/edit_indexer_handler_tests.rs index 265b091..b3107f2 100644 --- a/src/handlers/radarr_handlers/indexers/edit_indexer_handler_tests.rs +++ b/src/handlers/radarr_handlers/indexers/edit_indexer_handler_tests.rs @@ -1003,7 +1003,7 @@ mod tests { .handle(); assert_eq!(app.get_current_route(), block.into()); - assert!(app.should_ignore_quit_key); + assert!(app.ignore_special_keys_for_textbox_input); } #[test] @@ -1028,7 +1028,7 @@ mod tests { app.get_current_route(), ActiveRadarrBlock::EditIndexerPriorityInput.into() ); - assert!(!app.should_ignore_quit_key); + assert!(!app.ignore_special_keys_for_textbox_input); } #[test] @@ -1194,7 +1194,7 @@ mod tests { fn test_edit_indexer_name_input_submit() { let mut app = App::test_default(); app.push_navigation_stack(ActiveRadarrBlock::Indexers.into()); - app.should_ignore_quit_key = true; + app.ignore_special_keys_for_textbox_input = true; app.data.radarr_data.edit_indexer_modal = Some(EditIndexerModal { name: "Test".into(), ..EditIndexerModal::default() @@ -1210,7 +1210,7 @@ mod tests { ) .handle(); - assert!(!app.should_ignore_quit_key); + assert!(!app.ignore_special_keys_for_textbox_input); assert!(!app .data .radarr_data @@ -1230,7 +1230,7 @@ mod tests { fn test_edit_indexer_url_input_submit() { let mut app = App::test_default(); app.push_navigation_stack(ActiveRadarrBlock::Indexers.into()); - app.should_ignore_quit_key = true; + app.ignore_special_keys_for_textbox_input = true; app.data.radarr_data.edit_indexer_modal = Some(EditIndexerModal { url: "Test".into(), ..EditIndexerModal::default() @@ -1246,7 +1246,7 @@ mod tests { ) .handle(); - assert!(!app.should_ignore_quit_key); + assert!(!app.ignore_special_keys_for_textbox_input); assert!(!app .data .radarr_data @@ -1266,7 +1266,7 @@ mod tests { fn test_edit_indexer_api_key_input_submit() { let mut app = App::test_default(); app.push_navigation_stack(ActiveRadarrBlock::Indexers.into()); - app.should_ignore_quit_key = true; + app.ignore_special_keys_for_textbox_input = true; app.data.radarr_data.edit_indexer_modal = Some(EditIndexerModal { api_key: "Test".into(), ..EditIndexerModal::default() @@ -1282,7 +1282,7 @@ mod tests { ) .handle(); - assert!(!app.should_ignore_quit_key); + assert!(!app.ignore_special_keys_for_textbox_input); assert!(!app .data .radarr_data @@ -1302,7 +1302,7 @@ mod tests { fn test_edit_indexer_seed_ratio_input_submit() { let mut app = App::test_default(); app.push_navigation_stack(ActiveRadarrBlock::Indexers.into()); - app.should_ignore_quit_key = true; + app.ignore_special_keys_for_textbox_input = true; app.data.radarr_data.edit_indexer_modal = Some(EditIndexerModal { seed_ratio: "Test".into(), ..EditIndexerModal::default() @@ -1318,7 +1318,7 @@ mod tests { ) .handle(); - assert!(!app.should_ignore_quit_key); + assert!(!app.ignore_special_keys_for_textbox_input); assert!(!app .data .radarr_data @@ -1338,7 +1338,7 @@ mod tests { fn test_edit_indexer_tags_input_submit() { let mut app = App::test_default(); app.push_navigation_stack(ActiveRadarrBlock::Indexers.into()); - app.should_ignore_quit_key = true; + app.ignore_special_keys_for_textbox_input = true; app.data.radarr_data.edit_indexer_modal = Some(EditIndexerModal { tags: "Test".into(), ..EditIndexerModal::default() @@ -1354,7 +1354,7 @@ mod tests { ) .handle(); - assert!(!app.should_ignore_quit_key); + assert!(!app.ignore_special_keys_for_textbox_input); assert!(!app .data .radarr_data @@ -1418,12 +1418,12 @@ mod tests { app.push_navigation_stack(ActiveRadarrBlock::Indexers.into()); app.push_navigation_stack(active_radarr_block.into()); app.data.radarr_data.edit_indexer_modal = Some(EditIndexerModal::default()); - app.should_ignore_quit_key = true; + app.ignore_special_keys_for_textbox_input = true; EditIndexerHandler::new(ESC_KEY, &mut app, active_radarr_block, None).handle(); assert_eq!(app.get_current_route(), ActiveRadarrBlock::Indexers.into()); - assert!(!app.should_ignore_quit_key); + assert!(!app.ignore_special_keys_for_textbox_input); assert_eq!( app.data.radarr_data.edit_indexer_modal, Some(EditIndexerModal::default()) @@ -1795,11 +1795,11 @@ mod tests { } #[rstest] - fn test_edit_indexer_handler_ignore_alt_navigation( - #[values(true, false)] should_ignore_quit_key: bool, + fn test_edit_indexer_handler_ignore_special_keys( + #[values(true, false)] ignore_special_keys_for_textbox_input: bool, ) { let mut app = App::test_default(); - app.should_ignore_quit_key = should_ignore_quit_key; + app.ignore_special_keys_for_textbox_input = ignore_special_keys_for_textbox_input; let handler = EditIndexerHandler::new( DEFAULT_KEYBINDINGS.esc.key, &mut app, @@ -1807,7 +1807,10 @@ mod tests { None, ); - assert_eq!(handler.ignore_alt_navigation(), should_ignore_quit_key); + assert_eq!( + handler.ignore_special_keys(), + ignore_special_keys_for_textbox_input + ); } #[test] diff --git a/src/handlers/radarr_handlers/indexers/edit_indexer_settings_handler.rs b/src/handlers/radarr_handlers/indexers/edit_indexer_settings_handler.rs index e583175..4e1eca5 100644 --- a/src/handlers/radarr_handlers/indexers/edit_indexer_settings_handler.rs +++ b/src/handlers/radarr_handlers/indexers/edit_indexer_settings_handler.rs @@ -38,8 +38,8 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for IndexerSettingsHandl INDEXER_SETTINGS_BLOCKS.contains(&active_block) } - fn ignore_alt_navigation(&self) -> bool { - self.app.should_ignore_quit_key + fn ignore_special_keys(&self) -> bool { + self.app.ignore_special_keys_for_textbox_input } fn new( @@ -212,7 +212,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for IndexerSettingsHandl self.app.push_navigation_stack( ActiveRadarrBlock::IndexerSettingsWhitelistedSubtitleTagsInput.into(), ); - self.app.should_ignore_quit_key = true; + self.app.ignore_special_keys_for_textbox_input = true; } ActiveRadarrBlock::IndexerSettingsTogglePreferIndexerFlags => { let indexer_settings = self.app.data.radarr_data.indexer_settings.as_mut().unwrap(); @@ -229,7 +229,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for IndexerSettingsHandl } ActiveRadarrBlock::IndexerSettingsWhitelistedSubtitleTagsInput => { self.app.pop_navigation_stack(); - self.app.should_ignore_quit_key = false; + self.app.ignore_special_keys_for_textbox_input = false; } ActiveRadarrBlock::IndexerSettingsMinimumAgeInput | ActiveRadarrBlock::IndexerSettingsRetentionInput @@ -249,7 +249,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for IndexerSettingsHandl } ActiveRadarrBlock::IndexerSettingsWhitelistedSubtitleTagsInput => { self.app.pop_navigation_stack(); - self.app.should_ignore_quit_key = false; + self.app.ignore_special_keys_for_textbox_input = false; } _ => self.app.pop_navigation_stack(), } diff --git a/src/handlers/radarr_handlers/indexers/edit_indexer_settings_handler_tests.rs b/src/handlers/radarr_handlers/indexers/edit_indexer_settings_handler_tests.rs index d790e56..25fe87a 100644 --- a/src/handlers/radarr_handlers/indexers/edit_indexer_settings_handler_tests.rs +++ b/src/handlers/radarr_handlers/indexers/edit_indexer_settings_handler_tests.rs @@ -603,7 +603,7 @@ mod tests { app.get_current_route(), ActiveRadarrBlock::IndexerSettingsWhitelistedSubtitleTagsInput.into() ); - assert!(app.should_ignore_quit_key); + assert!(app.ignore_special_keys_for_textbox_input); } #[test] @@ -717,7 +717,7 @@ mod tests { #[test] fn test_edit_indexer_settings_whitelisted_subtitle_tags_input_submit() { let mut app = App::test_default(); - app.should_ignore_quit_key = true; + app.ignore_special_keys_for_textbox_input = true; app.data.radarr_data.indexer_settings = Some(IndexerSettings { whitelisted_hardcoded_subs: "Test tags".into(), ..IndexerSettings::default() @@ -735,7 +735,7 @@ mod tests { ) .handle(); - assert!(!app.should_ignore_quit_key); + assert!(!app.ignore_special_keys_for_textbox_input); assert!(!app .data .radarr_data @@ -815,7 +815,7 @@ mod tests { ActiveRadarrBlock::IndexerSettingsWhitelistedSubtitleTagsInput.into(), ); app.data.radarr_data.indexer_settings = Some(IndexerSettings::default()); - app.should_ignore_quit_key = true; + app.ignore_special_keys_for_textbox_input = true; IndexerSettingsHandler::new( ESC_KEY, @@ -826,7 +826,7 @@ mod tests { .handle(); assert_eq!(app.get_current_route(), ActiveRadarrBlock::Indexers.into()); - assert!(!app.should_ignore_quit_key); + assert!(!app.ignore_special_keys_for_textbox_input); assert_eq!( app.data.radarr_data.indexer_settings, Some(IndexerSettings::default()) @@ -972,11 +972,11 @@ mod tests { } #[rstest] - fn test_indexer_settings_handler_ignore_alt_navigation( - #[values(true, false)] should_ignore_quit_key: bool, + fn test_indexer_settings_handler_ignore_special_keys( + #[values(true, false)] ignore_special_keys_for_textbox_input: bool, ) { let mut app = App::test_default(); - app.should_ignore_quit_key = should_ignore_quit_key; + app.ignore_special_keys_for_textbox_input = ignore_special_keys_for_textbox_input; let handler = IndexerSettingsHandler::new( DEFAULT_KEYBINDINGS.esc.key, &mut app, @@ -984,7 +984,10 @@ mod tests { None, ); - assert_eq!(handler.ignore_alt_navigation(), should_ignore_quit_key); + assert_eq!( + handler.ignore_special_keys(), + ignore_special_keys_for_textbox_input + ); } #[test] diff --git a/src/handlers/radarr_handlers/indexers/indexers_handler_tests.rs b/src/handlers/radarr_handlers/indexers/indexers_handler_tests.rs index db5e657..e4a26c4 100644 --- a/src/handlers/radarr_handlers/indexers/indexers_handler_tests.rs +++ b/src/handlers/radarr_handlers/indexers/indexers_handler_tests.rs @@ -634,11 +634,11 @@ mod tests { } #[rstest] - fn test_indexers_handler_ignore_alt_navigation( - #[values(true, false)] should_ignore_quit_key: bool, + fn test_indexers_handler_ignore_special_keys( + #[values(true, false)] ignore_special_keys_for_textbox_input: bool, ) { let mut app = App::test_default(); - app.should_ignore_quit_key = should_ignore_quit_key; + app.ignore_special_keys_for_textbox_input = ignore_special_keys_for_textbox_input; let handler = IndexersHandler::new( DEFAULT_KEYBINDINGS.esc.key, &mut app, @@ -646,7 +646,10 @@ mod tests { None, ); - assert_eq!(handler.ignore_alt_navigation(), should_ignore_quit_key); + assert_eq!( + handler.ignore_special_keys(), + ignore_special_keys_for_textbox_input + ); } #[test] diff --git a/src/handlers/radarr_handlers/indexers/mod.rs b/src/handlers/radarr_handlers/indexers/mod.rs index 12eeecd..5770c2a 100644 --- a/src/handlers/radarr_handlers/indexers/mod.rs +++ b/src/handlers/radarr_handlers/indexers/mod.rs @@ -69,8 +69,8 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for IndexersHandler<'a, || INDEXERS_BLOCKS.contains(&active_block) } - fn ignore_alt_navigation(&self) -> bool { - self.app.should_ignore_quit_key + fn ignore_special_keys(&self) -> bool { + self.app.ignore_special_keys_for_textbox_input } fn new( diff --git a/src/handlers/radarr_handlers/indexers/test_all_indexers_handler.rs b/src/handlers/radarr_handlers/indexers/test_all_indexers_handler.rs index b1e4a83..896bd72 100644 --- a/src/handlers/radarr_handlers/indexers/test_all_indexers_handler.rs +++ b/src/handlers/radarr_handlers/indexers/test_all_indexers_handler.rs @@ -48,8 +48,8 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for TestAllIndexersHandl active_block == ActiveRadarrBlock::TestAllIndexers } - fn ignore_alt_navigation(&self) -> bool { - self.app.should_ignore_quit_key + fn ignore_special_keys(&self) -> bool { + self.app.ignore_special_keys_for_textbox_input } fn new( diff --git a/src/handlers/radarr_handlers/indexers/test_all_indexers_handler_tests.rs b/src/handlers/radarr_handlers/indexers/test_all_indexers_handler_tests.rs index b497380..7bfc93c 100644 --- a/src/handlers/radarr_handlers/indexers/test_all_indexers_handler_tests.rs +++ b/src/handlers/radarr_handlers/indexers/test_all_indexers_handler_tests.rs @@ -50,11 +50,11 @@ mod tests { } #[rstest] - fn test_test_all_indexers_handler_ignore_alt_navigation( - #[values(true, false)] should_ignore_quit_key: bool, + fn test_test_all_indexers_handler_ignore_special_keys( + #[values(true, false)] ignore_special_keys_for_textbox_input: bool, ) { let mut app = App::test_default(); - app.should_ignore_quit_key = should_ignore_quit_key; + app.ignore_special_keys_for_textbox_input = ignore_special_keys_for_textbox_input; let handler = TestAllIndexersHandler::new( DEFAULT_KEYBINDINGS.esc.key, &mut app, @@ -62,7 +62,10 @@ mod tests { None, ); - assert_eq!(handler.ignore_alt_navigation(), should_ignore_quit_key); + assert_eq!( + handler.ignore_special_keys(), + ignore_special_keys_for_textbox_input + ); } #[test] diff --git a/src/handlers/radarr_handlers/library/add_movie_handler.rs b/src/handlers/radarr_handlers/library/add_movie_handler.rs index 9840e17..3480bdb 100644 --- a/src/handlers/radarr_handlers/library/add_movie_handler.rs +++ b/src/handlers/radarr_handlers/library/add_movie_handler.rs @@ -133,8 +133,8 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for AddMovieHandler<'a, ADD_MOVIE_BLOCKS.contains(&active_block) } - fn ignore_alt_navigation(&self) -> bool { - self.app.should_ignore_quit_key + fn ignore_special_keys(&self) -> bool { + self.app.ignore_special_keys_for_textbox_input } fn new( @@ -409,7 +409,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for AddMovieHandler<'a, self .app .push_navigation_stack(ActiveRadarrBlock::AddMovieSearchResults.into()); - self.app.should_ignore_quit_key = false; + self.app.ignore_special_keys_for_textbox_input = false; } _ if self.active_radarr_block == ActiveRadarrBlock::AddMovieSearchResults && self.app.data.radarr_data.add_searched_movies.is_some() => @@ -473,7 +473,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for AddMovieHandler<'a, ) .into(), ); - self.app.should_ignore_quit_key = true; + self.app.ignore_special_keys_for_textbox_input = true; } _ => (), } @@ -484,7 +484,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for AddMovieHandler<'a, | ActiveRadarrBlock::AddMovieSelectRootFolder => self.app.pop_navigation_stack(), ActiveRadarrBlock::AddMovieTagsInput => { self.app.pop_navigation_stack(); - self.app.should_ignore_quit_key = false; + self.app.ignore_special_keys_for_textbox_input = false; } _ => (), } @@ -495,12 +495,12 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for AddMovieHandler<'a, ActiveRadarrBlock::AddMovieSearchInput => { self.app.pop_navigation_stack(); self.app.data.radarr_data.add_movie_search = None; - self.app.should_ignore_quit_key = false; + self.app.ignore_special_keys_for_textbox_input = false; } ActiveRadarrBlock::AddMovieSearchResults | ActiveRadarrBlock::AddMovieEmptySearchResults => { self.app.pop_navigation_stack(); self.app.data.radarr_data.add_searched_movies = None; - self.app.should_ignore_quit_key = true; + self.app.ignore_special_keys_for_textbox_input = true; } ActiveRadarrBlock::AddMoviePrompt => { self.app.pop_navigation_stack(); @@ -514,7 +514,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for AddMovieHandler<'a, | ActiveRadarrBlock::AddMovieSelectRootFolder => self.app.pop_navigation_stack(), ActiveRadarrBlock::AddMovieTagsInput => { self.app.pop_navigation_stack(); - self.app.should_ignore_quit_key = false; + self.app.ignore_special_keys_for_textbox_input = false; } _ => (), } diff --git a/src/handlers/radarr_handlers/library/add_movie_handler_tests.rs b/src/handlers/radarr_handlers/library/add_movie_handler_tests.rs index 8966189..4449905 100644 --- a/src/handlers/radarr_handlers/library/add_movie_handler_tests.rs +++ b/src/handlers/radarr_handlers/library/add_movie_handler_tests.rs @@ -782,7 +782,7 @@ mod tests { #[test] fn test_add_movie_search_input_submit() { let mut app = App::test_default(); - app.should_ignore_quit_key = true; + app.ignore_special_keys_for_textbox_input = true; app.data.radarr_data.add_movie_search = Some("test".into()); AddMovieHandler::new( @@ -793,7 +793,7 @@ mod tests { ) .handle(); - assert!(!app.should_ignore_quit_key); + assert!(!app.ignore_special_keys_for_textbox_input); assert_eq!( app.get_current_route(), ActiveRadarrBlock::AddMovieSearchResults.into() @@ -805,7 +805,7 @@ mod tests { let mut app = App::test_default(); app.data.radarr_data.add_movie_search = Some(HorizontallyScrollableText::default()); app.push_navigation_stack(ActiveRadarrBlock::AddMovieSearchInput.into()); - app.should_ignore_quit_key = true; + app.ignore_special_keys_for_textbox_input = true; AddMovieHandler::new( SUBMIT_KEY, @@ -815,7 +815,7 @@ mod tests { ) .handle(); - assert!(app.should_ignore_quit_key); + assert!(app.ignore_special_keys_for_textbox_input); assert_eq!( app.get_current_route(), ActiveRadarrBlock::AddMovieSearchInput.into() @@ -1093,7 +1093,7 @@ mod tests { assert_eq!(app.data.radarr_data.prompt_confirm_action, None); if selected_block == ActiveRadarrBlock::AddMovieTagsInput { - assert!(app.should_ignore_quit_key); + assert!(app.ignore_special_keys_for_textbox_input); } } @@ -1126,7 +1126,7 @@ mod tests { ); if active_radarr_block == ActiveRadarrBlock::AddMovieTagsInput { - assert!(!app.should_ignore_quit_key); + assert!(!app.ignore_special_keys_for_textbox_input); } } } @@ -1149,7 +1149,7 @@ mod tests { let mut app = App::test_default(); app.is_loading = is_ready; app.data.radarr_data = create_test_radarr_data(); - app.should_ignore_quit_key = true; + app.ignore_special_keys_for_textbox_input = true; app.push_navigation_stack(ActiveRadarrBlock::AddMovieSearchInput.into()); AddMovieHandler::new( @@ -1160,7 +1160,7 @@ mod tests { ) .handle(); - assert!(!app.should_ignore_quit_key); + assert!(!app.ignore_special_keys_for_textbox_input); assert_eq!(app.get_current_route(), ActiveRadarrBlock::Movies.into()); assert_eq!(app.data.radarr_data.add_movie_search, None); } @@ -1169,7 +1169,7 @@ mod tests { fn test_add_movie_input_esc() { let mut app = App::test_default(); app.data.radarr_data = create_test_radarr_data(); - app.should_ignore_quit_key = true; + app.ignore_special_keys_for_textbox_input = true; app.push_navigation_stack(ActiveRadarrBlock::AddMoviePrompt.into()); app.push_navigation_stack(ActiveRadarrBlock::AddMovieTagsInput.into()); @@ -1181,7 +1181,7 @@ mod tests { ) .handle(); - assert!(!app.should_ignore_quit_key); + assert!(!app.ignore_special_keys_for_textbox_input); assert_eq!( app.get_current_route(), ActiveRadarrBlock::AddMoviePrompt.into() @@ -1213,7 +1213,7 @@ mod tests { ActiveRadarrBlock::AddMovieSearchInput.into() ); assert!(app.data.radarr_data.add_searched_movies.is_none()); - assert!(app.should_ignore_quit_key); + assert!(app.ignore_special_keys_for_textbox_input); } #[test] @@ -1259,7 +1259,7 @@ mod tests { fn test_add_movie_tags_input_esc() { let mut app = App::test_default(); app.data.radarr_data = create_test_radarr_data(); - app.should_ignore_quit_key = true; + app.ignore_special_keys_for_textbox_input = true; app.push_navigation_stack(ActiveRadarrBlock::AddMoviePrompt.into()); app.push_navigation_stack(ActiveRadarrBlock::AddMovieTagsInput.into()); @@ -1271,7 +1271,7 @@ mod tests { ) .handle(); - assert!(!app.should_ignore_quit_key); + assert!(!app.ignore_special_keys_for_textbox_input); assert_eq!( app.get_current_route(), ActiveRadarrBlock::AddMoviePrompt.into() @@ -1524,11 +1524,11 @@ mod tests { } #[rstest] - fn test_add_movie_handler_ignore_alt_navigation( - #[values(true, false)] should_ignore_quit_key: bool, + fn test_add_movie_handler_ignore_special_keys( + #[values(true, false)] ignore_special_keys_for_textbox_input: bool, ) { let mut app = App::test_default(); - app.should_ignore_quit_key = should_ignore_quit_key; + app.ignore_special_keys_for_textbox_input = ignore_special_keys_for_textbox_input; let handler = AddMovieHandler::new( DEFAULT_KEYBINDINGS.esc.key, &mut app, @@ -1536,7 +1536,10 @@ mod tests { None, ); - assert_eq!(handler.ignore_alt_navigation(), should_ignore_quit_key); + assert_eq!( + handler.ignore_special_keys(), + ignore_special_keys_for_textbox_input + ); } #[test] diff --git a/src/handlers/radarr_handlers/library/delete_movie_handler.rs b/src/handlers/radarr_handlers/library/delete_movie_handler.rs index 860f895..b10ac3c 100644 --- a/src/handlers/radarr_handlers/library/delete_movie_handler.rs +++ b/src/handlers/radarr_handlers/library/delete_movie_handler.rs @@ -37,8 +37,8 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for DeleteMovieHandler<' DELETE_MOVIE_BLOCKS.contains(&active_block) } - fn ignore_alt_navigation(&self) -> bool { - self.app.should_ignore_quit_key + fn ignore_special_keys(&self) -> bool { + self.app.ignore_special_keys_for_textbox_input } fn new( diff --git a/src/handlers/radarr_handlers/library/delete_movie_handler_tests.rs b/src/handlers/radarr_handlers/library/delete_movie_handler_tests.rs index 85e8275..17b9338 100644 --- a/src/handlers/radarr_handlers/library/delete_movie_handler_tests.rs +++ b/src/handlers/radarr_handlers/library/delete_movie_handler_tests.rs @@ -315,11 +315,11 @@ mod tests { } #[rstest] - fn test_delete_movie_handler_ignore_alt_navigation( - #[values(true, false)] should_ignore_quit_key: bool, + fn test_delete_movie_handler_ignore_special_keys( + #[values(true, false)] ignore_special_keys_for_textbox_input: bool, ) { let mut app = App::test_default(); - app.should_ignore_quit_key = should_ignore_quit_key; + app.ignore_special_keys_for_textbox_input = ignore_special_keys_for_textbox_input; let handler = DeleteMovieHandler::new( DEFAULT_KEYBINDINGS.esc.key, &mut app, @@ -327,7 +327,10 @@ mod tests { None, ); - assert_eq!(handler.ignore_alt_navigation(), should_ignore_quit_key); + assert_eq!( + handler.ignore_special_keys(), + ignore_special_keys_for_textbox_input + ); } #[test] diff --git a/src/handlers/radarr_handlers/library/edit_movie_handler.rs b/src/handlers/radarr_handlers/library/edit_movie_handler.rs index 0daf472..10c3f14 100644 --- a/src/handlers/radarr_handlers/library/edit_movie_handler.rs +++ b/src/handlers/radarr_handlers/library/edit_movie_handler.rs @@ -67,8 +67,8 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for EditMovieHandler<'a, EDIT_MOVIE_BLOCKS.contains(&active_block) } - fn ignore_alt_navigation(&self) -> bool { - self.app.should_ignore_quit_key + fn ignore_special_keys(&self) -> bool { + self.app.ignore_special_keys_for_textbox_input } fn new( @@ -293,7 +293,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for EditMovieHandler<'a, ) .into(), ); - self.app.should_ignore_quit_key = true; + self.app.ignore_special_keys_for_textbox_input = true; } ActiveRadarrBlock::EditMovieToggleMonitored => { self @@ -322,7 +322,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for EditMovieHandler<'a, | ActiveRadarrBlock::EditMovieSelectQualityProfile => self.app.pop_navigation_stack(), ActiveRadarrBlock::EditMoviePathInput | ActiveRadarrBlock::EditMovieTagsInput => { self.app.pop_navigation_stack(); - self.app.should_ignore_quit_key = false; + self.app.ignore_special_keys_for_textbox_input = false; } _ => (), } @@ -332,7 +332,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for EditMovieHandler<'a, match self.active_radarr_block { ActiveRadarrBlock::EditMovieTagsInput | ActiveRadarrBlock::EditMoviePathInput => { self.app.pop_navigation_stack(); - self.app.should_ignore_quit_key = false; + self.app.ignore_special_keys_for_textbox_input = false; } ActiveRadarrBlock::EditMoviePrompt => { self.app.pop_navigation_stack(); diff --git a/src/handlers/radarr_handlers/library/edit_movie_handler_tests.rs b/src/handlers/radarr_handlers/library/edit_movie_handler_tests.rs index ce69fc6..9853ee3 100644 --- a/src/handlers/radarr_handlers/library/edit_movie_handler_tests.rs +++ b/src/handlers/radarr_handlers/library/edit_movie_handler_tests.rs @@ -549,7 +549,7 @@ mod tests { #[test] fn test_edit_movie_path_input_submit() { let mut app = App::test_default(); - app.should_ignore_quit_key = true; + app.ignore_special_keys_for_textbox_input = true; app.data.radarr_data.edit_movie_modal = Some(EditMovieModal { path: "Test Path".into(), ..EditMovieModal::default() @@ -565,7 +565,7 @@ mod tests { ) .handle(); - assert!(!app.should_ignore_quit_key); + assert!(!app.ignore_special_keys_for_textbox_input); assert!(!app .data .radarr_data @@ -584,7 +584,7 @@ mod tests { #[test] fn test_edit_movie_tags_input_submit() { let mut app = App::test_default(); - app.should_ignore_quit_key = true; + app.ignore_special_keys_for_textbox_input = true; app.data.radarr_data.edit_movie_modal = Some(EditMovieModal { tags: "Test Tags".into(), ..EditMovieModal::default() @@ -600,7 +600,7 @@ mod tests { ) .handle(); - assert!(!app.should_ignore_quit_key); + assert!(!app.ignore_special_keys_for_textbox_input); assert!(!app .data .radarr_data @@ -814,7 +814,7 @@ mod tests { if selected_block == ActiveRadarrBlock::EditMoviePathInput || selected_block == ActiveRadarrBlock::EditMovieTagsInput { - assert!(app.should_ignore_quit_key); + assert!(app.ignore_special_keys_for_textbox_input); } } @@ -852,7 +852,7 @@ mod tests { .into() ); assert_eq!(app.data.radarr_data.prompt_confirm_action, None); - assert!(!app.should_ignore_quit_key); + assert!(!app.ignore_special_keys_for_textbox_input); } #[rstest] @@ -886,7 +886,7 @@ mod tests { if active_radarr_block == ActiveRadarrBlock::EditMoviePathInput || active_radarr_block == ActiveRadarrBlock::EditMovieTagsInput { - assert!(!app.should_ignore_quit_key); + assert!(!app.ignore_special_keys_for_textbox_input); } } } @@ -912,13 +912,13 @@ mod tests { ) { let mut app = App::test_default(); app.data.radarr_data = create_test_radarr_data(); - app.should_ignore_quit_key = true; + app.ignore_special_keys_for_textbox_input = true; app.push_navigation_stack(ActiveRadarrBlock::EditMoviePrompt.into()); app.push_navigation_stack(active_radarr_block.into()); EditMovieHandler::new(ESC_KEY, &mut app, active_radarr_block, None).handle(); - assert!(!app.should_ignore_quit_key); + assert!(!app.ignore_special_keys_for_textbox_input); assert_eq!( app.get_current_route(), ActiveRadarrBlock::EditMoviePrompt.into() @@ -1150,11 +1150,11 @@ mod tests { } #[rstest] - fn test_edit_movie_handler_ignore_alt_navigation( - #[values(true, false)] should_ignore_quit_key: bool, + fn test_edit_movie_handler_ignore_special_keys( + #[values(true, false)] ignore_special_keys_for_textbox_input: bool, ) { let mut app = App::test_default(); - app.should_ignore_quit_key = should_ignore_quit_key; + app.ignore_special_keys_for_textbox_input = ignore_special_keys_for_textbox_input; let handler = EditMovieHandler::new( DEFAULT_KEYBINDINGS.esc.key, &mut app, @@ -1162,7 +1162,10 @@ mod tests { None, ); - assert_eq!(handler.ignore_alt_navigation(), should_ignore_quit_key); + assert_eq!( + handler.ignore_special_keys(), + ignore_special_keys_for_textbox_input + ); } #[test] diff --git a/src/handlers/radarr_handlers/library/library_handler_tests.rs b/src/handlers/radarr_handlers/library/library_handler_tests.rs index 1ed6f5f..2eb4275 100644 --- a/src/handlers/radarr_handlers/library/library_handler_tests.rs +++ b/src/handlers/radarr_handlers/library/library_handler_tests.rs @@ -331,7 +331,7 @@ mod tests { app.get_current_route(), ActiveRadarrBlock::AddMovieSearchInput.into() ); - assert!(app.should_ignore_quit_key); + assert!(app.ignore_special_keys_for_textbox_input); assert!(app.data.radarr_data.add_movie_search.is_some()); } @@ -355,7 +355,7 @@ mod tests { .handle(); assert_eq!(app.get_current_route(), ActiveRadarrBlock::Movies.into()); - assert!(!app.should_ignore_quit_key); + assert!(!app.ignore_special_keys_for_textbox_input); assert!(app.data.radarr_data.add_movie_search.is_none()); } @@ -778,11 +778,11 @@ mod tests { } #[rstest] - fn test_library_handler_ignore_alt_navigation( - #[values(true, false)] should_ignore_quit_key: bool, + fn test_library_handler_ignore_special_keys( + #[values(true, false)] ignore_special_keys_for_textbox_input: bool, ) { let mut app = App::test_default(); - app.should_ignore_quit_key = should_ignore_quit_key; + app.ignore_special_keys_for_textbox_input = ignore_special_keys_for_textbox_input; let handler = LibraryHandler::new( DEFAULT_KEYBINDINGS.esc.key, &mut app, @@ -790,7 +790,10 @@ mod tests { None, ); - assert_eq!(handler.ignore_alt_navigation(), should_ignore_quit_key); + assert_eq!( + handler.ignore_special_keys(), + ignore_special_keys_for_textbox_input + ); } #[test] diff --git a/src/handlers/radarr_handlers/library/mod.rs b/src/handlers/radarr_handlers/library/mod.rs index 93b76cc..d70bfbf 100644 --- a/src/handlers/radarr_handlers/library/mod.rs +++ b/src/handlers/radarr_handlers/library/mod.rs @@ -80,8 +80,8 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for LibraryHandler<'a, ' || LIBRARY_BLOCKS.contains(&active_block) } - fn ignore_alt_navigation(&self) -> bool { - self.app.should_ignore_quit_key + fn ignore_special_keys(&self) -> bool { + self.app.ignore_special_keys_for_textbox_input } fn new( @@ -181,7 +181,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for LibraryHandler<'a, ' .app .push_navigation_stack(ActiveRadarrBlock::AddMovieSearchInput.into()); self.app.data.radarr_data.add_movie_search = Some(HorizontallyScrollableText::default()); - self.app.should_ignore_quit_key = true; + self.app.ignore_special_keys_for_textbox_input = true; } _ if matches_key!(update, key) => { self diff --git a/src/handlers/radarr_handlers/library/movie_details_handler.rs b/src/handlers/radarr_handlers/library/movie_details_handler.rs index f8a4805..ac08fa1 100644 --- a/src/handlers/radarr_handlers/library/movie_details_handler.rs +++ b/src/handlers/radarr_handlers/library/movie_details_handler.rs @@ -135,8 +135,8 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for MovieDetailsHandler< MOVIE_DETAILS_BLOCKS.contains(&active_block) } - fn ignore_alt_navigation(&self) -> bool { - self.app.should_ignore_quit_key + fn ignore_special_keys(&self) -> bool { + self.app.ignore_special_keys_for_textbox_input } fn new( diff --git a/src/handlers/radarr_handlers/library/movie_details_handler_tests.rs b/src/handlers/radarr_handlers/library/movie_details_handler_tests.rs index bc3dbd0..2153748 100644 --- a/src/handlers/radarr_handlers/library/movie_details_handler_tests.rs +++ b/src/handlers/radarr_handlers/library/movie_details_handler_tests.rs @@ -1043,11 +1043,11 @@ mod tests { } #[rstest] - fn test_movie_details_handler_ignore_alt_navigation( - #[values(true, false)] should_ignore_quit_key: bool, + fn test_movie_details_handler_ignore_special_keys( + #[values(true, false)] ignore_special_keys_for_textbox_input: bool, ) { let mut app = App::test_default(); - app.should_ignore_quit_key = should_ignore_quit_key; + app.ignore_special_keys_for_textbox_input = ignore_special_keys_for_textbox_input; let handler = MovieDetailsHandler::new( DEFAULT_KEYBINDINGS.esc.key, &mut app, @@ -1055,7 +1055,10 @@ mod tests { None, ); - assert_eq!(handler.ignore_alt_navigation(), should_ignore_quit_key); + assert_eq!( + handler.ignore_special_keys(), + ignore_special_keys_for_textbox_input + ); } #[rstest] diff --git a/src/handlers/radarr_handlers/mod.rs b/src/handlers/radarr_handlers/mod.rs index f462704..e27237e 100644 --- a/src/handlers/radarr_handlers/mod.rs +++ b/src/handlers/radarr_handlers/mod.rs @@ -64,8 +64,8 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for RadarrHandler<'a, 'b true } - fn ignore_alt_navigation(&self) -> bool { - self.app.should_ignore_quit_key + fn ignore_special_keys(&self) -> bool { + self.app.ignore_special_keys_for_textbox_input } fn new( @@ -112,11 +112,11 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for RadarrHandler<'a, 'b pub fn handle_change_tab_left_right_keys(app: &mut App<'_>, key: Key) { let key_ref = key; match key_ref { - _ if matches_key!(left, key, app.should_ignore_quit_key) => { + _ if matches_key!(left, key, app.ignore_special_keys_for_textbox_input) => { app.data.radarr_data.main_tabs.previous(); app.pop_and_push_navigation_stack(app.data.radarr_data.main_tabs.get_active_route()); } - _ if matches_key!(right, key, app.should_ignore_quit_key) => { + _ if matches_key!(right, key, app.ignore_special_keys_for_textbox_input) => { app.data.radarr_data.main_tabs.next(); app.pop_and_push_navigation_stack(app.data.radarr_data.main_tabs.get_active_route()); } @@ -142,7 +142,7 @@ macro_rules! search_table { }; $app.data.radarr_data.is_searching = false; - $app.should_ignore_quit_key = false; + $app.ignore_special_keys_for_textbox_input = false; if search_index.is_some() { $app.pop_navigation_stack(); @@ -169,7 +169,7 @@ macro_rules! search_table { }; $app.data.radarr_data.is_searching = false; - $app.should_ignore_quit_key = false; + $app.ignore_special_keys_for_textbox_input = false; if search_index.is_some() { $app.pop_navigation_stack(); diff --git a/src/handlers/radarr_handlers/radarr_handler_tests.rs b/src/handlers/radarr_handlers/radarr_handler_tests.rs index ff118fe..9003ded 100644 --- a/src/handlers/radarr_handlers/radarr_handler_tests.rs +++ b/src/handlers/radarr_handlers/radarr_handler_tests.rs @@ -60,7 +60,7 @@ mod tests { #[case] right_block: ActiveRadarrBlock, ) { let mut app = App::test_default(); - app.should_ignore_quit_key = false; + app.ignore_special_keys_for_textbox_input = false; app.data.radarr_data.main_tabs.set_index(index); handle_change_tab_left_right_keys(&mut app, DEFAULT_KEYBINDINGS.left.alt.unwrap()); @@ -95,7 +95,7 @@ mod tests { #[case] block: ActiveRadarrBlock, ) { let mut app = App::test_default(); - app.should_ignore_quit_key = true; + app.ignore_special_keys_for_textbox_input = true; app.push_navigation_stack(block.into()); app.data.radarr_data.main_tabs.set_index(index); @@ -288,11 +288,11 @@ mod tests { } #[rstest] - fn test_radarr_handler_ignore_alt_navigation( - #[values(true, false)] should_ignore_quit_key: bool, + fn test_radarr_handler_ignore_special_keys( + #[values(true, false)] ignore_special_keys_for_textbox_input: bool, ) { let mut app = App::test_default(); - app.should_ignore_quit_key = should_ignore_quit_key; + app.ignore_special_keys_for_textbox_input = ignore_special_keys_for_textbox_input; let handler = RadarrHandler::new( DEFAULT_KEYBINDINGS.esc.key, &mut app, @@ -300,7 +300,10 @@ mod tests { None, ); - assert_eq!(handler.ignore_alt_navigation(), should_ignore_quit_key); + assert_eq!( + handler.ignore_special_keys(), + ignore_special_keys_for_textbox_input + ); } #[test] diff --git a/src/handlers/radarr_handlers/root_folders/mod.rs b/src/handlers/radarr_handlers/root_folders/mod.rs index e942163..88c028b 100644 --- a/src/handlers/radarr_handlers/root_folders/mod.rs +++ b/src/handlers/radarr_handlers/root_folders/mod.rs @@ -69,8 +69,8 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for RootFoldersHandler<' ROOT_FOLDERS_BLOCKS.contains(&active_block) } - fn ignore_alt_navigation(&self) -> bool { - self.app.should_ignore_quit_key + fn ignore_special_keys(&self) -> bool { + self.app.ignore_special_keys_for_textbox_input } fn new( @@ -173,7 +173,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for RootFoldersHandler<' self.build_add_root_folder_body(), )); self.app.data.radarr_data.prompt_confirm = true; - self.app.should_ignore_quit_key = false; + self.app.ignore_special_keys_for_textbox_input = false; self.app.pop_navigation_stack(); } _ => (), @@ -186,7 +186,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for RootFoldersHandler<' self.app.pop_navigation_stack(); self.app.data.radarr_data.edit_root_folder = None; self.app.data.radarr_data.prompt_confirm = false; - self.app.should_ignore_quit_key = false; + self.app.ignore_special_keys_for_textbox_input = false; } ActiveRadarrBlock::DeleteRootFolderPrompt => { self.app.pop_navigation_stack(); @@ -208,7 +208,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for RootFoldersHandler<' .app .push_navigation_stack(ActiveRadarrBlock::AddRootFolderPrompt.into()); self.app.data.radarr_data.edit_root_folder = Some(HorizontallyScrollableText::default()); - self.app.should_ignore_quit_key = true; + self.app.ignore_special_keys_for_textbox_input = true; } _ => (), }, diff --git a/src/handlers/radarr_handlers/root_folders/root_folders_handler_tests.rs b/src/handlers/radarr_handlers/root_folders/root_folders_handler_tests.rs index 036b7c8..632550a 100644 --- a/src/handlers/radarr_handlers/root_folders/root_folders_handler_tests.rs +++ b/src/handlers/radarr_handlers/root_folders/root_folders_handler_tests.rs @@ -263,7 +263,7 @@ mod tests { .set_items(vec![RootFolder::default()]); app.data.radarr_data.edit_root_folder = Some("Test".into()); app.data.radarr_data.prompt_confirm = true; - app.should_ignore_quit_key = true; + app.ignore_special_keys_for_textbox_input = true; app.push_navigation_stack(ActiveRadarrBlock::RootFolders.into()); app.push_navigation_stack(ActiveRadarrBlock::AddRootFolderPrompt.into()); @@ -276,7 +276,7 @@ mod tests { .handle(); assert!(app.data.radarr_data.prompt_confirm); - assert!(!app.should_ignore_quit_key); + assert!(!app.ignore_special_keys_for_textbox_input); assert_eq!( app.data.radarr_data.prompt_confirm_action, Some(RadarrEvent::AddRootFolder(expected_add_root_folder_body)) @@ -292,7 +292,7 @@ mod tests { let mut app = App::test_default(); app.data.radarr_data.edit_root_folder = Some(HorizontallyScrollableText::default()); app.data.radarr_data.prompt_confirm = false; - app.should_ignore_quit_key = true; + app.ignore_special_keys_for_textbox_input = true; app.push_navigation_stack(ActiveRadarrBlock::RootFolders.into()); app.push_navigation_stack(ActiveRadarrBlock::AddRootFolderPrompt.into()); @@ -305,7 +305,7 @@ mod tests { .handle(); assert!(!app.data.radarr_data.prompt_confirm); - assert!(app.should_ignore_quit_key); + assert!(app.ignore_special_keys_for_textbox_input); assert!(app.data.radarr_data.prompt_confirm_action.is_none()); assert_eq!( app.get_current_route(), @@ -407,7 +407,7 @@ mod tests { app.push_navigation_stack(ActiveRadarrBlock::RootFolders.into()); app.push_navigation_stack(ActiveRadarrBlock::AddRootFolderPrompt.into()); app.data.radarr_data.edit_root_folder = Some("/nfs/test".into()); - app.should_ignore_quit_key = true; + app.ignore_special_keys_for_textbox_input = true; RootFoldersHandler::new( ESC_KEY, @@ -424,7 +424,7 @@ mod tests { assert!(app.data.radarr_data.edit_root_folder.is_none()); assert!(!app.data.radarr_data.prompt_confirm); - assert!(!app.should_ignore_quit_key); + assert!(!app.ignore_special_keys_for_textbox_input); } #[rstest] @@ -473,7 +473,7 @@ mod tests { app.get_current_route(), ActiveRadarrBlock::AddRootFolderPrompt.into() ); - assert!(app.should_ignore_quit_key); + assert!(app.ignore_special_keys_for_textbox_input); assert!(app.data.radarr_data.edit_root_folder.is_some()); } @@ -500,7 +500,7 @@ mod tests { app.get_current_route(), ActiveRadarrBlock::RootFolders.into() ); - assert!(!app.should_ignore_quit_key); + assert!(!app.ignore_special_keys_for_textbox_input); assert!(app.data.radarr_data.edit_root_folder.is_none()); } @@ -646,11 +646,11 @@ mod tests { } #[rstest] - fn test_root_folders_handler_ignore_alt_navigation( - #[values(true, false)] should_ignore_quit_key: bool, + fn test_root_folders_handler_ignore_special_keys( + #[values(true, false)] ignore_special_keys_for_textbox_input: bool, ) { let mut app = App::test_default(); - app.should_ignore_quit_key = should_ignore_quit_key; + app.ignore_special_keys_for_textbox_input = ignore_special_keys_for_textbox_input; let handler = RootFoldersHandler::new( DEFAULT_KEYBINDINGS.esc.key, &mut app, @@ -658,7 +658,10 @@ mod tests { None, ); - assert_eq!(handler.ignore_alt_navigation(), should_ignore_quit_key); + assert_eq!( + handler.ignore_special_keys(), + ignore_special_keys_for_textbox_input + ); } #[test] diff --git a/src/handlers/radarr_handlers/system/mod.rs b/src/handlers/radarr_handlers/system/mod.rs index 83be458..0a194b5 100644 --- a/src/handlers/radarr_handlers/system/mod.rs +++ b/src/handlers/radarr_handlers/system/mod.rs @@ -35,8 +35,8 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for SystemHandler<'a, 'b SystemDetailsHandler::accepts(active_block) || active_block == ActiveRadarrBlock::System } - fn ignore_alt_navigation(&self) -> bool { - self.app.should_ignore_quit_key + fn ignore_special_keys(&self) -> bool { + self.app.ignore_special_keys_for_textbox_input } fn new( diff --git a/src/handlers/radarr_handlers/system/system_details_handler.rs b/src/handlers/radarr_handlers/system/system_details_handler.rs index e19c556..354fd08 100644 --- a/src/handlers/radarr_handlers/system/system_details_handler.rs +++ b/src/handlers/radarr_handlers/system/system_details_handler.rs @@ -36,8 +36,8 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for SystemDetailsHandler SYSTEM_DETAILS_BLOCKS.contains(&active_block) } - fn ignore_alt_navigation(&self) -> bool { - self.app.should_ignore_quit_key + fn ignore_special_keys(&self) -> bool { + self.app.ignore_special_keys_for_textbox_input } fn new( diff --git a/src/handlers/radarr_handlers/system/system_details_handler_tests.rs b/src/handlers/radarr_handlers/system/system_details_handler_tests.rs index a4caf72..bb9f098 100644 --- a/src/handlers/radarr_handlers/system/system_details_handler_tests.rs +++ b/src/handlers/radarr_handlers/system/system_details_handler_tests.rs @@ -940,11 +940,11 @@ mod tests { } #[rstest] - fn test_system_details_handler_ignore_alt_navigation( - #[values(true, false)] should_ignore_quit_key: bool, + fn test_system_details_handler_ignore_special_keys( + #[values(true, false)] ignore_special_keys_for_textbox_input: bool, ) { let mut app = App::test_default(); - app.should_ignore_quit_key = should_ignore_quit_key; + app.ignore_special_keys_for_textbox_input = ignore_special_keys_for_textbox_input; let handler = SystemDetailsHandler::new( DEFAULT_KEYBINDINGS.esc.key, &mut app, @@ -952,7 +952,10 @@ mod tests { None, ); - assert_eq!(handler.ignore_alt_navigation(), should_ignore_quit_key); + assert_eq!( + handler.ignore_special_keys(), + ignore_special_keys_for_textbox_input + ); } #[test] diff --git a/src/handlers/radarr_handlers/system/system_handler_tests.rs b/src/handlers/radarr_handlers/system/system_handler_tests.rs index 25f8622..e59148d 100644 --- a/src/handlers/radarr_handlers/system/system_handler_tests.rs +++ b/src/handlers/radarr_handlers/system/system_handler_tests.rs @@ -451,11 +451,11 @@ mod tests { } #[rstest] - fn test_system_handler_ignore_alt_navigation( - #[values(true, false)] should_ignore_quit_key: bool, + fn test_system_handler_ignore_special_keys( + #[values(true, false)] ignore_special_keys_for_textbox_input: bool, ) { let mut app = App::test_default(); - app.should_ignore_quit_key = should_ignore_quit_key; + app.ignore_special_keys_for_textbox_input = ignore_special_keys_for_textbox_input; let handler = SystemHandler::new( DEFAULT_KEYBINDINGS.esc.key, &mut app, @@ -463,7 +463,10 @@ mod tests { None, ); - assert_eq!(handler.ignore_alt_navigation(), should_ignore_quit_key); + assert_eq!( + handler.ignore_special_keys(), + ignore_special_keys_for_textbox_input + ); } #[test] diff --git a/src/handlers/sonarr_handlers/blocklist/blocklist_handler_tests.rs b/src/handlers/sonarr_handlers/blocklist/blocklist_handler_tests.rs index 74783ac..81d2c5b 100644 --- a/src/handlers/sonarr_handlers/blocklist/blocklist_handler_tests.rs +++ b/src/handlers/sonarr_handlers/blocklist/blocklist_handler_tests.rs @@ -515,11 +515,11 @@ mod tests { } #[rstest] - fn test_blocklist_handler_ignore_alt_navigation( - #[values(true, false)] should_ignore_quit_key: bool, + fn test_blocklist_handler_ignore_special_keys( + #[values(true, false)] ignore_special_keys_for_textbox_input: bool, ) { let mut app = App::test_default(); - app.should_ignore_quit_key = should_ignore_quit_key; + app.ignore_special_keys_for_textbox_input = ignore_special_keys_for_textbox_input; let handler = BlocklistHandler::new( DEFAULT_KEYBINDINGS.esc.key, &mut app, @@ -527,7 +527,10 @@ mod tests { None, ); - assert_eq!(handler.ignore_alt_navigation(), should_ignore_quit_key); + assert_eq!( + handler.ignore_special_keys(), + ignore_special_keys_for_textbox_input + ); } #[test] diff --git a/src/handlers/sonarr_handlers/blocklist/mod.rs b/src/handlers/sonarr_handlers/blocklist/mod.rs index ca91fb3..d891396 100644 --- a/src/handlers/sonarr_handlers/blocklist/mod.rs +++ b/src/handlers/sonarr_handlers/blocklist/mod.rs @@ -50,8 +50,8 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for BlocklistHandler<'a, BLOCKLIST_BLOCKS.contains(&active_block) } - fn ignore_alt_navigation(&self) -> bool { - self.app.should_ignore_quit_key + fn ignore_special_keys(&self) -> bool { + self.app.ignore_special_keys_for_textbox_input } fn new( diff --git a/src/handlers/sonarr_handlers/downloads/downloads_handler_tests.rs b/src/handlers/sonarr_handlers/downloads/downloads_handler_tests.rs index 68ff72a..441a347 100644 --- a/src/handlers/sonarr_handlers/downloads/downloads_handler_tests.rs +++ b/src/handlers/sonarr_handlers/downloads/downloads_handler_tests.rs @@ -391,11 +391,11 @@ mod tests { } #[rstest] - fn test_downloads_handler_ignore_alt_navigation( - #[values(true, false)] should_ignore_quit_key: bool, + fn test_downloads_handler_ignore_special_keys( + #[values(true, false)] ignore_special_keys_for_textbox_input: bool, ) { let mut app = App::test_default(); - app.should_ignore_quit_key = should_ignore_quit_key; + app.ignore_special_keys_for_textbox_input = ignore_special_keys_for_textbox_input; let handler = DownloadsHandler::new( DEFAULT_KEYBINDINGS.esc.key, &mut app, @@ -403,7 +403,10 @@ mod tests { None, ); - assert_eq!(handler.ignore_alt_navigation(), should_ignore_quit_key); + assert_eq!( + handler.ignore_special_keys(), + ignore_special_keys_for_textbox_input + ); } #[test] diff --git a/src/handlers/sonarr_handlers/downloads/mod.rs b/src/handlers/sonarr_handlers/downloads/mod.rs index 0ae0c5c..d6adab0 100644 --- a/src/handlers/sonarr_handlers/downloads/mod.rs +++ b/src/handlers/sonarr_handlers/downloads/mod.rs @@ -46,8 +46,8 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for DownloadsHandler<'a, DOWNLOADS_BLOCKS.contains(&active_block) } - fn ignore_alt_navigation(&self) -> bool { - self.app.should_ignore_quit_key + fn ignore_special_keys(&self) -> bool { + self.app.ignore_special_keys_for_textbox_input } fn new( diff --git a/src/handlers/sonarr_handlers/history/history_handler_tests.rs b/src/handlers/sonarr_handlers/history/history_handler_tests.rs index 08953c0..9b860cc 100644 --- a/src/handlers/sonarr_handlers/history/history_handler_tests.rs +++ b/src/handlers/sonarr_handlers/history/history_handler_tests.rs @@ -308,11 +308,11 @@ mod tests { } #[rstest] - fn test_history_handler_ignore_alt_navigation( - #[values(true, false)] should_ignore_quit_key: bool, + fn test_history_handler_ignore_special_keys( + #[values(true, false)] ignore_special_keys_for_textbox_input: bool, ) { let mut app = App::test_default(); - app.should_ignore_quit_key = should_ignore_quit_key; + app.ignore_special_keys_for_textbox_input = ignore_special_keys_for_textbox_input; let handler = HistoryHandler::new( DEFAULT_KEYBINDINGS.esc.key, &mut app, @@ -320,7 +320,10 @@ mod tests { None, ); - assert_eq!(handler.ignore_alt_navigation(), should_ignore_quit_key); + assert_eq!( + handler.ignore_special_keys(), + ignore_special_keys_for_textbox_input + ); } #[test] diff --git a/src/handlers/sonarr_handlers/history/mod.rs b/src/handlers/sonarr_handlers/history/mod.rs index 3ea81d8..cf422d0 100644 --- a/src/handlers/sonarr_handlers/history/mod.rs +++ b/src/handlers/sonarr_handlers/history/mod.rs @@ -51,8 +51,8 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for HistoryHandler<'a, ' HISTORY_BLOCKS.contains(&active_block) } - fn ignore_alt_navigation(&self) -> bool { - self.app.should_ignore_quit_key + fn ignore_special_keys(&self) -> bool { + self.app.ignore_special_keys_for_textbox_input } fn new( diff --git a/src/handlers/sonarr_handlers/indexers/edit_indexer_handler.rs b/src/handlers/sonarr_handlers/indexers/edit_indexer_handler.rs index 0448935..68cd44c 100644 --- a/src/handlers/sonarr_handlers/indexers/edit_indexer_handler.rs +++ b/src/handlers/sonarr_handlers/indexers/edit_indexer_handler.rs @@ -65,8 +65,8 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for EditIndexerHandler<' EDIT_INDEXER_BLOCKS.contains(&active_block) } - fn ignore_alt_navigation(&self) -> bool { - self.app.should_ignore_quit_key + fn ignore_special_keys(&self) -> bool { + self.app.ignore_special_keys_for_textbox_input } fn new( @@ -360,7 +360,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for EditIndexerHandler<' | ActiveSonarrBlock::EditIndexerSeedRatioInput | ActiveSonarrBlock::EditIndexerTagsInput => { self.app.push_navigation_stack(selected_block.into()); - self.app.should_ignore_quit_key = true; + self.app.ignore_special_keys_for_textbox_input = true; } ActiveSonarrBlock::EditIndexerPriorityInput => self .app @@ -406,7 +406,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for EditIndexerHandler<' | ActiveSonarrBlock::EditIndexerSeedRatioInput | ActiveSonarrBlock::EditIndexerTagsInput => { self.app.pop_navigation_stack(); - self.app.should_ignore_quit_key = false; + self.app.ignore_special_keys_for_textbox_input = false; } ActiveSonarrBlock::EditIndexerPriorityInput => self.app.pop_navigation_stack(), _ => (), @@ -427,7 +427,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for EditIndexerHandler<' | ActiveSonarrBlock::EditIndexerPriorityInput | ActiveSonarrBlock::EditIndexerTagsInput => { self.app.pop_navigation_stack(); - self.app.should_ignore_quit_key = false; + self.app.ignore_special_keys_for_textbox_input = false; } _ => self.app.pop_navigation_stack(), } diff --git a/src/handlers/sonarr_handlers/indexers/edit_indexer_handler_tests.rs b/src/handlers/sonarr_handlers/indexers/edit_indexer_handler_tests.rs index b14d07a..87468d0 100644 --- a/src/handlers/sonarr_handlers/indexers/edit_indexer_handler_tests.rs +++ b/src/handlers/sonarr_handlers/indexers/edit_indexer_handler_tests.rs @@ -1003,7 +1003,7 @@ mod tests { .handle(); assert_eq!(app.get_current_route(), block.into()); - assert!(app.should_ignore_quit_key); + assert!(app.ignore_special_keys_for_textbox_input); } #[test] @@ -1028,7 +1028,7 @@ mod tests { app.get_current_route(), ActiveSonarrBlock::EditIndexerPriorityInput.into() ); - assert!(!app.should_ignore_quit_key); + assert!(!app.ignore_special_keys_for_textbox_input); } #[test] @@ -1194,7 +1194,7 @@ mod tests { fn test_edit_indexer_name_input_submit() { let mut app = App::test_default(); app.push_navigation_stack(ActiveSonarrBlock::Indexers.into()); - app.should_ignore_quit_key = true; + app.ignore_special_keys_for_textbox_input = true; app.data.sonarr_data.edit_indexer_modal = Some(EditIndexerModal { name: "Test".into(), ..EditIndexerModal::default() @@ -1210,7 +1210,7 @@ mod tests { ) .handle(); - assert!(!app.should_ignore_quit_key); + assert!(!app.ignore_special_keys_for_textbox_input); assert!(!app .data .sonarr_data @@ -1230,7 +1230,7 @@ mod tests { fn test_edit_indexer_url_input_submit() { let mut app = App::test_default(); app.push_navigation_stack(ActiveSonarrBlock::Indexers.into()); - app.should_ignore_quit_key = true; + app.ignore_special_keys_for_textbox_input = true; app.data.sonarr_data.edit_indexer_modal = Some(EditIndexerModal { url: "Test".into(), ..EditIndexerModal::default() @@ -1246,7 +1246,7 @@ mod tests { ) .handle(); - assert!(!app.should_ignore_quit_key); + assert!(!app.ignore_special_keys_for_textbox_input); assert!(!app .data .sonarr_data @@ -1266,7 +1266,7 @@ mod tests { fn test_edit_indexer_api_key_input_submit() { let mut app = App::test_default(); app.push_navigation_stack(ActiveSonarrBlock::Indexers.into()); - app.should_ignore_quit_key = true; + app.ignore_special_keys_for_textbox_input = true; app.data.sonarr_data.edit_indexer_modal = Some(EditIndexerModal { api_key: "Test".into(), ..EditIndexerModal::default() @@ -1282,7 +1282,7 @@ mod tests { ) .handle(); - assert!(!app.should_ignore_quit_key); + assert!(!app.ignore_special_keys_for_textbox_input); assert!(!app .data .sonarr_data @@ -1302,7 +1302,7 @@ mod tests { fn test_edit_indexer_seed_ratio_input_submit() { let mut app = App::test_default(); app.push_navigation_stack(ActiveSonarrBlock::Indexers.into()); - app.should_ignore_quit_key = true; + app.ignore_special_keys_for_textbox_input = true; app.data.sonarr_data.edit_indexer_modal = Some(EditIndexerModal { seed_ratio: "Test".into(), ..EditIndexerModal::default() @@ -1318,7 +1318,7 @@ mod tests { ) .handle(); - assert!(!app.should_ignore_quit_key); + assert!(!app.ignore_special_keys_for_textbox_input); assert!(!app .data .sonarr_data @@ -1338,7 +1338,7 @@ mod tests { fn test_edit_indexer_tags_input_submit() { let mut app = App::test_default(); app.push_navigation_stack(ActiveSonarrBlock::Indexers.into()); - app.should_ignore_quit_key = true; + app.ignore_special_keys_for_textbox_input = true; app.data.sonarr_data.edit_indexer_modal = Some(EditIndexerModal { tags: "Test".into(), ..EditIndexerModal::default() @@ -1354,7 +1354,7 @@ mod tests { ) .handle(); - assert!(!app.should_ignore_quit_key); + assert!(!app.ignore_special_keys_for_textbox_input); assert!(!app .data .sonarr_data @@ -1418,12 +1418,12 @@ mod tests { app.push_navigation_stack(ActiveSonarrBlock::Indexers.into()); app.push_navigation_stack(active_sonarr_block.into()); app.data.sonarr_data.edit_indexer_modal = Some(EditIndexerModal::default()); - app.should_ignore_quit_key = true; + app.ignore_special_keys_for_textbox_input = true; EditIndexerHandler::new(ESC_KEY, &mut app, active_sonarr_block, None).handle(); assert_eq!(app.get_current_route(), ActiveSonarrBlock::Indexers.into()); - assert!(!app.should_ignore_quit_key); + assert!(!app.ignore_special_keys_for_textbox_input); assert_eq!( app.data.sonarr_data.edit_indexer_modal, Some(EditIndexerModal::default()) @@ -1795,11 +1795,11 @@ mod tests { } #[rstest] - fn test_edit_indexer_handler_ignore_alt_navigation( - #[values(true, false)] should_ignore_quit_key: bool, + fn test_edit_indexer_handler_ignore_special_keys( + #[values(true, false)] ignore_special_keys_for_textbox_input: bool, ) { let mut app = App::test_default(); - app.should_ignore_quit_key = should_ignore_quit_key; + app.ignore_special_keys_for_textbox_input = ignore_special_keys_for_textbox_input; let handler = EditIndexerHandler::new( DEFAULT_KEYBINDINGS.esc.key, &mut app, @@ -1807,7 +1807,10 @@ mod tests { None, ); - assert_eq!(handler.ignore_alt_navigation(), should_ignore_quit_key); + assert_eq!( + handler.ignore_special_keys(), + ignore_special_keys_for_textbox_input + ); } #[test] diff --git a/src/handlers/sonarr_handlers/indexers/edit_indexer_settings_handler.rs b/src/handlers/sonarr_handlers/indexers/edit_indexer_settings_handler.rs index 8ee6e1d..039f35f 100644 --- a/src/handlers/sonarr_handlers/indexers/edit_indexer_settings_handler.rs +++ b/src/handlers/sonarr_handlers/indexers/edit_indexer_settings_handler.rs @@ -36,8 +36,8 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for IndexerSettingsHandl INDEXER_SETTINGS_BLOCKS.contains(&active_block) } - fn ignore_alt_navigation(&self) -> bool { - self.app.should_ignore_quit_key + fn ignore_special_keys(&self) -> bool { + self.app.ignore_special_keys_for_textbox_input } fn new( diff --git a/src/handlers/sonarr_handlers/indexers/edit_indexer_settings_handler_tests.rs b/src/handlers/sonarr_handlers/indexers/edit_indexer_settings_handler_tests.rs index d22234a..f49a86a 100644 --- a/src/handlers/sonarr_handlers/indexers/edit_indexer_settings_handler_tests.rs +++ b/src/handlers/sonarr_handlers/indexers/edit_indexer_settings_handler_tests.rs @@ -523,11 +523,11 @@ mod tests { } #[rstest] - fn test_indexer_settings_handler_ignore_alt_navigation( - #[values(true, false)] should_ignore_quit_key: bool, + fn test_indexer_settings_handler_ignore_special_keys( + #[values(true, false)] ignore_special_keys_for_textbox_input: bool, ) { let mut app = App::test_default(); - app.should_ignore_quit_key = should_ignore_quit_key; + app.ignore_special_keys_for_textbox_input = ignore_special_keys_for_textbox_input; let handler = IndexerSettingsHandler::new( DEFAULT_KEYBINDINGS.esc.key, &mut app, @@ -535,7 +535,10 @@ mod tests { None, ); - assert_eq!(handler.ignore_alt_navigation(), should_ignore_quit_key); + assert_eq!( + handler.ignore_special_keys(), + ignore_special_keys_for_textbox_input + ); } #[test] diff --git a/src/handlers/sonarr_handlers/indexers/indexers_handler_tests.rs b/src/handlers/sonarr_handlers/indexers/indexers_handler_tests.rs index 8f7a963..5d218b3 100644 --- a/src/handlers/sonarr_handlers/indexers/indexers_handler_tests.rs +++ b/src/handlers/sonarr_handlers/indexers/indexers_handler_tests.rs @@ -644,11 +644,11 @@ mod tests { } #[rstest] - fn test_indexers_handler_ignore_alt_navigation( - #[values(true, false)] should_ignore_quit_key: bool, + fn test_indexers_handler_ignore_special_keys( + #[values(true, false)] ignore_special_keys_for_textbox_input: bool, ) { let mut app = App::test_default(); - app.should_ignore_quit_key = should_ignore_quit_key; + app.ignore_special_keys_for_textbox_input = ignore_special_keys_for_textbox_input; let handler = IndexersHandler::new( DEFAULT_KEYBINDINGS.esc.key, &mut app, @@ -656,7 +656,10 @@ mod tests { None, ); - assert_eq!(handler.ignore_alt_navigation(), should_ignore_quit_key); + assert_eq!( + handler.ignore_special_keys(), + ignore_special_keys_for_textbox_input + ); } #[test] diff --git a/src/handlers/sonarr_handlers/indexers/mod.rs b/src/handlers/sonarr_handlers/indexers/mod.rs index 0b68374..2dae7d9 100644 --- a/src/handlers/sonarr_handlers/indexers/mod.rs +++ b/src/handlers/sonarr_handlers/indexers/mod.rs @@ -69,8 +69,8 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for IndexersHandler<'a, || INDEXERS_BLOCKS.contains(&active_block) } - fn ignore_alt_navigation(&self) -> bool { - self.app.should_ignore_quit_key + fn ignore_special_keys(&self) -> bool { + self.app.ignore_special_keys_for_textbox_input } fn new( diff --git a/src/handlers/sonarr_handlers/indexers/test_all_indexers_handler.rs b/src/handlers/sonarr_handlers/indexers/test_all_indexers_handler.rs index 61ed861..de4bad1 100644 --- a/src/handlers/sonarr_handlers/indexers/test_all_indexers_handler.rs +++ b/src/handlers/sonarr_handlers/indexers/test_all_indexers_handler.rs @@ -48,8 +48,8 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for TestAllIndexersHandl active_block == ActiveSonarrBlock::TestAllIndexers } - fn ignore_alt_navigation(&self) -> bool { - self.app.should_ignore_quit_key + fn ignore_special_keys(&self) -> bool { + self.app.ignore_special_keys_for_textbox_input } fn new( diff --git a/src/handlers/sonarr_handlers/indexers/test_all_indexers_handler_tests.rs b/src/handlers/sonarr_handlers/indexers/test_all_indexers_handler_tests.rs index 8ad05c6..0764f16 100644 --- a/src/handlers/sonarr_handlers/indexers/test_all_indexers_handler_tests.rs +++ b/src/handlers/sonarr_handlers/indexers/test_all_indexers_handler_tests.rs @@ -50,11 +50,11 @@ mod tests { } #[rstest] - fn test_test_all_indexers_handler_ignore_alt_navigation( - #[values(true, false)] should_ignore_quit_key: bool, + fn test_test_all_indexers_handler_ignore_special_keys( + #[values(true, false)] ignore_special_keys_for_textbox_input: bool, ) { let mut app = App::test_default(); - app.should_ignore_quit_key = should_ignore_quit_key; + app.ignore_special_keys_for_textbox_input = ignore_special_keys_for_textbox_input; let handler = TestAllIndexersHandler::new( DEFAULT_KEYBINDINGS.esc.key, &mut app, @@ -62,7 +62,10 @@ mod tests { None, ); - assert_eq!(handler.ignore_alt_navigation(), should_ignore_quit_key); + assert_eq!( + handler.ignore_special_keys(), + ignore_special_keys_for_textbox_input + ); } #[test] diff --git a/src/handlers/sonarr_handlers/library/add_series_handler.rs b/src/handlers/sonarr_handlers/library/add_series_handler.rs index 53076c8..304d3a6 100644 --- a/src/handlers/sonarr_handlers/library/add_series_handler.rs +++ b/src/handlers/sonarr_handlers/library/add_series_handler.rs @@ -127,8 +127,8 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for AddSeriesHandler<'a, ADD_SERIES_BLOCKS.contains(&active_block) } - fn ignore_alt_navigation(&self) -> bool { - self.app.should_ignore_quit_key + fn ignore_special_keys(&self) -> bool { + self.app.ignore_special_keys_for_textbox_input } fn new( @@ -445,7 +445,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for AddSeriesHandler<'a, self .app .push_navigation_stack(ActiveSonarrBlock::AddSeriesSearchResults.into()); - self.app.should_ignore_quit_key = false; + self.app.ignore_special_keys_for_textbox_input = false; } _ if self.active_sonarr_block == ActiveSonarrBlock::AddSeriesSearchResults && self.app.data.sonarr_data.add_searched_series.is_some() => @@ -514,7 +514,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for AddSeriesHandler<'a, .get_active_block() .into(), ); - self.app.should_ignore_quit_key = true; + self.app.ignore_special_keys_for_textbox_input = true; } ActiveSonarrBlock::AddSeriesToggleUseSeasonFolder => { self @@ -543,7 +543,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for AddSeriesHandler<'a, | ActiveSonarrBlock::AddSeriesSelectRootFolder => self.app.pop_navigation_stack(), ActiveSonarrBlock::AddSeriesTagsInput => { self.app.pop_navigation_stack(); - self.app.should_ignore_quit_key = false; + self.app.ignore_special_keys_for_textbox_input = false; } _ => (), } @@ -554,13 +554,13 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for AddSeriesHandler<'a, ActiveSonarrBlock::AddSeriesSearchInput => { self.app.pop_navigation_stack(); self.app.data.sonarr_data.add_series_search = None; - self.app.should_ignore_quit_key = false; + self.app.ignore_special_keys_for_textbox_input = false; } ActiveSonarrBlock::AddSeriesSearchResults | ActiveSonarrBlock::AddSeriesEmptySearchResults => { self.app.pop_navigation_stack(); self.app.data.sonarr_data.add_searched_series = None; - self.app.should_ignore_quit_key = true; + self.app.ignore_special_keys_for_textbox_input = true; } ActiveSonarrBlock::AddSeriesPrompt => { self.app.pop_navigation_stack(); @@ -575,7 +575,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for AddSeriesHandler<'a, | ActiveSonarrBlock::AddSeriesSelectRootFolder => self.app.pop_navigation_stack(), ActiveSonarrBlock::AddSeriesTagsInput => { self.app.pop_navigation_stack(); - self.app.should_ignore_quit_key = false; + self.app.ignore_special_keys_for_textbox_input = false; } _ => (), } diff --git a/src/handlers/sonarr_handlers/library/add_series_handler_tests.rs b/src/handlers/sonarr_handlers/library/add_series_handler_tests.rs index b1f9bb3..db9740b 100644 --- a/src/handlers/sonarr_handlers/library/add_series_handler_tests.rs +++ b/src/handlers/sonarr_handlers/library/add_series_handler_tests.rs @@ -913,7 +913,7 @@ mod tests { fn test_add_series_search_input_submit() { let mut app = App::test_default(); app.push_navigation_stack(ActiveSonarrBlock::Series.into()); - app.should_ignore_quit_key = true; + app.ignore_special_keys_for_textbox_input = true; app.data.sonarr_data.add_series_search = Some("test".into()); AddSeriesHandler::new( @@ -924,7 +924,7 @@ mod tests { ) .handle(); - assert!(!app.should_ignore_quit_key); + assert!(!app.ignore_special_keys_for_textbox_input); assert_eq!( app.get_current_route(), ActiveSonarrBlock::AddSeriesSearchResults.into() @@ -937,7 +937,7 @@ mod tests { app.data.sonarr_data.add_series_search = Some(HorizontallyScrollableText::default()); app.push_navigation_stack(ActiveSonarrBlock::Series.into()); app.push_navigation_stack(ActiveSonarrBlock::AddSeriesSearchInput.into()); - app.should_ignore_quit_key = true; + app.ignore_special_keys_for_textbox_input = true; AddSeriesHandler::new( SUBMIT_KEY, @@ -947,7 +947,7 @@ mod tests { ) .handle(); - assert!(app.should_ignore_quit_key); + assert!(app.ignore_special_keys_for_textbox_input); assert_eq!( app.get_current_route(), ActiveSonarrBlock::AddSeriesSearchInput.into() @@ -1231,7 +1231,7 @@ mod tests { assert_eq!(app.data.sonarr_data.prompt_confirm_action, None); if selected_block == ActiveSonarrBlock::AddSeriesTagsInput { - assert!(app.should_ignore_quit_key); + assert!(app.ignore_special_keys_for_textbox_input); } } @@ -1260,7 +1260,7 @@ mod tests { ); if active_sonarr_block == ActiveSonarrBlock::AddSeriesTagsInput { - assert!(!app.should_ignore_quit_key); + assert!(!app.ignore_special_keys_for_textbox_input); } } @@ -1337,7 +1337,7 @@ mod tests { let mut app = App::test_default(); app.is_loading = is_ready; app.data.sonarr_data = create_test_sonarr_data(); - app.should_ignore_quit_key = true; + app.ignore_special_keys_for_textbox_input = true; app.push_navigation_stack(ActiveSonarrBlock::Series.into()); app.push_navigation_stack(ActiveSonarrBlock::AddSeriesSearchInput.into()); @@ -1349,7 +1349,7 @@ mod tests { ) .handle(); - assert!(!app.should_ignore_quit_key); + assert!(!app.ignore_special_keys_for_textbox_input); assert_eq!(app.get_current_route(), ActiveSonarrBlock::Series.into()); assert_eq!(app.data.sonarr_data.add_series_search, None); } @@ -1358,7 +1358,7 @@ mod tests { fn test_add_series_input_esc() { let mut app = App::test_default(); app.data.sonarr_data = create_test_sonarr_data(); - app.should_ignore_quit_key = true; + app.ignore_special_keys_for_textbox_input = true; app.push_navigation_stack(ActiveSonarrBlock::Series.into()); app.push_navigation_stack(ActiveSonarrBlock::AddSeriesPrompt.into()); app.push_navigation_stack(ActiveSonarrBlock::AddSeriesTagsInput.into()); @@ -1371,7 +1371,7 @@ mod tests { ) .handle(); - assert!(!app.should_ignore_quit_key); + assert!(!app.ignore_special_keys_for_textbox_input); assert_eq!( app.get_current_route(), ActiveSonarrBlock::AddSeriesPrompt.into() @@ -1404,7 +1404,7 @@ mod tests { ActiveSonarrBlock::AddSeriesSearchInput.into() ); assert!(app.data.sonarr_data.add_searched_series.is_none()); - assert!(app.should_ignore_quit_key); + assert!(app.ignore_special_keys_for_textbox_input); } #[test] @@ -1452,7 +1452,7 @@ mod tests { fn test_add_series_tags_input_esc() { let mut app = App::test_default(); app.data.sonarr_data = create_test_sonarr_data(); - app.should_ignore_quit_key = true; + app.ignore_special_keys_for_textbox_input = true; app.push_navigation_stack(ActiveSonarrBlock::Series.into()); app.push_navigation_stack(ActiveSonarrBlock::AddSeriesPrompt.into()); app.push_navigation_stack(ActiveSonarrBlock::AddSeriesTagsInput.into()); @@ -1465,7 +1465,7 @@ mod tests { ) .handle(); - assert!(!app.should_ignore_quit_key); + assert!(!app.ignore_special_keys_for_textbox_input); assert_eq!( app.get_current_route(), ActiveSonarrBlock::AddSeriesPrompt.into() @@ -1716,11 +1716,11 @@ mod tests { } #[rstest] - fn test_add_series_handler_ignore_alt_navigation( - #[values(true, false)] should_ignore_quit_key: bool, + fn test_add_series_handler_ignore_special_keys( + #[values(true, false)] ignore_special_keys_for_textbox_input: bool, ) { let mut app = App::test_default(); - app.should_ignore_quit_key = should_ignore_quit_key; + app.ignore_special_keys_for_textbox_input = ignore_special_keys_for_textbox_input; let handler = AddSeriesHandler::new( DEFAULT_KEYBINDINGS.esc.key, &mut app, @@ -1728,7 +1728,10 @@ mod tests { None, ); - assert_eq!(handler.ignore_alt_navigation(), should_ignore_quit_key); + assert_eq!( + handler.ignore_special_keys(), + ignore_special_keys_for_textbox_input + ); } #[test] diff --git a/src/handlers/sonarr_handlers/library/delete_series_handler.rs b/src/handlers/sonarr_handlers/library/delete_series_handler.rs index 4b515f8..c98d262 100644 --- a/src/handlers/sonarr_handlers/library/delete_series_handler.rs +++ b/src/handlers/sonarr_handlers/library/delete_series_handler.rs @@ -39,8 +39,8 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for DeleteSeriesHandler< DELETE_SERIES_BLOCKS.contains(&active_block) } - fn ignore_alt_navigation(&self) -> bool { - self.app.should_ignore_quit_key + fn ignore_special_keys(&self) -> bool { + self.app.ignore_special_keys_for_textbox_input } fn new( diff --git a/src/handlers/sonarr_handlers/library/delete_series_handler_tests.rs b/src/handlers/sonarr_handlers/library/delete_series_handler_tests.rs index e3c1601..4c85ec7 100644 --- a/src/handlers/sonarr_handlers/library/delete_series_handler_tests.rs +++ b/src/handlers/sonarr_handlers/library/delete_series_handler_tests.rs @@ -322,11 +322,11 @@ mod tests { } #[rstest] - fn test_delete_series_handler_ignore_alt_navigation( - #[values(true, false)] should_ignore_quit_key: bool, + fn test_delete_series_handler_ignore_special_keys( + #[values(true, false)] ignore_special_keys_for_textbox_input: bool, ) { let mut app = App::test_default(); - app.should_ignore_quit_key = should_ignore_quit_key; + app.ignore_special_keys_for_textbox_input = ignore_special_keys_for_textbox_input; let handler = DeleteSeriesHandler::new( DEFAULT_KEYBINDINGS.esc.key, &mut app, @@ -334,7 +334,10 @@ mod tests { None, ); - assert_eq!(handler.ignore_alt_navigation(), should_ignore_quit_key); + assert_eq!( + handler.ignore_special_keys(), + ignore_special_keys_for_textbox_input + ); } #[test] diff --git a/src/handlers/sonarr_handlers/library/edit_series_handler.rs b/src/handlers/sonarr_handlers/library/edit_series_handler.rs index eb7667e..fa72b4d 100644 --- a/src/handlers/sonarr_handlers/library/edit_series_handler.rs +++ b/src/handlers/sonarr_handlers/library/edit_series_handler.rs @@ -82,8 +82,8 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for EditSeriesHandler<'a EDIT_SERIES_BLOCKS.contains(&active_block) } - fn ignore_alt_navigation(&self) -> bool { - self.app.should_ignore_quit_key + fn ignore_special_keys(&self) -> bool { + self.app.ignore_special_keys_for_textbox_input } fn new( @@ -345,7 +345,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for EditSeriesHandler<'a ) .into(), ); - self.app.should_ignore_quit_key = true; + self.app.ignore_special_keys_for_textbox_input = true; } ActiveSonarrBlock::EditSeriesToggleMonitored => { self @@ -395,7 +395,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for EditSeriesHandler<'a | ActiveSonarrBlock::EditSeriesSelectLanguageProfile => self.app.pop_navigation_stack(), ActiveSonarrBlock::EditSeriesPathInput | ActiveSonarrBlock::EditSeriesTagsInput => { self.app.pop_navigation_stack(); - self.app.should_ignore_quit_key = false; + self.app.ignore_special_keys_for_textbox_input = false; } _ => (), } @@ -405,7 +405,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for EditSeriesHandler<'a match self.active_sonarr_block { ActiveSonarrBlock::EditSeriesTagsInput | ActiveSonarrBlock::EditSeriesPathInput => { self.app.pop_navigation_stack(); - self.app.should_ignore_quit_key = false; + self.app.ignore_special_keys_for_textbox_input = false; } ActiveSonarrBlock::EditSeriesPrompt => { self.app.pop_navigation_stack(); diff --git a/src/handlers/sonarr_handlers/library/edit_series_handler_tests.rs b/src/handlers/sonarr_handlers/library/edit_series_handler_tests.rs index 82e6464..7bb05a1 100644 --- a/src/handlers/sonarr_handlers/library/edit_series_handler_tests.rs +++ b/src/handlers/sonarr_handlers/library/edit_series_handler_tests.rs @@ -678,7 +678,7 @@ mod tests { #[test] fn test_edit_series_path_input_submit() { let mut app = App::test_default(); - app.should_ignore_quit_key = true; + app.ignore_special_keys_for_textbox_input = true; app.data.sonarr_data.edit_series_modal = Some(EditSeriesModal { path: "Test Path".into(), ..EditSeriesModal::default() @@ -695,7 +695,7 @@ mod tests { ) .handle(); - assert!(!app.should_ignore_quit_key); + assert!(!app.ignore_special_keys_for_textbox_input); assert!(!app .data .sonarr_data @@ -714,7 +714,7 @@ mod tests { #[test] fn test_edit_series_tags_input_submit() { let mut app = App::test_default(); - app.should_ignore_quit_key = true; + app.ignore_special_keys_for_textbox_input = true; app.data.sonarr_data.edit_series_modal = Some(EditSeriesModal { tags: "Test Tags".into(), ..EditSeriesModal::default() @@ -731,7 +731,7 @@ mod tests { ) .handle(); - assert!(!app.should_ignore_quit_key); + assert!(!app.ignore_special_keys_for_textbox_input); assert!(!app .data .sonarr_data @@ -1011,7 +1011,7 @@ mod tests { if selected_block == ActiveSonarrBlock::EditSeriesPathInput || selected_block == ActiveSonarrBlock::EditSeriesTagsInput { - assert!(app.should_ignore_quit_key); + assert!(app.ignore_special_keys_for_textbox_input); } } @@ -1050,7 +1050,7 @@ mod tests { .into() ); assert_eq!(app.data.sonarr_data.prompt_confirm_action, None); - assert!(!app.should_ignore_quit_key); + assert!(!app.ignore_special_keys_for_textbox_input); } #[rstest] @@ -1086,7 +1086,7 @@ mod tests { if active_sonarr_block == ActiveSonarrBlock::EditSeriesPathInput || active_sonarr_block == ActiveSonarrBlock::EditSeriesTagsInput { - assert!(!app.should_ignore_quit_key); + assert!(!app.ignore_special_keys_for_textbox_input); } } } @@ -1112,14 +1112,14 @@ mod tests { ) { let mut app = App::test_default(); app.data.sonarr_data = create_test_sonarr_data(); - app.should_ignore_quit_key = true; + app.ignore_special_keys_for_textbox_input = true; app.push_navigation_stack(ActiveSonarrBlock::Series.into()); app.push_navigation_stack(ActiveSonarrBlock::EditSeriesPrompt.into()); app.push_navigation_stack(active_sonarr_block.into()); EditSeriesHandler::new(ESC_KEY, &mut app, active_sonarr_block, None).handle(); - assert!(!app.should_ignore_quit_key); + assert!(!app.ignore_special_keys_for_textbox_input); assert_eq!( app.get_current_route(), ActiveSonarrBlock::EditSeriesPrompt.into() @@ -1370,11 +1370,11 @@ mod tests { } #[rstest] - fn test_edit_series_handler_ignore_alt_navigation( - #[values(true, false)] should_ignore_quit_key: bool, + fn test_edit_series_handler_ignore_special_keys( + #[values(true, false)] ignore_special_keys_for_textbox_input: bool, ) { let mut app = App::test_default(); - app.should_ignore_quit_key = should_ignore_quit_key; + app.ignore_special_keys_for_textbox_input = ignore_special_keys_for_textbox_input; let handler = EditSeriesHandler::new( DEFAULT_KEYBINDINGS.esc.key, &mut app, @@ -1382,7 +1382,10 @@ mod tests { None, ); - assert_eq!(handler.ignore_alt_navigation(), should_ignore_quit_key); + assert_eq!( + handler.ignore_special_keys(), + ignore_special_keys_for_textbox_input + ); } #[test] diff --git a/src/handlers/sonarr_handlers/library/episode_details_handler.rs b/src/handlers/sonarr_handlers/library/episode_details_handler.rs index 4026e62..037c97a 100644 --- a/src/handlers/sonarr_handlers/library/episode_details_handler.rs +++ b/src/handlers/sonarr_handlers/library/episode_details_handler.rs @@ -87,8 +87,8 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for EpisodeDetailsHandle EPISODE_DETAILS_BLOCKS.contains(&active_block) } - fn ignore_alt_navigation(&self) -> bool { - self.app.should_ignore_quit_key + fn ignore_special_keys(&self) -> bool { + self.app.ignore_special_keys_for_textbox_input } fn new( diff --git a/src/handlers/sonarr_handlers/library/episode_details_handler_tests.rs b/src/handlers/sonarr_handlers/library/episode_details_handler_tests.rs index 72cece8..c8bba29 100644 --- a/src/handlers/sonarr_handlers/library/episode_details_handler_tests.rs +++ b/src/handlers/sonarr_handlers/library/episode_details_handler_tests.rs @@ -626,11 +626,11 @@ mod tests { } #[rstest] - fn test_episode_details_handler_ignore_alt_navigation( - #[values(true, false)] should_ignore_quit_key: bool, + fn test_episode_details_handler_ignore_special_keys( + #[values(true, false)] ignore_special_keys_for_textbox_input: bool, ) { let mut app = App::test_default(); - app.should_ignore_quit_key = should_ignore_quit_key; + app.ignore_special_keys_for_textbox_input = ignore_special_keys_for_textbox_input; let handler = EpisodeDetailsHandler::new( DEFAULT_KEYBINDINGS.esc.key, &mut app, @@ -638,7 +638,10 @@ mod tests { None, ); - assert_eq!(handler.ignore_alt_navigation(), should_ignore_quit_key); + assert_eq!( + handler.ignore_special_keys(), + ignore_special_keys_for_textbox_input + ); } #[test] diff --git a/src/handlers/sonarr_handlers/library/library_handler_tests.rs b/src/handlers/sonarr_handlers/library/library_handler_tests.rs index d26046e..829f3dd 100644 --- a/src/handlers/sonarr_handlers/library/library_handler_tests.rs +++ b/src/handlers/sonarr_handlers/library/library_handler_tests.rs @@ -316,7 +316,7 @@ mod tests { app.get_current_route(), ActiveSonarrBlock::AddSeriesSearchInput.into() ); - assert!(app.should_ignore_quit_key); + assert!(app.ignore_special_keys_for_textbox_input); assert!(app.data.sonarr_data.add_series_search.is_some()); } @@ -340,7 +340,7 @@ mod tests { .handle(); assert_eq!(app.get_current_route(), ActiveSonarrBlock::Series.into()); - assert!(!app.should_ignore_quit_key); + assert!(!app.ignore_special_keys_for_textbox_input); assert!(app.data.sonarr_data.add_series_search.is_none()); } @@ -828,11 +828,11 @@ mod tests { } #[rstest] - fn test_library_handler_ignore_alt_navigation( - #[values(true, false)] should_ignore_quit_key: bool, + fn test_library_handler_ignore_special_keys( + #[values(true, false)] ignore_special_keys_for_textbox_input: bool, ) { let mut app = App::test_default(); - app.should_ignore_quit_key = should_ignore_quit_key; + app.ignore_special_keys_for_textbox_input = ignore_special_keys_for_textbox_input; let handler = LibraryHandler::new( DEFAULT_KEYBINDINGS.esc.key, &mut app, @@ -840,7 +840,10 @@ mod tests { None, ); - assert_eq!(handler.ignore_alt_navigation(), should_ignore_quit_key); + assert_eq!( + handler.ignore_special_keys(), + ignore_special_keys_for_textbox_input + ); } #[test] diff --git a/src/handlers/sonarr_handlers/library/mod.rs b/src/handlers/sonarr_handlers/library/mod.rs index 068b986..ec14f0e 100644 --- a/src/handlers/sonarr_handlers/library/mod.rs +++ b/src/handlers/sonarr_handlers/library/mod.rs @@ -102,8 +102,8 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for LibraryHandler<'a, ' || LIBRARY_BLOCKS.contains(&active_block) } - fn ignore_alt_navigation(&self) -> bool { - self.app.should_ignore_quit_key + fn ignore_special_keys(&self) -> bool { + self.app.ignore_special_keys_for_textbox_input } fn new( @@ -203,7 +203,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for LibraryHandler<'a, ' .app .push_navigation_stack(ActiveSonarrBlock::AddSeriesSearchInput.into()); self.app.data.sonarr_data.add_series_search = Some(HorizontallyScrollableText::default()); - self.app.should_ignore_quit_key = true; + self.app.ignore_special_keys_for_textbox_input = true; } _ if matches_key!(update, key) => { self diff --git a/src/handlers/sonarr_handlers/library/season_details_handler.rs b/src/handlers/sonarr_handlers/library/season_details_handler.rs index d3cf187..51708b2 100644 --- a/src/handlers/sonarr_handlers/library/season_details_handler.rs +++ b/src/handlers/sonarr_handlers/library/season_details_handler.rs @@ -139,8 +139,8 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for SeasonDetailsHandler SEASON_DETAILS_BLOCKS.contains(&active_block) } - fn ignore_alt_navigation(&self) -> bool { - self.app.should_ignore_quit_key + fn ignore_special_keys(&self) -> bool { + self.app.ignore_special_keys_for_textbox_input } fn new( diff --git a/src/handlers/sonarr_handlers/library/season_details_handler_tests.rs b/src/handlers/sonarr_handlers/library/season_details_handler_tests.rs index ec3f25c..da6c073 100644 --- a/src/handlers/sonarr_handlers/library/season_details_handler_tests.rs +++ b/src/handlers/sonarr_handlers/library/season_details_handler_tests.rs @@ -790,11 +790,11 @@ mod tests { } #[rstest] - fn test_season_details_handler_ignore_alt_navigation( - #[values(true, false)] should_ignore_quit_key: bool, + fn test_season_details_handler_ignore_special_keys( + #[values(true, false)] ignore_special_keys_for_textbox_input: bool, ) { let mut app = App::test_default(); - app.should_ignore_quit_key = should_ignore_quit_key; + app.ignore_special_keys_for_textbox_input = ignore_special_keys_for_textbox_input; let handler = SeasonDetailsHandler::new( DEFAULT_KEYBINDINGS.esc.key, &mut app, @@ -802,7 +802,10 @@ mod tests { None, ); - assert_eq!(handler.ignore_alt_navigation(), should_ignore_quit_key); + assert_eq!( + handler.ignore_special_keys(), + ignore_special_keys_for_textbox_input + ); } #[test] diff --git a/src/handlers/sonarr_handlers/library/series_details_handler.rs b/src/handlers/sonarr_handlers/library/series_details_handler.rs index 723f629..a87a419 100644 --- a/src/handlers/sonarr_handlers/library/series_details_handler.rs +++ b/src/handlers/sonarr_handlers/library/series_details_handler.rs @@ -90,8 +90,8 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for SeriesDetailsHandler SERIES_DETAILS_BLOCKS.contains(&active_block) } - fn ignore_alt_navigation(&self) -> bool { - self.app.should_ignore_quit_key + fn ignore_special_keys(&self) -> bool { + self.app.ignore_special_keys_for_textbox_input } fn new( diff --git a/src/handlers/sonarr_handlers/library/series_details_handler_tests.rs b/src/handlers/sonarr_handlers/library/series_details_handler_tests.rs index c534c2e..9d1ccda 100644 --- a/src/handlers/sonarr_handlers/library/series_details_handler_tests.rs +++ b/src/handlers/sonarr_handlers/library/series_details_handler_tests.rs @@ -612,11 +612,11 @@ mod tests { } #[rstest] - fn test_series_details_handler_ignore_alt_navigation( - #[values(true, false)] should_ignore_quit_key: bool, + fn test_series_details_handler_ignore_special_keys( + #[values(true, false)] ignore_special_keys_for_textbox_input: bool, ) { let mut app = App::test_default(); - app.should_ignore_quit_key = should_ignore_quit_key; + app.ignore_special_keys_for_textbox_input = ignore_special_keys_for_textbox_input; let handler = SeriesDetailsHandler::new( DEFAULT_KEYBINDINGS.esc.key, &mut app, @@ -624,7 +624,10 @@ mod tests { None, ); - assert_eq!(handler.ignore_alt_navigation(), should_ignore_quit_key); + assert_eq!( + handler.ignore_special_keys(), + ignore_special_keys_for_textbox_input + ); } #[test] diff --git a/src/handlers/sonarr_handlers/mod.rs b/src/handlers/sonarr_handlers/mod.rs index 100b935..2a05c69 100644 --- a/src/handlers/sonarr_handlers/mod.rs +++ b/src/handlers/sonarr_handlers/mod.rs @@ -67,8 +67,8 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for SonarrHandler<'a, 'b true } - fn ignore_alt_navigation(&self) -> bool { - self.app.should_ignore_quit_key + fn ignore_special_keys(&self) -> bool { + self.app.ignore_special_keys_for_textbox_input } fn new( @@ -115,11 +115,11 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for SonarrHandler<'a, 'b pub fn handle_change_tab_left_right_keys(app: &mut App<'_>, key: Key) { let key_ref = key; match key_ref { - _ if matches_key!(left, key, app.should_ignore_quit_key) => { + _ if matches_key!(left, key, app.ignore_special_keys_for_textbox_input) => { app.data.sonarr_data.main_tabs.previous(); app.pop_and_push_navigation_stack(app.data.sonarr_data.main_tabs.get_active_route()); } - _ if matches_key!(right, key, app.should_ignore_quit_key) => { + _ if matches_key!(right, key, app.ignore_special_keys_for_textbox_input) => { app.data.sonarr_data.main_tabs.next(); app.pop_and_push_navigation_stack(app.data.sonarr_data.main_tabs.get_active_route()); } diff --git a/src/handlers/sonarr_handlers/root_folders/mod.rs b/src/handlers/sonarr_handlers/root_folders/mod.rs index 4aceb14..3d27a59 100644 --- a/src/handlers/sonarr_handlers/root_folders/mod.rs +++ b/src/handlers/sonarr_handlers/root_folders/mod.rs @@ -67,8 +67,8 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for RootFoldersHandler<' ROOT_FOLDERS_BLOCKS.contains(&active_block) } - fn ignore_alt_navigation(&self) -> bool { - self.app.should_ignore_quit_key + fn ignore_special_keys(&self) -> bool { + self.app.ignore_special_keys_for_textbox_input } fn new( @@ -171,7 +171,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for RootFoldersHandler<' self.build_add_root_folder_body(), )); self.app.data.sonarr_data.prompt_confirm = true; - self.app.should_ignore_quit_key = false; + self.app.ignore_special_keys_for_textbox_input = false; self.app.pop_navigation_stack(); } _ => (), @@ -184,7 +184,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for RootFoldersHandler<' self.app.pop_navigation_stack(); self.app.data.sonarr_data.edit_root_folder = None; self.app.data.sonarr_data.prompt_confirm = false; - self.app.should_ignore_quit_key = false; + self.app.ignore_special_keys_for_textbox_input = false; } ActiveSonarrBlock::DeleteRootFolderPrompt => { self.app.pop_navigation_stack(); @@ -206,7 +206,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for RootFoldersHandler<' .app .push_navigation_stack(ActiveSonarrBlock::AddRootFolderPrompt.into()); self.app.data.sonarr_data.edit_root_folder = Some(HorizontallyScrollableText::default()); - self.app.should_ignore_quit_key = true; + self.app.ignore_special_keys_for_textbox_input = true; } _ => (), }, diff --git a/src/handlers/sonarr_handlers/root_folders/root_folders_handler_tests.rs b/src/handlers/sonarr_handlers/root_folders/root_folders_handler_tests.rs index 5719db2..aeb3c50 100644 --- a/src/handlers/sonarr_handlers/root_folders/root_folders_handler_tests.rs +++ b/src/handlers/sonarr_handlers/root_folders/root_folders_handler_tests.rs @@ -270,7 +270,7 @@ mod tests { .set_items(vec![RootFolder::default()]); app.data.sonarr_data.edit_root_folder = Some("Test".into()); app.data.sonarr_data.prompt_confirm = true; - app.should_ignore_quit_key = true; + app.ignore_special_keys_for_textbox_input = true; app.push_navigation_stack(ActiveSonarrBlock::RootFolders.into()); app.push_navigation_stack(ActiveSonarrBlock::AddRootFolderPrompt.into()); @@ -283,7 +283,7 @@ mod tests { .handle(); assert!(app.data.sonarr_data.prompt_confirm); - assert!(!app.should_ignore_quit_key); + assert!(!app.ignore_special_keys_for_textbox_input); assert_eq!( app.data.sonarr_data.prompt_confirm_action, Some(SonarrEvent::AddRootFolder(expected_add_root_folder_body)) @@ -300,7 +300,7 @@ mod tests { let mut app = App::test_default(); app.data.sonarr_data.edit_root_folder = Some(HorizontallyScrollableText::default()); app.data.sonarr_data.prompt_confirm = false; - app.should_ignore_quit_key = true; + app.ignore_special_keys_for_textbox_input = true; app.push_navigation_stack(ActiveSonarrBlock::RootFolders.into()); app.push_navigation_stack(ActiveSonarrBlock::AddRootFolderPrompt.into()); @@ -313,7 +313,7 @@ mod tests { .handle(); assert!(!app.data.sonarr_data.prompt_confirm); - assert!(app.should_ignore_quit_key); + assert!(app.ignore_special_keys_for_textbox_input); assert!(app.data.sonarr_data.prompt_confirm_action.is_none()); assert_eq!( app.get_current_route(), @@ -415,7 +415,7 @@ mod tests { app.push_navigation_stack(ActiveSonarrBlock::RootFolders.into()); app.push_navigation_stack(ActiveSonarrBlock::AddRootFolderPrompt.into()); app.data.sonarr_data.edit_root_folder = Some("/nfs/test".into()); - app.should_ignore_quit_key = true; + app.ignore_special_keys_for_textbox_input = true; RootFoldersHandler::new( ESC_KEY, @@ -432,7 +432,7 @@ mod tests { assert!(app.data.sonarr_data.edit_root_folder.is_none()); assert!(!app.data.sonarr_data.prompt_confirm); - assert!(!app.should_ignore_quit_key); + assert!(!app.ignore_special_keys_for_textbox_input); } #[rstest] @@ -482,7 +482,7 @@ mod tests { app.get_current_route(), ActiveSonarrBlock::AddRootFolderPrompt.into() ); - assert!(app.should_ignore_quit_key); + assert!(app.ignore_special_keys_for_textbox_input); assert!(app.data.sonarr_data.edit_root_folder.is_some()); } @@ -509,7 +509,7 @@ mod tests { app.get_current_route(), ActiveSonarrBlock::RootFolders.into() ); - assert!(!app.should_ignore_quit_key); + assert!(!app.ignore_special_keys_for_textbox_input); assert!(app.data.sonarr_data.edit_root_folder.is_none()); } @@ -657,11 +657,11 @@ mod tests { } #[rstest] - fn test_root_folders_handler_ignore_alt_navigation( - #[values(true, false)] should_ignore_quit_key: bool, + fn test_root_folders_handler_ignore_special_keys( + #[values(true, false)] ignore_special_keys_for_textbox_input: bool, ) { let mut app = App::test_default(); - app.should_ignore_quit_key = should_ignore_quit_key; + app.ignore_special_keys_for_textbox_input = ignore_special_keys_for_textbox_input; let handler = RootFoldersHandler::new( DEFAULT_KEYBINDINGS.esc.key, &mut app, @@ -669,7 +669,10 @@ mod tests { None, ); - assert_eq!(handler.ignore_alt_navigation(), should_ignore_quit_key); + assert_eq!( + handler.ignore_special_keys(), + ignore_special_keys_for_textbox_input + ); } #[test] diff --git a/src/handlers/sonarr_handlers/sonarr_handler_tests.rs b/src/handlers/sonarr_handlers/sonarr_handler_tests.rs index 4edb3dd..8dd160d 100644 --- a/src/handlers/sonarr_handlers/sonarr_handler_tests.rs +++ b/src/handlers/sonarr_handlers/sonarr_handler_tests.rs @@ -95,7 +95,7 @@ mod tests { ) { let mut app = App::test_default(); app.push_navigation_stack(block.into()); - app.should_ignore_quit_key = true; + app.ignore_special_keys_for_textbox_input = true; app.data.sonarr_data.main_tabs.set_index(index); handle_change_tab_left_right_keys(&mut app, DEFAULT_KEYBINDINGS.left.alt.unwrap()); @@ -300,11 +300,11 @@ mod tests { } #[rstest] - fn test_sonarr_handler_ignore_alt_navigation( - #[values(true, false)] should_ignore_quit_key: bool, + fn test_sonarr_handler_ignore_special_keys( + #[values(true, false)] ignore_special_keys_for_textbox_input: bool, ) { let mut app = App::test_default(); - app.should_ignore_quit_key = should_ignore_quit_key; + app.ignore_special_keys_for_textbox_input = ignore_special_keys_for_textbox_input; let handler = SonarrHandler::new( DEFAULT_KEYBINDINGS.esc.key, &mut app, @@ -312,7 +312,10 @@ mod tests { None, ); - assert_eq!(handler.ignore_alt_navigation(), should_ignore_quit_key); + assert_eq!( + handler.ignore_special_keys(), + ignore_special_keys_for_textbox_input + ); } #[test] diff --git a/src/handlers/sonarr_handlers/system/mod.rs b/src/handlers/sonarr_handlers/system/mod.rs index 8cf721c..f792f77 100644 --- a/src/handlers/sonarr_handlers/system/mod.rs +++ b/src/handlers/sonarr_handlers/system/mod.rs @@ -35,8 +35,8 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for SystemHandler<'a, 'b SystemDetailsHandler::accepts(active_block) || active_block == ActiveSonarrBlock::System } - fn ignore_alt_navigation(&self) -> bool { - self.app.should_ignore_quit_key + fn ignore_special_keys(&self) -> bool { + self.app.ignore_special_keys_for_textbox_input } fn new( diff --git a/src/handlers/sonarr_handlers/system/system_details_handler.rs b/src/handlers/sonarr_handlers/system/system_details_handler.rs index f309552..7615581 100644 --- a/src/handlers/sonarr_handlers/system/system_details_handler.rs +++ b/src/handlers/sonarr_handlers/system/system_details_handler.rs @@ -36,8 +36,8 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for SystemDetailsHandler SYSTEM_DETAILS_BLOCKS.contains(&active_block) } - fn ignore_alt_navigation(&self) -> bool { - self.app.should_ignore_quit_key + fn ignore_special_keys(&self) -> bool { + self.app.ignore_special_keys_for_textbox_input } fn new( diff --git a/src/handlers/sonarr_handlers/system/system_details_handler_tests.rs b/src/handlers/sonarr_handlers/system/system_details_handler_tests.rs index eb7817b..57118c1 100644 --- a/src/handlers/sonarr_handlers/system/system_details_handler_tests.rs +++ b/src/handlers/sonarr_handlers/system/system_details_handler_tests.rs @@ -962,11 +962,11 @@ mod tests { } #[rstest] - fn test_system_details_handler_ignore_alt_navigation( - #[values(true, false)] should_ignore_quit_key: bool, + fn test_system_details_handler_ignore_special_keys( + #[values(true, false)] ignore_special_keys_for_textbox_input: bool, ) { let mut app = App::test_default(); - app.should_ignore_quit_key = should_ignore_quit_key; + app.ignore_special_keys_for_textbox_input = ignore_special_keys_for_textbox_input; let handler = SystemDetailsHandler::new( DEFAULT_KEYBINDINGS.esc.key, &mut app, @@ -974,7 +974,10 @@ mod tests { None, ); - assert_eq!(handler.ignore_alt_navigation(), should_ignore_quit_key); + assert_eq!( + handler.ignore_special_keys(), + ignore_special_keys_for_textbox_input + ); } #[test] diff --git a/src/handlers/sonarr_handlers/system/system_handler_tests.rs b/src/handlers/sonarr_handlers/system/system_handler_tests.rs index e772f4d..2678086 100644 --- a/src/handlers/sonarr_handlers/system/system_handler_tests.rs +++ b/src/handlers/sonarr_handlers/system/system_handler_tests.rs @@ -457,11 +457,11 @@ mod tests { } #[rstest] - fn test_system_handler_ignore_alt_navigation( - #[values(true, false)] should_ignore_quit_key: bool, + fn test_system_handler_ignore_special_keys( + #[values(true, false)] ignore_special_keys_for_textbox_input: bool, ) { let mut app = App::test_default(); - app.should_ignore_quit_key = should_ignore_quit_key; + app.ignore_special_keys_for_textbox_input = ignore_special_keys_for_textbox_input; let handler = SystemHandler::new( DEFAULT_KEYBINDINGS.esc.key, &mut app, @@ -469,7 +469,10 @@ mod tests { None, ); - assert_eq!(handler.ignore_alt_navigation(), should_ignore_quit_key); + assert_eq!( + handler.ignore_special_keys(), + ignore_special_keys_for_textbox_input + ); } #[test] diff --git a/src/handlers/table_handler.rs b/src/handlers/table_handler.rs index 884f413..f0e32fc 100644 --- a/src/handlers/table_handler.rs +++ b/src/handlers/table_handler.rs @@ -42,12 +42,12 @@ macro_rules! handle_table_events { fn [](&mut $self, config: $crate::handlers::table_handler::TableHandlingConfig<$row>) -> bool { if $self.is_ready() { match $self.key { - _ if $crate::matches_key!(up, $self.key, $self.ignore_alt_navigation()) => $self.[](config), - _ if $crate::matches_key!(down, $self.key, $self.ignore_alt_navigation()) => $self.[](config), + _ if $crate::matches_key!(up, $self.key, $self.ignore_special_keys()) => $self.[](config), + _ if $crate::matches_key!(down, $self.key, $self.ignore_special_keys()) => $self.[](config), _ if $crate::matches_key!(home, $self.key) => $self.[](config), _ if $crate::matches_key!(end, $self.key) => $self.[](config), - _ if $crate::matches_key!(left, $self.key, $self.ignore_alt_navigation()) - || $crate::matches_key!(right, $self.key, $self.ignore_alt_navigation()) => + _ if $crate::matches_key!(left, $self.key, $self.ignore_special_keys()) + || $crate::matches_key!(right, $self.key, $self.ignore_special_keys()) => { $self.[](config) } @@ -244,7 +244,7 @@ macro_rules! handle_table_events { && $self.app.get_current_route() == *config.searching_block.as_ref().unwrap() => { $self.app.pop_navigation_stack(); - $self.app.should_ignore_quit_key = false; + $self.app.ignore_special_keys_for_textbox_input = false; if $table.search.is_some() { let search_field_fn = config @@ -267,7 +267,7 @@ macro_rules! handle_table_events { && $self.app.get_current_route() == *config.filtering_block.as_ref().unwrap() => { $self.app.pop_navigation_stack(); - $self.app.should_ignore_quit_key = false; + $self.app.ignore_special_keys_for_textbox_input = false; if $table.filter.is_some() { let filter_field_fn = config @@ -305,7 +305,7 @@ macro_rules! handle_table_events { { $self.app.pop_navigation_stack(); $table.reset_search(); - $self.app.should_ignore_quit_key = false; + $self.app.ignore_special_keys_for_textbox_input = false; true } _ if (config.filtering_block.is_some() @@ -315,7 +315,7 @@ macro_rules! handle_table_events { { $self.app.pop_navigation_stack(); $table.reset_filter(); - $self.app.should_ignore_quit_key = false; + $self.app.ignore_special_keys_for_textbox_input = false; true } _ if config.table_block == $self.app.get_current_route() @@ -335,7 +335,7 @@ macro_rules! handle_table_events { .push_navigation_stack(config.filtering_block.expect("Filtering block is undefined").into()); $table.reset_filter(); $table.filter = Some($crate::models::HorizontallyScrollableText::default()); - $self.app.should_ignore_quit_key = true; + $self.app.ignore_special_keys_for_textbox_input = true; true } else { @@ -349,7 +349,7 @@ macro_rules! handle_table_events { .app .push_navigation_stack(config.searching_block.expect("Searching block is undefined")); $table.search = Some($crate::models::HorizontallyScrollableText::default()); - $self.app.should_ignore_quit_key = true; + $self.app.ignore_special_keys_for_textbox_input = true; true } else { diff --git a/src/handlers/table_handler_tests.rs b/src/handlers/table_handler_tests.rs index 0418557..a0eeb65 100644 --- a/src/handlers/table_handler_tests.rs +++ b/src/handlers/table_handler_tests.rs @@ -48,8 +48,8 @@ mod tests { true } - fn ignore_alt_navigation(&self) -> bool { - self.app.should_ignore_quit_key + fn ignore_special_keys(&self) -> bool { + self.app.ignore_special_keys_for_textbox_input } fn new( @@ -652,7 +652,7 @@ mod tests { TableHandlerUnit::new(SUBMIT_KEY, &mut app, ActiveRadarrBlock::FilterMovies, None).handle(); assert!(app.data.radarr_data.movies.filtered_items.is_some()); - assert!(!app.should_ignore_quit_key); + assert!(!app.ignore_special_keys_for_textbox_input); assert_eq!( app .data @@ -688,7 +688,7 @@ mod tests { TableHandlerUnit::new(SUBMIT_KEY, &mut app, ActiveRadarrBlock::FilterMovies, None).handle(); - assert!(!app.should_ignore_quit_key); + assert!(!app.ignore_special_keys_for_textbox_input); assert!(app.data.radarr_data.movies.filtered_items.is_none()); assert_eq!( app.get_current_route(), @@ -739,7 +739,7 @@ mod tests { active_radarr_block: ActiveRadarrBlock, ) { let mut app = App::test_default(); - app.should_ignore_quit_key = true; + app.ignore_special_keys_for_textbox_input = true; app.push_navigation_stack(ActiveRadarrBlock::Movies.into()); app.push_navigation_stack(active_radarr_block.into()); app.data.radarr_data = create_test_radarr_data(); @@ -748,7 +748,7 @@ mod tests { TableHandlerUnit::new(ESC_KEY, &mut app, active_radarr_block, None).handle(); assert_eq!(app.get_current_route(), ActiveRadarrBlock::Movies.into()); - assert!(!app.should_ignore_quit_key); + assert!(!app.ignore_special_keys_for_textbox_input); assert_eq!(app.data.radarr_data.movies.search, None); } @@ -758,7 +758,7 @@ mod tests { active_radarr_block: ActiveRadarrBlock, ) { let mut app = App::test_default(); - app.should_ignore_quit_key = true; + app.ignore_special_keys_for_textbox_input = true; app.push_navigation_stack(ActiveRadarrBlock::Movies.into()); app.push_navigation_stack(active_radarr_block.into()); app.data.radarr_data = create_test_radarr_data(); @@ -777,7 +777,7 @@ mod tests { TableHandlerUnit::new(ESC_KEY, &mut app, active_radarr_block, None).handle(); assert_eq!(app.get_current_route(), ActiveRadarrBlock::Movies.into()); - assert!(!app.should_ignore_quit_key); + assert!(!app.ignore_special_keys_for_textbox_input); assert_eq!(app.data.radarr_data.movies.filter, None); assert_eq!(app.data.radarr_data.movies.filtered_items, None); assert_eq!(app.data.radarr_data.movies.filtered_state, None); @@ -824,7 +824,7 @@ mod tests { app.get_current_route(), ActiveRadarrBlock::SearchMovie.into() ); - assert!(app.should_ignore_quit_key); + assert!(app.ignore_special_keys_for_textbox_input); assert_eq!( app.data.radarr_data.movies.search, Some(HorizontallyScrollableText::default()) @@ -851,7 +851,7 @@ mod tests { .handle(); assert_eq!(app.get_current_route(), ActiveRadarrBlock::Movies.into()); - assert!(!app.should_ignore_quit_key); + assert!(!app.ignore_special_keys_for_textbox_input); assert_eq!(app.data.radarr_data.movies.search, None); } @@ -873,7 +873,7 @@ mod tests { .handle(); assert_eq!(app.get_current_route(), ActiveRadarrBlock::Movies.into()); - assert!(!app.should_ignore_quit_key); + assert!(!app.ignore_special_keys_for_textbox_input); assert_eq!(app.data.radarr_data.movies.search, None); } @@ -898,7 +898,7 @@ mod tests { app.get_current_route(), ActiveRadarrBlock::FilterMovies.into() ); - assert!(app.should_ignore_quit_key); + assert!(app.ignore_special_keys_for_textbox_input); assert!(app.data.radarr_data.movies.filter.is_some()); } @@ -922,14 +922,14 @@ mod tests { .handle(); assert_eq!(app.get_current_route(), ActiveRadarrBlock::Movies.into()); - assert!(!app.should_ignore_quit_key); + assert!(!app.ignore_special_keys_for_textbox_input); assert!(app.data.radarr_data.movies.filter.is_none()); } #[test] fn test_filter_table_key_resets_previous_filter() { let mut app = App::test_default(); - app.should_ignore_quit_key = true; + app.ignore_special_keys_for_textbox_input = true; app.push_navigation_stack(ActiveRadarrBlock::Movies.into()); app.data.radarr_data = create_test_radarr_data(); app @@ -951,7 +951,7 @@ mod tests { app.get_current_route(), ActiveRadarrBlock::FilterMovies.into() ); - assert!(app.should_ignore_quit_key); + assert!(app.ignore_special_keys_for_textbox_input); assert_eq!( app.data.radarr_data.movies.filter, Some(HorizontallyScrollableText::default()) @@ -978,7 +978,7 @@ mod tests { .handle(); assert_eq!(app.get_current_route(), ActiveRadarrBlock::Movies.into()); - assert!(!app.should_ignore_quit_key); + assert!(!app.ignore_special_keys_for_textbox_input); assert_eq!(app.data.radarr_data.movies.filter, None); } diff --git a/src/main.rs b/src/main.rs index 39238c3..45799a9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -246,7 +246,7 @@ async fn start_ui( match input_events.next()? { InputEvent::KeyEvent(key) => { - if key == Key::Char('q') && !app.should_ignore_quit_key { + if key == Key::Char('q') && !app.ignore_special_keys_for_textbox_input { break; }