chore: rename Top to TopCenter, Bottom to BottomCenter

This commit is contained in:
Hanaasagi 2023-11-14 10:37:27 +09:00 committed by sxyazi
parent 6bd869a7f1
commit e0095950eb
No known key found for this signature in database
8 changed files with 33 additions and 30 deletions

View file

@ -17,19 +17,19 @@ ueberzug_scale = 1
ueberzug_offset = [ 0, 0, 0, 0 ]
[input]
cd_position = "top"
cd_position = "top-center"
cd_offset = [0, 2, 50, 3]
search_position = "top"
search_position = "top-center"
search_offset = [0, 2, 50, 3]
find_position = "top"
find_position = "top-center"
find_offset = [0, 2, 50, 3]
shell_position = "top"
shell_position = "top-center"
shell_offset = [0, 2, 50, 3]
create_position = "top"
create_position = "top-center"
create_offset = [0, 2, 50, 3]
rename_position = "hovered"

View file

@ -7,12 +7,12 @@ pub enum Position {
TopLeft,
#[serde(rename = "top-right")]
TopRight,
#[serde(rename = "top")]
Top,
#[serde(rename = "top-center")]
TopCenter,
#[serde(rename = "center")]
Center,
#[serde(rename = "bottom")]
Bottom,
#[serde(rename = "bottom-center")]
BottomCenter,
#[serde(rename = "bottom-left")]
BottomLeft,
#[serde(rename = "bottom-right")]

View file

@ -55,7 +55,7 @@ impl Ctx {
(x, y)
}
Position::Top(RectShim { x_offset, y_offset, width, height }) => {
Position::TopCenter(RectShim { x_offset, y_offset, width, height }) => {
let right_max = columns.saturating_sub(width);
let bottom_max = rows.saturating_sub(height);
@ -79,7 +79,7 @@ impl Ctx {
(x, y)
}
Position::Bottom(RectShim { x_offset, y_offset, width, height }) => {
Position::BottomCenter(RectShim { x_offset, y_offset, width, height }) => {
let right_max = columns.saturating_sub(width);
let bottom_max = rows.saturating_sub(height);
@ -121,7 +121,7 @@ impl Ctx {
{
Position::Sticky(rect_shim, r)
} else {
Position::Top(rect_shim)
Position::TopCenter(rect_shim)
});
}
Position::Sticky(RectShim { x_offset, y_offset, width, height }, r) => {

View file

@ -29,11 +29,11 @@ impl InputOpt {
gen_method!(top_right, TopRight);
gen_method!(top, Top);
gen_method!(top_center, TopCenter);
gen_method!(center, Center);
gen_method!(bottom, Bottom);
gen_method!(bottom_center, BottomCenter);
gen_method!(bottom_left, BottomLeft);
@ -48,9 +48,9 @@ impl InputOpt {
match pos {
CfgPosition::TopLeft => Self::top_left(title, rect),
CfgPosition::TopRight => Self::top_right(title, rect),
CfgPosition::Top => Self::top(title, rect),
CfgPosition::TopCenter => Self::top_center(title, rect),
CfgPosition::Center => Self::center(title, rect),
CfgPosition::Bottom => Self::bottom(title, rect),
CfgPosition::BottomCenter => Self::bottom_center(title, rect),
CfgPosition::BottomLeft => Self::bottom_left(title, rect),
CfgPosition::BottomRight => Self::bottom_right(title, rect),
CfgPosition::Hovered => Self::hovered(title, rect),

View file

@ -19,16 +19,19 @@ impl Manager {
let opt = opt.into() as Opt;
let cwd = self.cwd().to_owned();
tokio::spawn(async move {
let mut result = emit!(Input(InputOpt::top("Create:", Default::default())));
let mut result = emit!(Input(InputOpt::top_center("Create:", Default::default())));
let Some(Ok(name)) = result.recv().await else {
return Ok(());
};
let path = cwd.join(&name);
if !opt.force && fs::symlink_metadata(&path).await.is_ok() {
match emit!(Input(InputOpt::top("Overwrite an existing file? (y/N)", Default::default())))
.recv()
.await
match emit!(Input(InputOpt::top_center(
"Overwrite an existing file? (y/N)",
Default::default()
)))
.recv()
.await
{
Some(Ok(c)) if c == "y" || c == "Y" => (),
_ => return Ok(()),

View file

@ -24,7 +24,7 @@ impl Manager {
}
tokio::spawn(async move {
let mut result = emit!(Input(InputOpt::top(
let mut result = emit!(Input(InputOpt::top_center(
format!("{tasks} tasks running, sure to quit? (y/N)",),
Default::default()
)));

View file

@ -16,9 +16,9 @@ impl Default for RectShim {
pub enum Position {
TopLeft(RectShim),
TopRight(RectShim),
Top(RectShim),
TopCenter(RectShim),
Center(RectShim),
Bottom(RectShim),
BottomCenter(RectShim),
BottomLeft(RectShim),
BottomRight(RectShim),
Hovered(RectShim),
@ -26,7 +26,7 @@ pub enum Position {
}
impl Default for Position {
fn default() -> Self { Self::Top(RectShim::default()) }
fn default() -> Self { Self::TopCenter(RectShim::default()) }
}
impl Position {
@ -35,9 +35,9 @@ impl Position {
match self {
Position::TopLeft(rect) => rect,
Position::TopRight(rect) => rect,
Position::Top(rect) => rect,
Position::TopCenter(rect) => rect,
Position::Center(rect) => rect,
Position::Bottom(rect) => rect,
Position::BottomCenter(rect) => rect,
Position::BottomLeft(rect) => rect,
Position::BottomRight(rect) => rect,
Position::Hovered(rect) => rect,

View file

@ -29,11 +29,11 @@ impl SelectOpt {
gen_method!(top_right, TopRight);
gen_method!(top, Top);
gen_method!(top_center, TopCenter);
gen_method!(center, Center);
gen_method!(bottom, Bottom);
gen_method!(bottom_center, BottomCenter);
gen_method!(bottom_left, BottomLeft);
@ -48,9 +48,9 @@ impl SelectOpt {
match pos {
CfgPosition::TopLeft => Self::top_left(title, items, rect),
CfgPosition::TopRight => Self::top_right(title, items, rect),
CfgPosition::Top => Self::top(title, items, rect),
CfgPosition::TopCenter => Self::top_center(title, items, rect),
CfgPosition::Center => Self::center(title, items, rect),
CfgPosition::Bottom => Self::bottom(title, items, rect),
CfgPosition::BottomCenter => Self::bottom_center(title, items, rect),
CfgPosition::BottomLeft => Self::bottom_left(title, items, rect),
CfgPosition::BottomRight => Self::bottom_right(title, items, rect),
CfgPosition::Hovered => Self::hovered(title, items, rect),