explore tweaks Round 1 (#7511)

A few small tweaks to the new `explore` command:

1. Rewrote the help text a bit.
    1. I think it's important to mention `:try` up front.
2. Removed the info about `:help foo` because it's currently supported
by very few subcommands
2. Make `exit_esc` default to true. I want to avoid people getting stuck
in `explore` like they get stuck in Vim
3. ~~Always show the help message ("For help type :help") on startup~~
1. The message is small+unobtrusive and I don't this is worth a
configuration item
4. Exit the information view when Escape is pressed
5. General typo+grammar cleanup
    
cc: @zhiburt @fdncred
This commit is contained in:
Reilly Wood 2022-12-17 12:05:41 -08:00 committed by GitHub
parent c3c41a61b0
commit 1966809502
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 37 additions and 39 deletions

View File

@ -76,7 +76,7 @@ impl Command for Explore {
update_config(&mut config, show_index, show_head);
let show_banner = is_need_banner(&config).unwrap_or(true);
let exit_esc = is_need_esc_exit(&config).unwrap_or(false);
let exit_esc = is_need_esc_exit(&config).unwrap_or(true);
let style = style_from_config(&config);

View File

@ -70,7 +70,7 @@ impl ViewCommand for ConfigCmd {
Some(HelpManual {
name: Self::NAME,
description:
"Interactive configuration manager.\nCan be used to set various explore settings.\n\nIt could be consired an interactive version of :tweak",
"Interactive configuration manager.\nCan be used to set various explore settings.\n\nLike an interactive version of :tweak",
config_options,
arguments: vec![],
examples: vec![],

View File

@ -53,7 +53,7 @@ impl ViewCommand for ConfigShowCmd {
Some(HelpManual {
name: Self::NAME,
description:
"Return a currently used configuration.\nSome default fields might be missing.",
"Show the current `explore` configuration.\nSome default fields might be missing.",
arguments: vec![HelpExample::new("nu", "Use a nuon format instead")],
config_options: vec![],
input: vec![],

View File

@ -30,19 +30,15 @@ impl HelpCmd {
const HELP_MESSAGE: &'static str = r#" Explore - main help file
Move around: Use the cursor keys.
Close this window: Use "<Esc>".
Get out of Explore: Use ":q<Enter>" (or <Ctrl> + <D>).
Get specific help: It is possible to go directly to whatewer you want help on,
by adding an argument to the ":help" command.
Currently you can only get help on a few commands.
To obtain a list of supported commands run ":help :<Enter>"
Move around: Use the cursor keys.
Close help: Press "<Esc>".
Exit Explore: Type ":q" then then <Enter> (or press Ctrl+D).
Open an interactive REPL: Type ":try" then enter
List all sub-commands: Type ":help :" then <Enter>
------------------------------------------------------------------------------------
Regular expressions ~
# Regular expressions
Most commands support regular expressions.

View File

@ -207,7 +207,7 @@ impl ViewCommand for TableCmd {
}
if self.settings.line_shift.unwrap_or(false) {
view.set_line_traling(true);
view.set_line_trailing(true);
}
if self.settings.show_cursor.unwrap_or(false) {

View File

@ -46,9 +46,9 @@ impl ViewCommand for TryCmd {
#[rustfmt::skip]
let config_options = vec![
ConfigOption::boolean(":try options", "Try makes running command on each input character", "try.reactive"),
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 highlighed menu color", "try.highlighted_color", default_color_list()),
ConfigOption::new(":try options", "Change a highlighted menu color", "try.highlighted_color", default_color_list()),
];
#[rustfmt::skip]
@ -59,7 +59,7 @@ impl ViewCommand for TryCmd {
Some(HelpManual {
name: "try",
description: "Opens a panel in which to run Nushell commands and explore their output. The exporer acts liek `:table`.",
description: "Opens a panel in which to run Nushell commands and explore their output. The explorer acts like `:table`.",
arguments: vec![],
examples,
input: shortcuts,

View File

@ -34,8 +34,7 @@ impl SimpleCommand for TweakCmd {
fn help(&self) -> Option<HelpManual> {
Some(HelpManual {
name: "tweak",
description:
"Set different settings.\nIt could be consired a not interactive version of :config",
description: "Set `explore` settings.\nLike a non-interactive version of :config",
arguments: vec![],
examples: vec![
HelpExample::new(":tweak table.show_index false", "Don't show index anymore"),

View File

@ -180,7 +180,7 @@ impl<'a> PagerConfig<'a> {
style_computer,
config,
peek_value: false,
exit_esc: false,
exit_esc: true,
reverse: false,
show_banner: false,
style: StyleConfig::default(),
@ -471,14 +471,14 @@ fn run_command(
fn set_cursor_cmd_bar(f: &mut Frame, area: Rect, pager: &Pager) {
if pager.cmd_buf.is_cmd_input {
// todo: deal with a situation where we exeed the bar width
// todo: deal with a situation where we exceed the bar width
let next_pos = (pager.cmd_buf.buf_cmd2.len() + 1) as u16;
// 1 skips a ':' char
if next_pos < area.width {
f.set_cursor(next_pos as u16, area.height - 1);
}
} else if pager.search_buf.is_search_input {
// todo: deal with a situation where we exeed the bar width
// todo: deal with a situation where we exceed the bar width
let next_pos = (pager.search_buf.buf_cmd_input.len() + 1) as u16;
// 1 skips a ':' char
if next_pos < area.width {
@ -670,9 +670,9 @@ fn handle_events<V: View>(
// Sometimes we get a BIG list of events;
// for example when someone scrolls via a mouse either UP or DOWN.
// This MIGHT causes freeses as we have a 400 delay for a next command read.
// This MIGHT cause freezes as we have a 400 delay for a next command read.
//
// To eliminate that we are trying ot read all possible commands which we should action upon.
// To eliminate that we are trying to read all possible commands which we should act upon.
while let Ok(Some(key)) = events.try_next() {
let result = handle_event(

View File

@ -62,9 +62,12 @@ impl View for InformationView {
_: &mut Stack,
_: &Layout,
_: &mut ViewInfo,
_: KeyEvent,
event: KeyEvent,
) -> Option<Transition> {
None
match event.code {
crossterm::event::KeyCode::Esc => Some(Transition::Exit),
_ => None,
}
}
fn collect_data(&self) -> Vec<NuText> {

View File

@ -27,7 +27,7 @@ use super::{
pub struct InteractiveView<'a> {
input: Value,
command: String,
imidiate: bool,
immediate: bool,
table: Option<RecordView<'a>>,
table_theme: TableTheme,
view_mode: bool,
@ -40,7 +40,7 @@ impl<'a> InteractiveView<'a> {
Self {
input,
table: None,
imidiate: false,
immediate: false,
table_theme: TableTheme::default(),
border_color: Style::default(),
highlighted_color: Style::default(),
@ -192,7 +192,7 @@ impl View for InteractiveView<'_> {
if !self.command.is_empty() {
self.command.pop();
if self.imidiate {
if self.immediate {
match self.try_run(engine_state, stack) {
Ok(_) => info.report = Some(Report::default()),
Err(err) => {
@ -207,7 +207,7 @@ impl View for InteractiveView<'_> {
KeyCode::Char(c) => {
self.command.push(*c);
if self.imidiate {
if self.immediate {
match self.try_run(engine_state, stack) {
Ok(_) => info.report = Some(Report::default()),
Err(err) => info.report = Some(Report::error(format!("Error: {}", err))),
@ -266,7 +266,7 @@ impl View for InteractiveView<'_> {
}
if let Some(val) = hm.get("reactive").and_then(|v| v.as_bool().ok()) {
self.imidiate = val;
self.immediate = val;
}
}

View File

@ -1,7 +1,7 @@
mod coloredtextw;
mod cursor;
mod information;
mod interative;
mod interactive;
mod preview;
mod record;
pub mod util;
@ -25,7 +25,7 @@ pub mod configuration;
pub use configuration::ConfigurationView;
pub use information::InformationView;
pub use interative::InteractiveView;
pub use interactive::InteractiveView;
pub use preview::Preview;
pub use record::{Orientation, RecordView};

View File

@ -74,7 +74,7 @@ impl<'a> RecordView<'a> {
}
pub fn show_cursor(&mut self, b: bool) {
self.theme.cursor.show_cursow = b;
self.theme.cursor.show_cursor = b;
}
pub fn set_line_head_top(&mut self, b: bool) {
@ -85,7 +85,7 @@ impl<'a> RecordView<'a> {
self.theme.table.header_bottom = b;
}
pub fn set_line_traling(&mut self, b: bool) {
pub fn set_line_trailing(&mut self, b: bool) {
self.theme.table.shift_line = b;
}
@ -636,7 +636,7 @@ fn highlight_cell(f: &mut Frame, area: Rect, info: ElementInfo, theme: &CursorSt
f.render_widget(hightlight_block.clone(), area);
}
if theme.show_cursow {
if theme.show_cursor {
f.set_cursor(info.area.x, info.area.y);
}
}
@ -791,7 +791,7 @@ fn theme_from_config(config: &ConfigMap) -> TableTheme {
theme.cursor.selected_cell = colors.get("selected_cell").cloned();
theme.cursor.selected_row = colors.get("selected_row").cloned();
theme.cursor.selected_column = colors.get("selected_column").cloned();
theme.cursor.show_cursow = config_get_bool(config, "show_cursor", true);
theme.cursor.show_cursor = config_get_bool(config, "show_cursor", true);
theme.table.header_top = config_get_bool(config, "line_head_top", true);
theme.table.header_bottom = config_get_bool(config, "line_head_bottom", true);
@ -835,5 +835,5 @@ struct CursorStyle {
selected_cell: Option<NuStyle>,
selected_column: Option<NuStyle>,
selected_row: Option<NuStyle>,
show_cursow: bool,
show_cursor: bool,
}

View File

@ -154,7 +154,7 @@ pub fn make_styled_string(
}
fn convert_with_precision(val: &str, precision: usize) -> Result<String, ShellError> {
// vall will always be a f64 so convert it with precision formatting
// val will always be a f64 so convert it with precision formatting
let val_float = match val.trim().parse::<f64>() {
Ok(f) => f,
Err(e) => {