From 308aac0af7aa82ea64d8808c022efaa7f4b5d6cb Mon Sep 17 00:00:00 2001 From: NerdyPepper Date: Wed, 27 Mar 2019 14:13:16 +0530 Subject: configure rustyline --- src/main.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src') 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 }; use rustyline::error::ReadlineError; use rustyline::Editor; +use rustyline::config::{ Config, Builder, ColorMode, EditMode }; fn main() { -let mut rl = Editor::<()>::new(); + let config_builder = Builder::new(); + let config = config_builder.color_mode(ColorMode::Enabled) + .edit_mode(EditMode::Emacs) + .history_ignore_space(true) + .max_history_size(1000) + .build(); + let mut rl = Editor::<()>::with_config(config); if rl.load_history("history.txt").is_err() { println!("No previous history."); } - 'main: loop { + + loop { let readline = rl.readline("> "); match readline { Ok(line) => { -- cgit v1.2.3