mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
WIP: remove cursor_at
This commit is contained in:
parent
3879e228e9
commit
9bd7b52697
4 changed files with 16 additions and 16 deletions
|
|
@ -5,11 +5,11 @@ use crate::{INPUT, SELECT};
|
||||||
pub struct InputCfg {
|
pub struct InputCfg {
|
||||||
pub title: String,
|
pub title: String,
|
||||||
pub value: String,
|
pub value: String,
|
||||||
|
pub cursor: Option<usize>,
|
||||||
pub position: Position,
|
pub position: Position,
|
||||||
pub realtime: bool,
|
pub realtime: bool,
|
||||||
pub completion: bool,
|
pub completion: bool,
|
||||||
pub highlight: bool,
|
pub highlight: bool,
|
||||||
pub cursor_at: Option<usize>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
|
|
@ -133,8 +133,8 @@ impl InputCfg {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn with_cursor_at(mut self, cursor_at: Option<usize>) -> Self {
|
pub fn with_cursor(mut self, cursor: usize) -> Self {
|
||||||
self.cursor_at = cursor_at;
|
self.cursor = Some(cursor);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,13 @@ impl Input {
|
||||||
self.highlight = opt.cfg.highlight;
|
self.highlight = opt.cfg.highlight;
|
||||||
|
|
||||||
// Reset snaps
|
// Reset snaps
|
||||||
self.snaps.reset(opt.cfg.value, self.limit(), opt.cfg.cursor_at);
|
self.snaps.reset(opt.cfg.value, self.limit());
|
||||||
|
|
||||||
|
// Set cursor after reset
|
||||||
|
if let Some(cursor) = opt.cfg.cursor {
|
||||||
|
self.snaps.current_mut().cursor = cursor;
|
||||||
|
}
|
||||||
|
|
||||||
render!();
|
render!();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,15 +11,11 @@ pub(super) struct InputSnaps {
|
||||||
|
|
||||||
impl InputSnaps {
|
impl InputSnaps {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub(super) fn reset(&mut self, value: String, limit: usize, cursor_at: Option<usize>) {
|
pub(super) fn reset(&mut self, value: String, limit: usize) {
|
||||||
self.idx = 0;
|
self.idx = 0;
|
||||||
self.versions.clear();
|
self.versions.clear();
|
||||||
self.versions.push(InputSnap::new(value, limit));
|
self.versions.push(InputSnap::new(value, limit));
|
||||||
self.current = self.versions[0].clone();
|
self.current = self.versions[0].clone();
|
||||||
|
|
||||||
if let Some(cursor) = cursor_at {
|
|
||||||
self.current.cursor = cursor;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) fn tag(&mut self, limit: usize) -> bool {
|
pub(super) fn tag(&mut self, limit: usize) -> bool {
|
||||||
|
|
|
||||||
|
|
@ -60,9 +60,7 @@ impl Manager {
|
||||||
(opt.replace.then(|| "").unwrap_or(&full_name).into(), None)
|
(opt.replace.then(|| "").unwrap_or(&full_name).into(), None)
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut result =
|
let mut result = Input::_show(InputCfg::rename().with_value(initial_value));
|
||||||
Input::_show(InputCfg::rename().with_value(initial_value).with_cursor_at(cursor_start));
|
|
||||||
|
|
||||||
let Some(Ok(name)) = result.recv().await else {
|
let Some(Ok(name)) = result.recv().await else {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue