refactor: use the term "action" instead of "command" (#3694)

This commit is contained in:
三咲雅 misaki masa 2026-02-17 16:12:16 +08:00 committed by sxyazi
parent 7f339381f1
commit 578016e00f
No known key found for this signature in database
112 changed files with 632 additions and 625 deletions

View file

@ -92,11 +92,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/):
- New experimental `ya.async()` API ([#3422]) - New experimental `ya.async()` API ([#3422])
- New `overall` option to set the overall background color ([#3317]) - New `overall` option to set the overall background color ([#3317])
- Rounded corners for indicator bar ([#3419]) - Rounded corners for indicator bar ([#3419])
- New `bulk_rename` command always renames files with the editor ([#2984]) - New `bulk_rename` action always renames files with the editor ([#2984])
- `key-*` DDS events to allow changing or canceling user key events ([#3005], [#3037]) - `key-*` DDS events to allow changing or canceling user key events ([#3005], [#3037])
- New `--bg` specifying image background color in the preset SVG and ImageMagick previewers ([#3189]) - New `--bg` specifying image background color in the preset SVG and ImageMagick previewers ([#3189])
- `filter` by full path (prefix + filename) in search view instead of just filename ([#2915]) - `filter` by full path (prefix + filename) in search view instead of just filename ([#2915])
- New `casefy` command for case conversion of the input content ([#3235]) - New `casefy` action for case conversion of the input content ([#3235])
- Allow dynamic adjustment of layout ratio via `rt.mgr.ratio` ([#2964]) - Allow dynamic adjustment of layout ratio via `rt.mgr.ratio` ([#2964])
- Support `.deb` packages ([#2807], [#3128], [#3209]) - Support `.deb` packages ([#2807], [#3128], [#3209])
- Port several widespread GUI keys to the input component ([#2849]) - Port several widespread GUI keys to the input component ([#2849])
@ -117,7 +117,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/):
- Rename `name` to `url` for open, fetchers, spotters, preloaders, previewers, filetype, and `globs` icon rules to support virtual file system ([#3034]) - Rename `name` to `url` for open, fetchers, spotters, preloaders, previewers, filetype, and `globs` icon rules to support virtual file system ([#3034])
- Rename `mime` fetcher to `mime.local`, and introduce `mime.dir` fetcher to support folder MIME types ([#3222]) - Rename `mime` fetcher to `mime.local`, and introduce `mime.dir` fetcher to support folder MIME types ([#3222])
- Reclassify `hovered` and `preview_hovered` under `[mgr]` of `theme.toml` into `[indicator]` as `current` and `preview`, respectively ([#3419]) - Reclassify `hovered` and `preview_hovered` under `[mgr]` of `theme.toml` into `[indicator]` as `current` and `preview`, respectively ([#3419])
- Remove `$0` parameter in opener rules to make the `open` command work under empty directories ([#3226]) - Remove `$0` parameter in opener rules to make the `open` action work under empty directories ([#3226])
- Return `Path` instead of `Url` from `Url:strip_prefix()` and `File.link_to` to enforce type safety ([#3361], [#3385]) - Return `Path` instead of `Url` from `Url:strip_prefix()` and `File.link_to` to enforce type safety ([#3361], [#3385])
- Use `body` instead of the term `content` in confirmations ([#2921]) - Use `body` instead of the term `content` in confirmations ([#2921])
- Use `u16` instead of `u32` as the type of `max_width` and `max_height` options to avoid memory exhaustion ([#3313]) - Use `u16` instead of `u32` as the type of `max_width` and `max_height` options to avoid memory exhaustion ([#3313])
@ -125,7 +125,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/):
### Deprecated ### Deprecated
- Deprecate `$n`, `$@` (\*nix) and `%n`, `%*` (Windows) in `shell` command and opener rules in favor of new shell formatting ([#3232]) - Deprecate `$n`, `$@` (\*nix) and `%n`, `%*` (Windows) in `shell` action and opener rules in favor of new shell formatting ([#3232])
- Deprecate `ya.hide`, `ya.render`, and `ya.truncate` in favor of `ui.hide`, `ui.render`, and `ui.truncate` ([#2939]) - Deprecate `ya.hide`, `ya.render`, and `ya.truncate` in favor of `ui.hide`, `ui.render`, and `ui.truncate` ([#2939])
- Deprecate `position` property of `ya.input()` in favor of `pos` to align with `ya.confirm()` and its type `ui.Pos` ([#2921]) - Deprecate `position` property of `ya.input()` in favor of `pos` to align with `ya.confirm()` and its type `ui.Pos` ([#2921])
- Deprecate `cx.tasks.progress` in favor of `cx.tasks.summary` ([#3131]) - Deprecate `cx.tasks.progress` in favor of `cx.tasks.summary` ([#3131])
@ -136,7 +136,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/):
- User-prepended open rules do not override presets ([#3360]) - User-prepended open rules do not override presets ([#3360])
- Respect user's system media opener instead of hardcoding `mpv` ([#2959]) - Respect user's system media opener instead of hardcoding `mpv` ([#2959])
- Incorrect `$0` and `$@` parameters in `shell` command under empty directories ([#3225]) - Incorrect `$0` and `$@` parameters in `shell` action under empty directories ([#3225])
- Avoid appending a newline when reading clipboard contents ([#3059]) - Avoid appending a newline when reading clipboard contents ([#3059])
- Renew package `rev` only when it's empty ([#3200]) - Renew package `rev` only when it's empty ([#3200])
- Suspend only when there is a parent process ([#3008]) - Suspend only when there is a parent process ([#3008])
@ -190,15 +190,15 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/):
- New `ya.emit()` API ([#2653]) - New `ya.emit()` API ([#2653])
- New `fs.calc_size()` API ([#2691]) - New `fs.calc_size()` API ([#2691])
- Allow custom exit code with `quit --code` ([#2609]) - Allow custom exit code with `quit --code` ([#2609])
- New `--hovered` for the `copy` command ([#2709]) - New `--hovered` for the `copy` action ([#2709])
- `s` and `S` keybinds in the input component ([#2678]) - `s` and `S` keybinds in the input component ([#2678])
- Limit memory usage for previewing large images ([#2602]) - Limit memory usage for previewing large images ([#2602])
- Show error when image preview fails ([#2706]) - Show error when image preview fails ([#2706])
- New `ui.Align`, `ui.Wrap`, and `ui.Edge` ([#2802]) - New `ui.Align`, `ui.Wrap`, and `ui.Edge` ([#2802])
- Make `ui.Line` renderable ([#2743]) - Make `ui.Line` renderable ([#2743])
- Checks in `ya pub` and `ya emit` subcommands to verify receiver exists and has necessary abilities ([#2696]) - Checks in `ya pub` and `ya emit` subcommands to verify receiver exists and has necessary abilities ([#2696])
- Make the hover state for `reveal`, `sort`, and `hidden` commands stable ([#2657]) - Make the hover state for `reveal`, `sort`, and `hidden` actions stable ([#2657])
- New `--no-dummy` option for `reveal` command ([#2664]) - New `--no-dummy` option for `reveal` action ([#2664])
- Fall back to `CSI 16 t` when PowerShell OpenSSH returns a fake terminal size ([#2636]) - Fall back to `CSI 16 t` when PowerShell OpenSSH returns a fake terminal size ([#2636])
### Changed ### Changed
@ -242,7 +242,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/):
- Enhance `fzf` integration ([#2553]) - Enhance `fzf` integration ([#2553])
- Platform-specific key binding ([#2526]) - Platform-specific key binding ([#2526])
- Custom search engine Lua API ([#2452]) - Custom search engine Lua API ([#2452])
- New `follow` command to follow files pointed to by symlinks ([#2543]) - New `follow` action to follow files pointed to by symlinks ([#2543])
- Allow `tab_swap` to cycle tabs ([#2456]) - Allow `tab_swap` to cycle tabs ([#2456])
- Show error message when directory fails to load ([#2527]) - Show error message when directory fails to load ([#2527])
- New `symlink_target` to style the target of symbolic links ([#2522]) - New `symlink_target` to style the target of symbolic links ([#2522])
@ -250,7 +250,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/):
- New `<C-A>` and `<C-E>` keybindings to select entire line for the input component ([#2439]) - New `<C-A>` and `<C-E>` keybindings to select entire line for the input component ([#2439])
- New `fs.expand_url()` API ([#2476]) - New `fs.expand_url()` API ([#2476])
- New `ui.Text:scroll()` API for setting text to scroll horizontally or vertically ([#2589]) - New `ui.Text:scroll()` API for setting text to scroll horizontally or vertically ([#2589])
- Allow initializing input when opening it with commands like `rename`, `create`, `find`, `filter`, etc. ([#2578]) - Allow initializing input when opening it with actions like `rename`, `create`, `find`, `filter`, etc. ([#2578])
- New `@sync peek` annotation for sync previewers ([#2487]) - New `@sync peek` annotation for sync previewers ([#2487])
- New `ya.id("app")` to get `YAZI_ID` in plugins ([#2503]) - New `ya.id("app")` to get `YAZI_ID` in plugins ([#2503])
- New `base` field for the `Url` ([#2492]) - New `base` field for the `Url` ([#2492])
@ -260,7 +260,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/):
### Changed ### Changed
- Navigation wraparound with new `arrow prev` and `arrow next` commands ([#2485], [#2540]) - Navigation wraparound with new `arrow prev` and `arrow next` actions ([#2485], [#2540])
- Swap default key bindings for fzf and zoxide ([#2546]) - Swap default key bindings for fzf and zoxide ([#2546])
- Switch to `resvg` as the SVG renderer ([#2581]) - Switch to `resvg` as the SVG renderer ([#2581])
- Make `frag`, `name`, `stem`, `ext`, and `parent` on `Url`, `name` on `tab::Tab`, and `is_hovered` on `fs::File` properties ([#2572]) - Make `frag`, `name`, `stem`, `ext`, and `parent` on `Url`, `name` on `tab::Tab`, and `is_hovered` on `fs::File` properties ([#2572])
@ -302,11 +302,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/):
### Added ### Added
- Allow to specify layer for keymap commands ([#2399]) - Allow to specify layer for keymap actions ([#2399])
- New `rt` and `th` allow to access user configuration and theme scheme in sync/async plugins consistently ([#2389], [#2392], [#2393], [#2397]) - New `rt` and `th` allow to access user configuration and theme scheme in sync/async plugins consistently ([#2389], [#2392], [#2393], [#2397])
- New `tbl_col` and `tbl_cell` in theme system for spotter table styling ([#2391]) - New `tbl_col` and `tbl_cell` in theme system for spotter table styling ([#2391])
- Allow different separators to be applied individually to the left and right sides of the status bar ([#2313]) - Allow different separators to be applied individually to the left and right sides of the status bar ([#2313])
- `ripgrep-all` support for the `search` command ([#2383]) - `ripgrep-all` support for the `search` action ([#2383])
- Respect the user's `max_width` setting in the preset PDF preloader ([#2331]) - Respect the user's `max_width` setting in the preset PDF preloader ([#2331])
- Respect the user's `wrap` setting in the preset JSON previewer ([#2337]) - Respect the user's `wrap` setting in the preset JSON previewer ([#2337])
- Respect the user's `image_alloc` setting in the preset ImageMagick previewer ([#2403]) - Respect the user's `image_alloc` setting in the preset ImageMagick previewer ([#2403])
@ -347,15 +347,15 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/):
- Mount manager ([#2199]) - Mount manager ([#2199])
- New `ya.confirm()` API ([#2095]) - New `ya.confirm()` API ([#2095])
- New `arrow top` and `arrow bot` commands to jump to the top and bottom ([#2294]) - New `arrow top` and `arrow bot` actions to jump to the top and bottom ([#2294])
- Support end of options (`--`) marker for all commands ([#2298]) - Support end of options (`--`) marker for all actions ([#2298])
- Replace mode and Vim motions (`W`, `E`, `B`, `^`, `_`) for inputs ([#2143]) - Replace mode and Vim motions (`W`, `E`, `B`, `^`, `_`) for inputs ([#2143])
- New `ya pack -d` subcommand to delete packages ([#2181]) - New `ya pack -d` subcommand to delete packages ([#2181])
- `ya pack` supports adding and deleting multiple packages at once ([#2257]) - `ya pack` supports adding and deleting multiple packages at once ([#2257])
- Theme support for the spotter border and title ([#2002]) - Theme support for the spotter border and title ([#2002])
- Use positional argument instead of `--args` for the `plugin` command ([#2299]) - Use positional argument instead of `--args` for the `plugin` action ([#2299])
- Support and hide Windows system files by default ([#2149]) - Support and hide Windows system files by default ([#2149])
- New `--no-cwd-file` option for the `close` command ([#2185]) - New `--no-cwd-file` option for the `close` action ([#2185])
- Prompt users missing fzf in the zoxide plugin ([#2122]) - Prompt users missing fzf in the zoxide plugin ([#2122])
- More decent package locking mechanism ([#2168]) - More decent package locking mechanism ([#2168])
- Custom modal component API ([#2205]) - Custom modal component API ([#2205])
@ -371,7 +371,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/):
### Deprecated ### Deprecated
- Deprecate `--args` in the `plugin` command in favor of a 2nd positional parameter ([#2299]) - Deprecate `--args` in the `plugin` action in favor of a 2nd positional parameter ([#2299])
- Deprecate plugin entry file `init.lua` in favor of `main.lua` ([#2168]) - Deprecate plugin entry file `init.lua` in favor of `main.lua` ([#2168])
- Deprecate `arrow -99999999` and `arrow 99999999` in favor of `arrow top` and `arrow bot` ([#2294]) - Deprecate `arrow -99999999` and `arrow 99999999` in favor of `arrow top` and `arrow bot` ([#2294])
- Deprecate the numeric return value of preloaders in favor of a boolean return value ([#2253]) - Deprecate the numeric return value of preloaders in favor of a boolean return value ([#2253])
@ -398,7 +398,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/):
- More supported archive formats to the preset config ([#1926]) - More supported archive formats to the preset config ([#1926])
- New `fs.create()` Lua API ([#2068]) - New `fs.create()` Lua API ([#2068])
- New `--cwd` parameter for the `shell` command and `fs.cwd()` API ([#2060]) - New `--cwd` parameter for the `shell` action and `fs.cwd()` API ([#2060])
- Allow `noop` for single-key chords by removing the mixing length limit ([#2064]) - Allow `noop` for single-key chords by removing the mixing length limit ([#2064])
- Support for Android platform in the `for` qualifier of opener ([#2041]) - Support for Android platform in the `for` qualifier of opener ([#2041])
@ -427,8 +427,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/):
- Spotter ([#1802]) - Spotter ([#1802])
- Support transparent image preview ([#1556]) - Support transparent image preview ([#1556])
- Auto switch between dark and light icons/flavors based on terminal backgrounds ([#1946]) - Auto switch between dark and light icons/flavors based on terminal backgrounds ([#1946])
- Allow disabling certain preset keybinds with the new `noop` virtual command ([#1882]) - Allow disabling certain preset keybinds with the new `noop` virtual action ([#1882])
- New `ya emit` and `ya emit-to` subcommands to emit commands to a specified instance for execution ([#1979]) - New `ya emit` and `ya emit-to` subcommands to emit actions to a specified instance for execution ([#1979])
- Custom styles for the `confirm` component ([#1789]) - Custom styles for the `confirm` component ([#1789])
- Make the builtin `extract` plugin support compressed tarballs (`*.tar.gz`, `*.tar.bz2`, etc.) ([#1583]) - Make the builtin `extract` plugin support compressed tarballs (`*.tar.gz`, `*.tar.bz2`, etc.) ([#1583])
- Launch from preset settings if the user's config cannot be parsed ([#1832]) - Launch from preset settings if the user's config cannot be parsed ([#1832])
@ -462,15 +462,15 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/):
- Use an `Error` userdata instead of a plain error code for I/O errors ([#1939]) - Use an `Error` userdata instead of a plain error code for I/O errors ([#1939])
- Remove `ui.ListItem` since it's no longer necessary ([#1772]) - Remove `ui.ListItem` since it's no longer necessary ([#1772])
- Decouple coordinates from `ui.List`, `ui.Bar`, `ui.Border`, and `ui.Gauge` ([#1782]) - Decouple coordinates from `ui.List`, `ui.Bar`, `ui.Border`, and `ui.Gauge` ([#1782])
- Make `backspace` command not close the input even when value is empty ([#1680]) - Make `backspace` action not close the input even when value is empty ([#1680])
- Remove the meaningless `--confirm` option to simplify the `shell` command ([#1982]) - Remove the meaningless `--confirm` option to simplify the `shell` action ([#1982])
- Use `dark` and `light` instead of `use` under `[flavor]` to support auto-switching between light and dark modes ([#1946]) - Use `dark` and `light` instead of `use` under `[flavor]` to support auto-switching between light and dark modes ([#1946])
- Unify the `fg_dark` and `fg_light` into one `fg` since `fg_light` is redundant and never used ([#1946]) - Unify the `fg_dark` and `fg_light` into one `fg` since `fg_light` is redundant and never used ([#1946])
- Extend the available styles for `mode` by separating `mode` from the `separator` styles ([#1953]) - Extend the available styles for `mode` by separating `mode` from the `separator` styles ([#1953])
### Deprecated ### Deprecated
- Deprecate `--sync` option for the `plugin` command ([#1891]) - Deprecate `--sync` option for the `plugin` action ([#1891])
- Deprecate `ui.Paragraph` in favor of `ui.Text` ([#1776]) - Deprecate `ui.Paragraph` in favor of `ui.Text` ([#1776])
- Deprecate the task info of `peek()`, `seek()`, and `preload()` from `self` in favor of a `job` parameter ([#1966]) - Deprecate the task info of `peek()`, `seek()`, and `preload()` from `self` in favor of a `job` parameter ([#1966])
- Deprecate parameter list of `entry()` from its first argument in favor of a `job` parameter ([#1966]) - Deprecate parameter list of `entry()` from its first argument in favor of a `job` parameter ([#1966])
@ -527,7 +527,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/):
- New confirm component ([#1167]) - New confirm component ([#1167])
- Word wrapping in `code` previewer ([#1159]) - Word wrapping in `code` previewer ([#1159])
- New `--dir` option for `create` command ([#1505]) - New `--dir` option for `create` action ([#1505])
- New `ext()` method for `Url` ([#1528]) - New `ext()` method for `Url` ([#1528])
- Make the builtin `code` previewer handle invalid carriage return chars and binary streams better ([#1550]) - Make the builtin `code` previewer handle invalid carriage return chars and binary streams better ([#1550])
@ -550,10 +550,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/):
- Start with multiple tabs with different paths ([#1443]) - Start with multiple tabs with different paths ([#1443])
- Key notion shorthands such as `<C-S-x>` as `<C-X>` ([#1448]) - Key notion shorthands such as `<C-S-x>` as `<C-X>` ([#1448])
- Support `F13` - `F19` keys ([#1446]) - Support `F13` - `F19` keys ([#1446])
- New `--cursor` for the `shell` command ([#1422]) - New `--cursor` for the `shell` action ([#1422])
- New `search_do` command to make it easier to achieve a flat view ([#1431]) - New `search_do` action to make it easier to achieve a flat view ([#1431])
- Portrait orientation preview for EXIF image ([#1412]) - Portrait orientation preview for EXIF image ([#1412])
- Keybinding for the `hardlink` command ([#1461]) - Keybinding for the `hardlink` action ([#1461])
- New `empty` previewer for empty and `/proc/*` files ([#1482]) - New `empty` previewer for empty and `/proc/*` files ([#1482])
- Note about filtering in the help menu ([#1361]) - Note about filtering in the help menu ([#1361])
- New `tab` DDS event on tab switch ([#1474]) - New `tab` DDS event on tab switch ([#1474])
@ -581,12 +581,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/):
- Font preview ([#1048]) - Font preview ([#1048])
- SVG, HEIC, AVIF, and JPEG XL preview support ([#1050], [#1249]) - SVG, HEIC, AVIF, and JPEG XL preview support ([#1050], [#1249])
- Simplify keybindings ([#1241]) - Simplify keybindings ([#1241])
- New command `hardlink` to create hard links ([#1268]) - New `hardlink` action to create hard links ([#1268])
- Keep file creation time on macOS and Windows ([#1169]) - Keep file creation time on macOS and Windows ([#1169])
- Sort randomly ([#1291]) - Sort randomly ([#1291])
- New linemode to show file ownership ([#1238]) - New linemode to show file ownership ([#1238])
- New linemode to show file ctime ([#1295]) - New linemode to show file ctime ([#1295])
- New `--hovered` option for the `rename` and `remove` commands ([#1227]) - New `--hovered` option for the `rename` and `remove` actions ([#1227])
- Support Super/Command/Windows key with `D-` notation ([#1069]) - Support Super/Command/Windows key with `D-` notation ([#1069])
- Interactive `cd` path auto-completion supports `~` expansion ([#1081]) - Interactive `cd` path auto-completion supports `~` expansion ([#1081])
- Preview files containing non-UTF-8 characters ([#958]) - Preview files containing non-UTF-8 characters ([#958])
@ -611,7 +611,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/):
- Use Ctrl+c instead of Ctrl+q as the universal close key to follow the conventions - Use Ctrl+c instead of Ctrl+q as the universal close key to follow the conventions
- Replace Alt+k/Alt+j with K/J as the `seek` keybindings to avoid Alt key not working in certain terminals - Replace Alt+k/Alt+j with K/J as the `seek` keybindings to avoid Alt key not working in certain terminals
- Replace Ctrl+Enter with Shift+Enter as the alternative key for Shift+o so that it corresponds to Enter being `o` (without Shift) - Replace Ctrl+Enter with Shift+Enter as the alternative key for Shift+o so that it corresponds to Enter being `o` (without Shift)
- keep original state of `sort` command in favor of specifying `yes` or `no` to explicitly apply a new state to its `--reverse`, `--dir-first`, and `--translit` - keep original state of `sort` action in favor of specifying `yes` or `no` to explicitly apply a new state to its `--reverse`, `--dir-first`, and `--translit`
- Move `mime` plugin from `[plugin.preloaders]` to `[plugin.fetchers]` of yazi.toml - Move `mime` plugin from `[plugin.preloaders]` to `[plugin.fetchers]` of yazi.toml
- Turn `success` and `code` into properties of `Status` instead of methods - Turn `success` and `code` into properties of `Status` instead of methods
- Remove `fs.cha_follow(url)` in favor of `fs.cha(url, true)` - Remove `fs.cha_follow(url)` in favor of `fs.cha(url, true)`
@ -638,7 +638,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/):
- Data distribution service ([#826], [#855], [#861], [#867], [#868], [#871], [#880], [#895], [#913], [#928], [#933], [#940]) - Data distribution service ([#826], [#855], [#861], [#867], [#868], [#871], [#880], [#895], [#913], [#928], [#933], [#940])
- Re-implement fzf and zoxide as built-in plugins ([#884], [#881]) - Re-implement fzf and zoxide as built-in plugins ([#884], [#881])
- Preserve files' modified at timestamp while copying ([#926]) - Preserve files' modified at timestamp while copying ([#926])
- New `--orphan` option for `shell` command ([#887]) - New `--orphan` option for `shell` action ([#887])
- Smart-case for completion of interactive `cd` paths ([#910]) - Smart-case for completion of interactive `cd` paths ([#910])
- Allow creating a tab with the startup directory through `tab_create` without specifying a path ([#917]) - Allow creating a tab with the startup directory through `tab_create` without specifying a path ([#917])
- Bunch of new debugging information to `yazi --debug` ([#824]) - Bunch of new debugging information to `yazi --debug` ([#824])
@ -651,7 +651,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/):
### Deprecated ### Deprecated
- Deprecate the `jump` command in favor of `plugin fzf` and `plugin zoxide` ([#884], [#881]) - Deprecate the `jump` action in favor of `plugin fzf` and `plugin zoxide` ([#884], [#881])
### Fixed ### Fixed
@ -683,7 +683,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/):
- New `<Home>`, `<End>`, and `<Delete>` keybindings for inputs ([#665]) - New `<Home>`, `<End>`, and `<Delete>` keybindings for inputs ([#665])
- New `<C-p>` and `<C-n>` for the select component to move the cursor up/down ([#779]) - New `<C-p>` and `<C-n>` for the select component to move the cursor up/down ([#779])
- New `Ctrl+[` as an alternative to the escape key ([#763]) - New `Ctrl+[` as an alternative to the escape key ([#763])
- New option `--hovered` for the `open` command allows only to open the currently hovered file ([#687]) - New option `--hovered` for the `open` action allows only to open the currently hovered file ([#687])
- Support musl builds for Linux ([#759]) - Support musl builds for Linux ([#759])
- New `--debug` flag to print debug information ([#794]) - New `--debug` flag to print debug information ([#794])
- Send a foreground notification to the user when the process fails to run ([#775]) - Send a foreground notification to the user when the process fails to run ([#775])
@ -694,7 +694,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/):
- Ability to sort candidates in the which component ([#662]) - Ability to sort candidates in the which component ([#662])
- Expose selected/yanked files as Lua API ([#674]) - Expose selected/yanked files as Lua API ([#674])
- New `cx.yanked` API to access yanked files ([#788]) - New `cx.yanked` API to access yanked files ([#788])
- New `$0` (Unix) / `%0` (Windows) to access the hovered file in `shell` command ([#738]) - New `$0` (Unix) / `%0` (Windows) to access the hovered file in `shell` action ([#738])
- New `ya.hide()` API to hide the UI temporarily ([#792]) - New `ya.hide()` API to hide the UI temporarily ([#792])
- Allow both `/` and `\` for folder creation on Windows ([#751]) - Allow both `/` and `\` for folder creation on Windows ([#751])
- New `parse()` method for the line elements to parse ANSI sequences - New `parse()` method for the line elements to parse ANSI sequences
@ -721,13 +721,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/):
### Added ### Added
- Preview image over SSH ([#585]) - Preview image over SSH ([#585])
- New `unyank` command ([#313]) - New `unyank` action ([#313])
- Customize number of columns of the which component ([#571]) - Customize number of columns of the which component ([#571])
- Support passing arguments to plugin ([#587]) - Support passing arguments to plugin ([#587])
- New `image_quality` and `sixel_fraction` options to configure the image preview quality ([#576]) - New `image_quality` and `sixel_fraction` options to configure the image preview quality ([#576])
- New `ya.which()` API for custom key events ([#617]) - New `ya.which()` API for custom key events ([#617])
- New `ya.quote()` API to quote strings safely - New `ya.quote()` API to quote strings safely
- `plugin` command for each layer - `plugin` action for each layer
- Plugin-specific state persistence ([#590]) - Plugin-specific state persistence ([#590])
- Allow to configure image filter ([#586]) - Allow to configure image filter ([#586])
- Shorten unit names and add more units to `ya.readable_size()` - Shorten unit names and add more units to `ya.readable_size()`
@ -765,7 +765,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/):
### Improved ### Improved
- New event system allows multiple commands to reuse a single render ([#561]) - New event system allows multiple actions to reuse a single render ([#561])
## [v0.2.1] ## [v0.2.1]
@ -777,17 +777,17 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/):
### Added ### Added
- New `filter` command to filter files on the fly ([#454]) - New `filter` action to filter files on the fly ([#454])
- Sort by file extension ([#405]) - Sort by file extension ([#405])
- Custom preloader and previewer ([#401]) - Custom preloader and previewer ([#401])
- New `plugin` command to run Lua plugins - New `plugin` action to run Lua plugins
- Auto-completion for input component ([#324], [#353], [#352]) - Auto-completion for input component ([#324], [#353], [#352])
- Start with the specified file hovers over ([#358]) - Start with the specified file hovers over ([#358])
- Emacs readline keybindings for inputs ([#345], [#382]) - Emacs readline keybindings for inputs ([#345], [#382])
- New `--empty` and `--cursor` options for the `rename` command ([#513]) - New `--empty` and `--cursor` options for the `rename` action ([#513])
- New `--follow` option for `paste` command ([#436]) - New `--follow` option for `paste` action ([#436])
- Make `copy` command work over SSH with OSC 52 ([#447]) - Make `copy` action work over SSH with OSC 52 ([#447])
- New `reveal` command ([#341]) - New `reveal` action ([#341])
- Support colored icons ([#503]) - Support colored icons ([#503])
- Support highlighting specific file types ([#510]) - Support highlighting specific file types ([#510])
- Make the position of input and select components customizable ([#361]) - Make the position of input and select components customizable ([#361])
@ -809,8 +809,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/):
### Changed ### Changed
- Rename the option `layout` to `ratio` to make it more self-explanatory - Rename the option `layout` to `ratio` to make it more self-explanatory
- Rename the `peek` command to `seek` to better convey the action of "seeking for" content to preview - Rename the `peek` action to `seek` to better convey the action of "seeking for" content to preview
- Rename the `--dir_first` option of `sort` command to `--dir-first` to make it consistent with the style of other commands - Rename the `--dir_first` option of `sort` action to `--dir-first` to make it consistent with the style of other actions
- Replace `[plugins.preload]` with the `init.lua` entry file - Replace `[plugins.preload]` with the `init.lua` entry file
### Fixed ### Fixed
@ -835,22 +835,22 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/):
### Added ### Added
- New `find` command to find files ([#104]) - New `find` action to find files ([#104])
- Linemode to show extra file info ([#291]) - Linemode to show extra file info ([#291])
- New `sort_sensitive` option ([#155]) - New `sort_sensitive` option ([#155])
- Cross-platform opener rules ([#289]) - Cross-platform opener rules ([#289])
- Multiple openers for a single open rule ([#154]) - Multiple openers for a single open rule ([#154])
- Vim-like `gg`, `G` in the preset key mappings for boundary jumps - Vim-like `gg`, `G` in the preset key mappings for boundary jumps
- Theme system ([#161]) - Theme system ([#161])
- New `--force` option for `remove`, `create`, `rename` commands ([#179], [#208]) - New `--force` option for `remove`, `create`, `rename` actions ([#179], [#208])
- Image preview within tmux ([#147]) - Image preview within tmux ([#147])
- New `link` command that creates symlinks to the yanked files ([#167]) - New `link` action creates symlinks to the yanked files ([#167])
- New `orphan` option for opener rules to detach processes from the task scheduler ([#216]) - New `orphan` option for opener rules to detach processes from the task scheduler ([#216])
- New `backward` and `forward` commands - New `backward` and `forward` actions
- New `--smart` option for the `find` command to support smart case ([#240]) - New `--smart` option for the `find` action to support smart case ([#240])
- Sorting for each tab individually ([#131]) - Sorting for each tab individually ([#131])
- Suspend process with `Ctrl+z` ([#120]) - Suspend process with `Ctrl+z` ([#120])
- Percentage values for the `arrow` command to scroll half/full page (with newly added Vi-like `<C-u>`, `<C-d>`, `<C-b>`, and `<C-f>` keybindings) ([#213]) - Percentage values for the `arrow` action to scroll half/full page (with newly added Vi-like `<C-u>`, `<C-d>`, `<C-b>`, and `<C-f>` keybindings) ([#213])
- Show keywords when in search mode ([#152]) - Show keywords when in search mode ([#152])
- Tab switch wraparound ([#160]) - Tab switch wraparound ([#160])
- Highlight matched keywords in find mode ([#211]) - Highlight matched keywords in find mode ([#211])
@ -859,7 +859,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/):
- Use of environment variables in `cd` paths ([#241]) - Use of environment variables in `cd` paths ([#241])
- Nix Flakes package ([#205]) - Nix Flakes package ([#205])
- New `V`, `D`, `C` Vim-like keybindings for the input component - New `V`, `D`, `C` Vim-like keybindings for the input component
- New `--no-cwd-file` option for the `quit` command to exit without writing the CWD file ([#245]) - New `--no-cwd-file` option for the `quit` action to exit without writing the CWD file ([#245])
- Fallback to built-in code highlighting if `jq` is not installed ([#151]) - Fallback to built-in code highlighting if `jq` is not installed ([#151])
- New `realtime` option for the input to support real-time input feedback ([#127]) - New `realtime` option for the input to support real-time input feedback ([#127])
- RGBA-16 image preview ([#250]) - RGBA-16 image preview ([#250])
@ -896,7 +896,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/):
- Scrollable preview ([#86]) - Scrollable preview ([#86])
- Natural sorting ([#82]) - Natural sorting ([#82])
- Windows support - Windows support
- New `copy` command to copy file paths to clipboard ([#72]) - New `copy` action to copy file paths to clipboard ([#72])
- File chooser mode ([#69]) - File chooser mode ([#69])
- Show symlink path ([#67]) - Show symlink path ([#67])
- Respect `$EDITOR` environment variable when opening text files ([#91]) - Respect `$EDITOR` environment variable when opening text files ([#91])
@ -929,8 +929,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/):
- Code highlighting supports more languages ([#22]) - Code highlighting supports more languages ([#22])
- Change the shell CWD on exit with the shell wrapper ([#40]) - Change the shell CWD on exit with the shell wrapper ([#40])
- Allow customizing the display name of openers ([#31]) - Allow customizing the display name of openers ([#31])
- New `shell` command ([#24]) - New `shell` action ([#24])
- Command template support for the `shell` command ([#48]) - Command template support for the `shell` action ([#48])
- Interactive `cd` ([#43]) - Interactive `cd` ([#43])
- Show the output of running tasks in real time ([#17]) - Show the output of running tasks in real time ([#17])
- Allow using the current directory name as tab name ([#41]) - Allow using the current directory name as tab name ([#41])
@ -945,7 +945,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/):
- PDF cache cannot be generated with a large `max_width` value ([#28]) - PDF cache cannot be generated with a large `max_width` value ([#28])
- `show_hidden` option not working ([#47]) - `show_hidden` option not working ([#47])
- Wrong task name when `shell` command has no arguments - Wrong task name when `shell` action has no arguments
### Improved ### Improved
@ -958,7 +958,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/):
### Added ### Added
- New `sort` command to change sorting method on the fly ([#7]) - New `sort` action to change sorting method on the fly ([#7])
- Which-key component to support multi-key chords ([#4]) - Which-key component to support multi-key chords ([#4])
- Hover the cursor over newly created files automatically ([#10]) - Hover the cursor over newly created files automatically ([#10])
- Make folders openable ([#9]) - Make folders openable ([#9])
@ -979,8 +979,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/):
- Arrow keys are now bound for navigation by default (along with existing Vim-style bindings) - Arrow keys are now bound for navigation by default (along with existing Vim-style bindings)
- Horizontal scrolling support for the `input` component - Horizontal scrolling support for the `input` component
- Visual mode for the input component - Visual mode for the input component
- New `yank` and `paste` commands for the input component - New `yank` and `paste` actions for the input component
- New `undo` and `redo` commands for the `input` component - New `undo` and `redo` actions for the `input` component
### Fixed ### Fixed
@ -995,7 +995,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/):
### Added ### Added
- Preset configurations - Preset configurations
- New `open` command - New `open` action
- Select component for interactive `open` - Select component for interactive `open`
- Plain text and archive preview - Plain text and archive preview
- Search files with `fd` and `rg` - Search files with `fd` and `rg`

View file

@ -3,7 +3,7 @@ use std::ops::{Deref, DerefMut};
use anyhow::{Result, anyhow}; use anyhow::{Result, anyhow};
use yazi_core::{Core, mgr::Tabs, tab::{Folder, Tab}, tasks::Tasks}; use yazi_core::{Core, mgr::Tabs, tab::{Folder, Tab}, tasks::Tasks};
use yazi_fs::File; use yazi_fs::File;
use yazi_shared::{Id, Source, event::Cmd, url::UrlBuf}; use yazi_shared::{Id, Source, event::Action, url::UrlBuf};
use yazi_term::Term; use yazi_term::Term;
pub struct Ctx<'a> { pub struct Ctx<'a> {
@ -28,8 +28,8 @@ impl DerefMut for Ctx<'_> {
impl<'a> Ctx<'a> { impl<'a> Ctx<'a> {
#[inline] #[inline]
pub fn new(cmd: &Cmd, core: &'a mut Core, term: &'a mut Option<Term>) -> Result<Self> { pub fn new(action: &Action, core: &'a mut Core, term: &'a mut Option<Term>) -> Result<Self> {
let tab = if let Ok(id) = cmd.get::<Id>("tab") { let tab = if let Ok(id) = action.get::<Id>("tab") {
core core
.mgr .mgr
.tabs .tabs
@ -45,7 +45,7 @@ impl<'a> Ctx<'a> {
term, term,
tab, tab,
level: 0, level: 0,
source: cmd.source, source: action.source,
#[cfg(debug_assertions)] #[cfg(debug_assertions)]
backtrace: vec![], backtrace: vec![],
}) })

View file

@ -1,6 +1,6 @@
use std::pin::Pin; use std::pin::Pin;
use mlua::{UserData, prelude::LuaUserDataMethods}; use mlua::{UserData, UserDataMethods};
use tokio::pin; use tokio::pin;
use tokio_stream::StreamExt; use tokio_stream::StreamExt;
use yazi_widgets::input::InputError; use yazi_widgets::input::InputError;
@ -28,7 +28,7 @@ impl<T: StreamExt<Item = Result<String, InputError>>> InputRx<T> {
} }
impl<T: StreamExt<Item = Result<String, InputError>> + 'static> UserData for InputRx<T> { impl<T: StreamExt<Item = Result<String, InputError>> + 'static> UserData for InputRx<T> {
fn add_methods<M: LuaUserDataMethods<Self>>(methods: &mut M) { fn add_methods<M: UserDataMethods<Self>>(methods: &mut M) {
methods.add_async_method_mut("recv", |_, mut me, ()| async move { methods.add_async_method_mut("recv", |_, mut me, ()| async move {
let mut inner = unsafe { Pin::new_unchecked(&mut me.inner) }; let mut inner = unsafe { Pin::new_unchecked(&mut me.inner) };
Ok(inner.next().await.map(Self::parse).unwrap_or((None, 0))) Ok(inner.next().await.map(Self::parse).unwrap_or((None, 0)))

View file

@ -1,7 +1,7 @@
use std::{mem, ops::Deref}; use std::{mem, ops::Deref};
use futures::{FutureExt, future::BoxFuture}; use futures::{FutureExt, future::BoxFuture};
use mlua::{UserData, prelude::LuaUserDataMethods}; use mlua::{UserData, UserDataMethods};
use tokio::sync::SemaphorePermit; use tokio::sync::SemaphorePermit;
pub type PermitRef = mlua::UserDataRef<Permit>; pub type PermitRef = mlua::UserDataRef<Permit>;
@ -45,7 +45,7 @@ impl Drop for Permit {
} }
impl UserData for Permit { impl UserData for Permit {
fn add_methods<M: LuaUserDataMethods<Self>>(methods: &mut M) { fn add_methods<M: UserDataMethods<Self>>(methods: &mut M) {
methods.add_async_method_mut("drop", |_, mut me, ()| async move { Ok(me.dropping().await) }); methods.add_async_method_mut("drop", |_, mut me, ()| async move { Ok(me.dropping().await) });
} }
} }

View file

@ -167,8 +167,8 @@ impl Actions {
let p = env::temp_dir().join(format!(".yazi-debug-{}.tmp", timestamp_us())); let p = env::temp_dir().join(format!(".yazi-debug-{}.tmp", timestamp_us()));
std::fs::File::create_new(&p).map(|mut f| f.write_all(b"Hello, World!")).ok(); std::fs::File::create_new(&p).map(|mut f| f.write_all(b"Hello, World!")).ok();
let cmd = env::var_os("YAZI_FILE_ONE").unwrap_or("file".into()); let program = env::var_os("YAZI_FILE_ONE").unwrap_or("file".into());
match std::process::Command::new(cmd).args(["-bL", "--mime-type"]).arg(&p).output() { match std::process::Command::new(program).args(["-bL", "--mime-type"]).arg(&p).output() {
Ok(out) => { Ok(out) => {
String::from_utf8_lossy(&out.stdout).trim().lines().next().unwrap_or_default().to_owned() String::from_utf8_lossy(&out.stdout).trim().lines().next().unwrap_or_default().to_owned()
} }

View file

@ -146,11 +146,11 @@ macro_rules! impl_emit_body {
Arg(Vec<u8>), Arg(Vec<u8>),
} }
let cmd: Vec<_> = [Elem::Name(self.name)] let action: Vec<_> = [Elem::Name(self.name)]
.into_iter() .into_iter()
.chain(self.args.into_iter().map(|s| Elem::Arg(s.into_encoded_bytes()))) .chain(self.args.into_iter().map(|s| Elem::Arg(s.into_encoded_bytes())))
.collect(); .collect();
Ok(serde_json::to_string(&cmd)?) Ok(serde_json::to_string(&action)?)
} }
} }
}; };

View file

@ -3,7 +3,7 @@ use std::{borrow::Cow, hash::{Hash, Hasher}, sync::OnceLock};
use anyhow::Result; use anyhow::Result;
use regex::Regex; use regex::Regex;
use serde::Deserialize; use serde::Deserialize;
use yazi_shared::{Layer, Source, event::Cmd}; use yazi_shared::{Layer, Source, event::Action};
use super::Key; use super::Key;
@ -14,7 +14,7 @@ pub struct Chord {
#[serde(deserialize_with = "super::deserialize_on")] #[serde(deserialize_with = "super::deserialize_on")]
pub on: Vec<Key>, pub on: Vec<Key>,
#[serde(deserialize_with = "super::deserialize_run")] #[serde(deserialize_with = "super::deserialize_run")]
pub run: Vec<Cmd>, pub run: Vec<Action>,
pub desc: Option<String>, pub desc: Option<String>,
pub r#for: Option<String>, pub r#for: Option<String>,
} }
@ -59,10 +59,10 @@ impl Chord {
impl Chord { impl Chord {
pub(super) fn reshape(mut self, layer: Layer) -> Result<Self> { pub(super) fn reshape(mut self, layer: Layer) -> Result<Self> {
for cmd in &mut self.run { for action in &mut self.run {
cmd.source = Source::Key; action.source = Source::Key;
if cmd.layer == Default::default() { if action.layer == Default::default() {
cmd.layer = layer; action.layer = layer;
} }
} }
Ok(self) Ok(self)

View file

@ -1,6 +1,6 @@
use std::ops::Deref; use std::ops::Deref;
use yazi_shared::event::CmdCow; use yazi_shared::event::ActionCow;
use super::Chord; use super::Chord;
@ -37,7 +37,7 @@ impl Default for ChordCow {
} }
impl ChordCow { impl ChordCow {
pub fn into_seq(self) -> Vec<CmdCow> { pub fn into_seq(self) -> Vec<ActionCow> {
match self { match self {
Self::Owned(c) => c.run.into_iter().rev().map(Into::into).collect(), Self::Owned(c) => c.run.into_iter().rev().map(Into::into).collect(),
Self::Borrowed(c) => c.run.iter().rev().map(Into::into).collect(), Self::Borrowed(c) => c.run.iter().rev().map(Into::into).collect(),

View file

@ -2,7 +2,7 @@ use std::{fmt, str::FromStr};
use anyhow::Result; use anyhow::Result;
use serde::{Deserializer, de::{self, Visitor}}; use serde::{Deserializer, de::{self, Visitor}};
use yazi_shared::event::Cmd; use yazi_shared::event::Action;
use crate::keymap::Key; use crate::keymap::Key;
@ -23,14 +23,14 @@ where
where where
A: de::SeqAccess<'de>, A: de::SeqAccess<'de>,
{ {
let mut cmds = Vec::with_capacity(seq.size_hint().unwrap_or(0)); let mut keys = Vec::with_capacity(seq.size_hint().unwrap_or(0));
while let Some(value) = &seq.next_element::<String>()? { while let Some(value) = &seq.next_element::<String>()? {
cmds.push(Key::from_str(value).map_err(de::Error::custom)?); keys.push(Key::from_str(value).map_err(de::Error::custom)?);
} }
if cmds.is_empty() { if keys.is_empty() {
return Err(de::Error::custom("`on` within keymap.toml cannot be empty")); return Err(de::Error::custom("`on` within keymap.toml cannot be empty"));
} }
Ok(cmds) Ok(keys)
} }
fn visit_str<E>(self, value: &str) -> Result<Self::Value, E> fn visit_str<E>(self, value: &str) -> Result<Self::Value, E>
@ -44,14 +44,14 @@ where
deserializer.deserialize_any(OnVisitor) deserializer.deserialize_any(OnVisitor)
} }
pub(super) fn deserialize_run<'de, D>(deserializer: D) -> Result<Vec<Cmd>, D::Error> pub(super) fn deserialize_run<'de, D>(deserializer: D) -> Result<Vec<Action>, D::Error>
where where
D: Deserializer<'de>, D: Deserializer<'de>,
{ {
struct RunVisitor; struct RunVisitor;
impl<'de> Visitor<'de> for RunVisitor { impl<'de> Visitor<'de> for RunVisitor {
type Value = Vec<Cmd>; type Value = Vec<Action>;
fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
formatter.write_str("a `run` string or array of strings within keymap.toml") formatter.write_str("a `run` string or array of strings within keymap.toml")
@ -61,21 +61,21 @@ where
where where
A: de::SeqAccess<'de>, A: de::SeqAccess<'de>,
{ {
let mut cmds = Vec::with_capacity(seq.size_hint().unwrap_or(0)); let mut actions = Vec::with_capacity(seq.size_hint().unwrap_or(0));
while let Some(value) = &seq.next_element::<String>()? { while let Some(value) = &seq.next_element::<String>()? {
cmds.push(Cmd::from_str(value).map_err(de::Error::custom)?); actions.push(Action::from_str(value).map_err(de::Error::custom)?);
} }
if cmds.is_empty() { if actions.is_empty() {
return Err(de::Error::custom("`run` within keymap.toml cannot be empty")); return Err(de::Error::custom("`run` within keymap.toml cannot be empty"));
} }
Ok(cmds) Ok(actions)
} }
fn visit_str<E>(self, value: &str) -> Result<Self::Value, E> fn visit_str<E>(self, value: &str) -> Result<Self::Value, E>
where where
E: de::Error, E: de::Error,
{ {
Ok(vec![Cmd::from_str(value).map_err(de::Error::custom)?]) Ok(vec![Action::from_str(value).map_err(de::Error::custom)?])
} }
} }

View file

@ -1,6 +1,6 @@
use serde::Deserialize; use serde::Deserialize;
use yazi_fs::File; use yazi_fs::File;
use yazi_shared::event::Cmd; use yazi_shared::event::Action;
use crate::{Pattern, Priority}; use crate::{Pattern, Priority};
@ -12,7 +12,7 @@ pub struct Fetcher {
pub id: String, pub id: String,
pub url: Option<Pattern>, pub url: Option<Pattern>,
pub mime: Option<Pattern>, pub mime: Option<Pattern>,
pub run: Cmd, pub run: Action,
#[serde(default)] #[serde(default)]
pub prio: Priority, pub prio: Priority,
} }

View file

@ -1,6 +1,6 @@
use serde::Deserialize; use serde::Deserialize;
use yazi_fs::File; use yazi_fs::File;
use yazi_shared::event::Cmd; use yazi_shared::event::Action;
use crate::{Pattern, Priority}; use crate::{Pattern, Priority};
@ -11,7 +11,7 @@ pub struct Preloader {
pub url: Option<Pattern>, pub url: Option<Pattern>,
pub mime: Option<Pattern>, pub mime: Option<Pattern>,
pub run: Cmd, pub run: Action,
#[serde(default)] #[serde(default)]
pub next: bool, pub next: bool,
#[serde(default)] #[serde(default)]

View file

@ -1,6 +1,6 @@
use serde::Deserialize; use serde::Deserialize;
use yazi_fs::File; use yazi_fs::File;
use yazi_shared::event::Cmd; use yazi_shared::event::Action;
use crate::Pattern; use crate::Pattern;
@ -8,7 +8,7 @@ use crate::Pattern;
pub struct Previewer { pub struct Previewer {
pub url: Option<Pattern>, pub url: Option<Pattern>,
pub mime: Option<Pattern>, pub mime: Option<Pattern>,
pub run: Cmd, pub run: Action,
} }
impl Previewer { impl Previewer {

View file

@ -1,6 +1,6 @@
use serde::Deserialize; use serde::Deserialize;
use yazi_fs::File; use yazi_fs::File;
use yazi_shared::event::Cmd; use yazi_shared::event::Action;
use crate::Pattern; use crate::Pattern;
@ -8,7 +8,7 @@ use crate::Pattern;
pub struct Spotter { pub struct Spotter {
pub url: Option<Pattern>, pub url: Option<Pattern>,
pub mime: Option<Pattern>, pub mime: Option<Pattern>,
pub run: Cmd, pub run: Action,
} }
impl Spotter { impl Spotter {

View file

@ -4,7 +4,7 @@ use anyhow::{Result, anyhow};
use mlua::{IntoLua, Lua, Value}; use mlua::{IntoLua, Lua, Value};
use yazi_boot::BOOT; use yazi_boot::BOOT;
use yazi_macro::{emit, relay}; use yazi_macro::{emit, relay};
use yazi_shared::{Id, event::CmdCow}; use yazi_shared::{Id, event::ActionCow};
use crate::{ID, ember::Ember, spark::Spark}; use crate::{ID, ember::Ember, spark::Spark};
@ -88,11 +88,11 @@ impl<'a> TryFrom<Spark<'a>> for Payload<'a> {
} }
} }
impl TryFrom<CmdCow> for Payload<'_> { impl TryFrom<ActionCow> for Payload<'_> {
type Error = anyhow::Error; type Error = anyhow::Error;
fn try_from(mut c: CmdCow) -> Result<Self, Self::Error> { fn try_from(mut a: ActionCow) -> Result<Self, Self::Error> {
c.take_any2("payload").ok_or_else(|| anyhow!("Missing 'payload' in Payload"))? a.take_any2("payload").ok_or_else(|| anyhow!("Missing 'payload' in Payload"))?
} }
} }

View file

@ -167,7 +167,7 @@ impl Sendable {
Self::value_to_data(lua, v)?, Self::value_to_data(lua, v)?,
); );
} }
_ => return Err("invalid key in Cmd".into_lua_err()), _ => return Err("invalid key in Action".into_lua_err()),
} }
} }
Ok(args) Ok(args)

View file

@ -6,7 +6,7 @@ use tracing::warn;
use yazi_actor::Ctx; use yazi_actor::Ctx;
use yazi_config::keymap::Key; use yazi_config::keymap::Key;
use yazi_macro::{act, emit, succ}; use yazi_macro::{act, emit, succ};
use yazi_shared::{data::Data, event::{CmdCow, Event, NEED_RENDER}}; use yazi_shared::{data::Data, event::{ActionCow, Event, NEED_RENDER}};
use yazi_widgets::input::InputMode; use yazi_widgets::input::InputMode;
use crate::{Executor, Router, app::App}; use crate::{Executor, Router, app::App};
@ -22,8 +22,8 @@ impl<'a> Dispatcher<'a> {
#[inline] #[inline]
pub(super) fn dispatch(&mut self, event: Event) -> Result<()> { pub(super) fn dispatch(&mut self, event: Event) -> Result<()> {
let result = match event { let result = match event {
Event::Call(cmd) => self.dispatch_call(cmd), Event::Call(action) => self.dispatch_call(action),
Event::Seq(cmds) => self.dispatch_seq(cmds), Event::Seq(actions) => self.dispatch_seq(actions),
Event::Render(partial) => self.dispatch_render(partial), Event::Render(partial) => self.dispatch_render(partial),
Event::Key(key) => self.dispatch_key(key), Event::Key(key) => self.dispatch_key(key),
Event::Mouse(mouse) => self.dispatch_mouse(mouse), Event::Mouse(mouse) => self.dispatch_mouse(mouse),
@ -39,15 +39,17 @@ impl<'a> Dispatcher<'a> {
} }
#[inline] #[inline]
fn dispatch_call(&mut self, cmd: CmdCow) -> Result<Data> { Executor::new(self.app).execute(cmd) } fn dispatch_call(&mut self, action: ActionCow) -> Result<Data> {
Executor::new(self.app).execute(action)
}
#[inline] #[inline]
fn dispatch_seq(&mut self, mut cmds: Vec<CmdCow>) -> Result<Data> { fn dispatch_seq(&mut self, mut actions: Vec<ActionCow>) -> Result<Data> {
if let Some(last) = cmds.pop() { if let Some(last) = actions.pop() {
self.dispatch_call(last)?; self.dispatch_call(last)?;
} }
if !cmds.is_empty() { if !actions.is_empty() {
emit!(Seq(cmds)); emit!(Seq(actions));
} }
succ!(); succ!();
} }

View file

@ -1,7 +1,7 @@
use anyhow::{Context, Result}; use anyhow::{Context, Result};
use yazi_actor::Ctx; use yazi_actor::Ctx;
use yazi_macro::{act, succ}; use yazi_macro::{act, succ};
use yazi_shared::{Layer, data::Data, event::CmdCow}; use yazi_shared::{Layer, data::Data, event::ActionCow};
use yazi_widgets::input::InputMode; use yazi_widgets::input::InputMode;
use crate::app::App; use crate::app::App;
@ -15,29 +15,29 @@ impl<'a> Executor<'a> {
pub(super) fn new(app: &'a mut App) -> Self { Self { app } } pub(super) fn new(app: &'a mut App) -> Self { Self { app } }
#[inline] #[inline]
pub(super) fn execute(&mut self, cmd: CmdCow) -> Result<Data> { pub(super) fn execute(&mut self, action: ActionCow) -> Result<Data> {
match cmd.layer { match action.layer {
Layer::App => self.app(cmd), Layer::App => self.app(action),
Layer::Mgr => self.mgr(cmd), Layer::Mgr => self.mgr(action),
Layer::Tasks => self.tasks(cmd), Layer::Tasks => self.tasks(action),
Layer::Spot => self.spot(cmd), Layer::Spot => self.spot(action),
Layer::Pick => self.pick(cmd), Layer::Pick => self.pick(action),
Layer::Input => self.input(cmd), Layer::Input => self.input(action),
Layer::Confirm => self.confirm(cmd), Layer::Confirm => self.confirm(action),
Layer::Help => self.help(cmd), Layer::Help => self.help(action),
Layer::Cmp => self.cmp(cmd), Layer::Cmp => self.cmp(action),
Layer::Which => self.which(cmd), Layer::Which => self.which(action),
Layer::Notify => self.notify(cmd), Layer::Notify => self.notify(action),
} }
} }
fn app(&mut self, mut cmd: CmdCow) -> Result<Data> { fn app(&mut self, mut action: ActionCow) -> Result<Data> {
let cx = &mut Ctx::new(&cmd, &mut self.app.core, &mut self.app.term)?; let cx = &mut Ctx::new(&action, &mut self.app.core, &mut self.app.term)?;
macro_rules! on { macro_rules! on {
($name:ident) => { ($name:ident) => {
if cmd.name == stringify!($name) { if action.name == stringify!($name) {
return act!(app:$name, cx, cmd); return act!(app:$name, cx, action);
} }
}; };
} }
@ -49,28 +49,28 @@ impl<'a> Executor<'a> {
on!(deprecate); on!(deprecate);
on!(quit); on!(quit);
match &*cmd.name { match &*action.name {
"resize" => act!(app:resize, cx, crate::Root::reflow as fn(_) -> _), "resize" => act!(app:resize, cx, crate::Root::reflow as fn(_) -> _),
"resume" => act!(app:resume, cx, yazi_parser::app::ResumeOpt { "resume" => act!(app:resume, cx, yazi_parser::app::ResumeOpt {
tx: self.app.signals.tx.clone(), tx: self.app.signals.tx.clone(),
token: cmd.take_any("token").context("Invalid 'token' in ResumeOpt")?, token: action.take_any("token").context("Invalid 'token' in ResumeOpt")?,
reflow: crate::Root::reflow, reflow: crate::Root::reflow,
}), }),
"stop" => act!(app:stop, cx, yazi_parser::app::StopOpt { "stop" => act!(app:stop, cx, yazi_parser::app::StopOpt {
tx: self.app.signals.tx.clone(), tx: self.app.signals.tx.clone(),
token: cmd.take_any("token").context("Invalid 'token' in StopOpt")?, token: action.take_any("token").context("Invalid 'token' in StopOpt")?,
}), }),
_ => succ!(), _ => succ!(),
} }
} }
fn mgr(&mut self, cmd: CmdCow) -> Result<Data> { fn mgr(&mut self, action: ActionCow) -> Result<Data> {
let cx = &mut Ctx::new(&cmd, &mut self.app.core, &mut self.app.term)?; let cx = &mut Ctx::new(&action, &mut self.app.core, &mut self.app.term)?;
macro_rules! on { macro_rules! on {
($name:ident) => { ($name:ident) => {
if cmd.name == stringify!($name) { if action.name == stringify!($name) {
return act!(mgr:$name, cx, cmd) return act!(mgr:$name, cx, action)
} }
}; };
} }
@ -151,22 +151,22 @@ impl<'a> Executor<'a> {
on!(upload); on!(upload);
on!(displace_do); on!(displace_do);
match cmd.name.as_ref() { match action.name.as_ref() {
// Help // Help
"help" => act!(help:toggle, cx, Layer::Mgr), "help" => act!(help:toggle, cx, Layer::Mgr),
// Plugin // Plugin
"plugin" => act!(app:plugin, cx, cmd), "plugin" => act!(app:plugin, cx, action),
_ => succ!(), _ => succ!(),
} }
} }
fn tasks(&mut self, cmd: CmdCow) -> Result<Data> { fn tasks(&mut self, action: ActionCow) -> Result<Data> {
let cx = &mut Ctx::new(&cmd, &mut self.app.core, &mut self.app.term)?; let cx = &mut Ctx::new(&action, &mut self.app.core, &mut self.app.term)?;
macro_rules! on { macro_rules! on {
($name:ident) => { ($name:ident) => {
if cmd.name == stringify!($name) { if action.name == stringify!($name) {
return act!(tasks:$name, cx, cmd); return act!(tasks:$name, cx, action);
} }
}; };
} }
@ -181,22 +181,22 @@ impl<'a> Executor<'a> {
on!(process_open); on!(process_open);
on!(open_shell_compat); on!(open_shell_compat);
match cmd.name.as_ref() { match action.name.as_ref() {
// Help // Help
"help" => act!(help:toggle, cx, Layer::Tasks), "help" => act!(help:toggle, cx, Layer::Tasks),
// Plugin // Plugin
"plugin" => act!(app:plugin, cx, cmd), "plugin" => act!(app:plugin, cx, action),
_ => succ!(), _ => succ!(),
} }
} }
fn spot(&mut self, cmd: CmdCow) -> Result<Data> { fn spot(&mut self, action: ActionCow) -> Result<Data> {
let cx = &mut Ctx::new(&cmd, &mut self.app.core, &mut self.app.term)?; let cx = &mut Ctx::new(&action, &mut self.app.core, &mut self.app.term)?;
macro_rules! on { macro_rules! on {
($name:ident) => { ($name:ident) => {
if cmd.name == stringify!($name) { if action.name == stringify!($name) {
return act!(spot:$name, cx, cmd); return act!(spot:$name, cx, action);
} }
}; };
} }
@ -206,22 +206,22 @@ impl<'a> Executor<'a> {
on!(swipe); on!(swipe);
on!(copy); on!(copy);
match cmd.name.as_ref() { match action.name.as_ref() {
// Help // Help
"help" => act!(help:toggle, cx, Layer::Spot), "help" => act!(help:toggle, cx, Layer::Spot),
// Plugin // Plugin
"plugin" => act!(app:plugin, cx, cmd), "plugin" => act!(app:plugin, cx, action),
_ => succ!(), _ => succ!(),
} }
} }
fn pick(&mut self, cmd: CmdCow) -> Result<Data> { fn pick(&mut self, action: ActionCow) -> Result<Data> {
let cx = &mut Ctx::new(&cmd, &mut self.app.core, &mut self.app.term)?; let cx = &mut Ctx::new(&action, &mut self.app.core, &mut self.app.term)?;
macro_rules! on { macro_rules! on {
($name:ident) => { ($name:ident) => {
if cmd.name == stringify!($name) { if action.name == stringify!($name) {
return act!(pick:$name, cx, cmd); return act!(pick:$name, cx, action);
} }
}; };
} }
@ -230,23 +230,23 @@ impl<'a> Executor<'a> {
on!(close); on!(close);
on!(arrow); on!(arrow);
match cmd.name.as_ref() { match action.name.as_ref() {
// Help // Help
"help" => act!(help:toggle, cx, Layer::Pick), "help" => act!(help:toggle, cx, Layer::Pick),
// Plugin // Plugin
"plugin" => act!(app:plugin, cx, cmd), "plugin" => act!(app:plugin, cx, action),
_ => succ!(), _ => succ!(),
} }
} }
fn input(&mut self, cmd: CmdCow) -> Result<Data> { fn input(&mut self, action: ActionCow) -> Result<Data> {
let mode = self.app.core.input.mode(); let mode = self.app.core.input.mode();
let cx = &mut Ctx::new(&cmd, &mut self.app.core, &mut self.app.term)?; let cx = &mut Ctx::new(&action, &mut self.app.core, &mut self.app.term)?;
macro_rules! on { macro_rules! on {
($name:ident) => { ($name:ident) => {
if cmd.name == stringify!($name) { if action.name == stringify!($name) {
return act!(input:$name, cx, cmd); return act!(input:$name, cx, action);
} }
}; };
} }
@ -257,11 +257,11 @@ impl<'a> Executor<'a> {
match mode { match mode {
InputMode::Normal => { InputMode::Normal => {
match cmd.name.as_ref() { match action.name.as_ref() {
// Help // Help
"help" => return act!(help:toggle, cx, Layer::Input), "help" => return act!(help:toggle, cx, Layer::Input),
// Plugin // Plugin
"plugin" => return act!(app:plugin, cx, cmd), "plugin" => return act!(app:plugin, cx, action),
_ => {} _ => {}
} }
} }
@ -271,16 +271,16 @@ impl<'a> Executor<'a> {
InputMode::Replace => {} InputMode::Replace => {}
}; };
self.app.core.input.execute(cmd) self.app.core.input.execute(action)
} }
fn confirm(&mut self, cmd: CmdCow) -> Result<Data> { fn confirm(&mut self, action: ActionCow) -> Result<Data> {
let cx = &mut Ctx::new(&cmd, &mut self.app.core, &mut self.app.term)?; let cx = &mut Ctx::new(&action, &mut self.app.core, &mut self.app.term)?;
macro_rules! on { macro_rules! on {
($name:ident) => { ($name:ident) => {
if cmd.name == stringify!($name) { if action.name == stringify!($name) {
return act!(confirm:$name, cx, cmd); return act!(confirm:$name, cx, action);
} }
}; };
} }
@ -292,13 +292,13 @@ impl<'a> Executor<'a> {
succ!(); succ!();
} }
fn help(&mut self, cmd: CmdCow) -> Result<Data> { fn help(&mut self, action: ActionCow) -> Result<Data> {
let cx = &mut Ctx::new(&cmd, &mut self.app.core, &mut self.app.term)?; let cx = &mut Ctx::new(&action, &mut self.app.core, &mut self.app.term)?;
macro_rules! on { macro_rules! on {
($name:ident) => { ($name:ident) => {
if cmd.name == stringify!($name) { if action.name == stringify!($name) {
return act!(help:$name, cx, cmd); return act!(help:$name, cx, action);
} }
}; };
} }
@ -307,22 +307,22 @@ impl<'a> Executor<'a> {
on!(arrow); on!(arrow);
on!(filter); on!(filter);
match cmd.name.as_ref() { match action.name.as_ref() {
// Help // Help
"close" => act!(help:toggle, cx, Layer::Help), "close" => act!(help:toggle, cx, Layer::Help),
// Plugin // Plugin
"plugin" => act!(app:plugin, cx, cmd), "plugin" => act!(app:plugin, cx, action),
_ => succ!(), _ => succ!(),
} }
} }
fn cmp(&mut self, cmd: CmdCow) -> Result<Data> { fn cmp(&mut self, action: ActionCow) -> Result<Data> {
let cx = &mut Ctx::new(&cmd, &mut self.app.core, &mut self.app.term)?; let cx = &mut Ctx::new(&action, &mut self.app.core, &mut self.app.term)?;
macro_rules! on { macro_rules! on {
($name:ident) => { ($name:ident) => {
if cmd.name == stringify!($name) { if action.name == stringify!($name) {
return act!(cmp:$name, cx, cmd); return act!(cmp:$name, cx, action);
} }
}; };
} }
@ -332,22 +332,22 @@ impl<'a> Executor<'a> {
on!(close); on!(close);
on!(arrow); on!(arrow);
match cmd.name.as_ref() { match action.name.as_ref() {
// Help // Help
"help" => act!(help:toggle, cx, Layer::Cmp), "help" => act!(help:toggle, cx, Layer::Cmp),
// Plugin // Plugin
"plugin" => act!(app:plugin, cx, cmd), "plugin" => act!(app:plugin, cx, action),
_ => succ!(), _ => succ!(),
} }
} }
fn which(&mut self, cmd: CmdCow) -> Result<Data> { fn which(&mut self, action: ActionCow) -> Result<Data> {
let cx = &mut Ctx::new(&cmd, &mut self.app.core, &mut self.app.term)?; let cx = &mut Ctx::new(&action, &mut self.app.core, &mut self.app.term)?;
macro_rules! on { macro_rules! on {
($name:ident) => { ($name:ident) => {
if cmd.name == stringify!($name) { if action.name == stringify!($name) {
return act!(which:$name, cx, cmd); return act!(which:$name, cx, action);
} }
}; };
} }
@ -358,13 +358,13 @@ impl<'a> Executor<'a> {
succ!(); succ!();
} }
fn notify(&mut self, cmd: CmdCow) -> Result<Data> { fn notify(&mut self, action: ActionCow) -> Result<Data> {
let cx = &mut Ctx::new(&cmd, &mut self.app.core, &mut self.app.term)?; let cx = &mut Ctx::new(&action, &mut self.app.core, &mut self.app.term)?;
macro_rules! on { macro_rules! on {
($name:ident) => { ($name:ident) => {
if cmd.name == stringify!($name) { if action.name == stringify!($name) {
return act!(notify:$name, cx, cmd); return act!(notify:$name, cx, action);
} }
}; };
} }

View file

@ -2,7 +2,7 @@ use std::{fmt::Display, ops::Range};
use anyhow::Result; use anyhow::Result;
use regex::bytes::{Regex, RegexBuilder}; use regex::bytes::{Regex, RegexBuilder};
use yazi_shared::{event::Cmd, strand::AsStrand}; use yazi_shared::{event::Action, strand::AsStrand};
pub struct Filter { pub struct Filter {
raw: String, raw: String,
@ -53,9 +53,9 @@ pub enum FilterCase {
Insensitive, Insensitive,
} }
impl From<&Cmd> for FilterCase { impl From<&Action> for FilterCase {
fn from(c: &Cmd) -> Self { fn from(a: &Action) -> Self {
match (c.bool("smart"), c.bool("insensitive")) { match (a.bool("smart"), a.bool("insensitive")) {
(true, _) => Self::Smart, (true, _) => Self::Smart,
(_, false) => Self::Sensitive, (_, false) => Self::Sensitive,
(_, true) => Self::Insensitive, (_, true) => Self::Insensitive,

View file

@ -24,8 +24,8 @@ macro_rules! act {
result result
}}; }};
($layer:ident : $name:ident, $cx:ident, $cmd:expr) => { ($layer:ident : $name:ident, $cx:ident, $action:expr) => {
<act!($layer:$name) as yazi_actor::Actor>::Options::try_from($cmd) <act!($layer:$name) as yazi_actor::Actor>::Options::try_from($action)
.map_err(anyhow::Error::from) .map_err(anyhow::Error::from)
.and_then(|opt| act!(@impl $layer:$name, $cx, opt)) .and_then(|opt| act!(@impl $layer:$name, $cx, opt))
}; };
@ -36,8 +36,8 @@ macro_rules! act {
paste::paste! { yazi_actor::$layer::[<$name:camel>] } paste::paste! { yazi_actor::$layer::[<$name:camel>] }
}; };
($name:ident, $cx:expr, $cmd:expr) => { ($name:ident, $cx:expr, $action:expr) => {
$cmd.try_into().map_err(anyhow::Error::from).and_then(|opt| $cx.$name(opt)) $action.try_into().map_err(anyhow::Error::from).and_then(|opt| $cx.$name(opt))
}; };
($name:ident, $cx:expr) => { ($name:ident, $cx:expr) => {
$cx.$name(Default::default()) $cx.$name(Default::default())

View file

@ -1,10 +1,10 @@
#[macro_export] #[macro_export]
macro_rules! emit { macro_rules! emit {
(Call($cmd:expr)) => { (Call($action:expr)) => {
yazi_shared::event::Event::Call(yazi_shared::event::CmdCow::from($cmd)).emit(); yazi_shared::event::Event::Call(yazi_shared::event::ActionCow::from($action)).emit();
}; };
(Seq($cmds:expr)) => { (Seq($actions:expr)) => {
yazi_shared::event::Event::Seq($cmds).emit(); yazi_shared::event::Event::Seq($actions).emit();
}; };
($event:ident) => { ($event:ident) => {
yazi_shared::event::Event::$event.emit(); yazi_shared::event::Event::$event.emit();
@ -14,10 +14,10 @@ macro_rules! emit {
#[macro_export] #[macro_export]
macro_rules! relay { macro_rules! relay {
($layer:ident : $name:ident) => { ($layer:ident : $name:ident) => {
yazi_shared::event::Cmd::new_relay(concat!(stringify!($layer), ":", stringify!($name))) yazi_shared::event::Action::new_relay(concat!(stringify!($layer), ":", stringify!($name)))
}; };
($layer:ident : $name:ident, $args:expr) => { ($layer:ident : $name:ident, $args:expr) => {
yazi_shared::event::Cmd::new_relay_args( yazi_shared::event::Action::new_relay_args(
concat!(stringify!($layer), ":", stringify!($name)), concat!(stringify!($layer), ":", stringify!($name)),
$args, $args,
) )

View file

@ -1,17 +1,17 @@
use anyhow::bail; use anyhow::bail;
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value}; use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
use yazi_shared::{SStr, event::CmdCow}; use yazi_shared::{SStr, event::ActionCow};
#[derive(Debug)] #[derive(Debug)]
pub struct DeprecateOpt { pub struct DeprecateOpt {
pub content: SStr, pub content: SStr,
} }
impl TryFrom<CmdCow> for DeprecateOpt { impl TryFrom<ActionCow> for DeprecateOpt {
type Error = anyhow::Error; type Error = anyhow::Error;
fn try_from(mut c: CmdCow) -> Result<Self, Self::Error> { fn try_from(mut a: ActionCow) -> Result<Self, Self::Error> {
let Ok(content) = c.take("content") else { let Ok(content) = a.take("content") else {
bail!("Invalid 'content' in DeprecateOpt"); bail!("Invalid 'content' in DeprecateOpt");
}; };

View file

@ -5,7 +5,7 @@ use dyn_clone::DynClone;
use hashbrown::HashMap; use hashbrown::HashMap;
use mlua::{ExternalError, FromLua, IntoLua, Lua, Table, Value}; use mlua::{ExternalError, FromLua, IntoLua, Lua, Table, Value};
use serde::Deserialize; use serde::Deserialize;
use yazi_shared::{SStr, data::{Data, DataKey}, event::{Cmd, CmdCow}}; use yazi_shared::{SStr, data::{Data, DataKey}, event::{Action, ActionCow}};
#[derive(Clone, Debug, Default)] #[derive(Clone, Debug, Default)]
pub struct PluginOpt { pub struct PluginOpt {
@ -15,27 +15,27 @@ pub struct PluginOpt {
pub callback: Option<Box<dyn PluginCallback>>, pub callback: Option<Box<dyn PluginCallback>>,
} }
impl TryFrom<CmdCow> for PluginOpt { impl TryFrom<ActionCow> for PluginOpt {
type Error = anyhow::Error; type Error = anyhow::Error;
fn try_from(mut c: CmdCow) -> Result<Self, Self::Error> { fn try_from(mut a: ActionCow) -> Result<Self, Self::Error> {
if let Some(opt) = c.take_any("opt") { if let Some(opt) = a.take_any("opt") {
return Ok(opt); return Ok(opt);
} }
let Some(id) = c.take_first::<SStr>().ok().filter(|s| !s.is_empty()) else { let Some(id) = a.take_first::<SStr>().ok().filter(|s| !s.is_empty()) else {
bail!("plugin id cannot be empty"); bail!("plugin id cannot be empty");
}; };
let args = if let Ok(s) = c.second() { let args = if let Ok(s) = a.second() {
let (words, last) = yazi_shared::shell::unix::split(s, true)?; let (words, last) = yazi_shared::shell::unix::split(s, true)?;
Cmd::parse_args(words, last)? Action::parse_args(words, last)?
} else { } else {
Default::default() Default::default()
}; };
let mode = c.str("mode").parse().unwrap_or_default(); let mode = a.str("mode").parse().unwrap_or_default();
Ok(Self { id: Self::normalize_id(id), args, mode, callback: c.take_any("callback") }) Ok(Self { id: Self::normalize_id(id), args, mode, callback: a.take_any("callback") })
} }
} }

View file

@ -1,7 +1,7 @@
use mlua::{FromLua, IntoLua, Lua, LuaSerdeExt, Value}; use mlua::{FromLua, IntoLua, Lua, LuaSerdeExt, Value};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use yazi_binding::SER_OPT; use yazi_binding::SER_OPT;
use yazi_shared::{event::CmdCow, strand::StrandBuf}; use yazi_shared::{event::ActionCow, strand::StrandBuf};
#[derive(Clone, Debug, Default, Deserialize, Serialize)] #[derive(Clone, Debug, Default, Deserialize, Serialize)]
pub struct QuitOpt { pub struct QuitOpt {
@ -11,18 +11,18 @@ pub struct QuitOpt {
pub no_cwd_file: bool, pub no_cwd_file: bool,
} }
impl TryFrom<CmdCow> for QuitOpt { impl TryFrom<ActionCow> for QuitOpt {
type Error = anyhow::Error; type Error = anyhow::Error;
fn try_from(mut c: CmdCow) -> Result<Self, Self::Error> { fn try_from(mut a: ActionCow) -> Result<Self, Self::Error> {
if let Some(opt) = c.take_any2("opt") { if let Some(opt) = a.take_any2("opt") {
return opt; return opt;
} }
Ok(Self { Ok(Self {
code: c.get("code").unwrap_or_default(), code: a.get("code").unwrap_or_default(),
selected: None, selected: None,
no_cwd_file: c.bool("no-cwd-file"), no_cwd_file: a.bool("no-cwd-file"),
}) })
} }
} }

View file

@ -2,18 +2,18 @@ use anyhow::bail;
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value}; use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
use ordered_float::OrderedFloat; use ordered_float::OrderedFloat;
use serde::Serialize; use serde::Serialize;
use yazi_shared::event::CmdCow; use yazi_shared::event::ActionCow;
#[derive(Debug)] #[derive(Debug)]
pub struct UpdateProgressOpt { pub struct UpdateProgressOpt {
pub summary: TaskSummary, pub summary: TaskSummary,
} }
impl TryFrom<CmdCow> for UpdateProgressOpt { impl TryFrom<ActionCow> for UpdateProgressOpt {
type Error = anyhow::Error; type Error = anyhow::Error;
fn try_from(mut c: CmdCow) -> Result<Self, Self::Error> { fn try_from(mut a: ActionCow) -> Result<Self, Self::Error> {
let Some(summary) = c.take_any("summary") else { let Some(summary) = a.take_any("summary") else {
bail!("Invalid 'summary' in UpdateProgressOpt"); bail!("Invalid 'summary' in UpdateProgressOpt");
}; };

View file

@ -1,6 +1,6 @@
use anyhow::bail; use anyhow::bail;
use mlua::{ExternalError, IntoLua, Lua, Value}; use mlua::{ExternalError, IntoLua, Lua, Value};
use yazi_shared::event::CmdCow; use yazi_shared::event::ActionCow;
use yazi_widgets::Step; use yazi_widgets::Step;
#[derive(Clone, Copy, Debug, Default)] #[derive(Clone, Copy, Debug, Default)]
@ -8,11 +8,11 @@ pub struct ArrowOpt {
pub step: Step, pub step: Step,
} }
impl TryFrom<CmdCow> for ArrowOpt { impl TryFrom<ActionCow> for ArrowOpt {
type Error = anyhow::Error; type Error = anyhow::Error;
fn try_from(c: CmdCow) -> Result<Self, Self::Error> { fn try_from(a: ActionCow) -> Result<Self, Self::Error> {
let Ok(step) = c.first() else { let Ok(step) = a.first() else {
bail!("Invalid 'step' in ArrowOpt"); bail!("Invalid 'step' in ArrowOpt");
}; };

View file

@ -1,13 +1,13 @@
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value}; use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
use yazi_shared::event::CmdCow; use yazi_shared::event::ActionCow;
#[derive(Debug, Default)] #[derive(Debug, Default)]
pub struct CloseOpt { pub struct CloseOpt {
pub submit: bool, pub submit: bool,
} }
impl From<CmdCow> for CloseOpt { impl From<ActionCow> for CloseOpt {
fn from(c: CmdCow) -> Self { Self { submit: c.bool("submit") } } fn from(a: ActionCow) -> Self { Self { submit: a.bool("submit") } }
} }
impl From<bool> for CloseOpt { impl From<bool> for CloseOpt {

View file

@ -1,6 +1,6 @@
use anyhow::bail; use anyhow::bail;
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value}; use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
use yazi_shared::{Id, event::CmdCow, path::PathBufDyn, strand::StrandBuf, url::UrlBuf}; use yazi_shared::{Id, event::ActionCow, path::PathBufDyn, strand::StrandBuf, url::UrlBuf};
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
pub struct ShowOpt { pub struct ShowOpt {
@ -10,11 +10,11 @@ pub struct ShowOpt {
pub ticket: Id, pub ticket: Id,
} }
impl TryFrom<CmdCow> for ShowOpt { impl TryFrom<ActionCow> for ShowOpt {
type Error = anyhow::Error; type Error = anyhow::Error;
fn try_from(mut c: CmdCow) -> Result<Self, Self::Error> { fn try_from(mut a: ActionCow) -> Result<Self, Self::Error> {
if let Some(opt) = c.take_any2("opt") { if let Some(opt) = a.take_any2("opt") {
opt opt
} else { } else {
bail!("missing 'opt' argument"); bail!("missing 'opt' argument");

View file

@ -1,5 +1,5 @@
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value}; use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
use yazi_shared::{Id, SStr, event::CmdCow}; use yazi_shared::{Id, SStr, event::ActionCow};
#[derive(Debug)] #[derive(Debug)]
pub struct TriggerOpt { pub struct TriggerOpt {
@ -7,9 +7,9 @@ pub struct TriggerOpt {
pub ticket: Option<Id>, pub ticket: Option<Id>,
} }
impl From<CmdCow> for TriggerOpt { impl From<ActionCow> for TriggerOpt {
fn from(mut c: CmdCow) -> Self { fn from(mut a: ActionCow) -> Self {
Self { word: c.take_first().unwrap_or_default(), ticket: c.get("ticket").ok() } Self { word: a.take_first().unwrap_or_default(), ticket: a.get("ticket").ok() }
} }
} }

View file

@ -1,13 +1,13 @@
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value}; use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
use yazi_shared::event::CmdCow; use yazi_shared::event::ActionCow;
#[derive(Debug, Default)] #[derive(Debug, Default)]
pub struct CloseOpt { pub struct CloseOpt {
pub submit: bool, pub submit: bool,
} }
impl From<CmdCow> for CloseOpt { impl From<ActionCow> for CloseOpt {
fn from(c: CmdCow) -> Self { Self { submit: c.bool("submit") } } fn from(a: ActionCow) -> Self { Self { submit: a.bool("submit") } }
} }
impl From<bool> for CloseOpt { impl From<bool> for CloseOpt {

View file

@ -1,7 +1,7 @@
use anyhow::bail; use anyhow::bail;
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value}; use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
use yazi_config::popup::ConfirmCfg; use yazi_config::popup::ConfirmCfg;
use yazi_shared::{CompletionToken, event::CmdCow}; use yazi_shared::{CompletionToken, event::ActionCow};
#[derive(Debug)] #[derive(Debug)]
pub struct ShowOpt { pub struct ShowOpt {
@ -9,15 +9,15 @@ pub struct ShowOpt {
pub token: CompletionToken, pub token: CompletionToken,
} }
impl TryFrom<CmdCow> for ShowOpt { impl TryFrom<ActionCow> for ShowOpt {
type Error = anyhow::Error; type Error = anyhow::Error;
fn try_from(mut c: CmdCow) -> Result<Self, Self::Error> { fn try_from(mut a: ActionCow) -> Result<Self, Self::Error> {
let Some(cfg) = c.take_any("cfg") else { let Some(cfg) = a.take_any("cfg") else {
bail!("Invalid 'cfg' in ShowOpt"); bail!("Invalid 'cfg' in ShowOpt");
}; };
let Some(token) = c.take_any("token") else { let Some(token) = a.take_any("token") else {
bail!("Invalid 'token' in ShowOpt"); bail!("Invalid 'token' in ShowOpt");
}; };

View file

@ -1,15 +1,15 @@
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value}; use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
use yazi_shared::{Layer, event::CmdCow}; use yazi_shared::{Layer, event::ActionCow};
#[derive(Debug)] #[derive(Debug)]
pub struct ToggleOpt { pub struct ToggleOpt {
pub layer: Layer, pub layer: Layer,
} }
impl TryFrom<CmdCow> for ToggleOpt { impl TryFrom<ActionCow> for ToggleOpt {
type Error = anyhow::Error; type Error = anyhow::Error;
fn try_from(c: CmdCow) -> Result<Self, Self::Error> { Ok(Self { layer: c.str(0).parse()? }) } fn try_from(a: ActionCow) -> Result<Self, Self::Error> { Ok(Self { layer: a.str(0).parse()? }) }
} }
impl From<Layer> for ToggleOpt { impl From<Layer> for ToggleOpt {

View file

@ -1,13 +1,13 @@
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value}; use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
use yazi_shared::event::CmdCow; use yazi_shared::event::ActionCow;
#[derive(Debug, Default)] #[derive(Debug, Default)]
pub struct CloseOpt { pub struct CloseOpt {
pub submit: bool, pub submit: bool,
} }
impl From<CmdCow> for CloseOpt { impl From<ActionCow> for CloseOpt {
fn from(c: CmdCow) -> Self { Self { submit: c.bool("submit") } } fn from(a: ActionCow) -> Self { Self { submit: a.bool("submit") } }
} }
impl From<bool> for CloseOpt { impl From<bool> for CloseOpt {

View file

@ -2,7 +2,7 @@ use anyhow::bail;
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value}; use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
use tokio::sync::mpsc; use tokio::sync::mpsc;
use yazi_config::popup::InputCfg; use yazi_config::popup::InputCfg;
use yazi_shared::event::CmdCow; use yazi_shared::event::ActionCow;
use yazi_widgets::input::InputError; use yazi_widgets::input::InputError;
#[derive(Debug)] #[derive(Debug)]
@ -11,15 +11,15 @@ pub struct ShowOpt {
pub tx: mpsc::UnboundedSender<Result<String, InputError>>, pub tx: mpsc::UnboundedSender<Result<String, InputError>>,
} }
impl TryFrom<CmdCow> for ShowOpt { impl TryFrom<ActionCow> for ShowOpt {
type Error = anyhow::Error; type Error = anyhow::Error;
fn try_from(mut c: CmdCow) -> Result<Self, Self::Error> { fn try_from(mut a: ActionCow) -> Result<Self, Self::Error> {
let Some(cfg) = c.take_any("cfg") else { let Some(cfg) = a.take_any("cfg") else {
bail!("Invalid 'cfg' in ShowOpt"); bail!("Invalid 'cfg' in ShowOpt");
}; };
let Some(tx) = c.take_any("tx") else { let Some(tx) = a.take_any("tx") else {
bail!("Invalid 'tx' in ShowOpt"); bail!("Invalid 'tx' in ShowOpt");
}; };

View file

@ -1,7 +1,7 @@
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value}; use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use yazi_fs::path::{clean_url, expand_url}; use yazi_fs::path::{clean_url, expand_url};
use yazi_shared::{event::CmdCow, url::{Url, UrlBuf}}; use yazi_shared::{event::ActionCow, url::{Url, UrlBuf}};
use yazi_vfs::provider; use yazi_vfs::provider;
#[derive(Debug)] #[derive(Debug)]
@ -11,11 +11,11 @@ pub struct CdOpt {
pub source: CdSource, pub source: CdSource,
} }
impl From<CmdCow> for CdOpt { impl From<ActionCow> for CdOpt {
fn from(mut c: CmdCow) -> Self { fn from(mut a: ActionCow) -> Self {
let mut target = c.take_first().unwrap_or_default(); let mut target = a.take_first().unwrap_or_default();
if !c.bool("raw") { if !a.bool("raw") {
target = expand_url(target); target = expand_url(target);
} }
@ -27,7 +27,7 @@ impl From<CmdCow> for CdOpt {
Self { Self {
target: clean_url(target), target: clean_url(target),
interactive: c.bool("interactive"), interactive: a.bool("interactive"),
source: CdSource::Cd, source: CdSource::Cd,
} }
} }

View file

@ -1,15 +1,15 @@
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value}; use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
use yazi_shared::event::CmdCow; use yazi_shared::event::ActionCow;
use crate::app::QuitOpt; use crate::app::QuitOpt;
#[derive(Debug, Default)] #[derive(Debug, Default)]
pub struct CloseOpt(pub QuitOpt); pub struct CloseOpt(pub QuitOpt);
impl TryFrom<CmdCow> for CloseOpt { impl TryFrom<ActionCow> for CloseOpt {
type Error = anyhow::Error; type Error = anyhow::Error;
fn try_from(c: CmdCow) -> Result<Self, Self::Error> { c.try_into().map(Self) } fn try_from(a: ActionCow) -> Result<Self, Self::Error> { a.try_into().map(Self) }
} }
impl FromLua for CloseOpt { impl FromLua for CloseOpt {

View file

@ -2,7 +2,7 @@ use std::{borrow::Cow, str::FromStr};
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value}; use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
use serde::Deserialize; use serde::Deserialize;
use yazi_shared::{SStr, event::CmdCow, strand::AsStrand}; use yazi_shared::{SStr, event::ActionCow, strand::AsStrand};
#[derive(Debug)] #[derive(Debug)]
pub struct CopyOpt { pub struct CopyOpt {
@ -11,12 +11,12 @@ pub struct CopyOpt {
pub hovered: bool, pub hovered: bool,
} }
impl From<CmdCow> for CopyOpt { impl From<ActionCow> for CopyOpt {
fn from(mut c: CmdCow) -> Self { fn from(mut a: ActionCow) -> Self {
Self { Self {
r#type: c.take_first().unwrap_or_default(), r#type: a.take_first().unwrap_or_default(),
separator: c.str("separator").parse().unwrap_or_default(), separator: a.str("separator").parse().unwrap_or_default(),
hovered: c.bool("hovered"), hovered: a.bool("hovered"),
} }
} }
} }

View file

@ -1,5 +1,5 @@
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value}; use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
use yazi_shared::event::CmdCow; use yazi_shared::event::ActionCow;
#[derive(Debug)] #[derive(Debug)]
pub struct CreateOpt { pub struct CreateOpt {
@ -7,8 +7,8 @@ pub struct CreateOpt {
pub force: bool, pub force: bool,
} }
impl From<CmdCow> for CreateOpt { impl From<ActionCow> for CreateOpt {
fn from(c: CmdCow) -> Self { Self { dir: c.bool("dir"), force: c.bool("force") } } fn from(a: ActionCow) -> Self { Self { dir: a.bool("dir"), force: a.bool("force") } }
} }
impl FromLua for CreateOpt { impl FromLua for CreateOpt {

View file

@ -1,6 +1,6 @@
use anyhow::bail; use anyhow::bail;
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value}; use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
use yazi_shared::{event::CmdCow, url::UrlBuf}; use yazi_shared::{event::ActionCow, url::UrlBuf};
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
pub struct DisplaceDoOpt { pub struct DisplaceDoOpt {
@ -8,11 +8,11 @@ pub struct DisplaceDoOpt {
pub from: UrlBuf, pub from: UrlBuf,
} }
impl TryFrom<CmdCow> for DisplaceDoOpt { impl TryFrom<ActionCow> for DisplaceDoOpt {
type Error = anyhow::Error; type Error = anyhow::Error;
fn try_from(mut c: CmdCow) -> Result<Self, Self::Error> { fn try_from(mut a: ActionCow) -> Result<Self, Self::Error> {
if let Some(opt) = c.take_any2("opt") { if let Some(opt) = a.take_any2("opt") {
opt opt
} else { } else {
bail!("Invalid 'opt' in DisplaceDoOpt"); bail!("Invalid 'opt' in DisplaceDoOpt");

View file

@ -1,5 +1,5 @@
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value}; use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
use yazi_shared::{event::CmdCow, url::UrlCow}; use yazi_shared::{event::ActionCow, url::UrlCow};
#[derive(Debug, Default)] #[derive(Debug, Default)]
pub struct DownloadOpt { pub struct DownloadOpt {
@ -7,8 +7,8 @@ pub struct DownloadOpt {
pub open: bool, pub open: bool,
} }
impl From<CmdCow> for DownloadOpt { impl From<ActionCow> for DownloadOpt {
fn from(mut c: CmdCow) -> Self { Self { urls: c.take_seq(), open: c.bool("open") } } fn from(mut a: ActionCow) -> Self { Self { urls: a.take_seq(), open: a.bool("open") } }
} }
impl FromLua for DownloadOpt { impl FromLua for DownloadOpt {

View file

@ -1,6 +1,6 @@
use bitflags::bitflags; use bitflags::bitflags;
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value}; use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
use yazi_shared::event::CmdCow; use yazi_shared::event::ActionCow;
bitflags! { bitflags! {
#[derive(Debug)] #[derive(Debug)]
@ -13,9 +13,9 @@ bitflags! {
} }
} }
impl From<CmdCow> for EscapeOpt { impl From<ActionCow> for EscapeOpt {
fn from(c: CmdCow) -> Self { fn from(a: ActionCow) -> Self {
c.args.iter().fold(Self::empty(), |acc, (k, v)| { a.args.iter().fold(Self::empty(), |acc, (k, v)| {
match (k.as_str().unwrap_or(""), v.try_into().unwrap_or(false)) { match (k.as_str().unwrap_or(""), v.try_into().unwrap_or(false)) {
("all", true) => Self::all(), ("all", true) => Self::all(),
("find", true) => acc | Self::FIND, ("find", true) => acc | Self::FIND,

View file

@ -1,6 +1,6 @@
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value}; use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
use yazi_fs::FilterCase; use yazi_fs::FilterCase;
use yazi_shared::{SStr, event::CmdCow}; use yazi_shared::{SStr, event::ActionCow};
#[derive(Clone, Debug, Default)] #[derive(Clone, Debug, Default)]
pub struct FilterOpt { pub struct FilterOpt {
@ -9,18 +9,18 @@ pub struct FilterOpt {
pub done: bool, pub done: bool,
} }
impl TryFrom<CmdCow> for FilterOpt { impl TryFrom<ActionCow> for FilterOpt {
type Error = anyhow::Error; type Error = anyhow::Error;
fn try_from(mut c: CmdCow) -> Result<Self, Self::Error> { fn try_from(mut a: ActionCow) -> Result<Self, Self::Error> {
if let Some(opt) = c.take_any2("opt") { if let Some(opt) = a.take_any2("opt") {
return opt; return opt;
} }
Ok(Self { Ok(Self {
query: c.take_first().unwrap_or_default(), query: a.take_first().unwrap_or_default(),
case: FilterCase::from(&*c), case: FilterCase::from(&*a),
done: c.bool("done"), done: a.bool("done"),
}) })
} }
} }

View file

@ -1,6 +1,6 @@
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value}; use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
use yazi_fs::FilterCase; use yazi_fs::FilterCase;
use yazi_shared::event::CmdCow; use yazi_shared::event::ActionCow;
#[derive(Debug)] #[derive(Debug)]
pub struct FindOpt { pub struct FindOpt {
@ -8,11 +8,11 @@ pub struct FindOpt {
pub case: FilterCase, pub case: FilterCase,
} }
impl TryFrom<CmdCow> for FindOpt { impl TryFrom<ActionCow> for FindOpt {
type Error = anyhow::Error; type Error = anyhow::Error;
fn try_from(c: CmdCow) -> Result<Self, Self::Error> { fn try_from(a: ActionCow) -> Result<Self, Self::Error> {
Ok(Self { prev: c.bool("previous"), case: FilterCase::from(&*c) }) Ok(Self { prev: a.bool("previous"), case: FilterCase::from(&*a) })
} }
} }

View file

@ -1,13 +1,13 @@
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value}; use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
use yazi_shared::event::CmdCow; use yazi_shared::event::ActionCow;
#[derive(Debug)] #[derive(Debug)]
pub struct FindArrowOpt { pub struct FindArrowOpt {
pub prev: bool, pub prev: bool,
} }
impl From<CmdCow> for FindArrowOpt { impl From<ActionCow> for FindArrowOpt {
fn from(c: CmdCow) -> Self { Self { prev: c.bool("previous") } } fn from(a: ActionCow) -> Self { Self { prev: a.bool("previous") } }
} }
impl FromLua for FindArrowOpt { impl FromLua for FindArrowOpt {

View file

@ -1,7 +1,7 @@
use anyhow::bail; use anyhow::bail;
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value}; use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
use yazi_fs::FilterCase; use yazi_fs::FilterCase;
use yazi_shared::{SStr, event::CmdCow}; use yazi_shared::{SStr, event::ActionCow};
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
pub struct FindDoOpt { pub struct FindDoOpt {
@ -10,19 +10,19 @@ pub struct FindDoOpt {
pub case: FilterCase, pub case: FilterCase,
} }
impl TryFrom<CmdCow> for FindDoOpt { impl TryFrom<ActionCow> for FindDoOpt {
type Error = anyhow::Error; type Error = anyhow::Error;
fn try_from(mut c: CmdCow) -> Result<Self, Self::Error> { fn try_from(mut a: ActionCow) -> Result<Self, Self::Error> {
if let Some(opt) = c.take_any2("opt") { if let Some(opt) = a.take_any2("opt") {
return opt; return opt;
} }
let Ok(query) = c.take_first() else { let Ok(query) = a.take_first() else {
bail!("Invalid 'query' in FindDoOpt"); bail!("Invalid 'query' in FindDoOpt");
}; };
Ok(Self { query, prev: c.bool("previous"), case: FilterCase::from(&*c) }) Ok(Self { query, prev: a.bool("previous"), case: FilterCase::from(&*a) })
} }
} }

View file

@ -1,5 +1,5 @@
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value}; use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
use yazi_shared::event::CmdCow; use yazi_shared::event::ActionCow;
#[derive(Debug)] #[derive(Debug)]
pub struct HardlinkOpt { pub struct HardlinkOpt {
@ -7,8 +7,8 @@ pub struct HardlinkOpt {
pub follow: bool, pub follow: bool,
} }
impl From<CmdCow> for HardlinkOpt { impl From<ActionCow> for HardlinkOpt {
fn from(c: CmdCow) -> Self { Self { force: c.bool("force"), follow: c.bool("follow") } } fn from(a: ActionCow) -> Self { Self { force: a.bool("force"), follow: a.bool("follow") } }
} }
impl FromLua for HardlinkOpt { impl FromLua for HardlinkOpt {

View file

@ -2,18 +2,18 @@ use std::str::FromStr;
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value}; use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use yazi_shared::event::CmdCow; use yazi_shared::event::ActionCow;
#[derive(Debug, Default)] #[derive(Debug, Default)]
pub struct HiddenOpt { pub struct HiddenOpt {
pub state: HiddenOptState, pub state: HiddenOptState,
} }
impl TryFrom<CmdCow> for HiddenOpt { impl TryFrom<ActionCow> for HiddenOpt {
type Error = anyhow::Error; type Error = anyhow::Error;
fn try_from(c: CmdCow) -> Result<Self, Self::Error> { fn try_from(a: ActionCow) -> Result<Self, Self::Error> {
Ok(Self { state: c.str(0).parse().unwrap_or_default() }) Ok(Self { state: a.str(0).parse().unwrap_or_default() })
} }
} }

View file

@ -1,17 +1,17 @@
use anyhow::bail; use anyhow::bail;
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value}; use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
use yazi_shared::{SStr, event::CmdCow}; use yazi_shared::{SStr, event::ActionCow};
#[derive(Debug)] #[derive(Debug)]
pub struct LinemodeOpt { pub struct LinemodeOpt {
pub new: SStr, pub new: SStr,
} }
impl TryFrom<CmdCow> for LinemodeOpt { impl TryFrom<ActionCow> for LinemodeOpt {
type Error = anyhow::Error; type Error = anyhow::Error;
fn try_from(mut c: CmdCow) -> Result<Self, Self::Error> { fn try_from(mut a: ActionCow) -> Result<Self, Self::Error> {
let Ok(new) = c.take_first::<SStr>() else { let Ok(new) = a.take_first::<SStr>() else {
bail!("a string argument is required for LinemodeOpt"); bail!("a string argument is required for LinemodeOpt");
}; };

View file

@ -1,5 +1,5 @@
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value}; use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
use yazi_shared::event::CmdCow; use yazi_shared::event::ActionCow;
#[derive(Debug)] #[derive(Debug)]
pub struct LinkOpt { pub struct LinkOpt {
@ -7,8 +7,8 @@ pub struct LinkOpt {
pub force: bool, pub force: bool,
} }
impl From<CmdCow> for LinkOpt { impl From<ActionCow> for LinkOpt {
fn from(c: CmdCow) -> Self { Self { relative: c.bool("relative"), force: c.bool("force") } } fn from(a: ActionCow) -> Self { Self { relative: a.bool("relative"), force: a.bool("force") } }
} }
impl FromLua for LinkOpt { impl FromLua for LinkOpt {

View file

@ -1,5 +1,5 @@
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value}; use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
use yazi_shared::{event::CmdCow, url::UrlCow}; use yazi_shared::{event::ActionCow, url::UrlCow};
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
pub struct OpenOpt { pub struct OpenOpt {
@ -9,19 +9,19 @@ pub struct OpenOpt {
pub hovered: bool, pub hovered: bool,
} }
impl TryFrom<CmdCow> for OpenOpt { impl TryFrom<ActionCow> for OpenOpt {
type Error = anyhow::Error; type Error = anyhow::Error;
fn try_from(mut c: CmdCow) -> Result<Self, Self::Error> { fn try_from(mut a: ActionCow) -> Result<Self, Self::Error> {
if let Some(opt) = c.take_any2("opt") { if let Some(opt) = a.take_any2("opt") {
return opt; return opt;
} }
Ok(Self { Ok(Self {
cwd: c.take("cwd").ok(), cwd: a.take("cwd").ok(),
targets: c.take_seq(), targets: a.take_seq(),
interactive: c.bool("interactive"), interactive: a.bool("interactive"),
hovered: c.bool("hovered"), hovered: a.bool("hovered"),
}) })
} }
} }

View file

@ -1,6 +1,6 @@
use anyhow::bail; use anyhow::bail;
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value}; use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
use yazi_shared::{event::CmdCow, url::UrlCow}; use yazi_shared::{event::ActionCow, url::UrlCow};
#[derive(Clone, Debug, Default)] #[derive(Clone, Debug, Default)]
pub struct OpenDoOpt { pub struct OpenDoOpt {
@ -9,11 +9,11 @@ pub struct OpenDoOpt {
pub interactive: bool, pub interactive: bool,
} }
impl TryFrom<CmdCow> for OpenDoOpt { impl TryFrom<ActionCow> for OpenDoOpt {
type Error = anyhow::Error; type Error = anyhow::Error;
fn try_from(mut c: CmdCow) -> Result<Self, Self::Error> { fn try_from(mut a: ActionCow) -> Result<Self, Self::Error> {
if let Some(opt) = c.take_any2("opt") { if let Some(opt) = a.take_any2("opt") {
opt opt
} else { } else {
bail!("Invalid 'opt' in OpenDoOpt"); bail!("Invalid 'opt' in OpenDoOpt");

View file

@ -1,5 +1,5 @@
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value}; use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
use yazi_shared::event::CmdCow; use yazi_shared::event::ActionCow;
#[derive(Debug)] #[derive(Debug)]
pub struct PasteOpt { pub struct PasteOpt {
@ -7,8 +7,8 @@ pub struct PasteOpt {
pub follow: bool, pub follow: bool,
} }
impl From<CmdCow> for PasteOpt { impl From<ActionCow> for PasteOpt {
fn from(c: CmdCow) -> Self { Self { force: c.bool("force"), follow: c.bool("follow") } } fn from(a: ActionCow) -> Self { Self { force: a.bool("force"), follow: a.bool("follow") } }
} }
impl FromLua for PasteOpt { impl FromLua for PasteOpt {

View file

@ -1,5 +1,5 @@
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value}; use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
use yazi_shared::{event::CmdCow, url::UrlCow}; use yazi_shared::{event::ActionCow, url::UrlCow};
#[derive(Debug, Default)] #[derive(Debug, Default)]
pub struct PeekOpt { pub struct PeekOpt {
@ -9,13 +9,13 @@ pub struct PeekOpt {
pub upper_bound: bool, pub upper_bound: bool,
} }
impl From<CmdCow> for PeekOpt { impl From<ActionCow> for PeekOpt {
fn from(mut c: CmdCow) -> Self { fn from(mut a: ActionCow) -> Self {
Self { Self {
skip: c.first().ok(), skip: a.first().ok(),
force: c.bool("force"), force: a.bool("force"),
only_if: c.take("only-if").ok(), only_if: a.take("only-if").ok(),
upper_bound: c.bool("upper-bound"), upper_bound: a.bool("upper-bound"),
} }
} }
} }

View file

@ -1,5 +1,5 @@
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value}; use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
use yazi_shared::{event::CmdCow, url::UrlBuf}; use yazi_shared::{event::ActionCow, url::UrlBuf};
#[derive(Debug)] #[derive(Debug)]
pub struct RemoveOpt { pub struct RemoveOpt {
@ -9,13 +9,13 @@ pub struct RemoveOpt {
pub targets: Vec<UrlBuf>, pub targets: Vec<UrlBuf>,
} }
impl From<CmdCow> for RemoveOpt { impl From<ActionCow> for RemoveOpt {
fn from(mut c: CmdCow) -> Self { fn from(mut a: ActionCow) -> Self {
Self { Self {
force: c.bool("force"), force: a.bool("force"),
permanently: c.bool("permanently"), permanently: a.bool("permanently"),
hovered: c.bool("hovered"), hovered: a.bool("hovered"),
targets: c.take_any("targets").unwrap_or_default(), targets: a.take_any("targets").unwrap_or_default(),
} }
} }
} }

View file

@ -1,5 +1,5 @@
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value}; use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
use yazi_shared::{SStr, event::CmdCow}; use yazi_shared::{SStr, event::ActionCow};
#[derive(Debug)] #[derive(Debug)]
pub struct RenameOpt { pub struct RenameOpt {
@ -9,13 +9,13 @@ pub struct RenameOpt {
pub cursor: SStr, pub cursor: SStr,
} }
impl From<CmdCow> for RenameOpt { impl From<ActionCow> for RenameOpt {
fn from(mut c: CmdCow) -> Self { fn from(mut a: ActionCow) -> Self {
Self { Self {
hovered: c.bool("hovered"), hovered: a.bool("hovered"),
force: c.bool("force"), force: a.bool("force"),
empty: c.take("empty").unwrap_or_default(), empty: a.take("empty").unwrap_or_default(),
cursor: c.take("cursor").unwrap_or_default(), cursor: a.take("cursor").unwrap_or_default(),
} }
} }
} }

View file

@ -1,6 +1,6 @@
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value}; use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
use yazi_fs::path::{clean_url, expand_url}; use yazi_fs::path::{clean_url, expand_url};
use yazi_shared::{event::CmdCow, url::UrlBuf}; use yazi_shared::{event::ActionCow, url::UrlBuf};
use yazi_vfs::provider; use yazi_vfs::provider;
use crate::mgr::CdSource; use crate::mgr::CdSource;
@ -12,11 +12,11 @@ pub struct RevealOpt {
pub no_dummy: bool, pub no_dummy: bool,
} }
impl From<CmdCow> for RevealOpt { impl From<ActionCow> for RevealOpt {
fn from(mut c: CmdCow) -> Self { fn from(mut a: ActionCow) -> Self {
let mut target = c.take_first().unwrap_or_default(); let mut target = a.take_first().unwrap_or_default();
if !c.bool("raw") { if !a.bool("raw") {
target = expand_url(target); target = expand_url(target);
} }
@ -26,7 +26,7 @@ impl From<CmdCow> for RevealOpt {
target = u.into_static(); target = u.into_static();
} }
Self { target: clean_url(target), source: CdSource::Reveal, no_dummy: c.bool("no-dummy") } Self { target: clean_url(target), source: CdSource::Reveal, no_dummy: a.bool("no-dummy") }
} }
} }

View file

@ -3,7 +3,7 @@ use std::str::FromStr;
use anyhow::bail; use anyhow::bail;
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value}; use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
use serde::Deserialize; use serde::Deserialize;
use yazi_shared::{SStr, event::CmdCow}; use yazi_shared::{SStr, event::ActionCow};
#[derive(Debug)] #[derive(Debug)]
pub struct SearchOpt { pub struct SearchOpt {
@ -13,18 +13,18 @@ pub struct SearchOpt {
pub args_raw: SStr, pub args_raw: SStr,
} }
impl TryFrom<CmdCow> for SearchOpt { impl TryFrom<ActionCow> for SearchOpt {
type Error = anyhow::Error; type Error = anyhow::Error;
fn try_from(mut c: CmdCow) -> Result<Self, Self::Error> { fn try_from(mut a: ActionCow) -> Result<Self, Self::Error> {
// TODO: remove this // TODO: remove this
let (via, subject) = if let Ok(s) = c.get("via") { let (via, subject) = if let Ok(s) = a.get("via") {
(str::parse(s)?, c.take_first().unwrap_or_default()) (str::parse(s)?, a.take_first().unwrap_or_default())
} else { } else {
(c.str(0).parse()?, "".into()) (a.str(0).parse()?, "".into())
}; };
let Ok(args) = yazi_shared::shell::unix::split(c.str("args"), false) else { let Ok(args) = yazi_shared::shell::unix::split(a.str("args"), false) else {
bail!("Invalid 'args' in SearchOpt"); bail!("Invalid 'args' in SearchOpt");
}; };
@ -33,7 +33,7 @@ impl TryFrom<CmdCow> for SearchOpt {
subject, subject,
// TODO: use second positional argument instead of `args` parameter // TODO: use second positional argument instead of `args` parameter
args: args.0, args: args.0,
args_raw: c.take("args").unwrap_or_default(), args_raw: a.take("args").unwrap_or_default(),
}) })
} }
} }

View file

@ -1,13 +1,13 @@
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value}; use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
use yazi_shared::event::CmdCow; use yazi_shared::event::ActionCow;
#[derive(Debug)] #[derive(Debug)]
pub struct SeekOpt { pub struct SeekOpt {
pub units: i16, pub units: i16,
} }
impl From<CmdCow> for SeekOpt { impl From<ActionCow> for SeekOpt {
fn from(c: CmdCow) -> Self { Self { units: c.first().unwrap_or(0) } } fn from(a: ActionCow) -> Self { Self { units: a.first().unwrap_or(0) } }
} }
impl FromLua for SeekOpt { impl FromLua for SeekOpt {

View file

@ -1,6 +1,6 @@
use anyhow::bail; use anyhow::bail;
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value}; use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
use yazi_shared::{SStr, event::CmdCow, url::UrlCow}; use yazi_shared::{SStr, event::ActionCow, url::UrlCow};
#[derive(Debug)] #[derive(Debug)]
pub struct ShellOpt { pub struct ShellOpt {
@ -14,19 +14,19 @@ pub struct ShellOpt {
pub cursor: Option<usize>, pub cursor: Option<usize>,
} }
impl TryFrom<CmdCow> for ShellOpt { impl TryFrom<ActionCow> for ShellOpt {
type Error = anyhow::Error; type Error = anyhow::Error;
fn try_from(mut c: CmdCow) -> Result<Self, Self::Error> { fn try_from(mut a: ActionCow) -> Result<Self, Self::Error> {
let me = Self { let me = Self {
run: c.take_first().unwrap_or_default(), run: a.take_first().unwrap_or_default(),
cwd: c.take("cwd").ok(), cwd: a.take("cwd").ok(),
block: c.bool("block"), block: a.bool("block"),
orphan: c.bool("orphan"), orphan: a.bool("orphan"),
interactive: c.bool("interactive"), interactive: a.bool("interactive"),
cursor: c.get("cursor").ok(), cursor: a.get("cursor").ok(),
}; };
if me.cursor.is_some_and(|c| c > me.run.chars().count()) { if me.cursor.is_some_and(|c| c > me.run.chars().count()) {

View file

@ -2,7 +2,7 @@ use mlua::{FromLua, IntoLua, Lua, LuaSerdeExt, Value};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use yazi_binding::SER_OPT; use yazi_binding::SER_OPT;
use yazi_fs::{SortBy, SortFallback}; use yazi_fs::{SortBy, SortFallback};
use yazi_shared::event::CmdCow; use yazi_shared::event::ActionCow;
#[derive(Debug, Default, Deserialize, Serialize)] #[derive(Debug, Default, Deserialize, Serialize)]
pub struct SortOpt { pub struct SortOpt {
@ -14,17 +14,17 @@ pub struct SortOpt {
pub fallback: Option<SortFallback>, pub fallback: Option<SortFallback>,
} }
impl TryFrom<CmdCow> for SortOpt { impl TryFrom<ActionCow> for SortOpt {
type Error = anyhow::Error; type Error = anyhow::Error;
fn try_from(c: CmdCow) -> Result<Self, Self::Error> { fn try_from(a: ActionCow) -> Result<Self, Self::Error> {
Ok(Self { Ok(Self {
by: c.first().ok().map(str::parse).transpose()?, by: a.first().ok().map(str::parse).transpose()?,
reverse: c.get("reverse").ok(), reverse: a.get("reverse").ok(),
dir_first: c.get("dir-first").ok(), dir_first: a.get("dir-first").ok(),
sensitive: c.get("sensitive").ok(), sensitive: a.get("sensitive").ok(),
translit: c.get("translit").ok(), translit: a.get("translit").ok(),
fallback: c.get("fallback").ok().map(str::parse).transpose()?, fallback: a.get("fallback").ok().map(str::parse).transpose()?,
}) })
} }
} }

View file

@ -1,13 +1,13 @@
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value}; use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
use yazi_shared::event::CmdCow; use yazi_shared::event::ActionCow;
#[derive(Debug, Default)] #[derive(Debug, Default)]
pub struct SpotOpt { pub struct SpotOpt {
pub skip: Option<usize>, pub skip: Option<usize>,
} }
impl From<CmdCow> for SpotOpt { impl From<ActionCow> for SpotOpt {
fn from(c: CmdCow) -> Self { Self { skip: c.get("skip").ok() } } fn from(a: ActionCow) -> Self { Self { skip: a.get("skip").ok() } }
} }
impl From<usize> for SpotOpt { impl From<usize> for SpotOpt {

View file

@ -2,7 +2,7 @@ use anyhow::bail;
use mlua::{ExternalError, FromLua, IntoLua, Lua, LuaSerdeExt, Value}; use mlua::{ExternalError, FromLua, IntoLua, Lua, LuaSerdeExt, Value};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use yazi_binding::{SER_OPT, Url}; use yazi_binding::{SER_OPT, Url};
use yazi_shared::{event::CmdCow, url::UrlBuf}; use yazi_shared::{event::ActionCow, url::UrlBuf};
use crate::mgr::{CdOpt, CdSource}; use crate::mgr::{CdOpt, CdSource};
@ -12,10 +12,10 @@ pub struct StashOpt {
pub source: CdSource, pub source: CdSource,
} }
impl TryFrom<CmdCow> for StashOpt { impl TryFrom<ActionCow> for StashOpt {
type Error = anyhow::Error; type Error = anyhow::Error;
fn try_from(_: CmdCow) -> Result<Self, Self::Error> { bail!("unsupported") } fn try_from(_: ActionCow) -> Result<Self, Self::Error> { bail!("unsupported") }
} }
impl From<CdOpt> for StashOpt { impl From<CdOpt> for StashOpt {

View file

@ -1,13 +1,13 @@
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value}; use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
use yazi_shared::event::CmdCow; use yazi_shared::event::ActionCow;
#[derive(Debug)] #[derive(Debug)]
pub struct TabCloseOpt { pub struct TabCloseOpt {
pub idx: usize, pub idx: usize,
} }
impl From<CmdCow> for TabCloseOpt { impl From<ActionCow> for TabCloseOpt {
fn from(c: CmdCow) -> Self { Self { idx: c.first().unwrap_or(0) } } fn from(a: ActionCow) -> Self { Self { idx: a.first().unwrap_or(0) } }
} }
impl From<usize> for TabCloseOpt { impl From<usize> for TabCloseOpt {

View file

@ -1,7 +1,7 @@
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value}; use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
use yazi_boot::BOOT; use yazi_boot::BOOT;
use yazi_fs::path::{clean_url, expand_url}; use yazi_fs::path::{clean_url, expand_url};
use yazi_shared::{event::CmdCow, url::UrlCow}; use yazi_shared::{event::ActionCow, url::UrlCow};
use yazi_vfs::provider; use yazi_vfs::provider;
#[derive(Debug)] #[derive(Debug)]
@ -9,17 +9,17 @@ pub struct TabCreateOpt {
pub url: Option<UrlCow<'static>>, pub url: Option<UrlCow<'static>>,
} }
impl From<CmdCow> for TabCreateOpt { impl From<ActionCow> for TabCreateOpt {
fn from(mut c: CmdCow) -> Self { fn from(mut a: ActionCow) -> Self {
if c.bool("current") { if a.bool("current") {
return Self { url: None }; return Self { url: None };
} }
let Ok(mut url) = c.take_first() else { let Ok(mut url) = a.take_first() else {
return Self { url: Some(UrlCow::from(&BOOT.cwds[0])) }; return Self { url: Some(UrlCow::from(&BOOT.cwds[0])) };
}; };
if !c.bool("raw") { if !a.bool("raw") {
url = expand_url(url); url = expand_url(url);
} }

View file

@ -1,6 +1,6 @@
use anyhow::bail; use anyhow::bail;
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value}; use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
use yazi_shared::{SStr, event::CmdCow}; use yazi_shared::{SStr, event::ActionCow};
#[derive(Debug)] #[derive(Debug)]
pub struct TabRenameOpt { pub struct TabRenameOpt {
@ -8,12 +8,12 @@ pub struct TabRenameOpt {
pub interactive: bool, pub interactive: bool,
} }
impl TryFrom<CmdCow> for TabRenameOpt { impl TryFrom<ActionCow> for TabRenameOpt {
type Error = anyhow::Error; type Error = anyhow::Error;
fn try_from(mut c: CmdCow) -> Result<Self, Self::Error> { fn try_from(mut a: ActionCow) -> Result<Self, Self::Error> {
let name = c.take_first().ok(); let name = a.take_first().ok();
let interactive = c.bool("interactive"); let interactive = a.bool("interactive");
if name.is_none() && !interactive { if name.is_none() && !interactive {
bail!("either name or interactive must be specified in TabRenameOpt"); bail!("either name or interactive must be specified in TabRenameOpt");

View file

@ -1,5 +1,5 @@
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value}; use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
use yazi_shared::event::CmdCow; use yazi_shared::event::ActionCow;
#[derive(Debug)] #[derive(Debug)]
pub struct TabSwitchOpt { pub struct TabSwitchOpt {
@ -7,8 +7,10 @@ pub struct TabSwitchOpt {
pub relative: bool, pub relative: bool,
} }
impl From<CmdCow> for TabSwitchOpt { impl From<ActionCow> for TabSwitchOpt {
fn from(c: CmdCow) -> Self { Self { step: c.first().unwrap_or(0), relative: c.bool("relative") } } fn from(a: ActionCow) -> Self {
Self { step: a.first().unwrap_or(0), relative: a.bool("relative") }
}
} }
impl FromLua for TabSwitchOpt { impl FromLua for TabSwitchOpt {

View file

@ -1,5 +1,5 @@
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value}; use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
use yazi_shared::{event::CmdCow, url::UrlCow}; use yazi_shared::{event::ActionCow, url::UrlCow};
#[derive(Debug)] #[derive(Debug)]
pub struct ToggleOpt { pub struct ToggleOpt {
@ -7,11 +7,11 @@ pub struct ToggleOpt {
pub state: Option<bool>, pub state: Option<bool>,
} }
impl From<CmdCow> for ToggleOpt { impl From<ActionCow> for ToggleOpt {
fn from(mut c: CmdCow) -> Self { fn from(mut a: ActionCow) -> Self {
Self { Self {
url: c.take_first().ok(), url: a.take_first().ok(),
state: match c.get("state") { state: match a.get("state") {
Ok("on") => Some(true), Ok("on") => Some(true),
Ok("off") => Some(false), Ok("off") => Some(false),
_ => None, _ => None,

View file

@ -1,5 +1,5 @@
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value}; use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
use yazi_shared::{event::CmdCow, url::UrlCow}; use yazi_shared::{event::ActionCow, url::UrlCow};
#[derive(Debug)] #[derive(Debug)]
pub struct ToggleAllOpt { pub struct ToggleAllOpt {
@ -7,11 +7,11 @@ pub struct ToggleAllOpt {
pub state: Option<bool>, pub state: Option<bool>,
} }
impl From<CmdCow> for ToggleAllOpt { impl From<ActionCow> for ToggleAllOpt {
fn from(mut c: CmdCow) -> Self { fn from(mut a: ActionCow) -> Self {
Self { Self {
urls: c.take_seq(), urls: a.take_seq(),
state: match c.get("state") { state: match a.get("state") {
Ok("on") => Some(true), Ok("on") => Some(true),
Ok("off") => Some(false), Ok("off") => Some(false),
_ => None, _ => None,

View file

@ -1,18 +1,18 @@
use anyhow::bail; use anyhow::bail;
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value}; use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
use yazi_fs::FilesOp; use yazi_fs::FilesOp;
use yazi_shared::event::CmdCow; use yazi_shared::event::ActionCow;
#[derive(Debug)] #[derive(Debug)]
pub struct UpdateFilesOpt { pub struct UpdateFilesOpt {
pub op: FilesOp, pub op: FilesOp,
} }
impl TryFrom<CmdCow> for UpdateFilesOpt { impl TryFrom<ActionCow> for UpdateFilesOpt {
type Error = anyhow::Error; type Error = anyhow::Error;
fn try_from(mut c: CmdCow) -> Result<Self, Self::Error> { fn try_from(mut a: ActionCow) -> Result<Self, Self::Error> {
let Some(op) = c.take_any("op") else { let Some(op) = a.take_any("op") else {
bail!("Invalid 'op' in UpdateFilesOpt"); bail!("Invalid 'op' in UpdateFilesOpt");
}; };

View file

@ -1,18 +1,18 @@
use anyhow::bail; use anyhow::bail;
use hashbrown::HashMap; use hashbrown::HashMap;
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value}; use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
use yazi_shared::{data::{Data, DataKey}, event::CmdCow}; use yazi_shared::{data::{Data, DataKey}, event::ActionCow};
#[derive(Debug)] #[derive(Debug)]
pub struct UpdateMimesOpt { pub struct UpdateMimesOpt {
pub updates: HashMap<DataKey, Data>, pub updates: HashMap<DataKey, Data>,
} }
impl TryFrom<CmdCow> for UpdateMimesOpt { impl TryFrom<ActionCow> for UpdateMimesOpt {
type Error = anyhow::Error; type Error = anyhow::Error;
fn try_from(mut c: CmdCow) -> Result<Self, Self::Error> { fn try_from(mut a: ActionCow) -> Result<Self, Self::Error> {
let Ok(updates) = c.take("updates") else { let Ok(updates) = a.take("updates") else {
bail!("Invalid 'updates' in UpdateMimesOpt"); bail!("Invalid 'updates' in UpdateMimesOpt");
}; };

View file

@ -1,5 +1,5 @@
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value}; use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
use yazi_shared::{event::CmdCow, url::UrlCow}; use yazi_shared::{event::ActionCow, url::UrlCow};
#[derive(Debug, Default)] #[derive(Debug, Default)]
pub struct UpdatePagedOpt { pub struct UpdatePagedOpt {
@ -7,8 +7,10 @@ pub struct UpdatePagedOpt {
pub only_if: Option<UrlCow<'static>>, pub only_if: Option<UrlCow<'static>>,
} }
impl From<CmdCow> for UpdatePagedOpt { impl From<ActionCow> for UpdatePagedOpt {
fn from(mut c: CmdCow) -> Self { Self { page: c.first().ok(), only_if: c.take("only-if").ok() } } fn from(mut a: ActionCow) -> Self {
Self { page: a.first().ok(), only_if: a.take("only-if").ok() }
}
} }
impl From<()> for UpdatePagedOpt { impl From<()> for UpdatePagedOpt {

View file

@ -1,22 +1,22 @@
use anyhow::bail; use anyhow::bail;
use mlua::{ExternalError, FromLua, IntoLua, Lua, Table, Value}; use mlua::{ExternalError, FromLua, IntoLua, Lua, Table, Value};
use yazi_binding::{FileRef, elements::{Rect, Renderable}}; use yazi_binding::{FileRef, elements::{Rect, Renderable}};
use yazi_shared::event::CmdCow; use yazi_shared::event::ActionCow;
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
pub struct UpdatePeekedOpt { pub struct UpdatePeekedOpt {
pub lock: PreviewLock, pub lock: PreviewLock,
} }
impl TryFrom<CmdCow> for UpdatePeekedOpt { impl TryFrom<ActionCow> for UpdatePeekedOpt {
type Error = anyhow::Error; type Error = anyhow::Error;
fn try_from(mut c: CmdCow) -> Result<Self, Self::Error> { fn try_from(mut a: ActionCow) -> Result<Self, Self::Error> {
if let Some(opt) = c.take_any2("opt") { if let Some(opt) = a.take_any2("opt") {
return opt; return opt;
} }
let Some(lock) = c.take_any("lock") else { let Some(lock) = a.take_any("lock") else {
bail!("Invalid 'lock' in UpdatePeekedOpt"); bail!("Invalid 'lock' in UpdatePeekedOpt");
}; };

View file

@ -1,22 +1,22 @@
use anyhow::bail; use anyhow::bail;
use mlua::{ExternalError, FromLua, IntoLua, Lua, Table, Value}; use mlua::{ExternalError, FromLua, IntoLua, Lua, Table, Value};
use yazi_binding::{FileRef, elements::Renderable}; use yazi_binding::{FileRef, elements::Renderable};
use yazi_shared::{Id, event::CmdCow}; use yazi_shared::{Id, event::ActionCow};
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
pub struct UpdateSpottedOpt { pub struct UpdateSpottedOpt {
pub lock: SpotLock, pub lock: SpotLock,
} }
impl TryFrom<CmdCow> for UpdateSpottedOpt { impl TryFrom<ActionCow> for UpdateSpottedOpt {
type Error = anyhow::Error; type Error = anyhow::Error;
fn try_from(mut c: CmdCow) -> Result<Self, Self::Error> { fn try_from(mut a: ActionCow) -> Result<Self, Self::Error> {
if let Some(opt) = c.take_any2("opt") { if let Some(opt) = a.take_any2("opt") {
return opt; return opt;
} }
let Some(lock) = c.take_any("lock") else { let Some(lock) = a.take_any("lock") else {
bail!("Invalid 'lock' in UpdateSpottedOpt"); bail!("Invalid 'lock' in UpdateSpottedOpt");
}; };

View file

@ -5,7 +5,7 @@ use hashbrown::HashSet;
use mlua::{AnyUserData, ExternalError, FromLua, IntoLua, Lua, MetaMethod, MultiValue, ObjectLike, UserData, UserDataFields, UserDataMethods, Value}; use mlua::{AnyUserData, ExternalError, FromLua, IntoLua, Lua, MetaMethod, MultiValue, ObjectLike, UserData, UserDataFields, UserDataMethods, Value};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use yazi_binding::get_metatable; use yazi_binding::get_metatable;
use yazi_shared::{event::CmdCow, url::UrlBufCov}; use yazi_shared::{event::ActionCow, url::UrlBufCov};
type Iter = yazi_binding::Iter< type Iter = yazi_binding::Iter<
std::iter::Map<hashbrown::hash_set::IntoIter<UrlBufCov>, fn(UrlBufCov) -> yazi_binding::Url>, std::iter::Map<hashbrown::hash_set::IntoIter<UrlBufCov>, fn(UrlBufCov) -> yazi_binding::Url>,
@ -18,11 +18,11 @@ pub struct UpdateYankedOpt<'a> {
pub urls: Cow<'a, HashSet<UrlBufCov>>, pub urls: Cow<'a, HashSet<UrlBufCov>>,
} }
impl TryFrom<CmdCow> for UpdateYankedOpt<'_> { impl TryFrom<ActionCow> for UpdateYankedOpt<'_> {
type Error = anyhow::Error; type Error = anyhow::Error;
fn try_from(mut c: CmdCow) -> Result<Self, Self::Error> { fn try_from(mut a: ActionCow) -> Result<Self, Self::Error> {
if let Some(opt) = c.take_any2("opt") { if let Some(opt) = a.take_any2("opt") {
opt opt
} else { } else {
bail!("Invalid 'opt' in UpdateYankedOpt"); bail!("Invalid 'opt' in UpdateYankedOpt");

View file

@ -1,13 +1,13 @@
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value}; use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
use yazi_shared::{event::CmdCow, url::UrlCow}; use yazi_shared::{event::ActionCow, url::UrlCow};
#[derive(Debug, Default)] #[derive(Debug, Default)]
pub struct UploadOpt { pub struct UploadOpt {
pub urls: Vec<UrlCow<'static>>, pub urls: Vec<UrlCow<'static>>,
} }
impl From<CmdCow> for UploadOpt { impl From<ActionCow> for UploadOpt {
fn from(mut c: CmdCow) -> Self { Self { urls: c.take_seq() } } fn from(mut a: ActionCow) -> Self { Self { urls: a.take_seq() } }
} }
impl FromLua for UploadOpt { impl FromLua for UploadOpt {

View file

@ -1,13 +1,13 @@
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value}; use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
use yazi_shared::event::CmdCow; use yazi_shared::event::ActionCow;
#[derive(Debug)] #[derive(Debug)]
pub struct VisualModeOpt { pub struct VisualModeOpt {
pub unset: bool, pub unset: bool,
} }
impl From<CmdCow> for VisualModeOpt { impl From<ActionCow> for VisualModeOpt {
fn from(c: CmdCow) -> Self { Self { unset: c.bool("unset") } } fn from(a: ActionCow) -> Self { Self { unset: a.bool("unset") } }
} }
impl FromLua for VisualModeOpt { impl FromLua for VisualModeOpt {

View file

@ -1,13 +1,13 @@
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value}; use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
use yazi_shared::event::CmdCow; use yazi_shared::event::ActionCow;
#[derive(Debug)] #[derive(Debug)]
pub struct YankOpt { pub struct YankOpt {
pub cut: bool, pub cut: bool,
} }
impl From<CmdCow> for YankOpt { impl From<ActionCow> for YankOpt {
fn from(c: CmdCow) -> Self { Self { cut: c.bool("cut") } } fn from(a: ActionCow) -> Self { Self { cut: a.bool("cut") } }
} }
impl FromLua for YankOpt { impl FromLua for YankOpt {

View file

@ -6,7 +6,7 @@ use serde::{Deserialize, Serialize};
use serde_with::{DurationSecondsWithFrac, serde_as}; use serde_with::{DurationSecondsWithFrac, serde_as};
use yazi_binding::SER_OPT; use yazi_binding::SER_OPT;
use yazi_config::{Style, THEME}; use yazi_config::{Style, THEME};
use yazi_shared::event::CmdCow; use yazi_shared::event::ActionCow;
#[serde_as] #[serde_as]
#[derive(Clone, Debug, Deserialize, Serialize)] #[derive(Clone, Debug, Deserialize, Serialize)]
@ -19,11 +19,11 @@ pub struct PushOpt {
pub timeout: Duration, pub timeout: Duration,
} }
impl TryFrom<CmdCow> for PushOpt { impl TryFrom<ActionCow> for PushOpt {
type Error = anyhow::Error; type Error = anyhow::Error;
fn try_from(mut c: CmdCow) -> Result<Self, Self::Error> { fn try_from(mut a: ActionCow) -> Result<Self, Self::Error> {
c.take_any("opt").ok_or_else(|| anyhow!("Invalid 'opt' in NotifyOpt")) a.take_any("opt").ok_or_else(|| anyhow!("Invalid 'opt' in NotifyOpt"))
} }
} }

View file

@ -2,18 +2,18 @@ use std::time::Duration;
use anyhow::bail; use anyhow::bail;
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value}; use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
use yazi_shared::event::CmdCow; use yazi_shared::event::ActionCow;
#[derive(Debug, Default)] #[derive(Debug, Default)]
pub struct TickOpt { pub struct TickOpt {
pub interval: Duration, pub interval: Duration,
} }
impl TryFrom<CmdCow> for TickOpt { impl TryFrom<ActionCow> for TickOpt {
type Error = anyhow::Error; type Error = anyhow::Error;
fn try_from(c: CmdCow) -> Result<Self, Self::Error> { fn try_from(a: ActionCow) -> Result<Self, Self::Error> {
let Ok(interval) = c.first() else { let Ok(interval) = a.first() else {
bail!("Invalid 'interval' in TickOpt"); bail!("Invalid 'interval' in TickOpt");
}; };

View file

@ -1,13 +1,13 @@
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value}; use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
use yazi_shared::event::CmdCow; use yazi_shared::event::ActionCow;
#[derive(Debug, Default)] #[derive(Debug, Default)]
pub struct CloseOpt { pub struct CloseOpt {
pub submit: bool, pub submit: bool,
} }
impl From<CmdCow> for CloseOpt { impl From<ActionCow> for CloseOpt {
fn from(c: CmdCow) -> Self { Self { submit: c.bool("submit") } } fn from(a: ActionCow) -> Self { Self { submit: a.bool("submit") } }
} }
impl From<bool> for CloseOpt { impl From<bool> for CloseOpt {

View file

@ -2,7 +2,7 @@ use anyhow::bail;
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value}; use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
use tokio::sync::mpsc; use tokio::sync::mpsc;
use yazi_config::popup::PickCfg; use yazi_config::popup::PickCfg;
use yazi_shared::event::CmdCow; use yazi_shared::event::ActionCow;
#[derive(Debug)] #[derive(Debug)]
pub struct ShowOpt { pub struct ShowOpt {
@ -10,15 +10,15 @@ pub struct ShowOpt {
pub tx: mpsc::UnboundedSender<Option<usize>>, pub tx: mpsc::UnboundedSender<Option<usize>>,
} }
impl TryFrom<CmdCow> for ShowOpt { impl TryFrom<ActionCow> for ShowOpt {
type Error = anyhow::Error; type Error = anyhow::Error;
fn try_from(mut c: CmdCow) -> Result<Self, Self::Error> { fn try_from(mut a: ActionCow) -> Result<Self, Self::Error> {
let Some(cfg) = c.take_any("cfg") else { let Some(cfg) = a.take_any("cfg") else {
bail!("Invalid 'cfg' in ShowOpt"); bail!("Invalid 'cfg' in ShowOpt");
}; };
let Some(tx) = c.take_any("tx") else { let Some(tx) = a.take_any("tx") else {
bail!("Invalid 'tx' in ShowOpt"); bail!("Invalid 'tx' in ShowOpt");
}; };

View file

@ -1,13 +1,13 @@
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value}; use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
use yazi_shared::{SStr, event::CmdCow}; use yazi_shared::{SStr, event::ActionCow};
#[derive(Debug)] #[derive(Debug)]
pub struct CopyOpt { pub struct CopyOpt {
pub r#type: SStr, pub r#type: SStr,
} }
impl From<CmdCow> for CopyOpt { impl From<ActionCow> for CopyOpt {
fn from(mut c: CmdCow) -> Self { Self { r#type: c.take_first().unwrap_or_default() } } fn from(mut a: ActionCow) -> Self { Self { r#type: a.take_first().unwrap_or_default() } }
} }
impl FromLua for CopyOpt { impl FromLua for CopyOpt {

View file

@ -2,7 +2,7 @@ use std::ffi::OsString;
use anyhow::anyhow; use anyhow::anyhow;
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value}; use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
use yazi_shared::{CompletionToken, event::CmdCow, url::UrlCow}; use yazi_shared::{CompletionToken, event::ActionCow, url::UrlCow};
// --- Exec // --- Exec
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
@ -17,11 +17,11 @@ pub struct ProcessOpenOpt {
pub spread: bool, // TODO: remove pub spread: bool, // TODO: remove
} }
impl TryFrom<CmdCow> for ProcessOpenOpt { impl TryFrom<ActionCow> for ProcessOpenOpt {
type Error = anyhow::Error; type Error = anyhow::Error;
fn try_from(mut c: CmdCow) -> Result<Self, Self::Error> { fn try_from(mut a: ActionCow) -> Result<Self, Self::Error> {
c.take_any("opt").ok_or_else(|| anyhow!("Missing 'opt' in ProcessOpenOpt")) a.take_any("opt").ok_or_else(|| anyhow!("Missing 'opt' in ProcessOpenOpt"))
} }
} }

View file

@ -1,17 +1,17 @@
use anyhow::bail; use anyhow::bail;
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value}; use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
use yazi_shared::{event::CmdCow, url::UrlBuf}; use yazi_shared::{event::ActionCow, url::UrlBuf};
#[derive(Debug)] #[derive(Debug)]
pub struct UpdateSucceedOpt { pub struct UpdateSucceedOpt {
pub urls: Vec<UrlBuf>, pub urls: Vec<UrlBuf>,
} }
impl TryFrom<CmdCow> for UpdateSucceedOpt { impl TryFrom<ActionCow> for UpdateSucceedOpt {
type Error = anyhow::Error; type Error = anyhow::Error;
fn try_from(mut c: CmdCow) -> Result<Self, Self::Error> { fn try_from(mut a: ActionCow) -> Result<Self, Self::Error> {
let Some(urls) = c.take_any("urls") else { let Some(urls) = a.take_any("urls") else {
bail!("Invalid 'urls' in UpdateSucceedOpt"); bail!("Invalid 'urls' in UpdateSucceedOpt");
}; };

View file

@ -1,11 +1,11 @@
use mlua::{FromLua, IntoLua, Lua, Value}; use mlua::{FromLua, IntoLua, Lua, Value};
use yazi_shared::event::CmdCow; use yazi_shared::event::ActionCow;
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)] #[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
pub struct VoidOpt; pub struct VoidOpt;
impl From<CmdCow> for VoidOpt { impl From<ActionCow> for VoidOpt {
fn from(_: CmdCow) -> Self { Self } fn from(_: ActionCow) -> Self { Self }
} }
impl From<()> for VoidOpt { impl From<()> for VoidOpt {

View file

@ -1,7 +1,7 @@
use mlua::{ExternalError, FromLua, IntoLua, Lua, Table, Value}; use mlua::{ExternalError, FromLua, IntoLua, Lua, Table, Value};
use tokio::sync::mpsc; use tokio::sync::mpsc;
use yazi_config::{KEYMAP, keymap::{ChordCow, Key}}; use yazi_config::{KEYMAP, keymap::{ChordCow, Key}};
use yazi_shared::{Layer, event::CmdCow}; use yazi_shared::{Layer, event::ActionCow};
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
pub struct ActivateOpt { pub struct ActivateOpt {
@ -11,19 +11,19 @@ pub struct ActivateOpt {
pub times: usize, pub times: usize,
} }
impl TryFrom<CmdCow> for ActivateOpt { impl TryFrom<ActionCow> for ActivateOpt {
type Error = anyhow::Error; type Error = anyhow::Error;
fn try_from(mut c: CmdCow) -> Result<Self, Self::Error> { fn try_from(mut a: ActionCow) -> Result<Self, Self::Error> {
if let Some(opt) = c.take_any2("opt") { if let Some(opt) = a.take_any2("opt") {
return opt; return opt;
} }
Ok(Self { Ok(Self {
tx: c.take_any2("tx").transpose()?, tx: a.take_any2("tx").transpose()?,
cands: c.take_any_iter::<yazi_binding::ChordCow>().map(Into::into).collect(), cands: a.take_any_iter::<yazi_binding::ChordCow>().map(Into::into).collect(),
silent: c.bool("silent"), silent: a.bool("silent"),
times: c.get("times").unwrap_or(0), times: a.get("times").unwrap_or(0),
}) })
} }
} }

View file

@ -1,10 +1,10 @@
local M = {} local M = {}
function M:setup() function M:setup()
ps.sub_remote("dds-emit", function(cmd) ps.sub_remote("dds-emit", function(action)
local i, args = 1, {} local i, args = 1, {}
for j = 2, #cmd do for j = 2, #action do
local word = string.char(table.unpack(cmd[j])) local word = string.char(table.unpack(action[j]))
local key = word:match("^%-%-([^=]+)") local key = word:match("^%-%-([^=]+)")
if not key then if not key then
i, args[i] = i + 1, word i, args[i] = i + 1, word
@ -14,7 +14,7 @@ function M:setup()
args[key] = word:sub(#key + 4) args[key] = word:sub(#key + 4)
end end
end end
ya.emit(cmd[1], args) ya.emit(action[1], args)
end) end)
end end

View file

@ -1,15 +1,15 @@
local M = {} local M = {}
function M:peek(job) function M:peek(job)
local cmd = os.getenv("YAZI_FILE_ONE") or "file" local program = os.getenv("YAZI_FILE_ONE") or "file"
local path = tostring(job.file.path) local path = tostring(job.file.path)
local output, err = Command(cmd):arg({ "-bL", "--", path }):output() local output, err = Command(program):arg({ "-bL", "--", path }):output()
local text local text
if output then if output then
text = ui.Text.parse("----- File Type Classification -----\n\n" .. output.stdout) text = ui.Text.parse("----- File Type Classification -----\n\n" .. output.stdout)
else else
text = ui.Text(string.format("Failed to start `%s`, error: %s", cmd, err)) text = ui.Text(string.format("Failed to start `%s`, error: %s", program, err))
end end
ya.preview_widget(job, text:area(job.area):wrap(ui.Wrap.YES)) ya.preview_widget(job, text:area(job.area):wrap(ui.Wrap.YES))

View file

@ -2,29 +2,30 @@ use mlua::{ExternalResult, FromLua, IntoLua, Lua, ObjectLike, Value};
use tokio::runtime::Handle; use tokio::runtime::Handle;
use yazi_binding::{Error, File}; use yazi_binding::{Error, File};
use yazi_dds::Sendable; use yazi_dds::Sendable;
use yazi_shared::event::CmdCow; use yazi_shared::event::ActionCow;
use super::slim_lua; use super::slim_lua;
use crate::loader::LOADER; use crate::loader::LOADER;
pub async fn fetch( pub async fn fetch(
cmd: CmdCow, action: ActionCow,
files: Vec<yazi_fs::File>, files: Vec<yazi_fs::File>,
) -> mlua::Result<(FetchState, Option<Error>)> { ) -> mlua::Result<(FetchState, Option<Error>)> {
if files.is_empty() { if files.is_empty() {
return Ok((FetchState::Bool(true), None)); return Ok((FetchState::Bool(true), None));
} }
LOADER.ensure(&cmd.name, |_| ()).await.into_lua_err()?; LOADER.ensure(&action.name, |_| ()).await.into_lua_err()?;
tokio::task::spawn_blocking(move || { tokio::task::spawn_blocking(move || {
let lua = slim_lua(&cmd.name)?; let lua = slim_lua(&action.name)?;
let job = lua.create_table_from([ let job = lua.create_table_from([
("args", Sendable::args_to_table_ref(&lua, &cmd.args)?.into_lua(&lua)?), ("args", Sendable::args_to_table_ref(&lua, &action.args)?.into_lua(&lua)?),
("files", lua.create_sequence_from(files.into_iter().map(File::new))?.into_lua(&lua)?), ("files", lua.create_sequence_from(files.into_iter().map(File::new))?.into_lua(&lua)?),
])?; ])?;
Handle::current() Handle::current().block_on(async {
.block_on(async { LOADER.load(&lua, &cmd.name).await?.call_async_method("fetch", job).await }) LOADER.load(&lua, &action.name).await?.call_async_method("fetch", job).await
})
}) })
.await .await
.into_lua_err()? .into_lua_err()?

View file

@ -7,18 +7,18 @@ use yazi_config::LAYOUT;
use yazi_dds::Sendable; use yazi_dds::Sendable;
use yazi_parser::{app::PluginOpt, mgr::{PreviewLock, UpdatePeekedOpt}}; use yazi_parser::{app::PluginOpt, mgr::{PreviewLock, UpdatePeekedOpt}};
use yazi_proxy::{AppProxy, MgrProxy}; use yazi_proxy::{AppProxy, MgrProxy};
use yazi_shared::{event::Cmd, pool::Symbol}; use yazi_shared::{event::Action, pool::Symbol};
use super::slim_lua; use super::slim_lua;
use crate::loader::{LOADER, Loader}; use crate::loader::{LOADER, Loader};
pub fn peek( pub fn peek(
cmd: &'static Cmd, action: &'static Action,
file: yazi_fs::File, file: yazi_fs::File,
mime: Symbol<str>, mime: Symbol<str>,
skip: usize, skip: usize,
) -> Option<CancellationToken> { ) -> Option<CancellationToken> {
let (id, ..) = Loader::normalize_id(&cmd.name).ok()?; let (id, ..) = Loader::normalize_id(&action.name).ok()?;
let ct = CancellationToken::new(); let ct = CancellationToken::new();
if let Some(c) = LOADER.read().get(id) { if let Some(c) = LOADER.read().get(id) {
@ -26,9 +26,9 @@ pub fn peek(
peek_error(file, mime, skip, e); peek_error(file, mime, skip, e);
return None; return None;
} else if c.sync_peek { } else if c.sync_peek {
peek_sync(cmd, file, mime, skip); peek_sync(action, file, mime, skip);
} else { } else {
peek_async(cmd, file, mime, skip, ct.clone()); peek_async(action, file, mime, skip, ct.clone());
} }
return Some(ct).filter(|_| !c.sync_peek); return Some(ct).filter(|_| !c.sync_peek);
} }
@ -39,9 +39,9 @@ pub fn peek(
_ = ct_.cancelled() => {}, _ = ct_.cancelled() => {},
Ok(b) = LOADER.ensure(id, |c| c.sync_peek) => { Ok(b) = LOADER.ensure(id, |c| c.sync_peek) => {
if b { if b {
peek_sync(cmd, file, mime, skip); peek_sync(action, file, mime, skip);
} else { } else {
peek_async(cmd, file, mime, skip, ct_); peek_async(action, file, mime, skip, ct_);
} }
}, },
else => {} else => {}
@ -51,11 +51,11 @@ pub fn peek(
Some(ct) Some(ct)
} }
fn peek_sync(cmd: &'static Cmd, file: yazi_fs::File, mime: Symbol<str>, skip: usize) { fn peek_sync(action: &'static Action, file: yazi_fs::File, mime: Symbol<str>, skip: usize) {
let cb = move |lua: &Lua, plugin: Table| { let cb = move |lua: &Lua, plugin: Table| {
let job = lua.create_table_from([ let job = lua.create_table_from([
("area", Rect::from(LAYOUT.get().preview).into_lua(lua)?), ("area", Rect::from(LAYOUT.get().preview).into_lua(lua)?),
("args", Sendable::args_to_table_ref(lua, &cmd.args)?.into_lua(lua)?), ("args", Sendable::args_to_table_ref(lua, &action.args)?.into_lua(lua)?),
("file", File::new(file).into_lua(lua)?), ("file", File::new(file).into_lua(lua)?),
("mime", mime.into_lua(lua)?), ("mime", mime.into_lua(lua)?),
("skip", skip.into_lua(lua)?), ("skip", skip.into_lua(lua)?),
@ -64,11 +64,11 @@ fn peek_sync(cmd: &'static Cmd, file: yazi_fs::File, mime: Symbol<str>, skip: us
plugin.call_method("peek", job) plugin.call_method("peek", job)
}; };
AppProxy::plugin(PluginOpt::new_callback(&*cmd.name, cb)); AppProxy::plugin(PluginOpt::new_callback(&*action.name, cb));
} }
fn peek_async( fn peek_async(
cmd: &'static Cmd, action: &'static Action,
file: yazi_fs::File, file: yazi_fs::File,
mime: Symbol<str>, mime: Symbol<str>,
skip: usize, skip: usize,
@ -77,7 +77,7 @@ fn peek_async(
let ct_ = ct.clone(); let ct_ = ct.clone();
tokio::task::spawn_blocking(move || { tokio::task::spawn_blocking(move || {
let future = async { let future = async {
let lua = slim_lua(&cmd.name)?; let lua = slim_lua(&action.name)?;
lua.set_hook( lua.set_hook(
HookTriggers::new().on_calls().on_returns().every_nth_instruction(2000), HookTriggers::new().on_calls().on_returns().every_nth_instruction(2000),
move |_, dbg| { move |_, dbg| {
@ -89,10 +89,10 @@ fn peek_async(
}, },
)?; )?;
let plugin = LOADER.load(&lua, &cmd.name).await?; let plugin = LOADER.load(&lua, &action.name).await?;
let job = lua.create_table_from([ let job = lua.create_table_from([
("area", Rect::from(LAYOUT.get().preview).into_lua(&lua)?), ("area", Rect::from(LAYOUT.get().preview).into_lua(&lua)?),
("args", Sendable::args_to_table_ref(&lua, &cmd.args)?.into_lua(&lua)?), ("args", Sendable::args_to_table_ref(&lua, &action.args)?.into_lua(&lua)?),
("file", File::new(file).into_lua(&lua)?), ("file", File::new(file).into_lua(&lua)?),
("mime", mime.into_lua(&lua)?), ("mime", mime.into_lua(&lua)?),
("skip", skip.into_lua(&lua)?), ("skip", skip.into_lua(&lua)?),

View file

@ -4,22 +4,22 @@ use tokio_util::sync::CancellationToken;
use yazi_binding::{Error, File, elements::Rect}; use yazi_binding::{Error, File, elements::Rect};
use yazi_config::LAYOUT; use yazi_config::LAYOUT;
use yazi_dds::Sendable; use yazi_dds::Sendable;
use yazi_shared::event::Cmd; use yazi_shared::event::Action;
use super::slim_lua; use super::slim_lua;
use crate::loader::LOADER; use crate::loader::LOADER;
pub async fn preload( pub async fn preload(
cmd: &'static Cmd, action: &'static Action,
file: yazi_fs::File, file: yazi_fs::File,
ct: CancellationToken, ct: CancellationToken,
) -> mlua::Result<(bool, Option<Error>)> { ) -> mlua::Result<(bool, Option<Error>)> {
let ct_ = ct.clone(); let ct_ = ct.clone();
tokio::task::spawn_blocking(move || { tokio::task::spawn_blocking(move || {
let future = async { let future = async {
LOADER.ensure(&cmd.name, |_| ()).await.into_lua_err()?; LOADER.ensure(&action.name, |_| ()).await.into_lua_err()?;
let lua = slim_lua(&cmd.name)?; let lua = slim_lua(&action.name)?;
lua.set_hook( lua.set_hook(
HookTriggers::new().on_calls().on_returns().every_nth_instruction(2000), HookTriggers::new().on_calls().on_returns().every_nth_instruction(2000),
move |_, dbg| { move |_, dbg| {
@ -31,10 +31,10 @@ pub async fn preload(
}, },
)?; )?;
let plugin = LOADER.load(&lua, &cmd.name).await?; let plugin = LOADER.load(&lua, &action.name).await?;
let job = lua.create_table_from([ let job = lua.create_table_from([
("area", Rect::from(LAYOUT.get().preview).into_lua(&lua)?), ("area", Rect::from(LAYOUT.get().preview).into_lua(&lua)?),
("args", Sendable::args_to_table_ref(&lua, &cmd.args)?.into_lua(&lua)?), ("args", Sendable::args_to_table_ref(&lua, &action.args)?.into_lua(&lua)?),
("file", File::new(file).into_lua(&lua)?), ("file", File::new(file).into_lua(&lua)?),
("skip", 0.into_lua(&lua)?), ("skip", 0.into_lua(&lua)?),
])?; ])?;

View file

@ -3,9 +3,9 @@ use yazi_binding::{File, elements::Rect};
use yazi_config::LAYOUT; use yazi_config::LAYOUT;
use yazi_parser::app::PluginOpt; use yazi_parser::app::PluginOpt;
use yazi_proxy::AppProxy; use yazi_proxy::AppProxy;
use yazi_shared::event::Cmd; use yazi_shared::event::Action;
pub fn seek_sync(cmd: &'static Cmd, file: yazi_fs::File, units: i16) { pub fn seek_sync(action: &'static Action, file: yazi_fs::File, units: i16) {
let cb = move |lua: &Lua, plugin: Table| { let cb = move |lua: &Lua, plugin: Table| {
let job = lua.create_table_from([ let job = lua.create_table_from([
("file", File::new(file).into_lua(lua)?), ("file", File::new(file).into_lua(lua)?),
@ -16,5 +16,5 @@ pub fn seek_sync(cmd: &'static Cmd, file: yazi_fs::File, units: i16) {
plugin.call_method("seek", job) plugin.call_method("seek", job)
}; };
AppProxy::plugin(PluginOpt::new_callback(&*cmd.name, cb)); AppProxy::plugin(PluginOpt::new_callback(&*action.name, cb));
} }

View file

@ -4,7 +4,7 @@ use tokio_util::sync::CancellationToken;
use tracing::error; use tracing::error;
use yazi_binding::{File, Id}; use yazi_binding::{File, Id};
use yazi_dds::Sendable; use yazi_dds::Sendable;
use yazi_shared::{Ids, event::Cmd, pool::Symbol}; use yazi_shared::{Ids, event::Action, pool::Symbol};
use super::slim_lua; use super::slim_lua;
use crate::loader::LOADER; use crate::loader::LOADER;
@ -12,7 +12,7 @@ use crate::loader::LOADER;
static IDS: Ids = Ids::new(); static IDS: Ids = Ids::new();
pub fn spot( pub fn spot(
cmd: &'static Cmd, action: &'static Action,
file: yazi_fs::File, file: yazi_fs::File,
mime: Symbol<str>, mime: Symbol<str>,
skip: usize, skip: usize,
@ -22,9 +22,9 @@ pub fn spot(
tokio::task::spawn_blocking(move || { tokio::task::spawn_blocking(move || {
let future = async { let future = async {
LOADER.ensure(&cmd.name, |_| ()).await.into_lua_err()?; LOADER.ensure(&action.name, |_| ()).await.into_lua_err()?;
let lua = slim_lua(&cmd.name)?; let lua = slim_lua(&action.name)?;
lua.set_hook( lua.set_hook(
HookTriggers::new().on_calls().on_returns().every_nth_instruction(2000), HookTriggers::new().on_calls().on_returns().every_nth_instruction(2000),
move |_, dbg| { move |_, dbg| {
@ -36,10 +36,10 @@ pub fn spot(
}, },
)?; )?;
let plugin = LOADER.load(&lua, &cmd.name).await?; let plugin = LOADER.load(&lua, &action.name).await?;
let job = lua.create_table_from([ let job = lua.create_table_from([
("id", Id(IDS.next()).into_lua(&lua)?), ("id", Id(IDS.next()).into_lua(&lua)?),
("args", Sendable::args_to_table_ref(&lua, &cmd.args)?.into_lua(&lua)?), ("args", Sendable::args_to_table_ref(&lua, &action.args)?.into_lua(&lua)?),
("file", File::new(file).into_lua(&lua)?), ("file", File::new(file).into_lua(&lua)?),
("mime", mime.into_lua(&lua)?), ("mime", mime.into_lua(&lua)?),
("skip", skip.into_lua(&lua)?), ("skip", skip.into_lua(&lua)?),

View file

@ -1,22 +1,22 @@
use mlua::{Function, Lua, Table}; use mlua::{Function, Lua, Table};
use yazi_dds::Sendable; use yazi_dds::Sendable;
use yazi_macro::emit; use yazi_macro::emit;
use yazi_shared::{Layer, Source, event::Cmd}; use yazi_shared::{Layer, Source, event::Action};
use super::Utils; use super::Utils;
impl Utils { impl Utils {
pub(super) fn emit(lua: &Lua) -> mlua::Result<Function> { pub(super) fn emit(lua: &Lua) -> mlua::Result<Function> {
lua.create_function(|lua, (name, args): (String, Table)| { lua.create_function(|lua, (name, args): (String, Table)| {
let mut cmd = Cmd::new(name, Source::Emit, Some(Layer::Mgr))?; let mut action = Action::new(name, Source::Emit, Some(Layer::Mgr))?;
cmd.args = Sendable::table_to_args(lua, args)?; action.args = Sendable::table_to_args(lua, args)?;
Ok(emit!(Call(cmd))) Ok(emit!(Call(action)))
}) })
} }
pub(super) fn mgr_emit(lua: &Lua) -> mlua::Result<Function> { pub(super) fn mgr_emit(lua: &Lua) -> mlua::Result<Function> {
lua.create_function(|lua, (name, args): (String, Table)| { lua.create_function(|lua, (name, args): (String, Table)| {
emit!(Call(Cmd { emit!(Call(Action {
name: name.into(), name: name.into(),
args: Sendable::table_to_args(lua, args)?, args: Sendable::table_to_args(lua, args)?,
layer: Layer::Mgr, layer: Layer::Mgr,

View file

@ -37,8 +37,8 @@ impl Utils {
.await .await
.iter() .iter()
.flat_map(|chord| &chord.run) .flat_map(|chord| &chord.run)
.find(|cmd| cmd.layer == Layer::Which && cmd.name == "callback") .find(|action| action.layer == Layer::Which && action.name == "callback")
.and_then(|cmd| cmd.first().ok()); .and_then(|action| action.first().ok());
Ok(idx) Ok(idx)
}) })

View file

@ -4,7 +4,7 @@ macro_rules! deprecate {
static WARNED: std::sync::atomic::AtomicBool = std::sync::atomic::AtomicBool::new(false); static WARNED: std::sync::atomic::AtomicBool = std::sync::atomic::AtomicBool::new(false);
if !WARNED.swap(true, std::sync::atomic::Ordering::Relaxed) { if !WARNED.swap(true, std::sync::atomic::Ordering::Relaxed) {
$crate::emit!(Call( $crate::emit!(Call(
yazi_shared::event::Cmd::new("app:deprecate").with("content", format!($tt, id)) yazi_shared::event::Action::new("app:deprecate").with("content", format!($tt, id))
)); ));
} }
}}; }};

View file

@ -8,7 +8,7 @@ use tracing::error;
use yazi_config::Priority; use yazi_config::Priority;
use yazi_fs::FsHash64; use yazi_fs::FsHash64;
use yazi_plugin::isolate; use yazi_plugin::isolate;
use yazi_shared::event::CmdCow; use yazi_shared::event::ActionCow;
use crate::{HIGH, LOW, TaskOp, TaskOps, fetch::{FetchIn, FetchOutFetch}}; use crate::{HIGH, LOW, TaskOp, TaskOps, fetch::{FetchIn, FetchOutFetch}};
@ -32,7 +32,7 @@ impl Fetch {
pub(crate) async fn fetch(&self, task: FetchIn) -> Result<(), FetchOutFetch> { pub(crate) async fn fetch(&self, task: FetchIn) -> Result<(), FetchOutFetch> {
let hashes: Vec<_> = task.targets.iter().map(|f| f.hash_u64()).collect(); let hashes: Vec<_> = task.targets.iter().map(|f| f.hash_u64()).collect();
let (state, err) = isolate::fetch(CmdCow::from(&task.plugin.run), task.targets).await?; let (state, err) = isolate::fetch(ActionCow::from(&task.plugin.run), task.targets).await?;
let mut loaded = self.loaded.lock(); let mut loaded = self.loaded.lock();
for (_, h) in hashes.into_iter().enumerate().filter(|&(i, _)| !state.get(i)) { for (_, h) in hashes.into_iter().enumerate().filter(|&(i, _)| !state.get(i)) {

View file

@ -7,21 +7,21 @@ use serde::{Deserialize, de};
use crate::{Layer, SStr, Source, data::{Data, DataAny, DataKey}}; use crate::{Layer, SStr, Source, data::{Data, DataAny, DataKey}};
#[derive(Clone, Debug, Default)] #[derive(Clone, Debug, Default)]
pub struct Cmd { pub struct Action {
pub name: SStr, pub name: SStr,
pub args: HashMap<DataKey, Data>, pub args: HashMap<DataKey, Data>,
pub layer: Layer, pub layer: Layer,
pub source: Source, pub source: Source,
} }
impl Cmd { impl Action {
pub fn new<N>(name: N, source: Source, default: Option<Layer>) -> Result<Self> pub fn new<N>(name: N, source: Source, default: Option<Layer>) -> Result<Self>
where where
N: Into<SStr>, N: Into<SStr>,
{ {
let cow: SStr = name.into(); let cow: SStr = name.into();
let (layer, name) = match cow.find(':') { let (layer, name) = match cow.find(':') {
None => (default.ok_or_else(|| anyhow!("Cannot infer layer from command name: {cow}"))?, cow), None => (default.ok_or_else(|| anyhow!("Cannot infer layer from action name: {cow}"))?, cow),
Some(i) => (cow[..i].parse()?, match cow { Some(i) => (cow[..i].parse()?, match cow {
Cow::Borrowed(s) => Cow::Borrowed(&s[i + 1..]), Cow::Borrowed(s) => Cow::Borrowed(&s[i + 1..]),
Cow::Owned(mut s) => { Cow::Owned(mut s) => {
@ -47,10 +47,10 @@ impl Cmd {
D: Into<Data>, D: Into<Data>,
I: IntoIterator<Item = D>, I: IntoIterator<Item = D>,
{ {
let mut cmd = Self::new(name, Source::Relay, None).unwrap_or(Self::null()); let mut action = Self::new(name, Source::Relay, None).unwrap_or(Self::null());
cmd.args = action.args =
args.into_iter().enumerate().map(|(i, a)| (DataKey::Integer(i as i64), a.into())).collect(); args.into_iter().enumerate().map(|(i, a)| (DataKey::Integer(i as i64), a.into())).collect();
cmd action
} }
fn null() -> Self { Self { name: Cow::Borrowed("null"), ..Default::default() } } fn null() -> Self { Self { name: Cow::Borrowed("null"), ..Default::default() } }
@ -215,7 +215,7 @@ impl Cmd {
} }
} }
impl Display for Cmd { impl Display for Action {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", self.name)?; write!(f, "{}", self.name)?;
@ -238,13 +238,13 @@ impl Display for Cmd {
} }
} }
impl FromStr for Cmd { impl FromStr for Action {
type Err = anyhow::Error; type Err = anyhow::Error;
fn from_str(s: &str) -> Result<Self, Self::Err> { fn from_str(s: &str) -> Result<Self, Self::Err> {
let (mut words, last) = crate::shell::unix::split(s, true)?; let (mut words, last) = crate::shell::unix::split(s, true)?;
if words.is_empty() || words[0].is_empty() { if words.is_empty() || words[0].is_empty() {
bail!("command name cannot be empty"); bail!("action name cannot be empty");
} }
let mut me = Self::new(mem::take(&mut words[0]), Default::default(), Some(Default::default()))?; let mut me = Self::new(mem::take(&mut words[0]), Default::default(), Some(Default::default()))?;
@ -253,7 +253,7 @@ impl FromStr for Cmd {
} }
} }
impl<'de> Deserialize<'de> for Cmd { impl<'de> Deserialize<'de> for Action {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where where
D: serde::Deserializer<'de>, D: serde::Deserializer<'de>,

View file

@ -2,17 +2,17 @@ use std::{iter, ops::Deref};
use anyhow::Result; use anyhow::Result;
use super::Cmd; use super::Action;
use crate::data::{Data, DataKey}; use crate::data::{Data, DataKey};
#[derive(Debug)] #[derive(Debug)]
pub enum CmdCow { pub enum ActionCow {
Owned(Cmd), Owned(Action),
Borrowed(&'static Cmd), Borrowed(&'static Action),
} }
impl Deref for CmdCow { impl Deref for ActionCow {
type Target = Cmd; type Target = Action;
fn deref(&self) -> &Self::Target { fn deref(&self) -> &Self::Target {
match self { match self {
@ -22,19 +22,19 @@ impl Deref for CmdCow {
} }
} }
impl From<CmdCow> for () { impl From<ActionCow> for () {
fn from(_: CmdCow) -> Self { () } fn from(_: ActionCow) -> Self { () }
} }
impl From<Cmd> for CmdCow { impl From<Action> for ActionCow {
fn from(c: Cmd) -> Self { Self::Owned(c) } fn from(a: Action) -> Self { Self::Owned(a) }
} }
impl From<&'static Cmd> for CmdCow { impl From<&'static Action> for ActionCow {
fn from(c: &'static Cmd) -> Self { Self::Borrowed(c) } fn from(a: &'static Action) -> Self { Self::Borrowed(a) }
} }
impl CmdCow { impl ActionCow {
pub fn take<'a, T>(&mut self, name: impl Into<DataKey>) -> Result<T> pub fn take<'a, T>(&mut self, name: impl Into<DataKey>) -> Result<T>
where where
T: TryFrom<Data> + TryFrom<&'a Data>, T: TryFrom<Data> + TryFrom<&'a Data>,

View file

@ -1,7 +1,7 @@
use crossterm::event::{KeyEvent, MouseEvent}; use crossterm::event::{KeyEvent, MouseEvent};
use tokio::sync::mpsc; use tokio::sync::mpsc;
use super::CmdCow; use super::ActionCow;
use crate::RoCell; use crate::RoCell;
static TX: RoCell<mpsc::UnboundedSender<Event>> = RoCell::new(); static TX: RoCell<mpsc::UnboundedSender<Event>> = RoCell::new();
@ -9,8 +9,8 @@ static RX: RoCell<mpsc::UnboundedReceiver<Event>> = RoCell::new();
#[derive(Debug)] #[derive(Debug)]
pub enum Event { pub enum Event {
Call(CmdCow), Call(ActionCow),
Seq(Vec<CmdCow>), Seq(Vec<ActionCow>),
Render(bool), Render(bool),
Key(KeyEvent), Key(KeyEvent),
Mouse(MouseEvent), Mouse(MouseEvent),

View file

@ -1,3 +1,3 @@
yazi_macro::mod_flat!(cmd cow event); yazi_macro::mod_flat!(action cow event);
pub static NEED_RENDER: std::sync::atomic::AtomicU8 = std::sync::atomic::AtomicU8::new(0); pub static NEED_RENDER: std::sync::atomic::AtomicU8 = std::sync::atomic::AtomicU8::new(0);

Some files were not shown because too many files have changed in this diff Show more