mirror of
https://github.com/nushell/nushell.git
synced 2025-06-30 22:50:14 +02:00
history-menu (#846)
This commit is contained in:
@ -17,6 +17,7 @@ pub struct NushellPrompt {
|
||||
default_vi_visual_prompt_indicator: String,
|
||||
default_menu_prompt_indicator: String,
|
||||
default_multiline_indicator: String,
|
||||
default_history_prompt_indicator: String,
|
||||
}
|
||||
|
||||
impl Default for NushellPrompt {
|
||||
@ -35,6 +36,7 @@ impl NushellPrompt {
|
||||
default_vi_visual_prompt_indicator: "v ".to_string(),
|
||||
default_menu_prompt_indicator: "| ".to_string(),
|
||||
default_multiline_indicator: "::: ".to_string(),
|
||||
default_history_prompt_indicator: "? ".to_string(),
|
||||
}
|
||||
}
|
||||
|
||||
@ -67,11 +69,12 @@ impl NushellPrompt {
|
||||
left_prompt_string: Option<String>,
|
||||
right_prompt_string: Option<String>,
|
||||
prompt_indicator_string: String,
|
||||
prompt_indicator_menu: String,
|
||||
prompt_multiline_indicator_string: String,
|
||||
prompt_vi: (String, String),
|
||||
prompt_menus: (String, String),
|
||||
) {
|
||||
let (prompt_vi_insert_string, prompt_vi_visual_string) = prompt_vi;
|
||||
let (prompt_indicator_menu, prompt_history_indicator_menu) = prompt_menus;
|
||||
|
||||
self.left_prompt_string = left_prompt_string;
|
||||
self.right_prompt_string = right_prompt_string;
|
||||
@ -79,7 +82,9 @@ impl NushellPrompt {
|
||||
self.default_vi_insert_prompt_indicator = prompt_vi_insert_string;
|
||||
self.default_vi_visual_prompt_indicator = prompt_vi_visual_string;
|
||||
self.default_multiline_indicator = prompt_multiline_indicator_string;
|
||||
|
||||
self.default_menu_prompt_indicator = prompt_indicator_menu;
|
||||
self.default_history_prompt_indicator = prompt_history_indicator_menu;
|
||||
}
|
||||
|
||||
fn default_wrapped_custom_string(&self, str: String) -> String {
|
||||
@ -117,6 +122,7 @@ impl Prompt for NushellPrompt {
|
||||
},
|
||||
PromptEditMode::Custom(str) => self.default_wrapped_custom_string(str).into(),
|
||||
PromptEditMode::Menu => self.default_menu_prompt_indicator.as_str().into(),
|
||||
PromptEditMode::HistoryMenu => self.default_history_prompt_indicator.as_str().into(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -65,6 +65,7 @@ pub struct Config {
|
||||
pub log_level: String,
|
||||
pub menu_config: HashMap<String, Value>,
|
||||
pub keybindings: Vec<ParsedKeybinding>,
|
||||
pub history_config: HashMap<String, Value>,
|
||||
}
|
||||
|
||||
impl Default for Config {
|
||||
@ -86,6 +87,7 @@ impl Default for Config {
|
||||
log_level: String::new(),
|
||||
menu_config: HashMap::new(),
|
||||
keybindings: Vec::new(),
|
||||
history_config: HashMap::new(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -243,6 +245,13 @@ impl Value {
|
||||
eprintln!("$config.keybindings is not a valid keybindings list")
|
||||
}
|
||||
}
|
||||
"history_config" => {
|
||||
if let Ok(map) = create_map(value, &config) {
|
||||
config.history_config = map;
|
||||
} else {
|
||||
eprintln!("$config.history_config is not a record")
|
||||
}
|
||||
}
|
||||
x => {
|
||||
eprintln!("$config.{} is an unknown config setting", x)
|
||||
}
|
||||
|
Reference in New Issue
Block a user