mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-21 14:51:03 +00:00
perf: eliminate hacks in image and UI conflict resolution (#4022)
This commit is contained in:
parent
8a4b0b208e
commit
ea7fa2127c
7 changed files with 12 additions and 50 deletions
|
|
@ -28,6 +28,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/):
|
|||
|
||||
- Deprecate `backward --far` and `forward --far` in favor of `backward wide` and `forward wide`, respectively ([#4012])
|
||||
|
||||
### Improved
|
||||
|
||||
- Eliminate hacks in image and UI conflict resolution ([#4022])
|
||||
|
||||
## [v26.5.6]
|
||||
|
||||
### Added
|
||||
|
|
@ -1737,3 +1741,4 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/):
|
|||
[#3990]: https://github.com/sxyazi/yazi/pull/3990
|
||||
[#4005]: https://github.com/sxyazi/yazi/pull/4005
|
||||
[#4012]: https://github.com/sxyazi/yazi/pull/4012
|
||||
[#4022]: https://github.com/sxyazi/yazi/pull/4022
|
||||
|
|
|
|||
|
|
@ -1,16 +0,0 @@
|
|||
use mlua::UserData;
|
||||
use yazi_codegen::FromLuaOwned;
|
||||
|
||||
#[derive(FromLuaOwned)]
|
||||
pub struct DataAny(Box<dyn yazi_shared::data::DataAny>);
|
||||
|
||||
impl DataAny {
|
||||
pub fn new<T>(value: T) -> Self
|
||||
where
|
||||
T: yazi_shared::data::DataAny,
|
||||
{
|
||||
Self(Box::new(value))
|
||||
}
|
||||
}
|
||||
|
||||
impl UserData for DataAny {}
|
||||
|
|
@ -1 +0,0 @@
|
|||
yazi_macro::mod_flat!(any);
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
mod macros;
|
||||
|
||||
yazi_macro::mod_pub!(config data elements event keymap process theme);
|
||||
yazi_macro::mod_pub!(config elements event keymap process theme);
|
||||
|
||||
yazi_macro::mod_flat!(access calculator cha chan composer dnd error fd file handle icon id image input iter layer mouse path permit range runtime scheme selector stage style tty url utils);
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use std::{io::Write, sync::atomic::{AtomicU8, Ordering}, time::Instant};
|
||||
|
||||
use anyhow::Result;
|
||||
use ratatui::{CompletedFrame, backend::Backend, buffer::Buffer, layout::Position};
|
||||
use ratatui::layout::Position;
|
||||
use yazi_actor::{Ctx, lives::Lives};
|
||||
use yazi_binding::runtime_scope;
|
||||
use yazi_config::LAYOUT;
|
||||
|
|
@ -10,7 +10,6 @@ use yazi_plugin::LUA;
|
|||
use yazi_shared::{data::Data, event::NEED_RENDER};
|
||||
use yazi_term::{CursorStyle, sequence::{BeginSyncUpdate, EndSyncUpdate, MoveTo, SetCursorStyle, ShowCursor}};
|
||||
use yazi_tty::TTY;
|
||||
use yazi_tui::RatermBackend;
|
||||
use yazi_widgets::COLLISION;
|
||||
|
||||
use crate::{app::App, root::Root};
|
||||
|
|
@ -30,15 +29,12 @@ impl App {
|
|||
|
||||
let collision = COLLISION.swap(false, Ordering::Relaxed);
|
||||
let preview_rect = LAYOUT.get().preview;
|
||||
let frame = term.draw(|f| {
|
||||
term.draw(|f| {
|
||||
_ = Lives::scope(&self.core, || {
|
||||
runtime_scope!(LUA, "root", Ok(f.render_widget(Root::new(&self.core), f.area())))
|
||||
});
|
||||
})?;
|
||||
|
||||
if COLLISION.load(Ordering::Relaxed) {
|
||||
Self::patch(frame);
|
||||
}
|
||||
if !self.core.notify.messages.is_empty() {
|
||||
self.render_partially()?;
|
||||
}
|
||||
|
|
@ -61,7 +57,7 @@ impl App {
|
|||
Self::routine(true, None);
|
||||
let _guard = scopeguard::guard(self.core.cursor(), |c| Self::routine(false, c));
|
||||
|
||||
let frame = term.draw_partial(|f| {
|
||||
term.draw_partial(|f| {
|
||||
_ = Lives::scope(&self.core, || {
|
||||
runtime_scope!(LUA, "root", {
|
||||
f.render_widget(crate::tasks::Progress::new(&self.core), f.area());
|
||||
|
|
@ -71,29 +67,9 @@ impl App {
|
|||
});
|
||||
})?;
|
||||
|
||||
if COLLISION.load(Ordering::Relaxed) {
|
||||
Self::patch(frame);
|
||||
}
|
||||
succ!();
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn patch(frame: CompletedFrame) {
|
||||
let mut new = Buffer::empty(frame.area);
|
||||
for y in new.area.top()..new.area.bottom() {
|
||||
for x in new.area.left()..new.area.right() {
|
||||
let cell = &frame.buffer[(x, y)];
|
||||
if cell.skip {
|
||||
new[(x, y)] = cell.clone();
|
||||
}
|
||||
new[(x, y)].set_skip(!cell.skip);
|
||||
}
|
||||
}
|
||||
|
||||
let patches = frame.buffer.diff(&new);
|
||||
RatermBackend::new(&mut *TTY.lockout()).draw(patches.into_iter()).ok();
|
||||
}
|
||||
|
||||
fn routine(push: bool, cursor: Option<(Position, CursorStyle)>) {
|
||||
static COUNT: AtomicU8 = AtomicU8::new(0);
|
||||
if push && COUNT.fetch_add(1, Ordering::Relaxed) != 0 {
|
||||
|
|
|
|||
|
|
@ -123,9 +123,7 @@ impl Raterm {
|
|||
let buffer = frame.buffer_mut();
|
||||
for y in self.last_area.top()..self.last_area.bottom() {
|
||||
for x in self.last_area.left()..self.last_area.right() {
|
||||
let mut cell = self.last_buffer[(x, y)].clone();
|
||||
cell.skip = false;
|
||||
buffer[(x, y)] = cell;
|
||||
buffer[(x, y)] = self.last_buffer[(x, y)].clone();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
|
||||
use ratatui::{buffer::Buffer, layout::Rect, widgets::Widget};
|
||||
use ratatui::{buffer::{Buffer, CellDiffOption}, layout::Rect, widgets::Widget};
|
||||
use yazi_adapter::ADAPTOR;
|
||||
|
||||
pub static COLLISION: AtomicBool = AtomicBool::new(false);
|
||||
|
|
@ -23,7 +23,7 @@ impl Widget for Clear {
|
|||
COLLISION.store(true, Ordering::Relaxed);
|
||||
for y in r.top()..r.bottom() {
|
||||
for x in r.left()..r.right() {
|
||||
buf[(x, y)].set_skip(true);
|
||||
buf[(x, y)].set_diff_option(CellDiffOption::AlwaysUpdate);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue