summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCanop <cano.petrole@gmail.com>2021-04-16 18:54:59 +0200
committerCanop <cano.petrole@gmail.com>2021-04-16 18:54:59 +0200
commitf925993a6bbacbf92befdf1d825de982ba094fdf (patch)
treec8464234311c683f51ec4ae0ef7ebb7d47a8eef0
parent831c10d6c5ccf74d0109b6bc3ffd708a9da61cab (diff)
move stage related internal handling to panel_state
-rw-r--r--src/app/app.rs220
-rw-r--r--src/app/cmd_context.rs20
-rw-r--r--src/app/cmd_result.rs1
-rw-r--r--src/app/panel.rs8
-rw-r--r--src/app/panel_state.rs123
-rw-r--r--src/app/standard_status.rs3
-rw-r--r--src/app/state_type.rs5
-rw-r--r--src/browser/browser_state.rs8
-rw-r--r--src/filesystems/filesystems_state.rs9
-rw-r--r--src/help/help_state.rs6
-rw-r--r--src/preview/preview_state.rs6
-rw-r--r--src/stage/stage.rs5
-rw-r--r--src/stage/stage_state.rs32
-rw-r--r--src/verb/internal.rs1
14 files changed, 250 insertions, 197 deletions
diff --git a/src/app/app.rs b/src/app/app.rs
index 3095404..951a02c 100644
--- a/src/app/app.rs
+++ b/src/app/app.rs
@@ -180,49 +180,6 @@ impl App {
}
}
- /// a polite request to show the stage, if it bothers nobody
- fn maybe_show_stage(&mut self, state: &AppState, con: &AppContext) -> bool {
- if state.stage.is_empty() {
- return false; // nothing to show
- }
- if self.stage_panel.is_some() {
- return false; // already here
- }
- let len = self.panels.len().get();
- if len >= con.max_panels_count {
- if let Some(panel_id) = self.preview_panel {
- // we replace the preview with the staging area
- let preview_panel_idx = self
- .panels
- .iter()
- .position(|p| p.id == panel_id)
- .unwrap_or(len - 1);
- self.close_panel(preview_panel_idx);
- } else {
- return false;
- }
- }
- let insertion_idx = len;
- if let Ok(areas) = Areas::create(
- self.panels.as_mut_slice(),
- insertion_idx,
- self.screen,
- false, // TODO new argument to set it smaller
- ) {
- let panel_id = self.created_panels_count.into();
- let state = StageState::new(
- self.state().tree_options(),
- con,
- );
- let mut panel = Panel::new(panel_id, Box::new(state), areas, con);
- self.created_panels_count += 1;
- self.panels.insert(insertion_idx, panel);
- self.stage_panel = Some(panel_id);
- info!("stage state added");
- }
- false
- }
-
/// remove the top state of the current panel
///
/// Close the panel too if that was its only state.
@@ -316,17 +273,19 @@ impl App {
let mut error: Option<String> = None;
let is_input_invocation = cmd.is_verb_invocated_from_input();
let app_cmd_context = AppCmdContext {
- app_state,
other_path: self.get_other_panel_path(),
panel_skin,
- preview: self.preview_panel,
+ preview_panel: self.preview_panel,
+ stage_panel: self.stage_panel,
screen: self.screen, // it can't change in this function
con,
};
- match self.mut_panel().apply_command(w, &cmd, &app_cmd_context)? {
+ match self.mut_panel().apply_command(w, &cmd, app_state, &app_cmd_context)? {
ApplyOnPanel { id } => {
if let Some(idx) = self.panel_id_to_idx(id) {
- if let DisplayError(txt) = self.panels[idx].apply_command(w, &cmd, &app_cmd_context)? {
+ if let DisplayError(txt) = self.panels[idx].apply_command(
+ w, &cmd, app_state, &app_cmd_context
+ )? {
// we should probably handle other results
// which implies the possibility of a recursion
error = Some(txt);
@@ -368,14 +327,14 @@ impl App {
let new_input = self.panel().get_input_content();
let cmd = Command::from_raw(new_input, false);
let app_cmd_context = AppCmdContext {
- app_state,
other_path: self.get_other_panel_path(),
panel_skin,
- preview: self.preview_panel,
+ preview_panel: self.preview_panel,
+ stage_panel: self.stage_panel,
screen,
con,
};
- self.mut_panel().apply_command(w, &cmd, &app_cmd_context)?;
+ self.mut_panel().apply_command(w, &cmd, app_state, &app_cmd_context)?;
}
} else {
self.quitting = true;
@@ -410,46 +369,6 @@ impl App {
Some(self.active_panel_idx + 1)
}
}
- Internal::clear_stage => {
- app_state.stage.paths.clear();
- let panel_idx = self.stage_panel
- .and_then(|id| self.panel_id_to_idx(id));
- if let Some(idx) = panel_idx {
- self.close_panel(idx);
- }
- // TODO refresh
- None
- }
- Internal::stage => {
- info!("received command to stage {:?}", self.state().selected_path());
- if let Some(path) = self.state().selected_path() {
- let path = path.to_path_buf();
- app_state.stage.add(path);
- self.maybe_show_stage(app_state, con);
- } else {
- // TODO display error ?
- warn!("no path in state");
- }
- None
- }
- Internal::unstage => {
- info!("received command to unstage {:?}", self.state().selected_path());
- if let Some(path) = self.state().selected_path() {
- if app_state.stage.remove(path) {
- if app_state.stage.is_empty() {
- let panel_idx = self.stage_panel
- .and_then(|id| self.panel_id_to_idx(id));
- if let Some(idx) = panel_idx {
- self.close_panel(idx);
- }
- }
- }
- } else {
- // TODO display error ?
- warn!("no path in state");
- }
- None
- }
_ => {
debug!("unhandled propagated internal. cmd={:?}", &cmd);
None
@@ -460,16 +379,15 @@ impl App {
self.mut_panel().clear_input();
}
self.active_panel_idx = idx;
- let other_path = self.get_other_panel_path();
let app_cmd_context = AppCmdContext {
- app_state,
other_path: self.get_other_panel_path(),
panel_skin,
- preview: self.preview_panel,
+ preview_panel: self.preview_panel,
+ stage_panel: self.stage_panel,
screen: self.screen,
con,
};
- self.mut_panel().refresh_input_status(&app_cmd_context);
+ self.mut_panel().refresh_input_status(app_state, &app_cmd_context);
}
}
Keep => {
@@ -486,46 +404,14 @@ impl App {
purpose,
direction,
} => {
- if is_input_invocation {
- self.mut_panel().clear_input_invocation();
- }
- let insertion_idx = if purpose.is_preview() {
- self.panels.len().get()
- } else if direction == HDir::Right {
- self.active_panel_idx + 1
- } else {
- self.active_panel_idx
- };
- let with_preview = purpose.is_preview() || self.preview_panel.is_some();
- match Areas::create(
- self.panels.as_mut_slice(),
- insertion_idx,
- self.screen,
- with_preview,
- ) {
- Ok(areas) => {
- let panel_id = self.created_panels_count.into();
- let mut panel = Panel::new(panel_id, state, areas, con);
- panel.purpose = purpose;
- self.created_panels_count += 1;
- self.panels.insert(insertion_idx, panel);
- if purpose.is_preview() {
- debug_assert!(self.preview_panel.is_none());
- self.preview_panel = Some(panel_id);
- } else {
- self.active_panel_idx = insertion_idx;
- }
- }
- Err(e) => {
- error = Some(e.to_string());
- }
+ if let Err(s) = self.new_panel(state, purpose, direction, is_input_invocation, con) {
+ error = Some(s);
}
}
NewState(state) => {
self.mut_panel().clear_input();
self.mut_panel().push_state(state);
- let other_path = self.get_other_panel_path();
- self.mut_panel().refresh_input_status(&app_cmd_context);
+ self.mut_panel().refresh_input_status(app_state, &app_cmd_context);
}
PopState => {
if is_input_invocation {
@@ -533,8 +419,7 @@ impl App {
}
if self.remove_state() {
self.mut_state().refresh(app_cmd_context.screen, con);
- let other_path = self.get_other_panel_path();
- self.mut_panel().refresh_input_status(&app_cmd_context);
+ self.mut_panel().refresh_input_status(app_state, &app_cmd_context);
} else if ESCAPE_TO_QUIT {
self.quitting = true;
}
@@ -545,14 +430,14 @@ impl App {
}
if self.remove_state() {
let app_cmd_context = AppCmdContext {
- app_state,
other_path: self.get_other_panel_path(),
panel_skin,
- preview: self.preview_panel,
+ preview_panel: self.preview_panel,
+ stage_panel: self.stage_panel,
screen: self.screen,
con,
};
- self.mut_panel().apply_command(w, &cmd, &app_cmd_context)?;
+ self.mut_panel().apply_command(w, &cmd, app_state, &app_cmd_context)?;
} else if ESCAPE_TO_QUIT {
self.quitting = true;
}
@@ -567,6 +452,7 @@ impl App {
if clear_cache {
clear_caches();
}
+ app_state.stage.refresh();
for i in 0..self.panels.len().get() {
self.panels[i].mut_state().refresh(self.screen, con);
}
@@ -605,6 +491,66 @@ impl App {
(len * x as usize) / (self.screen.width as usize + 1)
}
+ /// handle CmdResult::NewPanel
+ fn new_panel(
+ &mut self,
+ state: Box<dyn PanelState>,
+ purpose: PanelPurpose,
+ direction: HDir,
+ is_input_invocation: bool,
+ con: &AppContext,
+ ) -> Result<(), String> {
+ match state.get_type() {
+ PanelStateType::Preview if self.preview_panel.is_some() => {
+ return Err("There can be only one preview panel".to_owned());
+ // todo replace instead ?
+ }
+ PanelStateType::Stage if self.stage_panel.is_some() => {
+ return Err("There can be only one stage panel".to_owned());
+ // todo replace instead ?
+ }
+ _ => {}
+ }
+ if is_input_invocation {
+ self.mut_panel().clear_input_invocation();
+ }
+ let insertion_idx = if purpose.is_preview() {
+ self.panels.len().get()
+ } else if direction == HDir::Right {
+ self.active_panel_idx + 1
+ } else {
+ self.active_panel_idx
+ };
+ let with_preview = purpose.is_preview() || self.preview_panel.is_some();
+ match Areas::create(
+ self.panels.as_mut_slice(),
+ insertion_idx,
+ self.screen,
+ with_preview,
+ ) {
+ Ok(areas) => {
+ let panel_id = self.created_panels_count.into();
+ match state.get_type() {
+ PanelStateType::Preview => {
+ self.preview_panel = Some(panel_id);
+ }
+ PanelStateType::Stage => {
+ self.stage_panel = Some(panel_id);
+ }
+ _ => {
+ self.active_panel_idx = insertion_idx;
+ }
+ }
+ let mut panel = Panel::new(panel_id, state, areas, con);
+ panel.purpose = purpose;
+ self.created_panels_count += 1;
+ self.panels.insert(insertion_idx, panel);
+ Ok(())
+ }
+ Err(e) => Err(e.to_string())
+ }
+ }
+
/// do the pending tasks, if any, and refresh the screen accordingly
fn do_pending_tasks(
&mut self,
@@ -618,14 +564,14 @@ impl App {
if self.do_pending_task(con, dam) {
self.update_preview(con); // the selection may have changed
let app_cmd_context = AppCmdContext {
- app_state,
other_path: self.get_other_panel_path(),
panel_skin: &skin.focused,
- preview: self.preview_panel,
+ preview_panel: self.preview_panel,
+ stage_panel: self.stage_panel,
screen: self.screen,
con,
};
- self.mut_panel().refresh_input_status(&app_cmd_context);
+ self.mut_panel().refresh_input_status(app_state, &app_cmd_context);
self.display_panels(w, &skin, app_state, con)?;
} else {
warn!("unexpected lack of update on do_pending_task");
diff --git a/src/app/cmd_context.rs b/src/app/cmd_context.rs
index b3f546b..80a7738 100644
--- a/src/app/cmd_context.rs
+++ b/src/app/cmd_context.rs
@@ -18,10 +18,10 @@ pub struct CmdContext<'c> {
/// the part of the immutable command execution context which comes from the app
pub struct AppCmdContext<'c> {
- pub app_state: &'c AppState,
pub other_path: Option<PathBuf>,
pub panel_skin: &'c PanelSkin,
- pub preview: Option<PanelId>, // id of the app's preview panel
+ pub preview_panel: Option<PanelId>, // id of the app's preview panel
+ pub stage_panel: Option<PanelId>, // id of the app's preview panel
pub screen: Screen,
pub con: &'c AppContext,
}
@@ -32,11 +32,11 @@ pub struct PanelCmdContext<'c> {
pub purpose: PanelPurpose,
}
-impl<'c> CmdContext<'c> {
- pub fn has_preview(&self) -> bool {
- self.app.preview.is_some()
- }
- pub fn has_no_preview(&self) -> bool {
- self.app.preview.is_none()
- }
-}
+//impl<'c> CmdContext<'c> {
+// pub fn has_preview(&self) -> bool {
+// self.app.preview_panel.is_some()
+// }
+// pub fn has_no_preview(&self) -> bool {
+// self.app.preview.is_none()
+// }
+//}
diff --git a/src/app/cmd_result.rs b/src/app/cmd_result.rs
index fbe154f..a277eba 100644
--- a/src/app/cmd_result.rs
+++ b/src/app/cmd_result.rs
@@ -25,6 +25,7 @@ pub enum PanelReference {
Rightest,
Id(PanelId),
Preview,
+ //StagingArea,
}
/// Result of applying a command to a state
diff --git a/src/app/panel.rs b/src/app/panel.rs
index 5d33be7..6d11fd1 100644
--- a/src/app/panel.rs
+++ b/src/app/panel.rs
@@ -63,6 +63,7 @@ impl Panel {
&mut self,
w: &'c mut W,
cmd: &'c Command,
+ app_state: &mut AppState,
app_cmd_context: &'c AppCmdContext<'c>,
) -> Result<CmdResult, ProgramError> {
let state_idx = self.states.len() - 1;
@@ -74,9 +75,9 @@ impl Panel {
purpose: self.purpose,
},
};
- let result = self.states[state_idx].on_command(w, &cc);
+ let result = self.states[state_idx].on_command(w, app_state, &cc);
let has_previous_state = self.states.len() > 1;
- self.status = self.state().get_status(&cc, has_previous_state);
+ self.status = self.state().get_status(app_state, &cc, has_previous_state);
debug!("result in panel {:?}: {:?}", &self.id, &result);
result
}
@@ -85,6 +86,7 @@ impl Panel {
/// this updates the status from the command read in the input
pub fn refresh_input_status<'c>(
&mut self,
+ app_state: &AppState,
app_cmd_context: &'c AppCmdContext<'c>,
) {
let cmd = Command::from_raw(self.input.get_content(), false);
@@ -97,7 +99,7 @@ impl Panel {
},
};
let has_previous_state = self.states.len() > 1;
- self.status = self.state().get_status(&&cc, has_previous_state);
+ self.status = self.state().get_status(app_state, &cc, has_previous_state);
}
/// execute all the pending tasks until there's none remaining or
diff --git a/src/app/panel_state.rs b/src/app/panel_state.rs
index 0aaba3b..808ef19 100644
--- a/src/app/panel_state.rs
+++ b/src/app/panel_state.rs
@@ -9,6 +9,7 @@ use {
pattern::*,
preview::{PreviewMode, PreviewState},
print,
+ stage::StageState,
task_sync::Dam,
tree::*,
verb::*,
@@ -23,6 +24,8 @@ use {
/// to a previous one
pub trait PanelState {
+ fn get_type(&self) -> PanelStateType;
+
fn set_mode(&mut self, mode: Mode);
fn get_mode(&self) -> Mode;
@@ -83,6 +86,7 @@ pub trait PanelState {
internal_exec: &InternalExecution,
input_invocation: Option<&VerbInvocation>,
trigger_type: TriggerType,
+ app_state: &mut AppState,
cc: &CmdContext,
) -> Result<CmdResult, ProgramError>;
@@ -95,6 +99,7 @@ pub trait PanelState {
internal_exec: &InternalExecution,
input_invocation: Option<&VerbInvocation>,
_trigger_type: TriggerType,
+ app_state: &mut AppState,
cc: &CmdContext,
) -> Result<CmdResult, ProgramError> {
let con = &cc.app.con;
@@ -148,7 +153,7 @@ pub trait PanelState {
let bang = input_invocation
.map(|inv| inv.bang)
.unwrap_or(internal_exec.bang);
- if bang && cc.has_no_preview() {
+ if bang && cc.app.preview_panel.is_none() {
CmdResult::NewPanel {
state: Box::new(state),
purpose: PanelPurpose::None,
@@ -165,7 +170,7 @@ pub trait PanelState {
let bang = input_invocation
.map(|inv| inv.bang)
.unwrap_or(internal_exec.bang);
- if bang && cc.has_no_preview() {
+ if bang && cc.app.preview_panel.is_none() {
CmdResult::NewPanel {
state: Box::new(HelpState::new(self.tree_options(), screen, con)),
purpose: PanelPurpose::None,
@@ -289,7 +294,7 @@ pub trait PanelState {
self.with_new_options(screen, &|o| o.trim_root ^= true, bang, con)
}
Internal::close_preview => {
- if let Some(id) = cc.app.preview {
+ if let Some(id) = cc.app.preview_panel {
CmdResult::ClosePanel {
validate_purpose: false,
panel_ref: PanelReference::Id(id),
@@ -305,25 +310,19 @@ pub trait PanelState {
CmdResult::HandleInApp(Internal::panel_right)
}
Internal::clear_stage => {
- CmdResult::HandleInApp(Internal::clear_stage)
- }
- Internal::stage => {
- CmdResult::HandleInApp(Internal::stage)
- }
- Internal::unstage => {
- CmdResult::HandleInApp(Internal::unstage)
- }
- Internal::toggle_stage => {
- if let Some(path) = self.selected_path() {
- if cc.app.app_state.stage.paths.iter().any(|p| p==path) {
- CmdResult::HandleInApp(Internal::unstage)
- } else {
- CmdResult::HandleInApp(Internal::stage)
+ app_state.stage.paths.clear();
+ if let Some(panel_id) = cc.app.stage_panel {
+ CmdResult::ClosePanel {
+ validate_purpose: false,
+ panel_ref: PanelReference::Id(panel_id),
}
} else {
- CmdResult::error("no selection")
+ CmdResult::Keep
}
}
+ Internal::stage => self.stage(app_state, cc, con),
+ Internal::unstage => self.unstage(app_state, cc, con),
+ Internal::toggle_stage => self.toggle_stage(app_state, cc, con),
Internal::print_path => {
if let Some(path) = self.selected_path() {
print::print_path(path, con)?
@@ -344,15 +343,76 @@ pub trait PanelState {
})
}
+ fn stage(
+ &self,
+ app_state: &mut AppState,
+ cc: &CmdContext,
+ con: &AppContext,
+ ) -> CmdResult {
+ info!("received command to stage {:?}", self.selected_path());
+ if let Some(path) = self.selected_path() {
+ let path = path.to_path_buf();
+ app_state.stage.add(path);
+ if cc.app.stage_panel.is_none() {
+ return CmdResult::NewPanel {
+ state: Box::new(StageState::new(self.tree_options(), con)),
+ purpose: PanelPurpose::None,
+ direction: HDir::Right,
+ };
+ }
+ } else {
+ // TODO display error ?
+ warn!("no path in state");
+ }
+ CmdResult::Keep
+ }
+
+ fn unstage(
+ &self,
+ app_state: &mut AppState,
+ cc: &CmdContext,
+ con: &AppContext,
+ ) -> CmdResult {
+ if let Some(path) = self.selected_path() {
+ if app_state.stage.remove(path) && app_state.stage.is_empty() {
+ if let Some(panel_id) = cc.app.stage_panel {
+ return CmdResult::ClosePanel {
+ validate_purpose: false,
+ panel_ref: PanelReference::Id(panel_id),
+ };
+ }
+ }
+ }
+ CmdResult::Keep
+ }
+
+ fn toggle_stage(
+ &self,
+ app_state: &mut AppState,
+ cc: &CmdContext,
+ con: &AppContext,
+ ) -> CmdResult {
+ if let Some(path) = self.selected_path() {
+ if app_state.stage.paths.iter().any(|p| p==path) {
+ self.unstage(app_state, cc, con)
+ } else {
+ self.stage(app_state, cc, con)
+ }
+ } else {
+ CmdResult::error("no selection")
+ }
+ }
+
fn execute_verb(
&mut self,
w: &mut W, // needed because we may want to switch from alternate in some externals
verb: &Verb,
invocation: Option<&VerbInvocation>,
trigger_type: TriggerType,
+ app_state: &mut AppState,
cc: &CmdContext,
) -> Result<CmdResult, ProgramError> {
- if verb.needs_selection && !self.has_at_least_one_selection(cc) {
+ if verb.needs_selection && !self.has_at_least_one_selection(app_state) {
return Ok(CmdResult::DisplayError(
"This verb needs a selection".to_string()
));
@@ -364,13 +424,13 @@ pub trait PanelState {
}
match &verb.execution {
VerbExecution::Internal(internal_exec) => {
- self.on_internal(w, internal_exec, invocation, trigger_type, cc)
+ self.on_internal(w, internal_exec, invocation, trigger_type, app_state, cc)
}
VerbExecution::External(external) => {
- self.execute_external(w, verb, external, invocation, cc)
+ self.execute_external(w, verb, external, invocation, app_state, cc)
}
VerbExecution::Sequence(seq_ex) => {
- self.execute_sequence(w, verb, seq_ex, invocation, cc)
+ self.execute_sequence(w, verb, seq_ex, invocation, app_state, cc)
}
}
}
@@ -381,6 +441,7 @@ pub trait PanelState {
verb: &Verb,
external_execution: &ExternalExecution,
invocation: Option<&VerbInvocation>,
+ _app_state: &mut AppState,
cc: &CmdContext,
) -> Result<CmdResult, ProgramError> {
let selection = match self.selection() {
@@ -406,10 +467,11 @@ pub trait PanelState {
fn execute_sequence(
&mut self,
- w: &mut W,
+ _w: &mut W,
verb: &Verb,
seq_ex: &SequenceExecution,
invocation: Option<&VerbInvocation>,
+ _app_state: &mut AppState,
cc: &CmdContext,
) -> Result<CmdResult, ProgramError> {
let selection = match self.selection() {
@@ -443,6 +505,7 @@ pub trait PanelState {
fn on_command(
&mut self,
w: &mut W,
+ app_state: &mut AppState,
cc: &CmdContext,
) -> Result<CmdResult, ProgramError> {
self.clear_pending();
@@ -465,6 +528,7 @@ pub trait PanelState {
&con.verb_store.verbs[*index],
input_invocation.as_ref(),
TriggerType::Other,
+ app_state,
cc,
),
Command::Internal {
@@ -475,10 +539,10 @@ pub trait PanelState {
&InternalExecution::from_internal(*internal),
input_invocation.as_ref(),
TriggerType::Other,
+ app_state,
cc,
),
Command::VerbInvocate(invocation) => {
- let selection = self.selection();
match con.verb_store.search(
&invocation.name,
self.selection().map(|s| s.stype),
@@ -489,6 +553,7 @@ pub trait PanelState {
verb,
Some(invocation),
TriggerType::Input,
+ app_state,
cc,
)
}
@@ -509,7 +574,7 @@ pub trait PanelState {
close_if_open: bool,
cc: &CmdContext,
) -> CmdResult {
- if let Some(id) = cc.app.preview {
+ if let Some(id) = cc.app.preview_panel {
if close_if_open {
CmdResult::ClosePanel {
validate_purpose: false,
@@ -555,7 +620,7 @@ pub trait PanelState {
fn selection(&self) -> Option<Selection<'_>>;
- fn sel_info<'c>(&'c self, app_state: &'c AppState) -> SelInfo<'c> {
+ fn sel_info<'c>(&'c self, _app_state: &'c AppState) -> SelInfo<'c> {
// overloaded in stage_state
match self.selection() {
None => SelInfo::None,
@@ -563,7 +628,7 @@ pub trait PanelState {
}
}
- fn has_at_least_one_selection(&self, cc: &CmdContext) -> bool {
+ fn has_at_least_one_selection(&self, _app_state: &AppState) -> bool {
true // overloaded in stage_state
}
@@ -627,6 +692,7 @@ pub trait PanelState {
fn get_status(
&self,
+ app_state: &AppState,
cc: &CmdContext,
has_previous_state: bool,
) -> Status {
@@ -647,7 +713,7 @@ pub trait PanelState {
Status::new("No matching verb (*?* for the list of verbs)", true)
}
PrefixSearchResult::Match(_, verb) => {
- self.get_verb_status(verb, invocation, cc)
+ self.get_verb_status(verb, invocation, app_state, cc)
}
PrefixSearchResult::Matches(completions) => Status::new(
format!(
@@ -672,6 +738,7 @@ pub trait PanelState {
&self,
verb: &Verb,
invocation: &VerbInvocation,
+ _app_state: &AppState,
cc: &CmdContext,
) -> Status {
let selection = self.selection();
diff --git a/src/app/standard_status.rs b/src/app/standard_status.rs
index b3d758d..3b8f256 100644
--- a/src/app/standard_status.rs
+++ b/src/app/standard_status.rs
@@ -185,6 +185,9 @@ impl<'s> StandardStatusBuilder<'s> {
parts.add(&ss.no_verb);
}
}
+ PanelStateType::Fs => {
+ warn!("TODO fs status");
+ }
PanelStateType::Stage => {
warn!("TODO stage status");
}
diff --git a/src/app/state_type.rs b/src/app/state_type.rs
index fa2f47a..7ceecfb 100644
--- a/src/app/state_type.rs
+++ b/src/app/state_type.rs
@@ -1,5 +1,5 @@
-/// one of the three types of state that you could
+/// one of the types of state that you could
/// find in a panel today
#[derive(Debug, Clone, Copy)]
pub enum PanelStateType {
@@ -7,6 +7,9 @@ pub enum PanelStateType {
/// The standard browsing tree
Tree,
+ /// the filesystem
+ Fs,
+
/// The help "screen"
Help,
diff --git a/src/browser/browser_state.rs b/src/browser/browser_state.rs
index 2e0435e..f8cb79c 100644
--- a/src/browser/browser_state.rs
+++ b/src/browser/browser_state.rs
@@ -146,6 +146,10 @@ impl BrowserState {
impl PanelState for BrowserState {
+ fn get_type(&self) -> PanelStateType {
+ PanelStateType::Tree
+ }
+
fn set_mode(&mut self, mode: Mode) {
debug!("BrowserState::set_mode({:?})", mode);
self.mode = mode;
@@ -248,6 +252,7 @@ impl PanelState for BrowserState {
internal_exec: &InternalExecution,
input_invocation: Option<&VerbInvocation>,
trigger_type: TriggerType,
+ app_state: &mut AppState,
cc: &CmdContext,
) -> Result<CmdResult, ProgramError> {
let con = &cc.app.con;
@@ -364,7 +369,7 @@ impl PanelState for BrowserState {
let areas = &cc.panel.areas;
let selected_path = &self.displayed_tree().selected_line().path;
if areas.is_last() && areas.nb_pos < con.max_panels_count {
- let purpose = if selected_path.is_file() && cc.has_no_preview() {
+ let purpose = if selected_path.is_file() && cc.app.preview_panel.is_none() {
PanelPurpose::Preview
} else {
PanelPurpose::None
@@ -464,6 +469,7 @@ impl PanelState for BrowserState {
internal_exec,
input_invocation,
trigger_type,
+ app_state,
cc,
)?,
})
diff --git a/src/filesystems/filesystems_state.rs b/src/filesystems/filesystems_state.rs
index 0bf3c25..86b2b9f 100644
--- a/src/filesystems/filesystems_state.rs
+++ b/src/filesystems/filesystems_state.rs
@@ -7,7 +7,6 @@ use {
display::*,
errors::ProgramError,
pattern::*,
- skin::PanelSkin,
task_sync::Dam,
tree::TreeOptions,
verb::*,
@@ -26,7 +25,7 @@ use {
path::P