diff --git a/yazi-adapter/src/brand.rs b/yazi-adapter/src/brand.rs index cbf82cbd..c9cebc75 100644 --- a/yazi-adapter/src/brand.rs +++ b/yazi-adapter/src/brand.rs @@ -53,6 +53,7 @@ impl Brand { ("WEZTERM_EXECUTABLE", B::WezTerm), ("GHOSTTY_RESOURCES_DIR", B::Ghostty), ("WT_Session", B::Microsoft), + ("WARP_HONOR_PS1", B::Warp), ("VSCODE_INJECTION", B::VSCode), ("TABBY_CONFIG_DIRECTORY", B::Tabby), ]; diff --git a/yazi-config/src/popup/options.rs b/yazi-config/src/popup/options.rs index 2663cabc..b27d0c65 100644 --- a/yazi-config/src/popup/options.rs +++ b/yazi-config/src/popup/options.rs @@ -9,10 +9,10 @@ pub struct InputCfg { pub title: String, pub value: String, pub cursor: Option, + pub obscure: bool, pub position: Position, pub realtime: bool, pub completion: bool, - pub highlight: bool, } #[derive(Default)] @@ -86,7 +86,6 @@ impl InputCfg { Self { title: YAZI.input.shell_title[block as usize].to_owned(), position: Position::new(YAZI.input.shell_origin, YAZI.input.shell_offset), - highlight: true, ..Default::default() } } diff --git a/yazi-core/src/input/commands/show.rs b/yazi-core/src/input/commands/show.rs index d17ef3e5..13a4b55c 100644 --- a/yazi-core/src/input/commands/show.rs +++ b/yazi-core/src/input/commands/show.rs @@ -32,9 +32,6 @@ impl Input { self.tx = Some(opt.tx.clone()); let ticket = self.ticket.clone(); - // Shell - self.highlight = opt.cfg.highlight; - // Reset input let cb: InputCallback = Box::new(move |before, after| { if opt.cfg.realtime { @@ -46,6 +43,7 @@ impl Input { self.inner = yazi_widgets::input::Input::new( opt.cfg.value, opt.cfg.position.offset.width.saturating_sub(YAZI.input.border()) as usize, + opt.cfg.obscure, cb, ); diff --git a/yazi-core/src/input/input.rs b/yazi-core/src/input/input.rs index 879a0463..b68b0e0d 100644 --- a/yazi-core/src/input/input.rs +++ b/yazi-core/src/input/input.rs @@ -15,9 +15,6 @@ pub struct Input { // Typing pub(super) tx: Option>>, pub(super) ticket: Rc, - - // Shell - pub highlight: bool, } impl Deref for Input { diff --git a/yazi-core/src/mgr/mgr.rs b/yazi-core/src/mgr/mgr.rs index 7771fc2b..6a7a06cd 100644 --- a/yazi-core/src/mgr/mgr.rs +++ b/yazi-core/src/mgr/mgr.rs @@ -2,7 +2,7 @@ use ratatui::layout::Rect; use yazi_adapter::Dimension; use yazi_config::popup::{Origin, Position}; use yazi_fs::File; -use yazi_shared::{Id, url::Url}; +use yazi_shared::url::Url; use super::{Mimetype, Tabs, Watcher, Yanked}; use crate::tab::{Folder, Tab}; @@ -47,26 +47,12 @@ impl Mgr { #[inline] pub fn active_mut(&mut self) -> &mut Tab { self.tabs.active_mut() } - #[inline] - pub fn active_or(&self, id: Option) -> &Tab { self.tabs.active_or(id) } - - #[inline] - pub fn active_or_mut(&mut self, id: Option) -> &mut Tab { self.tabs.active_or_mut(id) } - #[inline] pub fn current(&self) -> &Folder { &self.active().current } #[inline] pub fn current_mut(&mut self) -> &mut Folder { &mut self.active_mut().current } - #[inline] - pub fn current_or(&self, id: Option) -> &Folder { &self.active_or(id).current } - - #[inline] - pub fn current_or_mut(&mut self, id: Option) -> &mut Folder { - &mut self.active_or_mut(id).current - } - #[inline] pub fn parent(&self) -> Option<&Folder> { self.active().parent.as_ref() } diff --git a/yazi-core/src/mgr/tabs.rs b/yazi-core/src/mgr/tabs.rs index 9c53e657..556a4f1d 100644 --- a/yazi-core/src/mgr/tabs.rs +++ b/yazi-core/src/mgr/tabs.rs @@ -49,20 +49,6 @@ impl Tabs { #[inline] pub(super) fn active_mut(&mut self) -> &mut Tab { &mut self.items[self.cursor] } - #[inline] - pub fn active_or(&self, id: Option) -> &Tab { - id.and_then(|id| self.iter().find(|&t| t.id == id)).unwrap_or(self.active()) - } - - #[inline] - pub(super) fn active_or_mut(&mut self, id: Option) -> &mut Tab { - if let Some(i) = id.and_then(|id| self.iter().position(|t| t.id == id)) { - &mut self.items[i] - } else { - self.active_mut() - } - } - #[inline] pub fn current(&self) -> &Folder { &self.active().current } diff --git a/yazi-plugin/preset/plugins/extract.lua b/yazi-plugin/preset/plugins/extract.lua index 204079e8..e59b1994 100644 --- a/yazi-plugin/preset/plugins/extract.lua +++ b/yazi-plugin/preset/plugins/extract.lua @@ -28,6 +28,7 @@ function M:entry(job) local value, event = ya.input { title = string.format('Password for "%s":', from.name), + obscure = true, position = { "center", w = 50 }, } if event == 1 then diff --git a/yazi-plugin/src/utils/layer.rs b/yazi-plugin/src/utils/layer.rs index f33fff6c..797b5275 100644 --- a/yazi-plugin/src/utils/layer.rs +++ b/yazi-plugin/src/utils/layer.rs @@ -45,10 +45,10 @@ impl Utils { title: t.raw_get("title")?, value: t.raw_get("value").unwrap_or_default(), cursor: None, // TODO + obscure: t.raw_get("obscure").unwrap_or_default(), position: Pos::new_input(t.raw_get::("position")?)?.into(), realtime, completion: false, - highlight: false, })); if !realtime { diff --git a/yazi-widgets/src/input/input.rs b/yazi-widgets/src/input/input.rs index c70f7863..b476563e 100644 --- a/yazi-widgets/src/input/input.rs +++ b/yazi-widgets/src/input/input.rs @@ -13,12 +13,13 @@ pub type InputCallback = Box; pub struct Input { pub snaps: InputSnaps, pub limit: usize, + pub obscure: bool, pub callback: Option, } impl Input { - pub fn new(value: String, limit: usize, callback: InputCallback) -> Self { - Self { snaps: InputSnaps::new(value, limit), limit, callback: Some(callback) } + pub fn new(value: String, limit: usize, obscure: bool, callback: InputCallback) -> Self { + Self { snaps: InputSnaps::new(value, limit), limit, obscure, callback: Some(callback) } } pub(super) fn handle_op(&mut self, cursor: usize, include: bool) -> bool { @@ -75,7 +76,13 @@ impl Input { pub fn value(&self) -> &str { &self.snap().value } #[inline] - pub fn visible_value(&self) -> &str { self.snap().slice(self.snap().window(self.limit)) } + pub fn display(&self) -> Cow { + if self.obscure { + "•".repeat(self.window(self.limit).len()).into() + } else { + self.snap().slice(self.window(self.limit)).into() + } + } #[inline] pub fn mode(&self) -> InputMode { self.snap().mode } diff --git a/yazi-widgets/src/input/snap.rs b/yazi-widgets/src/input/snap.rs index 11d39ba9..c1ee4c2b 100644 --- a/yazi-widgets/src/input/snap.rs +++ b/yazi-widgets/src/input/snap.rs @@ -66,7 +66,6 @@ impl InputSnap { Self::find_window(self.value.chars(), self.offset, limit) } - #[inline] pub(super) fn find_window(it: T, offset: usize, limit: usize) -> Range where T: Iterator, diff --git a/yazi-widgets/src/input/widget.rs b/yazi-widgets/src/input/widget.rs index 43df8740..fee55ac1 100644 --- a/yazi-widgets/src/input/widget.rs +++ b/yazi-widgets/src/input/widget.rs @@ -12,7 +12,7 @@ impl Widget for &Input { { yazi_plugin::elements::Clear::default().render(area, buf); - Line::styled(self.visible_value(), THEME.input.value).render(area, buf); + Line::styled(self.display(), THEME.input.value).render(area, buf); if let Some(Range { start, end }) = self.selected() { let s = start.min(area.width);