From e845d77bf025bc3e17105e1672f83cce24d29cbe Mon Sep 17 00:00:00 2001 From: sxyazi Date: Mon, 15 Jan 2024 02:55:08 +0800 Subject: [PATCH] docs: add `folder::Folder` docs --- docs/configuration/yazi.md | 4 ++-- docs/plugins/common.md | 26 ++++++++++++-------------- docs/plugins/overview.md | 2 +- docs/plugins/utils.md | 24 ++++++++++++------------ docs/tips.md | 4 ++-- 5 files changed, 29 insertions(+), 31 deletions(-) diff --git a/docs/configuration/yazi.md b/docs/configuration/yazi.md index b78d1742..aed61592 100644 --- a/docs/configuration/yazi.md +++ b/docs/configuration/yazi.md @@ -162,7 +162,7 @@ prepend_previewers = [ ] ``` -Yazi comes with the those previewer plugins: +Yazi comes with the these previewer plugins: - folder: bridge between the Yazi file system and the preview - code: bridge between built-in code highlighting and the preview, providing async concurrent rendering @@ -196,7 +196,7 @@ prepend_preloaders = [ ] ``` -Yazi comes with the those preloader plugins: +Yazi comes with the these preloader plugins: - mime: preloads mime-type of files in chunks - noop: no operation diff --git a/docs/plugins/common.md b/docs/plugins/common.md index d5ba1bde..dae3c312 100644 --- a/docs/plugins/common.md +++ b/docs/plugins/common.md @@ -19,7 +19,7 @@ Cha means one file's characteristics with the following properties: - `is_char_device`: Whether this file is a character device - `is_fifo`: Whether this file is a fifo - `is_socket`: Whether this file is a socket -- `length`: The length of this file, returns a integer representing the size in bytes. Note that it can't reflect the size of a directory, use [`size()`](#folderfile) instead +- `length`: The length of this file, returns an integer representing the size in bytes. Note that it can't reflect the size of a directory, use [`size()`](#folderfile) instead - `created`: The created time of this file in Unix timestamp, or `nil` if it doesn't have a valid time - `modified`: The modified time of this file in Unix timestamp, or `nil` if it doesn't have a valid time - `accessed`: The accessed time of this file in Unix timestamp, or `nil` if it doesn't have a valid time @@ -102,8 +102,6 @@ Meta methods: ### `tab::Config` -TODO - Properties: - `sort_by` @@ -113,23 +111,23 @@ Properties: - `linemode` - `show_hidden` -### `tab::Preview` +These properties are consistent with those in [yazi.toml](../configuration/yazi.md), and will not be detailed here. -TODO +### `tab::Preview` Properties: -- `skip` -- `folder` +- `skip` - The number of units to skip. The units largely depend on your previewer, such as lines for code and percentages for videos. +- `folder` - The [folder::Folder](#folderfolder) being previewed, or `nil` if this preview is not for folders ### `folder::Folder` -- cwd -- offset -- cursor -- window -- files -- hovered +- `cwd` - The current working directory of this folder, which is a [Url](#url) +- `offset` - The offset of this folder, which is an integer +- `cursor` - The cursor position of this folder, which is an integer +- `window` - A table of [File](#file)s in the visible area of this folder +- `files` - The [Files](#folderfiles) of this folder +- `hovered` - The hovered [File](#file) of this folder, or `nil` if there is no hovered file ### `folder::Files` @@ -142,7 +140,7 @@ Meta methods: Based on [File](#file), with the following additional methods: -- `size()` - The size of this file, returns a integer representing the size in bytes, or `nil` if its a directory and it has not been scanned +- `size()` - The size of this file, returns an integer representing the size in bytes, or `nil` if its a directory and it has not been scanned - `mime()` - The mime-type string of this file - `prefix()` - The prefix of this file relative to `CWD`, which used in the flat view during search. For instance, if `CWD` is `/foo`, and the file is `/foo/bar/baz`, then the prefix is `bar/` - `icon()` - The [Icon](#icon) of this file, [`[icon]`](../configuration/theme.md#icons) rules are applied; if no rule matches, returns `nil` diff --git a/docs/plugins/overview.md b/docs/plugins/overview.md index 30f8b23c..fce8c244 100644 --- a/docs/plugins/overview.md +++ b/docs/plugins/overview.md @@ -77,7 +77,7 @@ You can also obtain a small amount of app data from the sync context by calling local get_hovered_url = sync(function() -- You can access all app data through the `cx`, - -- within the `sync()` block, in a async plugin + -- within the `sync()` block, in an async plugin local h = cx.active.current.hovered return h and tostring(h.url) or "" end) diff --git a/docs/plugins/utils.md b/docs/plugins/utils.md index 6f1db2a9..64247c63 100644 --- a/docs/plugins/utils.md +++ b/docs/plugins/utils.md @@ -98,7 +98,7 @@ Returns the target family of the current platform, `"windows"`, `"unix"`, or `"w Truncate the text to the specified length and return it: - `text` - Required, the text to be truncated, which is a string -- `max` - Required, the maximum length of the text, which is a integer +- `max` - Required, the maximum length of the text, which is an integer ### `mime_valid(mime)` @@ -112,11 +112,11 @@ Returns the current timestamp, which is a float, the integer part represents the ### `uid()` -Returns the user id of the current user, which is a integer. +Returns the user id of the current user, which is an integer. ### `gid()` -Returns the group id of the current user, which is a integer. +Returns the group id of the current user, which is an integer. ### `user_name()` @@ -142,7 +142,7 @@ Write data to the specified file: Returns `(ok, err)`: - `ok` - Whether the operation is successful, which is a boolean -- `err` - The error code if the operation is failed, which is a integer if any +- `err` - The error code if the operation is failed, which is an integer if any ### `cha(url)` @@ -157,7 +157,7 @@ Get the [Cha](./common.md#cha) of the specified file, which is faster than [`cha Returns `(cha, err)`: - `cha` - The [Cha](./common.md#cha) of the file if successful; otherwise, `nil` -- `err` - The error code if the operation is failed, which is a integer if any +- `err` - The error code if the operation is failed, which is an integer if any ### `cha_follow(url)` @@ -172,7 +172,7 @@ Get the [Cha](./common.md#cha) of the specified file, and follow the symbolic li Returns `(cha, err)`: - `cha` - The [Cha](./common.md#cha) of the file if successful; otherwise, `nil` -- `err` - The error code if the operation is failed, which is a integer if any +- `err` - The error code if the operation is failed, which is an integer if any ## Command @@ -280,7 +280,7 @@ local child, err = Command("ls"):spawn() Spawn the command, returns `(child, err)`: - `child` - The [Child](#child) of the command if successful; otherwise, `nil` -- `err` - The error code if the operation is failed, which is a integer if any +- `err` - The error code if the operation is failed, which is an integer if any ### `output()` @@ -291,7 +291,7 @@ local output, err = Command("ls"):output() Spawn the command and wait for it to finish, returns `(output, err)`: - `output` - The [Output](#output-1) of the command if successful; otherwise, `nil` -- `err` - The error code if the operation is failed, which is a integer if any +- `err` - The error code if the operation is failed, which is an integer if any ## Child @@ -329,7 +329,7 @@ local line, event = child:wait_line_with { timeout = 500 } Similar to [`read_line()`](#read_line), but it accepts a table of options: -- `timeout` - Required, timeout in milliseconds, which is a integer +- `timeout` - Required, timeout in milliseconds, which is an integer And includes the following additional events: @@ -344,7 +344,7 @@ local status, err = child:wait() Wait for the child process to finish, returns `(status, err)`: - `status` - The [Status](#status) of the child process if successful; otherwise, `nil` -- `err` - The error code if the operation is failed, which is a integer if any +- `err` - The error code if the operation is failed, which is an integer if any ### `start_kill()` @@ -355,7 +355,7 @@ local ok, err = child:start_kill() Send a SIGTERM signal to the child process, returns `(ok, err)`: - `ok` - Whether the operation is successful, which is a boolean -- `err` - The error code if the operation is failed, which is a integer if any +- `err` - The error code if the operation is failed, which is an integer if any ## Output @@ -383,4 +383,4 @@ Returns whether the child process exited successfully, which is a boolean. local code = status:code() ``` -Returns the exit code of the child process, which is a integer if any. +Returns the exit code of the child process, which is an integer if any. diff --git a/docs/tips.md b/docs/tips.md index 04473dce..69189073 100644 --- a/docs/tips.md +++ b/docs/tips.md @@ -92,7 +92,7 @@ To exiting input directly, without entering Vi mode, making it behave like a reg ## Smart enter: `enter` for directory, `open` for file -Save those lines as `~/.config/yazi/plugins/smart-enter.yazi/init.lua`: +Save these lines as `~/.config/yazi/plugins/smart-enter.yazi/init.lua`: ```lua return { @@ -125,7 +125,7 @@ Please make sure that `` does not conflict with your other keys. -Save those lines as a file, for example `~/.config/yazi/ui.lua`: +Save these lines as a file, for example `~/.config/yazi/ui.lua`: ```lua function Status:render() return {} end