From f2f4b83886d0060b93eef49baac1bb3ce18d42af Mon Sep 17 00:00:00 2001 From: Reilly Wood <26268125+rgwood@users.noreply.github.com> Date: Thu, 6 Jun 2024 06:46:43 -0700 Subject: [PATCH] Overhaul `explore` config (#13075) Configuration in `explore` has always been confusing to me. This PR overhauls (and simplifies, I think) how configuration is done. # Details 1. Configuration is now strongly typed. In `Explore::run()` we create an `ExploreConfig` struct from the more general Nu configuration and arguments to `explore`, then pass that struct to other parts of `explore` that need configuration. IMO this is a lot easier to reason about and trace than the previous approach of creating a `HashMap` and then using that to make various structs elsewhere. 2. We now inherit more configuration from the config used for regular Nu tables 1. Border/line styling now uses the `separator` style used for regular Nu tables, the special `explore.split_line` config point has been retired. 2. Cell padding in tables is now controlled by `table.padding` instead of the undocumented `column_padding_left`/`column_padding_right` config 3. The (optional, previously not enabled by default) `selected_row` and `selected_column` configuration has been removed. We now only highlight the selected cell. I could re-add this if people really like the feature but I'm guessing nobody uses it. The interface still looks the same with a default/empty config.nu: ![image](https://github.com/nushell/nushell/assets/26268125/e40161ba-a8ec-407a-932d-5ece6f4dc616) --- crates/nu-explore/src/commands/table.rs | 35 --- crates/nu-explore/src/commands/try.rs | 6 +- crates/nu-explore/src/explore.rs | 285 +++++++----------- crates/nu-explore/src/lib.rs | 4 +- crates/nu-explore/src/nu_common/mod.rs | 2 +- crates/nu-explore/src/nu_common/value.rs | 4 - crates/nu-explore/src/pager/mod.rs | 202 +++---------- crates/nu-explore/src/views/binary/mod.rs | 36 +-- crates/nu-explore/src/views/mod.rs | 12 +- crates/nu-explore/src/views/record/mod.rs | 160 ++-------- .../src/views/record/table_widget.rs | 48 ++- .../src/views/{interactive.rs => try.rs} | 59 +--- crates/nu-explore/src/views/util.rs | 5 - .../src/sample_config/default_config.nu | 7 +- 14 files changed, 229 insertions(+), 636 deletions(-) rename crates/nu-explore/src/views/{interactive.rs => try.rs} (82%) diff --git a/crates/nu-explore/src/commands/table.rs b/crates/nu-explore/src/commands/table.rs index 39ef8f0f99..6bc6268067 100644 --- a/crates/nu-explore/src/commands/table.rs +++ b/crates/nu-explore/src/commands/table.rs @@ -4,7 +4,6 @@ use crate::{ views::{Orientation, RecordView}, }; use anyhow::Result; -use nu_ansi_term::Style; use nu_protocol::{ engine::{EngineState, Stack}, Value, @@ -19,12 +18,6 @@ pub struct TableCmd { #[derive(Debug, Default, Clone)] struct TableSettings { orientation: Option, - split_line_s: Option