diff options
author | Canop <cano.petrole@gmail.com> | 2021-04-05 15:04:47 +0200 |
---|---|---|
committer | Canop <cano.petrole@gmail.com> | 2021-04-05 15:04:47 +0200 |
commit | 61911a7c39d44aa0cba70718afeca5084d26a889 (patch) | |
tree | 7c59f38b20ed8277996d65e1dc89349ddacf3dc9 | |
parent | 685836c7a465f992e6a4f2a3f4c2feca23df3403 (diff) |
rename some types to bring them closer from their use
The AppState was named this way when there was only one
panel. Now it's not the whole app state anymore.
-rw-r--r-- | src/app/app.rs | 6 | ||||
-rw-r--r-- | src/app/cmd_result.rs | 56 | ||||
-rw-r--r-- | src/app/mod.rs | 6 | ||||
-rw-r--r-- | src/app/panel.rs | 12 | ||||
-rw-r--r-- | src/app/panel_state.rs (renamed from src/app/state.rs) | 90 | ||||
-rw-r--r-- | src/app/selection.rs | 12 | ||||
-rw-r--r-- | src/app/standard_status.rs | 12 | ||||
-rw-r--r-- | src/app/state_type.rs | 2 | ||||
-rw-r--r-- | src/browser/browser_state.rs | 82 | ||||
-rw-r--r-- | src/filesystems/filesystems_state.rs | 36 | ||||
-rw-r--r-- | src/help/help_state.rs | 32 | ||||
-rw-r--r-- | src/preview/preview_state.rs | 58 | ||||
-rw-r--r-- | src/print.rs | 20 | ||||
-rw-r--r-- | src/verb/external_execution.rs | 18 | ||||
-rw-r--r-- | src/verb/internal_focus.rs | 18 |
15 files changed, 230 insertions, 230 deletions
diff --git a/src/app/app.rs b/src/app/app.rs index c18deb3..d6c8cc9 100644 --- a/src/app/app.rs +++ b/src/app/app.rs @@ -118,10 +118,10 @@ impl App { self.panels.iter().position(|panel| panel.id == id) } - fn state(&self) -> &dyn AppState { + fn state(&self) -> &dyn PanelState { self.panels[self.active_panel_idx].state() } - fn mut_state(&mut self) -> &mut dyn AppState { + fn mut_state(&mut self) -> &mut dyn PanelState { self.panels[self.active_panel_idx].mut_state() } fn panel(&self) -> &Panel { @@ -243,7 +243,7 @@ impl App { panel_skin: &PanelSkin, con: &AppContext, ) -> Result<(), ProgramError> { - use AppStateCmdResult::*; + use CmdResult::*; let mut error: Option<String> = None; let is_input_invocation = cmd.is_verb_invocated_from_input(); let other_path = self.get_other_panel_path(); diff --git a/src/app/cmd_result.rs b/src/app/cmd_result.rs index 9c822a0..c0cfcde 100644 --- a/src/app/cmd_result.rs +++ b/src/app/cmd_result.rs @@ -28,7 +28,7 @@ pub enum PanelReference { } /// Result of applying a command to a state -pub enum AppStateCmdResult { +pub enum CmdResult { ApplyOnPanel { id: PanelId, }, @@ -44,11 +44,11 @@ pub enum AppStateCmdResult { Keep, Launch(Box<Launchable>), NewPanel { - state: Box<dyn AppState>, + state: Box<dyn PanelState>, purpose: PanelPurpose, direction: HDir, }, - NewState(Box<dyn AppState>), + NewState(Box<dyn PanelState>), PopStateAndReapply, // the state asks the command be executed on a previous state PopState, Quit, @@ -57,62 +57,62 @@ pub enum AppStateCmdResult { }, } -impl AppStateCmdResult { - pub fn verb_not_found(text: &str) -> AppStateCmdResult { - AppStateCmdResult::DisplayError(format!("verb not found: {:?}", &text)) +impl CmdResult { + pub fn verb_not_found(text: &str) -> CmdResult { + CmdResult::DisplayError(format!("verb not found: {:?}", &text)) } pub fn from_optional_state( os: Result<Option<BrowserState>, TreeBuildError>, in_new_panel: bool, - ) -> AppStateCmdResult { + ) -> CmdResult { match os { Ok(Some(os)) => { if in_new_panel { - AppStateCmdResult::NewPanel { + CmdResult::NewPanel { state: Box::new(os), purpose: PanelPurpose::None, direction: HDir::Right, } } else { - AppStateCmdResult::NewState(Box::new(os)) + CmdResult::NewState(Box::new(os)) } } - Ok(None) => AppStateCmdResult::Keep, - Err(e) => AppStateCmdResult::DisplayError(e.to_string()), + Ok(None) => CmdResult::Keep, + Err(e) => CmdResult::DisplayError(e.to_string()), } } } -impl From<Launchable> for AppStateCmdResult { +impl From<Launchable> for CmdResult { fn from(launchable: Launchable) -> Self { - AppStateCmdResult::Launch(Box::new(launchable)) + CmdResult::Launch(Box::new(launchable)) } } -impl fmt::Debug for AppStateCmdResult { +impl fmt::Debug for CmdResult { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!( f, "{}", match self { - AppStateCmdResult::ApplyOnPanel { .. } => "ApplyOnPanel", - AppStateCmdResult::ClosePanel { + CmdResult::ApplyOnPanel { .. } => "ApplyOnPanel", + CmdResult::ClosePanel { validate_purpose: false, .. } => "CancelPanel", - AppStateCmdResult::ClosePanel { + CmdResult::ClosePanel { validate_purpose: true, .. } => "OkPanel", - AppStateCmdResult::DisplayError(_) => "DisplayError", - AppStateCmdResult::ExecuteSequence{ .. } => "ExecuteSequence", - AppStateCmdResult::Keep => "Keep", - AppStateCmdResult::Launch(_) => "Launch", - AppStateCmdResult::NewState { .. } => "NewState", - AppStateCmdResult::NewPanel { .. } => "NewPanel", - AppStateCmdResult::PopStateAndReapply => "PopStateAndReapply", - AppStateCmdResult::PopState => "PopState", - AppStateCmdResult::HandleInApp(_) => "HandleInApp", - AppStateCmdResult::Quit => "Quit", - AppStateCmdResult::RefreshState { .. } => "RefreshState", + CmdResult::DisplayError(_) => "DisplayError", + CmdResult::ExecuteSequence{ .. } => "ExecuteSequence", + CmdResult::Keep => "Keep", + CmdResult::Launch(_) => "Launch", + CmdResult::NewState { .. } => "NewState", + CmdResult::NewPanel { .. } => "NewPanel", + CmdResult::PopStateAndReapply => "PopStateAndReapply", + CmdResult::PopState => "PopState", + CmdResult::HandleInApp(_) => "HandleInApp", + CmdResult::Quit => "Quit", + CmdResult::RefreshState { .. } => "RefreshState", } ) } diff --git a/src/app/mod.rs b/src/app/mod.rs index 361e3fe..5204735 100644 --- a/src/app/mod.rs +++ b/src/app/mod.rs @@ -6,9 +6,9 @@ mod mode; mod panel; mod panel_id; mod panel_purpose; +mod panel_state; mod selection; mod standard_status; -mod state; mod state_type; mod status; @@ -21,9 +21,9 @@ pub use { panel::Panel, panel_id::PanelId, panel_purpose::PanelPurpose, + panel_state::*, selection::{LineNumber, Selection, SelectionType}, standard_status::StandardStatus, - state::*, - state_type::AppStateType, + state_type::PanelStateType, status::Status, }; diff --git a/src/app/panel.rs b/src/app/panel.rs index e638d38..17efdcc 100644 --- a/src/app/panel.rs +++ b/src/app/panel.rs @@ -25,7 +25,7 @@ use { /// one being visible pub struct Panel { pub id: PanelId, - states: Vec<Box<dyn AppState>>, // stack: the last one is current + states: Vec<Box<dyn PanelState>>, // stack: the last one is current pub areas: Areas, status: Status, pub purpose: PanelPurpose, @@ -36,7 +36,7 @@ impl Panel { pub fn new( id: PanelId, - state: Box<dyn AppState>, + state: Box<dyn PanelState>, areas: Areas, con: &AppContext, ) -> Self { @@ -69,7 +69,7 @@ impl Panel { panel_skin: &PanelSkin, preview: Option<PanelId>, con: &AppContext, - ) -> Result<AppStateCmdResult, ProgramError> { + ) -> Result<CmdResult, ProgramError> { let state_idx = self.states.len() - 1; let cc = CmdContext { cmd, @@ -146,14 +146,14 @@ impl Panel { self.input.on_event(w, event, con, sel, self.state().get_mode()) } - pub fn push_state(&mut self, new_state: Box<dyn AppState>) { + pub fn push_state(&mut self, new_state: Box<dyn PanelState>) { self.input.set_content(&new_state.get_starting_input()); self.states.push(new_state); } - pub fn mut_state(&mut self) -> &mut dyn AppState { + pub fn mut_state(&mut self) -> &mut dyn PanelState { self.states.last_mut().unwrap().as_mut() } - pub fn state(&self) -> &dyn AppState { + pub fn state(&self) -> &dyn PanelState { self.states.last().unwrap().as_ref() } diff --git a/src/app/state.rs b/src/app/panel_state.rs index 5c771eb..4f09c08 100644 --- a/src/app/state.rs +++ b/src/app/panel_state.rs @@ -23,7 +23,7 @@ use { /// a panel state, stackable to allow reverting /// to a previous one -pub trait AppState { +pub trait PanelState { fn set_mode(&mut self, mode: Mode); fn get_mode(&self) -> Mode; @@ -37,8 +37,8 @@ pub trait AppState { _y: u16, _screen: Screen, _con: &AppContext, - ) -> Result<AppStateCmdResult, ProgramError> { - Ok(AppStateCmdResult::Keep) + ) -> Result<CmdResult, ProgramError> { + Ok(CmdResult::Keep) } fn on_double_click( @@ -47,28 +47,28 @@ pub trait AppState { _y: u16, _screen: Screen, _con: &AppContext, - ) -> Result<AppStateCmdResult, ProgramError> { - Ok(AppStateCmdResult::Keep) + ) -> Result<CmdResult, ProgramError> { + Ok(CmdResult::Keep) } fn on_pattern( &mut self, _pat: InputPattern, _con: &AppContext, - ) -> Result<AppStateCmdResult, ProgramError> { - Ok(AppStateCmdResult::Keep) + ) -> Result<CmdResult, ProgramError> { + Ok(CmdResult::Keep) } fn on_mode_verb( &mut self, mode: Mode, con: &AppContext, - ) -> AppStateCmdResult { + ) -> CmdResult { if con.modal { self.set_mode(mode); - AppStateCmdResult::Keep + CmdResult::Keep } else { - AppStateCmdResult::DisplayError( + CmdResult::DisplayError( "modal mode not enabled in configuration".to_string() ) } @@ -87,7 +87,7 @@ pub trait AppState { trigger_type: TriggerType, cc: &CmdContext, screen: Screen, - ) -> Result<AppStateCmdResult, ProgramError>; + ) -> Result<CmdResult, ProgramError>; /// a generic implementation of on_internal which may be /// called by states when they don't have a specific @@ -100,17 +100,17 @@ pub trait AppState { _trigger_type: TriggerType, cc: &CmdContext, screen: Screen, - ) -> Result<AppStateCmdResult, ProgramError> { + ) -> Result<CmdResult, ProgramError> { let con = &cc.con; let bang = input_invocation .map(|inv| inv.bang) .unwrap_or(internal_exec.bang); Ok(match internal_exec.internal { - Internal::back => AppStateCmdResult::PopState, + Internal::back => CmdResult::PopState, Internal::copy_line | Internal::copy_path => { #[cfg(not(feature = "clipboard"))] { - AppStateCmdResult::DisplayError( + CmdResult::DisplayError( "Clipboard feature not enabled at compilation".to_string(), ) } @@ -118,18 +118,18 @@ pub trait AppState { { let path = self.selected_path().to_string_lossy().to_string(); match terminal_clipboard::set_string(path) { - Ok(()) => AppStateCmdResult::Keep, - Err(_) => AppStateCmdResult::DisplayError( + Ok(()) => CmdResult::Keep, + Err(_) => CmdResult::DisplayError( "Clipboard error while copying path".to_string(), ), } } } - Internal::close_panel_ok => AppStateCmdResult::ClosePanel { + Internal::close_panel_ok => CmdResult::ClosePanel { validate_purpose: true, panel_ref: PanelReference::Active, }, - Internal::close_panel_cancel => AppStateCmdResult::ClosePanel { + Internal::close_panel_cancel => CmdResult::ClosePanel { validate_purpose: false, panel_ref: PanelReference::Active, }, @@ -146,16 +146,16 @@ pub trait AppState { .map(|inv| inv.bang) .unwrap_or(internal_exec.bang); if bang && cc.preview.is_none() { - AppStateCmdResult::NewPanel { + CmdResult::NewPanel { state: Box::new(state), purpose: PanelPurpose::None, direction: HDir::Right, } } else { - AppStateCmdResult::NewState(Box::new(state)) + CmdResult::NewState(Box::new(state)) } } - Err(e) => AppStateCmdResult::DisplayError(format!("{}", e)), + Err(e) => CmdResult::DisplayError(format!("{}", e)), } } Internal::help => { @@ -163,13 +163,13 @@ pub trait AppState { .map(|inv| inv.bang) .unwrap_or(internal_exec.bang); if bang && cc.preview.is_none() { - AppStateCmdResult::NewPanel { + CmdResult::NewPanel { state: Box::new(HelpState::new(self.tree_options(), screen, con)), purpose: PanelPurpose::None, direction: HDir::Right, } } else { - AppStateCmdResult::NewState(Box::new( + CmdResult::NewState(Box::new( HelpState::new(self.tree_options(), screen, con) )) } @@ -281,19 +281,19 @@ pub trait AppState { } Internal::close_preview => { if let Some(id) = cc.preview { - AppStateCmdResult::ClosePanel { + CmdResult::ClosePanel { validate_purpose: false, panel_ref: PanelReference::Id(id), } } else { - AppStateCmdResult::Keep + CmdResult::Keep } } Internal::panel_left => { - AppStateCmdResult::HandleInApp(Internal::panel_left) + CmdResult::HandleInApp(Internal::panel_left) } Internal::panel_right => { - AppStateCmdResult::HandleInApp(Internal::panel_right) + CmdResult::HandleInApp(Internal::panel_right) } Internal::print_path => { print::print_path(self.selected_path(), con)? @@ -301,9 +301,9 @@ pub trait AppState { Internal::print_relative_path => { print::print_relative_path(self.selected_path(), con)? } - Internal::refresh => AppStateCmdResult::RefreshState { clear_cache: true }, - Internal::quit => AppStateCmdResult::Quit, - _ => AppStateCmdResult::Keep, + Internal::refresh => CmdResult::RefreshState { clear_cache: true }, + Internal::quit => CmdResult::Quit, + _ => CmdResult::Keep, }) } @@ -315,9 +315,9 @@ pub trait AppState { trigger_type: TriggerType, cc: &CmdContext, screen: Screen, - ) -> Result<AppStateCmdResult, ProgramError> { + ) -> Result<CmdResult, ProgramError> { if verb.need_another_panel && cc.other_path.is_none() { - return Ok(AppStateCmdResult::DisplayError( + return Ok(CmdResult::DisplayError( "This verb needs another panel".to_string() )); } @@ -343,7 +343,7 @@ pub trait AppState { raw: exec_builder().shell_exec_string(&ExecPattern::from_string(&seq_ex.sequence.raw)), separator: seq_ex.sequence.separator.clone(), }; - Ok(AppStateCmdResult::ExecuteSequence { sequence }) + Ok(CmdResult::ExecuteSequence { sequence }) } } } @@ -354,7 +354,7 @@ pub trait AppState { w: &mut W, cc: &CmdContext, screen: Screen, - ) -> Result<AppStateCmdResult, ProgramError> { + ) -> Result<CmdResult, ProgramError> { self.clear_pending(); let con = &cc.con; match cc.cmd { @@ -363,7 +363,7 @@ pub trait AppState { Command::PatternEdit { raw, expr } => { match InputPattern::new(raw.clone(), expr, &cc.con) { Ok(pattern) => self.on_pattern(pattern, con), - Err(e) => Ok(AppStateCmdResult::DisplayError(format!("{}", e))), + Err(e) => Ok(CmdResult::DisplayError(format!("{}", e))), } } Command::VerbTrigger { @@ -394,7 +394,7 @@ pub trait AppState { ) { PrefixSearchResult::Match(_, verb) => { if let Some(err) = verb.check_args(invocation, &cc.other_path) { - Ok(AppStateCmdResult::DisplayError(err)) + Ok(CmdResult::DisplayError(err)) } else { self.execute_verb( w, @@ -406,11 +406,11 @@ pub trait AppState { ) } } - _ => Ok(AppStateCmdResult::verb_not_found(&invocation.name)), + _ => Ok(CmdResult::verb_not_found(&invocation.name)), }, Command::None | Command::VerbEdit(_) => { // we do nothing here, the real job is done in get_status - Ok(AppStateCmdResult::Keep) + Ok(CmdResult::Keep) } } } @@ -421,10 +421,10 @@ pub trait AppState { prefered_mode: Option<PreviewMode>, close_if_open: bool, cc: &CmdContext, - ) -> AppStateCmdResult { + ) -> CmdResult { if let Some(id) = cc.preview { if close_if_open { - AppStateCmdResult::ClosePanel { + CmdResult::ClosePanel { validate_purpose: false, panel_ref: PanelReference::Id(id), } @@ -432,15 +432,15 @@ pub trait AppState { if prefered_mode.is_some() { // we'll make the preview mode change be // applied on the preview panel - AppStateCmdResult::ApplyOnPanel { id } + CmdResult::ApplyOnPanel { id } } else { - AppStateCmdResult::Keep + CmdResult::Keep } } } else { let path = self.selected_path(); if path.is_file() { - AppStateCmdResult::NewPanel { + CmdResult::NewPanel { state: Box::new(PreviewState::new( path.to_path_buf(), InputPattern::none(), @@ -452,7 +452,7 @@ pub trait AppState { direction: HDir::Right, } } else { - AppStateCmdResult::DisplayError( + CmdResult::DisplayError( "only regular files can be previewed".to_string() ) } @@ -475,7 +475,7 @@ pub trait AppState { change_options: &dyn Fn(&mut TreeOptions), in_new_panel: bool, con: &AppContext, - ) -> AppStateCmdResult; + ) -> CmdResult; fn do_pending_task( &mut self, diff --git a/src/app/selection.rs b/src/app/selection.rs index 84c806d..c84003e 100644 --- a/src/app/selection.rs +++ b/src/app/selection.rs @@ -2,7 +2,7 @@ use { super::{ AppContext, - AppStateCmdResult, + CmdResult, }, crate::{ errors::ProgramError, @@ -44,29 +44,29 @@ pub struct Selection<'s> { impl Selection<'_> { - /// build a AppStateCmdResult with a launchable which will be used to + /// build a CmdResult with a launchable which will be used to /// 1/ quit broot /// 2/ open the relevant file the best possible way pub fn to_opener( self, con: &AppContext, - ) -> Result<AppStateCmdResult, ProgramError> { + ) -> Result<CmdResult, ProgramError> { Ok(if self.is_exe { let path = self.path.to_string_lossy().to_string(); if let Some(export_path) = &con.launch_args.cmd_export_path { // broot was launched as br, we can launch the executable from the shell let f = OpenOptions::new().append(true).open(export_path)?; writeln!(&f, "{}", path)?; - AppStateCmdResult::Quit + CmdResult::Quit } else { - AppStateCmdResult::from(Launchable::program( + CmdResult::from(Launchable::program( vec![path], None, // we don't set the working directory con, )?) } } else { - AppStateCmdResult::from(Launchable::opener(self.path.to_path_buf())) + CmdResult::from(Launchable::opener(self.path.to_path_buf())) }) } diff --git a/src/app/standard_status.rs b/src/app/standard_status.rs index 46c9918..d21a868 100644 --- a/src/app/standard_status.rs +++ b/src/app/standard_status.rs @@ -70,7 +70,7 @@ impl StandardStatus { } pub fn builder<'s>( &'s self, - state_type: AppStateType, + state_type: PanelStateType, selection: Selection<'s>, ) -> StandardStatusBuilder<'s> { StandardStatusBuilder::new(&self, state_type, selection) @@ -111,7 +111,7 @@ impl<'b> StatusParts<'b> { pub struct StandardStatusBuilder<'s> { ss: &'s StandardStatus, - state_type: AppStateType, + state_type: PanelStateType, selection: Selection<'s>, pub has_previous_state: bool, pub is_filtered: bool, @@ -121,7 +121,7 @@ pub struct StandardStatusBuilder<'s> { impl<'s> StandardStatusBuilder<'s> { fn new( ss: &'s StandardStatus, - state_type: AppStateType, + state_type: PanelStateType, selection: Selection<'s>, ) -> Self { Self { @@ -141,7 +141,7 @@ impl<'s> StandardStatusBuilder<'s> { parts.add(&ss.not_first_state); } match self.state_type { - AppStateType::Tree => { + PanelStateType::Tree => { if self.on_tree_root { if self.selection.path.file_name().is_some() { // it's not '/' parts.add(&ss.tree_top_focus); @@ -169,7 +169,7 @@ impl<'s> StandardStatusBuilder<'s> { } } } - AppStateType::Preview => { + PanelStateType::Preview => { if self.is_filtered { parts.addo(&ss.preview_filtered); } else if self.has_removed_pattern { @@ -179,7 +179,7 @@ impl<'s> StandardStatusBuilder<'s> { } parts.add(&ss.no_verb); } - AppStateType::Help => { + PanelStateType::Help => { // not yet used, help_state has its own hard status if parts.len() < 4 { parts.add(&ss.no_verb); diff --git a/src/app/state_type.rs b/src/app/state_type.rs index 5e4751b..fab67ce 100644 --- a/src/app/state_type.rs +++ b/src/app/state_type.rs @@ -2,7 +2,7 @@ /// one of the three types of state that you could /// find in a panel today #[derive(Debug, Clone, Copy)] -pub enum AppStateType { +pub enum PanelStateType { /// The standard browsing tree Tree, diff --git a/src/browser/browser_state.rs b/src/browser/browser_state.rs index 9dae74c..8dd5311 100644 --- a/src/browser/browser_state.rs +++ b/src/browser/browser_state.rs @@ -85,7 +85,7 @@ impl BrowserState { con: &AppContext, in_new_panel: bool, keep_pattern: bool, - ) -> Result<AppStateCmdResult, ProgramError> { + ) -> Result<CmdResult, ProgramError> { let tree = self.displayed_tree(); let line = tree.selected_line(); let mut target = line.target().to_path_buf(); @@ -98,7 +98,7 @@ impl BrowserState { } } let dam = Dam::unlimited(); - Ok(AppStateCmdResult::from_optional_state( + Ok(CmdResult::from_optional_state( BrowserState::new( target, if keep_pattern { @@ -116,9 +116,9 @@ impl BrowserState { match open::that(&target) { Ok(exit_status) => { info!("open returned with exit_status {:?}", exit_status); - Ok(AppStateCmdResult::Keep) + Ok(CmdResult::Keep) } - Err(e) => Ok(AppStateCmdResult::DisplayError(format!("{:?}", e))), + Err(e) => Ok(CmdResult::DisplayError(format!("{:?}", e))), } } } @@ -128,9 +128,9 @@ impl BrowserState { screen: Screen, con: &AppContext, in_new_panel: bool, - ) -> AppStateCmdResult { + ) -> CmdResult { match &self.displayed_tree().selected_line().path.parent() { - Some(path) => AppStateCmdResult::from_optional_state( + Some(path) => CmdResult::from_optional_state( BrowserState::new( path.to_path_buf(), self.displayed_tree().options.without_pattern(), @@ -140,13 +140,13 @@ impl BrowserState { ), in_new_panel, ), - None => AppStateCmdResult::DisplayError("no parent found".to_string()), + None => CmdResult::DisplayError("no parent found".to_string()), } } } -impl AppState for BrowserState { +impl PanelState for BrowserState { fn set_mode(&mut self, mode: Mode) { debug!("BrowserState::set_mode({:?})", mode); @@ -190,11 +190,11 @@ impl AppState for BrowserState { change_options: &dyn Fn(&mut TreeOptions), in_new_panel: bool, con: &AppContext, - ) -> AppStateCmdResult { + ) -> CmdResult { let tree = self.displayed_tree(); let mut options = tree.options.clone(); change_options(&mut options); - AppStateCmdResult::from_optional_state( + CmdResult::from_optional_state( BrowserState::new(tree.root().clone(), options, screen, con, &Dam::unlimited()), in_new_panel, ) @@ -210,9 +210,9 @@ impl AppState for BrowserState { y: u16, _screen: Screen, _con: &AppContext, - ) -> Result<AppStateCmdResult, ProgramError> { + ) -> Result<CmdResult, ProgramError> { self.displayed_tree_mut().try_select_y(y as i32); - Ok(AppStateCmdResult::Keep) + Ok(CmdResult::Keep) } fn on_double_click( @@ -221,14 +221,14 @@ impl AppState for BrowserState { y: u16, screen: Screen, con: &AppContext, - ) -> Result<AppStateCmdResult, ProgramError> { + ) -> Result<CmdResult, ProgramError> { if self.displayed_tree().selection == y as usize { self.open_selection_stay_in_broot(screen, con, false, false) } else { // A double click always come after a simple click at // same position. If it's not the selected line, it means // the click wasn't on a selectable/openable tree line - Ok(AppStateCmdResult::Keep) + Ok(CmdResult::Keep) } } @@ -236,12 +236,12 @@ impl AppState for BrowserState { &mut self, pat: InputPattern, _con: &AppContext, - ) -> Result<AppStateCmdResult, ProgramError> { + ) -> Result<CmdResult, ProgramError> { if pat.is_none() { self.filtered_tree = None; } self.pending_pattern = pat; - Ok(AppStateCmdResult::Keep) + Ok(CmdResult::Keep) } fn on_internal( @@ -252,7 +252,7 @@ impl AppState for BrowserState { trigger_type: TriggerType, cc: &CmdContext, screen: Screen, - ) -> Result<AppStateCmdResult, ProgramError> { + ) -> Result<CmdResult, ProgramError> { let con = &cc.con; let page_height = BrowserState::page_height(screen); let bang = input_invocation @@ -266,12 +266,12 @@ impl AppState for BrowserState { self.tree.make_selection_visible(page_height); } self.filtered_tree = None; - AppStateCmdResult::Keep + CmdResult::Keep } else if self.tree.selection > 0 { self.tree.selection = 0; - AppStateCmdResult::Keep + CmdResult::Keep } else { - AppStateCmdResult::PopState + CmdResult::PopState } } Internal::focus => internal_focus::on_internal( @@ -291,59 +291,59 @@ impl AppState for BrowserState { bang, con, ), - None => AppStateCmdResult::DisplayError("no parent found".to_string()), + None => CmdResult::DisplayError("no parent found".to_string()), }, Internal::open_stay => self.open_selection_stay_in_broot(screen, con, bang, false)?, Internal::open_stay_filter => self.open_selection_stay_in_broot(screen, con, bang, true)?, Internal::line_down => { let count = get_arg(input_invocation, internal_exec, 1); self.displayed_tree_mut().move_selection(count, page_height, true); - AppStateCmdResult::Keep + CmdResult::Keep } Internal::line_up => { let count = get_arg(input_invocation, internal_exec, 1); self.displayed_tree_mut().move_selection(-count, page_height, true); - AppStateCmdResult::Keep + CmdResult::Keep } Internal::line_down_no_cycle => { let count = get_arg(input_invocation, internal_exec, 1); self.displayed_tree_mut().move_selection(count, page_height, false); - AppStateCmdResult::Keep + CmdResult::Keep } Internal::line_up_no_cycle => { let count = get_arg(input_invocation, internal_exec, 1); self.displayed_tree_mut().move_selection(-count, page_height, false); - AppStateCmdResult::Keep + CmdResult::Keep } Internal::previous_match => { self.displayed_tree_mut().try_select_previous_match(); - AppStateCmdResult::Keep + CmdResult::Keep } Internal::next_match => { self.displayed_tree_mut().try_select_next_match(); - AppStateCmdResult::Keep + CmdResult::Keep } Internal::previous_same_depth => { self.displayed_tree_mut().try_select_previous_same_depth(); - AppStateCmdResult::Keep + CmdResult::Keep } Internal::next_same_depth => { self.displayed_tree_mut().try_select_next_same_depth(); - AppStateCmdResult::Keep + CmdResult::Keep } Internal::page_down => { let tree = self.displayed_tree_mut(); if page_height < tree.lines.len() as i32 { tree.try_scroll(page_height, page_height); } - AppStateCmdResult::Keep + CmdResult::Keep } Internal::page_up => { let tree = self.displayed_tree_mut(); if page_height < tree |