fix: Updated the name of the should_ignore_quit_key to ignore_special_keys_for_textbox_input to give a better idea of what the flag is used for; also added alt keybinding for backspace

This commit is contained in:
2025-03-27 15:21:44 -06:00
parent f25829f3c1
commit cf00d7992e
80 changed files with 584 additions and 435 deletions
@@ -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]
@@ -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(
@@ -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]
@@ -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(
@@ -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]
+2 -2
View File
@@ -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(
@@ -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(),
}
@@ -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]
@@ -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(
@@ -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]
@@ -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]
+2 -2
View File
@@ -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(
@@ -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(
@@ -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]
@@ -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;
}
_ => (),
}
@@ -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]
@@ -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(
@@ -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]
@@ -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();
@@ -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]
@@ -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(
@@ -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]
@@ -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]
+3 -3
View File
@@ -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
@@ -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(
@@ -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]
@@ -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(
@@ -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]
+4 -4
View File
@@ -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());
}
@@ -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;
}
_ => (),
},
@@ -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]
@@ -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]
+2 -2
View File
@@ -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(
@@ -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(
@@ -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]
@@ -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]