Now handling CtrlC properly

This commit is contained in:
Justine
2023-02-20 14:41:54 +01:00
parent 40a61e7e68
commit 57476671ed
2 changed files with 9 additions and 1 deletions

View File

@ -16,3 +16,4 @@ unicode-segmentation = "1.6.0"
which = { version = "4.4.0", features = ["regex"] } which = { version = "4.4.0", features = ["regex"] }
regex = "1.7.1" regex = "1.7.1"
yaml-rust = "0.4.5" yaml-rust = "0.4.5"
ctrlc = "3.2.5"

View File

@ -30,6 +30,8 @@ pub mod shell {
//used for home directory //used for home directory
extern crate dirs; extern crate dirs;
extern crate ctrlc;
fn process_line(input: &str) -> String { fn process_line(input: &str) -> String {
@ -112,7 +114,7 @@ pub mod shell {
.expect("Failed to wait on child"); .expect("Failed to wait on child");
let status = output.status let status = output.status
.code() .code()
.expect("Could not get retcode") .unwrap_or(255)
.to_string(); .to_string();
previous_command = None; previous_command = None;
let format_res = format!("{}", let format_res = format!("{}",
@ -290,6 +292,11 @@ pub mod shell {
let mut current_pos: usize = 0; let mut current_pos: usize = 0;
let mut max_pos: usize = 0; let mut max_pos: usize = 0;
//Handle Ctrl+C
ctrlc::set_handler(|| {
();
}).unwrap();
let mut conf = match SqishConf::from_sqishrc() { let mut conf = match SqishConf::from_sqishrc() {
Ok(c) => c, Ok(c) => c,
Err(e) => { Err(e) => {