mirror of
https://github.com/nushell/nushell.git
synced 2025-03-29 09:06:52 +01:00
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:
parent
c3c41a61b0
commit
1966809502
@ -76,7 +76,7 @@ impl Command for Explore {
|
|||||||
update_config(&mut config, show_index, show_head);
|
update_config(&mut config, show_index, show_head);
|
||||||
|
|
||||||
let show_banner = is_need_banner(&config).unwrap_or(true);
|
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);
|
let style = style_from_config(&config);
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ impl ViewCommand for ConfigCmd {
|
|||||||
Some(HelpManual {
|
Some(HelpManual {
|
||||||
name: Self::NAME,
|
name: Self::NAME,
|
||||||
description:
|
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,
|
config_options,
|
||||||
arguments: vec![],
|
arguments: vec![],
|
||||||
examples: vec![],
|
examples: vec![],
|
||||||
|
@ -53,7 +53,7 @@ impl ViewCommand for ConfigShowCmd {
|
|||||||
Some(HelpManual {
|
Some(HelpManual {
|
||||||
name: Self::NAME,
|
name: Self::NAME,
|
||||||
description:
|
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")],
|
arguments: vec![HelpExample::new("nu", "Use a nuon format instead")],
|
||||||
config_options: vec![],
|
config_options: vec![],
|
||||||
input: vec![],
|
input: vec![],
|
||||||
|
@ -30,19 +30,15 @@ impl HelpCmd {
|
|||||||
|
|
||||||
const HELP_MESSAGE: &'static str = r#" Explore - main help file
|
const HELP_MESSAGE: &'static str = r#" Explore - main help file
|
||||||
|
|
||||||
Move around: Use the cursor keys.
|
Move around: Use the cursor keys.
|
||||||
Close this window: Use "<Esc>".
|
Close help: Press "<Esc>".
|
||||||
Get out of Explore: Use ":q<Enter>" (or <Ctrl> + <D>).
|
Exit Explore: Type ":q" then then <Enter> (or press Ctrl+D).
|
||||||
|
Open an interactive REPL: Type ":try" then enter
|
||||||
Get specific help: It is possible to go directly to whatewer you want help on,
|
List all sub-commands: Type ":help :" then <Enter>
|
||||||
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>"
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------------
|
------------------------------------------------------------------------------------
|
||||||
|
|
||||||
Regular expressions ~
|
# Regular expressions
|
||||||
|
|
||||||
Most commands support regular expressions.
|
Most commands support regular expressions.
|
||||||
|
|
||||||
|
@ -207,7 +207,7 @@ impl ViewCommand for TableCmd {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if self.settings.line_shift.unwrap_or(false) {
|
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) {
|
if self.settings.show_cursor.unwrap_or(false) {
|
||||||
|
@ -46,9 +46,9 @@ impl ViewCommand for TryCmd {
|
|||||||
|
|
||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
let config_options = vec![
|
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 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]
|
#[rustfmt::skip]
|
||||||
@ -59,7 +59,7 @@ impl ViewCommand for TryCmd {
|
|||||||
|
|
||||||
Some(HelpManual {
|
Some(HelpManual {
|
||||||
name: "try",
|
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![],
|
arguments: vec![],
|
||||||
examples,
|
examples,
|
||||||
input: shortcuts,
|
input: shortcuts,
|
||||||
|
@ -34,8 +34,7 @@ impl SimpleCommand for TweakCmd {
|
|||||||
fn help(&self) -> Option<HelpManual> {
|
fn help(&self) -> Option<HelpManual> {
|
||||||
Some(HelpManual {
|
Some(HelpManual {
|
||||||
name: "tweak",
|
name: "tweak",
|
||||||
description:
|
description: "Set `explore` settings.\nLike a non-interactive version of :config",
|
||||||
"Set different settings.\nIt could be consired a not interactive version of :config",
|
|
||||||
arguments: vec![],
|
arguments: vec![],
|
||||||
examples: vec![
|
examples: vec![
|
||||||
HelpExample::new(":tweak table.show_index false", "Don't show index anymore"),
|
HelpExample::new(":tweak table.show_index false", "Don't show index anymore"),
|
||||||
|
@ -180,7 +180,7 @@ impl<'a> PagerConfig<'a> {
|
|||||||
style_computer,
|
style_computer,
|
||||||
config,
|
config,
|
||||||
peek_value: false,
|
peek_value: false,
|
||||||
exit_esc: false,
|
exit_esc: true,
|
||||||
reverse: false,
|
reverse: false,
|
||||||
show_banner: false,
|
show_banner: false,
|
||||||
style: StyleConfig::default(),
|
style: StyleConfig::default(),
|
||||||
@ -471,14 +471,14 @@ fn run_command(
|
|||||||
|
|
||||||
fn set_cursor_cmd_bar(f: &mut Frame, area: Rect, pager: &Pager) {
|
fn set_cursor_cmd_bar(f: &mut Frame, area: Rect, pager: &Pager) {
|
||||||
if pager.cmd_buf.is_cmd_input {
|
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;
|
let next_pos = (pager.cmd_buf.buf_cmd2.len() + 1) as u16;
|
||||||
// 1 skips a ':' char
|
// 1 skips a ':' char
|
||||||
if next_pos < area.width {
|
if next_pos < area.width {
|
||||||
f.set_cursor(next_pos as u16, area.height - 1);
|
f.set_cursor(next_pos as u16, area.height - 1);
|
||||||
}
|
}
|
||||||
} else if pager.search_buf.is_search_input {
|
} 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;
|
let next_pos = (pager.search_buf.buf_cmd_input.len() + 1) as u16;
|
||||||
// 1 skips a ':' char
|
// 1 skips a ':' char
|
||||||
if next_pos < area.width {
|
if next_pos < area.width {
|
||||||
@ -670,9 +670,9 @@ fn handle_events<V: View>(
|
|||||||
|
|
||||||
// Sometimes we get a BIG list of events;
|
// Sometimes we get a BIG list of events;
|
||||||
// for example when someone scrolls via a mouse either UP or DOWN.
|
// 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() {
|
while let Ok(Some(key)) = events.try_next() {
|
||||||
let result = handle_event(
|
let result = handle_event(
|
||||||
|
@ -62,9 +62,12 @@ impl View for InformationView {
|
|||||||
_: &mut Stack,
|
_: &mut Stack,
|
||||||
_: &Layout,
|
_: &Layout,
|
||||||
_: &mut ViewInfo,
|
_: &mut ViewInfo,
|
||||||
_: KeyEvent,
|
event: KeyEvent,
|
||||||
) -> Option<Transition> {
|
) -> Option<Transition> {
|
||||||
None
|
match event.code {
|
||||||
|
crossterm::event::KeyCode::Esc => Some(Transition::Exit),
|
||||||
|
_ => None,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn collect_data(&self) -> Vec<NuText> {
|
fn collect_data(&self) -> Vec<NuText> {
|
||||||
|
@ -27,7 +27,7 @@ use super::{
|
|||||||
pub struct InteractiveView<'a> {
|
pub struct InteractiveView<'a> {
|
||||||
input: Value,
|
input: Value,
|
||||||
command: String,
|
command: String,
|
||||||
imidiate: bool,
|
immediate: bool,
|
||||||
table: Option<RecordView<'a>>,
|
table: Option<RecordView<'a>>,
|
||||||
table_theme: TableTheme,
|
table_theme: TableTheme,
|
||||||
view_mode: bool,
|
view_mode: bool,
|
||||||
@ -40,7 +40,7 @@ impl<'a> InteractiveView<'a> {
|
|||||||
Self {
|
Self {
|
||||||
input,
|
input,
|
||||||
table: None,
|
table: None,
|
||||||
imidiate: false,
|
immediate: false,
|
||||||
table_theme: TableTheme::default(),
|
table_theme: TableTheme::default(),
|
||||||
border_color: Style::default(),
|
border_color: Style::default(),
|
||||||
highlighted_color: Style::default(),
|
highlighted_color: Style::default(),
|
||||||
@ -192,7 +192,7 @@ impl View for InteractiveView<'_> {
|
|||||||
if !self.command.is_empty() {
|
if !self.command.is_empty() {
|
||||||
self.command.pop();
|
self.command.pop();
|
||||||
|
|
||||||
if self.imidiate {
|
if self.immediate {
|
||||||
match self.try_run(engine_state, stack) {
|
match self.try_run(engine_state, stack) {
|
||||||
Ok(_) => info.report = Some(Report::default()),
|
Ok(_) => info.report = Some(Report::default()),
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
@ -207,7 +207,7 @@ impl View for InteractiveView<'_> {
|
|||||||
KeyCode::Char(c) => {
|
KeyCode::Char(c) => {
|
||||||
self.command.push(*c);
|
self.command.push(*c);
|
||||||
|
|
||||||
if self.imidiate {
|
if self.immediate {
|
||||||
match self.try_run(engine_state, stack) {
|
match self.try_run(engine_state, stack) {
|
||||||
Ok(_) => info.report = Some(Report::default()),
|
Ok(_) => info.report = Some(Report::default()),
|
||||||
Err(err) => info.report = Some(Report::error(format!("Error: {}", err))),
|
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()) {
|
if let Some(val) = hm.get("reactive").and_then(|v| v.as_bool().ok()) {
|
||||||
self.imidiate = val;
|
self.immediate = val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,7 +1,7 @@
|
|||||||
mod coloredtextw;
|
mod coloredtextw;
|
||||||
mod cursor;
|
mod cursor;
|
||||||
mod information;
|
mod information;
|
||||||
mod interative;
|
mod interactive;
|
||||||
mod preview;
|
mod preview;
|
||||||
mod record;
|
mod record;
|
||||||
pub mod util;
|
pub mod util;
|
||||||
@ -25,7 +25,7 @@ pub mod configuration;
|
|||||||
|
|
||||||
pub use configuration::ConfigurationView;
|
pub use configuration::ConfigurationView;
|
||||||
pub use information::InformationView;
|
pub use information::InformationView;
|
||||||
pub use interative::InteractiveView;
|
pub use interactive::InteractiveView;
|
||||||
pub use preview::Preview;
|
pub use preview::Preview;
|
||||||
pub use record::{Orientation, RecordView};
|
pub use record::{Orientation, RecordView};
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ impl<'a> RecordView<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn show_cursor(&mut self, b: bool) {
|
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) {
|
pub fn set_line_head_top(&mut self, b: bool) {
|
||||||
@ -85,7 +85,7 @@ impl<'a> RecordView<'a> {
|
|||||||
self.theme.table.header_bottom = b;
|
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;
|
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);
|
f.render_widget(hightlight_block.clone(), area);
|
||||||
}
|
}
|
||||||
|
|
||||||
if theme.show_cursow {
|
if theme.show_cursor {
|
||||||
f.set_cursor(info.area.x, info.area.y);
|
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_cell = colors.get("selected_cell").cloned();
|
||||||
theme.cursor.selected_row = colors.get("selected_row").cloned();
|
theme.cursor.selected_row = colors.get("selected_row").cloned();
|
||||||
theme.cursor.selected_column = colors.get("selected_column").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_top = config_get_bool(config, "line_head_top", true);
|
||||||
theme.table.header_bottom = config_get_bool(config, "line_head_bottom", true);
|
theme.table.header_bottom = config_get_bool(config, "line_head_bottom", true);
|
||||||
@ -835,5 +835,5 @@ struct CursorStyle {
|
|||||||
selected_cell: Option<NuStyle>,
|
selected_cell: Option<NuStyle>,
|
||||||
selected_column: Option<NuStyle>,
|
selected_column: Option<NuStyle>,
|
||||||
selected_row: Option<NuStyle>,
|
selected_row: Option<NuStyle>,
|
||||||
show_cursow: bool,
|
show_cursor: bool,
|
||||||
}
|
}
|
||||||
|
@ -154,7 +154,7 @@ pub fn make_styled_string(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn convert_with_precision(val: &str, precision: usize) -> Result<String, ShellError> {
|
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>() {
|
let val_float = match val.trim().parse::<f64>() {
|
||||||
Ok(f) => f,
|
Ok(f) => f,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user