mirror of
https://github.com/sxyazi/yazi.git
synced 2026-05-13 08:16:40 +00:00
refactor: move tty to the new yazi-term crate (#2701)
This commit is contained in:
parent
13a515c0ed
commit
8ed569b729
25 changed files with 60 additions and 20 deletions
9
Cargo.lock
generated
9
Cargo.lock
generated
|
|
@ -3244,6 +3244,7 @@ dependencies = [
|
|||
"yazi-config",
|
||||
"yazi-macro",
|
||||
"yazi-shared",
|
||||
"yazi-term",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -3326,6 +3327,7 @@ dependencies = [
|
|||
"yazi-fs",
|
||||
"yazi-macro",
|
||||
"yazi-shared",
|
||||
"yazi-term",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -3360,6 +3362,7 @@ dependencies = [
|
|||
"yazi-proxy",
|
||||
"yazi-scheduler",
|
||||
"yazi-shared",
|
||||
"yazi-term",
|
||||
"yazi-widgets",
|
||||
]
|
||||
|
||||
|
|
@ -3503,6 +3506,7 @@ dependencies = [
|
|||
"yazi-prebuilt",
|
||||
"yazi-proxy",
|
||||
"yazi-shared",
|
||||
"yazi-term",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -3572,7 +3576,12 @@ name = "yazi-term"
|
|||
version = "25.4.8"
|
||||
dependencies = [
|
||||
"crossterm 0.29.0",
|
||||
"libc",
|
||||
"parking_lot",
|
||||
"tracing",
|
||||
"windows-sys 0.59.0",
|
||||
"yazi-macro",
|
||||
"yazi-shared",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ repository = "https://github.com/sxyazi/yazi"
|
|||
yazi-config = { path = "../yazi-config", version = "25.4.8" }
|
||||
yazi-macro = { path = "../yazi-macro", version = "25.4.8" }
|
||||
yazi-shared = { path = "../yazi-shared", version = "25.4.8" }
|
||||
yazi-term = { path = "../yazi-term", version = "25.4.8" }
|
||||
|
||||
# External dependencies
|
||||
ansi-to-tui = { workspace = true }
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ use anyhow::Result;
|
|||
use base64::{Engine, engine::general_purpose};
|
||||
use image::DynamicImage;
|
||||
use ratatui::layout::Rect;
|
||||
use yazi_shared::tty::TTY;
|
||||
use yazi_term::tty::TTY;
|
||||
|
||||
use crate::{CLOSE, ESCAPE, Emulator, Image, START, adapter::Adapter};
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,8 @@ use crossterm::{cursor::{RestorePosition, SavePosition}, execute, style::Print,
|
|||
use scopeguard::defer;
|
||||
use tokio::time::sleep;
|
||||
use tracing::{debug, error, warn};
|
||||
use yazi_shared::{Either, tty::{Handle, TTY}};
|
||||
use yazi_shared::Either;
|
||||
use yazi_term::tty::{Handle, TTY};
|
||||
|
||||
use crate::{Adapter, Brand, Dimension, Mux, TMUX, Unknown};
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use anyhow::Result;
|
||||
use tracing::error;
|
||||
use yazi_macro::time;
|
||||
use yazi_shared::tty::TTY;
|
||||
use yazi_term::tty::TTY;
|
||||
|
||||
use crate::{CLOSE, ESCAPE, Emulator, START, TMUX};
|
||||
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ yazi-codegen = { path = "../yazi-codegen", version = "25.4.8" }
|
|||
yazi-fs = { path = "../yazi-fs", version = "25.4.8" }
|
||||
yazi-macro = { path = "../yazi-macro", version = "25.4.8" }
|
||||
yazi-shared = { path = "../yazi-shared", version = "25.4.8" }
|
||||
yazi-term = { path = "../yazi-term", version = "25.4.8" }
|
||||
|
||||
# External dependencies
|
||||
anyhow = { workspace = true }
|
||||
|
|
|
|||
|
|
@ -6,7 +6,8 @@ yazi_macro::mod_flat!(layout pattern platform preset priority yazi);
|
|||
|
||||
use std::io::{Read, Write};
|
||||
|
||||
use yazi_shared::{RoCell, SyncCell, tty::TTY};
|
||||
use yazi_shared::{RoCell, SyncCell};
|
||||
use yazi_term::tty::TTY;
|
||||
|
||||
pub static YAZI: RoCell<yazi::Yazi> = RoCell::new();
|
||||
pub static KEYMAP: RoCell<keymap::Keymap> = RoCell::new();
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ yazi-plugin = { path = "../yazi-plugin", version = "25.4.8" }
|
|||
yazi-proxy = { path = "../yazi-proxy", version = "25.4.8" }
|
||||
yazi-scheduler = { path = "../yazi-scheduler", version = "25.4.8" }
|
||||
yazi-shared = { path = "../yazi-shared", version = "25.4.8" }
|
||||
yazi-term = { path = "../yazi-term", version = "25.4.8" }
|
||||
yazi-widgets = { path = "../yazi-widgets", version = "25.4.8" }
|
||||
|
||||
# External dependencies
|
||||
|
|
|
|||
|
|
@ -8,7 +8,8 @@ use yazi_config::YAZI;
|
|||
use yazi_dds::Pubsub;
|
||||
use yazi_fs::{File, FilesOp, max_common_root, maybe_exists, paths_to_same_file};
|
||||
use yazi_proxy::{AppProxy, HIDER, TasksProxy, WATCHER};
|
||||
use yazi_shared::{terminal_clear, tty::TTY, url::Url};
|
||||
use yazi_shared::{terminal_clear, url::Url};
|
||||
use yazi_term::tty::TTY;
|
||||
|
||||
use crate::mgr::Mgr;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
use crossterm::{execute, terminal::SetTitle};
|
||||
use yazi_config::YAZI;
|
||||
use yazi_fs::CWD;
|
||||
use yazi_shared::{event::CmdCow, tty::TTY};
|
||||
use yazi_shared::event::CmdCow;
|
||||
use yazi_term::tty::TTY;
|
||||
|
||||
use crate::{mgr::Mgr, tasks::Tasks};
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,8 @@ use crossterm::{execute, terminal::{disable_raw_mode, enable_raw_mode}};
|
|||
use scopeguard::defer;
|
||||
use tokio::{io::{AsyncReadExt, stdin}, select, sync::mpsc, time};
|
||||
use yazi_proxy::{AppProxy, HIDER};
|
||||
use yazi_shared::{event::CmdCow, terminal_clear, tty::TTY};
|
||||
use yazi_shared::{event::CmdCow, terminal_clear};
|
||||
use yazi_term::tty::TTY;
|
||||
|
||||
use crate::tasks::Tasks;
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,8 @@ use std::sync::atomic::{AtomicU8, Ordering};
|
|||
use crossterm::{cursor::{MoveTo, SetCursorStyle, Show}, execute, queue, terminal::{BeginSynchronizedUpdate, EndSynchronizedUpdate}};
|
||||
use ratatui::{CompletedFrame, backend::{Backend, CrosstermBackend}, buffer::Buffer, layout::Position};
|
||||
use yazi_plugin::elements::COLLISION;
|
||||
use yazi_shared::{event::NEED_RENDER, tty::TTY};
|
||||
use yazi_shared::event::NEED_RENDER;
|
||||
use yazi_term::tty::TTY;
|
||||
|
||||
use crate::{app::App, lives::Lives, root::Root};
|
||||
|
||||
|
|
|
|||
|
|
@ -16,6 +16,8 @@ async fn main() -> anyhow::Result<()> {
|
|||
Logs::start()?;
|
||||
_ = fdlimit::raise_fd_limit();
|
||||
|
||||
yazi_term::init();
|
||||
|
||||
yazi_fs::init();
|
||||
|
||||
yazi_config::init()?;
|
||||
|
|
|
|||
|
|
@ -5,7 +5,8 @@ use crossterm::{Command, event::{DisableBracketedPaste, DisableMouseCapture, Ena
|
|||
use ratatui::{CompletedFrame, Frame, Terminal, backend::CrosstermBackend, buffer::Buffer, layout::Rect};
|
||||
use yazi_adapter::{Emulator, Mux, TMUX};
|
||||
use yazi_config::YAZI;
|
||||
use yazi_shared::{SyncCell, tty::{TTY, TtyWriter}};
|
||||
use yazi_shared::SyncCell;
|
||||
use yazi_term::tty::{TTY, TtyWriter};
|
||||
|
||||
static CSI_U: AtomicBool = AtomicBool::new(false);
|
||||
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ yazi-fs = { path = "../yazi-fs", version = "25.4.8" }
|
|||
yazi-macro = { path = "../yazi-macro", version = "25.4.8" }
|
||||
yazi-proxy = { path = "../yazi-proxy", version = "25.4.8" }
|
||||
yazi-shared = { path = "../yazi-shared", version = "25.4.8" }
|
||||
yazi-term = { path = "../yazi-term", version = "25.4.8" }
|
||||
|
||||
# External dependencies
|
||||
ansi-to-tui = { workspace = true }
|
||||
|
|
@ -51,7 +52,7 @@ uzers = { workspace = true }
|
|||
|
||||
[target."cfg(windows)".dependencies]
|
||||
clipboard-win = "5.4.0"
|
||||
windows-sys = { version = "0.59.0", features = [ "Win32_Security", "Win32_System_JobObjects", "Win32_System_Threading" ] }
|
||||
windows-sys = { version = "0.59.0", features = [ "Win32_System_JobObjects" ] }
|
||||
|
||||
[target.'cfg(target_os = "macos")'.dependencies]
|
||||
crossterm = { workspace = true, features = [ "use-dev-tty", "libc" ] }
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ impl Clipboard {
|
|||
|
||||
use crossterm::execute;
|
||||
use tokio::{io::AsyncWriteExt, process::Command};
|
||||
use yazi_shared::tty::TTY;
|
||||
use yazi_term::tty::TTY;
|
||||
|
||||
s.as_ref().clone_into(&mut self.content.lock());
|
||||
execute!(TTY.writer(), osc52::SetClipboard::new(s.as_ref())).ok();
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ libc = { workspace = true }
|
|||
uzers = { workspace = true }
|
||||
|
||||
[target.'cfg(windows)'.dependencies]
|
||||
windows-sys = { version = "0.59.0", features = [ "Win32_Globalization", "Win32_Security", "Win32_Storage_FileSystem", "Win32_System_Console", "Win32_System_IO", "Win32_System_Threading", "Win32_UI_Shell" ] }
|
||||
windows-sys = { version = "0.59.0", features = [ "Win32_UI_Shell" ] }
|
||||
|
||||
[target.'cfg(target_os = "macos")'.dependencies]
|
||||
crossterm = { workspace = true, features = [ "use-dev-tty", "libc" ] }
|
||||
|
|
|
|||
|
|
@ -1,12 +1,10 @@
|
|||
#![allow(clippy::option_map_unit_fn)]
|
||||
|
||||
yazi_macro::mod_pub!(errors event shell theme translit tty url);
|
||||
yazi_macro::mod_pub!(errors event shell theme translit url);
|
||||
|
||||
yazi_macro::mod_flat!(chars condition debounce either env id layer natsort number os rand ro_cell sync_cell terminal throttle time utf8);
|
||||
|
||||
pub fn init() {
|
||||
tty::init();
|
||||
|
||||
LOG_LEVEL.replace(<_>::from(std::env::var("YAZI_LOG").unwrap_or_default()));
|
||||
|
||||
#[cfg(unix)]
|
||||
|
|
|
|||
|
|
@ -10,7 +10,21 @@ repository = "https://github.com/sxyazi/yazi"
|
|||
rust-version = "1.85.0"
|
||||
|
||||
[dependencies]
|
||||
yazi-macro = { path = "../yazi-macro", version = "25.4.8" }
|
||||
yazi-macro = { path = "../yazi-macro", version = "25.4.8" }
|
||||
yazi-shared = { path = "../yazi-shared", version = "25.4.8" }
|
||||
|
||||
# Logging
|
||||
tracing = { workspace = true }
|
||||
|
||||
# External dependencies
|
||||
crossterm = { workspace = true }
|
||||
crossterm = { workspace = true }
|
||||
parking_lot = { workspace = true }
|
||||
|
||||
[target."cfg(unix)".dependencies]
|
||||
libc = { workspace = true }
|
||||
|
||||
[target.'cfg(target_os = "macos")'.dependencies]
|
||||
crossterm = { workspace = true, features = [ "use-dev-tty", "libc" ] }
|
||||
|
||||
[target.'cfg(windows)'.dependencies]
|
||||
windows-sys = { version = "0.59.0", features = [ "Win32_Globalization", "Win32_Storage_FileSystem", "Win32_System_IO", "Win32_System_Console", "Win32_System_Threading" ] }
|
||||
|
|
|
|||
|
|
@ -1,3 +1,7 @@
|
|||
#![allow(clippy::unit_arg)]
|
||||
|
||||
yazi_macro::mod_pub!(tty);
|
||||
|
||||
yazi_macro::mod_flat!(cursor if_);
|
||||
|
||||
pub fn init() { tty::init(); }
|
||||
|
|
|
|||
|
|
@ -3,6 +3,6 @@ yazi_macro::mod_flat!(handle tty);
|
|||
#[cfg(windows)]
|
||||
yazi_macro::mod_flat!(windows);
|
||||
|
||||
pub static TTY: crate::RoCell<Tty> = crate::RoCell::new();
|
||||
pub static TTY: yazi_shared::RoCell<Tty> = yazi_shared::RoCell::new();
|
||||
|
||||
pub(super) fn init() { TTY.with(<_>::default); }
|
||||
|
|
@ -3,8 +3,7 @@
|
|||
use std::{mem::MaybeUninit, os::windows::io::RawHandle, str};
|
||||
|
||||
use windows_sys::Win32::{Globalization::{CP_UTF8, MB_ERR_INVALID_CHARS, MultiByteToWideChar}, System::Console::WriteConsoleW};
|
||||
|
||||
use crate::{floor_char_boundary, utf8_char_width};
|
||||
use yazi_shared::{floor_char_boundary, utf8_char_width};
|
||||
|
||||
// Apparently Windows doesn't handle large reads on stdin or writes to
|
||||
// stdout/stderr well (see #13304 for details).
|
||||
|
|
@ -20,3 +20,6 @@ crossterm = { workspace = true }
|
|||
futures = { workspace = true }
|
||||
ratatui = { workspace = true }
|
||||
unicode-width = { workspace = true }
|
||||
|
||||
[target.'cfg(target_os = "macos")'.dependencies]
|
||||
crossterm = { workspace = true, features = [ "use-dev-tty", "libc" ] }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue