From 1d9d5f5145de8030fcfdbcb3616714c9abcc7c7c Mon Sep 17 00:00:00 2001 From: Arijit Basu Date: Mon, 9 Jan 2023 16:28:12 +0530 Subject: [PATCH] Minor changes --- docs/en/src/awesome-plugins.md | 2 +- docs/en/src/configuration.md | 1 - src/app.rs | 32 +- src/config.rs | 6 - src/init.lua | 2856 ++++++++++++++++---------------- 5 files changed, 1437 insertions(+), 1460 deletions(-) diff --git a/docs/en/src/awesome-plugins.md b/docs/en/src/awesome-plugins.md index e922e3f..fffb908 100644 --- a/docs/en/src/awesome-plugins.md +++ b/docs/en/src/awesome-plugins.md @@ -19,7 +19,7 @@ of the following plugins work for you, it's very easy to - [**dtomvan/term.xplr**][39] Terminal integration for xplr - [**sayanarijit/wl-clipboard.xplr**][52] Copy and paste with system clipboard using wl-clipboard - [**dtomvan/xpm.xplr**][47] The XPLR Plugin Manager -- [**emsquid/style.xplr**][57] Helper plugin that allows you to integrate xplr's [Style][58] anywhere +- [**emsquid/style.xplr**][57] Helper plugin that allows you to integrate xplr's [Style][58] anywhere ### Integration diff --git a/docs/en/src/configuration.md b/docs/en/src/configuration.md index a73954d..65c8b17 100644 --- a/docs/en/src/configuration.md +++ b/docs/en/src/configuration.md @@ -131,5 +131,4 @@ return { { LogSuccess = "Switched layout" }, { CallLuaSilently = "custom.some_plugin_with_hooks.on_layout_switch" }, } -} ``` diff --git a/src/app.rs b/src/app.rs index de1927a..1ee5537 100644 --- a/src/app.rs +++ b/src/app.rs @@ -1106,20 +1106,10 @@ impl App { } fn switch_mode_keeping_input_buffer(mut self, mode: &str) -> Result { - if let Some(mode) = self.config.modes.get(mode).cloned() { - self = self.push_mode(); - self.mode = mode.sanitized( - self.config.general.read_only, - self.config.general.global_key_bindings.to_owned(), - ); - - // Hooks - if !self.hooks.on_mode_switch.is_empty() { - let msgs = self.hooks.on_mode_switch.clone(); - self = self.handle_batch_external_msgs(msgs)? - } - - Ok(self) + if self.config.modes.builtin.contains_key(mode) { + self.switch_mode_builtin(mode) + } else if self.config.modes.custom.contains_key(mode) { + self.switch_mode_custom(mode) } else { self.log_error(format!("Mode not found: {}", mode)) } @@ -1176,16 +1166,10 @@ impl App { } fn switch_layout(mut self, layout: &str) -> Result { - if let Some(l) = self.config.layouts.get(layout) { - self.layout = l.to_owned(); - - // Hooks - if !self.hooks.on_layout_switch.is_empty() { - let msgs = self.hooks.on_layout_switch.clone(); - self = self.handle_batch_external_msgs(msgs)? - } - - Ok(self) + if self.config.layouts.builtin.contains_key(layout) { + self.switch_layout_builtin(layout) + } else if self.config.layouts.custom.contains_key(layout) { + self.switch_layout_custom(layout) } else { self.log_error(format!("Layout not found: {}", layout)) } diff --git a/src/config.rs b/src/config.rs index 5749e2b..7b37c0b 100644 --- a/src/config.rs +++ b/src/config.rs @@ -537,12 +537,6 @@ pub struct ModesConfig { pub custom: HashMap, } -impl ModesConfig { - pub fn get(&self, name: &str) -> Option<&Mode> { - self.builtin.get(name).or_else(|| self.custom.get(name)) - } -} - #[derive(Debug, Clone, Default, Serialize, Deserialize, PartialEq, Eq)] #[serde(deny_unknown_fields)] pub struct PanelUiConfig { diff --git a/src/init.lua b/src/init.lua index 33123b5..336ae69 100644 --- a/src/init.lua +++ b/src/init.lua @@ -157,11 +157,11 @@ xplr.config.general.logs.error.style = { fg = "Red" } -- * format: nullable string -- * style: [Style](https://xplr.dev/en/style) xplr.config.general.table.header.cols = { - { format = " index", style = {} }, - { format = "╭─── path", style = {} }, - { format = "permissions", style = {} }, - { format = "size", style = {} }, - { format = "modified", style = {} }, + { format = " index", style = {} }, + { format = "╭─── path", style = {} }, + { format = "permissions", style = {} }, + { format = "size", style = {} }, + { format = "modified", style = {} }, } -- Style of the table header. @@ -181,26 +181,26 @@ xplr.config.general.table.header.height = 1 -- * format: nullable string -- * style: [Style](https://xplr.dev/en/style) xplr.config.general.table.row.cols = { - { - format = "builtin.fmt_general_table_row_cols_0", - style = {}, - }, - { - format = "builtin.fmt_general_table_row_cols_1", - style = {}, - }, - { - format = "builtin.fmt_general_table_row_cols_2", - style = {}, - }, - { - format = "builtin.fmt_general_table_row_cols_3", - style = {}, - }, - { - format = "builtin.fmt_general_table_row_cols_4", - style = {}, - }, + { + format = "builtin.fmt_general_table_row_cols_0", + style = {}, + }, + { + format = "builtin.fmt_general_table_row_cols_1", + style = {}, + }, + { + format = "builtin.fmt_general_table_row_cols_2", + style = {}, + }, + { + format = "builtin.fmt_general_table_row_cols_3", + style = {}, + }, + { + format = "builtin.fmt_general_table_row_cols_4", + style = {}, + }, } -- Default style of the table. @@ -225,9 +225,9 @@ xplr.config.general.table.style = {} -- * format: nullable string -- * style: [Style](https://xplr.dev/en/style) xplr.config.general.table.tree = { - { format = "├", style = {} }, - { format = "├", style = {} }, - { format = "╰", style = {} }, + { format = "├", style = {} }, + { format = "├", style = {} }, + { format = "╰", style = {} }, } -- Spacing between the columns in the table. @@ -239,11 +239,11 @@ xplr.config.general.table.col_spacing = 1 -- -- Type: nullable list of [Constraint](https://xplr.dev/en/layouts#constraint) xplr.config.general.table.col_widths = { - { Percentage = 10 }, - { Percentage = 50 }, - { Percentage = 10 }, - { Percentage = 10 }, - { Percentage = 20 }, + { Percentage = 10 }, + { Percentage = 50 }, + { Percentage = 10 }, + { Percentage = 10 }, + { Percentage = 20 }, } -- The content that is placed before the item name for each row by default. @@ -289,8 +289,8 @@ xplr.config.general.selection_ui.suffix = "}" -- -- Type: [Style](https://xplr.dev/en/style) xplr.config.general.selection_ui.style = { - fg = "LightGreen", - add_modifiers = { "Bold" }, + fg = "LightGreen", + add_modifiers = { "Bold" }, } -- The string placed before item name for a selected row that gets the focus. @@ -307,8 +307,8 @@ xplr.config.general.focus_selection_ui.suffix = "]" -- -- Type: [Style](https://xplr.dev/en/style) xplr.config.general.focus_selection_ui.style = { - fg = "LightGreen", - add_modifiers = { "Bold" }, + fg = "LightGreen", + add_modifiers = { "Bold" }, } -- The shape of the separator for the Sort & filter panel. @@ -320,7 +320,7 @@ xplr.config.general.sort_and_filter_ui.separator.format = " › " -- -- Type: [Style](https://xplr.dev/en/style) xplr.config.general.sort_and_filter_ui.separator.style = { - add_modifiers = { "Dim" }, + add_modifiers = { "Dim" }, } -- The content of the default identifier in Sort & filter panel. @@ -362,38 +362,38 @@ xplr.config.general.sort_and_filter_ui.sort_direction_identifiers.reverse.style -- * format: nullable string -- * style: [Style](https://xplr.dev/en/style) xplr.config.general.sort_and_filter_ui.sorter_identifiers = { - ByExtension = { format = "ext", style = {} }, - ByICanonicalAbsolutePath = { format = "[ci]abs", style = {} }, - ByIRelativePath = { format = "[i]rel", style = {} }, - ByISymlinkAbsolutePath = { format = "[si]abs", style = {} }, - ByIsBroken = { format = "⨯", style = {} }, - ByIsDir = { format = "dir", style = {} }, - ByIsFile = { format = "file", style = {} }, - ByIsReadonly = { format = "ro", style = {} }, - ByIsSymlink = { format = "sym", style = {} }, - ByMimeEssence = { format = "mime", style = {} }, - ByRelativePath = { format = "rel", style = {} }, - BySize = { format = "size", style = {} }, - ByCreated = { format = "created", style = {} }, - ByLastModified = { format = "modified", style = {} }, - ByCanonicalAbsolutePath = { format = "[c]abs", style = {} }, - ByCanonicalExtension = { format = "[c]ext", style = {} }, - ByCanonicalIsDir = { format = "[c]dir", style = {} }, - ByCanonicalIsFile = { format = "[c]file", style = {} }, - ByCanonicalIsReadonly = { format = "[c]ro", style = {} }, - ByCanonicalMimeEssence = { format = "[c]mime", style = {} }, - ByCanonicalSize = { format = "[c]size", style = {} }, - ByCanonicalCreated = { format = "[c]created", style = {} }, - ByCanonicalLastModified = { format = "[c]modified", style = {} }, - BySymlinkAbsolutePath = { format = "[s]abs", style = {} }, - BySymlinkExtension = { format = "[s]ext", style = {} }, - BySymlinkIsDir = { format = "[s]dir", style = {} }, - BySymlinkIsFile = { format = "[s]file", style = {} }, - BySymlinkIsReadonly = { format = "[s]ro", style = {} }, - BySymlinkMimeEssence = { format = "[s]mime", style = {} }, - BySymlinkSize = { format = "[s]size", style = {} }, - BySymlinkCreated = { format = "[s]created", style = {} }, - BySymlinkLastModified = { format = "[s]modified", style = {} }, + ByExtension = { format = "ext", style = {} }, + ByICanonicalAbsolutePath = { format = "[ci]abs", style = {} }, + ByIRelativePath = { format = "[i]rel", style = {} }, + ByISymlinkAbsolutePath = { format = "[si]abs", style = {} }, + ByIsBroken = { format = "⨯", style = {} }, + ByIsDir = { format = "dir", style = {} }, + ByIsFile = { format = "file", style = {} }, + ByIsReadonly = { format = "ro", style = {} }, + ByIsSymlink = { format = "sym", style = {} }, + ByMimeEssence = { format = "mime", style = {} }, + ByRelativePath = { format = "rel", style = {} }, + BySize = { format = "size", style = {} }, + ByCreated = { format = "created", style = {} }, + ByLastModified = { format = "modified", style = {} }, + ByCanonicalAbsolutePath = { format = "[c]abs", style = {} }, + ByCanonicalExtension = { format = "[c]ext", style = {} }, + ByCanonicalIsDir = { format = "[c]dir", style = {} }, + ByCanonicalIsFile = { format = "[c]file", style = {} }, + ByCanonicalIsReadonly = { format = "[c]ro", style = {} }, + ByCanonicalMimeEssence = { format = "[c]mime", style = {} }, + ByCanonicalSize = { format = "[c]size", style = {} }, + ByCanonicalCreated = { format = "[c]created", style = {} }, + ByCanonicalLastModified = { format = "[c]modified", style = {} }, + BySymlinkAbsolutePath = { format = "[s]abs", style = {} }, + BySymlinkExtension = { format = "[s]ext", style = {} }, + BySymlinkIsDir = { format = "[s]dir", style = {} }, + BySymlinkIsFile = { format = "[s]file", style = {} }, + BySymlinkIsReadonly = { format = "[s]ro", style = {} }, + BySymlinkMimeEssence = { format = "[s]mime", style = {} }, + BySymlinkSize = { format = "[s]size", style = {} }, + BySymlinkCreated = { format = "[s]created", style = {} }, + BySymlinkLastModified = { format = "[s]modified", style = {} }, } -- The identifiers used to denote applied filters in the Sort & filter panel. @@ -405,57 +405,57 @@ xplr.config.general.sort_and_filter_ui.sorter_identifiers = { -- * format: nullable string -- * style: [Style](https://xplr.dev/en/style) xplr.config.general.sort_and_filter_ui.filter_identifiers = { - RelativePathDoesContain = { format = "rel=~", style = {} }, - RelativePathDoesEndWith = { format = "rel=$", style = {} }, - RelativePathDoesNotContain = { format = "rel!~", style = {} }, - RelativePathDoesNotEndWith = { format = "rel!$", style = {} }, - RelativePathDoesNotStartWith = { format = "rel!^", style = {} }, - RelativePathDoesStartWith = { format = "rel=^", style = {} }, - RelativePathIs = { format = "rel==", style = {} }, - RelativePathIsNot = { format = "rel!=", style = {} }, - RelativePathDoesMatchRegex = { format = "rel=/", style = {} }, - RelativePathDoesNotMatchRegex = { format = "rel!/", style = {} }, - - IRelativePathDoesContain = { format = "[i]rel=~", style = {} }, - IRelativePathDoesEndWith = { format = "[i]rel=$", style = {} }, - IRelativePathDoesNotContain = { format = "[i]rel!~", style = {} }, - IRelativePathDoesNotEndWith = { format = "[i]rel!$", style = {} }, - IRelativePathDoesNotStartWith = { format = "[i]rel!^", style = {} }, - IRelativePathDoesStartWith = { format = "[i]rel=^", style = {} }, - IRelativePathIs = { format = "[i]rel==", style = {} }, - IRelativePathIsNot = { format = "[i]rel!=", style = {} }, - IRelativePathDoesMatchRegex = { format = "[i]rel=/", style = {} }, - IRelativePathDoesNotMatchRegex = { format = "[i]rel!/", style = {} }, - - AbsolutePathDoesContain = { format = "abs=~", style = {} }, - AbsolutePathDoesEndWith = { format = "abs=$", style = {} }, - AbsolutePathDoesNotContain = { format = "abs!~", style = {} }, - AbsolutePathDoesNotEndWith = { format = "abs!$", style = {} }, - AbsolutePathDoesNotStartWith = { format = "abs!^", style = {} }, - AbsolutePathDoesStartWith = { format = "abs=^", style = {} }, - AbsolutePathIs = { format = "abs==", style = {} }, - AbsolutePathIsNot = { format = "abs!=", style = {} }, - AbsolutePathDoesMatchRegex = { format = "abs=/", style = {} }, - AbsolutePathDoesNotMatchRegex = { format = "abs!/", style = {} }, - - IAbsolutePathDoesContain = { format = "[i]abs=~", style = {} }, - IAbsolutePathDoesEndWith = { format = "[i]abs=$", style = {} }, - IAbsolutePathDoesNotContain = { format = "[i]abs!~", style = {} }, - IAbsolutePathDoesNotEndWith = { format = "[i]abs!$", style = {} }, - IAbsolutePathDoesNotStartWith = { format = "[i]abs!^", style = {} }, - IAbsolutePathDoesStartWith = { format = "[i]abs=^", style = {} }, - IAbsolutePathIs = { format = "[i]abs==", style = {} }, - IAbsolutePathIsNot = { format = "[i]abs!=", style = {} }, - IAbsolutePathDoesMatchRegex = { format = "[i]abs=/", style = {} }, - IAbsolutePathDoesNotMatchRegex = { format = "[i]abs!/", style = {} }, + RelativePathDoesContain = { format = "rel=~", style = {} }, + RelativePathDoesEndWith = { format = "rel=$", style = {} }, + RelativePathDoesNotContain = { format = "rel!~", style = {} }, + RelativePathDoesNotEndWith = { format = "rel!$", style = {} }, + RelativePathDoesNotStartWith = { format = "rel!^", style = {} }, + RelativePathDoesStartWith = { format = "rel=^", style = {} }, + RelativePathIs = { format = "rel==", style = {} }, + RelativePathIsNot = { format = "rel!=", style = {} }, + RelativePathDoesMatchRegex = { format = "rel=/", style = {} }, + RelativePathDoesNotMatchRegex = { format = "rel!/", style = {} }, + + IRelativePathDoesContain = { format = "[i]rel=~", style = {} }, + IRelativePathDoesEndWith = { format = "[i]rel=$", style = {} }, + IRelativePathDoesNotContain = { format = "[i]rel!~", style = {} }, + IRelativePathDoesNotEndWith = { format = "[i]rel!$", style = {} }, + IRelativePathDoesNotStartWith = { format = "[i]rel!^", style = {} }, + IRelativePathDoesStartWith = { format = "[i]rel=^", style = {} }, + IRelativePathIs = { format = "[i]rel==", style = {} }, + IRelativePathIsNot = { format = "[i]rel!=", style = {} }, + IRelativePathDoesMatchRegex = { format = "[i]rel=/", style = {} }, + IRelativePathDoesNotMatchRegex = { format = "[i]rel!/", style = {} }, + + AbsolutePathDoesContain = { format = "abs=~", style = {} }, + AbsolutePathDoesEndWith = { format = "abs=$", style = {} }, + AbsolutePathDoesNotContain = { format = "abs!~", style = {} }, + AbsolutePathDoesNotEndWith = { format = "abs!$", style = {} }, + AbsolutePathDoesNotStartWith = { format = "abs!^", style = {} }, + AbsolutePathDoesStartWith = { format = "abs=^", style = {} }, + AbsolutePathIs = { format = "abs==", style = {} }, + AbsolutePathIsNot = { format = "abs!=", style = {} }, + AbsolutePathDoesMatchRegex = { format = "abs=/", style = {} }, + AbsolutePathDoesNotMatchRegex = { format = "abs!/", style = {} }, + + IAbsolutePathDoesContain = { format = "[i]abs=~", style = {} }, + IAbsolutePathDoesEndWith = { format = "[i]abs=$", style = {} }, + IAbsolutePathDoesNotContain = { format = "[i]abs!~", style = {} }, + IAbsolutePathDoesNotEndWith = { format = "[i]abs!$", style = {} }, + IAbsolutePathDoesNotStartWith = { format = "[i]abs!^", style = {} }, + IAbsolutePathDoesStartWith = { format = "[i]abs=^", style = {} }, + IAbsolutePathIs = { format = "[i]abs==", style = {} }, + IAbsolutePathIsNot = { format = "[i]abs!=", style = {} }, + IAbsolutePathDoesMatchRegex = { format = "[i]abs=/", style = {} }, + IAbsolutePathDoesNotMatchRegex = { format = "[i]abs!/", style = {} }, } -- The identifiers used to denote applied search input. -- -- Type: { format = nullable string, style = [Style](https://xplr.dev/en/style) } xplr.config.general.sort_and_filter_ui.search_identifier = { - format = "search:", - style = {}, + format = "search:", + style = {}, } -- The content for panel title by default. @@ -467,8 +467,8 @@ xplr.config.general.panel_ui.default.title.format = nil -- -- Type: [Style](https://xplr.dev/en/style) xplr.config.general.panel_ui.default.title.style = { - fg = "Reset", - add_modifiers = { "Bold" }, + fg = "Reset", + add_modifiers = { "Bold" }, } -- Style of the panels by default. @@ -480,10 +480,10 @@ xplr.config.general.panel_ui.default.style = {} -- -- Type: nullable list of [Border](https://xplr.dev/en/borders#border) xplr.config.general.panel_ui.default.borders = { - "Top", - "Right", - "Bottom", - "Left", + "Top", + "Right", + "Bottom", + "Left", } -- Type of the borders by default. @@ -648,8 +648,8 @@ xplr.config.general.panel_ui.sort_and_filter.border_style = {} -- -- Type: nullable list of [Node Sorter](https://xplr.dev/en/sorting#node-sorter-applicable) xplr.config.general.initial_sorting = { - { sorter = "ByCanonicalIsDir", reverse = true }, - { sorter = "ByIRelativePath", reverse = false }, + { sorter = "ByCanonicalIsDir", reverse = true }, + { sorter = "ByIRelativePath", reverse = false }, } -- The name of one of the modes to use when xplr loads. @@ -673,18 +673,18 @@ xplr.config.general.start_fifo = nil -- -- Type: [Key Bindings](https://xplr.dev/en/configure-key-bindings#key-bindings) xplr.config.general.global_key_bindings = { - on_key = { - ["esc"] = { - messages = { - "PopMode", - }, - }, - ["ctrl-c"] = { - messages = { - "Terminate", - }, - }, + on_key = { + ["esc"] = { + messages = { + "PopMode", + }, + }, + ["ctrl-c"] = { + messages = { + "Terminate", + }, }, + }, } -- ### Node Types ------------------------------------------------------------- @@ -702,8 +702,8 @@ xplr.config.general.global_key_bindings = { -- -- Type: [Style](https://xplr.dev/en/style) xplr.config.node_types.directory.style = { - fg = "Cyan", - add_modifiers = { "Bold" }, + fg = "Cyan", + add_modifiers = { "Bold" }, } -- Metadata for the directory nodes. @@ -741,8 +741,8 @@ xplr.config.node_types.file.meta.icon = "ƒ" -- -- Type: [Style](https://xplr.dev/en/style) xplr.config.node_types.symlink.style = { - fg = "Magenta", - add_modifiers = { "Italic" }, + fg = "Magenta", + add_modifiers = { "Italic" }, } -- Metadata for the symlink nodes. @@ -857,132 +857,132 @@ xplr.config.node_types.special = {} -- -- Type: [Layout](https://xplr.dev/en/layout) xplr.config.layouts.builtin.default = { - Horizontal = { - config = { + Horizontal = { + config = { + constraints = { + { Percentage = 70 }, + { Percentage = 30 }, + }, + }, + splits = { + { + Vertical = { + config = { constraints = { - { Percentage = 70 }, - { Percentage = 30 }, + { Length = 3 }, + { Min = 1 }, + { Length = 3 }, }, + }, + splits = { + "SortAndFilter", + "Table", + "InputAndLogs", + }, }, - splits = { - { - Vertical = { - config = { - constraints = { - { Length = 3 }, - { Min = 1 }, - { Length = 3 }, - }, - }, - splits = { - "SortAndFilter", - "Table", - "InputAndLogs", - }, - }, - }, - { - Vertical = { - config = { - constraints = { - { Percentage = 30 }, - { Percentage = 70 }, - }, - }, - splits = { - "Selection", - "HelpMenu", - }, - }, + }, + { + Vertical = { + config = { + constraints = { + { Percentage = 30 }, + { Percentage = 70 }, }, + }, + splits = { + "Selection", + "HelpMenu", + }, }, + }, }, + }, } -- The layout without help menu -- -- Type: [Layout](https://xplr.dev/en/layout) xplr.config.layouts.builtin.no_help = { - Horizontal = { - config = { + Horizontal = { + config = { + constraints = { + { Percentage = 70 }, + { Percentage = 30 }, + }, + }, + splits = { + { + Vertical = { + config = { constraints = { - { Percentage = 70 }, - { Percentage = 30 }, - }, - }, - splits = { - { - Vertical = { - config = { - constraints = { - { Length = 3 }, - { Min = 1 }, - { Length = 3 }, - }, - }, - splits = { - "SortAndFilter", - "Table", - "InputAndLogs", - }, - }, + { Length = 3 }, + { Min = 1 }, + { Length = 3 }, }, - "Selection", + }, + splits = { + "SortAndFilter", + "Table", + "InputAndLogs", + }, }, + }, + "Selection", }, + }, } -- The layout without selection panel -- -- Type: [Layout](https://xplr.dev/en/layout) xplr.config.layouts.builtin.no_selection = { - Horizontal = { - config = { + Horizontal = { + config = { + constraints = { + { Percentage = 70 }, + { Percentage = 30 }, + }, + }, + splits = { + { + Vertical = { + config = { constraints = { - { Percentage = 70 }, - { Percentage = 30 }, - }, - }, - splits = { - { - Vertical = { - config = { - constraints = { - { Length = 3 }, - { Min = 1 }, - { Length = 3 }, - }, - }, - splits = { - "SortAndFilter", - "Table", - "InputAndLogs", - }, - }, + { Length = 3 }, + { Min = 1 }, + { Length = 3 }, }, - "HelpMenu", + }, + splits = { + "SortAndFilter", + "Table", + "InputAndLogs", + }, }, + }, + "HelpMenu", }, + }, } -- The layout without help menu and selection panel -- -- Type: [Layout](https://xplr.dev/en/layout) xplr.config.layouts.builtin.no_help_no_selection = { - Vertical = { - config = { - constraints = { - { Length = 3 }, - { Min = 1 }, - { Length = 3 }, - }, - }, - splits = { - "SortAndFilter", - "Table", - "InputAndLogs", - }, + Vertical = { + config = { + constraints = { + { Length = 3 }, + { Min = 1 }, + { Length = 3 }, + }, + }, + splits = { + "SortAndFilter", + "Table", + "InputAndLogs", }, + }, } -- This is where you can define custom layouts @@ -1017,272 +1017,272 @@ xplr.config.layouts.custom = {} -- -- Type: [Mode](https://xplr.dev/en/mode) xplr.config.modes.builtin.default = { - name = "default", - key_bindings = { - on_key = { - ["#"] = { - messages = { - "PrintAppStateAndQuit", - }, - }, - ["."] = { - help = "show hidden", - messages = { - { - ToggleNodeFilter = { filter = "RelativePathDoesNotStartWith", input = "." }, - }, - "ExplorePwdAsync", - }, - }, - [":"] = { - help = "action", - messages = { - "PopMode", - { SwitchModeBuiltin = "action" }, - }, - }, - ["?"] = { - help = "global help menu", - messages = { - { - BashExec = [===[ + name = "default", + key_bindings = { + on_key = { + ["#"] = { + messages = { + "PrintAppStateAndQuit", + }, + }, + ["."] = { + help = "show hidden", + messages = { + { + ToggleNodeFilter = { filter = "RelativePathDoesNotStartWith", input = "." }, + }, + "ExplorePwdAsync", + }, + }, + [":"] = { + help = "action", + messages = { + "PopMode", + { SwitchModeBuiltin = "action" }, + }, + }, + ["?"] = { + help = "global help menu", + messages = { + { + BashExec = [===[ [ -z "$PAGER" ] && PAGER="less -+F" cat -- "${XPLR_PIPE_GLOBAL_HELP_MENU_OUT}" | ${PAGER:?} - ]===] , - }, - }, - }, - ["G"] = { - help = "go to bottom", - messages = { - "PopMode", - "FocusLast", - }, - }, - ["ctrl-a"] = { - help = "select/unselect all", - messages = { - "ToggleSelectAll", - }, - }, - ["ctrl-f"] = { - help = "search", - messages = { - "PopMode", - { SwitchModeBuiltin = "search" }, - { SetInputBuffer = "" }, - }, - }, - ["ctrl-i"] = { - help = "next visited path", - messages = { - "NextVisitedPath", - }, - }, - ["ctrl-o"] = { - help = "last visited path", - messages = { - "LastVisitedPath", - }, - }, - ["ctrl-r"] = { - help = "refresh screen", - messages = { - "ClearScreen", - }, - }, - ["ctrl-u"] = { - help = "clear selection", - messages = { - "ClearSelection", - }, - }, - ["ctrl-w"] = { - help = "switch layout", - messages = { - { SwitchModeBuiltin = "switch_layout" }, - }, - }, - ["d"] = { - help = "delete", - messages = { - "PopMode", - { SwitchModeBuiltin = "delete" }, - }, - }, - ["down"] = { - help = "down", - messages = { - "FocusNext", - }, - }, - ["enter"] = { - help = "quit with result", - messages = { - "PrintResultAndQuit", - }, - }, - ["f"] = { - help = "filter", - messages = { - "PopMode", - { SwitchModeBuiltin = "filter" }, - }, - }, - ["g"] = { - help = "go to", - messages = { - "PopMode", - { SwitchModeBuiltin = "go_to" }, - }, - }, - ["left"] = { - help = "back", - messages = { - "Back", - }, - }, - ["q"] = { - help = "quit", - messages = { - "Quit", - }, - }, - ["r"] = { - help = "rename", - messages = { - "PopMode", - { SwitchModeBuiltin = "rename" }, - { - BashExecSilently0 = [===[ + ]===], + }, + }, + }, + ["G"] = { + help = "go to bottom", + messages = { + "PopMode", + "FocusLast", + }, + }, + ["ctrl-a"] = { + help = "select/unselect all", + messages = { + "ToggleSelectAll", + }, + }, + ["ctrl-f"] = { + help = "search", + messages = { + "PopMode", + { SwitchModeBuiltin = "search" }, + { SetInputBuffer = "" }, + }, + }, + ["ctrl-i"] = { + help = "next visited path", + messages = { + "NextVisitedPath", + }, + }, + ["ctrl-o"] = { + help = "last visited path", + messages = { + "LastVisitedPath", + }, + }, + ["ctrl-r"] = { + help = "refresh screen", + messages = { + "ClearScreen", + }, + }, + ["ctrl-u"] = { + help = "clear selection", + messages = { + "ClearSelection", + }, + }, + ["ctrl-w"] = { + help = "switch layout", + messages = { + { SwitchModeBuiltin = "switch_layout" }, + }, + }, + ["d"] = { + help = "delete", + messages = { + "PopMode", + { SwitchModeBuiltin = "delete" }, + }, + }, + ["down"] = { + help = "down", + messages = { + "FocusNext", + }, + }, + ["enter"] = { + help = "quit with result", + messages = { + "PrintResultAndQuit", + }, + }, + ["f"] = { + help = "filter", + messages = { + "PopMode", + { SwitchModeBuiltin = "filter" }, + }, + }, + ["g"] = { + help = "go to", + messages = { + "PopMode", + { SwitchModeBuiltin = "go_to" }, + }, + }, + ["left"] = { + help = "back", + messages = { + "Back", + }, + }, + ["q"] = { + help = "quit", + messages = { + "Quit", + }, + }, + ["r"] = { + help = "rename", + messages = { + "PopMode", + { SwitchModeBuiltin = "rename" }, + { + BashExecSilently0 = [===[ NAME=$(basename "${XPLR_FOCUS_PATH:?}") "$XPLR" -m 'SetInputBuffer: %q' "${NAME:?}" - ]===] , - }, - }, - }, - ["ctrl-d"] = { - help = "duplicate as", - messages = { - "PopMode", - { SwitchModeBuiltin = "duplicate_as" }, - { - BashExecSilently0 = [===[ + ]===], + }, + }, + }, + ["ctrl-d"] = { + help = "duplicate as", + messages = { + "PopMode", + { SwitchModeBuiltin = "duplicate_as" }, + { + BashExecSilently0 = [===[ NAME=$(basename "${XPLR_FOCUS_PATH:?}") "$XPLR" -m 'SetInputBuffer: %q' "${NAME:?}" - ]===] , - }, - }, - }, - ["right"] = { - help = "enter", - messages = { - "Enter", - }, - }, - ["s"] = { - help = "sort", - messages = { - "PopMode", - { SwitchModeBuiltin = "sort" }, - }, - }, - ["space"] = { - help = "toggle selection", - messages = { - "ToggleSelection", - "FocusNext", - }, - }, - ["up"] = { - help = "up", - messages = { - "FocusPrevious", - }, - }, - ["~"] = { - help = "go home", - messages = { - { - BashExecSilently0 = [===[ + ]===], + }, + }, + }, + ["right"] = { + help = "enter", + messages = { + "Enter", + }, + }, + ["s"] = { + help = "sort", + messages = { + "PopMode", + { SwitchModeBuiltin = "sort" }, + }, + }, + ["space"] = { + help = "toggle selection", + messages = { + "ToggleSelection", + "FocusNext", + }, + }, + ["up"] = { + help = "up", + messages = { + "FocusPrevious", + }, + }, + ["~"] = { + help = "go home", + messages = { + { + BashExecSilently0 = [===[ "$XPLR" -m 'ChangeDirectory: %q' "${HOME:?}" - ]===] , - }, - }, - }, - ["page-up"] = { - help = "scroll up", - messages = { - "ScrollUp", - }, - }, - ["page-down"] = { - help = "scroll down", - messages = { - "ScrollDown", - }, - }, - ["{"] = { - help = "scroll up half", - messages = { - "ScrollUpHalf", - }, - }, - ["}"] = { - help = "scroll down half", - messages = { - "ScrollDownHalf", - }, - }, + ]===], + }, }, - on_number = { - help = "input", - messages = { - "PopMode", - { SwitchModeBuiltin = "number" }, - "BufferInputFromKey", - }, + }, + ["page-up"] = { + help = "scroll up", + messages = { + "ScrollUp", + }, + }, + ["page-down"] = { + help = "scroll down", + messages = { + "ScrollDown", + }, + }, + ["{"] = { + help = "scroll up half", + messages = { + "ScrollUpHalf", }, + }, + ["}"] = { + help = "scroll down half", + messages = { + "ScrollDownHalf", + }, + }, + }, + on_number = { + help = "input", + messages = { + "PopMode", + { SwitchModeBuiltin = "number" }, + "BufferInputFromKey", + }, }, + }, } xplr.config.modes.builtin.default.key_bindings.on_key["tab"] = -xplr.config.modes.builtin.default.key_bindings.on_key["ctrl-i"] + xplr.config.modes.builtin.default.key_bindings.on_key["ctrl-i"] xplr.config.modes.builtin.default.key_bindings.on_key["v"] = -xplr.config.modes.builtin.default.key_bindings.on_key["space"] + xplr.config.modes.builtin.default.key_bindings.on_key["space"] xplr.config.modes.builtin.default.key_bindings.on_key["V"] = -xplr.config.modes.builtin.default.key_bindings.on_key["ctrl-a"] + xplr.config.modes.builtin.default.key_bindings.on_key["ctrl-a"] xplr.config.modes.builtin.default.key_bindings.on_key["/"] = -xplr.config.modes.builtin.default.key_bindings.on_key["ctrl-f"] + xplr.config.modes.builtin.default.key_bindings.on_key["ctrl-f"] xplr.config.modes.builtin.default.key_bindings.on_key["h"] = -xplr.config.modes.builtin.default.key_bindings.on_key["left"] + xplr.config.modes.builtin.default.key_bindings.on_key["left"] xplr.config.modes.builtin.default.key_bindings.on_key["j"] = -xplr.config.modes.builtin.default.key_bindings.on_key["down"] + xplr.config.modes.builtin.default.key_bindings.on_key["down"] xplr.config.modes.builtin.default.key_bindings.on_key["k"] = -xplr.config.modes.builtin.default.key_bindings.on_key["up"] + xplr.config.modes.builtin.default.key_bindings.on_key["up"] xplr.config.modes.builtin.default.key_bindings.on_key["l"] = -xplr.config.modes.builtin.default.key_bindings.on_key["right"] + xplr.config.modes.builtin.default.key_bindings.on_key["right"] -- The builtin debug error mode. -- -- Type: [Mode](https://xplr.dev/en/mode) xplr.config.modes.builtin.debug_error = { - name = "debug error", - layout = { - Vertical = { - config = { - constraints = { - { Min = 14 }, - { MinLessThanScreenHeight = 14 }, - }, - }, - splits = { - { - CustomContent = { - title = "debug error", - body = { - StaticParagraph = { - render = [[ + name = "debug error", + layout = { + Vertical = { + config = { + constraints = { + { Min = 14 }, + { MinLessThanScreenHeight = 14 }, + }, + }, + splits = { + { + CustomContent = { + title = "debug error", + body = { + StaticParagraph = { + render = [[ Some errors occurred during startup. If you think this is a bug, please report it at: @@ -1294,51 +1294,51 @@ xplr.config.modes.builtin.debug_error = { To disable this mode, set `xplr.config.general.disable_debug_error_mode` to `true` in your config file. - ]] , - }, - }, - }, - }, - "InputAndLogs", + ]], + }, }, + }, }, + "InputAndLogs", + }, }, - key_bindings = { - on_key = { - ["enter"] = { - help = "open logs in editor", - messages = { - { - BashExec = [===[ + }, + key_bindings = { + on_key = { + ["enter"] = { + help = "open logs in editor", + messages = { + { + BashExec = [===[ cat "${XPLR_PIPE_LOGS_OUT:?}" | ${EDITOR:-vi} - - ]===] , - }, - }, - }, - ["q"] = { - help = "quit", - messages = { - "Quit", - }, - }, + ]===], + }, }, - default = { - messages = {}, + }, + ["q"] = { + help = "quit", + messages = { + "Quit", }, + }, + }, + default = { + messages = {}, }, + }, } -- The builtin recover mode. -- -- Type: [Mode](https://xplr.dev/en/mode) xplr.config.modes.builtin.recover = { - name = "recover", - layout = { - CustomContent = { - title = " recover ", - body = { - StaticParagraph = { - render = [[ + name = "recover", + layout = { + CustomContent = { + title = " recover ", + body = { + StaticParagraph = { + render = [[ You pressed an invalid key and went into "recover" mode. This mode saves you from performing unwanted actions. @@ -1347,30 +1347,30 @@ xplr.config.modes.builtin.recover = { To disable this mode, set `xplr.config.general.enable_recover_mode` to `false` in your config file. - ]] , - }, - }, + ]], }, + }, }, - key_bindings = { - default = { - messages = {}, - }, + }, + key_bindings = { + default = { + messages = {}, }, + }, } -- The builtin go to path mode. -- -- Type: [Mode](https://xplr.dev/en/mode) xplr.config.modes.builtin.go_to_path = { - name = "go to path", - key_bindings = { - on_key = { - ["enter"] = { - help = "submit", - messages = { - { - BashExecSilently0 = [===[ + name = "go to path", + key_bindings = { + on_key = { + ["enter"] = { + help = "submit", + messages = { + { + BashExecSilently0 = [===[ PTH=${XPLR_INPUT_BUFFER} PTH_ESC=$(printf %q "$PTH") if [ -d "$PTH" ]; then @@ -1380,39 +1380,39 @@ xplr.config.modes.builtin.go_to_path = { else "$XPLR" -m 'LogError: %q' "could not find $PTH_ESC" fi - ]===] , - }, - "PopMode", - }, - }, - ["tab"] = { - help = "try complete", - messages = { - { CallLuaSilently = "builtin.try_complete_path" }, - }, - }, + ]===], + }, + "PopMode", }, - default = { - messages = { - "UpdateInputBufferFromKey", - }, + }, + ["tab"] = { + help = "try complete", + messages = { + { CallLuaSilently = "builtin.try_complete_path" }, }, + }, }, + default = { + messages = { + "UpdateInputBufferFromKey", + }, + }, + }, } -- The builtin selection ops mode. -- -- Type: [Mode](https://xplr.dev/en/mode) xplr.config.modes.builtin.selection_ops = { - name = "selection ops", - layout = "HelpMenu", - key_bindings = { - on_key = { - ["c"] = { - help = "copy here", - messages = { - { - BashExec0 = [===[ + name = "selection ops", + layout = "HelpMenu", + key_bindings = { + on_key = { + ["c"] = { + help = "copy here", + messages = { + { + BashExec0 = [===[ (while IFS= read -r -d '' PTH; do PTH_ESC=$(printf %q "$PTH") if cp -vr -- "${PTH:?}" ./; then @@ -1424,16 +1424,16 @@ xplr.config.modes.builtin.selection_ops = { "$XPLR" -m ExplorePwdAsync "$XPLR" -m ClearSelection read -p "[enter to continue]" - ]===] , - }, - "PopMode", - }, - }, - ["m"] = { - help = "move here", - messages = { - { - BashExec0 = [===[ + ]===], + }, + "PopMode", + }, + }, + ["m"] = { + help = "move here", + messages = { + { + BashExec0 = [===[ (while IFS= read -r -d '' PTH; do PTH_ESC=$(printf %q "$PTH") if mv -v -- "${PTH:?}" ./; then @@ -1444,69 +1444,69 @@ xplr.config.modes.builtin.selection_ops = { done < "${XPLR_PIPE_SELECTION_OUT:?}") "$XPLR" -m ExplorePwdAsync read -p "[enter to continue]" - ]===] , - }, - "PopMode", - }, - }, - ["u"] = { - help = "clear selection", - messages = { - "ClearSelection", - "PopMode", - }, - }, + ]===], + }, + "PopMode", }, + }, + ["u"] = { + help = "clear selection", + messages = { + "ClearSelection", + "PopMode", + }, + }, }, + }, } -- The builtin create mode. -- -- Type: [Mode](https://xplr.dev/en/mode) xplr.config.modes.builtin.create = { - name = "create", - layout = "HelpMenu", - key_bindings = { - on_key = { - ["d"] = { - help = "create directory", - messages = { - "PopMode", - { SwitchModeBuiltin = "create_directory" }, - { SetInputBuffer = "" }, - }, - }, - ["f"] = { - help = "create file", - messages = { - "PopMode", - { SwitchModeBuiltin = "create_file" }, - { SetInputBuffer = "" }, - }, - }, + name = "create", + layout = "HelpMenu", + key_bindings = { + on_key = { + ["d"] = { + help = "create directory", + messages = { + "PopMode", + { SwitchModeBuiltin = "create_directory" }, + { SetInputBuffer = "" }, + }, + }, + ["f"] = { + help = "create file", + messages = { + "PopMode", + { SwitchModeBuiltin = "create_file" }, + { SetInputBuffer = "" }, }, + }, }, + }, } -- The builtin create directory mode. -- -- Type: [Mode](https://xplr.dev/en/mode) xplr.config.modes.builtin.create_directory = { - name = "create directory", - prompt = "ð ❯ ", - key_bindings = { - on_key = { - ["tab"] = { - help = "try complete", - messages = { - { CallLuaSilently = "builtin.try_complete_path" }, - }, - }, - ["enter"] = { - help = "submit", - messages = { - { - BashExecSilently0 = [===[ + name = "create directory", + prompt = "ð ❯ ", + key_bindings = { + on_key = { + ["tab"] = { + help = "try complete", + messages = { + { CallLuaSilently = "builtin.try_complete_path" }, + }, + }, + ["enter"] = { + help = "submit", + messages = { + { + BashExecSilently0 = [===[ PTH="$XPLR_INPUT_BUFFER" PTH_ESC=$(printf %q "$PTH") if [ "$PTH" ]; then @@ -1518,38 +1518,38 @@ xplr.config.modes.builtin.create_directory = { else "$XPLR" -m PopMode fi - ]===] , - }, - }, - }, - }, - default = { - messages = { - "UpdateInputBufferFromKey", - }, + ]===], + }, }, + }, + }, + default = { + messages = { + "UpdateInputBufferFromKey", + }, }, + }, } -- The builtin create file mode. -- -- Type: [Mode](https://xplr.dev/en/mode) xplr.config.modes.builtin.create_file = { - name = "create file", - prompt = "ƒ ❯ ", - key_bindings = { - on_key = { - ["tab"] = { - help = "try complete", - messages = { - { CallLuaSilently = "builtin.try_complete_path" }, - }, - }, - ["enter"] = { - help = "submit", - messages = { - { - BashExecSilently0 = [===[ + name = "create file", + prompt = "ƒ ❯ ", + key_bindings = { + on_key = { + ["tab"] = { + help = "try complete", + messages = { + { CallLuaSilently = "builtin.try_complete_path" }, + }, + }, + ["enter"] = { + help = "submit", + messages = { + { + BashExecSilently0 = [===[ PTH="$XPLR_INPUT_BUFFER" PTH_ESC=$(printf %q "$PTH") if [ "$PTH" ]; then @@ -1562,114 +1562,114 @@ xplr.config.modes.builtin.create_file = { else "$XPLR" -m PopMode fi - ]===] , - }, - }, - }, - }, - default = { - messages = { - "UpdateInputBufferFromKey", - }, + ]===], + }, }, + }, }, + default = { + messages = { + "UpdateInputBufferFromKey", + }, + }, + }, } -- The builtin number mode. -- -- Type: [Mode](https://xplr.dev/en/mode) xplr.config.modes.builtin.number = { - name = "number", - prompt = ":", - key_bindings = { - on_key = { - ["down"] = { - help = "to down", - messages = { - "FocusNextByRelativeIndexFromInput", - "PopMode", - }, - }, - ["enter"] = { - help = "to index", - messages = { - "FocusByIndexFromInput", - "PopMode", - }, - }, - ["up"] = { - help = "to up", - messages = { - "FocusPreviousByRelativeIndexFromInput", - "PopMode", - }, - }, + name = "number", + prompt = ":", + key_bindings = { + on_key = { + ["down"] = { + help = "to down", + messages = { + "FocusNextByRelativeIndexFromInput", + "PopMode", }, - on_navigation = { - messages = { - "UpdateInputBufferFromKey", - }, + }, + ["enter"] = { + help = "to index", + messages = { + "FocusByIndexFromInput", + "PopMode", }, - on_number = { - help = "input", - messages = { - "UpdateInputBufferFromKey", - }, + }, + ["up"] = { + help = "to up", + messages = { + "FocusPreviousByRelativeIndexFromInput", + "PopMode", }, + }, + }, + on_navigation = { + messages = { + "UpdateInputBufferFromKey", + }, }, + on_number = { + help = "input", + messages = { + "UpdateInputBufferFromKey", + }, + }, + }, } xplr.config.modes.builtin.number.key_bindings.on_key["j"] = -xplr.config.modes.builtin.number.key_bindings.on_key["down"] + xplr.config.modes.builtin.number.key_bindings.on_key["down"] xplr.config.modes.builtin.number.key_bindings.on_key["k"] = -xplr.config.modes.builtin.number.key_bindings.on_key["up"] + xplr.config.modes.builtin.number.key_bindings.on_key["up"] -- The builtin go to mode. -- -- Type: [Mode](https://xplr.dev/en/mode) xplr.config.modes.builtin.go_to = { - name = "go to", - layout = "HelpMenu", - key_bindings = { - on_key = { - ["f"] = { - help = "follow symlink", - messages = { - "FollowSymlink", - "PopMode", - }, - }, - ["g"] = { - help = "top", - messages = { - "FocusFirst", - "PopMode", - }, - }, - ["p"] = { - help = "path", - messages = { - "PopMode", - { SwitchModeBuiltin = "go_to_path" }, - { SetInputBuffer = "" }, - }, - }, - ["i"] = { - help = "initial $PWD", - messages = { - "PopMode", - { - BashExecSilently0 = [===[ + name = "go to", + layout = "HelpMenu", + key_bindings = { + on_key = { + ["f"] = { + help = "follow symlink", + messages = { + "FollowSymlink", + "PopMode", + }, + }, + ["g"] = { + help = "top", + messages = { + "FocusFirst", + "PopMode", + }, + }, + ["p"] = { + help = "path", + messages = { + "PopMode", + { SwitchModeBuiltin = "go_to_path" }, + { SetInputBuffer = "" }, + }, + }, + ["i"] = { + help = "initial $PWD", + messages = { + "PopMode", + { + BashExecSilently0 = [===[ "$XPLR" -m 'ChangeDirectory: %q' "${XPLR_INITIAL_PWD:?}" - ]===] , - }, - }, - }, - ["x"] = { - help = "open in gui", - messages = { - { - BashExecSilently0 = [===[ + ]===], + }, + }, + }, + ["x"] = { + help = "open in gui", + messages = { + { + BashExecSilently0 = [===[ if [ -z "$OPENER" ]; then if command -v xdg-open; then OPENER=xdg-open @@ -1683,34 +1683,34 @@ xplr.config.modes.builtin.go_to = { (while IFS= read -r -d '' PTH; do $OPENER "${PTH:?}" > /dev/null 2>&1 done < "${XPLR_PIPE_RESULT_OUT:?}") - ]===] , - }, - "ClearScreen", - "PopMode", - }, - }, + ]===], + }, + "ClearScreen", + "PopMode", }, + }, }, + }, } -- The builtin rename mode. -- -- Type: [Mode](https://xplr.dev/en/mode) xplr.config.modes.builtin.rename = { - name = "rename", - key_bindings = { - on_key = { - ["tab"] = { - help = "try complete", - messages = { - { CallLuaSilently = "builtin.try_complete_path" }, - }, - }, - ["enter"] = { - help = "submit", - messages = { - { - BashExecSilently0 = [===[ + name = "rename", + key_bindings = { + on_key = { + ["tab"] = { + help = "try complete", + messages = { + { CallLuaSilently = "builtin.try_complete_path" }, + }, + }, + ["enter"] = { + help = "submit", + messages = { + { + BashExecSilently0 = [===[ SRC="${XPLR_FOCUS_PATH:?}" SRC_ESC=$(printf %q "$SRC") TARGET="${XPLR_INPUT_BUFFER:?}" @@ -1723,38 +1723,38 @@ xplr.config.modes.builtin.rename = { && "$XPLR" -m 'FocusPath: %q' "$TARGET" \ && "$XPLR" -m 'LogSuccess: %q' "$SRC_ESC renamed to $TARGET_ESC" fi - ]===] , - }, - "PopMode", - }, - }, - }, - default = { - messages = { - "UpdateInputBufferFromKey", - }, + ]===], + }, + "PopMode", }, + }, + }, + default = { + messages = { + "UpdateInputBufferFromKey", + }, }, + }, } -- The builtin duplicate as mode. -- -- Type: [Mode](https://xplr.dev/en/mode) xplr.config.modes.builtin.duplicate_as = { - name = "duplicate as", - key_bindings = { - on_key = { - ["tab"] = { - help = "try complete", - messages = { - { CallLuaSilently = "builtin.try_complete_path" }, - }, - }, - ["enter"] = { - help = "submit", - messages = { - { - BashExecSilently0 = [===[ + name = "duplicate as", + key_bindings = { + on_key = { + ["tab"] = { + help = "try complete", + messages = { + { CallLuaSilently = "builtin.try_complete_path" }, + }, + }, + ["enter"] = { + help = "submit", + messages = { + { + BashExecSilently0 = [===[ SRC="${XPLR_FOCUS_PATH:?}" SRC_ESC=$(printf %q "$SRC") TARGET="${XPLR_INPUT_BUFFER:?}" @@ -1767,33 +1767,33 @@ xplr.config.modes.builtin.duplicate_as = { && "$XPLR" -m 'FocusPath: %q' "$TARGET_ESC" \ && "$XPLR" -m 'LogSuccess: %q' "$SRC_ESC duplicated as $TARGET_ESC" fi - ]===] , - }, - "PopMode", - }, - }, - }, - default = { - messages = { - "UpdateInputBufferFromKey", - }, + ]===], + }, + "PopMode", }, + }, }, + default = { + messages = { + "UpdateInputBufferFromKey", + }, + }, + }, } -- The builtin delete mode. -- -- Type: [Mode](https://xplr.dev/en/mode) xplr.config.modes.builtin.delete = { - name = "delete", - layout = "HelpMenu", - key_bindings = { - on_key = { - ["D"] = { - help = "force delete", - messages = { - { - BashExec0 = [===[ + name = "delete", + layout = "HelpMenu", + key_bindings = { + on_key = { + ["D"] = { + help = "force delete", + messages = { + { + BashExec0 = [===[ (while IFS= read -r -d '' PTH; do PTH_ESC=$(printf %q "$PTH") if rm -rfv -- "${PTH:?}"; then @@ -1804,16 +1804,16 @@ xplr.config.modes.builtin.delete = { done < "${XPLR_PIPE_RESULT_OUT:?}") "$XPLR" -m ExplorePwdAsync read -p "[enter to continue]" - ]===] , - }, - "PopMode", - }, - }, - ["d"] = { - help = "delete", - messages = { - { - BashExec0 = [===[ + ]===], + }, + "PopMode", + }, + }, + ["d"] = { + help = "delete", + messages = { + { + BashExec0 = [===[ (while IFS= read -r -d '' PTH; do PTH_ESC=$(printf %q "$PTH") if [ -d "$PTH" ] && [ ! -L "$PTH" ]; then @@ -1832,581 +1832,581 @@ xplr.config.modes.builtin.delete = { done < "${XPLR_PIPE_RESULT_OUT:?}") "$XPLR" -m ExplorePwdAsync read -p "[enter to continue]" - ]===] , - }, - "PopMode", - }, - }, + ]===], + }, + "PopMode", }, + }, }, + }, } -- The builtin action mode. -- -- Type: [Mode](https://xplr.dev/en/mode) xplr.config.modes.builtin.action = { - name = "action to", - layout = "HelpMenu", - key_bindings = { - on_key = { - ["!"] = { - help = "shell", - messages = { - "PopMode", - { Call0 = { command = os.getenv("SHELL") or "bash", args = { "-i" } } }, - "ExplorePwdAsync", - }, - }, - ["c"] = { - help = "create", - messages = { - "PopMode", - { SwitchModeBuiltin = "create" }, - }, - }, - ["e"] = { - help = "open in editor", - messages = { - { - BashExec0 = [===[ + name = "action to", + layout = "HelpMenu", + key_bindings = { + on_key = { + ["!"] = { + help = "shell", + messages = { + "PopMode", + { Call0 = { command = os.getenv("SHELL") or "bash", args = { "-i" } } }, + "ExplorePwdAsync", + }, + }, + ["c"] = { + help = "create", + messages = { + "PopMode", + { SwitchModeBuiltin = "create" }, + }, + }, + ["e"] = { + help = "open in editor", + messages = { + { + BashExec0 = [===[ ${EDITOR:-vi} "${XPLR_FOCUS_PATH:?}" - ]===] , - }, - "PopMode", - }, - }, - ["l"] = { - help = "logs", - messages = { - { - BashExec = [===[ + ]===], + }, + "PopMode", + }, + }, + ["l"] = { + help = "logs", + messages = { + { + BashExec = [===[ [ -z "$PAGER" ] && PAGER="less -+F" cat -- "${XPLR_PIPE_LOGS_OUT}" | ${PAGER:?} - ]===] , - }, - "PopMode", - }, - }, - ["s"] = { - help = "selection operations", - messages = { - "PopMode", - { SwitchModeBuiltin = "selection_ops" }, - }, - }, - ["m"] = { - help = "toggle mouse", - messages = { - "PopMode", - "ToggleMouse", - }, - }, - ["v"] = { - help = "vroot", - messages = { - "PopMode", - { SwitchModeBuiltin = "vroot" }, - }, - }, - ["q"] = { - help = "quit options", - messages = { - "PopMode", - { SwitchModeBuiltin = "quit" }, - }, - }, + ]===], + }, + "PopMode", }, - on_number = { - help = "go to index", - messages = { - "PopMode", - { SwitchModeBuiltin = "number" }, - "BufferInputFromKey", - }, + }, + ["s"] = { + help = "selection operations", + messages = { + "PopMode", + { SwitchModeBuiltin = "selection_ops" }, + }, + }, + ["m"] = { + help = "toggle mouse", + messages = { + "PopMode", + "ToggleMouse", }, + }, + ["v"] = { + help = "vroot", + messages = { + "PopMode", + { SwitchModeBuiltin = "vroot" }, + }, + }, + ["q"] = { + help = "quit options", + messages = { + "PopMode", + { SwitchModeBuiltin = "quit" }, + }, + }, + }, + on_number = { + help = "go to index", + messages = { + "PopMode", + { SwitchModeBuiltin = "number" }, + "BufferInputFromKey", + }, }, + }, } -- The builtin quit mode. -- -- Type: [Mode](https://xplr.dev/en/mode) xplr.config.modes.builtin.quit = { - name = "quit", - layout = "HelpMenu", - key_bindings = { - on_key = { - ["enter"] = { - help = "just quit", - messages = { - "Quit", - }, - }, - ["p"] = { - help = "quit printing pwd", - messages = { - "PrintPwdAndQuit", - }, - }, - ["f"] = { - help = "quit printing focus", - messages = { - "PrintFocusPathAndQuit", - }, - }, - ["s"] = { - help = "quit printing selection", - messages = { - "PrintSelectionAndQuit", - }, - }, - ["r"] = { - help = "quit printing result", - messages = { - "PrintResultAndQuit", - }, - }, + name = "quit", + layout = "HelpMenu", + key_bindings = { + on_key = { + ["enter"] = { + help = "just quit", + messages = { + "Quit", + }, + }, + ["p"] = { + help = "quit printing pwd", + messages = { + "PrintPwdAndQuit", }, + }, + ["f"] = { + help = "quit printing focus", + messages = { + "PrintFocusPathAndQuit", + }, + }, + ["s"] = { + help = "quit printing selection", + messages = { + "PrintSelectionAndQuit", + }, + }, + ["r"] = { + help = "quit printing result", + messages = { + "PrintResultAndQuit", + }, + }, }, + }, } -- The builtin search mode. -- -- Type: [Mode](https://xplr.dev/en/mode) xplr.config.modes.builtin.search = { - name = "search", - prompt = "/", - key_bindings = { - on_key = { - ["up"] = { - help = "up", - messages = { - "FocusPrevious", - }, - }, - ["down"] = { - help = "down", - messages = { - "FocusNext", - }, - }, - ["right"] = { - help = "enter", - messages = { - "Enter", - { SetInputBuffer = "" }, - }, - }, - ["left"] = { - help = "back", - messages = { - "Back", - { SetInputBuffer = "" }, - }, - }, - ["tab"] = { - help = "toggle selection", - messages = { - "ToggleSelection", - "FocusNext", - }, - }, - ["enter"] = { - help = "submit", - messages = { - "AcceptSearch", - "PopMode", - }, - }, - ["esc"] = { - help = "cancel", - messages = { - "CancelSearch", - "PopMode", - }, - }, + name = "search", + prompt = "/", + key_bindings = { + on_key = { + ["up"] = { + help = "up", + messages = { + "FocusPrevious", }, - default = { - messages = { - "UpdateInputBufferFromKey", - "SearchFuzzyFromInput", - "ExplorePwdAsync", - }, + }, + ["down"] = { + help = "down", + messages = { + "FocusNext", + }, + }, + ["right"] = { + help = "enter", + messages = { + "Enter", + { SetInputBuffer = "" }, + }, + }, + ["left"] = { + help = "back", + messages = { + "Back", + { SetInputBuffer = "" }, + }, + }, + ["tab"] = { + help = "toggle selection", + messages = { + "ToggleSelection", + "FocusNext", + }, + }, + ["enter"] = { + help = "submit", + messages = { + "AcceptSearch", + "PopMode", }, + }, + ["esc"] = { + help = "cancel", + messages = { + "CancelSearch", + "PopMode", + }, + }, + }, + default = { + messages = { + "UpdateInputBufferFromKey", + "SearchFuzzyFromInput", + "ExplorePwdAsync", + }, }, + }, } xplr.config.modes.builtin.search.key_bindings.on_key["ctrl-n"] = -xplr.config.modes.builtin.search.key_bindings.on_key["down"] + xplr.config.modes.builtin.search.key_bindings.on_key["down"] xplr.config.modes.builtin.search.key_bindings.on_key["ctrl-p"] = -xplr.config.modes.builtin.search.key_bindings.on_key["up"] + xplr.config.modes.builtin.search.key_bindings.on_key["up"] -- The builtin filter mode. -- -- Type: [Mode](https://xplr.dev/en/mode) xplr.config.modes.builtin.filter = { - name = "filter", - key_bindings = { - on_key = { - ["r"] = { - help = "relative path does match regex", - messages = { - { SwitchModeBuiltin = "relative_path_does_match_regex" }, - { SetInputBuffer = "" }, - { AddNodeFilterFromInput = "RelativePathDoesMatchRegex" }, - "ExplorePwdAsync", - }, - }, - ["R"] = { - help = "relative path does not match regex", - messages = { - { SwitchModeBuiltin = "relative_path_does_not_match_regex" }, - { SetInputBuffer = "" }, - { AddNodeFilterFromInput = "RelativePathDoesNotMatchRegex" }, - "ExplorePwdAsync", - }, - }, - ["backspace"] = { - help = "remove last filter", - messages = { - "RemoveLastNodeFilter", - "ExplorePwdAsync", - }, - }, - ["ctrl-r"] = { - help = "reset filters", - messages = { - "ResetNodeFilters", - "ExplorePwdAsync", - }, - }, - ["ctrl-u"] = { - help = "clear filters", - messages = { - "ClearNodeFilters", - "ExplorePwdAsync", - }, - }, + name = "filter", + key_bindings = { + on_key = { + ["r"] = { + help = "relative path does match regex", + messages = { + { SwitchModeBuiltin = "relative_path_does_match_regex" }, + { SetInputBuffer = "" }, + { AddNodeFilterFromInput = "RelativePathDoesMatchRegex" }, + "ExplorePwdAsync", + }, + }, + ["R"] = { + help = "relative path does not match regex", + messages = { + { SwitchModeBuiltin = "relative_path_does_not_match_regex" }, + { SetInputBuffer = "" }, + { AddNodeFilterFromInput = "RelativePathDoesNotMatchRegex" }, + "ExplorePwdAsync", + }, + }, + ["backspace"] = { + help = "remove last filter", + messages = { + "RemoveLastNodeFilter", + "ExplorePwdAsync", + }, + }, + ["ctrl-r"] = { + help = "reset filters", + messages = { + "ResetNodeFilters", + "ExplorePwdAsync", }, + }, + ["ctrl-u"] = { + help = "clear filters", + messages = { + "ClearNodeFilters", + "ExplorePwdAsync", + }, + }, }, + }, } -- The builtin relative_path_does_match_regex mode. -- -- 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"] = { - help = "submit", - messages = { - "PopMode", - }, - }, - ["esc"] = { - messages = { - { RemoveNodeFilterFromInput = "RelativePathDoesMatchRegex" }, - "PopMode", - "ExplorePwdAsync", - }, - }, + name = "relative path does match regex", + prompt = xplr.config.general.sort_and_filter_ui.filter_identifiers.RelativePathDoesMatchRegex.format, + key_bindings = { + on_key = { + ["enter"] = { + help = "submit", + messages = { + "PopMode", }, - default = { - messages = { - { RemoveNodeFilterFromInput = "RelativePathDoesMatchRegex" }, - "UpdateInputBufferFromKey", - { AddNodeFilterFromInput = "RelativePathDoesMatchRegex" }, - "ExplorePwdAsync", - }, + }, + ["esc"] = { + messages = { + { RemoveNodeFilterFromInput = "RelativePathDoesMatchRegex" }, + "PopMode", + "ExplorePwdAsync", }, + }, }, + default = { + messages = { + { RemoveNodeFilterFromInput = "RelativePathDoesMatchRegex" }, + "UpdateInputBufferFromKey", + { AddNodeFilterFromInput = "RelativePathDoesMatchRegex" }, + "ExplorePwdAsync", + }, + }, + }, } -- The builtin relative_path_does_not_match_regex mode. -- -- 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"] = { - help = "submit", - messages = { - "PopMode", - }, - }, - ["esc"] = { - messages = { - { RemoveNodeFilterFromInput = "RelativePathDoesNotMatchRegex" }, - "PopMode", - "ExplorePwdAsync", - }, - }, + name = "relative path does not match regex", + prompt = xplr.config.general.sort_and_filter_ui.filter_identifiers.RelativePathDoesNotMatchRegex.format, + key_bindings = { + on_key = { + ["enter"] = { + help = "submit", + messages = { + "PopMode", }, - default = { - messages = { - { RemoveNodeFilterFromInput = "RelativePathDoesNotMatchRegex" }, - "UpdateInputBufferFromKey", - { AddNodeFilterFromInput = "RelativePathDoesNotMatchRegex" }, - "ExplorePwdAsync", - }, + }, + ["esc"] = { + messages = { + { RemoveNodeFilterFromInput = "RelativePathDoesNotMatchRegex" }, + "PopMode", + "ExplorePwdAsync", }, + }, }, + default = { + messages = { + { RemoveNodeFilterFromInput = "RelativePathDoesNotMatchRegex" }, + "UpdateInputBufferFromKey", + { AddNodeFilterFromInput = "RelativePathDoesNotMatchRegex" }, + "ExplorePwdAsync", + }, + }, + }, } -- The builtin sort mode. -- -- Type: [Mode](https://xplr.dev/en/mode) xplr.config.modes.builtin.sort = { - name = "sort", - key_bindings = { - on_key = { - ["!"] = { - help = "reverse sorters", - messages = { - "ReverseNodeSorters", - "ExplorePwdAsync", - }, - }, - ["E"] = { - help = "by canonical extension reverse", - messages = { - { AddNodeSorter = { sorter = "ByCanonicalExtension", reverse = true } }, - "ExplorePwdAsync", - }, - }, - ["M"] = { - help = "by canonical mime essence reverse", - messages = { - { AddNodeSorter = { sorter = "ByCanonicalMimeEssence", reverse = true } }, - "ExplorePwdAsync", - }, - }, - ["N"] = { - help = "by node type reverse", - messages = { - { AddNodeSorter = { sorter = "ByCanonicalIsDir", reverse = true } }, - { AddNodeSorter = { sorter = "ByCanonicalIsFile", reverse = true } }, - { AddNodeSorter = { sorter = "ByIsSymlink", reverse = true } }, - "ExplorePwdAsync", - }, - }, - ["R"] = { - help = "by relative path reverse", - messages = { - { AddNodeSorter = { sorter = "ByIRelativePath", reverse = true } }, - "ExplorePwdAsync", - }, - }, - ["S"] = { - help = "by size reverse", - messages = { - { AddNodeSorter = { sorter = "BySize", reverse = true } }, - "ExplorePwdAsync", - }, - }, - ["backspace"] = { - help = "remove last sorter", - messages = { - "RemoveLastNodeSorter", - "ExplorePwdAsync", - }, - }, - ["ctrl-r"] = { - help = "reset sorters", - messages = { - "ResetNodeSorters", - "ExplorePwdAsync", - }, - }, - ["ctrl-u"] = { - help = "clear sorters", - messages = { - "ClearNodeSorters", - "ExplorePwdAsync", - }, - }, - ["e"] = { - help = "by canonical extension", - messages = { - { AddNodeSorter = { sorter = "ByCanonicalExtension", reverse = false } }, - "ExplorePwdAsync", - }, - }, - ["enter"] = { - help = "submit", - messages = { - "PopMode", - }, - }, - ["m"] = { - help = "by canonical mime essence", - messages = { - { AddNodeSorter = { sorter = "ByCanonicalMimeEssence", reverse = false } }, - "ExplorePwdAsync", - }, - }, - ["n"] = { - help = "by node type", - messages = { - { AddNodeSorter = { sorter = "ByCanonicalIsDir", reverse = false } }, - { AddNodeSorter = { sorter = "ByCanonicalIsFile", reverse = false } }, - { AddNodeSorter = { sorter = "ByIsSymlink", reverse = false } }, - "ExplorePwdAsync", - }, - }, - ["r"] = { - help = "by relative path", - messages = { - { AddNodeSorter = { sorter = "ByIRelativePath", reverse = false } }, - "ExplorePwdAsync", - }, - }, - ["s"] = { - help = "by size", - messages = { - { AddNodeSorter = { sorter = "BySize", reverse = false } }, - "ExplorePwdAsync", - }, - }, + name = "sort", + key_bindings = { + on_key = { + ["!"] = { + help = "reverse sorters", + messages = { + "ReverseNodeSorters", + "ExplorePwdAsync", + }, + }, + ["E"] = { + help = "by canonical extension reverse", + messages = { + { AddNodeSorter = { sorter = "ByCanonicalExtension", reverse = true } }, + "ExplorePwdAsync", + }, + }, + ["M"] = { + help = "by canonical mime essence reverse", + messages = { + { AddNodeSorter = { sorter = "ByCanonicalMimeEssence", reverse = true } }, + "ExplorePwdAsync", + }, + }, + ["N"] = { + help = "by node type reverse", + messages = { + { AddNodeSorter = { sorter = "ByCanonicalIsDir", reverse = true } }, + { AddNodeSorter = { sorter = "ByCanonicalIsFile", reverse = true } }, + { AddNodeSorter = { sorter = "ByIsSymlink", reverse = true } }, + "ExplorePwdAsync", + }, + }, + ["R"] = { + help = "by relative path reverse", + messages = { + { AddNodeSorter = { sorter = "ByIRelativePath", reverse = true } }, + "ExplorePwdAsync", + }, + }, + ["S"] = { + help = "by size reverse", + messages = { + { AddNodeSorter = { sorter = "BySize", reverse = true } }, + "ExplorePwdAsync", + }, + }, + ["backspace"] = { + help = "remove last sorter", + messages = { + "RemoveLastNodeSorter", + "ExplorePwdAsync", + }, + }, + ["ctrl-r"] = { + help = "reset sorters", + messages = { + "ResetNodeSorters", + "ExplorePwdAsync", + }, + }, + ["ctrl-u"] = { + help = "clear sorters", + messages = { + "ClearNodeSorters", + "ExplorePwdAsync", + }, + }, + ["e"] = { + help = "by canonical extension", + messages = { + { AddNodeSorter = { sorter = "ByCanonicalExtension", reverse = false } }, + "ExplorePwdAsync", + }, + }, + ["enter"] = { + help = "submit", + messages = { + "PopMode", + }, + }, + ["m"] = { + help = "by canonical mime essence", + messages = { + { AddNodeSorter = { sorter = "ByCanonicalMimeEssence", reverse = false } }, + "ExplorePwdAsync", + }, + }, + ["n"] = { + help = "by node type", + messages = { + { AddNodeSorter = { sorter = "ByCanonicalIsDir", reverse = false } }, + { AddNodeSorter = { sorter = "ByCanonicalIsFile", reverse = false } }, + { AddNodeSorter = { sorter = "ByIsSymlink", reverse = false } }, + "ExplorePwdAsync", + }, + }, + ["r"] = { + help = "by relative path", + messages = { + { AddNodeSorter = { sorter = "ByIRelativePath", reverse = false } }, + "ExplorePwdAsync", + }, + }, + ["s"] = { + help = "by size", + messages = { + { AddNodeSorter = { sorter = "BySize", reverse = false } }, + "ExplorePwdAsync", + }, + }, - ["c"] = { - help = "by created", - messages = { - { AddNodeSorter = { sorter = "ByCreated", reverse = false } }, - "ExplorePwdAsync", - }, - }, + ["c"] = { + help = "by created", + messages = { + { AddNodeSorter = { sorter = "ByCreated", reverse = false } }, + "ExplorePwdAsync", + }, + }, - ["C"] = { - help = "by created reverse", - messages = { - { AddNodeSorter = { sorter = "ByCreated", reverse = true } }, - "ExplorePwdAsync", - }, - }, + ["C"] = { + help = "by created reverse", + messages = { + { AddNodeSorter = { sorter = "ByCreated", reverse = true } }, + "ExplorePwdAsync", + }, + }, - ["l"] = { - help = "by last modified", - messages = { - { AddNodeSorter = { sorter = "ByLastModified", reverse = false } }, - "ExplorePwdAsync", - }, - }, + ["l"] = { + help = "by last modified", + messages = { + { AddNodeSorter = { sorter = "ByLastModified", reverse = false } }, + "ExplorePwdAsync", + }, + }, - ["L"] = { - help = "by last modified reverse", - messages = { - { AddNodeSorter = { sorter = "ByLastModified", reverse = true } }, - "ExplorePwdAsync", - }, - }, + ["L"] = { + help = "by last modified reverse", + messages = { + { AddNodeSorter = { sorter = "ByLastModified", reverse = true } }, + "ExplorePwdAsync", }, + }, }, + }, } -- The builtin switch layout mode. -- -- Type: [Mode](https://xplr.dev/en/mode) xplr.config.modes.builtin.switch_layout = { - name = "switch layout", - layout = "HelpMenu", - key_bindings = { - on_key = { - ["1"] = { - help = "default", - messages = { - { SwitchLayoutBuiltin = "default" }, - "PopMode", - }, - }, - ["2"] = { - help = "no help menu", - messages = { - { SwitchLayoutBuiltin = "no_help" }, - "PopMode", - }, - }, - ["3"] = { - help = "no selection panel", - messages = { - { SwitchLayoutBuiltin = "no_selection" }, - "PopMode", - }, - }, - ["4"] = { - help = "no help or selection", - messages = { - { SwitchLayoutBuiltin = "no_help_no_selection" }, - "PopMode", - }, - }, + name = "switch layout", + layout = "HelpMenu", + key_bindings = { + on_key = { + ["1"] = { + help = "default", + messages = { + { SwitchLayoutBuiltin = "default" }, + "PopMode", + }, + }, + ["2"] = { + help = "no help menu", + messages = { + { SwitchLayoutBuiltin = "no_help" }, + "PopMode", + }, + }, + ["3"] = { + help = "no selection panel", + messages = { + { SwitchLayoutBuiltin = "no_selection" }, + "PopMode", }, + }, + ["4"] = { + help = "no help or selection", + messages = { + { SwitchLayoutBuiltin = "no_help_no_selection" }, + "PopMode", + }, + }, }, + }, } -- The builtin vroot mode. -- -- Type: [Mode](https://xplr.dev/en/mode) xplr.config.modes.builtin.vroot = { - name = "vroot", - layout = "HelpMenu", - key_bindings = { - on_key = { - ["v"] = { - help = "toggle vroot", - messages = { - "PopMode", - "ToggleVroot", - }, - }, - ["."] = { - help = "vroot $PWD", - messages = { - "PopMode", - { - BashExecSilently0 = [===[ + name = "vroot", + layout = "HelpMenu", + key_bindings = { + on_key = { + ["v"] = { + help = "toggle vroot", + messages = { + "PopMode", + "ToggleVroot", + }, + }, + ["."] = { + help = "vroot $PWD", + messages = { + "PopMode", + { + BashExecSilently0 = [===[ "$XPLR" -m 'SetVroot: %q' "${PWD:?}" - ]===] , - }, - }, - }, - ["/"] = { - help = "vroot /", - messages = { - "PopMode", - { SetVroot = "/" }, - }, - }, - ["~"] = { - help = "vroot $HOME", - messages = { - "PopMode", - { - BashExecSilently0 = [===[ + ]===], + }, + }, + }, + ["/"] = { + help = "vroot /", + messages = { + "PopMode", + { SetVroot = "/" }, + }, + }, + ["~"] = { + help = "vroot $HOME", + messages = { + "PopMode", + { + BashExecSilently0 = [===[ "$XPLR" -m 'SetVroot: %q' "${HOME:?}" - ]===] , - }, - }, - }, - ["ctrl-r"] = { - help = "reset vroot", - messages = { - "PopMode", - "ResetVroot", - }, - }, - ["ctrl-u"] = { - help = "unset vroot", - messages = { - "PopMode", - "UnsetVroot", - }, - }, + ]===], + }, + }, + }, + ["ctrl-r"] = { + help = "reset vroot", + messages = { + "PopMode", + "ResetVroot", + }, + }, + ["ctrl-u"] = { + help = "unset vroot", + messages = { + "PopMode", + "UnsetVroot", }, + }, }, + }, } -- This is where you define custom modes. @@ -2450,210 +2450,210 @@ xplr.config.modes.custom = {} -- Tries to auto complete the path in the input buffer xplr.fn.builtin.try_complete_path = function(m) - if not m.input_buffer then - return + if not m.input_buffer then + return + end + + local function matches_all(str, paths) + for _, path in ipairs(paths) do + if string.sub(path, 1, #str) ~= str then + return false + end end + return true + end - local function matches_all(str, paths) - for _, path in ipairs(paths) do - if string.sub(path, 1, #str) ~= str then - return false - end - end - return true - end - - local path = m.input_buffer - local explorer_config = { - filters = { - { filter = "RelativePathDoesStartWith", input = xplr.util.basename(path) }, - }, + local path = m.input_buffer + local explorer_config = { + filters = { + { filter = "RelativePathDoesStartWith", input = xplr.util.basename(path) }, + }, + } + local parent = xplr.util.dirname(path) + if not parent or parent == "" then + parent = "./" + elseif parent ~= "/" then + parent = parent .. "/" + end + + local nodes = xplr.util.explore(parent, explorer_config) + local found = {} + for _, node in ipairs(nodes) do + table.insert(found, parent .. node.relative_path) + end + local count = #found + + if count == 0 then + return + elseif count == 1 then + return { + { SetInputBuffer = found[1] }, } - local parent = xplr.util.dirname(path) - if not parent or parent == "" then - parent = "./" - elseif parent ~= "/" then - parent = parent .. "/" + else + local first = found[1] + while #first > #path and matches_all(path, found) do + path = string.sub(first, 1, #path + 1) end - local nodes = xplr.util.explore(parent, explorer_config) - local found = {} - for _, node in ipairs(nodes) do - table.insert(found, parent .. node.relative_path) - end - local count = #found - - if count == 0 then - return - elseif count == 1 then - return { - { SetInputBuffer = found[1] }, - } - else - local first = found[1] - while #first > #path and matches_all(path, found) do - path = string.sub(first, 1, #path + 1) - end - - if matches_all(path, found) then - return { - { SetInputBuffer = path }, - } - end - - return { - { SetInputBuffer = string.sub(path, 1, #path - 1) }, - } + if matches_all(path, found) then + return { + { SetInputBuffer = path }, + } end + + return { + { SetInputBuffer = string.sub(path, 1, #path - 1) }, + } + end end -- Renders the first column in the table xplr.fn.builtin.fmt_general_table_row_cols_0 = function(m) - local r = "" - if m.is_before_focus then - r = r .. " -" - else - r = r .. " " - end + local r = "" + if m.is_before_focus then + r = r .. " -" + else + r = r .. " " + end - r = r .. m.relative_index .. "│" .. m.index + r = r .. m.relative_index .. "│" .. m.index - return r + return r end -- Renders the second column in the table xplr.fn.builtin.fmt_general_table_row_cols_1 = function(m) - local r = m.tree .. m.prefix + local r = m.tree .. m.prefix - local function path_escape(path) - return string.gsub(string.gsub(path, "\\", "\\\\"), "\n", "\\n") - end + local function path_escape(path) + return string.gsub(string.gsub(path, "\\", "\\\\"), "\n", "\\n") + end - if m.meta.icon == nil then - r = r .. "" - else - r = r .. m.meta.icon .. " " - end + if m.meta.icon == nil then + r = r .. "" + else + r = r .. m.meta.icon .. " " + end - r = r .. path_escape(m.relative_path) + r = r .. path_escape(m.relative_path) - if m.is_dir then - r = r .. "/" - end + if m.is_dir then + r = r .. "/" + end - r = r .. m.suffix .. " " + r = r .. m.suffix .. " " - if m.is_symlink then - r = r .. "-> " + if m.is_symlink then + r = r .. "-> " - if m.is_broken then - r = r .. "×" - else - r = r .. path_escape(m.symlink.absolute_path) + if m.is_broken then + r = r .. "×" + else + r = r .. path_escape(m.symlink.absolute_path) - if m.symlink.is_dir then - r = r .. "/" - end - end + if m.symlink.is_dir then + r = r .. "/" + end end + end - return r + return r end -- Renders the third column in the table xplr.fn.builtin.fmt_general_table_row_cols_2 = function(m) - local no_color = os.getenv("NO_COLOR") - - local function green(x) - if no_color == nil then - return "\x1b[32m" .. x .. "\x1b[0m" - else - return x - end - end + local no_color = os.getenv("NO_COLOR") - local function yellow(x) - if no_color == nil then - return "\x1b[33m" .. x .. "\x1b[0m" - else - return x - end - end - - local function red(x) - if no_color == nil then - return "\x1b[31m" .. x .. "\x1b[0m" - else - return x - end - end - - local function bit(x, color, cond) - if cond then - return color(x) - else - return color("-") - end + local function green(x) + if no_color == nil then + return "\x1b[32m" .. x .. "\x1b[0m" + else + return x end + end - local p = m.permissions - - local r = "" - - r = r .. bit("r", green, p.user_read) - r = r .. bit("w", yellow, p.user_write) - - if p.user_execute == false and p.setuid == false then - r = r .. bit("-", red, p.user_execute) - elseif p.user_execute == true and p.setuid == false then - r = r .. bit("x", red, p.user_execute) - elseif p.user_execute == false and p.setuid == true then - r = r .. bit("S", red, p.user_execute) + local function yellow(x) + if no_color == nil then + return "\x1b[33m" .. x .. "\x1b[0m" else - r = r .. bit("s", red, p.user_execute) + return x end + end - r = r .. bit("r", green, p.group_read) - r = r .. bit("w", yellow, p.group_write) - - if p.group_execute == false and p.setuid == false then - r = r .. bit("-", red, p.group_execute) - elseif p.group_execute == true and p.setuid == false then - r = r .. bit("x", red, p.group_execute) - elseif p.group_execute == false and p.setuid == true then - r = r .. bit("S", red, p.group_execute) + local function red(x) + if no_color == nil then + return "\x1b[31m" .. x .. "\x1b[0m" else - r = r .. bit("s", red, p.group_execute) + return x end + end - r = r .. bit("r", green, p.other_read) - r = r .. bit("w", yellow, p.other_write) - - if p.other_execute == false and p.setuid == false then - r = r .. bit("-", red, p.other_execute) - elseif p.other_execute == true and p.setuid == false then - r = r .. bit("x", red, p.other_execute) - elseif p.other_execute == false and p.setuid == true then - r = r .. bit("T", red, p.other_execute) + local function bit(x, color, cond) + if cond then + return color(x) else - r = r .. bit("t", red, p.other_execute) + return color("-") end - - return r + end + + local p = m.permissions + + local r = "" + + r = r .. bit("r", green, p.user_read) + r = r .. bit("w", yellow, p.user_write) + + if p.user_execute == false and p.setuid == false then + r = r .. bit("-", red, p.user_execute) + elseif p.user_execute == true and p.setuid == false then + r = r .. bit("x", red, p.user_execute) + elseif p.user_execute == false and p.setuid == true then + r = r .. bit("S", red, p.user_execute) + else + r = r .. bit("s", red, p.user_execute) + end + + r = r .. bit("r", green, p.group_read) + r = r .. bit("w", yellow, p.group_write) + + if p.group_execute == false and p.setuid == false then + r = r .. bit("-", red, p.group_execute) + elseif p.group_execute == true and p.setuid == false then + r = r .. bit("x", red, p.group_execute) + elseif p.group_execute == false and p.setuid == true then + r = r .. bit("S", red, p.group_execute) + else + r = r .. bit("s", red, p.group_execute) + end + + r = r .. bit("r", green, p.other_read) + r = r .. bit("w", yellow, p.other_write) + + if p.other_execute == false and p.setuid == false then + r = r .. bit("-", red, p.other_execute) + elseif p.other_execute == true and p.setuid == false then + r = r .. bit("x", red, p.other_execute) + elseif p.other_execute == false and p.setuid == true then + r = r .. bit("T", red, p.other_execute) + else + r = r .. bit("t", red, p.other_execute) + end + + return r end -- Renders the fourth column in the table xplr.fn.builtin.fmt_general_table_row_cols_3 = function(m) - if not m.is_dir then - return m.human_size - else - return "" - end + if not m.is_dir then + return m.human_size + else + return "" + end end -- Renders the fifth column in the table xplr.fn.builtin.fmt_general_table_row_cols_4 = function(m) - return tostring(os.date("%a %b %d %H:%M:%S %Y", m.last_modified / 1000000000)) + return tostring(os.date("%a %b %d %H:%M:%S %Y", m.last_modified / 1000000000)) end -- This is where the custom functions can be added. @@ -2722,9 +2722,9 @@ xplr.fn.custom = {} -- ``` return { - on_load = {}, - on_directory_change = {}, - on_focus_change = {}, - on_mode_switch = {}, - on_layout_switch = {}, + on_load = {}, + on_directory_change = {}, + on_focus_change = {}, + on_mode_switch = {}, + on_layout_switch = {}, }