aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNerdyPepper <[email protected]>2019-06-18 07:52:07 +0100
committerNerdyPepper <[email protected]>2019-06-18 07:52:07 +0100
commit1a06f12da5e701b778009fc5c81db28f092fcede (patch)
tree41aa18e98550c263e04a17d085a40b7bb7d8a561
parent2eda7d259dc7529ddaf52c30558d1e0432217959 (diff)
add history hinting
-rw-r--r--Cargo.toml2
-rw-r--r--readme.md6
-rw-r--r--src/main.rs9
3 files changed, 12 insertions, 5 deletions
diff --git a/Cargo.toml b/Cargo.toml
index 4523192..8c10596 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -12,7 +12,7 @@ categories = ["command-line-interface", "science", "parser-implementations"]
12license = "MIT" 12license = "MIT"
13 13
14[dependencies] 14[dependencies]
15rustyline = "3.0.0" 15rustyline = "4.0.0"
16clap = "2.32.0" 16clap = "2.32.0"
17radix_fmt = "0.1.1" 17radix_fmt = "0.1.1"
18lazy_static = "1.3.0" 18lazy_static = "1.3.0"
diff --git a/readme.md b/readme.md
index ea96c76..2c1998a 100644
--- a/readme.md
+++ b/readme.md
@@ -23,7 +23,7 @@ $ cargo run
23### usage 23### usage
24 24
25```shell 25```shell
26eva 0.2.3 26eva 0.2.4
27NerdyPepper <[email protected]> 27NerdyPepper <[email protected]>
28Calculator REPL similar to bc(1) 28Calculator REPL similar to bc(1)
29 29
@@ -36,10 +36,12 @@ FLAGS:
36 -V, --version Prints version information 36 -V, --version Prints version information
37 37
38OPTIONS: 38OPTIONS:
39 -f, --fix <FIX> set number of decimal places in the output 39 -b, --base <RADIX> set the radix of calculation output (2, 8, 10, 16 etc.)
40 -f, --fix <FIX> set number of decimal places in the output
40 41
41ARGS: 42ARGS:
42 <INPUT> optional expression string to run eva in command mode 43 <INPUT> optional expression string to run eva in command mode
44
43``` 45```
44 46
45type out an expression and hit enter, repeat. 47type out an expression and hit enter, repeat.
diff --git a/src/main.rs b/src/main.rs
index 5846a87..ffdb690 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -20,10 +20,14 @@ use crate::format::*;
20// extern crates 20// extern crates
21use rustyline::error::ReadlineError; 21use rustyline::error::ReadlineError;
22use rustyline::Editor; 22use rustyline::Editor;
23use rustyline::config::{ Builder, ColorMode, EditMode }; 23use rustyline::config::{ Builder, ColorMode, EditMode, CompletionType };
24use rustyline::highlight::{ Highlighter, MatchingBracketHighlighter };
25use rustyline::hint::{ Hinter, HistoryHinter };
24use clap::{Arg, App}; 26use clap::{Arg, App};
25use lazy_static::lazy_static; 27use lazy_static::lazy_static;
26 28
29struct LineHelper (MatchingBracketHighlighter, HistoryHinter);
30
27struct Configuration { 31struct Configuration {
28 radian_mode: bool, 32 radian_mode: bool,
29 fix: usize, 33 fix: usize,
@@ -50,6 +54,7 @@ fn main() {
50 let config = config_builder.color_mode(ColorMode::Enabled) 54 let config = config_builder.color_mode(ColorMode::Enabled)
51 .edit_mode(EditMode::Emacs) 55 .edit_mode(EditMode::Emacs)
52 .history_ignore_space(true) 56 .history_ignore_space(true)
57 .completion_type(CompletionType::Circular)
53 .max_history_size(1000) 58 .max_history_size(1000)
54 .build(); 59 .build();
55 let mut rl = Editor::<()>::with_config(config); 60 let mut rl = Editor::<()>::with_config(config);
@@ -102,7 +107,7 @@ fn parse_arguments() -> Configuration {
102 .long("base") 107 .long("base")
103 .takes_value(true) 108 .takes_value(true)
104 .value_name("RADIX") 109 .value_name("RADIX")
105 .help("set the radix of calculation output (2, 8, 10, 16 etc.)")) 110 .help("set the radix of calculation output (1 - 36)"))
106 .arg(Arg::with_name("INPUT") 111 .arg(Arg::with_name("INPUT")
107 .help("optional expression string to run eva in command mode") 112 .help("optional expression string to run eva in command mode")
108 .index(1)) 113 .index(1))