yazi/yazi-core/src/manager/commands/yank.rs
2024-04-22 14:18:00 +08:00

24 lines
508 B
Rust

use yazi_shared::{event::Cmd, render};
use crate::manager::{Manager, Yanked};
pub struct Opt {
cut: bool,
}
impl From<Cmd> for Opt {
fn from(c: Cmd) -> Self { Self { cut: c.bool("cut") } }
}
impl Manager {
pub fn yank(&mut self, opt: impl Into<Opt>) {
if !self.active_mut().try_escape_visual() {
return;
}
self.yanked = Yanked::new(opt.into().cut, self.selected_or_hovered(false).cloned().collect());
render!(self.yanked.catchup_revision(true));
self.active_mut().escape_select();
}
}