From 361ad08c2074493a48a0c86d17af4478ca9fe1ef Mon Sep 17 00:00:00 2001 From: Sam Tay Date: Wed, 1 Jul 2020 22:41:21 -0700 Subject: Use include_str instead of duplicating theme --- TODO.md | 2 -- src/config.rs | 43 +------------------------------------------ src/tui/app.rs | 1 - 3 files changed, 1 insertion(+), 45 deletions(-) diff --git a/TODO.md b/TODO.md index e6456cd..bce0caf 100644 --- a/TODO.md +++ b/TODO.md @@ -1,11 +1,9 @@ # TODO ### chores -0. Use `include_str!` instead of hardcoding `colors.toml`. 1. Move to github actions ASAP, travis & appveyor are a PITA. See resources below. 2. Refactor layout handling (see TODO on `tui::views::LayoutView::relayout`) 3. Release on AUR & Homebrew -4. Either `include_str!` or avoid parsing key mappings text altogether ### bugs 1. Shift+TAB should move focus backwards diff --git a/src/config.rs b/src/config.rs index 987a887..79caa28 100644 --- a/src/config.rs +++ b/src/config.rs @@ -96,7 +96,7 @@ pub fn theme_file_name() -> Result { let name = project_dir()?.config_dir().join("colors.toml"); if !name.as_path().exists() { let mut file = utils::create_file(&name)?; - file.write_all(DEFAULT_COLORS_TOML.as_bytes())?; + file.write_all(include_str!("../themes/default.toml").as_bytes())?; } Ok(name) } @@ -111,44 +111,3 @@ fn write_config(config: &Config) -> Result<()> { fn config_file_name() -> Result { Ok(project_dir()?.config_dir().join("config.yml")) } - -static DEFAULT_COLORS_TOML: &str = r##" -# Every field in a theme file is optional. - -shadow = false -borders = "outset" # Alternatives are "none" and "simple" - -# Base colors are -# red, green, blue, cyan, magenta, yellow, white and black. -# -# There are 3 ways to select a color: -# - The 16 base colors are selected by name: -# "blue", "light red", "magenta", ... -# - Low-resolution colors use 3 characters, each <= 5: -# "541", "003", ... -# - Full-resolution colors start with '#' and can be 3 or 6 hex digits: -# "#1A6", "#123456", ... -[colors] -background = "default" - -# If the terminal doesn't support custom color (like the linux TTY), -# non-base colors will be skipped. -shadow = [] -view = "default" - -# An array with a single value has the same effect as a simple value. -primary = ["default"] -secondary = "cyan" # secondary style is used for code hightlighting -tertiary = "green" - -# Hex values can use lower or uppercase. -# (base color MUST be lowercase) -# If the value is an array, the first valid -# and supported color will be used. -title_primary = ["BLUE", "red"] # `BLUE` will be skipped. -title_secondary = "yellow" - -# Lower precision values can use only 3 digits. -highlight = "yellow" -highlight_inactive = "light yellow" -"##; diff --git a/src/tui/app.rs b/src/tui/app.rs index c0e2328..accb1de 100644 --- a/src/tui/app.rs +++ b/src/tui/app.rs @@ -140,7 +140,6 @@ fn pretty_score(score: i32) -> StyledString { } // This would be a good usecase for brining in termimad tables -// TODO dont parse this at runtime, just hardcode it (or include_str) pub fn help() -> Dialog { let bindings = r###" ## Panes -- cgit v1.2.3