From 2a0866ab64665f6c66e88923ad53a9a3bc883623 Mon Sep 17 00:00:00 2001 From: Justine Date: Sun, 19 Feb 2023 19:41:06 +0100 Subject: [PATCH] v1, champagne --- Cargo.toml | 2 +- README.md | 2 +- src/lib.rs | 30 +++++++----------------------- 3 files changed, 9 insertions(+), 25 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 4bf6a74..7e78106 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "sqish" -version = "0.1.0" +version = "1.0.0" edition = "2021" [profile.release] diff --git a/README.md b/README.md index 3f9ec97..0ce9407 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/src/lib.rs b/src/lib.rs index 39c7332..692fbe5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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); },