diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/config/mod.rs | 3 | ||||
| -rw-r--r-- | src/repl/mod.rs | 7 |
2 files changed, 7 insertions, 3 deletions
diff --git a/src/config/mod.rs b/src/config/mod.rs index b18bc74..1643b4e 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -62,6 +62,8 @@ pub struct Config { pub wrap: Option<String>, /// Whether wrap code block pub wrap_code: bool, + /// Whether to exit REPL by pressing Ctrl+C twice + pub ctrlc_exit: bool, /// Automatically copy the last output to the clipboard pub auto_copy: bool, /// REPL keybindings. (emacs, vi) @@ -109,6 +111,7 @@ impl Default for Config { light_theme: false, wrap: None, wrap_code: false, + ctrlc_exit: true, auto_copy: false, keybindings: Default::default(), prelude: String::new(), diff --git a/src/repl/mod.rs b/src/repl/mod.rs index 1b96d3b..cc642cc 100644 --- a/src/repl/mod.rs +++ b/src/repl/mod.rs @@ -103,6 +103,7 @@ impl Repl { self.banner(); let mut already_ctrlc = false; + let ctrlc_exit = self.config.read().ctrlc_exit; loop { if self.abort.aborted_ctrld() { @@ -117,8 +118,8 @@ impl Repl { already_ctrlc = false; self.abort.reset(); match self.handle(&line) { - Ok(quit) => { - if quit { + Ok(exit) => { + if exit { break; } } @@ -130,7 +131,7 @@ impl Repl { } Ok(Signal::CtrlC) => { self.abort.set_ctrlc(); - if already_ctrlc { + if already_ctrlc && ctrlc_exit { break; } already_ctrlc = true; |
