implemented history for the line editor

This commit is contained in:
2025-05-28 20:24:09 -04:00
parent f67543c111
commit 8cacbfdbdd
8 changed files with 731 additions and 147 deletions

View File

@@ -14,18 +14,18 @@ fn get_prompt() -> ShResult<String> {
//
// username@hostname
// short/path/to/pwd/
// $
// $ _
let default = "\\n\\e[1;0m\\u\\e[1;36m@\\e[1;31m\\h\\n\\e[1;36m\\W\\e[1;32m/\\n\\e[1;32m\\$\\e[0m ";
return Ok(format!("{}",expand_prompt(default)?))
return expand_prompt(default)
};
Ok(format!("\n{}",expand_prompt(&prompt)?))
expand_prompt(&prompt)
}
pub fn read_line(edit_mode: FernEditMode) -> ShResult<String> {
let prompt = get_prompt()?;
let mut reader: Box<dyn Readline> = match edit_mode {
FernEditMode::Vi => Box::new(FernVi::new(Some(prompt))),
FernEditMode::Vi => Box::new(FernVi::new(Some(prompt))?),
FernEditMode::Emacs => todo!()
};
reader.readline()