From 1a06f12da5e701b778009fc5c81db28f092fcede Mon Sep 17 00:00:00 2001 From: NerdyPepper Date: Tue, 18 Jun 2019 12:22:07 +0530 Subject: add history hinting --- Cargo.toml | 2 +- readme.md | 6 ++++-- src/main.rs | 9 +++++++-- 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"] license = "MIT" [dependencies] -rustyline = "3.0.0" +rustyline = "4.0.0" clap = "2.32.0" radix_fmt = "0.1.1" lazy_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 ### usage ```shell -eva 0.2.3 +eva 0.2.4 NerdyPepper Calculator REPL similar to bc(1) @@ -36,10 +36,12 @@ FLAGS: -V, --version Prints version information OPTIONS: - -f, --fix set number of decimal places in the output + -b, --base set the radix of calculation output (2, 8, 10, 16 etc.) + -f, --fix set number of decimal places in the output ARGS: optional expression string to run eva in command mode + ``` type 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::*; // extern crates use rustyline::error::ReadlineError; use rustyline::Editor; -use rustyline::config::{ Builder, ColorMode, EditMode }; +use rustyline::config::{ Builder, ColorMode, EditMode, CompletionType }; +use rustyline::highlight::{ Highlighter, MatchingBracketHighlighter }; +use rustyline::hint::{ Hinter, HistoryHinter }; use clap::{Arg, App}; use lazy_static::lazy_static; +struct LineHelper (MatchingBracketHighlighter, HistoryHinter); + struct Configuration { radian_mode: bool, fix: usize, @@ -50,6 +54,7 @@ fn main() { let config = config_builder.color_mode(ColorMode::Enabled) .edit_mode(EditMode::Emacs) .history_ignore_space(true) + .completion_type(CompletionType::Circular) .max_history_size(1000) .build(); let mut rl = Editor::<()>::with_config(config); @@ -102,7 +107,7 @@ fn parse_arguments() -> Configuration { .long("base") .takes_value(true) .value_name("RADIX") - .help("set the radix of calculation output (2, 8, 10, 16 etc.)")) + .help("set the radix of calculation output (1 - 36)")) .arg(Arg::with_name("INPUT") .help("optional expression string to run eva in command mode") .index(1)) -- cgit v1.2.3