Some more autocomplete improvs

This commit is contained in:
Justine
2023-02-07 02:04:38 +01:00
parent aa9cbb323d
commit e7ecb6a7d0
2 changed files with 18 additions and 10 deletions

View File

@ -239,14 +239,16 @@ pub mod shell {
let mut conf = match SqishConf::from_sqishrc() {
Ok(c) => c,
Err(e) => {
let ret_line = format!("Could not build conf, got {}\r\nUsing default\r\n", e);
write!(stdout, "{}", ret_line);
let conf = SqishConf {
promptline: String::from("$COLORGREEN_ [$USER_@$HOSTNAME_] "),
promptline_base: String::from("$COLORGREEN_ [$USER_@$HOSTNAME_] "),
promptline: String::from("!$HISTNUMBER$COLORGREEN_[$USER_@$HOSTNAME_]$COLORRESET_ "),
promptline_base: String::from("!$HISTNUMBER_$COLORGREEN_[$USER_@$HOSTNAME_]$COLORRESET_ "),
aliases: 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
},
};
@ -268,7 +270,7 @@ pub mod shell {
//Search
*&mut mycommand = replace_signs(&mycommand);
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.push_str(&res);
max_pos = res.len();
@ -286,7 +288,7 @@ pub mod shell {
let _res = handle_input(&comm);
RawTerminal::activate_raw_mode(&stdout);
mycommand.clear();
//Proper printing
//Proper printing of return code
//for line in res.split('\n') {
// if line != "\r" {
// write!(stdout, "\r\n{}", line);
@ -295,6 +297,7 @@ pub mod shell {
&conf.update_prompt(get_curr_history_number());
write!(stdout, "\r\n{}", conf.promptline).unwrap();
stdout.flush();
current_number += 1;
} else if mycommand == String::from("exit") {
write!(stdout, "\r\n Sayonara \r\n");
break;