Skip to content

Commit

Permalink
docs: ya.hide() plugin API
Browse files Browse the repository at this point in the history
  • Loading branch information
sxyazi committed Mar 8, 2024
1 parent c10afb7 commit a5bdc14
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions docs/plugins/utils.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,24 @@ description: Learn how to use Yazi's Lua API.

## ya

### `hide()`

Hide Yazi to the secondary screen by returning to the terminal, completely controlled by the requested plugin.

```lua
local permit = ya.hide()
```

This method returns a `permit` for this resource. When it's necessary to restore the TUI display, call its `drop()` method:

```lua
permit:drop()
```

Note that since there's always only one available terminal control resource, `ya.hide()` cannot be called again before the previous `permit` is dropped, otherwise an error will be thrown, effectively avoiding deadlocks.

This function is only available in the async context.

### `file_cache(opts)`

Calculate the cached [Url](/docs/plugins/types#url) corresponding to the given file:
Expand Down Expand Up @@ -62,7 +80,7 @@ Prompt users with a set of available keys:
- `silent`: Optional, whether to show the UI of key indicator, which is a boolean

```lua
local key = ya.which {
local cand = ya.which {
cands = {
{ on = "a" },
{ on = "b", desc = "optional description" },
Expand All @@ -73,7 +91,7 @@ local key = ya.which {
}
```

When the user clicks a valid candidate, `ya.which` returns the 1-based index of that "cand";
When the user clicks a valid candidate, `ya.which` returns the 1-based index of that `cand`;
otherwise, it returns nil, indicating that the user has canceled the key operation.

This function is only available in the async context.
Expand Down

0 comments on commit a5bdc14

Please sign in to comment.