fn apply_command(
        &mut self,
        cmd: Command,
        screen: &mut Screen,
        con: &AppContext,
    ) -> io::Result<Command> {
        let mut cmd = cmd;
        debug!("action: {:?}", &cmd.action);
        screen.read_size(con)?;
        screen.input_field.display();
        self.state().write_flags(screen, con)?;
        screen.write_spinner(false)?;
        match self.mut_state().apply(&mut cmd, screen, con)? {
            AppStateCmdResult::Quit => {
                debug!("cmd result quit");
                self.quitting = true;
            }
            AppStateCmdResult::Launch(launchable) => {
                self.launch_at_end = Some(*launchable);
                self.quitting = true;
            }
            AppStateCmdResult::NewState(boxed_state, new_cmd) => {
                self.push(boxed_state);
                cmd = new_cmd;
                self.state().write_status(screen, &cmd, con)?;
            }
            AppStateCmdResult::RefreshState => {
                file_sizes::clear_cache();
                cmd = self.mut_state().refresh(screen, con);
            }
            AppStateCmdResult::PopState => {
                if self.states.len() == 1 {
                    debug!("quitting on last pop state");
                    self.quitting = true;
                } else {
                    self.states.pop();
                    cmd = self.mut_state().refresh(screen, con);
                    self.state().write_status(screen, &cmd, con)?;
                }
            }
            AppStateCmdResult::PopStateAndReapply => {
                if self.states.len() == 1 {
                    debug!("quitting on last pop state");
                    self.quitting = true;
                } else {
                    self.states.pop();
                    debug!("about to reapply {:?}", &cmd);
                    return self.apply_command(cmd, screen, con);
                }
            }
            AppStateCmdResult::DisplayError(txt) => {
                screen.write_status_err(&txt)?;
            }
            AppStateCmdResult::Keep => {
                self.state().write_status(screen, &cmd, con)?;
            }
        }
        screen.input_field.set_content(&cmd.raw);
        self.mut_state().display(screen, con)?;
        screen.input_field.display();
        self.state().write_flags(screen, con)?;
        Ok(cmd)
    }
/// apply a command, and returns a command, which may be the same (modified or not)
///  or a new one.
/// This normally mutates self
apply a command, and returns a command, which may be the same (modified or not)
or a new one.
This normally mutates self
apply a command and returns a command which may be the same ( modified or not ) or a new one . This normally mutates self
fn apply_command(
        &mut self,
        cmd: Command,
        screen: &mut Screen,
        con: &AppContext,
    ) -> io::Result<Command> {
        let mut cmd = cmd;
        debug!("action: {:?}", &cmd.action);
        screen.read_size(con)?;
        screen.input_field.display();
        self.state().write_flags(screen, con)?;
        screen.write_spinner(false)?;
        match self.mut_state().apply(&mut cmd, screen, con)? {
            AppStateCmdResult::Quit => {
                debug!("cmd result quit");
                self.quitting = true;
            }
            AppStateCmdResult::Launch(launchable) => {
                self.launch_at_end = Some(*launchable);
                self.quitting = true;
            }
            AppStateCmdResult::NewState(boxed_state, new_cmd) => {
                self.push(boxed_state);
                cmd = new_cmd;
                self.state().write_status(screen, &cmd, con)?;
            }
            AppStateCmdResult::RefreshState => {
                file_sizes::clear_cache();
                cmd = self.mut_state().refresh(screen, con);
            }
            AppStateCmdResult::PopState => {
                if self.states.len() == 1 {
                    debug!("quitting on last pop state");
                    self.quitting = true;
                } else {
                    self.states.pop();
                    cmd = self.mut_state().refresh(screen, con);
                    self.state().write_status(screen, &cmd, con)?;
                }
            }
            AppStateCmdResult::PopStateAndReapply => {
                if self.states.len() == 1 {
                    debug!("quitting on last pop state");
                    self.quitting = true;
                } else {
                    self.states.pop();
                    debug!("about to reapply {:?}", &cmd);
                    return self.apply_command(cmd, screen, con);
                }
            }
            AppStateCmdResult::DisplayError(txt) => {
                screen.write_status_err(&txt)?;
            }
            AppStateCmdResult::Keep => {
                self.state().write_status(screen, &cmd, con)?;
            }
        }
        screen.input_field.set_content(&cmd.raw);
        self.mut_state().display(screen, con)?;
        screen.input_field.display();
        self.state().write_flags(screen, con)?;
        Ok(cmd)
    }
fn apply_command ( & mut self , cmd : Command , screen : & mut Screen , con : & AppContext , ) -> io :: Result < Command > { let mut cmd = cmd ; debug ! ( " " cmd action ) ; screen . read_size ( con ) ? ; screen . input_field . display ( ) ; self . state ( ) . write_flags ( screen , con ) ? ; screen . write_spinner ( false ) ? ; match self . mut_state ( ) . apply ( & mut cmd , screen , con ) ? { AppStateCmdResult :: Quit => { debug ! ( " " ) ; self . quitting = true ; } AppStateCmdResult :: Launch ( launchable ) => { self . launch_at_end = Some ( * launchable ) ; self . quitting = true ; } AppStateCmdResult :: NewState ( boxed_state , new_cmd ) => { self . push ( boxed_state ) ; cmd = new_cmd ; self . state ( ) . write_status ( screen , & cmd , con ) ? ; } AppStateCmdResult :: RefreshState => { file_sizes :: clear_cache ( ) ; cmd = self . mut_state ( ) . refresh ( screen , con ) ; } AppStateCmdResult :: PopState => { if self . states . len ( ) == 1 { debug ! ( " " ) ; self . quitting = true ; } else { self . states . pop ( ) ; cmd = self . mut_state ( ) . refresh ( screen , con ) ; self . state ( ) . write_status ( screen , & cmd , con ) ? ; } } AppStateCmdResult :: PopStateAndReapply => { if self . states . len ( ) == 1 { debug ! ( " " ) ; self . quitting = true ; } else { self . states . pop ( ) ; debug ! ( " " cmd ) ; return self . apply_command ( cmd , screen , con ) ; } } AppStateCmdResult :: DisplayError ( txt ) => { screen . write_status_err ( & txt ) ? ; } AppStateCmdResult :: Keep => { self . state ( ) . write_status ( screen , & cmd , con ) ? ; } } screen . input_field . set_content ( & cmd . raw ) ; self . mut_state ( ) . display ( screen , con ) ? ; screen . input_field . display ( ) ; self . state ( ) . write_flags ( screen , con ) ? ; Ok ( cmd ) }
apply a command, and returns a command, which may be the same (modified or not)
or a new one.
apply a command and returns a command which may be the same ( modified or not ) or a new one .
&mut self
cmd
Command
screen
&mut Screen
con
&AppContext
&mut self
cmd
Command
screen
&mut Screen
con
&AppContext