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

Start removing colour config from explore #10270

Merged
merged 2 commits into from
Sep 8, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion crates/nu-explore/src/commands/try.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ impl ViewCommand for TryCmd {
#[rustfmt::skip]
let config_options = vec![
ConfigOption::boolean(":try options", "In the `:try` REPL, attempt to run the command on every keypress", "try.reactive"),
ConfigOption::new(":try options", "Change a border color of the menus", "try.border_color", default_color_list()),
ConfigOption::new(":try options", "Change a highlighted menu color", "try.highlighted_color", default_color_list()),
];

Expand Down
22 changes: 0 additions & 22 deletions crates/nu-explore/src/explore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,6 @@ fn prepare_default_config(config: &mut HashMap<String, Value>) {

const TABLE_SELECT_COLUMN: Style = color(None, None);

const TRY_BORDER_COLOR: Style = color(None, None);

const CONFIG_CURSOR_COLOR: Style = color(Some(Color::Black), Some(Color::LightYellow));

insert_style(config, "status_bar_background", STATUS_BAR);
Expand Down Expand Up @@ -262,17 +260,6 @@ fn prepare_default_config(config: &mut HashMap<String, Value>) {
config.insert(String::from("table"), map_into_value(hm));
}

{
let mut hm = config
.get("try")
.and_then(parse_hash_map)
.unwrap_or_default();

insert_style(&mut hm, "border_color", TRY_BORDER_COLOR);

config.insert(String::from("try"), map_into_value(hm));
}

{
let mut hm = config
.get("config")
Expand Down Expand Up @@ -344,15 +331,6 @@ fn include_nu_config(config: &mut HashMap<String, Value>, style_computer: &Style
config.insert(String::from("table"), map_into_value(map));
}

{
let mut map = config
.get("try")
.and_then(parse_hash_map)
.unwrap_or_default();
insert_style(&mut map, "border_color", line_color);
config.insert(String::from("try"), map_into_value(map));
}

{
let mut map = config
.get("config")
Expand Down
8 changes: 3 additions & 5 deletions crates/nu-explore/src/views/interactive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use crate::{

use super::{
record::{RecordView, TableTheme},
util::nu_style_to_tui,
util::{lookup_tui_color, nu_style_to_tui},
Layout, Orientation, View, ViewConfig,
};

Expand Down Expand Up @@ -248,13 +248,11 @@ impl View for InteractiveView<'_> {
}

fn setup(&mut self, config: ViewConfig<'_>) {
self.border_color = lookup_tui_color(config.style_computer, "separator");

if let Some(hm) = config.config.get("try").and_then(create_map) {
let colors = get_color_map(&hm);

if let Some(color) = colors.get("border_color").copied() {
self.border_color = nu_style_to_tui(color);
}

if let Some(color) = colors.get("highlighted_color").copied() {
self.highlighted_color = nu_style_to_tui(color);
}
Expand Down
5 changes: 5 additions & 0 deletions crates/nu-explore/src/views/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ pub fn set_span(
text_width as u16
}

pub fn lookup_tui_color(style_computer: &StyleComputer, key: &str) -> Style {
let nu_style = style_computer.compute(key, &Value::nothing(nu_protocol::Span::unknown()));
nu_style_to_tui(nu_style)
}

pub fn nu_style_to_tui(style: NuStyle) -> ratatui::style::Style {
let mut out = ratatui::style::Style::default();
if let Some(clr) = style.background {
Expand Down
7 changes: 0 additions & 7 deletions crates/nu-utils/src/sample_config/default_config.nu
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,6 @@ $env.config = {
}

explore: {
try: {
border_color: {fg: "white"}
},
status_bar_background: {fg: "#1D1F21", bg: "#C4C9C6"},
command_bar_text: {fg: "#C4C9C6"},
highlight: {fg: "black", bg: "yellow"},
Expand All @@ -200,10 +197,6 @@ $env.config = {
line_shift: true,
line_index: true,
},
config: {
border_color: {fg: "white"}
cursor_color: {fg: "black", bg: "light_yellow"}
},
}

history: {
Expand Down