Skip to content

Commit

Permalink
docs: add heic plugin example
Browse files Browse the repository at this point in the history
  • Loading branch information
sxyazi committed Jan 14, 2024
1 parent 893795f commit 4139148
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
18 changes: 17 additions & 1 deletion docs/configuration/yazi.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,14 @@ Here are the available options for a single rule:
- `exec` (String): The name of the Lua plugin to be executed
- `sync` (Boolean): Whether to execute synchronously, the default is `false`

```toml
[plugin]
prepend_previewers = [
# Heic previewer
{ mime = "image/heic", exec = "heic" },
]
```

Yazi comes with the those previewer plugins:

- folder: bridge between the Yazi file system and the preview
Expand All @@ -165,7 +173,7 @@ Yazi comes with the those previewer plugins:
- pdf: bridge between `pdftoppm` and the preview, offering mixed preview capabilities
- archive: bridge between `unar` and the preview, offering mixed preview and concurrent rendering capabilities

If you want to create your own preloader, see [Previewer API](../plugins/overview.md#previewer).
If you want to create your own previewer, see [Previewer API](../plugins/overview.md#previewer).

### preloaders

Expand All @@ -180,6 +188,14 @@ Here are the available options for a single rule:
- `multi` (Boolean): Whether to preload multiple files at once
- `prio` (String): Preload priority, `low`, `normal` or `high`. The default is `normal` if not specified.

```toml
[plugin]
prepend_previewers = [
# Heic preloader
{ mime = "image/heic", exec = "heic" },
]
```

Yazi comes with the those preloader plugins:

- mime: preloads mime-type of files in chunks
Expand Down
14 changes: 7 additions & 7 deletions docs/plugins/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,19 +106,19 @@ A previewer needs to return an table that implements the `peek` and `seek` funct

When the user presses `j` or `k` to switch between hovering files, `peek` is called, with:

- `file`: The file to be previewed.
- `file`: The [File](./common.md#file) to be previewed.
- `skip`: The number of units to skip. The units largely depend on your previewer, such as lines for code and percentages for videos.
- `area`: The Rect of the available preview area.
- `window`: The Rect of the entire terminal window.
- `area`: The [Rect](./layout.md#rect) of the available preview area.
- `window`: The [Rect](./layout.md#rect) of the entire terminal window.

When the user presses `Alt-j` or `Alt-k` to scroll the preview of this file, `seek` is called, with:

- `file`: The file being scrolled.
- `area`: The Rect of the available preview area.
- `file`: The [File](./common.md#file) being scrolled.
- `area`: The [Rect](./layout.md#rect) of the available preview area.

The task of `peek` is to draw in the preview area based on the values of `file` and `skip`. This process is asynchronous.

The task of `seek` is to change the value of `skip` based on user behavior and trigger `peek` again. It is synchronous, meaning you can access app data through `cx`.
The task of `seek` is to change the value of `skip` based on user behavior and trigger `peek` again. It is synchronous, meaning you can access [app data](./common.md#app-data) through `cx`.

Here are some preset previewers and preloaders you can refer to: [Yazi Preset Plugins](https://github.com/sxyazi/yazi/tree/main/yazi-plugin/preset/plugins)

Expand Down Expand Up @@ -148,7 +148,7 @@ When "continue" is set, the preloader can reload the files that have already bee

Yazi will automatically invoke the `preload` concurrently for each file that matches the preload rules on the page.

When the user specifies `multi = true` for it, the plugin allows preloading multiple files at once. In this case, `self.file` will be replaced by `self.files`.
When the user specifies [`multi = true`](../configuration/yazi.md#preloaders) for it, the plugin allows preloading multiple files at once. In this case, `self.file` will be replaced by `self.files`.

Typically, a preloader only needs to implement one of them - either single or multiple. This depends on the specific task and the magnitude of the workload.
If it truly requires loading multiple files at once, the user needs to be prompted to enable the `multi` option for it.

0 comments on commit 4139148

Please sign in to comment.