diff --git a/docs/en/src/mode.md b/docs/en/src/mode.md index a966f7e2..4f726161 100644 --- a/docs/en/src/mode.md +++ b/docs/en/src/mode.md @@ -7,6 +7,7 @@ A mode contains the following information: - [extra_help][7] - [key_bindings][9] - [layout][10] +- [prompt][13] ### name @@ -40,6 +41,12 @@ Type: nullable [Layout][11] If specified, this layout will be used to render the UI. +### prompt + +Type: nullable string + +If set, this prompt will be displayed in the input buffer when in this mode. + ## Also See: - [xplr.config.modes][12] @@ -56,3 +63,4 @@ If specified, this layout will be used to render the UI. [10]: #layout [11]: layout.md#layout [12]: modes.md +[13]: #prompt diff --git a/src/app.rs b/src/app.rs index 8e25a1b5..ec906a46 100644 --- a/src/app.rs +++ b/src/app.rs @@ -862,11 +862,11 @@ impl App { self.input = InputBuffer { buffer: Default::default(), prompt: self - .config - .general + .mode .prompt - .format - .to_owned() + .as_ref() + .or(self.config.general.prompt.format.as_ref()) + .cloned() .unwrap_or_default(), }; Ok(self) diff --git a/src/config.rs b/src/config.rs index 92a71fbb..f77e4009 100644 --- a/src/config.rs +++ b/src/config.rs @@ -373,6 +373,9 @@ pub struct Mode { #[serde(default)] pub layout: Option, + + #[serde(default)] + pub prompt: Option, } impl Mode { diff --git a/src/init.lua b/src/init.lua index 949449f9..53c53923 100644 --- a/src/init.lua +++ b/src/init.lua @@ -1065,7 +1065,6 @@ xplr.config.modes.builtin.default = { messages = { "PopMode", { SwitchModeBuiltin = "search" }, - { SetInputPrompt = "/" }, { SetInputBuffer = "(?i)" }, "ExplorePwdAsync", }, @@ -1213,7 +1212,6 @@ xplr.config.modes.builtin.default = { messages = { "PopMode", { SwitchModeBuiltin = "number" }, - { SetInputPrompt = ":" }, "BufferInputFromKey", }, }, @@ -1463,7 +1461,6 @@ xplr.config.modes.builtin.create = { messages = { "PopMode", { SwitchModeBuiltin = "create_directory" }, - { SetInputPrompt = "ð ❯ " }, { SetInputBuffer = "" }, }, }, @@ -1472,7 +1469,6 @@ xplr.config.modes.builtin.create = { messages = { "PopMode", { SwitchModeBuiltin = "create_file" }, - { SetInputPrompt = "ƒ ❯ " }, { SetInputBuffer = "" }, }, }, @@ -1485,6 +1481,7 @@ xplr.config.modes.builtin.create = { -- Type: [Mode](https://xplr.dev/en/mode) xplr.config.modes.builtin.create_directory = { name = "create directory", + prompt = "ð ❯ ", key_bindings = { on_key = { tab = { @@ -1526,6 +1523,7 @@ xplr.config.modes.builtin.create_directory = { -- Type: [Mode](https://xplr.dev/en/mode) xplr.config.modes.builtin.create_file = { name = "create file", + prompt = "ƒ ❯ ", key_bindings = { on_key = { tab = { @@ -1568,6 +1566,7 @@ xplr.config.modes.builtin.create_file = { -- Type: [Mode](https://xplr.dev/en/mode) xplr.config.modes.builtin.number = { name = "number", + prompt = ":", key_bindings = { on_key = { down = { @@ -1879,7 +1878,6 @@ xplr.config.modes.builtin.action = { messages = { "PopMode", { SwitchModeBuiltin = "number" }, - { SetInputPrompt = ":" }, "BufferInputFromKey", }, }, @@ -1932,6 +1930,7 @@ xplr.config.modes.builtin.quit = { -- Type: [Mode](https://xplr.dev/en/mode) xplr.config.modes.builtin.search = { name = "search", + prompt = "/", key_bindings = { on_key = { down = { @@ -2009,9 +2008,6 @@ xplr.config.modes.builtin.filter = { help = "relative path does match regex", messages = { { SwitchModeBuiltin = "relative_path_does_match_regex" }, - { - SetInputPrompt = xplr.config.general.sort_and_filter_ui.filter_identifiers.RelativePathDoesMatchRegex.format, - }, { SetInputBuffer = "" }, { AddNodeFilterFromInput = "RelativePathDoesMatchRegex" }, "ExplorePwdAsync", @@ -2021,9 +2017,6 @@ xplr.config.modes.builtin.filter = { help = "relative path does not match regex", messages = { { SwitchModeBuiltin = "relative_path_does_not_match_regex" }, - { - SetInputPrompt = xplr.config.general.sort_and_filter_ui.filter_identifiers.RelativePathDoesNotMatchRegex.format, - }, { SetInputBuffer = "" }, { AddNodeFilterFromInput = "RelativePathDoesNotMatchRegex" }, "ExplorePwdAsync", @@ -2059,6 +2052,7 @@ xplr.config.modes.builtin.filter = { -- Type: [Mode](https://xplr.dev/en/mode) xplr.config.modes.builtin.relative_path_does_match_regex = { name = "relative path does match regex", + prompt = xplr.config.general.sort_and_filter_ui.filter_identifiers.RelativePathDoesMatchRegex.format, key_bindings = { on_key = { enter = { @@ -2091,6 +2085,7 @@ xplr.config.modes.builtin.relative_path_does_match_regex = { -- Type: [Mode](https://xplr.dev/en/mode) xplr.config.modes.builtin.relative_path_does_not_match_regex = { name = "relative path does not match regex", + prompt = xplr.config.general.sort_and_filter_ui.filter_identifiers.RelativePathDoesNotMatchRegex.format, key_bindings = { on_key = { enter = {