mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
..
This commit is contained in:
parent
bce10de2af
commit
6c10d86383
9 changed files with 6 additions and 182 deletions
|
|
@ -1,34 +0,0 @@
|
||||||
use serde::{Deserialize, Deserializer};
|
|
||||||
|
|
||||||
use crate::MERGED_YAZI;
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
|
||||||
pub struct Headsup {
|
|
||||||
// TODO: remove this once Yazi 0.3 is released --
|
|
||||||
pub disable_exec_warn: bool,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Default for Headsup {
|
|
||||||
fn default() -> Self { toml::from_str(&MERGED_YAZI).unwrap() }
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'de> Deserialize<'de> for Headsup {
|
|
||||||
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
|
||||||
where
|
|
||||||
D: Deserializer<'de>,
|
|
||||||
{
|
|
||||||
#[derive(Deserialize)]
|
|
||||||
struct Outer {
|
|
||||||
headsup: Shadow,
|
|
||||||
}
|
|
||||||
#[derive(Deserialize)]
|
|
||||||
struct Shadow {
|
|
||||||
#[serde(default)]
|
|
||||||
disable_exec_warn: bool,
|
|
||||||
}
|
|
||||||
|
|
||||||
let outer = Outer::deserialize(deserializer)?;
|
|
||||||
|
|
||||||
Ok(Self { disable_exec_warn: outer.headsup.disable_exec_warn })
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
mod headsup;
|
|
||||||
|
|
||||||
pub use headsup::*;
|
|
||||||
|
|
@ -1,14 +1,14 @@
|
||||||
use std::{borrow::Cow, collections::VecDeque, sync::atomic::Ordering};
|
use std::{borrow::Cow, collections::VecDeque};
|
||||||
|
|
||||||
use serde::{Deserialize, Deserializer};
|
use serde::Deserialize;
|
||||||
use yazi_shared::event::Cmd;
|
use yazi_shared::event::Cmd;
|
||||||
|
|
||||||
use super::Key;
|
use super::Key;
|
||||||
use crate::DEPRECATED_EXEC;
|
|
||||||
|
|
||||||
#[derive(Debug, Default)]
|
#[derive(Debug, Default, Deserialize)]
|
||||||
pub struct Control {
|
pub struct Control {
|
||||||
pub on: Vec<Key>,
|
pub on: Vec<Key>,
|
||||||
|
#[serde(deserialize_with = "super::run_deserialize")]
|
||||||
pub run: Vec<Cmd>,
|
pub run: Vec<Cmd>,
|
||||||
pub desc: Option<String>,
|
pub desc: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
@ -40,33 +40,3 @@ impl Control {
|
||||||
|| self.on().to_lowercase().contains(&s)
|
|| self.on().to_lowercase().contains(&s)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: remove this once Yazi 0.3 is released
|
|
||||||
impl<'de> Deserialize<'de> for Control {
|
|
||||||
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
|
||||||
where
|
|
||||||
D: Deserializer<'de>,
|
|
||||||
{
|
|
||||||
#[derive(Deserialize)]
|
|
||||||
pub struct Shadow {
|
|
||||||
pub on: Vec<Key>,
|
|
||||||
pub run: Option<VecCmd>,
|
|
||||||
pub exec: Option<VecCmd>,
|
|
||||||
pub desc: Option<String>,
|
|
||||||
}
|
|
||||||
|
|
||||||
let shadow = Shadow::deserialize(deserializer)?;
|
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
|
||||||
struct VecCmd(#[serde(deserialize_with = "super::run_deserialize")] Vec<Cmd>);
|
|
||||||
|
|
||||||
if shadow.exec.is_some() {
|
|
||||||
DEPRECATED_EXEC.store(true, Ordering::Relaxed);
|
|
||||||
}
|
|
||||||
let Some(run) = shadow.run.or(shadow.exec) else {
|
|
||||||
return Err(serde::de::Error::custom("missing field `run` within `[keymap]`"));
|
|
||||||
};
|
|
||||||
|
|
||||||
Ok(Self { on: shadow.on, run: run.0, desc: shadow.desc })
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
use yazi_shared::{RoCell, Xdg};
|
use yazi_shared::{RoCell, Xdg};
|
||||||
|
|
||||||
pub mod headsup;
|
|
||||||
pub mod keymap;
|
pub mod keymap;
|
||||||
mod layout;
|
mod layout;
|
||||||
mod log;
|
mod log;
|
||||||
|
|
@ -24,17 +23,12 @@ pub(crate) use pattern::*;
|
||||||
pub(crate) use preset::*;
|
pub(crate) use preset::*;
|
||||||
pub use priority::*;
|
pub use priority::*;
|
||||||
|
|
||||||
// TODO: remove this once Yazi 0.3 is released --
|
|
||||||
pub static DEPRECATED_EXEC: std::sync::atomic::AtomicBool =
|
|
||||||
std::sync::atomic::AtomicBool::new(false);
|
|
||||||
|
|
||||||
static MERGED_YAZI: RoCell<String> = RoCell::new();
|
static MERGED_YAZI: RoCell<String> = RoCell::new();
|
||||||
static MERGED_KEYMAP: RoCell<String> = RoCell::new();
|
static MERGED_KEYMAP: RoCell<String> = RoCell::new();
|
||||||
static MERGED_THEME: RoCell<String> = RoCell::new();
|
static MERGED_THEME: RoCell<String> = RoCell::new();
|
||||||
|
|
||||||
pub static LAYOUT: RoCell<arc_swap::ArcSwap<Layout>> = RoCell::new();
|
pub static LAYOUT: RoCell<arc_swap::ArcSwap<Layout>> = RoCell::new();
|
||||||
|
|
||||||
pub static HEADSUP: RoCell<headsup::Headsup> = RoCell::new();
|
|
||||||
pub static KEYMAP: RoCell<keymap::Keymap> = RoCell::new();
|
pub static KEYMAP: RoCell<keymap::Keymap> = RoCell::new();
|
||||||
pub static LOG: RoCell<log::Log> = RoCell::new();
|
pub static LOG: RoCell<log::Log> = RoCell::new();
|
||||||
pub static MANAGER: RoCell<manager::Manager> = RoCell::new();
|
pub static MANAGER: RoCell<manager::Manager> = RoCell::new();
|
||||||
|
|
@ -55,7 +49,6 @@ pub fn init() -> anyhow::Result<()> {
|
||||||
|
|
||||||
LAYOUT.with(Default::default);
|
LAYOUT.with(Default::default);
|
||||||
|
|
||||||
HEADSUP.with(Default::default);
|
|
||||||
KEYMAP.with(Default::default);
|
KEYMAP.with(Default::default);
|
||||||
LOG.with(Default::default);
|
LOG.with(Default::default);
|
||||||
MANAGER.with(Default::default);
|
MANAGER.with(Default::default);
|
||||||
|
|
@ -68,18 +61,5 @@ pub fn init() -> anyhow::Result<()> {
|
||||||
SELECT.with(Default::default);
|
SELECT.with(Default::default);
|
||||||
WHICH.with(Default::default);
|
WHICH.with(Default::default);
|
||||||
|
|
||||||
// TODO: remove this once Yazi 0.3 is released --
|
|
||||||
if !HEADSUP.disable_exec_warn && DEPRECATED_EXEC.load(std::sync::atomic::Ordering::Relaxed) {
|
|
||||||
eprintln!(
|
|
||||||
r#"
|
|
||||||
WARNING: `exec` will be deprecated in the next major version v0.3 and replaced by `run`.
|
|
||||||
|
|
||||||
Please replace all `exec = ...` with `run = ...`, in your `yazi.toml` and `keymap.toml`.
|
|
||||||
|
|
||||||
---
|
|
||||||
Add `disable_exec_warn = true` to your `yazi.toml` under `[headsup]` to suppress this warning.
|
|
||||||
"#
|
|
||||||
);
|
|
||||||
}
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,5 @@
|
||||||
use std::sync::atomic::Ordering;
|
|
||||||
|
|
||||||
use serde::{Deserialize, Deserializer};
|
use serde::{Deserialize, Deserializer};
|
||||||
|
|
||||||
use crate::DEPRECATED_EXEC;
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
pub struct Opener {
|
pub struct Opener {
|
||||||
pub run: String,
|
pub run: String,
|
||||||
|
|
@ -36,9 +32,7 @@ impl<'de> Deserialize<'de> for Opener {
|
||||||
{
|
{
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
pub struct Shadow {
|
pub struct Shadow {
|
||||||
run: Option<String>,
|
run: String,
|
||||||
// TODO: remove this once Yazi 0.3 is released --
|
|
||||||
exec: Option<String>,
|
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
block: bool,
|
block: bool,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
|
|
@ -50,13 +44,7 @@ impl<'de> Deserialize<'de> for Opener {
|
||||||
|
|
||||||
let shadow = Shadow::deserialize(deserializer)?;
|
let shadow = Shadow::deserialize(deserializer)?;
|
||||||
|
|
||||||
// TODO: remove this once Yazi 0.3 is released --
|
let run = shadow.run;
|
||||||
if shadow.exec.is_some() {
|
|
||||||
DEPRECATED_EXEC.store(true, Ordering::Relaxed);
|
|
||||||
}
|
|
||||||
let run = shadow.run.or(shadow.exec).unwrap_or_default();
|
|
||||||
// TODO: -- remove this once Yazi 0.3 is released
|
|
||||||
|
|
||||||
if run.is_empty() {
|
if run.is_empty() {
|
||||||
return Err(serde::de::Error::custom("`run` cannot be empty"));
|
return Err(serde::de::Error::custom("`run` cannot be empty"));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,55 +0,0 @@
|
||||||
use std::time::Duration;
|
|
||||||
|
|
||||||
use yazi_proxy::{options::{NotifyLevel, NotifyOpt}, AppProxy};
|
|
||||||
use yazi_shared::{emit, event::Cmd, Layer};
|
|
||||||
|
|
||||||
use crate::tab::Tab;
|
|
||||||
|
|
||||||
pub struct Opt {
|
|
||||||
type_: OptType,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(PartialEq, Eq)]
|
|
||||||
pub enum OptType {
|
|
||||||
None,
|
|
||||||
Fzf,
|
|
||||||
Zoxide,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<Cmd> for Opt {
|
|
||||||
fn from(mut c: Cmd) -> Self {
|
|
||||||
Self {
|
|
||||||
type_: match c.take_first_str().as_deref() {
|
|
||||||
Some("fzf") => OptType::Fzf,
|
|
||||||
Some("zoxide") => OptType::Zoxide,
|
|
||||||
_ => OptType::None,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Tab {
|
|
||||||
// TODO: Remove this once Yazi v0.2.7 is released
|
|
||||||
pub fn jump(&self, opt: impl Into<Opt>) {
|
|
||||||
AppProxy::notify(NotifyOpt {
|
|
||||||
title: "Jump".to_owned(),
|
|
||||||
content: r#"The `jump` command has been deprecated in Yazi v0.2.5.
|
|
||||||
Please replace `jump fzf` with `plugin fzf`, and `jump zoxide` with `plugin zoxide`, in your `keymap.toml`.
|
|
||||||
|
|
||||||
See https://github.com/sxyazi/yazi/issues/865 for more details."#.to_owned(),
|
|
||||||
level: NotifyLevel::Warn,
|
|
||||||
timeout: Duration::from_secs(15),
|
|
||||||
});
|
|
||||||
|
|
||||||
let opt = opt.into() as Opt;
|
|
||||||
if opt.type_ == OptType::None {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if opt.type_ == OptType::Fzf {
|
|
||||||
emit!(Call(Cmd::args("plugin", vec!["fzf".to_owned()]), Layer::App));
|
|
||||||
} else {
|
|
||||||
emit!(Call(Cmd::args("plugin", vec!["zoxide".to_owned()]), Layer::App));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -8,7 +8,6 @@ mod filter;
|
||||||
mod find;
|
mod find;
|
||||||
mod forward;
|
mod forward;
|
||||||
mod hidden;
|
mod hidden;
|
||||||
mod jump;
|
|
||||||
mod leave;
|
mod leave;
|
||||||
mod linemode;
|
mod linemode;
|
||||||
mod preview;
|
mod preview;
|
||||||
|
|
|
||||||
|
|
@ -108,7 +108,6 @@ impl<'a> Executor<'a> {
|
||||||
on!(ACTIVE, hidden);
|
on!(ACTIVE, hidden);
|
||||||
on!(ACTIVE, linemode);
|
on!(ACTIVE, linemode);
|
||||||
on!(ACTIVE, search);
|
on!(ACTIVE, search);
|
||||||
on!(ACTIVE, jump);
|
|
||||||
|
|
||||||
// Filter
|
// Filter
|
||||||
on!(ACTIVE, filter);
|
on!(ACTIVE, filter);
|
||||||
|
|
|
||||||
|
|
@ -56,26 +56,6 @@ function Header:tabs()
|
||||||
return ui.Line(spans)
|
return ui.Line(spans)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- TODO: remove this function after v0.2.5 release
|
|
||||||
function Header:layout(area)
|
|
||||||
if not ya.deprecated_header_layout then
|
|
||||||
ya.deprecated_header_layout = true
|
|
||||||
ya.notify {
|
|
||||||
title = "Deprecated API",
|
|
||||||
content = "`Header:layout()` is deprecated, please apply the latest `Header:render()` in your `init.lua`",
|
|
||||||
timeout = 5,
|
|
||||||
level = "warn",
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
self.area = area
|
|
||||||
|
|
||||||
return ui.Layout()
|
|
||||||
:direction(ui.Layout.HORIZONTAL)
|
|
||||||
:constraints({ ui.Constraint.Percentage(50), ui.Constraint.Percentage(50) })
|
|
||||||
:split(area)
|
|
||||||
end
|
|
||||||
|
|
||||||
function Header:render(area)
|
function Header:render(area)
|
||||||
self.area = area
|
self.area = area
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue