diff --git a/CHANGELOG.md b/CHANGELOG.md index 1fb14358..94b6aad7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 `` and `` 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 `` as `` ([#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 ``, ``, and `` keybindings for inputs ([#665]) - New `` and `` 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 ``, ``, ``, and `` keybindings) ([#213]) +- Percentage values for the `arrow` action to scroll half/full page (with newly added Vi-like ``, ``, ``, and `` 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` diff --git a/yazi-actor/src/context.rs b/yazi-actor/src/context.rs index 6633428c..2c460256 100644 --- a/yazi-actor/src/context.rs +++ b/yazi-actor/src/context.rs @@ -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) -> Result { - let tab = if let Ok(id) = cmd.get::("tab") { + pub fn new(action: &Action, core: &'a mut Core, term: &'a mut Option) -> Result { + let tab = if let Ok(id) = action.get::("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![], }) diff --git a/yazi-binding/src/input.rs b/yazi-binding/src/input.rs index 35741c3a..5c98078f 100644 --- a/yazi-binding/src/input.rs +++ b/yazi-binding/src/input.rs @@ -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>> InputRx { } impl> + 'static> UserData for InputRx { - fn add_methods>(methods: &mut M) { + fn add_methods>(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))) diff --git a/yazi-binding/src/permit.rs b/yazi-binding/src/permit.rs index 19acf379..1224108b 100644 --- a/yazi-binding/src/permit.rs +++ b/yazi-binding/src/permit.rs @@ -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; @@ -45,7 +45,7 @@ impl Drop for Permit { } impl UserData for Permit { - fn add_methods>(methods: &mut M) { + fn add_methods>(methods: &mut M) { methods.add_async_method_mut("drop", |_, mut me, ()| async move { Ok(me.dropping().await) }); } } diff --git a/yazi-boot/src/actions/debug.rs b/yazi-boot/src/actions/debug.rs index bd9d3a38..e948364b 100644 --- a/yazi-boot/src/actions/debug.rs +++ b/yazi-boot/src/actions/debug.rs @@ -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() } diff --git a/yazi-cli/src/args.rs b/yazi-cli/src/args.rs index 86ebac67..a2728658 100644 --- a/yazi-cli/src/args.rs +++ b/yazi-cli/src/args.rs @@ -146,11 +146,11 @@ macro_rules! impl_emit_body { Arg(Vec), } - 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)?) } } }; diff --git a/yazi-config/src/keymap/chord.rs b/yazi-config/src/keymap/chord.rs index 1d35909a..8c036e56 100644 --- a/yazi-config/src/keymap/chord.rs +++ b/yazi-config/src/keymap/chord.rs @@ -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, #[serde(deserialize_with = "super::deserialize_run")] - pub run: Vec, + pub run: Vec, pub desc: Option, pub r#for: Option, } @@ -59,10 +59,10 @@ impl Chord { impl Chord { pub(super) fn reshape(mut self, layer: Layer) -> Result { - 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) diff --git a/yazi-config/src/keymap/cow.rs b/yazi-config/src/keymap/cow.rs index 78b71022..ba415af4 100644 --- a/yazi-config/src/keymap/cow.rs +++ b/yazi-config/src/keymap/cow.rs @@ -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 { + pub fn into_seq(self) -> Vec { 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(), diff --git a/yazi-config/src/keymap/deserializers.rs b/yazi-config/src/keymap/deserializers.rs index 462325c1..6d9fd14b 100644 --- a/yazi-config/src/keymap/deserializers.rs +++ b/yazi-config/src/keymap/deserializers.rs @@ -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::()? { - 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(self, value: &str) -> Result @@ -44,14 +44,14 @@ where deserializer.deserialize_any(OnVisitor) } -pub(super) fn deserialize_run<'de, D>(deserializer: D) -> Result, D::Error> +pub(super) fn deserialize_run<'de, D>(deserializer: D) -> Result, D::Error> where D: Deserializer<'de>, { struct RunVisitor; impl<'de> Visitor<'de> for RunVisitor { - type Value = Vec; + type Value = Vec; 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::()? { - 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(self, value: &str) -> Result 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)?]) } } diff --git a/yazi-config/src/plugin/fetcher.rs b/yazi-config/src/plugin/fetcher.rs index 6638c319..31414c8b 100644 --- a/yazi-config/src/plugin/fetcher.rs +++ b/yazi-config/src/plugin/fetcher.rs @@ -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, pub mime: Option, - pub run: Cmd, + pub run: Action, #[serde(default)] pub prio: Priority, } diff --git a/yazi-config/src/plugin/preloader.rs b/yazi-config/src/plugin/preloader.rs index 3af758ca..2df7766f 100644 --- a/yazi-config/src/plugin/preloader.rs +++ b/yazi-config/src/plugin/preloader.rs @@ -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, pub mime: Option, - pub run: Cmd, + pub run: Action, #[serde(default)] pub next: bool, #[serde(default)] diff --git a/yazi-config/src/plugin/previewer.rs b/yazi-config/src/plugin/previewer.rs index e98cb24c..d79063fb 100644 --- a/yazi-config/src/plugin/previewer.rs +++ b/yazi-config/src/plugin/previewer.rs @@ -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, pub mime: Option, - pub run: Cmd, + pub run: Action, } impl Previewer { diff --git a/yazi-config/src/plugin/spotter.rs b/yazi-config/src/plugin/spotter.rs index 9994370a..0e4d841c 100644 --- a/yazi-config/src/plugin/spotter.rs +++ b/yazi-config/src/plugin/spotter.rs @@ -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, pub mime: Option, - pub run: Cmd, + pub run: Action, } impl Spotter { diff --git a/yazi-dds/src/payload.rs b/yazi-dds/src/payload.rs index ec5be04a..7bedd083 100644 --- a/yazi-dds/src/payload.rs +++ b/yazi-dds/src/payload.rs @@ -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> for Payload<'a> { } } -impl TryFrom for Payload<'_> { +impl TryFrom for Payload<'_> { type Error = anyhow::Error; - fn try_from(mut c: CmdCow) -> Result { - c.take_any2("payload").ok_or_else(|| anyhow!("Missing 'payload' in Payload"))? + fn try_from(mut a: ActionCow) -> Result { + a.take_any2("payload").ok_or_else(|| anyhow!("Missing 'payload' in Payload"))? } } diff --git a/yazi-dds/src/sendable.rs b/yazi-dds/src/sendable.rs index 4334b34d..71c42550 100644 --- a/yazi-dds/src/sendable.rs +++ b/yazi-dds/src/sendable.rs @@ -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) diff --git a/yazi-fm/src/dispatcher.rs b/yazi-fm/src/dispatcher.rs index 51893ceb..fac9e74e 100644 --- a/yazi-fm/src/dispatcher.rs +++ b/yazi-fm/src/dispatcher.rs @@ -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 { Executor::new(self.app).execute(cmd) } + fn dispatch_call(&mut self, action: ActionCow) -> Result { + Executor::new(self.app).execute(action) + } #[inline] - fn dispatch_seq(&mut self, mut cmds: Vec) -> Result { - if let Some(last) = cmds.pop() { + fn dispatch_seq(&mut self, mut actions: Vec) -> Result { + 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!(); } diff --git a/yazi-fm/src/executor.rs b/yazi-fm/src/executor.rs index 5c00c37f..bf35ce13 100644 --- a/yazi-fm/src/executor.rs +++ b/yazi-fm/src/executor.rs @@ -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 { - 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 { + 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 { - let cx = &mut Ctx::new(&cmd, &mut self.app.core, &mut self.app.term)?; + fn app(&mut self, mut action: ActionCow) -> Result { + 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 { - let cx = &mut Ctx::new(&cmd, &mut self.app.core, &mut self.app.term)?; + fn mgr(&mut self, action: ActionCow) -> Result { + 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 { - let cx = &mut Ctx::new(&cmd, &mut self.app.core, &mut self.app.term)?; + fn tasks(&mut self, action: ActionCow) -> Result { + 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 { - let cx = &mut Ctx::new(&cmd, &mut self.app.core, &mut self.app.term)?; + fn spot(&mut self, action: ActionCow) -> Result { + 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 { - let cx = &mut Ctx::new(&cmd, &mut self.app.core, &mut self.app.term)?; + fn pick(&mut self, action: ActionCow) -> Result { + 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 { + fn input(&mut self, action: ActionCow) -> Result { 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 { - let cx = &mut Ctx::new(&cmd, &mut self.app.core, &mut self.app.term)?; + fn confirm(&mut self, action: ActionCow) -> Result { + 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 { - let cx = &mut Ctx::new(&cmd, &mut self.app.core, &mut self.app.term)?; + fn help(&mut self, action: ActionCow) -> Result { + 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 { - let cx = &mut Ctx::new(&cmd, &mut self.app.core, &mut self.app.term)?; + fn cmp(&mut self, action: ActionCow) -> Result { + 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 { - let cx = &mut Ctx::new(&cmd, &mut self.app.core, &mut self.app.term)?; + fn which(&mut self, action: ActionCow) -> Result { + 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 { - let cx = &mut Ctx::new(&cmd, &mut self.app.core, &mut self.app.term)?; + fn notify(&mut self, action: ActionCow) -> Result { + 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); } }; } diff --git a/yazi-fs/src/filter.rs b/yazi-fs/src/filter.rs index 7baf323c..62a16f58 100644 --- a/yazi-fs/src/filter.rs +++ b/yazi-fs/src/filter.rs @@ -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, diff --git a/yazi-macro/src/actor.rs b/yazi-macro/src/actor.rs index ca9999c1..c7daf069 100644 --- a/yazi-macro/src/actor.rs +++ b/yazi-macro/src/actor.rs @@ -24,8 +24,8 @@ macro_rules! act { result }}; - ($layer:ident : $name:ident, $cx:ident, $cmd:expr) => { - ::Options::try_from($cmd) + ($layer:ident : $name:ident, $cx:ident, $action:expr) => { + ::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()) diff --git a/yazi-macro/src/event.rs b/yazi-macro/src/event.rs index 2f307979..f4f9253a 100644 --- a/yazi-macro/src/event.rs +++ b/yazi-macro/src/event.rs @@ -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, ) diff --git a/yazi-parser/src/app/deprecate.rs b/yazi-parser/src/app/deprecate.rs index e35837d2..deb16820 100644 --- a/yazi-parser/src/app/deprecate.rs +++ b/yazi-parser/src/app/deprecate.rs @@ -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 for DeprecateOpt { +impl TryFrom for DeprecateOpt { type Error = anyhow::Error; - fn try_from(mut c: CmdCow) -> Result { - let Ok(content) = c.take("content") else { + fn try_from(mut a: ActionCow) -> Result { + let Ok(content) = a.take("content") else { bail!("Invalid 'content' in DeprecateOpt"); }; diff --git a/yazi-parser/src/app/plugin.rs b/yazi-parser/src/app/plugin.rs index 745f7a93..30d34575 100644 --- a/yazi-parser/src/app/plugin.rs +++ b/yazi-parser/src/app/plugin.rs @@ -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>, } -impl TryFrom for PluginOpt { +impl TryFrom for PluginOpt { type Error = anyhow::Error; - fn try_from(mut c: CmdCow) -> Result { - if let Some(opt) = c.take_any("opt") { + fn try_from(mut a: ActionCow) -> Result { + if let Some(opt) = a.take_any("opt") { return Ok(opt); } - let Some(id) = c.take_first::().ok().filter(|s| !s.is_empty()) else { + let Some(id) = a.take_first::().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") }) } } diff --git a/yazi-parser/src/app/quit.rs b/yazi-parser/src/app/quit.rs index 7990cd01..283d8f38 100644 --- a/yazi-parser/src/app/quit.rs +++ b/yazi-parser/src/app/quit.rs @@ -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 for QuitOpt { +impl TryFrom for QuitOpt { type Error = anyhow::Error; - fn try_from(mut c: CmdCow) -> Result { - if let Some(opt) = c.take_any2("opt") { + fn try_from(mut a: ActionCow) -> Result { + 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"), }) } } diff --git a/yazi-parser/src/app/update_progress.rs b/yazi-parser/src/app/update_progress.rs index c90dba3c..58386d48 100644 --- a/yazi-parser/src/app/update_progress.rs +++ b/yazi-parser/src/app/update_progress.rs @@ -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 for UpdateProgressOpt { +impl TryFrom for UpdateProgressOpt { type Error = anyhow::Error; - fn try_from(mut c: CmdCow) -> Result { - let Some(summary) = c.take_any("summary") else { + fn try_from(mut a: ActionCow) -> Result { + let Some(summary) = a.take_any("summary") else { bail!("Invalid 'summary' in UpdateProgressOpt"); }; diff --git a/yazi-parser/src/arrow.rs b/yazi-parser/src/arrow.rs index f369f728..061286bb 100644 --- a/yazi-parser/src/arrow.rs +++ b/yazi-parser/src/arrow.rs @@ -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 for ArrowOpt { +impl TryFrom for ArrowOpt { type Error = anyhow::Error; - fn try_from(c: CmdCow) -> Result { - let Ok(step) = c.first() else { + fn try_from(a: ActionCow) -> Result { + let Ok(step) = a.first() else { bail!("Invalid 'step' in ArrowOpt"); }; diff --git a/yazi-parser/src/cmp/close.rs b/yazi-parser/src/cmp/close.rs index 00a146d8..91a0d0b7 100644 --- a/yazi-parser/src/cmp/close.rs +++ b/yazi-parser/src/cmp/close.rs @@ -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 for CloseOpt { - fn from(c: CmdCow) -> Self { Self { submit: c.bool("submit") } } +impl From for CloseOpt { + fn from(a: ActionCow) -> Self { Self { submit: a.bool("submit") } } } impl From for CloseOpt { diff --git a/yazi-parser/src/cmp/show.rs b/yazi-parser/src/cmp/show.rs index d6b49a53..625b4cc0 100644 --- a/yazi-parser/src/cmp/show.rs +++ b/yazi-parser/src/cmp/show.rs @@ -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 for ShowOpt { +impl TryFrom for ShowOpt { type Error = anyhow::Error; - fn try_from(mut c: CmdCow) -> Result { - if let Some(opt) = c.take_any2("opt") { + fn try_from(mut a: ActionCow) -> Result { + if let Some(opt) = a.take_any2("opt") { opt } else { bail!("missing 'opt' argument"); diff --git a/yazi-parser/src/cmp/trigger.rs b/yazi-parser/src/cmp/trigger.rs index 2e60f2d0..92f7b793 100644 --- a/yazi-parser/src/cmp/trigger.rs +++ b/yazi-parser/src/cmp/trigger.rs @@ -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, } -impl From for TriggerOpt { - fn from(mut c: CmdCow) -> Self { - Self { word: c.take_first().unwrap_or_default(), ticket: c.get("ticket").ok() } +impl From for TriggerOpt { + fn from(mut a: ActionCow) -> Self { + Self { word: a.take_first().unwrap_or_default(), ticket: a.get("ticket").ok() } } } diff --git a/yazi-parser/src/confirm/close.rs b/yazi-parser/src/confirm/close.rs index 00a146d8..91a0d0b7 100644 --- a/yazi-parser/src/confirm/close.rs +++ b/yazi-parser/src/confirm/close.rs @@ -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 for CloseOpt { - fn from(c: CmdCow) -> Self { Self { submit: c.bool("submit") } } +impl From for CloseOpt { + fn from(a: ActionCow) -> Self { Self { submit: a.bool("submit") } } } impl From for CloseOpt { diff --git a/yazi-parser/src/confirm/show.rs b/yazi-parser/src/confirm/show.rs index 5df2d9f4..8e4a8f93 100644 --- a/yazi-parser/src/confirm/show.rs +++ b/yazi-parser/src/confirm/show.rs @@ -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 for ShowOpt { +impl TryFrom for ShowOpt { type Error = anyhow::Error; - fn try_from(mut c: CmdCow) -> Result { - let Some(cfg) = c.take_any("cfg") else { + fn try_from(mut a: ActionCow) -> Result { + 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"); }; diff --git a/yazi-parser/src/help/toggle.rs b/yazi-parser/src/help/toggle.rs index f333bbd5..31c8a823 100644 --- a/yazi-parser/src/help/toggle.rs +++ b/yazi-parser/src/help/toggle.rs @@ -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 for ToggleOpt { +impl TryFrom for ToggleOpt { type Error = anyhow::Error; - fn try_from(c: CmdCow) -> Result { Ok(Self { layer: c.str(0).parse()? }) } + fn try_from(a: ActionCow) -> Result { Ok(Self { layer: a.str(0).parse()? }) } } impl From for ToggleOpt { diff --git a/yazi-parser/src/input/close.rs b/yazi-parser/src/input/close.rs index 00a146d8..91a0d0b7 100644 --- a/yazi-parser/src/input/close.rs +++ b/yazi-parser/src/input/close.rs @@ -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 for CloseOpt { - fn from(c: CmdCow) -> Self { Self { submit: c.bool("submit") } } +impl From for CloseOpt { + fn from(a: ActionCow) -> Self { Self { submit: a.bool("submit") } } } impl From for CloseOpt { diff --git a/yazi-parser/src/input/show.rs b/yazi-parser/src/input/show.rs index cbf99d68..a7e31f28 100644 --- a/yazi-parser/src/input/show.rs +++ b/yazi-parser/src/input/show.rs @@ -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>, } -impl TryFrom for ShowOpt { +impl TryFrom for ShowOpt { type Error = anyhow::Error; - fn try_from(mut c: CmdCow) -> Result { - let Some(cfg) = c.take_any("cfg") else { + fn try_from(mut a: ActionCow) -> Result { + 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"); }; diff --git a/yazi-parser/src/mgr/cd.rs b/yazi-parser/src/mgr/cd.rs index 766651f3..ae85b24e 100644 --- a/yazi-parser/src/mgr/cd.rs +++ b/yazi-parser/src/mgr/cd.rs @@ -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 for CdOpt { - fn from(mut c: CmdCow) -> Self { - let mut target = c.take_first().unwrap_or_default(); +impl From 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 for CdOpt { Self { target: clean_url(target), - interactive: c.bool("interactive"), + interactive: a.bool("interactive"), source: CdSource::Cd, } } diff --git a/yazi-parser/src/mgr/close.rs b/yazi-parser/src/mgr/close.rs index 34d80e67..f1b074ce 100644 --- a/yazi-parser/src/mgr/close.rs +++ b/yazi-parser/src/mgr/close.rs @@ -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 for CloseOpt { +impl TryFrom for CloseOpt { type Error = anyhow::Error; - fn try_from(c: CmdCow) -> Result { c.try_into().map(Self) } + fn try_from(a: ActionCow) -> Result { a.try_into().map(Self) } } impl FromLua for CloseOpt { diff --git a/yazi-parser/src/mgr/copy.rs b/yazi-parser/src/mgr/copy.rs index 55d5d30f..52f8f733 100644 --- a/yazi-parser/src/mgr/copy.rs +++ b/yazi-parser/src/mgr/copy.rs @@ -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 for CopyOpt { - fn from(mut c: CmdCow) -> Self { +impl From 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"), } } } diff --git a/yazi-parser/src/mgr/create.rs b/yazi-parser/src/mgr/create.rs index 8d7e0068..72f9392e 100644 --- a/yazi-parser/src/mgr/create.rs +++ b/yazi-parser/src/mgr/create.rs @@ -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 for CreateOpt { - fn from(c: CmdCow) -> Self { Self { dir: c.bool("dir"), force: c.bool("force") } } +impl From for CreateOpt { + fn from(a: ActionCow) -> Self { Self { dir: a.bool("dir"), force: a.bool("force") } } } impl FromLua for CreateOpt { diff --git a/yazi-parser/src/mgr/displace_do.rs b/yazi-parser/src/mgr/displace_do.rs index afc766c9..b2ca6543 100644 --- a/yazi-parser/src/mgr/displace_do.rs +++ b/yazi-parser/src/mgr/displace_do.rs @@ -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 for DisplaceDoOpt { +impl TryFrom for DisplaceDoOpt { type Error = anyhow::Error; - fn try_from(mut c: CmdCow) -> Result { - if let Some(opt) = c.take_any2("opt") { + fn try_from(mut a: ActionCow) -> Result { + if let Some(opt) = a.take_any2("opt") { opt } else { bail!("Invalid 'opt' in DisplaceDoOpt"); diff --git a/yazi-parser/src/mgr/download.rs b/yazi-parser/src/mgr/download.rs index a22c85e1..b5d699b9 100644 --- a/yazi-parser/src/mgr/download.rs +++ b/yazi-parser/src/mgr/download.rs @@ -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 for DownloadOpt { - fn from(mut c: CmdCow) -> Self { Self { urls: c.take_seq(), open: c.bool("open") } } +impl From for DownloadOpt { + fn from(mut a: ActionCow) -> Self { Self { urls: a.take_seq(), open: a.bool("open") } } } impl FromLua for DownloadOpt { diff --git a/yazi-parser/src/mgr/escape.rs b/yazi-parser/src/mgr/escape.rs index 145b0390..953c06e1 100644 --- a/yazi-parser/src/mgr/escape.rs +++ b/yazi-parser/src/mgr/escape.rs @@ -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 for EscapeOpt { - fn from(c: CmdCow) -> Self { - c.args.iter().fold(Self::empty(), |acc, (k, v)| { +impl From 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, diff --git a/yazi-parser/src/mgr/filter.rs b/yazi-parser/src/mgr/filter.rs index 62170989..0f58c47e 100644 --- a/yazi-parser/src/mgr/filter.rs +++ b/yazi-parser/src/mgr/filter.rs @@ -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 for FilterOpt { +impl TryFrom for FilterOpt { type Error = anyhow::Error; - fn try_from(mut c: CmdCow) -> Result { - if let Some(opt) = c.take_any2("opt") { + fn try_from(mut a: ActionCow) -> Result { + 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"), }) } } diff --git a/yazi-parser/src/mgr/find.rs b/yazi-parser/src/mgr/find.rs index 7120a1fa..deb172e4 100644 --- a/yazi-parser/src/mgr/find.rs +++ b/yazi-parser/src/mgr/find.rs @@ -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 for FindOpt { +impl TryFrom for FindOpt { type Error = anyhow::Error; - fn try_from(c: CmdCow) -> Result { - Ok(Self { prev: c.bool("previous"), case: FilterCase::from(&*c) }) + fn try_from(a: ActionCow) -> Result { + Ok(Self { prev: a.bool("previous"), case: FilterCase::from(&*a) }) } } diff --git a/yazi-parser/src/mgr/find_arrow.rs b/yazi-parser/src/mgr/find_arrow.rs index 30bc2ef4..ff93827c 100644 --- a/yazi-parser/src/mgr/find_arrow.rs +++ b/yazi-parser/src/mgr/find_arrow.rs @@ -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 for FindArrowOpt { - fn from(c: CmdCow) -> Self { Self { prev: c.bool("previous") } } +impl From for FindArrowOpt { + fn from(a: ActionCow) -> Self { Self { prev: a.bool("previous") } } } impl FromLua for FindArrowOpt { diff --git a/yazi-parser/src/mgr/find_do.rs b/yazi-parser/src/mgr/find_do.rs index a3705104..7d09823a 100644 --- a/yazi-parser/src/mgr/find_do.rs +++ b/yazi-parser/src/mgr/find_do.rs @@ -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 for FindDoOpt { +impl TryFrom for FindDoOpt { type Error = anyhow::Error; - fn try_from(mut c: CmdCow) -> Result { - if let Some(opt) = c.take_any2("opt") { + fn try_from(mut a: ActionCow) -> Result { + 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) }) } } diff --git a/yazi-parser/src/mgr/hardlink.rs b/yazi-parser/src/mgr/hardlink.rs index df24058c..98287a06 100644 --- a/yazi-parser/src/mgr/hardlink.rs +++ b/yazi-parser/src/mgr/hardlink.rs @@ -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 for HardlinkOpt { - fn from(c: CmdCow) -> Self { Self { force: c.bool("force"), follow: c.bool("follow") } } +impl From for HardlinkOpt { + fn from(a: ActionCow) -> Self { Self { force: a.bool("force"), follow: a.bool("follow") } } } impl FromLua for HardlinkOpt { diff --git a/yazi-parser/src/mgr/hidden.rs b/yazi-parser/src/mgr/hidden.rs index 36f84d27..190b540a 100644 --- a/yazi-parser/src/mgr/hidden.rs +++ b/yazi-parser/src/mgr/hidden.rs @@ -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 for HiddenOpt { +impl TryFrom for HiddenOpt { type Error = anyhow::Error; - fn try_from(c: CmdCow) -> Result { - Ok(Self { state: c.str(0).parse().unwrap_or_default() }) + fn try_from(a: ActionCow) -> Result { + Ok(Self { state: a.str(0).parse().unwrap_or_default() }) } } diff --git a/yazi-parser/src/mgr/linemode.rs b/yazi-parser/src/mgr/linemode.rs index 6c416b89..b710ae6f 100644 --- a/yazi-parser/src/mgr/linemode.rs +++ b/yazi-parser/src/mgr/linemode.rs @@ -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 for LinemodeOpt { +impl TryFrom for LinemodeOpt { type Error = anyhow::Error; - fn try_from(mut c: CmdCow) -> Result { - let Ok(new) = c.take_first::() else { + fn try_from(mut a: ActionCow) -> Result { + let Ok(new) = a.take_first::() else { bail!("a string argument is required for LinemodeOpt"); }; diff --git a/yazi-parser/src/mgr/link.rs b/yazi-parser/src/mgr/link.rs index 1933d92e..d9970faa 100644 --- a/yazi-parser/src/mgr/link.rs +++ b/yazi-parser/src/mgr/link.rs @@ -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 for LinkOpt { - fn from(c: CmdCow) -> Self { Self { relative: c.bool("relative"), force: c.bool("force") } } +impl From for LinkOpt { + fn from(a: ActionCow) -> Self { Self { relative: a.bool("relative"), force: a.bool("force") } } } impl FromLua for LinkOpt { diff --git a/yazi-parser/src/mgr/open.rs b/yazi-parser/src/mgr/open.rs index dc2b29ce..5086860e 100644 --- a/yazi-parser/src/mgr/open.rs +++ b/yazi-parser/src/mgr/open.rs @@ -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 for OpenOpt { +impl TryFrom for OpenOpt { type Error = anyhow::Error; - fn try_from(mut c: CmdCow) -> Result { - if let Some(opt) = c.take_any2("opt") { + fn try_from(mut a: ActionCow) -> Result { + 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"), }) } } diff --git a/yazi-parser/src/mgr/open_do.rs b/yazi-parser/src/mgr/open_do.rs index 287403fe..9b86eec5 100644 --- a/yazi-parser/src/mgr/open_do.rs +++ b/yazi-parser/src/mgr/open_do.rs @@ -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 for OpenDoOpt { +impl TryFrom for OpenDoOpt { type Error = anyhow::Error; - fn try_from(mut c: CmdCow) -> Result { - if let Some(opt) = c.take_any2("opt") { + fn try_from(mut a: ActionCow) -> Result { + if let Some(opt) = a.take_any2("opt") { opt } else { bail!("Invalid 'opt' in OpenDoOpt"); diff --git a/yazi-parser/src/mgr/paste.rs b/yazi-parser/src/mgr/paste.rs index 56da952a..d9e7c42a 100644 --- a/yazi-parser/src/mgr/paste.rs +++ b/yazi-parser/src/mgr/paste.rs @@ -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 for PasteOpt { - fn from(c: CmdCow) -> Self { Self { force: c.bool("force"), follow: c.bool("follow") } } +impl From for PasteOpt { + fn from(a: ActionCow) -> Self { Self { force: a.bool("force"), follow: a.bool("follow") } } } impl FromLua for PasteOpt { diff --git a/yazi-parser/src/mgr/peek.rs b/yazi-parser/src/mgr/peek.rs index 881e5376..74143608 100644 --- a/yazi-parser/src/mgr/peek.rs +++ b/yazi-parser/src/mgr/peek.rs @@ -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 for PeekOpt { - fn from(mut c: CmdCow) -> Self { +impl From 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"), } } } diff --git a/yazi-parser/src/mgr/remove.rs b/yazi-parser/src/mgr/remove.rs index 6dc4ec3e..7225b349 100644 --- a/yazi-parser/src/mgr/remove.rs +++ b/yazi-parser/src/mgr/remove.rs @@ -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, } -impl From for RemoveOpt { - fn from(mut c: CmdCow) -> Self { +impl From 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(), } } } diff --git a/yazi-parser/src/mgr/rename.rs b/yazi-parser/src/mgr/rename.rs index 93830bfa..69b459b4 100644 --- a/yazi-parser/src/mgr/rename.rs +++ b/yazi-parser/src/mgr/rename.rs @@ -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 for RenameOpt { - fn from(mut c: CmdCow) -> Self { +impl From 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(), } } } diff --git a/yazi-parser/src/mgr/reveal.rs b/yazi-parser/src/mgr/reveal.rs index 59187185..8d8daf8e 100644 --- a/yazi-parser/src/mgr/reveal.rs +++ b/yazi-parser/src/mgr/reveal.rs @@ -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 for RevealOpt { - fn from(mut c: CmdCow) -> Self { - let mut target = c.take_first().unwrap_or_default(); +impl From 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 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") } } } diff --git a/yazi-parser/src/mgr/search.rs b/yazi-parser/src/mgr/search.rs index 8ce91bd4..87fddfe5 100644 --- a/yazi-parser/src/mgr/search.rs +++ b/yazi-parser/src/mgr/search.rs @@ -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 for SearchOpt { +impl TryFrom for SearchOpt { type Error = anyhow::Error; - fn try_from(mut c: CmdCow) -> Result { + fn try_from(mut a: ActionCow) -> Result { // 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 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(), }) } } diff --git a/yazi-parser/src/mgr/seek.rs b/yazi-parser/src/mgr/seek.rs index bc8183da..a646b24b 100644 --- a/yazi-parser/src/mgr/seek.rs +++ b/yazi-parser/src/mgr/seek.rs @@ -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 for SeekOpt { - fn from(c: CmdCow) -> Self { Self { units: c.first().unwrap_or(0) } } +impl From for SeekOpt { + fn from(a: ActionCow) -> Self { Self { units: a.first().unwrap_or(0) } } } impl FromLua for SeekOpt { diff --git a/yazi-parser/src/mgr/shell.rs b/yazi-parser/src/mgr/shell.rs index d4fcebc1..f5914b60 100644 --- a/yazi-parser/src/mgr/shell.rs +++ b/yazi-parser/src/mgr/shell.rs @@ -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, } -impl TryFrom for ShellOpt { +impl TryFrom for ShellOpt { type Error = anyhow::Error; - fn try_from(mut c: CmdCow) -> Result { + fn try_from(mut a: ActionCow) -> Result { 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()) { diff --git a/yazi-parser/src/mgr/sort.rs b/yazi-parser/src/mgr/sort.rs index 5e4295a2..fc689e3a 100644 --- a/yazi-parser/src/mgr/sort.rs +++ b/yazi-parser/src/mgr/sort.rs @@ -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, } -impl TryFrom for SortOpt { +impl TryFrom for SortOpt { type Error = anyhow::Error; - fn try_from(c: CmdCow) -> Result { + fn try_from(a: ActionCow) -> Result { 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()?, }) } } diff --git a/yazi-parser/src/mgr/spot.rs b/yazi-parser/src/mgr/spot.rs index 02591edf..08fb39e3 100644 --- a/yazi-parser/src/mgr/spot.rs +++ b/yazi-parser/src/mgr/spot.rs @@ -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, } -impl From for SpotOpt { - fn from(c: CmdCow) -> Self { Self { skip: c.get("skip").ok() } } +impl From for SpotOpt { + fn from(a: ActionCow) -> Self { Self { skip: a.get("skip").ok() } } } impl From for SpotOpt { diff --git a/yazi-parser/src/mgr/stash.rs b/yazi-parser/src/mgr/stash.rs index 35f6a197..9dfa2bc3 100644 --- a/yazi-parser/src/mgr/stash.rs +++ b/yazi-parser/src/mgr/stash.rs @@ -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 for StashOpt { +impl TryFrom for StashOpt { type Error = anyhow::Error; - fn try_from(_: CmdCow) -> Result { bail!("unsupported") } + fn try_from(_: ActionCow) -> Result { bail!("unsupported") } } impl From for StashOpt { diff --git a/yazi-parser/src/mgr/tab_close.rs b/yazi-parser/src/mgr/tab_close.rs index da54de94..e5205cbe 100644 --- a/yazi-parser/src/mgr/tab_close.rs +++ b/yazi-parser/src/mgr/tab_close.rs @@ -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 for TabCloseOpt { - fn from(c: CmdCow) -> Self { Self { idx: c.first().unwrap_or(0) } } +impl From for TabCloseOpt { + fn from(a: ActionCow) -> Self { Self { idx: a.first().unwrap_or(0) } } } impl From for TabCloseOpt { diff --git a/yazi-parser/src/mgr/tab_create.rs b/yazi-parser/src/mgr/tab_create.rs index d6c789a1..f891d19f 100644 --- a/yazi-parser/src/mgr/tab_create.rs +++ b/yazi-parser/src/mgr/tab_create.rs @@ -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>, } -impl From for TabCreateOpt { - fn from(mut c: CmdCow) -> Self { - if c.bool("current") { +impl From 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); } diff --git a/yazi-parser/src/mgr/tab_rename.rs b/yazi-parser/src/mgr/tab_rename.rs index 9ae2b0f0..45a0062b 100644 --- a/yazi-parser/src/mgr/tab_rename.rs +++ b/yazi-parser/src/mgr/tab_rename.rs @@ -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 for TabRenameOpt { +impl TryFrom for TabRenameOpt { type Error = anyhow::Error; - fn try_from(mut c: CmdCow) -> Result { - let name = c.take_first().ok(); - let interactive = c.bool("interactive"); + fn try_from(mut a: ActionCow) -> Result { + 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"); diff --git a/yazi-parser/src/mgr/tab_switch.rs b/yazi-parser/src/mgr/tab_switch.rs index f6652330..69ad43ea 100644 --- a/yazi-parser/src/mgr/tab_switch.rs +++ b/yazi-parser/src/mgr/tab_switch.rs @@ -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 for TabSwitchOpt { - fn from(c: CmdCow) -> Self { Self { step: c.first().unwrap_or(0), relative: c.bool("relative") } } +impl From for TabSwitchOpt { + fn from(a: ActionCow) -> Self { + Self { step: a.first().unwrap_or(0), relative: a.bool("relative") } + } } impl FromLua for TabSwitchOpt { diff --git a/yazi-parser/src/mgr/toggle.rs b/yazi-parser/src/mgr/toggle.rs index 585c80c2..4ee8ac93 100644 --- a/yazi-parser/src/mgr/toggle.rs +++ b/yazi-parser/src/mgr/toggle.rs @@ -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, } -impl From for ToggleOpt { - fn from(mut c: CmdCow) -> Self { +impl From 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, diff --git a/yazi-parser/src/mgr/toggle_all.rs b/yazi-parser/src/mgr/toggle_all.rs index 6ccd8e10..70349587 100644 --- a/yazi-parser/src/mgr/toggle_all.rs +++ b/yazi-parser/src/mgr/toggle_all.rs @@ -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, } -impl From for ToggleAllOpt { - fn from(mut c: CmdCow) -> Self { +impl From 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, diff --git a/yazi-parser/src/mgr/update_files.rs b/yazi-parser/src/mgr/update_files.rs index 6f274379..7ea73da2 100644 --- a/yazi-parser/src/mgr/update_files.rs +++ b/yazi-parser/src/mgr/update_files.rs @@ -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 for UpdateFilesOpt { +impl TryFrom for UpdateFilesOpt { type Error = anyhow::Error; - fn try_from(mut c: CmdCow) -> Result { - let Some(op) = c.take_any("op") else { + fn try_from(mut a: ActionCow) -> Result { + let Some(op) = a.take_any("op") else { bail!("Invalid 'op' in UpdateFilesOpt"); }; diff --git a/yazi-parser/src/mgr/update_mimes.rs b/yazi-parser/src/mgr/update_mimes.rs index 4a47c18f..f2e6f444 100644 --- a/yazi-parser/src/mgr/update_mimes.rs +++ b/yazi-parser/src/mgr/update_mimes.rs @@ -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, } -impl TryFrom for UpdateMimesOpt { +impl TryFrom for UpdateMimesOpt { type Error = anyhow::Error; - fn try_from(mut c: CmdCow) -> Result { - let Ok(updates) = c.take("updates") else { + fn try_from(mut a: ActionCow) -> Result { + let Ok(updates) = a.take("updates") else { bail!("Invalid 'updates' in UpdateMimesOpt"); }; diff --git a/yazi-parser/src/mgr/update_paged.rs b/yazi-parser/src/mgr/update_paged.rs index e943e7e2..cd94fc02 100644 --- a/yazi-parser/src/mgr/update_paged.rs +++ b/yazi-parser/src/mgr/update_paged.rs @@ -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>, } -impl From for UpdatePagedOpt { - fn from(mut c: CmdCow) -> Self { Self { page: c.first().ok(), only_if: c.take("only-if").ok() } } +impl From for UpdatePagedOpt { + fn from(mut a: ActionCow) -> Self { + Self { page: a.first().ok(), only_if: a.take("only-if").ok() } + } } impl From<()> for UpdatePagedOpt { diff --git a/yazi-parser/src/mgr/update_peeked.rs b/yazi-parser/src/mgr/update_peeked.rs index 4af594e0..a56c960b 100644 --- a/yazi-parser/src/mgr/update_peeked.rs +++ b/yazi-parser/src/mgr/update_peeked.rs @@ -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 for UpdatePeekedOpt { +impl TryFrom for UpdatePeekedOpt { type Error = anyhow::Error; - fn try_from(mut c: CmdCow) -> Result { - if let Some(opt) = c.take_any2("opt") { + fn try_from(mut a: ActionCow) -> Result { + 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"); }; diff --git a/yazi-parser/src/mgr/update_spotted.rs b/yazi-parser/src/mgr/update_spotted.rs index 39bb0156..63fc765f 100644 --- a/yazi-parser/src/mgr/update_spotted.rs +++ b/yazi-parser/src/mgr/update_spotted.rs @@ -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 for UpdateSpottedOpt { +impl TryFrom for UpdateSpottedOpt { type Error = anyhow::Error; - fn try_from(mut c: CmdCow) -> Result { - if let Some(opt) = c.take_any2("opt") { + fn try_from(mut a: ActionCow) -> Result { + 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"); }; diff --git a/yazi-parser/src/mgr/update_yanked.rs b/yazi-parser/src/mgr/update_yanked.rs index d835a508..ed45f55a 100644 --- a/yazi-parser/src/mgr/update_yanked.rs +++ b/yazi-parser/src/mgr/update_yanked.rs @@ -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, fn(UrlBufCov) -> yazi_binding::Url>, @@ -18,11 +18,11 @@ pub struct UpdateYankedOpt<'a> { pub urls: Cow<'a, HashSet>, } -impl TryFrom for UpdateYankedOpt<'_> { +impl TryFrom for UpdateYankedOpt<'_> { type Error = anyhow::Error; - fn try_from(mut c: CmdCow) -> Result { - if let Some(opt) = c.take_any2("opt") { + fn try_from(mut a: ActionCow) -> Result { + if let Some(opt) = a.take_any2("opt") { opt } else { bail!("Invalid 'opt' in UpdateYankedOpt"); diff --git a/yazi-parser/src/mgr/upload.rs b/yazi-parser/src/mgr/upload.rs index 2c876ddc..33deb022 100644 --- a/yazi-parser/src/mgr/upload.rs +++ b/yazi-parser/src/mgr/upload.rs @@ -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>, } -impl From for UploadOpt { - fn from(mut c: CmdCow) -> Self { Self { urls: c.take_seq() } } +impl From for UploadOpt { + fn from(mut a: ActionCow) -> Self { Self { urls: a.take_seq() } } } impl FromLua for UploadOpt { diff --git a/yazi-parser/src/mgr/visual_mode.rs b/yazi-parser/src/mgr/visual_mode.rs index efa81252..38b7eb73 100644 --- a/yazi-parser/src/mgr/visual_mode.rs +++ b/yazi-parser/src/mgr/visual_mode.rs @@ -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 for VisualModeOpt { - fn from(c: CmdCow) -> Self { Self { unset: c.bool("unset") } } +impl From for VisualModeOpt { + fn from(a: ActionCow) -> Self { Self { unset: a.bool("unset") } } } impl FromLua for VisualModeOpt { diff --git a/yazi-parser/src/mgr/yank.rs b/yazi-parser/src/mgr/yank.rs index 0275d415..176c30c3 100644 --- a/yazi-parser/src/mgr/yank.rs +++ b/yazi-parser/src/mgr/yank.rs @@ -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 for YankOpt { - fn from(c: CmdCow) -> Self { Self { cut: c.bool("cut") } } +impl From for YankOpt { + fn from(a: ActionCow) -> Self { Self { cut: a.bool("cut") } } } impl FromLua for YankOpt { diff --git a/yazi-parser/src/notify/push.rs b/yazi-parser/src/notify/push.rs index cb0c7bda..9e230705 100644 --- a/yazi-parser/src/notify/push.rs +++ b/yazi-parser/src/notify/push.rs @@ -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 for PushOpt { +impl TryFrom for PushOpt { type Error = anyhow::Error; - fn try_from(mut c: CmdCow) -> Result { - c.take_any("opt").ok_or_else(|| anyhow!("Invalid 'opt' in NotifyOpt")) + fn try_from(mut a: ActionCow) -> Result { + a.take_any("opt").ok_or_else(|| anyhow!("Invalid 'opt' in NotifyOpt")) } } diff --git a/yazi-parser/src/notify/tick.rs b/yazi-parser/src/notify/tick.rs index 6a0a5593..d8bd4ff7 100644 --- a/yazi-parser/src/notify/tick.rs +++ b/yazi-parser/src/notify/tick.rs @@ -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 for TickOpt { +impl TryFrom for TickOpt { type Error = anyhow::Error; - fn try_from(c: CmdCow) -> Result { - let Ok(interval) = c.first() else { + fn try_from(a: ActionCow) -> Result { + let Ok(interval) = a.first() else { bail!("Invalid 'interval' in TickOpt"); }; diff --git a/yazi-parser/src/pick/close.rs b/yazi-parser/src/pick/close.rs index 00a146d8..91a0d0b7 100644 --- a/yazi-parser/src/pick/close.rs +++ b/yazi-parser/src/pick/close.rs @@ -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 for CloseOpt { - fn from(c: CmdCow) -> Self { Self { submit: c.bool("submit") } } +impl From for CloseOpt { + fn from(a: ActionCow) -> Self { Self { submit: a.bool("submit") } } } impl From for CloseOpt { diff --git a/yazi-parser/src/pick/show.rs b/yazi-parser/src/pick/show.rs index 543789aa..0e9239f8 100644 --- a/yazi-parser/src/pick/show.rs +++ b/yazi-parser/src/pick/show.rs @@ -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>, } -impl TryFrom for ShowOpt { +impl TryFrom for ShowOpt { type Error = anyhow::Error; - fn try_from(mut c: CmdCow) -> Result { - let Some(cfg) = c.take_any("cfg") else { + fn try_from(mut a: ActionCow) -> Result { + 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"); }; diff --git a/yazi-parser/src/spot/copy.rs b/yazi-parser/src/spot/copy.rs index f5799fef..a073c50c 100644 --- a/yazi-parser/src/spot/copy.rs +++ b/yazi-parser/src/spot/copy.rs @@ -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 for CopyOpt { - fn from(mut c: CmdCow) -> Self { Self { r#type: c.take_first().unwrap_or_default() } } +impl From for CopyOpt { + fn from(mut a: ActionCow) -> Self { Self { r#type: a.take_first().unwrap_or_default() } } } impl FromLua for CopyOpt { diff --git a/yazi-parser/src/tasks/process_open.rs b/yazi-parser/src/tasks/process_open.rs index e7d5e28c..a42c71b0 100644 --- a/yazi-parser/src/tasks/process_open.rs +++ b/yazi-parser/src/tasks/process_open.rs @@ -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 for ProcessOpenOpt { +impl TryFrom for ProcessOpenOpt { type Error = anyhow::Error; - fn try_from(mut c: CmdCow) -> Result { - c.take_any("opt").ok_or_else(|| anyhow!("Missing 'opt' in ProcessOpenOpt")) + fn try_from(mut a: ActionCow) -> Result { + a.take_any("opt").ok_or_else(|| anyhow!("Missing 'opt' in ProcessOpenOpt")) } } diff --git a/yazi-parser/src/tasks/update_succeed.rs b/yazi-parser/src/tasks/update_succeed.rs index b9187a83..524f12e7 100644 --- a/yazi-parser/src/tasks/update_succeed.rs +++ b/yazi-parser/src/tasks/update_succeed.rs @@ -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, } -impl TryFrom for UpdateSucceedOpt { +impl TryFrom for UpdateSucceedOpt { type Error = anyhow::Error; - fn try_from(mut c: CmdCow) -> Result { - let Some(urls) = c.take_any("urls") else { + fn try_from(mut a: ActionCow) -> Result { + let Some(urls) = a.take_any("urls") else { bail!("Invalid 'urls' in UpdateSucceedOpt"); }; diff --git a/yazi-parser/src/void.rs b/yazi-parser/src/void.rs index 2b9f25cf..c82ac915 100644 --- a/yazi-parser/src/void.rs +++ b/yazi-parser/src/void.rs @@ -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 for VoidOpt { - fn from(_: CmdCow) -> Self { Self } +impl From for VoidOpt { + fn from(_: ActionCow) -> Self { Self } } impl From<()> for VoidOpt { diff --git a/yazi-parser/src/which/activate.rs b/yazi-parser/src/which/activate.rs index 73fca637..7d741e2e 100644 --- a/yazi-parser/src/which/activate.rs +++ b/yazi-parser/src/which/activate.rs @@ -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 for ActivateOpt { +impl TryFrom for ActivateOpt { type Error = anyhow::Error; - fn try_from(mut c: CmdCow) -> Result { - if let Some(opt) = c.take_any2("opt") { + fn try_from(mut a: ActionCow) -> Result { + if let Some(opt) = a.take_any2("opt") { return opt; } Ok(Self { - tx: c.take_any2("tx").transpose()?, - cands: c.take_any_iter::().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::().map(Into::into).collect(), + silent: a.bool("silent"), + times: a.get("times").unwrap_or(0), }) } } diff --git a/yazi-plugin/preset/plugins/dds.lua b/yazi-plugin/preset/plugins/dds.lua index b6e403ac..4b28fda0 100644 --- a/yazi-plugin/preset/plugins/dds.lua +++ b/yazi-plugin/preset/plugins/dds.lua @@ -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 diff --git a/yazi-plugin/preset/plugins/file.lua b/yazi-plugin/preset/plugins/file.lua index 246a79d1..78f487ec 100644 --- a/yazi-plugin/preset/plugins/file.lua +++ b/yazi-plugin/preset/plugins/file.lua @@ -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)) diff --git a/yazi-plugin/src/isolate/fetch.rs b/yazi-plugin/src/isolate/fetch.rs index 7fb2f72e..7482feaf 100644 --- a/yazi-plugin/src/isolate/fetch.rs +++ b/yazi-plugin/src/isolate/fetch.rs @@ -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, ) -> mlua::Result<(FetchState, Option)> { 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()? diff --git a/yazi-plugin/src/isolate/peek.rs b/yazi-plugin/src/isolate/peek.rs index eddb41d1..ca1c9a29 100644 --- a/yazi-plugin/src/isolate/peek.rs +++ b/yazi-plugin/src/isolate/peek.rs @@ -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, skip: usize, ) -> Option { - 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, skip: usize) { +fn peek_sync(action: &'static Action, file: yazi_fs::File, mime: Symbol, 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, 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, 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)?), diff --git a/yazi-plugin/src/isolate/preload.rs b/yazi-plugin/src/isolate/preload.rs index f112d1a2..f6f85dfd 100644 --- a/yazi-plugin/src/isolate/preload.rs +++ b/yazi-plugin/src/isolate/preload.rs @@ -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)> { 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)?), ])?; diff --git a/yazi-plugin/src/isolate/seek.rs b/yazi-plugin/src/isolate/seek.rs index 0762711f..701da4b6 100644 --- a/yazi-plugin/src/isolate/seek.rs +++ b/yazi-plugin/src/isolate/seek.rs @@ -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)); } diff --git a/yazi-plugin/src/isolate/spot.rs b/yazi-plugin/src/isolate/spot.rs index 308cfe63..183a2ae9 100644 --- a/yazi-plugin/src/isolate/spot.rs +++ b/yazi-plugin/src/isolate/spot.rs @@ -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, 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)?), diff --git a/yazi-plugin/src/utils/call.rs b/yazi-plugin/src/utils/call.rs index 4b68bd9b..d88d1b51 100644 --- a/yazi-plugin/src/utils/call.rs +++ b/yazi-plugin/src/utils/call.rs @@ -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 { 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 { 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, diff --git a/yazi-plugin/src/utils/layer.rs b/yazi-plugin/src/utils/layer.rs index ffc8f1cd..6a0b0bcf 100644 --- a/yazi-plugin/src/utils/layer.rs +++ b/yazi-plugin/src/utils/layer.rs @@ -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) }) diff --git a/yazi-proxy/src/macros.rs b/yazi-proxy/src/macros.rs index a2c1d4f4..7c399c6c 100644 --- a/yazi-proxy/src/macros.rs +++ b/yazi-proxy/src/macros.rs @@ -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)) )); } }}; diff --git a/yazi-scheduler/src/fetch/fetch.rs b/yazi-scheduler/src/fetch/fetch.rs index 1992dba0..87fe6e59 100644 --- a/yazi-scheduler/src/fetch/fetch.rs +++ b/yazi-scheduler/src/fetch/fetch.rs @@ -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)) { diff --git a/yazi-shared/src/event/cmd.rs b/yazi-shared/src/event/action.rs similarity index 95% rename from yazi-shared/src/event/cmd.rs rename to yazi-shared/src/event/action.rs index f09ec440..82d5cb11 100644 --- a/yazi-shared/src/event/cmd.rs +++ b/yazi-shared/src/event/action.rs @@ -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, pub layer: Layer, pub source: Source, } -impl Cmd { +impl Action { pub fn new(name: N, source: Source, default: Option) -> Result where N: Into, { 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, I: IntoIterator, { - 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 { 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(deserializer: D) -> Result where D: serde::Deserializer<'de>, diff --git a/yazi-shared/src/event/cow.rs b/yazi-shared/src/event/cow.rs index 85f89778..04af09de 100644 --- a/yazi-shared/src/event/cow.rs +++ b/yazi-shared/src/event/cow.rs @@ -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 for () { - fn from(_: CmdCow) -> Self { () } +impl From for () { + fn from(_: ActionCow) -> Self { () } } -impl From for CmdCow { - fn from(c: Cmd) -> Self { Self::Owned(c) } +impl From 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) -> Result where T: TryFrom + TryFrom<&'a Data>, diff --git a/yazi-shared/src/event/event.rs b/yazi-shared/src/event/event.rs index edf10871..ab6698a2 100644 --- a/yazi-shared/src/event/event.rs +++ b/yazi-shared/src/event/event.rs @@ -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> = RoCell::new(); @@ -9,8 +9,8 @@ static RX: RoCell> = RoCell::new(); #[derive(Debug)] pub enum Event { - Call(CmdCow), - Seq(Vec), + Call(ActionCow), + Seq(Vec), Render(bool), Key(KeyEvent), Mouse(MouseEvent), diff --git a/yazi-shared/src/event/mod.rs b/yazi-shared/src/event/mod.rs index 420a2d6c..d3259125 100644 --- a/yazi-shared/src/event/mod.rs +++ b/yazi-shared/src/event/mod.rs @@ -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); diff --git a/yazi-widgets/src/clear.rs b/yazi-widgets/src/clear.rs index 2534c982..807a3136 100644 --- a/yazi-widgets/src/clear.rs +++ b/yazi-widgets/src/clear.rs @@ -1,6 +1,6 @@ use std::sync::atomic::{AtomicBool, Ordering}; -use ratatui::widgets::Widget; +use ratatui::{buffer::Buffer, layout::Rect, widgets::Widget}; use yazi_adapter::ADAPTOR; pub static COLLISION: AtomicBool = AtomicBool::new(false); @@ -9,7 +9,7 @@ pub static COLLISION: AtomicBool = AtomicBool::new(false); pub struct Clear; impl Widget for Clear { - fn render(self, area: ratatui::layout::Rect, buf: &mut ratatui::prelude::Buffer) + fn render(self, area: Rect, buf: &mut Buffer) where Self: Sized, { @@ -29,11 +29,11 @@ impl Widget for Clear { } } -const fn is_overlapping(a: ratatui::layout::Rect, b: ratatui::layout::Rect) -> bool { +const fn is_overlapping(a: Rect, b: Rect) -> bool { a.x < b.x + b.width && a.x + a.width > b.x && a.y < b.y + b.height && a.y + a.height > b.y } -fn overlap(a: ratatui::layout::Rect, b: ratatui::layout::Rect) -> Option { +fn overlap(a: Rect, b: Rect) -> Option { if !is_overlapping(a, b) { return None; } @@ -42,5 +42,5 @@ fn overlap(a: ratatui::layout::Rect, b: ratatui::layout::Rect) -> Option Result { + pub fn execute(&mut self, action: ActionCow) -> Result { macro_rules! on { ($name:ident) => { - if cmd.name == stringify!($name) { - return act!($name, self, cmd); + if action.name == stringify!($name) { + return act!($name, self, action); } }; ($name:ident, $alias:literal) => { - if cmd.name == $alias { - return act!($name, self, cmd); + if action.name == $alias { + return act!($name, self, action); } }; } diff --git a/yazi-widgets/src/input/parser/backspace.rs b/yazi-widgets/src/input/parser/backspace.rs index b2cb9078..6c586ea6 100644 --- a/yazi-widgets/src/input/parser/backspace.rs +++ b/yazi-widgets/src/input/parser/backspace.rs @@ -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 BackspaceOpt { pub under: bool, } -impl From for BackspaceOpt { - fn from(c: CmdCow) -> Self { Self { under: c.bool("under") } } +impl From for BackspaceOpt { + fn from(a: ActionCow) -> Self { Self { under: a.bool("under") } } } impl From for BackspaceOpt { diff --git a/yazi-widgets/src/input/parser/backward.rs b/yazi-widgets/src/input/parser/backward.rs index 9c3ee892..b26c8fca 100644 --- a/yazi-widgets/src/input/parser/backward.rs +++ b/yazi-widgets/src/input/parser/backward.rs @@ -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 BackwardOpt { pub far: bool, } -impl From for BackwardOpt { - fn from(c: CmdCow) -> Self { Self { far: c.bool("far") } } +impl From for BackwardOpt { + fn from(a: ActionCow) -> Self { Self { far: a.bool("far") } } } impl FromLua for BackwardOpt { diff --git a/yazi-widgets/src/input/parser/casefy.rs b/yazi-widgets/src/input/parser/casefy.rs index 30628c91..98aa5552 100644 --- a/yazi-widgets/src/input/parser/casefy.rs +++ b/yazi-widgets/src/input/parser/casefy.rs @@ -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 CasefyOpt { pub upper: bool, } -impl From for CasefyOpt { - fn from(c: CmdCow) -> Self { Self { upper: c.str(0) == "upper" } } +impl From for CasefyOpt { + fn from(a: ActionCow) -> Self { Self { upper: a.str(0) == "upper" } } } impl FromLua for CasefyOpt { diff --git a/yazi-widgets/src/input/parser/complete.rs b/yazi-widgets/src/input/parser/complete.rs index d1b062bb..318f0b38 100644 --- a/yazi-widgets/src/input/parser/complete.rs +++ b/yazi-widgets/src/input/parser/complete.rs @@ -1,7 +1,7 @@ use std::path::MAIN_SEPARATOR_STR; use mlua::{ExternalError, FromLua, IntoLua, Lua, Value}; -use yazi_shared::{Id, event::CmdCow, strand::{StrandBuf, StrandLike}}; +use yazi_shared::{Id, event::ActionCow, strand::{StrandBuf, StrandLike}}; #[derive(Debug)] pub struct CompleteOpt { @@ -10,14 +10,14 @@ pub struct CompleteOpt { pub ticket: Id, } -impl TryFrom for CompleteOpt { +impl TryFrom for CompleteOpt { type Error = anyhow::Error; - fn try_from(mut c: CmdCow) -> Result { + fn try_from(mut a: ActionCow) -> Result { Ok(Self { - name: c.take("name")?, - is_dir: c.bool("is_dir"), - ticket: c.get("ticket").unwrap_or_default(), + name: a.take("name")?, + is_dir: a.bool("is_dir"), + ticket: a.get("ticket").unwrap_or_default(), }) } } diff --git a/yazi-widgets/src/input/parser/delete.rs b/yazi-widgets/src/input/parser/delete.rs index 09fd4f35..1b7b91b6 100644 --- a/yazi-widgets/src/input/parser/delete.rs +++ b/yazi-widgets/src/input/parser/delete.rs @@ -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 DeleteOpt { @@ -7,8 +7,8 @@ pub struct DeleteOpt { pub insert: bool, } -impl From for DeleteOpt { - fn from(c: CmdCow) -> Self { Self { cut: c.bool("cut"), insert: c.bool("insert") } } +impl From for DeleteOpt { + fn from(a: ActionCow) -> Self { Self { cut: a.bool("cut"), insert: a.bool("insert") } } } impl FromLua for DeleteOpt { diff --git a/yazi-widgets/src/input/parser/forward.rs b/yazi-widgets/src/input/parser/forward.rs index c3bc6a57..13415988 100644 --- a/yazi-widgets/src/input/parser/forward.rs +++ b/yazi-widgets/src/input/parser/forward.rs @@ -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 ForwardOpt { @@ -7,8 +7,8 @@ pub struct ForwardOpt { pub end_of_word: bool, } -impl From for ForwardOpt { - fn from(c: CmdCow) -> Self { Self { far: c.bool("far"), end_of_word: c.bool("end-of-word") } } +impl From for ForwardOpt { + fn from(a: ActionCow) -> Self { Self { far: a.bool("far"), end_of_word: a.bool("end-of-word") } } } impl FromLua for ForwardOpt { diff --git a/yazi-widgets/src/input/parser/insert.rs b/yazi-widgets/src/input/parser/insert.rs index 988157c6..a2a7c8c4 100644 --- a/yazi-widgets/src/input/parser/insert.rs +++ b/yazi-widgets/src/input/parser/insert.rs @@ -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 InsertOpt { pub append: bool, } -impl From for InsertOpt { - fn from(c: CmdCow) -> Self { Self { append: c.bool("append") } } +impl From for InsertOpt { + fn from(a: ActionCow) -> Self { Self { append: a.bool("append") } } } impl From for InsertOpt { diff --git a/yazi-widgets/src/input/parser/kill.rs b/yazi-widgets/src/input/parser/kill.rs index 51cbd962..2b955864 100644 --- a/yazi-widgets/src/input/parser/kill.rs +++ b/yazi-widgets/src/input/parser/kill.rs @@ -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 KillOpt { pub kind: SStr, } -impl From for KillOpt { - fn from(mut c: CmdCow) -> Self { Self { kind: c.take_first().unwrap_or_default() } } +impl From for KillOpt { + fn from(mut a: ActionCow) -> Self { Self { kind: a.take_first().unwrap_or_default() } } } impl FromLua for KillOpt { diff --git a/yazi-widgets/src/input/parser/move.rs b/yazi-widgets/src/input/parser/move.rs index 8870e7bc..e7914a41 100644 --- a/yazi-widgets/src/input/parser/move.rs +++ b/yazi-widgets/src/input/parser/move.rs @@ -2,7 +2,7 @@ use std::{num::ParseIntError, str::FromStr}; use anyhow::bail; use mlua::{ExternalError, FromLua, IntoLua, Lua, Value}; -use yazi_shared::{data::Data, event::CmdCow}; +use yazi_shared::{data::Data, event::ActionCow}; #[derive(Debug, Default)] pub struct MoveOpt { @@ -10,9 +10,9 @@ pub struct MoveOpt { pub in_operating: bool, } -impl From for MoveOpt { - fn from(c: CmdCow) -> Self { - Self { step: c.first().ok().unwrap_or_default(), in_operating: c.bool("in-operating") } +impl From for MoveOpt { + fn from(a: ActionCow) -> Self { + Self { step: a.first().ok().unwrap_or_default(), in_operating: a.bool("in-operating") } } } diff --git a/yazi-widgets/src/input/parser/paste.rs b/yazi-widgets/src/input/parser/paste.rs index a6e6b68c..5b429c2b 100644 --- a/yazi-widgets/src/input/parser/paste.rs +++ b/yazi-widgets/src/input/parser/paste.rs @@ -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 PasteOpt { pub before: bool, } -impl From for PasteOpt { - fn from(c: CmdCow) -> Self { Self { before: c.bool("before") } } +impl From for PasteOpt { + fn from(a: ActionCow) -> Self { Self { before: a.bool("before") } } } impl FromLua for PasteOpt {