diff options
author | NerdyPepper <[email protected]> | 2019-03-27 08:43:16 +0000 |
---|---|---|
committer | NerdyPepper <[email protected]> | 2019-03-27 08:43:16 +0000 |
commit | 308aac0af7aa82ea64d8808c022efaa7f4b5d6cb (patch) | |
tree | 5a0bdeeeabaea8f1c4c06316972c9e7bc385ce60 | |
parent | 6d390a03367544fb7a824ae7825ed333903f255f (diff) |
configure rustyline
-rw-r--r-- | src/main.rs | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/main.rs b/src/main.rs index a92a594..4e9a4e9 100644 --- a/src/main.rs +++ b/src/main.rs | |||
@@ -11,13 +11,21 @@ use crate::error::{ CalcError, handler }; | |||
11 | 11 | ||
12 | use rustyline::error::ReadlineError; | 12 | use rustyline::error::ReadlineError; |
13 | use rustyline::Editor; | 13 | use rustyline::Editor; |
14 | use rustyline::config::{ Config, Builder, ColorMode, EditMode }; | ||
14 | 15 | ||
15 | fn main() { | 16 | fn main() { |
16 | let mut rl = Editor::<()>::new(); | 17 | let config_builder = Builder::new(); |
18 | let config = config_builder.color_mode(ColorMode::Enabled) | ||
19 | .edit_mode(EditMode::Emacs) | ||
20 | .history_ignore_space(true) | ||
21 | .max_history_size(1000) | ||
22 | .build(); | ||
23 | let mut rl = Editor::<()>::with_config(config); | ||
17 | if rl.load_history("history.txt").is_err() { | 24 | if rl.load_history("history.txt").is_err() { |
18 | println!("No previous history."); | 25 | println!("No previous history."); |
19 | } | 26 | } |
20 | 'main: loop { | 27 | |
28 | loop { | ||
21 | let readline = rl.readline("> "); | 29 | let readline = rl.readline("> "); |
22 | match readline { | 30 | match readline { |
23 | Ok(line) => { | 31 | Ok(line) => { |