diff options
author | Canop <cano.petrole@gmail.com> | 2020-07-13 23:04:13 +0200 |
---|---|---|
committer | Canop <cano.petrole@gmail.com> | 2020-07-13 23:04:13 +0200 |
commit | 79af2798986f78afe37e13ccd3486c7b1f511880 (patch) | |
tree | 1af8ae047e14b9d73f111b40fa1b828708b8f5e3 /src/browser/browser_state.rs | |
parent | 4d61940e26ad624806adf0ca24dc96c832100ea1 (diff) |
much progress on the preview panel
Diffstat (limited to 'src/browser/browser_state.rs')
-rw-r--r-- | src/browser/browser_state.rs | 35 |
1 files changed, 25 insertions, 10 deletions
diff --git a/src/browser/browser_state.rs b/src/browser/browser_state.rs index c3f2efd..579eadf 100644 --- a/src/browser/browser_state.rs +++ b/src/browser/browser_state.rs @@ -389,9 +389,11 @@ impl AppState for BrowserState { } Internal::close_panel_ok => AppStateCmdResult::ClosePanel { validate_purpose: true, + id: None, // close current panel }, Internal::close_panel_cancel => AppStateCmdResult::ClosePanel { validate_purpose: false, + id: None, // close current panel }, Internal::focus => internal_focus::on_internal( internal_exec, @@ -458,15 +460,22 @@ impl AppState for BrowserState { } Internal::panel_left => { if cc.areas.is_first() { - // we ask for the creation of a panel to the left - internal_focus::new_panel_on_path( - self.selected_path().to_path_buf(), - screen, - self.tree.options.clone(), - PanelPurpose::None, - con, - HDir::Left, - ) + if cc.preview.is_some() && cc.areas.nb_pos == 2 { + AppStateCmdResult::ClosePanel { + validate_purpose: false, + id: cc.preview, + } + } else { + // we ask for the creation of a panel to the left + internal_focus::new_panel_on_path( + self.selected_path().to_path_buf(), + screen, + self.tree.options.clone(), + PanelPurpose::None, + con, + HDir::Left, + ) + } } else { // we ask the app to focus the panel to the left AppStateCmdResult::Propagate(Internal::panel_left) @@ -474,12 +483,17 @@ impl AppState for BrowserState { } Internal::panel_right => { if cc.areas.is_last() { + let purpose = if self.selected_path().is_file() && cc.preview.is_none() { + PanelPurpose::Preview + } else { + PanelPurpose::None + }; // we ask for the creation of a panel to the right internal_focus::new_panel_on_path( self.selected_path().to_path_buf(), screen, self.tree.options.clone(), - PanelPurpose::None, + purpose, con, HDir::Right, ) @@ -514,6 +528,7 @@ impl AppState for BrowserState { debug!("start_end understood as end"); AppStateCmdResult::ClosePanel { validate_purpose: true, + id: None, } } else { debug!("start_end understood as start"); |