summaryrefslogtreecommitdiffstats
path: root/src/app/cmd_result.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/app/cmd_result.rs')
-rw-r--r--src/app/cmd_result.rs16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/app/cmd_result.rs b/src/app/cmd_result.rs
index 465feff..ff7b462 100644
--- a/src/app/cmd_result.rs
+++ b/src/app/cmd_result.rs
@@ -48,7 +48,10 @@ pub enum CmdResult {
purpose: PanelPurpose,
direction: HDir,
},
- NewState(Box<dyn PanelState>),
+ NewState {
+ state: Box<dyn PanelState>,
+ message: Option<&'static str>, // explaining why there's a new state
+ },
PopStateAndReapply, // the state asks the command be executed on a previous state
PopState,
Quit,
@@ -63,24 +66,31 @@ impl CmdResult {
}
pub fn from_optional_state(
os: Result<BrowserState, TreeBuildError>,
+ message: Option<&'static str>,
in_new_panel: bool,
) -> CmdResult {
match os {
Ok(os) => {
if in_new_panel {
- CmdResult::NewPanel {
+ CmdResult::NewPanel { // TODO keep the message ?
state: Box::new(os),
purpose: PanelPurpose::None,
direction: HDir::Right,
}
} else {
- CmdResult::NewState(Box::new(os))
+ CmdResult::NewState {
+ state: Box::new(os),
+ message,
+ }
}
}
Err(TreeBuildError::Interrupted) => CmdResult::Keep,
Err(e) => CmdResult::error(e.to_string()),
}
}
+ pub fn new_state(state: Box<dyn PanelState>) -> Self {
+ Self::NewState { state, message: None }
+ }
pub fn error<S: Into<String>>(message: S) -> Self {
Self::DisplayError(message.into())
}