mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
..
This commit is contained in:
parent
c95b613ed5
commit
75dc1ec8a3
15 changed files with 224 additions and 244 deletions
|
|
@ -76,55 +76,55 @@ preload = []
|
||||||
[input]
|
[input]
|
||||||
# cd
|
# cd
|
||||||
cd_title = "Change directory:"
|
cd_title = "Change directory:"
|
||||||
cd_position = "top-center"
|
cd_origin = "top-center"
|
||||||
cd_offset = [ 0, 2, 50, 3 ]
|
cd_offset = [ 0, 2, 50, 3 ]
|
||||||
cd_completion = 1
|
cd_completion = 1
|
||||||
|
|
||||||
# create
|
# create
|
||||||
create_title = "Create:"
|
create_title = "Create:"
|
||||||
create_position = "top-center"
|
create_origin = "top-center"
|
||||||
create_offset = [ 0, 2, 50, 3 ]
|
create_offset = [ 0, 2, 50, 3 ]
|
||||||
|
|
||||||
# rename
|
# rename
|
||||||
rename_title = "Rename:"
|
rename_title = "Rename:"
|
||||||
rename_position = "hovered"
|
rename_origin = "hovered"
|
||||||
rename_offset = [ 0, 1, 50, 3 ]
|
rename_offset = [ 0, 1, 50, 3 ]
|
||||||
|
|
||||||
# trash
|
# trash
|
||||||
trash_title = "Move {n} selected file{s} to trash? (y/N)"
|
trash_title = "Move {n} selected file{s} to trash? (y/N)"
|
||||||
trash_position = "top-center"
|
trash_origin = "top-center"
|
||||||
trash_offset = [ 0, 2, 50, 3 ]
|
trash_offset = [ 0, 2, 50, 3 ]
|
||||||
|
|
||||||
# delete
|
# delete
|
||||||
delete_title = "Delete {n} selected file{s} permanently? (y/N)"
|
delete_title = "Delete {n} selected file{s} permanently? (y/N)"
|
||||||
delete_position = "top-center"
|
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 previous:", "Find next:" ]
|
||||||
find_position = "top-center"
|
find_origin = "top-center"
|
||||||
find_offset = [ 0, 2, 50, 3 ]
|
find_offset = [ 0, 2, 50, 3 ]
|
||||||
find_realtime = true
|
find_realtime = true
|
||||||
|
|
||||||
# search
|
# search
|
||||||
search_title = "Search:"
|
search_title = "Search:"
|
||||||
search_position = "top-center"
|
search_origin = "top-center"
|
||||||
search_offset = [ 0, 2, 50, 3 ]
|
search_offset = [ 0, 2, 50, 3 ]
|
||||||
|
|
||||||
# shell
|
# shell
|
||||||
shell_title = [ "Shell:", "Shell (block):" ]
|
shell_title = [ "Shell:", "Shell (block):" ]
|
||||||
shell_position = "top-center"
|
shell_origin = "top-center"
|
||||||
shell_offset = [ 0, 2, 50, 3 ]
|
shell_offset = [ 0, 2, 50, 3 ]
|
||||||
shell_highlight = true
|
shell_highlight = true
|
||||||
|
|
||||||
# overwrite
|
# overwrite
|
||||||
overwrite_title = "Overwrite an existing file? (y/N)"
|
overwrite_title = "Overwrite an existing file? (y/N)"
|
||||||
overwrite_position = "top-center"
|
overwrite_origin = "top-center"
|
||||||
overwrite_offset = [ 0, 2, 50, 3 ]
|
overwrite_offset = [ 0, 2, 50, 3 ]
|
||||||
|
|
||||||
[select]
|
[select]
|
||||||
open_title = "Open with:"
|
open_title = "Open with:"
|
||||||
open_position = "hovered"
|
open_origin = "hovered"
|
||||||
open_offset = [ 0, 1, 50, 3 ]
|
open_offset = [ 0, 1, 50, 3 ]
|
||||||
|
|
||||||
[log]
|
[log]
|
||||||
|
|
|
||||||
|
|
@ -1,48 +1,48 @@
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
|
||||||
use super::position::{Offset, Position};
|
use super::{Offset, Origin};
|
||||||
use crate::MERGED_YAZI;
|
use crate::MERGED_YAZI;
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Deserialize)]
|
||||||
pub struct Input {
|
pub struct Input {
|
||||||
// cd
|
// cd
|
||||||
pub cd_title: String,
|
pub cd_title: String,
|
||||||
pub cd_position: Position,
|
pub cd_origin: Origin,
|
||||||
pub cd_offset: Offset,
|
pub cd_offset: Offset,
|
||||||
|
|
||||||
// create
|
// create
|
||||||
pub create_title: String,
|
pub create_title: String,
|
||||||
pub create_position: Position,
|
pub create_origin: Origin,
|
||||||
pub create_offset: Offset,
|
pub create_offset: Offset,
|
||||||
|
|
||||||
// rename
|
// rename
|
||||||
pub rename_title: String,
|
pub rename_title: String,
|
||||||
pub rename_position: Position,
|
pub rename_origin: Origin,
|
||||||
pub rename_offset: Offset,
|
pub rename_offset: Offset,
|
||||||
|
|
||||||
// trash
|
// trash
|
||||||
pub trash_title: String,
|
pub trash_title: String,
|
||||||
pub trash_position: Position,
|
pub trash_origin: Origin,
|
||||||
pub trash_offset: Offset,
|
pub trash_offset: Offset,
|
||||||
|
|
||||||
// delete
|
// delete
|
||||||
pub delete_title: String,
|
pub delete_title: String,
|
||||||
pub delete_position: Position,
|
pub delete_origin: Origin,
|
||||||
pub delete_offset: Offset,
|
pub delete_offset: Offset,
|
||||||
|
|
||||||
// find
|
// find
|
||||||
pub find_title: [String; 2],
|
pub find_title: [String; 2],
|
||||||
pub find_position: Position,
|
pub find_origin: Origin,
|
||||||
pub find_offset: Offset,
|
pub find_offset: Offset,
|
||||||
|
|
||||||
// search
|
// search
|
||||||
pub search_title: String,
|
pub search_title: String,
|
||||||
pub search_position: Position,
|
pub search_origin: Origin,
|
||||||
pub search_offset: Offset,
|
pub search_offset: Offset,
|
||||||
|
|
||||||
// shell
|
// shell
|
||||||
pub shell_title: [String; 2],
|
pub shell_title: [String; 2],
|
||||||
pub shell_position: Position,
|
pub shell_origin: Origin,
|
||||||
pub shell_offset: Offset,
|
pub shell_offset: Offset,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,13 @@
|
||||||
mod input;
|
mod input;
|
||||||
|
mod offset;
|
||||||
mod options;
|
mod options;
|
||||||
|
mod origin;
|
||||||
mod position;
|
mod position;
|
||||||
mod select;
|
mod select;
|
||||||
|
|
||||||
pub use input::*;
|
pub use input::*;
|
||||||
|
pub use offset::*;
|
||||||
pub use options::*;
|
pub use options::*;
|
||||||
|
pub use origin::*;
|
||||||
pub use position::*;
|
pub use position::*;
|
||||||
pub use select::*;
|
pub use select::*;
|
||||||
|
|
|
||||||
31
yazi-config/src/popup/offset.rs
Normal file
31
yazi-config/src/popup/offset.rs
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
use anyhow::bail;
|
||||||
|
use serde::Deserialize;
|
||||||
|
|
||||||
|
#[derive(Clone, Copy, Default, Deserialize)]
|
||||||
|
#[serde(try_from = "Vec<i16>")]
|
||||||
|
pub struct Offset {
|
||||||
|
pub x: i16,
|
||||||
|
pub y: i16,
|
||||||
|
pub width: u16,
|
||||||
|
pub height: u16,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl TryFrom<Vec<i16>> for Offset {
|
||||||
|
type Error = anyhow::Error;
|
||||||
|
|
||||||
|
fn try_from(values: Vec<i16>) -> Result<Self, Self::Error> {
|
||||||
|
if values.len() != 4 {
|
||||||
|
bail!("invalid offset: {:?}", values);
|
||||||
|
}
|
||||||
|
if values[2] < 0 || values[3] < 0 {
|
||||||
|
bail!("invalid offset: {:?}", values);
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(Self {
|
||||||
|
x: values[0],
|
||||||
|
y: values[1],
|
||||||
|
width: values[2] as u16,
|
||||||
|
height: values[3] as u16,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
24
yazi-config/src/popup/origin.rs
Normal file
24
yazi-config/src/popup/origin.rs
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
use serde::Deserialize;
|
||||||
|
|
||||||
|
#[derive(Clone, Copy, Default, Deserialize)]
|
||||||
|
pub enum Origin {
|
||||||
|
#[default]
|
||||||
|
#[serde(rename = "top-left")]
|
||||||
|
TopLeft,
|
||||||
|
#[serde(rename = "top-center")]
|
||||||
|
TopCenter,
|
||||||
|
#[serde(rename = "top-right")]
|
||||||
|
TopRight,
|
||||||
|
|
||||||
|
#[serde(rename = "bottom-left")]
|
||||||
|
BottomLeft,
|
||||||
|
#[serde(rename = "bottom-center")]
|
||||||
|
BottomCenter,
|
||||||
|
#[serde(rename = "bottom-right")]
|
||||||
|
BottomRight,
|
||||||
|
|
||||||
|
#[serde(rename = "center")]
|
||||||
|
Center,
|
||||||
|
#[serde(rename = "hovered")]
|
||||||
|
Hovered,
|
||||||
|
}
|
||||||
|
|
@ -1,54 +1,91 @@
|
||||||
use anyhow::bail;
|
use crossterm::terminal::WindowSize;
|
||||||
use serde::{Deserialize, Serialize};
|
use ratatui::layout::Rect;
|
||||||
|
use yazi_shared::Term;
|
||||||
|
|
||||||
#[derive(Debug, Default, Deserialize)]
|
use super::{Offset, Origin};
|
||||||
pub enum Position {
|
|
||||||
#[serde(rename = "top-left")]
|
|
||||||
TopLeft,
|
|
||||||
#[serde(rename = "top-center")]
|
|
||||||
TopCenter,
|
|
||||||
#[serde(rename = "top-right")]
|
|
||||||
TopRight,
|
|
||||||
|
|
||||||
#[serde(rename = "bottom-left")]
|
#[derive(Clone, Copy, Default)]
|
||||||
BottomLeft,
|
pub struct Position {
|
||||||
#[serde(rename = "bottom-center")]
|
pub origin: Origin,
|
||||||
BottomCenter,
|
pub offset: Offset,
|
||||||
#[serde(rename = "bottom-right")]
|
|
||||||
BottomRight,
|
|
||||||
|
|
||||||
#[serde(rename = "center")]
|
|
||||||
#[default]
|
|
||||||
Center,
|
|
||||||
#[serde(rename = "hovered")]
|
|
||||||
Hovered,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, Default, Deserialize, Serialize, PartialEq, Eq)]
|
impl Position {
|
||||||
#[serde(try_from = "Vec<i16>")]
|
pub fn rect(&self) -> Rect {
|
||||||
pub struct Offset {
|
let Offset { x, y, width, height } = self.offset;
|
||||||
pub x: i16,
|
let WindowSize { columns, rows, .. } = Term::size();
|
||||||
pub y: i16,
|
|
||||||
pub width: u16,
|
let max_x = columns.saturating_sub(width);
|
||||||
pub height: u16,
|
let max_y = rows.saturating_sub(height);
|
||||||
|
|
||||||
|
let (x, y) = match self.origin {
|
||||||
|
// Top
|
||||||
|
Origin::TopLeft => (x.clamp(0, max_x as i16) as u16, y.clamp(0, max_y as i16) as u16),
|
||||||
|
Origin::TopCenter => (
|
||||||
|
(columns / 2).saturating_sub(width / 2).saturating_add_signed(x).clamp(0, max_x),
|
||||||
|
y.clamp(0, max_y as i16) as u16,
|
||||||
|
),
|
||||||
|
Origin::TopRight => {
|
||||||
|
(max_x.saturating_add_signed(x).clamp(0, max_x), y.clamp(0, max_y as i16) as u16)
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TryFrom<Vec<i16>> for Offset {
|
// Bottom
|
||||||
type Error = anyhow::Error;
|
Origin::BottomLeft => {
|
||||||
|
(x.clamp(0, max_x as i16) as u16, max_y.saturating_add_signed(y).clamp(0, max_y))
|
||||||
fn try_from(values: Vec<i16>) -> Result<Self, Self::Error> {
|
}
|
||||||
if values.len() != 4 {
|
Origin::BottomCenter => (
|
||||||
bail!("invalid offset: {:?}", values);
|
(columns / 2).saturating_sub(width / 2).saturating_add_signed(x).clamp(0, max_x),
|
||||||
|
max_y.saturating_add_signed(y).clamp(0, max_y),
|
||||||
|
),
|
||||||
|
Origin::BottomRight => (
|
||||||
|
max_x.saturating_add_signed(x).clamp(0, max_x),
|
||||||
|
max_y.saturating_add_signed(y).clamp(0, max_y),
|
||||||
|
),
|
||||||
|
|
||||||
|
// Special
|
||||||
|
// Origin::Hovered => {
|
||||||
|
// return Origin::rect(&if let Some(r) =
|
||||||
|
// self.manager.hovered().and_then(|h| self.manager.current().rect_current(&h.url))
|
||||||
|
// {
|
||||||
|
// Origin::Sticky(r)
|
||||||
|
// } else {
|
||||||
|
// Origin::TopCenter(rect_shim)
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
Origin::Center => (
|
||||||
|
(columns / 2).saturating_sub(width / 2).saturating_add_signed(x).clamp(0, max_x),
|
||||||
|
(max_y / 2).saturating_sub(height / 2).saturating_add_signed(y).clamp(0, max_y),
|
||||||
|
),
|
||||||
|
Origin::Hovered => unreachable!(),
|
||||||
|
};
|
||||||
|
|
||||||
|
Rect {
|
||||||
|
x,
|
||||||
|
y,
|
||||||
|
width: width.min(columns.saturating_sub(x)),
|
||||||
|
height: height.min(rows.saturating_sub(y)),
|
||||||
}
|
}
|
||||||
if values[2] < 0 || values[3] < 0 {
|
|
||||||
bail!("invalid offset: {:?}", values);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(Self {
|
pub fn sticky(base: Rect, offset: Offset) -> Rect {
|
||||||
x: values[0],
|
let Offset { x, y, width, height } = offset;
|
||||||
y: values[1],
|
let WindowSize { columns, rows, .. } = Term::size();
|
||||||
width: values[2] as u16,
|
|
||||||
height: values[3] as u16,
|
let above =
|
||||||
})
|
base.y.saturating_add(base.height).saturating_add(height).saturating_add_signed(y) > rows;
|
||||||
|
|
||||||
|
let x = base.x.saturating_add_signed(x).clamp(0, columns.saturating_sub(width));
|
||||||
|
let y = if above {
|
||||||
|
base.y.saturating_sub(height.saturating_sub(y.unsigned_abs()))
|
||||||
|
} else {
|
||||||
|
base.y.saturating_add(base.height).saturating_add_signed(y)
|
||||||
|
};
|
||||||
|
|
||||||
|
Rect {
|
||||||
|
x,
|
||||||
|
y,
|
||||||
|
width: width.min(columns.saturating_sub(x)),
|
||||||
|
height: height.min(rows.saturating_sub(y)),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
|
||||||
use super::position::{Offset, Position};
|
use super::{Offset, Origin};
|
||||||
use crate::MERGED_YAZI;
|
use crate::MERGED_YAZI;
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Deserialize)]
|
||||||
pub struct Select {
|
pub struct Select {
|
||||||
// open
|
// open
|
||||||
pub open_title: String,
|
pub open_title: String,
|
||||||
pub open_position: Position,
|
pub open_origin: Origin,
|
||||||
pub open_offset: Offset,
|
pub open_offset: Offset,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,5 @@
|
||||||
use crossterm::terminal::WindowSize;
|
|
||||||
use ratatui::prelude::Rect;
|
use ratatui::prelude::Rect;
|
||||||
use yazi_config::popup::Position;
|
use yazi_config::popup::{Origin, Position};
|
||||||
use yazi_shared::Term;
|
|
||||||
|
|
||||||
use crate::{completion::Completion, help::Help, input::Input, manager::Manager, select::Select, tasks::Tasks, which::Which};
|
use crate::{completion::Completion, help::Help, input::Input, manager::Manager, select::Select, tasks::Tasks, which::Which};
|
||||||
|
|
||||||
|
|
@ -29,123 +27,12 @@ impl Ctx {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn area(&self, pos: &Position) -> Rect {
|
pub fn area(&self, pos: &Position) -> Rect {
|
||||||
let WindowSize { columns, rows, .. } = Term::size();
|
// TODO: hovered
|
||||||
|
if let Origin::Hovered = pos.origin {
|
||||||
let (x, y) = match *pos {
|
return Rect::default();
|
||||||
Position::TopLeft(Offset { x_offset, y_offset, width, height }) => {
|
|
||||||
let right_max = columns.saturating_sub(width);
|
|
||||||
let bottom_max = rows.saturating_sub(height);
|
|
||||||
|
|
||||||
let base_x = 0_u16;
|
|
||||||
let base_y = 0_u16;
|
|
||||||
|
|
||||||
let x = base_x.saturating_add_signed(x_offset).max(0).min(right_max);
|
|
||||||
let y = base_y.saturating_add_signed(y_offset).max(0).min(bottom_max);
|
|
||||||
|
|
||||||
(x, y)
|
|
||||||
}
|
}
|
||||||
Position::TopRight(Offset { x_offset, y_offset, width, height }) => {
|
|
||||||
let right_max = columns.saturating_sub(width);
|
|
||||||
let bottom_max = rows.saturating_sub(height);
|
|
||||||
|
|
||||||
let base_x = right_max;
|
pos.rect()
|
||||||
let base_y = 0_u16;
|
|
||||||
|
|
||||||
let x = base_x.saturating_add_signed(x_offset).max(0).min(right_max);
|
|
||||||
let y = base_y.saturating_add_signed(y_offset).max(0).min(bottom_max);
|
|
||||||
|
|
||||||
(x, y)
|
|
||||||
}
|
|
||||||
Position::TopCenter(Offset { x_offset, y_offset, width, height }) => {
|
|
||||||
let right_max = columns.saturating_sub(width);
|
|
||||||
let bottom_max = rows.saturating_sub(height);
|
|
||||||
|
|
||||||
let base_x = (columns / 2).saturating_sub(width / 2);
|
|
||||||
let base_y = 0_u16;
|
|
||||||
|
|
||||||
let x = base_x.saturating_add_signed(x_offset).max(0).min(right_max);
|
|
||||||
let y = base_y.saturating_add_signed(y_offset).max(0).min(bottom_max);
|
|
||||||
|
|
||||||
(x, y)
|
|
||||||
}
|
|
||||||
Position::Center(Offset { x_offset, y_offset, width, height }) => {
|
|
||||||
let right_max = columns.saturating_sub(width);
|
|
||||||
let bottom_max = rows.saturating_sub(height);
|
|
||||||
|
|
||||||
let base_x = (columns / 2).saturating_sub(width / 2);
|
|
||||||
let base_y = (bottom_max / 2).saturating_sub(height / 2);
|
|
||||||
|
|
||||||
let x = base_x.saturating_add_signed(x_offset).max(0).min(right_max);
|
|
||||||
let y = base_y.saturating_add_signed(y_offset).max(0).min(bottom_max);
|
|
||||||
|
|
||||||
(x, y)
|
|
||||||
}
|
|
||||||
Position::BottomCenter(Offset { x_offset, y_offset, width, height }) => {
|
|
||||||
let right_max = columns.saturating_sub(width);
|
|
||||||
let bottom_max = rows.saturating_sub(height);
|
|
||||||
|
|
||||||
let base_x = (columns / 2).saturating_sub(width / 2);
|
|
||||||
let base_y = bottom_max;
|
|
||||||
|
|
||||||
let x = base_x.saturating_add_signed(x_offset).max(0).min(right_max);
|
|
||||||
let y = base_y.saturating_add_signed(y_offset).max(0).min(bottom_max);
|
|
||||||
|
|
||||||
(x, y)
|
|
||||||
}
|
|
||||||
Position::BottomLeft(Offset { x_offset, y_offset, width, height }) => {
|
|
||||||
let right_max = columns.saturating_sub(width);
|
|
||||||
let bottom_max = rows.saturating_sub(height);
|
|
||||||
|
|
||||||
let base_x = 0_u16;
|
|
||||||
let base_y = bottom_max;
|
|
||||||
|
|
||||||
let x = base_x.saturating_add_signed(x_offset).max(0).min(right_max);
|
|
||||||
let y = base_y.saturating_add_signed(y_offset).max(0).min(bottom_max);
|
|
||||||
|
|
||||||
(x, y)
|
|
||||||
}
|
|
||||||
Position::BottomRight(Offset { x_offset, y_offset, width, height }) => {
|
|
||||||
let right_max = columns.saturating_sub(width);
|
|
||||||
let bottom_max = rows.saturating_sub(height);
|
|
||||||
|
|
||||||
let base_x = right_max;
|
|
||||||
let base_y = bottom_max;
|
|
||||||
|
|
||||||
let x = base_x.saturating_add_signed(x_offset).max(0).min(right_max);
|
|
||||||
let y = base_y.saturating_add_signed(y_offset).max(0).min(bottom_max);
|
|
||||||
|
|
||||||
(x, y)
|
|
||||||
}
|
|
||||||
Position::Hovered(rect_shim) => {
|
|
||||||
return self.area(&if let Some(r) =
|
|
||||||
self.manager.hovered().and_then(|h| self.manager.current().rect_current(&h.url))
|
|
||||||
{
|
|
||||||
Position::Sticky(rect_shim, r)
|
|
||||||
} else {
|
|
||||||
Position::TopCenter(rect_shim)
|
|
||||||
});
|
|
||||||
}
|
|
||||||
Position::Sticky(Offset { x_offset, y_offset, width, height }, r) => {
|
|
||||||
let base_x = r.x;
|
|
||||||
let base_y = r.y;
|
|
||||||
if base_y.saturating_add(height).saturating_add(r.height).saturating_add_signed(y_offset)
|
|
||||||
> rows
|
|
||||||
{
|
|
||||||
(
|
|
||||||
base_x.saturating_add_signed(x_offset).max(0).min(columns.saturating_sub(width)),
|
|
||||||
base_y.saturating_sub(height.saturating_sub(y_offset.unsigned_abs())),
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
(
|
|
||||||
base_x.saturating_add_signed(x_offset),
|
|
||||||
base_y.saturating_add(r.height).saturating_add_signed(y_offset),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
let (w, h) = pos.dimension();
|
|
||||||
Rect { x, y, width: w.min(columns.saturating_sub(x)), height: h.min(rows.saturating_sub(y)) }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use std::ffi::OsString;
|
use std::ffi::OsString;
|
||||||
|
|
||||||
use yazi_config::{keymap::Exec, popup::SelectOpt, OPEN, SELECT};
|
use yazi_config::{keymap::Exec, popup::SelectOpt, OPEN};
|
||||||
use yazi_shared::MIME_DIR;
|
use yazi_shared::MIME_DIR;
|
||||||
|
|
||||||
use crate::{emit, external, manager::Manager};
|
use crate::{emit, external, manager::Manager};
|
||||||
|
|
|
||||||
|
|
@ -24,16 +24,17 @@ impl Manager {
|
||||||
}
|
}
|
||||||
|
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
let mut result = emit!(Input(InputOpt::top_center(
|
// TODO
|
||||||
format!("{tasks} tasks running, sure to quit? (y/N)",),
|
// let mut result = emit!(Input(InputOpt::top_center(
|
||||||
Default::default()
|
// format!("{tasks} tasks running, sure to quit? (y/N)",),
|
||||||
)));
|
// Default::default()
|
||||||
|
// )));
|
||||||
|
|
||||||
if let Some(Ok(choice)) = result.recv().await {
|
// if let Some(Ok(choice)) = result.recv().await {
|
||||||
if choice == "y" || choice == "Y" {
|
// if choice == "y" || choice == "Y" {
|
||||||
emit!(Quit(opt.no_cwd_file));
|
// emit!(Quit(opt.no_cwd_file));
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
});
|
});
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ use std::{collections::BTreeSet, ffi::OsStr, io::{stdout, BufWriter, Write}, pat
|
||||||
|
|
||||||
use anyhow::{anyhow, bail, Result};
|
use anyhow::{anyhow, bail, Result};
|
||||||
use tokio::{fs::{self, OpenOptions}, io::{stdin, AsyncReadExt, AsyncWriteExt}};
|
use tokio::{fs::{self, OpenOptions}, io::{stdin, AsyncReadExt, AsyncWriteExt}};
|
||||||
use yazi_config::{keymap::Exec, popup::InputOpt, INPUT, OPEN, PREVIEW};
|
use yazi_config::{keymap::Exec, popup::InputOpt, OPEN, PREVIEW};
|
||||||
use yazi_shared::{max_common_root, Defer, Term, Url};
|
use yazi_shared::{max_common_root, Defer, Term, Url};
|
||||||
|
|
||||||
use crate::{emit, external::{self, ShellOpt}, files::{File, FilesOp}, manager::Manager, Event, BLOCKER};
|
use crate::{emit, external::{self, ShellOpt}, files::{File, FilesOp}, manager::Manager, Event, BLOCKER};
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ use std::time::Duration;
|
||||||
|
|
||||||
use tokio::pin;
|
use tokio::pin;
|
||||||
use tokio_stream::{wrappers::UnboundedReceiverStream, StreamExt};
|
use tokio_stream::{wrappers::UnboundedReceiverStream, StreamExt};
|
||||||
use yazi_config::{keymap::{Exec, KeymapLayer}, popup::InputOpt, INPUT};
|
use yazi_config::{keymap::{Exec, KeymapLayer}, popup::InputOpt};
|
||||||
use yazi_shared::{Debounce, InputError};
|
use yazi_shared::{Debounce, InputError};
|
||||||
|
|
||||||
use crate::{emit, tab::{Finder, FinderCase, Tab}};
|
use crate::{emit, tab::{Finder, FinderCase, Tab}};
|
||||||
|
|
@ -39,7 +39,6 @@ impl Tab {
|
||||||
pub fn find<'a>(&mut self, opt: impl Into<Opt<'a>>) -> bool {
|
pub fn find<'a>(&mut self, opt: impl Into<Opt<'a>>) -> bool {
|
||||||
let opt = opt.into() as Opt;
|
let opt = opt.into() as Opt;
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
let title = if opt.prev { "Find previous:" } else { "Find next:" };
|
|
||||||
let rx = emit!(Input(InputOpt::find(opt.prev)));
|
let rx = emit!(Input(InputOpt::find(opt.prev)));
|
||||||
|
|
||||||
let rx = Debounce::new(UnboundedReceiverStream::new(rx), Duration::from_millis(50));
|
let rx = Debounce::new(UnboundedReceiverStream::new(rx), Duration::from_millis(50));
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ use std::{mem, time::Duration};
|
||||||
use anyhow::bail;
|
use anyhow::bail;
|
||||||
use tokio::pin;
|
use tokio::pin;
|
||||||
use tokio_stream::{wrappers::UnboundedReceiverStream, StreamExt};
|
use tokio_stream::{wrappers::UnboundedReceiverStream, StreamExt};
|
||||||
use yazi_config::{keymap::{Exec, KeymapLayer}, popup::InputOpt, INPUT};
|
use yazi_config::{keymap::{Exec, KeymapLayer}, popup::InputOpt};
|
||||||
|
|
||||||
use crate::{emit, external, files::FilesOp, tab::Tab};
|
use crate::{emit, external, files::FilesOp, tab::Tab};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
use yazi_config::{keymap::Exec, open::Opener, popup::InputOpt, INPUT};
|
use yazi_config::{keymap::Exec, open::Opener, popup::InputOpt};
|
||||||
|
|
||||||
use crate::{emit, tab::Tab};
|
use crate::{emit, tab::Tab};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
use std::path::MAIN_SEPARATOR;
|
use std::path::MAIN_SEPARATOR;
|
||||||
|
|
||||||
use ratatui::{buffer::Buffer, layout::Rect, widgets::{Block, BorderType, Borders, Clear, List, ListItem, Widget}};
|
use ratatui::{buffer::Buffer, layout::Rect, widgets::{Block, BorderType, Borders, Clear, List, ListItem, Widget}};
|
||||||
use yazi_config::THEME;
|
use yazi_config::{popup::{Offset, Position}, THEME};
|
||||||
use yazi_core::{Ctx, Offset, Position};
|
use yazi_core::Ctx;
|
||||||
|
|
||||||
pub(crate) struct Completion<'a> {
|
pub(crate) struct Completion<'a> {
|
||||||
cx: &'a Ctx,
|
cx: &'a Ctx,
|
||||||
|
|
@ -39,15 +39,12 @@ impl<'a> Widget for Completion<'a> {
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
let input_area = self.cx.area(&self.cx.input.position);
|
let input_area = self.cx.area(&self.cx.input.position);
|
||||||
let mut area = self.cx.area(&Position::Sticky(
|
let mut area = Position::sticky(input_area, Offset {
|
||||||
Offset {
|
x: 1,
|
||||||
x_offset: 1,
|
y: 0,
|
||||||
y_offset: 0,
|
|
||||||
width: input_area.width.saturating_sub(2),
|
width: input_area.width.saturating_sub(2),
|
||||||
height: items.len() as u16 + 2,
|
height: items.len() as u16 + 2,
|
||||||
},
|
});
|
||||||
input_area,
|
|
||||||
));
|
|
||||||
|
|
||||||
if area.y > input_area.y {
|
if area.y > input_area.y {
|
||||||
area.y = area.y.saturating_sub(1);
|
area.y = area.y.saturating_sub(1);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue