Skip to content

Commit

Permalink
docs: add folder::Folder docs
Browse files Browse the repository at this point in the history
  • Loading branch information
sxyazi committed Jan 14, 2024
1 parent d94d623 commit e845d77
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 31 deletions.
4 changes: 2 additions & 2 deletions docs/configuration/yazi.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
26 changes: 12 additions & 14 deletions docs/plugins/common.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -102,8 +102,6 @@ Meta methods:

### `tab::Config`

TODO

Properties:

- `sort_by`
Expand All @@ -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`

Expand All @@ -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`
Expand Down
2 changes: 1 addition & 1 deletion docs/plugins/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
24 changes: 12 additions & 12 deletions docs/plugins/utils.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)`

Expand All @@ -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()`

Expand All @@ -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)`

Expand All @@ -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)`

Expand All @@ -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

Expand Down Expand Up @@ -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()`

Expand All @@ -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

Expand Down Expand Up @@ -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:

Expand All @@ -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()`

Expand All @@ -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

Expand Down Expand Up @@ -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.
4 changes: 2 additions & 2 deletions docs/tips.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -125,7 +125,7 @@ Please make sure that `<C-n>` does not conflict with your other keys.

<img src={useBaseUrl("/img/no-status-bar.jpg")} width="600" />

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
Expand Down

0 comments on commit e845d77

Please sign in to comment.