mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
..
This commit is contained in:
parent
437757f4d6
commit
aaa87d2131
4 changed files with 35 additions and 14 deletions
|
|
@ -119,6 +119,11 @@ overwrite_title = "Overwrite an existing file? (y/N)"
|
|||
overwrite_origin = "top-center"
|
||||
overwrite_offset = [ 0, 2, 50, 3 ]
|
||||
|
||||
# quit
|
||||
quit_title = "{n} task{s} running, sure to quit? (y/N)"
|
||||
quit_origin = "top-center"
|
||||
quit_offset = [ 0, 2, 50, 3 ]
|
||||
|
||||
[select]
|
||||
open_title = "Open with:"
|
||||
open_origin = "hovered"
|
||||
|
|
|
|||
|
|
@ -49,6 +49,11 @@ pub struct Input {
|
|||
pub overwrite_title: String,
|
||||
pub overwrite_origin: Origin,
|
||||
pub overwrite_offset: Offset,
|
||||
|
||||
// quit
|
||||
pub quit_title: String,
|
||||
pub quit_origin: Origin,
|
||||
pub quit_offset: Offset,
|
||||
}
|
||||
|
||||
impl Default for Input {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use super::Position;
|
||||
use crate::INPUT;
|
||||
use crate::{INPUT, SELECT};
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct InputOpt {
|
||||
|
|
@ -105,6 +105,16 @@ impl InputOpt {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn quit(n: usize) -> Self {
|
||||
let title = INPUT.quit_title.replace("{n}", &n.to_string());
|
||||
Self {
|
||||
title: title.replace("{s}", if n > 1 { "s" } else { "" }),
|
||||
position: Position::new(INPUT.quit_origin, INPUT.quit_offset),
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn with_value(mut self, value: impl Into<String>) -> Self {
|
||||
self.value = value.into();
|
||||
|
|
@ -114,7 +124,13 @@ impl InputOpt {
|
|||
|
||||
impl SelectOpt {
|
||||
#[inline]
|
||||
pub fn open() -> Self { todo!() }
|
||||
pub fn open() -> Self {
|
||||
Self {
|
||||
title: SELECT.open_title.to_owned(),
|
||||
position: Position::new(SELECT.open_origin, SELECT.open_offset),
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn with_items(mut self, items: Vec<String>) -> Self {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use yazi_config::keymap::Exec;
|
||||
use yazi_config::{keymap::Exec, popup::InputOpt};
|
||||
|
||||
use crate::{emit, manager::Manager, tasks::Tasks};
|
||||
|
||||
|
|
@ -24,17 +24,12 @@ impl Manager {
|
|||
}
|
||||
|
||||
tokio::spawn(async move {
|
||||
// TODO
|
||||
// let mut result = emit!(Input(InputOpt::top_center(
|
||||
// format!("{tasks} tasks running, sure to quit? (y/N)",),
|
||||
// Default::default()
|
||||
// )));
|
||||
|
||||
// if let Some(Ok(choice)) = result.recv().await {
|
||||
// if choice == "y" || choice == "Y" {
|
||||
// emit!(Quit(opt.no_cwd_file));
|
||||
// }
|
||||
// }
|
||||
let mut result = emit!(Input(InputOpt::quit(tasks)));
|
||||
if let Some(Ok(choice)) = result.recv().await {
|
||||
if choice == "y" || choice == "Y" {
|
||||
emit!(Quit(opt.no_cwd_file));
|
||||
}
|
||||
}
|
||||
});
|
||||
false
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue