From e0095950ebd7615d785fdeec283ca3bcfd001e19 Mon Sep 17 00:00:00 2001 From: Hanaasagi Date: Tue, 14 Nov 2023 10:37:27 +0900 Subject: [PATCH] chore: rename `Top` to `TopCenter`, `Bottom` to `BottomCenter` --- yazi-config/preset/yazi.toml | 10 +++++----- yazi-config/src/popup/position.rs | 8 ++++---- yazi-core/src/context.rs | 6 +++--- yazi-core/src/input/option.rs | 8 ++++---- yazi-core/src/manager/commands/create.rs | 11 +++++++---- yazi-core/src/manager/commands/quit.rs | 2 +- yazi-core/src/position.rs | 10 +++++----- yazi-core/src/select/option.rs | 8 ++++---- 8 files changed, 33 insertions(+), 30 deletions(-) diff --git a/yazi-config/preset/yazi.toml b/yazi-config/preset/yazi.toml index 8403c6a7..968de7cd 100644 --- a/yazi-config/preset/yazi.toml +++ b/yazi-config/preset/yazi.toml @@ -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" diff --git a/yazi-config/src/popup/position.rs b/yazi-config/src/popup/position.rs index d2764a43..af517184 100644 --- a/yazi-config/src/popup/position.rs +++ b/yazi-config/src/popup/position.rs @@ -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")] diff --git a/yazi-core/src/context.rs b/yazi-core/src/context.rs index a8f496ee..867ff136 100644 --- a/yazi-core/src/context.rs +++ b/yazi-core/src/context.rs @@ -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) => { diff --git a/yazi-core/src/input/option.rs b/yazi-core/src/input/option.rs index 8b5278ad..9eb1f618 100644 --- a/yazi-core/src/input/option.rs +++ b/yazi-core/src/input/option.rs @@ -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), diff --git a/yazi-core/src/manager/commands/create.rs b/yazi-core/src/manager/commands/create.rs index 331dc093..4ab5ea85 100644 --- a/yazi-core/src/manager/commands/create.rs +++ b/yazi-core/src/manager/commands/create.rs @@ -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(()), diff --git a/yazi-core/src/manager/commands/quit.rs b/yazi-core/src/manager/commands/quit.rs index 14c0efa7..3c7032e8 100644 --- a/yazi-core/src/manager/commands/quit.rs +++ b/yazi-core/src/manager/commands/quit.rs @@ -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() ))); diff --git a/yazi-core/src/position.rs b/yazi-core/src/position.rs index e2534471..bb09aade 100644 --- a/yazi-core/src/position.rs +++ b/yazi-core/src/position.rs @@ -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, diff --git a/yazi-core/src/select/option.rs b/yazi-core/src/select/option.rs index 357fc1be..7628ad96 100644 --- a/yazi-core/src/select/option.rs +++ b/yazi-core/src/select/option.rs @@ -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),