From 982546cc4dd9885e09848167555651551cc03238 Mon Sep 17 00:00:00 2001 From: sxyazi Date: Sun, 13 Oct 2024 17:24:48 +0800 Subject: [PATCH] refactor!: rename the term `select` to `toggle` to reserve `select` for future use --- README.md | 6 ++- yazi-config/preset/keymap.toml | 24 +++++----- yazi-config/preset/theme.toml | 4 +- yazi-config/preset/yazi.toml | 2 +- yazi-config/src/keymap/keymap.rs | 8 ++-- yazi-config/src/lib.rs | 8 ++-- yazi-config/src/popup/mod.rs | 2 +- yazi-config/src/popup/options.rs | 15 +++---- yazi-config/src/popup/{select.rs => pick.rs} | 10 ++--- yazi-config/src/theme/theme.rs | 4 +- yazi-core/src/input/op.rs | 3 +- yazi-core/src/lib.rs | 2 +- yazi-core/src/manager/commands/open.rs | 4 +- .../src/{select => pick}/commands/arrow.rs | 4 +- .../src/{select => pick}/commands/close.rs | 4 +- .../src/{select => pick}/commands/mod.rs | 0 .../src/{select => pick}/commands/show.rs | 8 ++-- yazi-core/src/{select => pick}/mod.rs | 2 +- .../src/{select/select.rs => pick/pick.rs} | 10 ++--- yazi-core/src/tab/commands/mod.rs | 44 +++++++++---------- .../src/tab/commands/{select.rs => toggle.rs} | 10 ++--- .../commands/{select_all.rs => toggle_all.rs} | 10 ++--- yazi-fm/src/context.rs | 6 +-- yazi-fm/src/executor.rs | 14 +++--- yazi-fm/src/main.rs | 4 +- yazi-fm/src/pick/mod.rs | 1 + .../src/{select/select.rs => pick/pick.rs} | 22 +++++----- yazi-fm/src/root.rs | 6 +-- yazi-fm/src/router.rs | 4 +- yazi-fm/src/select/mod.rs | 1 - yazi-proxy/src/lib.rs | 2 +- yazi-proxy/src/{select.rs => pick.rs} | 10 ++--- yazi-shared/src/layer.rs | 6 +-- 33 files changed, 131 insertions(+), 129 deletions(-) rename yazi-config/src/popup/{select.rs => pick.rs} (75%) rename yazi-core/src/{select => pick}/commands/arrow.rs (96%) rename yazi-core/src/{select => pick}/commands/close.rs (93%) rename yazi-core/src/{select => pick}/commands/mod.rs (100%) rename yazi-core/src/{select => pick}/commands/show.rs (87%) rename yazi-core/src/{select => pick}/mod.rs (51%) rename yazi-core/src/{select/select.rs => pick/pick.rs} (79%) rename yazi-core/src/tab/commands/{select.rs => toggle.rs} (83%) rename yazi-core/src/tab/commands/{select_all.rs => toggle_all.rs} (84%) create mode 100644 yazi-fm/src/pick/mod.rs rename yazi-fm/src/{select/select.rs => pick/pick.rs} (54%) delete mode 100644 yazi-fm/src/select/mod.rs rename yazi-proxy/src/{select.rs => pick.rs} (56%) diff --git a/README.md b/README.md index 9e78a17e..5ae75e2e 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,7 @@ +## The main branch is the upcoming v0.4 development version. Please see [the `shipped` tag](https://github.com/sxyazi/yazi/tree/shipped) for the stable version of Yazi. + +For breaking changes, see [Migrating to Yazi v0.4.0](https://github.com/sxyazi/yazi/issues/1772). +
Yazi logo
@@ -16,7 +20,7 @@ Yazi (means "duck") is a terminal file manager written in Rust, based on non-blo - 📡 **Data Distribution Service**: Built on a client-server architecture (no additional server process required), integrated with a Lua-based publish-subscribe model, achieving cross-instance communication and state persistence. - 📦 **Package Manager**: Install plugins and themes with one command, keeping them up to date, or pin them to a specific version. - 🧰 Integration with ripgrep, fd, fzf, zoxide -- 💫 Vim-like input/select/confirm/which/notify component, auto-completion for cd paths +- 💫 Vim-like input/pick/confirm/which/notify component, auto-completion for cd paths - 🏷️ Multi-Tab Support, Cross-directory selection, Scrollable Preview (for videos, PDFs, archives, directories, code, etc.) - 🔄 Bulk Renaming, Visual Mode, File Chooser - 🎨 Theme System, Mouse Support, Trash Bin, Custom Layouts, CSI u diff --git a/yazi-config/preset/keymap.toml b/yazi-config/preset/keymap.toml index 9dabc302..0f59f98b 100644 --- a/yazi-config/preset/keymap.toml +++ b/yazi-config/preset/keymap.toml @@ -46,12 +46,14 @@ keymap = [ { on = "K", run = "seek -5", desc = "Seek up 5 units in the preview" }, { on = "J", run = "seek 5", desc = "Seek down 5 units in the preview" }, - # Selection - { on = "", run = [ "select --state=none", "arrow 1" ], desc = "Toggle the current selection state" }, - { on = "v", run = "visual_mode", desc = "Enter visual mode (selection mode)" }, - { on = "V", run = "visual_mode --unset", desc = "Enter visual mode (unset mode)" }, - { on = "", run = "select_all --state=true", desc = "Select all files" }, - { on = "", run = "select_all --state=none", desc = "Inverse selection of all files" }, + # Toggle + { on = "", run = [ "toggle", "arrow 1" ], desc = "Toggle the current selection state" }, + { on = "", run = "toggle_all on", desc = "Select all files" }, + { on = "", run = "toggle_all", desc = "Invert selection of all files" }, + + # Visual mode + { on = "v", run = "visual_mode", desc = "Enter visual mode (selection mode)" }, + { on = "V", run = "visual_mode --unset", desc = "Enter visual mode (unset mode)" }, # Operation { on = "o", run = "open", desc = "Open selected files" }, @@ -173,13 +175,13 @@ keymap = [ { on = "", run = "help", desc = "Open help" }, ] -[select] +[pick] keymap = [ - { on = "", run = "close", desc = "Cancel selection" }, - { on = "", run = "close", desc = "Cancel selection" }, - { on = "", run = "close", desc = "Cancel selection" }, - { on = "", run = "close --submit", desc = "Submit the selection" }, + { on = "", run = "close", desc = "Cancel pick" }, + { on = "", run = "close", desc = "Cancel pick" }, + { on = "", run = "close", desc = "Cancel pick" }, + { on = "", run = "close --submit", desc = "Submit the pick" }, { on = "k", run = "arrow -1", desc = "Move cursor up" }, { on = "j", run = "arrow 1", desc = "Move cursor down" }, diff --git a/yazi-config/preset/theme.toml b/yazi-config/preset/theme.toml index 09e65b03..a5001a2d 100644 --- a/yazi-config/preset/theme.toml +++ b/yazi-config/preset/theme.toml @@ -77,9 +77,9 @@ permissions_s = { fg = "darkgray" } # : }}} -# : Select {{{ +# : Pick {{{ -[select] +[pick] border = { fg = "blue" } active = { fg = "magenta", bold = true } inactive = {} diff --git a/yazi-config/preset/yazi.toml b/yazi-config/preset/yazi.toml index 05a60fa2..9c71da8b 100644 --- a/yazi-config/preset/yazi.toml +++ b/yazi-config/preset/yazi.toml @@ -191,7 +191,7 @@ quit_content = "The following task is still running, are you sure you want to qu quit_origin = "center" quit_offset = [ 0, 0, 50, 15 ] -[select] +[pick] open_title = "Open with:" open_origin = "hovered" open_offset = [ 0, 1, 50, 7 ] diff --git a/yazi-config/src/keymap/keymap.rs b/yazi-config/src/keymap/keymap.rs index c01851c8..2cf291ad 100644 --- a/yazi-config/src/keymap/keymap.rs +++ b/yazi-config/src/keymap/keymap.rs @@ -11,7 +11,7 @@ use crate::Preset; pub struct Keymap { pub manager: Vec, pub tasks: Vec, - pub select: Vec, + pub pick: Vec, pub input: Vec, pub confirm: Vec, pub help: Vec, @@ -25,7 +25,7 @@ impl Keymap { Layer::App => unreachable!(), Layer::Manager => &self.manager, Layer::Tasks => &self.tasks, - Layer::Select => &self.select, + Layer::Pick => &self.pick, Layer::Input => &self.input, Layer::Confirm => &self.confirm, Layer::Help => &self.help, @@ -50,7 +50,7 @@ impl<'de> Deserialize<'de> for Keymap { struct Shadow { manager: Inner, tasks: Inner, - select: Inner, + pick: Inner, input: Inner, confirm: Inner, help: Inner, @@ -81,7 +81,7 @@ impl<'de> Deserialize<'de> for Keymap { #[rustfmt::skip] tasks: mix(shadow.tasks.keymap, shadow.tasks.prepend_keymap, shadow.tasks.append_keymap), #[rustfmt::skip] - select: mix(shadow.select.keymap, shadow.select.prepend_keymap, shadow.select.append_keymap), + pick: mix(shadow.pick.keymap, shadow.pick.prepend_keymap, shadow.pick.append_keymap), #[rustfmt::skip] input: mix(shadow.input.keymap, shadow.input.prepend_keymap, shadow.input.append_keymap), #[rustfmt::skip] diff --git a/yazi-config/src/lib.rs b/yazi-config/src/lib.rs index da1efe4b..7c09c86d 100644 --- a/yazi-config/src/lib.rs +++ b/yazi-config/src/lib.rs @@ -1,8 +1,8 @@ #![allow(clippy::module_inception)] -yazi_macro::mod_pub!(keymap, log, manager, open, plugin, popup, preview, tasks, theme, which); +yazi_macro::mod_pub!(keymap log manager open plugin popup preview tasks theme which); -yazi_macro::mod_flat!(layout, pattern, preset, priority); +yazi_macro::mod_flat!(layout pattern preset priority); use std::str::FromStr; @@ -20,7 +20,7 @@ pub static TASKS: RoCell = RoCell::new(); pub static THEME: RoCell = RoCell::new(); pub static INPUT: RoCell = RoCell::new(); pub static CONFIRM: RoCell = RoCell::new(); -pub static SELECT: RoCell = RoCell::new(); +pub static PICK: RoCell = RoCell::new(); pub static WHICH: RoCell = RoCell::new(); pub fn init() -> anyhow::Result<()> { @@ -41,7 +41,7 @@ pub fn init() -> anyhow::Result<()> { THEME.init(<_>::from_str(theme_toml)?); INPUT.init(<_>::from_str(yazi_toml)?); CONFIRM.init(<_>::from_str(yazi_toml)?); - SELECT.init(<_>::from_str(yazi_toml)?); + PICK.init(<_>::from_str(yazi_toml)?); WHICH.init(<_>::from_str(yazi_toml)?); // TODO: Remove in v0.3.2 diff --git a/yazi-config/src/popup/mod.rs b/yazi-config/src/popup/mod.rs index 8adc3f49..f1611bbb 100644 --- a/yazi-config/src/popup/mod.rs +++ b/yazi-config/src/popup/mod.rs @@ -1 +1 @@ -yazi_macro::mod_flat!(confirm, input, offset, options, origin, position, select); +yazi_macro::mod_flat!(confirm, input, offset, options, origin, pick, position); diff --git a/yazi-config/src/popup/options.rs b/yazi-config/src/popup/options.rs index 6cf419d9..c97a640c 100644 --- a/yazi-config/src/popup/options.rs +++ b/yazi-config/src/popup/options.rs @@ -2,7 +2,7 @@ use ratatui::{text::Text, widgets::{Paragraph, Wrap}}; use yazi_shared::fs::Url; use super::{Offset, Origin, Position}; -use crate::{CONFIRM, INPUT, SELECT}; +use crate::{CONFIRM, INPUT, PICK}; #[derive(Default)] pub struct InputCfg { @@ -16,7 +16,7 @@ pub struct InputCfg { } #[derive(Default)] -pub struct SelectCfg { +pub struct PickCfg { pub title: String, pub items: Vec, pub position: Position, @@ -176,21 +176,18 @@ impl ConfirmCfg { } } -impl SelectCfg { +impl PickCfg { #[inline] fn max_height(len: usize) -> u16 { - SELECT.open_offset.height.min(SELECT.border().saturating_add(len as u16)) + PICK.open_offset.height.min(PICK.border().saturating_add(len as u16)) } pub fn open(items: Vec) -> Self { let max_height = Self::max_height(items.len()); Self { - title: SELECT.open_title.to_owned(), + title: PICK.open_title.to_owned(), items, - position: Position::new(SELECT.open_origin, Offset { - height: max_height, - ..SELECT.open_offset - }), + position: Position::new(PICK.open_origin, Offset { height: max_height, ..PICK.open_offset }), } } } diff --git a/yazi-config/src/popup/select.rs b/yazi-config/src/popup/pick.rs similarity index 75% rename from yazi-config/src/popup/select.rs rename to yazi-config/src/popup/pick.rs index df584df8..ea2218c3 100644 --- a/yazi-config/src/popup/select.rs +++ b/yazi-config/src/popup/pick.rs @@ -5,26 +5,26 @@ use serde::Deserialize; use super::{Offset, Origin}; #[derive(Deserialize)] -pub struct Select { +pub struct Pick { // open pub open_title: String, pub open_origin: Origin, pub open_offset: Offset, } -impl Select { +impl Pick { pub const fn border(&self) -> u16 { 2 } } -impl FromStr for Select { +impl FromStr for Pick { type Err = toml::de::Error; fn from_str(s: &str) -> Result { #[derive(Deserialize)] struct Outer { - select: Select, + pick: Pick, } - Ok(toml::from_str::(s)?.select) + Ok(toml::from_str::(s)?.pick) } } diff --git a/yazi-config/src/theme/theme.rs b/yazi-config/src/theme/theme.rs index a8d6e417..6f872bf1 100644 --- a/yazi-config/src/theme/theme.rs +++ b/yazi-config/src/theme/theme.rs @@ -12,7 +12,7 @@ pub struct Theme { pub manager: Manager, status: Status, pub input: Input, - pub select: Select, + pub pick: Pick, pub completion: Completion, pub tasks: Tasks, pub which: Which, @@ -115,7 +115,7 @@ pub struct Input { } #[derive(Deserialize, Serialize)] -pub struct Select { +pub struct Pick { pub border: Style, pub active: Style, pub inactive: Style, diff --git a/yazi-core/src/input/op.rs b/yazi-core/src/input/op.rs index 7a2fbae2..55ab0772 100644 --- a/yazi-core/src/input/op.rs +++ b/yazi-core/src/input/op.rs @@ -5,8 +5,7 @@ pub enum InputOp { #[default] None, Select(usize), - // cut, insert, start - Delete(bool, bool, usize), + Delete(bool, bool, usize), // cut, insert, start Yank(usize), } diff --git a/yazi-core/src/lib.rs b/yazi-core/src/lib.rs index 952774c5..8d7616ef 100644 --- a/yazi-core/src/lib.rs +++ b/yazi-core/src/lib.rs @@ -6,7 +6,7 @@ clippy::unit_arg )] -yazi_macro::mod_pub!(completion, confirm, help, input, manager, notify, select, tab, tasks, which); +yazi_macro::mod_pub!(completion confirm help input manager notify pick tab tasks which); pub fn init() { manager::WATCHED.with(<_>::default); diff --git a/yazi-core/src/manager/commands/open.rs b/yazi-core/src/manager/commands/open.rs index 449a15d8..630455b5 100644 --- a/yazi-core/src/manager/commands/open.rs +++ b/yazi-core/src/manager/commands/open.rs @@ -2,7 +2,7 @@ use std::{borrow::Cow, ffi::OsString}; use tracing::error; use yazi_boot::ARGS; -use yazi_config::{OPEN, popup::SelectCfg}; +use yazi_config::{OPEN, popup::PickCfg}; use yazi_fs::Folder; use yazi_macro::emit; use yazi_plugin::isolate; @@ -96,7 +96,7 @@ impl Manager { let urls = [opt.hovered].into_iter().chain(targets.into_iter().map(|(u, _)| u)).collect(); tokio::spawn(async move { - let result = yazi_proxy::SelectProxy::show(SelectCfg::open( + let result = yazi_proxy::PickProxy::show(PickCfg::open( openers.iter().map(|o| o.desc.clone()).collect(), )); if let Ok(choice) = result.await { diff --git a/yazi-core/src/select/commands/arrow.rs b/yazi-core/src/pick/commands/arrow.rs similarity index 96% rename from yazi-core/src/select/commands/arrow.rs rename to yazi-core/src/pick/commands/arrow.rs index deea6b36..e78883e8 100644 --- a/yazi-core/src/select/commands/arrow.rs +++ b/yazi-core/src/pick/commands/arrow.rs @@ -1,7 +1,7 @@ use yazi_macro::render; use yazi_shared::event::{Cmd, Data}; -use crate::select::Select; +use crate::pick::Pick; struct Opt { step: isize, @@ -11,7 +11,7 @@ impl From for Opt { fn from(c: Cmd) -> Self { Self { step: c.first().and_then(Data::as_isize).unwrap_or(0) } } } -impl Select { +impl Pick { #[yazi_codegen::command] pub fn arrow(&mut self, opt: Opt) { if opt.step > 0 { self.next(opt.step as usize) } else { self.prev(opt.step.unsigned_abs()) } diff --git a/yazi-core/src/select/commands/close.rs b/yazi-core/src/pick/commands/close.rs similarity index 93% rename from yazi-core/src/select/commands/close.rs rename to yazi-core/src/pick/commands/close.rs index 6e73fd8b..cd684345 100644 --- a/yazi-core/src/select/commands/close.rs +++ b/yazi-core/src/pick/commands/close.rs @@ -2,7 +2,7 @@ use anyhow::anyhow; use yazi_macro::render; use yazi_shared::event::Cmd; -use crate::select::Select; +use crate::pick::Pick; struct Opt { submit: bool, @@ -15,7 +15,7 @@ impl From for Opt { fn from(submit: bool) -> Self { Self { submit } } } -impl Select { +impl Pick { #[yazi_codegen::command] pub fn close(&mut self, opt: Opt) { if let Some(cb) = self.callback.take() { diff --git a/yazi-core/src/select/commands/mod.rs b/yazi-core/src/pick/commands/mod.rs similarity index 100% rename from yazi-core/src/select/commands/mod.rs rename to yazi-core/src/pick/commands/mod.rs diff --git a/yazi-core/src/select/commands/show.rs b/yazi-core/src/pick/commands/show.rs similarity index 87% rename from yazi-core/src/select/commands/show.rs rename to yazi-core/src/pick/commands/show.rs index 022fb8b3..dc24fefe 100644 --- a/yazi-core/src/select/commands/show.rs +++ b/yazi-core/src/pick/commands/show.rs @@ -1,12 +1,12 @@ use tokio::sync::oneshot; -use yazi_config::popup::SelectCfg; +use yazi_config::popup::PickCfg; use yazi_macro::render; use yazi_shared::event::Cmd; -use crate::select::Select; +use crate::pick::Pick; pub struct Opt { - cfg: SelectCfg, + cfg: PickCfg, tx: oneshot::Sender>, } @@ -18,7 +18,7 @@ impl TryFrom for Opt { } } -impl Select { +impl Pick { pub fn show(&mut self, opt: impl TryInto) { let Ok(opt) = opt.try_into() else { return; diff --git a/yazi-core/src/select/mod.rs b/yazi-core/src/pick/mod.rs similarity index 51% rename from yazi-core/src/select/mod.rs rename to yazi-core/src/pick/mod.rs index 02c53b3c..c9f4add5 100644 --- a/yazi-core/src/select/mod.rs +++ b/yazi-core/src/pick/mod.rs @@ -1,3 +1,3 @@ yazi_macro::mod_pub!(commands); -yazi_macro::mod_flat!(select); +yazi_macro::mod_flat!(pick); diff --git a/yazi-core/src/select/select.rs b/yazi-core/src/pick/pick.rs similarity index 79% rename from yazi-core/src/select/select.rs rename to yazi-core/src/pick/pick.rs index c86f27a4..dba61eb6 100644 --- a/yazi-core/src/select/select.rs +++ b/yazi-core/src/pick/pick.rs @@ -1,9 +1,9 @@ use anyhow::Result; use tokio::sync::oneshot::Sender; -use yazi_config::{SELECT, popup::Position}; +use yazi_config::{PICK, popup::Position}; #[derive(Default)] -pub struct Select { +pub struct Pick { pub(super) title: String, pub(super) items: Vec, pub position: Position, @@ -15,7 +15,7 @@ pub struct Select { pub visible: bool, } -impl Select { +impl Pick { #[inline] pub fn window(&self) -> &[String] { let end = (self.offset + self.limit()).min(self.items.len()); @@ -24,11 +24,11 @@ impl Select { #[inline] pub(super) fn limit(&self) -> usize { - self.position.offset.height.saturating_sub(SELECT.border()) as usize + self.position.offset.height.saturating_sub(PICK.border()) as usize } } -impl Select { +impl Pick { #[inline] pub fn title(&self) -> String { self.title.clone() } diff --git a/yazi-core/src/tab/commands/mod.rs b/yazi-core/src/tab/commands/mod.rs index dddf38dc..ef5f18c7 100644 --- a/yazi-core/src/tab/commands/mod.rs +++ b/yazi-core/src/tab/commands/mod.rs @@ -1,25 +1,25 @@ yazi_macro::mod_flat!( - arrow, - back, - cd, - copy, - enter, - escape, - filter, - filter_do, - find, - find_arrow, - find_do, - forward, - hidden, - leave, - linemode, - preview, - reveal, - search, - select, - select_all, - shell, - sort, + arrow + back + cd + copy + enter + escape + filter + filter_do + find + find_arrow + find_do + forward + hidden + leave + linemode + preview + reveal + search + shell + sort + toggle + toggle_all visual_mode ); diff --git a/yazi-core/src/tab/commands/select.rs b/yazi-core/src/tab/commands/toggle.rs similarity index 83% rename from yazi-core/src/tab/commands/select.rs rename to yazi-core/src/tab/commands/toggle.rs index 94fc57c2..2dfdf709 100644 --- a/yazi-core/src/tab/commands/select.rs +++ b/yazi-core/src/tab/commands/toggle.rs @@ -15,9 +15,9 @@ impl<'a> From for Opt<'a> { fn from(mut c: Cmd) -> Self { Self { url: c.take("url").and_then(Data::into_url).map(Cow::Owned), - state: match c.take_str("state").as_deref() { - Some("true") => Some(true), - Some("false") => Some(false), + state: match c.take_first_str().as_deref() { + Some("on") => Some(true), + Some("off") => Some(false), _ => None, }, } @@ -26,7 +26,7 @@ impl<'a> From for Opt<'a> { impl<'a> Tab { #[yazi_codegen::command] - pub fn select(&mut self, opt: Opt<'a>) { + pub fn toggle(&mut self, opt: Opt<'a>) { let Some(url) = opt.url.or_else(|| self.current.hovered().map(|h| Cow::Borrowed(&h.url))) else { return; @@ -40,7 +40,7 @@ impl<'a> Tab { if !b { AppProxy::notify_warn( - "Select one", + "Toggle", "This file cannot be selected, due to path nesting conflict.", ); } diff --git a/yazi-core/src/tab/commands/select_all.rs b/yazi-core/src/tab/commands/toggle_all.rs similarity index 84% rename from yazi-core/src/tab/commands/select_all.rs rename to yazi-core/src/tab/commands/toggle_all.rs index 4e568494..ebab9e97 100644 --- a/yazi-core/src/tab/commands/select_all.rs +++ b/yazi-core/src/tab/commands/toggle_all.rs @@ -11,9 +11,9 @@ struct Opt { impl From for Opt { fn from(mut c: Cmd) -> Self { Self { - state: match c.take_str("state").as_deref() { - Some("true") => Some(true), - Some("false") => Some(false), + state: match c.take_first_str().as_deref() { + Some("on") => Some(true), + Some("off") => Some(false), _ => None, }, } @@ -25,7 +25,7 @@ impl From> for Opt { impl Tab { #[yazi_codegen::command] - pub fn select_all(&mut self, opt: Opt) { + pub fn toggle_all(&mut self, opt: Opt) { let iter = self.current.files.iter().map(|f| &f.url); let (removal, addition): (Vec<_>, Vec<_>) = match opt.state { Some(true) => (vec![], iter.collect()), @@ -41,7 +41,7 @@ impl Tab { if added != addition.len() { AppProxy::notify_warn( - "Select all", + "Toggle all", "Some files cannot be selected, due to path nesting conflict.", ); } diff --git a/yazi-fm/src/context.rs b/yazi-fm/src/context.rs index c97336e2..3d46b539 100644 --- a/yazi-fm/src/context.rs +++ b/yazi-fm/src/context.rs @@ -1,10 +1,10 @@ use ratatui::layout::Rect; -use yazi_core::{completion::Completion, confirm::Confirm, help::Help, input::Input, manager::Manager, notify::Notify, select::Select, tasks::Tasks, which::Which}; +use yazi_core::{completion::Completion, confirm::Confirm, help::Help, input::Input, manager::Manager, notify::Notify, pick::Pick, tasks::Tasks, which::Which}; pub struct Ctx { pub manager: Manager, pub tasks: Tasks, - pub select: Select, + pub pick: Pick, pub input: Input, pub confirm: Confirm, pub help: Help, @@ -18,7 +18,7 @@ impl Ctx { Self { manager: Manager::make(), tasks: Tasks::serve(), - select: Default::default(), + pick: Default::default(), input: Default::default(), confirm: Default::default(), help: Default::default(), diff --git a/yazi-fm/src/executor.rs b/yazi-fm/src/executor.rs index 6b6addf7..9dbc3e73 100644 --- a/yazi-fm/src/executor.rs +++ b/yazi-fm/src/executor.rs @@ -17,7 +17,7 @@ impl<'a> Executor<'a> { Layer::App => self.app(cmd), Layer::Manager => self.manager(cmd), Layer::Tasks => self.tasks(cmd), - Layer::Select => self.select(cmd), + Layer::Pick => self.pick(cmd), Layer::Input => self.input(cmd), Layer::Confirm => self.confirm(cmd), Layer::Help => self.help(cmd), @@ -89,9 +89,9 @@ impl<'a> Executor<'a> { on!(ACTIVE, cd); on!(ACTIVE, reveal); - // Selection - on!(ACTIVE, select); - on!(ACTIVE, select_all); + // Toggle + on!(ACTIVE, toggle); + on!(ACTIVE, toggle_all); on!(ACTIVE, visual_mode); // Operation @@ -172,11 +172,11 @@ impl<'a> Executor<'a> { } } - fn select(&mut self, cmd: Cmd) { + fn pick(&mut self, cmd: Cmd) { macro_rules! on { ($name:ident) => { if cmd.name == stringify!($name) { - return self.app.cx.select.$name(cmd); + return self.app.cx.pick.$name(cmd); } }; } @@ -187,7 +187,7 @@ impl<'a> Executor<'a> { match cmd.name.as_str() { // Help - "help" => self.app.cx.help.toggle(Layer::Select), + "help" => self.app.cx.help.toggle(Layer::Pick), // Plugin "plugin" => self.app.plugin(cmd), _ => {} diff --git a/yazi-fm/src/main.rs b/yazi-fm/src/main.rs index d2a8b4ef..ac33b1c9 100644 --- a/yazi-fm/src/main.rs +++ b/yazi-fm/src/main.rs @@ -6,10 +6,10 @@ static GLOBAL: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc; yazi_macro::mod_pub!( - app, completion, components, confirm, help, input, lives, notify, select, tasks, which + app completion components confirm help input lives notify pick tasks which ); -yazi_macro::mod_flat!(context, executor, logs, panic, root, router, signals, term); +yazi_macro::mod_flat!(context executor logs panic root router signals term); #[tokio::main] async fn main() -> anyhow::Result<()> { diff --git a/yazi-fm/src/pick/mod.rs b/yazi-fm/src/pick/mod.rs new file mode 100644 index 00000000..7275cd93 --- /dev/null +++ b/yazi-fm/src/pick/mod.rs @@ -0,0 +1 @@ +yazi_macro::mod_flat!(pick); diff --git a/yazi-fm/src/select/select.rs b/yazi-fm/src/pick/pick.rs similarity index 54% rename from yazi-fm/src/select/select.rs rename to yazi-fm/src/pick/pick.rs index 2fc04a45..4cbace5f 100644 --- a/yazi-fm/src/select/select.rs +++ b/yazi-fm/src/pick/pick.rs @@ -3,29 +3,29 @@ use yazi_config::THEME; use crate::Ctx; -pub(crate) struct Select<'a> { +pub(crate) struct Pick<'a> { cx: &'a Ctx, } -impl<'a> Select<'a> { +impl<'a> Pick<'a> { pub(crate) fn new(cx: &'a Ctx) -> Self { Self { cx } } } -impl<'a> Widget for Select<'a> { +impl<'a> Widget for Pick<'a> { fn render(self, _: Rect, buf: &mut Buffer) { - let select = &self.cx.select; - let area = self.cx.manager.area(select.position); + let pick = &self.cx.pick; + let area = self.cx.manager.area(pick.position); - let items: Vec<_> = select + let items: Vec<_> = pick .window() .iter() .enumerate() .map(|(i, v)| { - if i != select.rel_cursor() { - return ListItem::new(format!(" {v}")).style(THEME.select.inactive); + if i != pick.rel_cursor() { + return ListItem::new(format!(" {v}")).style(THEME.pick.inactive); } - ListItem::new(format!(" {v}")).style(THEME.select.active) + ListItem::new(format!(" {v}")).style(THEME.pick.active) }) .collect(); @@ -33,9 +33,9 @@ impl<'a> Widget for Select<'a> { List::new(items) .block( Block::bordered() - .title(select.title()) + .title(pick.title()) .border_type(BorderType::Rounded) - .border_style(THEME.select.border), + .border_style(THEME.pick.border), ) .render(area, buf); } diff --git a/yazi-fm/src/root.rs b/yazi-fm/src/root.rs index a10f5742..60d60746 100644 --- a/yazi-fm/src/root.rs +++ b/yazi-fm/src/root.rs @@ -3,7 +3,7 @@ use ratatui::{buffer::Buffer, layout::Rect, widgets::Widget}; use tracing::error; use yazi_plugin::{LUA, elements::render_widgets}; -use super::{completion, confirm, input, select, tasks, which}; +use super::{completion, confirm, input, pick, tasks, which}; use crate::{Ctx, components, help}; pub(super) struct Root<'a> { @@ -33,8 +33,8 @@ impl<'a> Widget for Root<'a> { tasks::Layout::new(self.cx).render(area, buf); } - if self.cx.select.visible { - select::Select::new(self.cx).render(area, buf); + if self.cx.pick.visible { + pick::Pick::new(self.cx).render(area, buf); } if self.cx.input.visible { diff --git a/yazi-fm/src/router.rs b/yazi-fm/src/router.rs index dc56e9c5..1f45da53 100644 --- a/yazi-fm/src/router.rs +++ b/yazi-fm/src/router.rs @@ -34,8 +34,8 @@ impl<'a> Router<'a> { self.matches(Layer::Input, key) } else if cx.confirm.visible { self.matches(Layer::Confirm, key) - } else if cx.select.visible { - self.matches(Layer::Select, key) + } else if cx.pick.visible { + self.matches(Layer::Pick, key) } else if cx.tasks.visible { self.matches(Layer::Tasks, key) } else { diff --git a/yazi-fm/src/select/mod.rs b/yazi-fm/src/select/mod.rs deleted file mode 100644 index fae8b47f..00000000 --- a/yazi-fm/src/select/mod.rs +++ /dev/null @@ -1 +0,0 @@ -yazi_macro::mod_flat!(select); diff --git a/yazi-proxy/src/lib.rs b/yazi-proxy/src/lib.rs index 3a781ac4..5a565072 100644 --- a/yazi-proxy/src/lib.rs +++ b/yazi-proxy/src/lib.rs @@ -1,5 +1,5 @@ yazi_macro::mod_pub!(options); -yazi_macro::mod_flat!(app, completion, confirm, input, manager, select, semaphore, tab, tasks); +yazi_macro::mod_flat!(app completion confirm input manager pick semaphore tab tasks); pub fn init() { crate::init_semaphore(); } diff --git a/yazi-proxy/src/select.rs b/yazi-proxy/src/pick.rs similarity index 56% rename from yazi-proxy/src/select.rs rename to yazi-proxy/src/pick.rs index 35fbfcb5..5375898b 100644 --- a/yazi-proxy/src/select.rs +++ b/yazi-proxy/src/pick.rs @@ -1,15 +1,15 @@ use tokio::sync::oneshot; -use yazi_config::popup::SelectCfg; +use yazi_config::popup::PickCfg; use yazi_macro::emit; use yazi_shared::{Layer, event::Cmd}; -pub struct SelectProxy; +pub struct PickProxy; -impl SelectProxy { +impl PickProxy { #[inline] - pub async fn show(cfg: SelectCfg) -> anyhow::Result { + pub async fn show(cfg: PickCfg) -> anyhow::Result { let (tx, rx) = oneshot::channel(); - emit!(Call(Cmd::new("show").with_any("tx", tx).with_any("cfg", cfg), Layer::Select)); + emit!(Call(Cmd::new("show").with_any("tx", tx).with_any("cfg", cfg), Layer::Pick)); rx.await? } } diff --git a/yazi-shared/src/layer.rs b/yazi-shared/src/layer.rs index 525fc051..44df60a9 100644 --- a/yazi-shared/src/layer.rs +++ b/yazi-shared/src/layer.rs @@ -8,7 +8,7 @@ pub enum Layer { App, Manager, Tasks, - Select, + Pick, Input, Confirm, Help, @@ -22,7 +22,7 @@ impl Display for Layer { Self::App => "app", Self::Manager => "manager", Self::Tasks => "tasks", - Self::Select => "select", + Self::Pick => "pick", Self::Input => "input", Self::Confirm => "confirm", Self::Help => "help", @@ -40,7 +40,7 @@ impl FromStr for Layer { "app" => Self::App, "manager" => Self::Manager, "tasks" => Self::Tasks, - "select" => Self::Select, + "pick" => Self::Pick, "input" => Self::Input, "confirm" => Self::Confirm, "help" => Self::Help,