aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNerdyPepper <[email protected]>2019-03-27 08:43:16 +0000
committerNerdyPepper <[email protected]>2019-03-27 08:43:16 +0000
commit308aac0af7aa82ea64d8808c022efaa7f4b5d6cb (patch)
tree5a0bdeeeabaea8f1c4c06316972c9e7bc385ce60 /src
parent6d390a03367544fb7a824ae7825ed333903f255f (diff)
configure rustyline
Diffstat (limited to 'src')
-rw-r--r--src/main.rs12
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
12use rustyline::error::ReadlineError; 12use rustyline::error::ReadlineError;
13use rustyline::Editor; 13use rustyline::Editor;
14use rustyline::config::{ Config, Builder, ColorMode, EditMode };
14 15
15fn main() { 16fn main() {
16let 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) => {