From 41391485f36ca862a1cab4a116c2e8548eff8114 Mon Sep 17 00:00:00 2001 From: sxyazi Date: Mon, 15 Jan 2024 01:19:45 +0800 Subject: [PATCH] docs: add heic plugin example --- docs/configuration/yazi.md | 18 +++++++++++++++++- docs/plugins/overview.md | 14 +++++++------- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/docs/configuration/yazi.md b/docs/configuration/yazi.md index 6ef3c0bb..93837d32 100644 --- a/docs/configuration/yazi.md +++ b/docs/configuration/yazi.md @@ -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 @@ -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 @@ -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 diff --git a/docs/plugins/overview.md b/docs/plugins/overview.md index 0b43b7bb..30f8b23c 100644 --- a/docs/plugins/overview.md +++ b/docs/plugins/overview.md @@ -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) @@ -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.