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 `overall` option to set the overall background color ([#3317])
- 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])
- 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])
- 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])
- Support `.deb` packages ([#2807], [#3128], [#3209])
- 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 `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])
- 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])
- 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])
@ -125,7 +125,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/):
### 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 `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])
@ -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])
- 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])
- Renew package `rev` only when it's empty ([#3200])
- 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 `fs.calc_size()` API ([#2691])
- 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])
- Limit memory usage for previewing large images ([#2602])
- Show error when image preview fails ([#2706])
- New `ui.Align`, `ui.Wrap`, and `ui.Edge` ([#2802])
- Make `ui.Line` renderable ([#2743])
- 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])
- New `--no-dummy` option for `reveal` command ([#2664])
- Make the hover state for `reveal`, `sort`, and `hidden` actions stable ([#2657])
- New `--no-dummy` option for `reveal` action ([#2664])
- Fall back to `CSI 16 t` when PowerShell OpenSSH returns a fake terminal size ([#2636])
### Changed
@ -242,7 +242,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/):
- Enhance `fzf` integration ([#2553])
- Platform-specific key binding ([#2526])
- 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])
- Show error message when directory fails to load ([#2527])
- 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 `fs.expand_url()` API ([#2476])
- 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 `ya.id("app")` to get `YAZI_ID` in plugins ([#2503])
- 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
- 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])
- 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])
@ -302,11 +302,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/):
### 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 `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])
- `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 `wrap` setting in the preset JSON previewer ([#2337])
- 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])
- New `ya.confirm()` API ([#2095])
- New `arrow top` and `arrow bot` commands to jump to the top and bottom ([#2294])
- Support end of options (`--`) marker for all commands ([#2298])
- New `arrow top` and `arrow bot` actions to jump to the top and bottom ([#2294])
- Support end of options (`--`) marker for all actions ([#2298])
- Replace mode and Vim motions (`W`, `E`, `B`, `^`, `_`) for inputs ([#2143])
- New `ya pack -d` subcommand to delete packages ([#2181])
- `ya pack` supports adding and deleting multiple packages at once ([#2257])
- 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])
- 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])
- More decent package locking mechanism ([#2168])
- 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
- 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 `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])
@ -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])
- 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])
- 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])
- Support transparent image preview ([#1556])
- 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])
- New `ya emit` and `ya emit-to` subcommands to emit commands to a specified instance for execution ([#1979])
- Allow disabling certain preset keybinds with the new `noop` virtual action ([#1882])
- 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])
- 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])
@ -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])
- Remove `ui.ListItem` since it's no longer necessary ([#1772])
- 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])
- Remove the meaningless `--confirm` option to simplify the `shell` command ([#1982])
- Make `backspace` action not close the input even when value is empty ([#1680])
- 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])
- 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])
### 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 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])
@ -527,7 +527,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/):
- New confirm component ([#1167])
- 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])
- 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])
- Key notion shorthands such as `<C-S-x>` as `<C-X>` ([#1448])
- Support `F13` - `F19` keys ([#1446])
- New `--cursor` for the `shell` command ([#1422])
- New `search_do` command to make it easier to achieve a flat view ([#1431])
- New `--cursor` for the `shell` action ([#1422])
- New `search_do` action to make it easier to achieve a flat view ([#1431])
- 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])
- Note about filtering in the help menu ([#1361])
- 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])
- SVG, HEIC, AVIF, and JPEG XL preview support ([#1050], [#1249])
- 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])
- Sort randomly ([#1291])
- New linemode to show file ownership ([#1238])
- 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])
- Interactive `cd` path auto-completion supports `~` expansion ([#1081])
- 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
- 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)
- 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
- Turn `success` and `code` into properties of `Status` instead of methods
- 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])
- Re-implement fzf and zoxide as built-in plugins ([#884], [#881])
- 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])
- 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])
@ -651,7 +651,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/):
### 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
@ -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 `<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 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])
- New `--debug` flag to print debug information ([#794])
- 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])
- Expose selected/yanked files as Lua API ([#674])
- 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])
- Allow both `/` and `\` for folder creation on Windows ([#751])
- 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
- Preview image over SSH ([#585])
- New `unyank` command ([#313])
- New `unyank` action ([#313])
- Customize number of columns of the which component ([#571])
- Support passing arguments to plugin ([#587])
- 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.quote()` API to quote strings safely
- `plugin` command for each layer
- `plugin` action for each layer
- Plugin-specific state persistence ([#590])
- Allow to configure image filter ([#586])
- 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
- 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]
@ -777,17 +777,17 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/):
### 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])
- 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])
- Start with the specified file hovers over ([#358])
- Emacs readline keybindings for inputs ([#345], [#382])
- New `--empty` and `--cursor` options for the `rename` command ([#513])
- New `--follow` option for `paste` command ([#436])
- Make `copy` command work over SSH with OSC 52 ([#447])
- New `reveal` command ([#341])
- New `--empty` and `--cursor` options for the `rename` action ([#513])
- New `--follow` option for `paste` action ([#436])
- Make `copy` action work over SSH with OSC 52 ([#447])
- New `reveal` action ([#341])
- Support colored icons ([#503])
- Support highlighting specific file types ([#510])
- 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
- 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 `--dir_first` option of `sort` command to `--dir-first` to make it consistent with the style of other commands
- Rename the `peek` action to `seek` to better convey the action of "seeking for" content to preview
- 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
### Fixed
@ -835,22 +835,22 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/):
### Added
- New `find` command to find files ([#104])
- New `find` action to find files ([#104])
- Linemode to show extra file info ([#291])
- New `sort_sensitive` option ([#155])
- Cross-platform opener rules ([#289])
- Multiple openers for a single open rule ([#154])
- Vim-like `gg`, `G` in the preset key mappings for boundary jumps
- 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])
- 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 `backward` and `forward` commands
- New `--smart` option for the `find` command to support smart case ([#240])
- New `backward` and `forward` actions
- New `--smart` option for the `find` action to support smart case ([#240])
- Sorting for each tab individually ([#131])
- 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])
- Tab switch wraparound ([#160])
- 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])
- Nix Flakes package ([#205])
- 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])
- New `realtime` option for the input to support real-time input feedback ([#127])
- 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])
- Natural sorting ([#82])
- 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])
- Show symlink path ([#67])
- 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])
- Change the shell CWD on exit with the shell wrapper ([#40])
- Allow customizing the display name of openers ([#31])
- New `shell` command ([#24])
- Command template support for the `shell` command ([#48])
- New `shell` action ([#24])
- Command template support for the `shell` action ([#48])
- Interactive `cd` ([#43])
- Show the output of running tasks in real time ([#17])
- 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])
- `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
@ -958,7 +958,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/):
### 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])
- Hover the cursor over newly created files automatically ([#10])
- 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)
- Horizontal scrolling support for the `input` component
- Visual mode for the input component
- New `yank` and `paste` commands for the input component
- New `undo` and `redo` commands for the `input` component
- New `yank` and `paste` actions for the input component
- New `undo` and `redo` actions for the `input` component
### Fixed
@ -995,7 +995,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/):
### Added
- Preset configurations
- New `open` command
- New `open` action
- Select component for interactive `open`
- Plain text and archive preview
- Search files with `fd` and `rg`

View file

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

View file

@ -1,6 +1,6 @@
use std::pin::Pin;
use mlua::{UserData, prelude::LuaUserDataMethods};
use mlua::{UserData, UserDataMethods};
use tokio::pin;
use tokio_stream::StreamExt;
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> {
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 {
let mut inner = unsafe { Pin::new_unchecked(&mut me.inner) };
Ok(inner.next().await.map(Self::parse).unwrap_or((None, 0)))

View file

@ -1,7 +1,7 @@
use std::{mem, ops::Deref};
use futures::{FutureExt, future::BoxFuture};
use mlua::{UserData, prelude::LuaUserDataMethods};
use mlua::{UserData, UserDataMethods};
use tokio::sync::SemaphorePermit;
pub type PermitRef = mlua::UserDataRef<Permit>;
@ -45,7 +45,7 @@ impl Drop 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) });
}
}

View file

@ -167,8 +167,8 @@ impl Actions {
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();
let cmd = env::var_os("YAZI_FILE_ONE").unwrap_or("file".into());
match std::process::Command::new(cmd).args(["-bL", "--mime-type"]).arg(&p).output() {
let program = env::var_os("YAZI_FILE_ONE").unwrap_or("file".into());
match std::process::Command::new(program).args(["-bL", "--mime-type"]).arg(&p).output() {
Ok(out) => {
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>),
}
let cmd: Vec<_> = [Elem::Name(self.name)]
let action: Vec<_> = [Elem::Name(self.name)]
.into_iter()
.chain(self.args.into_iter().map(|s| Elem::Arg(s.into_encoded_bytes())))
.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 regex::Regex;
use serde::Deserialize;
use yazi_shared::{Layer, Source, event::Cmd};
use yazi_shared::{Layer, Source, event::Action};
use super::Key;
@ -14,7 +14,7 @@ pub struct Chord {
#[serde(deserialize_with = "super::deserialize_on")]
pub on: Vec<Key>,
#[serde(deserialize_with = "super::deserialize_run")]
pub run: Vec<Cmd>,
pub run: Vec<Action>,
pub desc: Option<String>,
pub r#for: Option<String>,
}
@ -59,10 +59,10 @@ impl Chord {
impl Chord {
pub(super) fn reshape(mut self, layer: Layer) -> Result<Self> {
for cmd in &mut self.run {
cmd.source = Source::Key;
if cmd.layer == Default::default() {
cmd.layer = layer;
for action in &mut self.run {
action.source = Source::Key;
if action.layer == Default::default() {
action.layer = layer;
}
}
Ok(self)

View file

@ -1,6 +1,6 @@
use std::ops::Deref;
use yazi_shared::event::CmdCow;
use yazi_shared::event::ActionCow;
use super::Chord;
@ -37,7 +37,7 @@ impl Default for ChordCow {
}
impl ChordCow {
pub fn into_seq(self) -> Vec<CmdCow> {
pub fn into_seq(self) -> Vec<ActionCow> {
match self {
Self::Owned(c) => c.run.into_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 serde::{Deserializer, de::{self, Visitor}};
use yazi_shared::event::Cmd;
use yazi_shared::event::Action;
use crate::keymap::Key;
@ -23,14 +23,14 @@ where
where
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>()? {
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"));
}
Ok(cmds)
Ok(keys)
}
fn visit_str<E>(self, value: &str) -> Result<Self::Value, E>
@ -44,14 +44,14 @@ where
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
D: Deserializer<'de>,
{
struct RunVisitor;
impl<'de> Visitor<'de> for RunVisitor {
type Value = Vec<Cmd>;
type Value = Vec<Action>;
fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
formatter.write_str("a `run` string or array of strings within keymap.toml")
@ -61,21 +61,21 @@ where
where
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>()? {
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"));
}
Ok(cmds)
Ok(actions)
}
fn visit_str<E>(self, value: &str) -> Result<Self::Value, E>
where
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 yazi_fs::File;
use yazi_shared::event::Cmd;
use yazi_shared::event::Action;
use crate::{Pattern, Priority};
@ -12,7 +12,7 @@ pub struct Fetcher {
pub id: String,
pub url: Option<Pattern>,
pub mime: Option<Pattern>,
pub run: Cmd,
pub run: Action,
#[serde(default)]
pub prio: Priority,
}

View file

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

View file

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

View file

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

View file

@ -4,7 +4,7 @@ use anyhow::{Result, anyhow};
use mlua::{IntoLua, Lua, Value};
use yazi_boot::BOOT;
use yazi_macro::{emit, relay};
use yazi_shared::{Id, event::CmdCow};
use yazi_shared::{Id, event::ActionCow};
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;
fn try_from(mut c: CmdCow) -> Result<Self, Self::Error> {
c.take_any2("payload").ok_or_else(|| anyhow!("Missing 'payload' in Payload"))?
fn try_from(mut a: ActionCow) -> Result<Self, Self::Error> {
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)?,
);
}
_ => return Err("invalid key in Cmd".into_lua_err()),
_ => return Err("invalid key in Action".into_lua_err()),
}
}
Ok(args)

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -5,7 +5,7 @@ use dyn_clone::DynClone;
use hashbrown::HashMap;
use mlua::{ExternalError, FromLua, IntoLua, Lua, Table, Value};
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)]
pub struct PluginOpt {
@ -15,27 +15,27 @@ pub struct PluginOpt {
pub callback: Option<Box<dyn PluginCallback>>,
}
impl TryFrom<CmdCow> for PluginOpt {
impl TryFrom<ActionCow> for PluginOpt {
type Error = anyhow::Error;
fn try_from(mut c: CmdCow) -> Result<Self, Self::Error> {
if let Some(opt) = c.take_any("opt") {
fn try_from(mut a: ActionCow) -> Result<Self, Self::Error> {
if let Some(opt) = a.take_any("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");
};
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)?;
Cmd::parse_args(words, last)?
Action::parse_args(words, last)?
} else {
Default::default()
};
let mode = c.str("mode").parse().unwrap_or_default();
Ok(Self { id: Self::normalize_id(id), args, mode, callback: c.take_any("callback") })
let mode = a.str("mode").parse().unwrap_or_default();
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 serde::{Deserialize, Serialize};
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)]
pub struct QuitOpt {
@ -11,18 +11,18 @@ pub struct QuitOpt {
pub no_cwd_file: bool,
}
impl TryFrom<CmdCow> for QuitOpt {
impl TryFrom<ActionCow> for QuitOpt {
type Error = anyhow::Error;
fn try_from(mut c: CmdCow) -> Result<Self, Self::Error> {
if let Some(opt) = c.take_any2("opt") {
fn try_from(mut a: ActionCow) -> Result<Self, Self::Error> {
if let Some(opt) = a.take_any2("opt") {
return opt;
}
Ok(Self {
code: c.get("code").unwrap_or_default(),
code: a.get("code").unwrap_or_default(),
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 ordered_float::OrderedFloat;
use serde::Serialize;
use yazi_shared::event::CmdCow;
use yazi_shared::event::ActionCow;
#[derive(Debug)]
pub struct UpdateProgressOpt {
pub summary: TaskSummary,
}
impl TryFrom<CmdCow> for UpdateProgressOpt {
impl TryFrom<ActionCow> for UpdateProgressOpt {
type Error = anyhow::Error;
fn try_from(mut c: CmdCow) -> Result<Self, Self::Error> {
let Some(summary) = c.take_any("summary") else {
fn try_from(mut a: ActionCow) -> Result<Self, Self::Error> {
let Some(summary) = a.take_any("summary") else {
bail!("Invalid 'summary' in UpdateProgressOpt");
};

View file

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

View file

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

View file

@ -1,6 +1,6 @@
use anyhow::bail;
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)]
pub struct ShowOpt {
@ -10,11 +10,11 @@ pub struct ShowOpt {
pub ticket: Id,
}
impl TryFrom<CmdCow> for ShowOpt {
impl TryFrom<ActionCow> for ShowOpt {
type Error = anyhow::Error;
fn try_from(mut c: CmdCow) -> Result<Self, Self::Error> {
if let Some(opt) = c.take_any2("opt") {
fn try_from(mut a: ActionCow) -> Result<Self, Self::Error> {
if let Some(opt) = a.take_any2("opt") {
opt
} else {
bail!("missing 'opt' argument");

View file

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

View file

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

View file

@ -1,15 +1,15 @@
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
use yazi_shared::{Layer, event::CmdCow};
use yazi_shared::{Layer, event::ActionCow};
#[derive(Debug)]
pub struct ToggleOpt {
pub layer: Layer,
}
impl TryFrom<CmdCow> for ToggleOpt {
impl TryFrom<ActionCow> for ToggleOpt {
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 {

View file

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

View file

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

View file

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

View file

@ -1,15 +1,15 @@
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
use yazi_shared::event::CmdCow;
use yazi_shared::event::ActionCow;
use crate::app::QuitOpt;
#[derive(Debug, Default)]
pub struct CloseOpt(pub QuitOpt);
impl TryFrom<CmdCow> for CloseOpt {
impl TryFrom<ActionCow> for CloseOpt {
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 {

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,6 +1,6 @@
use anyhow::bail;
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)]
pub struct OpenDoOpt {
@ -9,11 +9,11 @@ pub struct OpenDoOpt {
pub interactive: bool,
}
impl TryFrom<CmdCow> for OpenDoOpt {
impl TryFrom<ActionCow> for OpenDoOpt {
type Error = anyhow::Error;
fn try_from(mut c: CmdCow) -> Result<Self, Self::Error> {
if let Some(opt) = c.take_any2("opt") {
fn try_from(mut a: ActionCow) -> Result<Self, Self::Error> {
if let Some(opt) = a.take_any2("opt") {
opt
} else {
bail!("Invalid 'opt' in OpenDoOpt");

View file

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

View file

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

View file

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

View file

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

View file

@ -1,6 +1,6 @@
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
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 crate::mgr::CdSource;
@ -12,11 +12,11 @@ pub struct RevealOpt {
pub no_dummy: bool,
}
impl From<CmdCow> for RevealOpt {
fn from(mut c: CmdCow) -> Self {
let mut target = c.take_first().unwrap_or_default();
impl From<ActionCow> for RevealOpt {
fn from(mut a: ActionCow) -> Self {
let mut target = a.take_first().unwrap_or_default();
if !c.bool("raw") {
if !a.bool("raw") {
target = expand_url(target);
}
@ -26,7 +26,7 @@ impl From<CmdCow> for RevealOpt {
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 mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
use serde::Deserialize;
use yazi_shared::{SStr, event::CmdCow};
use yazi_shared::{SStr, event::ActionCow};
#[derive(Debug)]
pub struct SearchOpt {
@ -13,18 +13,18 @@ pub struct SearchOpt {
pub args_raw: SStr,
}
impl TryFrom<CmdCow> for SearchOpt {
impl TryFrom<ActionCow> for SearchOpt {
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
let (via, subject) = if let Ok(s) = c.get("via") {
(str::parse(s)?, c.take_first().unwrap_or_default())
let (via, subject) = if let Ok(s) = a.get("via") {
(str::parse(s)?, a.take_first().unwrap_or_default())
} 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");
};
@ -33,7 +33,7 @@ impl TryFrom<CmdCow> for SearchOpt {
subject,
// TODO: use second positional argument instead of `args` parameter
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 yazi_shared::event::CmdCow;
use yazi_shared::event::ActionCow;
#[derive(Debug)]
pub struct SeekOpt {
pub units: i16,
}
impl From<CmdCow> for SeekOpt {
fn from(c: CmdCow) -> Self { Self { units: c.first().unwrap_or(0) } }
impl From<ActionCow> for SeekOpt {
fn from(a: ActionCow) -> Self { Self { units: a.first().unwrap_or(0) } }
}
impl FromLua for SeekOpt {

View file

@ -1,6 +1,6 @@
use anyhow::bail;
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)]
pub struct ShellOpt {
@ -14,19 +14,19 @@ pub struct ShellOpt {
pub cursor: Option<usize>,
}
impl TryFrom<CmdCow> for ShellOpt {
impl TryFrom<ActionCow> for ShellOpt {
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 {
run: c.take_first().unwrap_or_default(),
cwd: c.take("cwd").ok(),
run: a.take_first().unwrap_or_default(),
cwd: a.take("cwd").ok(),
block: c.bool("block"),
orphan: c.bool("orphan"),
interactive: c.bool("interactive"),
block: a.bool("block"),
orphan: a.bool("orphan"),
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()) {

View file

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

View file

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

View file

@ -2,7 +2,7 @@ use anyhow::bail;
use mlua::{ExternalError, FromLua, IntoLua, Lua, LuaSerdeExt, Value};
use serde::{Deserialize, Serialize};
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};
@ -12,10 +12,10 @@ pub struct StashOpt {
pub source: CdSource,
}
impl TryFrom<CmdCow> for StashOpt {
impl TryFrom<ActionCow> for StashOpt {
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 {

View file

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

View file

@ -1,7 +1,7 @@
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
use yazi_boot::BOOT;
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;
#[derive(Debug)]
@ -9,17 +9,17 @@ pub struct TabCreateOpt {
pub url: Option<UrlCow<'static>>,
}
impl From<CmdCow> for TabCreateOpt {
fn from(mut c: CmdCow) -> Self {
if c.bool("current") {
impl From<ActionCow> for TabCreateOpt {
fn from(mut a: ActionCow) -> Self {
if a.bool("current") {
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])) };
};
if !c.bool("raw") {
if !a.bool("raw") {
url = expand_url(url);
}

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,18 +1,18 @@
use anyhow::bail;
use hashbrown::HashMap;
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)]
pub struct UpdateMimesOpt {
pub updates: HashMap<DataKey, Data>,
}
impl TryFrom<CmdCow> for UpdateMimesOpt {
impl TryFrom<ActionCow> for UpdateMimesOpt {
type Error = anyhow::Error;
fn try_from(mut c: CmdCow) -> Result<Self, Self::Error> {
let Ok(updates) = c.take("updates") else {
fn try_from(mut a: ActionCow) -> Result<Self, Self::Error> {
let Ok(updates) = a.take("updates") else {
bail!("Invalid 'updates' in UpdateMimesOpt");
};

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,15 +1,15 @@
local M = {}
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 output, err = Command(cmd):arg({ "-bL", "--", path }):output()
local output, err = Command(program):arg({ "-bL", "--", path }):output()
local text
if output then
text = ui.Text.parse("----- File Type Classification -----\n\n" .. output.stdout)
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
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 yazi_binding::{Error, File};
use yazi_dds::Sendable;
use yazi_shared::event::CmdCow;
use yazi_shared::event::ActionCow;
use super::slim_lua;
use crate::loader::LOADER;
pub async fn fetch(
cmd: CmdCow,
action: ActionCow,
files: Vec<yazi_fs::File>,
) -> mlua::Result<(FetchState, Option<Error>)> {
if files.is_empty() {
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 || {
let lua = slim_lua(&cmd.name)?;
let lua = slim_lua(&action.name)?;
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)?),
])?;
Handle::current()
.block_on(async { LOADER.load(&lua, &cmd.name).await?.call_async_method("fetch", job).await })
Handle::current().block_on(async {
LOADER.load(&lua, &action.name).await?.call_async_method("fetch", job).await
})
})
.await
.into_lua_err()?

View file

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

View file

@ -3,9 +3,9 @@ use yazi_binding::{File, elements::Rect};
use yazi_config::LAYOUT;
use yazi_parser::app::PluginOpt;
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 job = lua.create_table_from([
("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)
};
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 yazi_binding::{File, Id};
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 crate::loader::LOADER;
@ -12,7 +12,7 @@ use crate::loader::LOADER;
static IDS: Ids = Ids::new();
pub fn spot(
cmd: &'static Cmd,
action: &'static Action,
file: yazi_fs::File,
mime: Symbol<str>,
skip: usize,
@ -22,9 +22,9 @@ pub fn spot(
tokio::task::spawn_blocking(move || {
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(
HookTriggers::new().on_calls().on_returns().every_nth_instruction(2000),
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([
("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)?),
("mime", mime.into_lua(&lua)?),
("skip", skip.into_lua(&lua)?),

View file

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

View file

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

View file

@ -4,7 +4,7 @@ macro_rules! deprecate {
static WARNED: std::sync::atomic::AtomicBool = std::sync::atomic::AtomicBool::new(false);
if !WARNED.swap(true, std::sync::atomic::Ordering::Relaxed) {
$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_fs::FsHash64;
use yazi_plugin::isolate;
use yazi_shared::event::CmdCow;
use yazi_shared::event::ActionCow;
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> {
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();
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}};
#[derive(Clone, Debug, Default)]
pub struct Cmd {
pub struct Action {
pub name: SStr,
pub args: HashMap<DataKey, Data>,
pub layer: Layer,
pub source: Source,
}
impl Cmd {
impl Action {
pub fn new<N>(name: N, source: Source, default: Option<Layer>) -> Result<Self>
where
N: Into<SStr>,
{
let cow: SStr = name.into();
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 {
Cow::Borrowed(s) => Cow::Borrowed(&s[i + 1..]),
Cow::Owned(mut s) => {
@ -47,10 +47,10 @@ impl Cmd {
D: Into<Data>,
I: IntoIterator<Item = D>,
{
let mut cmd = Self::new(name, Source::Relay, None).unwrap_or(Self::null());
cmd.args =
let mut action = Self::new(name, Source::Relay, None).unwrap_or(Self::null());
action.args =
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() } }
@ -215,7 +215,7 @@ impl Cmd {
}
}
impl Display for Cmd {
impl Display for Action {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", self.name)?;
@ -238,13 +238,13 @@ impl Display for Cmd {
}
}
impl FromStr for Cmd {
impl FromStr for Action {
type Err = anyhow::Error;
fn from_str(s: &str) -> Result<Self, Self::Err> {
let (mut words, last) = crate::shell::unix::split(s, true)?;
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()))?;
@ -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>
where
D: serde::Deserializer<'de>,

View file

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

View file

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

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