mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
..
This commit is contained in:
parent
bc8bd86a22
commit
7e6471f8c7
1 changed files with 40 additions and 40 deletions
|
|
@ -23,46 +23,6 @@ pub static CONFIRM: RoCell<popup::Confirm> = RoCell::new();
|
||||||
pub static PICK: RoCell<popup::Pick> = RoCell::new();
|
pub static PICK: RoCell<popup::Pick> = RoCell::new();
|
||||||
pub static WHICH: RoCell<which::Which> = RoCell::new();
|
pub static WHICH: RoCell<which::Which> = RoCell::new();
|
||||||
|
|
||||||
fn try_init(merge: bool) -> anyhow::Result<()> {
|
|
||||||
let (yazi_toml, keymap_toml, theme_toml) = if merge {
|
|
||||||
let p = Xdg::config_dir();
|
|
||||||
(Preset::yazi(&p)?, Preset::keymap(&p)?, Preset::theme(&p)?)
|
|
||||||
} else {
|
|
||||||
use yazi_macro::config_preset as preset;
|
|
||||||
(preset!("yazi"), preset!("keymap"), preset!("theme"))
|
|
||||||
};
|
|
||||||
|
|
||||||
let keymap = <_>::from_str(&keymap_toml)?;
|
|
||||||
let log = <_>::from_str(&yazi_toml)?;
|
|
||||||
let manager = <_>::from_str(&yazi_toml)?;
|
|
||||||
let open = <_>::from_str(&yazi_toml)?;
|
|
||||||
let plugin = <_>::from_str(&yazi_toml)?;
|
|
||||||
let preview = <_>::from_str(&yazi_toml)?;
|
|
||||||
let tasks = <_>::from_str(&yazi_toml)?;
|
|
||||||
let theme = <_>::from_str(&theme_toml)?;
|
|
||||||
let input = <_>::from_str(&yazi_toml)?;
|
|
||||||
let confirm = <_>::from_str(&yazi_toml)?;
|
|
||||||
let pick = <_>::from_str(&yazi_toml)?;
|
|
||||||
let which = <_>::from_str(&yazi_toml)?;
|
|
||||||
|
|
||||||
LAYOUT.with(<_>::default);
|
|
||||||
|
|
||||||
KEYMAP.init(keymap);
|
|
||||||
LOG.init(log);
|
|
||||||
MANAGER.init(manager);
|
|
||||||
OPEN.init(open);
|
|
||||||
PLUGIN.init(plugin);
|
|
||||||
PREVIEW.init(preview);
|
|
||||||
TASKS.init(tasks);
|
|
||||||
THEME.init(theme);
|
|
||||||
INPUT.init(input);
|
|
||||||
CONFIRM.init(confirm);
|
|
||||||
PICK.init(pick);
|
|
||||||
WHICH.init(which);
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn init() -> anyhow::Result<()> {
|
pub fn init() -> anyhow::Result<()> {
|
||||||
if let Err(e) = try_init(true) {
|
if let Err(e) = try_init(true) {
|
||||||
eprintln!("{e}");
|
eprintln!("{e}");
|
||||||
|
|
@ -118,3 +78,43 @@ Please change `create_title = "Create:"` to `create_title = ["Create:", "Create
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn try_init(merge: bool) -> anyhow::Result<()> {
|
||||||
|
let (yazi_toml, keymap_toml, theme_toml) = if merge {
|
||||||
|
let p = Xdg::config_dir();
|
||||||
|
(Preset::yazi(&p)?, Preset::keymap(&p)?, Preset::theme(&p)?)
|
||||||
|
} else {
|
||||||
|
use yazi_macro::config_preset as preset;
|
||||||
|
(preset!("yazi"), preset!("keymap"), preset!("theme"))
|
||||||
|
};
|
||||||
|
|
||||||
|
let keymap = <_>::from_str(&keymap_toml)?;
|
||||||
|
let log = <_>::from_str(&yazi_toml)?;
|
||||||
|
let manager = <_>::from_str(&yazi_toml)?;
|
||||||
|
let open = <_>::from_str(&yazi_toml)?;
|
||||||
|
let plugin = <_>::from_str(&yazi_toml)?;
|
||||||
|
let preview = <_>::from_str(&yazi_toml)?;
|
||||||
|
let tasks = <_>::from_str(&yazi_toml)?;
|
||||||
|
let theme = <_>::from_str(&theme_toml)?;
|
||||||
|
let input = <_>::from_str(&yazi_toml)?;
|
||||||
|
let confirm = <_>::from_str(&yazi_toml)?;
|
||||||
|
let pick = <_>::from_str(&yazi_toml)?;
|
||||||
|
let which = <_>::from_str(&yazi_toml)?;
|
||||||
|
|
||||||
|
LAYOUT.with(<_>::default);
|
||||||
|
|
||||||
|
KEYMAP.init(keymap);
|
||||||
|
LOG.init(log);
|
||||||
|
MANAGER.init(manager);
|
||||||
|
OPEN.init(open);
|
||||||
|
PLUGIN.init(plugin);
|
||||||
|
PREVIEW.init(preview);
|
||||||
|
TASKS.init(tasks);
|
||||||
|
THEME.init(theme);
|
||||||
|
INPUT.init(input);
|
||||||
|
CONFIRM.init(confirm);
|
||||||
|
PICK.init(pick);
|
||||||
|
WHICH.init(which);
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue