refactor: move CLIPBOARD from yazi-core -> yazi-plugin

This needs to be done because we want to make it possible to use the
clipboard in lua plugins.

Before this change, the clipboard was only available in the yazi-core
crate, which depends on yazi-plugin.

The lua plugins are configured in the yazi-plugin crate, but it can't
use anything from yazi-core, because it would create a circular
dependency.
This commit is contained in:
Mika Vilpas 2024-04-30 17:16:38 +03:00
parent bdb28f7691
commit 63f78f82fb
9 changed files with 16 additions and 11 deletions

4
Cargo.lock generated
View file

@ -2764,7 +2764,6 @@ dependencies = [
"anyhow",
"base64 0.22.0",
"bitflags 2.5.0",
"clipboard-win",
"crossterm",
"futures",
"libc",
@ -2843,6 +2842,9 @@ version = "0.2.5"
dependencies = [
"ansi-to-tui",
"anyhow",
"base64 0.22.0",
"clipboard-win",
"crossterm",
"futures",
"md-5",
"mlua",

View file

@ -40,6 +40,3 @@ tracing = { version = "0.1.40", features = [ "max_level_debug", "release_max_lev
[target."cfg(unix)".dependencies]
libc = "0.2.153"
[target."cfg(windows)".dependencies]
clipboard-win = "5.3.1"

View file

@ -1,6 +1,7 @@
use yazi_plugin::CLIPBOARD;
use yazi_shared::{event::Cmd, render};
use crate::{input::{op::InputOp, Input}, CLIPBOARD};
use crate::input::{op::InputOp, Input};
pub struct Opt {
before: bool,

View file

@ -3,10 +3,10 @@ use std::ops::Range;
use tokio::sync::mpsc::UnboundedSender;
use unicode_width::UnicodeWidthStr;
use yazi_config::{popup::Position, INPUT};
use yazi_plugin::CLIPBOARD;
use yazi_shared::{render, InputError};
use super::{mode::InputMode, op::InputOp, InputSnap, InputSnaps};
use crate::CLIPBOARD;
#[derive(Default)]
pub struct Input {

View file

@ -6,7 +6,6 @@
clippy::unit_arg
)]
mod clipboard;
pub mod completion;
pub mod folder;
pub mod help;
@ -19,12 +18,9 @@ pub mod tab;
pub mod tasks;
pub mod which;
pub use clipboard::*;
pub use step::*;
pub fn init() {
CLIPBOARD.with(Default::default);
manager::WATCHED.with(Default::default);
manager::LINKED.with(Default::default);
}

View file

@ -1,8 +1,9 @@
use std::ffi::{OsStr, OsString};
use yazi_plugin::CLIPBOARD;
use yazi_shared::event::Cmd;
use crate::{tab::Tab, CLIPBOARD};
use crate::tab::Tab;
pub struct Opt {
type_: String,

View file

@ -23,6 +23,8 @@ yazi-shared = { path = "../yazi-shared", version = "0.2.5" }
# External dependencies
ansi-to-tui = "3.1.0"
anyhow = "1.0.82"
base64 = "0.22.0"
crossterm = "0.27.0"
futures = "0.3.30"
md-5 = "0.10.6"
mlua = { version = "0.9.7", features = [ "lua54", "serialize", "macros", "async" ] }
@ -43,3 +45,6 @@ tracing = { version = "0.1.40", features = [ "max_level_debug", "release_max_lev
[target."cfg(unix)".dependencies]
uzers = "0.11.3"
[target."cfg(windows)".dependencies]
clipboard-win = "5.3.1"

View file

@ -2,6 +2,7 @@
pub mod bindings;
mod cast;
pub mod clipboard;
mod config;
pub mod elements;
pub mod external;
@ -17,6 +18,7 @@ pub mod url;
pub mod utils;
pub use cast::*;
pub use clipboard::*;
pub use config::*;
pub use lua::*;
pub use opt::*;
@ -25,4 +27,5 @@ pub use runtime::*;
pub fn init() {
crate::loader::init();
crate::init_lua();
CLIPBOARD.with(Default::default);
}