aboutsummaryrefslogtreecommitdiff
path: root/src/readline/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/readline/mod.rs')
-rw-r--r--src/readline/mod.rs9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/readline/mod.rs b/src/readline/mod.rs
index 97f03bd..e9d4b33 100644
--- a/src/readline/mod.rs
+++ b/src/readline/mod.rs
@@ -26,6 +26,7 @@ impl Highlighter for LineHighlighter {
26 let op = eval_math_expression(line, 0f64); 26 let op = eval_math_expression(line, 0f64);
27 match op { 27 match op {
28 Ok(_) => { 28 Ok(_) => {
29 let constants = ["e", "pi"];
29 let functions = [ 30 let functions = [
30 "sin" , "cos" , "tan" , 31 "sin" , "cos" , "tan" ,
31 "csc" , "sec" , "cot" , 32 "csc" , "sec" , "cot" ,
@@ -39,9 +40,11 @@ impl Highlighter for LineHighlighter {
39 let ops = Regex::new(r"(?P<o>[\+-/\*%\^!])").unwrap(); 40 let ops = Regex::new(r"(?P<o>[\+-/\*%\^!])").unwrap();
40 let mut coloured: String = ops.replace_all(line, "\x1b[33m$o\x1b[0m").into(); 41 let mut coloured: String = ops.replace_all(line, "\x1b[33m$o\x1b[0m").into();
41 42
42 for &f in functions.iter() { 43 for c in &constants {
43 let hfn = format!("\x1b[34m{}\x1b[0m", f); 44 coloured = coloured.replace(c, &format!("\x1b[33m{}\x1b[0m", c));
44 coloured = coloured.replace(f, &hfn[..]); 45 }
46 for f in &functions {
47 coloured = coloured.replace(f, &format!("\x1b[34m{}\x1b[0m", f));
45 } 48 }
46 Owned(coloured.into()) 49 Owned(coloured.into())
47 }, 50 },