From 2b90620d831b06d226c6928c3cac19cec7f221c4 Mon Sep 17 00:00:00 2001 From: PaddiM8 Date: Sat, 30 May 2020 15:59:25 +0200 Subject: [PATCH] Added some colours to the terminal output. --- Cargo.lock | 10 ++++++++++ Cargo.toml | 1 + src/main.rs | 7 ++++--- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 811ff9d..6cfadfb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,5 +1,14 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. +[[package]] +name = "ansi_term" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" +dependencies = [ + "winapi", +] + [[package]] name = "arrayref" version = "0.3.6" @@ -113,6 +122,7 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" name = "lek" version = "0.1.0" dependencies = [ + "ansi_term", "phf", "rustyline", ] diff --git a/Cargo.toml b/Cargo.toml index 4f9ea5e..70a42ab 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,3 +13,4 @@ panic = "abort" [dependencies] rustyline = "6.1.2" phf = { version = "0.8", features = ["macros"] } +ansi_term = "0.12" diff --git a/src/main.rs b/src/main.rs index 6afe1ea..926462a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -7,9 +7,10 @@ mod parser; mod prelude; mod symbol_table; +use ansi_term::Colour::{Cyan, Red}; +use ast::Unit; use rustyline::error::ReadlineError; use rustyline::Editor; -use ast::Unit; fn main() { let mut parser = parser::Context::new(); @@ -24,7 +25,7 @@ fn main() { let mut rl = Editor::<()>::new(); loop { - let readline = rl.readline(">> "); + let readline = rl.readline(&Cyan.paint(">> ").to_string()); match readline { Ok(input) => { @@ -50,7 +51,7 @@ fn eval(parser: &mut parser::Context, input: &str) { match parser::parse(parser, input, get_angle_unit()) { Ok(Some(result)) => println!("{}", result), Ok(None) => print!(""), - Err(err) => println!("{}", err), + Err(err) => println!("{}", Red.paint(err)), } }