v1, champagne

This commit is contained in:
Justine 2023-02-19 19:41:06 +01:00
parent 08f80a57c1
commit 2a0866ab64
3 changed files with 9 additions and 25 deletions

View File

@ -1,6 +1,6 @@
[package]
name = "sqish"
version = "0.1.0"
version = "1.0.0"
edition = "2021"
[profile.release]

View File

@ -11,7 +11,7 @@ See the included sqishrc.yaml.example file included, and copy it as ~/.sqishrc.y
## Built-in shortcuts
### As Hotkeys
Some shortcuts are built in. They may be unique to Sqish or be copied from Zsh for example.
* Ctrl+Q : Quits the shell immediatly
* Ctrl+Q or Ctrl+D : Quits the shell immediatly
* Ctrl+U : Clears currently written line
* Alt+. : Appends the last word from previous command
* Ctrl+A : Jumps to the end of the line

View File

@ -108,25 +108,9 @@ pub mod shell {
let output = child
.wait_with_output()
.expect("Failed to wait on child");
//RawTerminal::activate_raw_mode(stdout);
// let output = Command::new(command)
// .args(args)
// .stdin(stdin)
// .output();
// let command_result = match output {
// Ok(o) => o,
// Err(e) => {
// eprintln!("\r\nGot error {}", e);
// return String::from("!");
// },
// };
//
// let _ = &mut resultat.push_str(str::from_utf8(&command_result.stdout)
let status = output.status
.code()
.expect("Could not get code")
.expect("Could not get retcode")
.to_string();
previous_command = None;
let format_res = format!("{}...Exit: {}\r\n",
@ -248,12 +232,14 @@ pub mod shell {
*current_number += 1;
} else if mycommand == &String::from("exit") {
write!(stdout, "\r\n Sayonara \r\n");
RawTerminal::suspend_raw_mode(&stdout);
std::process::exit(0);
} else {
conf.update_prompt(get_curr_history_number());
write!(stdout, "\r\n{}", conf.promptline).unwrap();
stdout.flush();
}
stdout.flush();
}
fn write_letter(mycommand: &mut String, current_pos: &mut usize, max_pos: &mut usize, c: char) {
@ -354,7 +340,8 @@ pub mod shell {
&mut stdout);
},
Key::Ctrl('q') => {
Key::Ctrl('q'|'d') => {
RawTerminal::suspend_raw_mode(&stdout);
writeln!(stdout, "\r\n Sayonara \r\n");
break;
},
@ -484,7 +471,7 @@ pub mod shell {
Key::Alt(x) => {
match x {
'a'..='y' => {
'a'..='z' => {
let x = String::from(x);
if conf.hotkeys.contains_key(&x) {
let hotcmd = &conf.hotkeys[&x].clone();
@ -506,9 +493,6 @@ pub mod shell {
}
}
},
'z' => {
print!("Z");
},
'.' => {
append_prev_arg(&mut mycommand, &mut current_pos, &mut max_pos);
},