mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-21 14:51:03 +00:00
32 lines
683 B
Rust
32 lines
683 B
Rust
use yazi_plugin::CLIPBOARD;
|
|
use yazi_shared::{event::Cmd, render};
|
|
|
|
use crate::input::{Input, op::InputOp};
|
|
|
|
pub struct Opt {
|
|
before: bool,
|
|
}
|
|
|
|
impl From<Cmd> for Opt {
|
|
fn from(c: Cmd) -> Self { Self { before: c.bool("before") } }
|
|
}
|
|
|
|
impl Input {
|
|
pub fn paste(&mut self, opt: impl Into<Opt>) {
|
|
if let Some(start) = self.snap().op.start() {
|
|
self.snap_mut().op = InputOp::Delete(false, false, start);
|
|
self.handle_op(self.snap().cursor, true);
|
|
}
|
|
|
|
let s = futures::executor::block_on(CLIPBOARD.get());
|
|
if s.is_empty() {
|
|
return;
|
|
}
|
|
|
|
let opt = opt.into() as Opt;
|
|
self.insert(!opt.before);
|
|
self.type_str(&s.to_string_lossy());
|
|
self.escape(());
|
|
render!();
|
|
}
|
|
}
|