diff --git a/Cargo.lock b/Cargo.lock index 3b3c599..f149e13 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1917,7 +1917,7 @@ checksum = "213b7324336b53d2414b2db8537e56544d981803139155afa84f76eeebb7a546" [[package]] name = "xplr" -version = "0.21.5" +version = "0.21.6" dependencies = [ "ansi-to-tui", "anyhow", diff --git a/Cargo.toml b/Cargo.toml index edf07d1..bf64170 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,7 +8,7 @@ path = './benches/criterion.rs' [package] name = 'xplr' -version = '0.21.5' +version = '0.21.6' authors = ['Arijit Basu '] edition = '2021' description = 'A hackable, minimal, fast TUI file explorer' diff --git a/docs/en/src/upgrade-guide.md b/docs/en/src/upgrade-guide.md index a91e281..2ef1f3b 100644 --- a/docs/en/src/upgrade-guide.md +++ b/docs/en/src/upgrade-guide.md @@ -45,7 +45,7 @@ compatibility. ### Instructions -#### [v0.20.2][48] -> [v0.21.5][49] +#### [v0.20.2][48] -> [v0.21.6][49] - Some plugins might stop rendering colors. Wait for them to update. - Rename `xplr.config.general.sort_and_filter_ui.search_identifier` to @@ -123,6 +123,10 @@ compatibility. messages: - NextVisitedDeepBranch (bound to `)` key) - PreviousVisitedDeepBranch (bound to `(` key) +- Since v0.21.6: + - You can use `c` and `m` keys in default mode to quickly copy + and move focused or selected files, without having to change directory. + - Use `xplr.util.debug()` to debug lua values. Thanks to @noahmayr for contributing to a major part of this release. @@ -521,5 +525,5 @@ Else do the following: [46]: https://github.com/sayanarijit/xplr/releases/tag/v0.18.0 [47]: https://github.com/sayanarijit/xplr/releases/tag/v0.19.4 [48]: https://github.com/sayanarijit/xplr/releases/tag/v0.20.2 -[49]: https://github.com/sayanarijit/xplr/releases/tag/v0.21.5 +[49]: https://github.com/sayanarijit/xplr/releases/tag/v0.21.6 [50]: https://github.com/lotabout/skim#search-syntax diff --git a/docs/en/src/xplr.util.md b/docs/en/src/xplr.util.md index 5c1684f..fed14d0 100644 --- a/docs/en/src/xplr.util.md +++ b/docs/en/src/xplr.util.md @@ -11,6 +11,23 @@ xplr.util.version() -- { major = 0, minor = 0, patch = 0 } ``` +### xplr.util.debug + +Print the given value to the console, and return it as a string. +Useful for debugging. + +Type: function( value ) -> string + +Example: + +```lua +xplr.util.debug({ foo = "bar", bar = function() end }) +-- { +-- ["bar"] = function: 0x55e5cebdeae0, +-- ["foo"] = "bar", +-- } +``` + ### xplr.util.clone Clone/deepcopy a Lua value. Doesn't work with functions. diff --git a/src/init.lua b/src/init.lua index 9e4bea1..a36ddb7 100644 --- a/src/init.lua +++ b/src/init.lua @@ -478,7 +478,7 @@ xplr.config.general.sort_and_filter_ui.search_identifiers = { -- -- Type: nullable string xplr.config.general.sort_and_filter_ui.search_direction_identifiers.ordered.format = - "↓" +"↓" -- The shape of unordered indicator for search ordering identifiers in Sort & filter panel. -- @@ -676,7 +676,7 @@ 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 = "ByIRelativePath", reverse = false }, } -- The name of one of the modes to use when xplr loads. @@ -1325,23 +1325,23 @@ xplr.config.modes.builtin.default = { } 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"] xplr.config.modes.builtin.default.key_bindings.on_key["tab"] = - xplr.config.modes.builtin.default.key_bindings.on_key["ctrl-i"] -- compatibility workaround + xplr.config.modes.builtin.default.key_bindings.on_key["ctrl-i"] -- compatibility workaround xplr.config.modes.builtin.default.key_bindings.on_key["?"] = - xplr.config.general.global_key_bindings.on_key["f1"] + xplr.config.general.global_key_bindings.on_key["f1"] -- The builtin debug error mode. -- @@ -1993,9 +1993,9 @@ xplr.config.modes.builtin.number = { } 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. -- @@ -2479,9 +2479,9 @@ xplr.config.modes.builtin.search = { } 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. -- @@ -3161,7 +3161,7 @@ xplr.fn.builtin.fmt_general_table_row_cols_1 = function(m) r = r .. "×" else local symlink_path = - xplr.util.shorten(m.symlink.absolute_path, { base = m.parent }) + xplr.util.shorten(m.symlink.absolute_path, { base = m.parent }) if m.symlink.is_dir then symlink_path = symlink_path .. "/" end @@ -3183,14 +3183,14 @@ xplr.fn.builtin.fmt_general_table_row_cols_2 = function(m) local T = xplr.util.paint("T", { fg = "Red" }) return xplr.util - .permissions_rwx(m.permissions) - :gsub("r", r) - :gsub("w", w) - :gsub("x", x) - :gsub("s", s) - :gsub("S", S) - :gsub("t", t) - :gsub("T", T) + .permissions_rwx(m.permissions) + :gsub("r", r) + :gsub("w", w) + :gsub("x", x) + :gsub("s", s) + :gsub("S", S) + :gsub("t", t) + :gsub("T", T) end -- Renders the fourth column in the table diff --git a/src/lua/mod.rs b/src/lua/mod.rs index 6bd0823..9dd827f 100644 --- a/src/lua/mod.rs +++ b/src/lua/mod.rs @@ -160,24 +160,24 @@ mod tests { assert!(check_version(VERSION, "foo path").is_ok()); // Current release if OK - assert!(check_version("0.21.5", "foo path").is_ok()); + assert!(check_version("0.21.6", "foo path").is_ok()); // Prev major release is ERR // - Not yet // Prev minor release is ERR (Change when we get to v1) - assert!(check_version("0.20.5", "foo path").is_err()); + assert!(check_version("0.20.6", "foo path").is_err()); // Prev bugfix release is OK - assert!(check_version("0.21.4", "foo path").is_ok()); + assert!(check_version("0.21.5", "foo path").is_ok()); // Next major release is ERR - assert!(check_version("1.20.5", "foo path").is_err()); + assert!(check_version("1.20.6", "foo path").is_err()); // Next minor release is ERR - assert!(check_version("0.22.5", "foo path").is_err()); + assert!(check_version("0.22.6", "foo path").is_err()); // Next bugfix release is ERR (Change when we get to v1) - assert!(check_version("0.21.6", "foo path").is_err()); + assert!(check_version("0.21.7", "foo path").is_err()); } } diff --git a/src/lua/util.rs b/src/lua/util.rs index 21d8ce7..cf198e2 100644 --- a/src/lua/util.rs +++ b/src/lua/util.rs @@ -64,6 +64,30 @@ pub fn version<'a>(util: Table<'a>, lua: &Lua) -> Result> { Ok(util) } +/// Print the given value to the console, and return it as a string. +/// Useful for debugging. +/// +/// Type: function( value ) -> string +/// +/// Example: +/// +/// ```lua +/// xplr.util.debug({ foo = "bar", bar = function() end }) +/// -- { +/// -- ["bar"] = function: 0x55e5cebdeae0, +/// -- ["foo"] = "bar", +/// -- } +/// ``` +pub fn debug<'a>(util: Table<'a>, lua: &Lua) -> Result> { + let func = lua.create_function(|_, value: Value| { + let log = format!("{:#?}", value); + println!("{}", log); + Ok(log) + })?; + util.set("debug", func)?; + Ok(util) +} + /// Clone/deepcopy a Lua value. Doesn't work with functions. /// /// Type: function( value ) -> value @@ -838,6 +862,7 @@ pub(crate) fn create_table(lua: &Lua) -> Result { let mut util = lua.create_table()?; util = version(util, lua)?; + util = debug(util, lua)?; util = clone(util, lua)?; util = exists(util, lua)?; util = is_dir(util, lua)?;