Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Light mode #30

Merged
merged 4 commits into from
Dec 14, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,16 @@ To avoid McFly's UI messing up your scrollback history in iTerm2, make sure this

<img src="/docs/iterm2.jpeg" alt="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.
Expand Down
18 changes: 15 additions & 3 deletions src/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -169,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 {
Expand All @@ -187,7 +195,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::Cyan).to_string()
},
fg,
self.debug
)
Expand Down
6 changes: 6 additions & 0 deletions src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ pub struct Settings {
pub old_dir: Option<String>,
pub append_to_histfile: bool,
pub refresh_training_cache: bool,
pub lightmode: bool,
}

impl Default for Settings {
Expand All @@ -44,6 +45,7 @@ impl Default for Settings {
refresh_training_cache: false,
append_to_histfile: false,
debug: false,
lightmode: false,
}
}
}
Expand Down Expand Up @@ -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
}

Expand Down