From 264a1296e4114b23d70378123fc287c1e1a73b2a Mon Sep 17 00:00:00 2001 From: Max Shron Date: Wed, 5 Dec 2018 22:40:40 -0500 Subject: [PATCH 1/4] Demo of functionality; MCFLY_LIGHT -> color change --- src/interface.rs | 6 +++++- src/settings.rs | 6 ++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/interface.rs b/src/interface.rs index 2705c161..00d748c3 100644 --- a/src/interface.rs +++ b/src/interface.rs @@ -187,7 +187,11 @@ impl<'a> Interface<'a> { command, &self.input.command, width, - color::Fg(color::Green).to_string(), + if self.settings.lightmode { + color::Fg(color::Blue).to_string() + } else { + color::Fg(color::Green).to_string() + }, fg, self.debug ) diff --git a/src/settings.rs b/src/settings.rs index cee44f9f..3aade763 100644 --- a/src/settings.rs +++ b/src/settings.rs @@ -28,6 +28,7 @@ pub struct Settings { pub old_dir: Option, pub append_to_histfile: bool, pub refresh_training_cache: bool, + pub lightmode: bool, } impl Default for Settings { @@ -44,6 +45,7 @@ impl Default for Settings { refresh_training_cache: false, append_to_histfile: false, debug: false, + lightmode: false, } } } @@ -243,6 +245,10 @@ impl Settings { _ => unreachable!(), // If all subcommands are defined above, anything else is unreachable!() } + settings.lightmode = match env::var_os("MCFLY_LIGHT") { + Some(_val) => true, + None => false + }; settings } From 00edd5bfb816de7ae9c817c97e26bbafe088505b Mon Sep 17 00:00:00 2001 From: Max Shron Date: Tue, 11 Dec 2018 21:43:16 -0500 Subject: [PATCH 2/4] Adjust color scheme. When you run mcfly with MCFLY_LIGHT set, the color scheme will work better on light terminals. --- src/interface.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/interface.rs b/src/interface.rs index 00d748c3..1dc87edd 100644 --- a/src/interface.rs +++ b/src/interface.rs @@ -130,7 +130,11 @@ impl<'a> Interface<'a> { write!( screen, "{}{}{}$ {}", - color::Fg(color::LightWhite).to_string(), + if self.settings.lightmode { + color::Fg(color::Black).to_string() + } else { + color::Fg(color::LightWhite).to_string() + }, cursor::Goto(1, PROMPT_LINE_INDEX), clear::CurrentLine, self.input @@ -190,7 +194,7 @@ impl<'a> Interface<'a> { if self.settings.lightmode { color::Fg(color::Blue).to_string() } else { - color::Fg(color::Green).to_string() + color::Fg(color::Cyan).to_string() }, fg, self.debug From 56f3cf8c54c51d8480592c1dda98608481c586c1 Mon Sep 17 00:00:00 2001 From: Max Shron Date: Tue, 11 Dec 2018 21:45:19 -0500 Subject: [PATCH 3/4] Fix color for results text in light mode --- src/interface.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/interface.rs b/src/interface.rs index 1dc87edd..9e1e7891 100644 --- a/src/interface.rs +++ b/src/interface.rs @@ -173,7 +173,11 @@ impl<'a> Interface<'a> { } for (index, command) in self.matches.iter().enumerate() { - let mut fg = color::Fg(color::LightWhite).to_string(); + let mut fg = if self.settings.lightmode { + color::Fg(color::Black).to_string() + } else { + color::Fg(color::LightWhite).to_string() + }; let mut bg = color::Bg(color::Reset).to_string(); if index == self.selection { From ecbad3911b1afc1ef594a746f2ecfa1fdfa8636a Mon Sep 17 00:00:00 2001 From: Max Shron Date: Tue, 11 Dec 2018 21:51:25 -0500 Subject: [PATCH 4/4] Update README.md to include light mode documentation --- README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.md b/README.md index a4199988..5585c43b 100644 --- a/README.md +++ b/README.md @@ -100,6 +100,16 @@ To avoid McFly's UI messing up your scrollback history in iTerm2, make sure this iterm2 UI instructions +## Light Mode + +To swap the color scheme for use in a light terminal, set the environment variable `MCFLY_LIGHT`. + +For example, add the following to your `~/.bash_profile`: + +```bash +export MCFLY_LIGHT=TRUE +``` + ## Possible Future Features * Add a screencast to README.