Some more autocomplete improvs
This commit is contained in:
parent
aa9cbb323d
commit
e7ecb6a7d0
15
src/lib.rs
15
src/lib.rs
@ -239,14 +239,16 @@ pub mod shell {
|
|||||||
let mut conf = match SqishConf::from_sqishrc() {
|
let mut conf = match SqishConf::from_sqishrc() {
|
||||||
Ok(c) => c,
|
Ok(c) => c,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
let ret_line = format!("Could not build conf, got {}\r\nUsing default\r\n", e);
|
|
||||||
write!(stdout, "{}", ret_line);
|
|
||||||
let conf = SqishConf {
|
let conf = SqishConf {
|
||||||
promptline: String::from("$COLORGREEN_ [$USER_@$HOSTNAME_] "),
|
promptline: String::from("!$HISTNUMBER$COLORGREEN_[$USER_@$HOSTNAME_]$COLORRESET_ "),
|
||||||
promptline_base: String::from("$COLORGREEN_ [$USER_@$HOSTNAME_] "),
|
promptline_base: String::from("!$HISTNUMBER_$COLORGREEN_[$USER_@$HOSTNAME_]$COLORRESET_ "),
|
||||||
aliases: HashMap::new(),
|
aliases: HashMap::new(),
|
||||||
hotkeys: HashMap::new(),
|
hotkeys: HashMap::new(),
|
||||||
};
|
};
|
||||||
|
let ret_line = format!("Could not build conf, got {}\
|
||||||
|
\r\nUsing default promptline:\
|
||||||
|
\r\n{}\r\n", e, conf.promptline);
|
||||||
|
write!(stdout, "{}", ret_line);
|
||||||
conf
|
conf
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@ -268,7 +270,7 @@ pub mod shell {
|
|||||||
//Search
|
//Search
|
||||||
*&mut mycommand = replace_signs(&mycommand);
|
*&mut mycommand = replace_signs(&mycommand);
|
||||||
let (res, list) = Search::build(&mycommand).unwrap().autocomplete();
|
let (res, list) = Search::build(&mycommand).unwrap().autocomplete();
|
||||||
write!(stdout, "\r\n{}\r\n", list);
|
if list.len() > 0 { write!(stdout, "\r\n{}\r\n", list); }
|
||||||
mycommand.clear();
|
mycommand.clear();
|
||||||
mycommand.push_str(&res);
|
mycommand.push_str(&res);
|
||||||
max_pos = res.len();
|
max_pos = res.len();
|
||||||
@ -286,7 +288,7 @@ pub mod shell {
|
|||||||
let _res = handle_input(&comm);
|
let _res = handle_input(&comm);
|
||||||
RawTerminal::activate_raw_mode(&stdout);
|
RawTerminal::activate_raw_mode(&stdout);
|
||||||
mycommand.clear();
|
mycommand.clear();
|
||||||
//Proper printing
|
//Proper printing of return code
|
||||||
//for line in res.split('\n') {
|
//for line in res.split('\n') {
|
||||||
// if line != "\r" {
|
// if line != "\r" {
|
||||||
// write!(stdout, "\r\n{}", line);
|
// write!(stdout, "\r\n{}", line);
|
||||||
@ -295,6 +297,7 @@ pub mod shell {
|
|||||||
&conf.update_prompt(get_curr_history_number());
|
&conf.update_prompt(get_curr_history_number());
|
||||||
write!(stdout, "\r\n{}", conf.promptline).unwrap();
|
write!(stdout, "\r\n{}", conf.promptline).unwrap();
|
||||||
stdout.flush();
|
stdout.flush();
|
||||||
|
current_number += 1;
|
||||||
} else if mycommand == String::from("exit") {
|
} else if mycommand == String::from("exit") {
|
||||||
write!(stdout, "\r\n Sayonara \r\n");
|
write!(stdout, "\r\n Sayonara \r\n");
|
||||||
break;
|
break;
|
||||||
|
@ -94,7 +94,7 @@ impl Search {
|
|||||||
SearchType::CmdSearch => autocomplete_cmd(&self.searchee, &self),
|
SearchType::CmdSearch => autocomplete_cmd(&self.searchee, &self),
|
||||||
SearchType::FileSearch => match autocomplete_file(&self) {
|
SearchType::FileSearch => match autocomplete_file(&self) {
|
||||||
Ok(t) => t,
|
Ok(t) => t,
|
||||||
Err(_) => (String::new(), String::new()),
|
Err(_) => (format!("{}{}", &self.command, &self.searchee), String::new()),
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -188,6 +188,11 @@ fn autocomplete_file(search: &Search) -> std::io::Result<(String, String)> {
|
|||||||
*&mut last_found = longest;
|
*&mut last_found = longest;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if nbr_found == 0 {
|
||||||
|
let ret_val = format!("{}{}", &search.command, &search.searchee);
|
||||||
|
return Ok((ret_val, String::new()));
|
||||||
|
}
|
||||||
|
|
||||||
//Handle the path when tabbing in a long path, zsh-like
|
//Handle the path when tabbing in a long path, zsh-like
|
||||||
//then return the value
|
//then return the value
|
||||||
let xxx = &search.search_path.clone().into_os_string().into_string().unwrap();
|
let xxx = &search.search_path.clone().into_os_string().into_string().unwrap();
|
||||||
@ -214,7 +219,7 @@ fn autocomplete_cmd(input: &String, search: &Search) -> (String, String) {
|
|||||||
return (res_string, res_list);
|
return (res_string, res_list);
|
||||||
} else if found_bins.len() == 0 {
|
} else if found_bins.len() == 0 {
|
||||||
let list = String::from("Nothing adequate.");
|
let list = String::from("Nothing adequate.");
|
||||||
let res = String::new();
|
let res = String::from("");
|
||||||
return (res, list);
|
return (res, list);
|
||||||
} else {
|
} else {
|
||||||
let mut all_res = String::new();
|
let mut all_res = String::new();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user