mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
..
This commit is contained in:
parent
75dc1ec8a3
commit
437757f4d6
4 changed files with 88 additions and 22 deletions
|
|
@ -78,7 +78,6 @@ preload = []
|
||||||
cd_title = "Change directory:"
|
cd_title = "Change directory:"
|
||||||
cd_origin = "top-center"
|
cd_origin = "top-center"
|
||||||
cd_offset = [ 0, 2, 50, 3 ]
|
cd_offset = [ 0, 2, 50, 3 ]
|
||||||
cd_completion = 1
|
|
||||||
|
|
||||||
# create
|
# create
|
||||||
create_title = "Create:"
|
create_title = "Create:"
|
||||||
|
|
@ -101,10 +100,9 @@ delete_origin = "top-center"
|
||||||
delete_offset = [ 0, 2, 50, 3 ]
|
delete_offset = [ 0, 2, 50, 3 ]
|
||||||
|
|
||||||
# find
|
# find
|
||||||
find_title = [ "Find previous:", "Find next:" ]
|
find_title = [ "Find next:", "Find previous:" ]
|
||||||
find_origin = "top-center"
|
find_origin = "top-center"
|
||||||
find_offset = [ 0, 2, 50, 3 ]
|
find_offset = [ 0, 2, 50, 3 ]
|
||||||
find_realtime = true
|
|
||||||
|
|
||||||
# search
|
# search
|
||||||
search_title = "Search:"
|
search_title = "Search:"
|
||||||
|
|
@ -115,7 +113,6 @@ search_offset = [ 0, 2, 50, 3 ]
|
||||||
shell_title = [ "Shell:", "Shell (block):" ]
|
shell_title = [ "Shell:", "Shell (block):" ]
|
||||||
shell_origin = "top-center"
|
shell_origin = "top-center"
|
||||||
shell_offset = [ 0, 2, 50, 3 ]
|
shell_offset = [ 0, 2, 50, 3 ]
|
||||||
shell_highlight = true
|
|
||||||
|
|
||||||
# overwrite
|
# overwrite
|
||||||
overwrite_title = "Overwrite an existing file? (y/N)"
|
overwrite_title = "Overwrite an existing file? (y/N)"
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,11 @@ pub struct Input {
|
||||||
pub shell_title: [String; 2],
|
pub shell_title: [String; 2],
|
||||||
pub shell_origin: Origin,
|
pub shell_origin: Origin,
|
||||||
pub shell_offset: Offset,
|
pub shell_offset: Offset,
|
||||||
|
|
||||||
|
// overwrite
|
||||||
|
pub overwrite_title: String,
|
||||||
|
pub overwrite_origin: Origin,
|
||||||
|
pub overwrite_offset: Offset,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for Input {
|
impl Default for Input {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
use super::Position;
|
use super::Position;
|
||||||
|
use crate::INPUT;
|
||||||
|
|
||||||
|
#[derive(Default)]
|
||||||
pub struct InputOpt {
|
pub struct InputOpt {
|
||||||
pub title: String,
|
pub title: String,
|
||||||
pub value: String,
|
pub value: String,
|
||||||
|
|
@ -9,6 +11,7 @@ pub struct InputOpt {
|
||||||
pub highlight: bool,
|
pub highlight: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Default)]
|
||||||
pub struct SelectOpt {
|
pub struct SelectOpt {
|
||||||
pub title: String,
|
pub title: String,
|
||||||
pub items: Vec<String>,
|
pub items: Vec<String>,
|
||||||
|
|
@ -17,32 +20,90 @@ pub struct SelectOpt {
|
||||||
|
|
||||||
impl InputOpt {
|
impl InputOpt {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn cd() -> Self { todo!() }
|
pub fn cd() -> Self {
|
||||||
|
Self {
|
||||||
|
title: INPUT.cd_title.to_owned(),
|
||||||
|
position: Position::new(INPUT.cd_origin, INPUT.cd_offset),
|
||||||
|
completion: true,
|
||||||
|
..Default::default()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn create() -> Self { todo!() }
|
pub fn create() -> Self {
|
||||||
|
Self {
|
||||||
|
title: INPUT.create_title.to_owned(),
|
||||||
|
position: Position::new(INPUT.create_origin, INPUT.create_offset),
|
||||||
|
..Default::default()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn rename() -> Self { todo!() }
|
pub fn rename() -> Self {
|
||||||
|
Self {
|
||||||
|
title: INPUT.rename_title.to_owned(),
|
||||||
|
position: Position::new(INPUT.rename_origin, INPUT.rename_offset),
|
||||||
|
..Default::default()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn trash(n: usize) -> Self { todo!() }
|
pub fn trash(n: usize) -> Self {
|
||||||
|
let title = INPUT.trash_title.replace("{n}", &n.to_string());
|
||||||
|
Self {
|
||||||
|
title: title.replace("{s}", if n > 1 { "s" } else { "" }),
|
||||||
|
position: Position::new(INPUT.trash_origin, INPUT.trash_offset),
|
||||||
|
..Default::default()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn delete(n: usize) -> Self { todo!() }
|
pub fn delete(n: usize) -> Self {
|
||||||
|
let title = INPUT.delete_title.replace("{n}", &n.to_string());
|
||||||
|
Self {
|
||||||
|
title: title.replace("{s}", if n > 1 { "s" } else { "" }),
|
||||||
|
position: Position::new(INPUT.delete_origin, INPUT.delete_offset),
|
||||||
|
..Default::default()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn find(prev: bool) -> Self { todo!() }
|
pub fn find(prev: bool) -> Self {
|
||||||
|
Self {
|
||||||
|
title: INPUT.find_title[prev as usize].to_owned(),
|
||||||
|
position: Position::new(INPUT.find_origin, INPUT.find_offset),
|
||||||
|
realtime: true,
|
||||||
|
..Default::default()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn search() -> Self { todo!() }
|
pub fn search() -> Self {
|
||||||
|
Self {
|
||||||
|
title: INPUT.search_title.to_owned(),
|
||||||
|
position: Position::new(INPUT.search_origin, INPUT.search_offset),
|
||||||
|
..Default::default()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
pub fn shell(block: bool) -> Self {
|
||||||
pub fn shell(block: bool) -> Self { todo!() }
|
Self {
|
||||||
|
title: INPUT.shell_title[block as usize].to_owned(),
|
||||||
|
position: Position::new(INPUT.shell_origin, INPUT.shell_offset),
|
||||||
|
highlight: true,
|
||||||
|
..Default::default()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn overwrite() -> Self { todo!() }
|
pub fn overwrite() -> Self {
|
||||||
|
Self {
|
||||||
|
title: INPUT.overwrite_title.to_owned(),
|
||||||
|
position: Position::new(INPUT.overwrite_origin, INPUT.overwrite_offset),
|
||||||
|
..Default::default()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn with_value(mut self, value: impl Into<String>) -> Self {
|
pub fn with_value(mut self, value: impl Into<String>) -> Self {
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,9 @@ pub struct Position {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Position {
|
impl Position {
|
||||||
|
#[inline]
|
||||||
|
pub fn new(origin: Origin, offset: Offset) -> Self { Self { origin, offset } }
|
||||||
|
|
||||||
pub fn rect(&self) -> Rect {
|
pub fn rect(&self) -> Rect {
|
||||||
let Offset { x, y, width, height } = self.offset;
|
let Offset { x, y, width, height } = self.offset;
|
||||||
let WindowSize { columns, rows, .. } = Term::size();
|
let WindowSize { columns, rows, .. } = Term::size();
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue