Add color_scheme configuration option

I'll write up more comprehensive docs once CI has proven that
the color schemes are packaged correctly.

The gist of it is that you can now specify:

```
color_scheme = "Batman"
```

to specify the default color palette.

The name corresponds to one of the color schemes from the
`assets/colors` directory.  That directory is packaged and installed by
the CI deployment script, but we're also able to load them from the
source dir if you're running from in the wezterm source tree.

You can see previews of the various schemes here:
<https://iterm2colorschemes.com/>

In addition to loading from those that path, wezterm will search:

* In the `config` dir that is a sibling to `wezterm.exe` on windows
  (not yet tested!)
* The directories specified in your `color_scheme_dirs` config setting
  (multiple paths can be specified)
* You may also define schemes directly inline in your config file
  using syntax like this:

```
[color_schemes."My Name"]
foreground = "#4a4543"
background = "#f7f7f7"
```
This commit is contained in:
Wez Furlong committed 2020-01-12 22:08:36 -08:00
1 parent ab2090c5c4
commit 1af9ded3ce
2 files changed
+21 -1

No files matched your search

+12
View File
@@ -275,6 +275,10 @@ pub struct Config {
/// The color palette
pub colors: Option<Palette>,
/// Use a named color scheme rather than the palette specified
/// by the colors setting.
pub color_scheme: Option<String>,
/// Named color schemes
#[serde(default)]
pub color_schemes: HashMap<String, Palette>,
@@ -641,6 +645,14 @@ impl Config {
cfg.load_color_schemes(&cfg.compute_color_scheme_dirs())
.ok();
if let Some(scheme) = cfg.color_scheme.as_ref() {
if !cfg.color_schemes.contains_key(scheme) {
log::error!("Your configuration specifies \
color_scheme=\"{}\" but that scheme \
was not found", scheme);
}
}
cfg
}
+9 -1
View File
@@ -22,7 +22,15 @@ impl term::TerminalConfiguration for TermConfig {
}
fn color_palette(&self) -> ColorPalette {
configuration()
let config = configuration();
if let Some(scheme_name) = config.color_scheme.as_ref() {
if let Some(palette) = config.color_schemes.get(scheme_name) {
return palette.clone().into();
}
}
config
.colors
.as_ref()
.cloned()