mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
refactor!: rename the term select to toggle to reserve select for future use
This commit is contained in:
parent
13e307eab2
commit
982546cc4d
33 changed files with 131 additions and 129 deletions
|
|
@ -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).
|
||||
|
||||
<div align="center">
|
||||
<img src="assets/logo.png" alt="Yazi logo" width="20%">
|
||||
</div>
|
||||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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 = "<Space>", 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 = "<C-a>", run = "select_all --state=true", desc = "Select all files" },
|
||||
{ on = "<C-r>", run = "select_all --state=none", desc = "Inverse selection of all files" },
|
||||
# Toggle
|
||||
{ on = "<Space>", run = [ "toggle", "arrow 1" ], desc = "Toggle the current selection state" },
|
||||
{ on = "<C-a>", run = "toggle_all on", desc = "Select all files" },
|
||||
{ on = "<C-r>", 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 = "<F1>", run = "help", desc = "Open help" },
|
||||
]
|
||||
|
||||
[select]
|
||||
[pick]
|
||||
|
||||
keymap = [
|
||||
{ on = "<Esc>", run = "close", desc = "Cancel selection" },
|
||||
{ on = "<C-[>", run = "close", desc = "Cancel selection" },
|
||||
{ on = "<C-c>", run = "close", desc = "Cancel selection" },
|
||||
{ on = "<Enter>", run = "close --submit", desc = "Submit the selection" },
|
||||
{ on = "<Esc>", run = "close", desc = "Cancel pick" },
|
||||
{ on = "<C-[>", run = "close", desc = "Cancel pick" },
|
||||
{ on = "<C-c>", run = "close", desc = "Cancel pick" },
|
||||
{ on = "<Enter>", 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" },
|
||||
|
|
|
|||
|
|
@ -77,9 +77,9 @@ permissions_s = { fg = "darkgray" }
|
|||
# : }}}
|
||||
|
||||
|
||||
# : Select {{{
|
||||
# : Pick {{{
|
||||
|
||||
[select]
|
||||
[pick]
|
||||
border = { fg = "blue" }
|
||||
active = { fg = "magenta", bold = true }
|
||||
inactive = {}
|
||||
|
|
|
|||
|
|
@ -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 ]
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ use crate::Preset;
|
|||
pub struct Keymap {
|
||||
pub manager: Vec<Chord>,
|
||||
pub tasks: Vec<Chord>,
|
||||
pub select: Vec<Chord>,
|
||||
pub pick: Vec<Chord>,
|
||||
pub input: Vec<Chord>,
|
||||
pub confirm: Vec<Chord>,
|
||||
pub help: Vec<Chord>,
|
||||
|
|
@ -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]
|
||||
|
|
|
|||
|
|
@ -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<tasks::Tasks> = RoCell::new();
|
|||
pub static THEME: RoCell<theme::Theme> = RoCell::new();
|
||||
pub static INPUT: RoCell<popup::Input> = RoCell::new();
|
||||
pub static CONFIRM: RoCell<popup::Confirm> = RoCell::new();
|
||||
pub static SELECT: RoCell<popup::Select> = RoCell::new();
|
||||
pub static PICK: RoCell<popup::Pick> = RoCell::new();
|
||||
pub static WHICH: RoCell<which::Which> = 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
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
yazi_macro::mod_flat!(confirm, input, offset, options, origin, position, select);
|
||||
yazi_macro::mod_flat!(confirm, input, offset, options, origin, pick, position);
|
||||
|
|
|
|||
|
|
@ -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<String>,
|
||||
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<String>) -> 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 }),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<Self, Self::Err> {
|
||||
#[derive(Deserialize)]
|
||||
struct Outer {
|
||||
select: Select,
|
||||
pick: Pick,
|
||||
}
|
||||
|
||||
Ok(toml::from_str::<Outer>(s)?.select)
|
||||
Ok(toml::from_str::<Outer>(s)?.pick)
|
||||
}
|
||||
}
|
||||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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),
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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<Cmd> 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()) }
|
||||
|
|
@ -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<bool> 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() {
|
||||
|
|
@ -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<anyhow::Result<usize>>,
|
||||
}
|
||||
|
||||
|
|
@ -18,7 +18,7 @@ impl TryFrom<Cmd> for Opt {
|
|||
}
|
||||
}
|
||||
|
||||
impl Select {
|
||||
impl Pick {
|
||||
pub fn show(&mut self, opt: impl TryInto<Opt>) {
|
||||
let Ok(opt) = opt.try_into() else {
|
||||
return;
|
||||
|
|
@ -1,3 +1,3 @@
|
|||
yazi_macro::mod_pub!(commands);
|
||||
|
||||
yazi_macro::mod_flat!(select);
|
||||
yazi_macro::mod_flat!(pick);
|
||||
|
|
@ -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<String>,
|
||||
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() }
|
||||
|
||||
|
|
@ -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
|
||||
);
|
||||
|
|
|
|||
|
|
@ -15,9 +15,9 @@ impl<'a> From<Cmd> 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<Cmd> 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.",
|
||||
);
|
||||
}
|
||||
|
|
@ -11,9 +11,9 @@ struct Opt {
|
|||
impl From<Cmd> 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<Option<bool>> 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.",
|
||||
);
|
||||
}
|
||||
|
|
@ -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(),
|
||||
|
|
|
|||
|
|
@ -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),
|
||||
_ => {}
|
||||
|
|
|
|||
|
|
@ -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<()> {
|
||||
|
|
|
|||
1
yazi-fm/src/pick/mod.rs
Normal file
1
yazi-fm/src/pick/mod.rs
Normal file
|
|
@ -0,0 +1 @@
|
|||
yazi_macro::mod_flat!(pick);
|
||||
|
|
@ -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);
|
||||
}
|
||||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -1 +0,0 @@
|
|||
yazi_macro::mod_flat!(select);
|
||||
|
|
@ -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(); }
|
||||
|
|
|
|||
|
|
@ -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<usize> {
|
||||
pub async fn show(cfg: PickCfg) -> anyhow::Result<usize> {
|
||||
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?
|
||||
}
|
||||
}
|
||||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue