diff --git a/.cargo/config b/.cargo/config index 0a661cc..bcfce47 100644 --- a/.cargo/config +++ b/.cargo/config @@ -8,7 +8,7 @@ rustflags = ["-C", "link-args=-rdynamic"] rustflags = ["-C", "linker=aarch64-linux-gnu-gcc", "-C", "link-args=-rdynamic"] [target.aarch64-linux-android] -rustflags = ["-C", "linker=aarch64-linux-android-clang", "-C", "link-args=-rdynamic"] +rustflags = ["-C", "linker=aarch64-linux-android-clang", "-C", "link-args=-rdynamic", "-C", "default-linker-libraries"] [target.arm-unknown-linux-gnueabihf] rustflags = ["-C", "linker=arm-linux-gnueabihf-gcc", "-C", "link-args=-rdynamic"] diff --git a/docs/en/src/general-config.md b/docs/en/src/general-config.md index 8b09e11..75fa861 100644 --- a/docs/en/src/general-config.md +++ b/docs/en/src/general-config.md @@ -587,12 +587,16 @@ Type: nullable list of [Node Sorter](https://xplr.dev/en/sorting#node-sorter-app #### xplr.config.general.initial_mode The name of one of the modes to use when xplr loads. +This isn't the default mode. To modify the default mode, overwrite +[xplr.config.modes.builtin.default](https://xplr.dev/en/modes#xplrconfigmodesbuiltindefault). Type: nullable string #### xplr.config.general.initial_layout The name of one of the layouts to use when xplr loads. +This isn't the default layout. To modify the default layout, overwrite +[xplr.config.layouts.builtin.default](https://xplr.dev/en/layouts#xplrconfiglayoutsbuiltindefault). Type: nullable string diff --git a/docs/en/src/install.md b/docs/en/src/install.md index 88d93f8..c32f3aa 100644 --- a/docs/en/src/install.md +++ b/docs/en/src/install.md @@ -196,6 +196,23 @@ cargo build --locked --release --bin xplr sudo cp target/release/xplr /usr/local/bin/ ``` +## Android + +### [Termux][24] + +```bash +pkg install rust make binutils +cargo install --locked xplr + +# Run +~/.cargo/bin/xplr +``` + +> Please note that xplr isn't heavily tested on Termux, hence things might need +> a little tweaking and fixing for a smooth user experience. + +![termux demo][23] + [1]: #direct-download [2]: #from-cratesio [3]: #build-from-source @@ -218,6 +235,8 @@ sudo cp target/release/xplr /usr/local/bin/ [20]: https://gcc.gnu.org/ [21]: https://www.gnu.org/software/make/ [22]: https://git-scm.com/ +[23]: https://github.com/sayanarijit/xplr/assets/11632726/3b61e8c8-76f0-48e8-8734-50e9e7e495b7 +[24]: https://termux.dev/ [25]: https://gifyu.com/image/tF2D [26]: https://github.com/sayanarijit/xplr/releases/latest/download/xplr-linux-musl.tar.gz [27]: https://pkgs.alpinelinux.org/packages?name=xplr diff --git a/docs/en/src/layout.md b/docs/en/src/layout.md index 2a74878..ec603a8 100644 --- a/docs/en/src/layout.md +++ b/docs/en/src/layout.md @@ -2,15 +2,13 @@ #### Example: Defining Custom Layout -[![layout.png][23]][24] - ```lua xplr.config.layouts.builtin.default = { Horizontal = { config = { margin = 1, - horizontal_margin = 2, - vertical_margin = 3, + horizontal_margin = 1, + vertical_margin = 1, constraints = { { Percentage = 50 }, { Percentage = 50 }, @@ -24,6 +22,21 @@ xplr.config.layouts.builtin.default = { } ``` +Result: + +``` + ╭ /home ─────────────╮╭ Help [default] ────╮ + │ ╭─── path ││. show hidden │ + │ ├▸[ð Desktop/] ││/ search │ + │ ├ ð Documents/ ││: action │ + │ ├ ð Downloads/ ││? global help │ + │ ├ ð GitHub/ ││G go to bottom │ + │ ├ ð Music/ ││V select/unselect│ + │ ├ ð Pictures/ ││ctrl duplicate as │ + │ ├ ð Public/ ││ctrl next visit │ + ╰────────────────────╯╰────────────────────╯ +``` + A layout is a [sum type][56] can be one of the following: - [Nothing][8] @@ -86,7 +99,7 @@ Type: { Static = [Custom Panel][27] } This is a custom layout to render dynamic content using a function defined in [xplr.fn][28] that takes [Content Renderer Argument][36] and returns [Custom Panel][27]. -Type: { Dynamic = [Content Renderer][35] } +Type: { Dynamic = "[Content Renderer][35]" } ### Horizontal @@ -97,7 +110,7 @@ It contains the following information: - [config][15] - [splits][17] -Type: { Horizontal = { config = [config][15], splits = [splits][17] } +Type: { Vertical = { config = [Layout Config][15], splits = { [Layout][17], ... } } ### Vertical @@ -108,7 +121,7 @@ It contains the following information: - [config][15] - [splits][17] -Type: { Vertical = { config = [config][15], splits = [splits][17] } +Type: { Vertical = { config = [Layout Config][15], splits = { [Layout][17], ... } } ## Layout Config @@ -200,6 +213,16 @@ xplr.config.layouts.builtin.default = { } ``` +Result: + +``` +╭ custom title ────────╮ +│custom body │ +│ │ +│ │ +╰──────────────────────╯ +``` + #### Example: Render a custom dynamic paragraph ```lua @@ -215,6 +238,23 @@ xplr.fn.custom.render_layout = function(ctx) end ``` +Result: + +``` +╭/home/sayanarijit───────────────────────────╮ +│mime_essence: inode/directory │ +│relative_path: Desktop │ +│is_symlink: false │ +│is_readonly: false │ +│parent: /home/sayanarijit │ +│absolute_path: /home/sayanarijit/Desktop │ +│is_broken: false │ +│created: 1668087850396758714 │ +│size: 4096 │ +│gid: 100 │ +╰────────────────────────────────────────────╯ +``` + ### CustomList A list to render. It contains the following fields: @@ -235,6 +275,17 @@ xplr.config.layouts.builtin.default = { } ``` +Result: + +``` +╭ custom title ─────────────╮ +│1 │ +│2 │ +│3 │ +│ │ +╰───────────────────────────╯ +``` + #### Example: Render a custom dynamic list ```lua @@ -254,6 +305,18 @@ xplr.fn.custom.render_layout = function(ctx) end ``` +Result: + +``` +╭/home/sayanarijit──────────╮ +│Desktop │ +│0.21.2 │ +│17336 │ +│ │ +│ │ +╰───────────────────────────╯ +``` + ## CustomTable A custom table to render. It contains the following fields: @@ -283,6 +346,18 @@ xplr.config.layouts.builtin.default = { } ``` +Result: + +``` +╭ custom title ────────────────────╮ +│a b │ +│c d │ +│ │ +│ │ +│ │ +╰──────────────────────────────────╯ +``` + #### Example: Render a custom dynamic table ```lua @@ -309,6 +384,23 @@ xplr.fn.custom.render_layout = function(ctx) end ``` +Result: + +``` +╭/home/sayanarijit───────────────────────────╮ +│ │ +│Layout height 12 │ +│Layout width 46 │ +│ │ +│Screen height 12 │ +│Screen width 46 │ +│ │ +│ │ +│ │ +│ │ +╰────────────────────────────────────────────╯ +``` + ### CustomLayout A whole custom layout to render. It doesn't make sense to use it as a @@ -347,6 +439,40 @@ xplr.fn.custom.render_layout = function(ctx) end ``` +Result: + +``` +╭─────────────────────╮╭─────────────────────╮ +│Try your luck... ││Press ctrl-r │ +│ ││ │ +│ ││ │ +│ ││ │ +│ ││ │ +│ ││ │ +│ ││ │ +│ ││ │ +│ ││ │ +│ ││ │ +╰─────────────────────╯╰─────────────────────╯ +``` + +Or + +``` +╭────────────────────────────────────────────╮ +│Try your luck... │ +│ │ +│ │ +│ │ +╰────────────────────────────────────────────╯ +╭────────────────────────────────────────────╮ +│Press ctrl-r │ +│ │ +│ │ +│ │ +╰────────────────────────────────────────────╯ +``` + ## Panel UI Config It contains the following optional fields: @@ -429,8 +555,6 @@ Hence, only the following fields are available. [20]: #vertical_margin [21]: #constraints [22]: #constraint -[23]: https://s6.gifyu.com/images/layout.png -[24]: https://gifyu.com/image/1X38 [25]: #static [26]: #dynamic [27]: #custom-panel diff --git a/docs/en/src/layouts.md b/docs/en/src/layouts.md index 1650da6..9ee0635 100644 --- a/docs/en/src/layouts.md +++ b/docs/en/src/layouts.md @@ -12,15 +12,13 @@ You can add new panels in `xplr.config.layouts.custom`. ##### Example: Defining Custom Layout -![demo](https://s6.gifyu.com/images/layout.png) - ```lua xplr.config.layouts.builtin.default = { Horizontal = { config = { margin = 1, - horizontal_margin = 2, - vertical_margin = 3, + horizontal_margin = 1, + vertical_margin = 1, constraints = { { Percentage = 50 }, { Percentage = 50 }, @@ -34,6 +32,21 @@ xplr.config.layouts.builtin.default = { } ``` +Result: + +``` +╭ /home ─────────────╮╭ Help [default] ────╮ +│ ╭─── path ││. show hidden │ +│ ├▸[ð Desktop/] ││/ search │ +│ ├ ð Documents/ ││: action │ +│ ├ ð Downloads/ ││? global help │ +│ ├ ð GitHub/ ││G go to bottom │ +│ ├ ð Music/ ││V select/unselect│ +│ ├ ð Pictures/ ││ctrl duplicate as │ +│ ├ ð Public/ ││ctrl next visit │ +╰────────────────────╯╰────────────────────╯ +``` + #### xplr.config.layouts.builtin.default The default layout diff --git a/docs/en/src/sum-type.md b/docs/en/src/sum-type.md index cf7f654..26e93dd 100644 --- a/docs/en/src/sum-type.md +++ b/docs/en/src/sum-type.md @@ -29,23 +29,23 @@ them, but only a few modern programming languages allow nesting other types into a sum type. ```rust -enum Result { - Ok, - Err, +enum Color { + Red, + Green, } ``` -Here, `Result` can be one of two possible set of values: `Ok` and `Err`, just -like `boolean`, but unlike `boolean`, being tagged allows `Result` to have more +Here, `Color` can be one of two possible set of values: `Red` and `Green`, just +like `boolean`, but unlike `boolean`, being tagged allows `Color` to have more than two variants if required, by changing the definition. e.g. ```rust -enum Result { - Ok, - Err, - Pending, +enum Color { + Red, + Green, + Blue, } ``` @@ -53,35 +53,39 @@ We'd document it here as: > Result is a sum type that can be one of the following: > -> - "Ok" -> - "Err" -> - "Pending" +> - "Red" +> - "Green" +> - "Blue" But some languages (like Rust, Haskell, Elm etc.) go even further, allowing us to associate each branch of the enum with further nested types like: ```rust -enum Result { - Ok(bool), - Err(Error), - Pending, +enum Layout { + Table, + HelpMenu, + Horizontal { + config: LayoutConfig, // A product type (similar to class/struct) + splits: Vec // A list of "Layout"s (i.e. list of sum types) + }, } ``` -Here, as we can see, unlike the first example, some of `Result`'s possible -variants can have further nested types associated with them. Note that `Error` -here can be either a sum type (e.g. enum), or a product type (e.g. -class/struct), but whatever it is, it will only exist when `Result` is `Err`. +Here, as we can see, unlike the first example, some of `Layout`'s possible +variants can have further nested types associated with them. Note that +`Horizontal` here can have a sum type (e.g. enum), or a product type (e.g. +class/struct), or both (any number of them actually) nested in it. But the +nested values will only exist when `Layout` is `Horizontal`. We'd document it here as: -> Result is a sum type that can be one of the following: +> Layout is a sum type that can be one of the following: > -> - { Ok = bool } -> - { Err = Error } -> - "Pending" +> - "Table" +> - "HelpMenu" +> - { Horizontal = { config = Layout Config, splits = { Layout, ... } } -And then we'd go on documenting whatever `Error` is. +And then we'd go on documenting whatever `Layout Config` is. So, there you go. This is exactly what sum types are - glorified enums that can have nested types in each branch. diff --git a/src/init.lua b/src/init.lua index 21228bf..296e62a 100644 --- a/src/init.lua +++ b/src/init.lua @@ -680,11 +680,15 @@ xplr.config.general.initial_sorting = { } -- The name of one of the modes to use when xplr loads. +-- This isn't the default mode. To modify the default mode, overwrite +-- [xplr.config.modes.builtin.default](https://xplr.dev/en/modes#xplrconfigmodesbuiltindefault). -- -- Type: nullable string xplr.config.general.initial_mode = "default" -- The name of one of the layouts to use when xplr loads. +-- This isn't the default layout. To modify the default layout, overwrite +-- [xplr.config.layouts.builtin.default](https://xplr.dev/en/layouts#xplrconfiglayoutsbuiltindefault). -- -- Type: nullable string xplr.config.general.initial_layout = "default" @@ -852,15 +856,13 @@ xplr.config.node_types.special = {} -- -- ##### Example: Defining Custom Layout -- --- ![demo](https://s6.gifyu.com/images/layout.png) --- -- ```lua -- xplr.config.layouts.builtin.default = { -- Horizontal = { -- config = { -- margin = 1, --- horizontal_margin = 2, --- vertical_margin = 3, +-- horizontal_margin = 1, +-- vertical_margin = 1, -- constraints = { -- { Percentage = 50 }, -- { Percentage = 50 }, @@ -873,6 +875,21 @@ xplr.config.node_types.special = {} -- } -- } -- ``` +-- +-- Result: +-- +-- ``` +-- ╭ /home ─────────────╮╭ Help [default] ────╮ +-- │ ╭─── path ││. show hidden │ +-- │ ├▸[ð Desktop/] ││/ search │ +-- │ ├ ð Documents/ ││: action │ +-- │ ├ ð Downloads/ ││? global help │ +-- │ ├ ð GitHub/ ││G go to bottom │ +-- │ ├ ð Music/ ││V select/unselect│ +-- │ ├ ð Pictures/ ││ctrl duplicate as │ +-- │ ├ ð Public/ ││ctrl next visit │ +-- ╰────────────────────╯╰────────────────────╯ +-- ``` -- The default layout -- @@ -3077,6 +3094,14 @@ xplr.fn.custom = {} -- { LogSuccess = "Switched layout" }, -- { CallLuaSilently = "custom.some_plugin_with_hooks.on_layout_switch" }, -- } +-- +-- -- Add messages to send when the selection changes +-- -- +-- -- Type: list of [Message](https://xplr.dev/en/message#message)s +-- on_selection_change = { +-- { LogSuccess = "Selection changed" }, +-- { CallLuaSilently = "custom.some_plugin_with_hooks.on_selection_change" }, +-- } -- } -- ```