yazi_core/tab/commands/
visual_mode.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
use std::collections::BTreeSet;

use yazi_macro::render;
use yazi_shared::event::CmdCow;

use crate::tab::{Mode, Tab};

struct Opt {
	unset: bool,
}

impl From<CmdCow> for Opt {
	fn from(c: CmdCow) -> Self { Self { unset: c.bool("unset") } }
}

impl Tab {
	#[yazi_codegen::command]
	pub fn visual_mode(&mut self, opt: Opt) {
		let idx = self.current.cursor;
		if opt.unset {
			self.mode = Mode::Unset(idx, BTreeSet::from([idx]));
		} else {
			self.mode = Mode::Select(idx, BTreeSet::from([idx]));
		};
		render!();
	}
}