From 48ab7653e4ecda3eb3148d62e36b79e7ffe69909 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Hozda?= Date: Tue, 18 Aug 2020 20:54:09 +0200 Subject: [PATCH] readd colors --- Cargo.lock | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++- Cargo.toml | 2 +- src/main.rs | 14 +++++----- 3 files changed, 83 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 135ed19..745e94d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -35,6 +35,27 @@ dependencies = [ "constant_time_eq", ] +[[package]] +name = "bunt" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cea10ffe8284fa58449999363754310f02c14341eebbe6d6d8114a20aebf3d64" +dependencies = [ + "bunt-macros", + "termcolor", +] + +[[package]] +name = "bunt-macros" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4e933115fd38a2271140ccc2d8757408a705176878c6b929d8d353601b14913" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "cfg-if" version = "0.1.10" @@ -107,6 +128,24 @@ version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "237a5ed80e274dbc66f86bd59c1e25edc039660be53194b5fe0a482e0f2612ea" +[[package]] +name = "proc-macro2" +version = "1.0.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04f5f085b5d71e2188cb8271e5da0161ad52c3f227a661a3c135fdf28e258b12" +dependencies = [ + "unicode-xid", +] + +[[package]] +name = "quote" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa563d17ecb180e500da1cfd2b028310ac758de548efdd203e18f283af693f37" +dependencies = [ + "proc-macro2", +] + [[package]] name = "rand" version = "0.7.3" @@ -178,8 +217,8 @@ dependencies = [ name = "rgc" version = "0.3.3" dependencies = [ + "bunt", "dirs", - "libc", "simple_input", "tempfile", ] @@ -202,6 +241,17 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fa41a909f42f472032b66a7de24725c5999edefe69f6fa21b1746ba840bb981b" +[[package]] +name = "syn" +version = "1.0.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e69abc24912995b3038597a7a593be5053eb0fb44f3cc5beec0deb421790c1f4" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + [[package]] name = "tempfile" version = "3.1.0" @@ -216,6 +266,21 @@ dependencies = [ "winapi", ] +[[package]] +name = "termcolor" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb6bfa289a4d7c5766392812c0a1f4c1ba45afa1ad47803c11e1f407d846d75f" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "unicode-xid" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564" + [[package]] name = "wasi" version = "0.9.0+wasi-snapshot-preview1" @@ -238,6 +303,15 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" +[[package]] +name = "winapi-util" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +dependencies = [ + "winapi", +] + [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" diff --git a/Cargo.toml b/Cargo.toml index 3f105bb..9b375ea 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,7 +9,7 @@ license = "ISC" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -libc = "0.2.74" tempfile = "3.1.0" simple_input = "0.4.0" dirs = "3.0.1" +bunt = "0.1.0" diff --git a/src/main.rs b/src/main.rs index 7318802..51e1436 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,4 @@ +extern crate bunt; extern crate dirs; extern crate tempfile; extern crate simple_input; @@ -196,10 +197,9 @@ impl BrowserState { }; self.links = Some(Box::new(link)); - let fresh4 = self.link_key; + make_key_str(self.link_key, &mut a, &mut b, &mut c); self.link_key += 1; - make_key_str(fresh4, &mut a, &mut b, &mut c); - println!("{}{}{} {}", a, b, c, name); + bunt::println!("{[green]}{[green]}{[green]} {}", a, b, c, name); } pub fn clear_links(&mut self) { @@ -649,11 +649,11 @@ impl BrowserState { false, ); /* to display the prompt */ loop { - // todo color prompt - let line = input(&format!( - "{}:{}{} ", + bunt::print!( + "{[blue]}:{[blue]}{[blue]} ", self.current_host, self.current_port, &self.current_selector - )); + ); + let line = input(""); match line.chars().next() { Some('?') => {