implemented ex mode :w/:e commands
implemented tab completion and history search for the ex mode prompt as well fixed paths not expanding correctly in ex mode command arguments
This commit is contained in:
@@ -7,6 +7,8 @@ use itertools::Itertools;
|
||||
use crate::bitflags;
|
||||
use crate::expand::{Expander, expand_raw};
|
||||
use crate::libsh::error::{ShErr, ShErrKind, ShResult};
|
||||
use crate::parse::lex::TkFlags;
|
||||
use crate::readline::complete::SimpleCompleter;
|
||||
use crate::readline::history::History;
|
||||
use crate::readline::keys::KeyEvent;
|
||||
use crate::readline::linebuf::LineBuf;
|
||||
@@ -152,6 +154,14 @@ impl ViMode for ViEx {
|
||||
None
|
||||
}
|
||||
|
||||
fn editor(&mut self) -> Option<&mut LineBuf> {
|
||||
Some(&mut self.pending_cmd.buf)
|
||||
}
|
||||
|
||||
fn history(&mut self) -> Option<&mut History> {
|
||||
Some(&mut self.pending_cmd.history)
|
||||
}
|
||||
|
||||
fn cursor_style(&self) -> String {
|
||||
"\x1b[3 q".to_string()
|
||||
}
|
||||
@@ -328,8 +338,13 @@ fn parse_read(chars: &mut Peekable<Chars<'_>>) -> Result<Option<Verb>, Option<St
|
||||
}
|
||||
|
||||
fn get_path(path: &str) -> Result<PathBuf, Option<String>> {
|
||||
let expanded = expand_raw(&mut path.chars().peekable())
|
||||
.map_err(|e| Some(format!("Error expanding path: {}", e)))?;
|
||||
log::debug!("Expanding path: {}", path);
|
||||
let expanded = Expander::from_raw(path, TkFlags::empty())
|
||||
.map_err(|e| Some(format!("Error expanding path: {}", e)))?
|
||||
.expand()
|
||||
.map_err(|e| Some(format!("Error expanding path: {}", e)))?
|
||||
.join(" ");
|
||||
log::debug!("Expanded path: {}", expanded);
|
||||
Ok(PathBuf::from(&expanded))
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,9 @@ use std::fmt::Display;
|
||||
use unicode_segmentation::UnicodeSegmentation;
|
||||
|
||||
use crate::libsh::error::ShResult;
|
||||
use crate::readline::history::History;
|
||||
use crate::readline::keys::{KeyCode as K, KeyEvent as E, ModKeys as M};
|
||||
use crate::readline::linebuf::LineBuf;
|
||||
use crate::readline::vicmd::{Motion, MotionCmd, To, Verb, VerbCmd, ViCmd};
|
||||
|
||||
pub mod ex;
|
||||
@@ -79,9 +81,9 @@ pub trait ViMode {
|
||||
fn as_replay(&self) -> Option<CmdReplay>;
|
||||
fn cursor_style(&self) -> String;
|
||||
fn pending_seq(&self) -> Option<String>;
|
||||
fn pending_cursor(&self) -> Option<usize> {
|
||||
None
|
||||
}
|
||||
fn pending_cursor(&self) -> Option<usize> { None }
|
||||
fn editor(&mut self) -> Option<&mut LineBuf> { None }
|
||||
fn history(&mut self) -> Option<&mut History> { None }
|
||||
fn move_cursor_on_undo(&self) -> bool;
|
||||
fn clamp_cursor(&self) -> bool;
|
||||
fn hist_scroll_start_pos(&self) -> Option<To>;
|
||||
|
||||
Reference in New Issue
Block a user