mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
Format
This commit is contained in:
parent
980942260d
commit
df2a5ee95c
7 changed files with 21 additions and 74 deletions
|
|
@ -11,10 +11,10 @@ pub struct Args {
|
|||
|
||||
/// Write the cwd on exit to this file
|
||||
#[arg(long)]
|
||||
pub cwd_file: Option<PathBuf>,
|
||||
pub cwd_file: Option<PathBuf>,
|
||||
/// Write the selected files on open emitted by the chooser mode
|
||||
#[arg(long)]
|
||||
pub chooser_file: Option<PathBuf>,
|
||||
pub chooser_file: Option<PathBuf>,
|
||||
/// Write the selected files on open to stdout
|
||||
#[arg(long, action)]
|
||||
pub chooser_stdout: bool,
|
||||
|
|
|
|||
|
|
@ -3,18 +3,12 @@ use std::ffi::OsString;
|
|||
use tracing::error;
|
||||
use yazi_config::{popup::SelectCfg, ARGS, OPEN};
|
||||
use yazi_plugin::isolate;
|
||||
use yazi_shared::event::QuitAction;
|
||||
use yazi_shared::{
|
||||
emit,
|
||||
event::Exec,
|
||||
fs::{File, Url},
|
||||
Layer, MIME_DIR,
|
||||
};
|
||||
use yazi_shared::{emit, event::{Exec, QuitAction}, fs::{File, Url}, Layer, MIME_DIR};
|
||||
|
||||
use crate::{manager::Manager, select::Select, tasks::Tasks};
|
||||
|
||||
pub struct Opt {
|
||||
targets: Option<Vec<(Url, Option<String>)>>,
|
||||
targets: Option<Vec<(Url, Option<String>)>>,
|
||||
interactive: bool,
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,5 @@
|
|||
use yazi_config::popup::InputCfg;
|
||||
use yazi_shared::{
|
||||
emit,
|
||||
event::{Exec, QuitAction},
|
||||
};
|
||||
use yazi_shared::{emit, event::{Exec, QuitAction}};
|
||||
|
||||
use crate::{input::Input, manager::Manager, tasks::Tasks};
|
||||
|
||||
|
|
@ -11,14 +8,10 @@ pub struct Opt {
|
|||
no_cwd_file: bool,
|
||||
}
|
||||
impl From<()> for Opt {
|
||||
fn from(_: ()) -> Self {
|
||||
Self::default()
|
||||
}
|
||||
fn from(_: ()) -> Self { Self::default() }
|
||||
}
|
||||
impl From<&Exec> for Opt {
|
||||
fn from(e: &Exec) -> Self {
|
||||
Self { no_cwd_file: e.named.contains_key("no-cwd-file") }
|
||||
}
|
||||
fn from(e: &Exec) -> Self { Self { no_cwd_file: e.named.contains_key("no-cwd-file") } }
|
||||
}
|
||||
|
||||
impl Manager {
|
||||
|
|
|
|||
|
|
@ -4,18 +4,13 @@ use anyhow::{Ok, Result};
|
|||
use crossterm::event::KeyEvent;
|
||||
use yazi_config::keymap::Key;
|
||||
use yazi_core::input::InputMode;
|
||||
use yazi_shared::{
|
||||
emit,
|
||||
event::{Event, Exec, NEED_RENDER},
|
||||
term::Term,
|
||||
Layer,
|
||||
};
|
||||
use yazi_shared::{emit, event::{Event, Exec, NEED_RENDER}, term::Term, Layer};
|
||||
|
||||
use crate::{lives::Lives, Ctx, Executor, Logs, Panic, Signals};
|
||||
|
||||
pub(crate) struct App {
|
||||
pub(crate) cx: Ctx,
|
||||
pub(crate) term: Option<Term>,
|
||||
pub(crate) cx: Ctx,
|
||||
pub(crate) term: Option<Term>,
|
||||
pub(crate) signals: Signals,
|
||||
}
|
||||
|
||||
|
|
@ -59,9 +54,7 @@ impl App {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
fn dispatch_key(&mut self, key: KeyEvent) {
|
||||
Executor::new(self).handle(Key::from(key));
|
||||
}
|
||||
fn dispatch_key(&mut self, key: KeyEvent) { Executor::new(self).handle(Key::from(key)); }
|
||||
|
||||
fn dispatch_paste(&mut self, str: String) {
|
||||
if self.cx.input.visible {
|
||||
|
|
|
|||
|
|
@ -1,18 +1,11 @@
|
|||
use anyhow::Result;
|
||||
use crossterm::event::{Event as CrosstermEvent, EventStream, KeyEvent, KeyEventKind};
|
||||
use futures::StreamExt;
|
||||
use tokio::{
|
||||
select,
|
||||
sync::{
|
||||
mpsc::{self, UnboundedReceiver, UnboundedSender},
|
||||
oneshot,
|
||||
},
|
||||
task::JoinHandle,
|
||||
};
|
||||
use tokio::{select, sync::{mpsc::{self, UnboundedReceiver, UnboundedSender}, oneshot}, task::JoinHandle};
|
||||
use yazi_shared::event::Event;
|
||||
|
||||
pub(super) struct Signals {
|
||||
tx: UnboundedSender<Event>,
|
||||
tx: UnboundedSender<Event>,
|
||||
pub(super) rx: UnboundedReceiver<Event>,
|
||||
|
||||
term_stop_tx: Option<oneshot::Sender<()>>,
|
||||
|
|
@ -49,9 +42,7 @@ impl Signals {
|
|||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
fn spawn_system_task(&self) -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
fn spawn_system_task(&self) -> Result<()> { Ok(()) }
|
||||
|
||||
#[cfg(unix)]
|
||||
fn spawn_system_task(&self) -> Result<JoinHandle<()>> {
|
||||
|
|
|
|||
|
|
@ -28,14 +28,10 @@ pub enum QuitAction {
|
|||
|
||||
impl Event {
|
||||
#[inline]
|
||||
pub fn init(tx: UnboundedSender<Event>) {
|
||||
TX.init(tx);
|
||||
}
|
||||
pub fn init(tx: UnboundedSender<Event>) { TX.init(tx); }
|
||||
|
||||
#[inline]
|
||||
pub fn emit(self) {
|
||||
TX.send(self).ok();
|
||||
}
|
||||
pub fn emit(self) { TX.send(self).ok(); }
|
||||
|
||||
pub async fn wait<T>(self, rx: oneshot::Receiver<T>) -> T {
|
||||
TX.send(self).ok();
|
||||
|
|
|
|||
|
|
@ -1,21 +1,7 @@
|
|||
use std::{
|
||||
io::{stdout, Stdout, Write},
|
||||
mem,
|
||||
ops::{Deref, DerefMut},
|
||||
};
|
||||
use std::{io::{stdout, Stdout, Write}, mem, ops::{Deref, DerefMut}};
|
||||
|
||||
use anyhow::Result;
|
||||
use crossterm::{
|
||||
event::{
|
||||
DisableBracketedPaste, DisableFocusChange, EnableBracketedPaste, EnableFocusChange,
|
||||
KeyboardEnhancementFlags, PopKeyboardEnhancementFlags, PushKeyboardEnhancementFlags,
|
||||
},
|
||||
execute, queue,
|
||||
terminal::{
|
||||
disable_raw_mode, enable_raw_mode, supports_keyboard_enhancement, Clear, ClearType,
|
||||
EnterAlternateScreen, LeaveAlternateScreen, WindowSize,
|
||||
},
|
||||
};
|
||||
use crossterm::{event::{DisableBracketedPaste, DisableFocusChange, EnableBracketedPaste, EnableFocusChange, KeyboardEnhancementFlags, PopKeyboardEnhancementFlags, PushKeyboardEnhancementFlags}, execute, queue, terminal::{disable_raw_mode, enable_raw_mode, supports_keyboard_enhancement, Clear, ClearType, EnterAlternateScreen, LeaveAlternateScreen, WindowSize}};
|
||||
use ratatui::{backend::CrosstermBackend, Terminal};
|
||||
|
||||
pub struct Term {
|
||||
|
|
@ -121,21 +107,15 @@ impl Term {
|
|||
}
|
||||
|
||||
impl Drop for Term {
|
||||
fn drop(&mut self) {
|
||||
self.stop().ok();
|
||||
}
|
||||
fn drop(&mut self) { self.stop().ok(); }
|
||||
}
|
||||
|
||||
impl Deref for Term {
|
||||
type Target = Terminal<CrosstermBackend<Stdout>>;
|
||||
|
||||
fn deref(&self) -> &Self::Target {
|
||||
&self.inner
|
||||
}
|
||||
fn deref(&self) -> &Self::Target { &self.inner }
|
||||
}
|
||||
|
||||
impl DerefMut for Term {
|
||||
fn deref_mut(&mut self) -> &mut Self::Target {
|
||||
&mut self.inner
|
||||
}
|
||||
fn deref_mut(&mut self) -> &mut Self::Target { &mut self.inner }
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue