Skip to content

Commit

Permalink
chore: upgrade ratatui to 0.28.1 (#1601)
Browse files Browse the repository at this point in the history
  • Loading branch information
sxyazi authored Sep 3, 2024
1 parent e940d81 commit ff04e2d
Show file tree
Hide file tree
Showing 18 changed files with 116 additions and 100 deletions.
134 changes: 69 additions & 65 deletions Cargo.lock

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,21 @@ panic = "abort"
strip = true

[workspace.dependencies]
ansi-to-tui = "5.0.0-rc.1"
ansi-to-tui = "6.0.0"
anyhow = "1.0.86"
arc-swap = "1.7.1"
base64 = "0.22.1"
bitflags = "2.6.0"
clap = { version = "4.5.16", features = [ "derive" ] }
crossterm = { version = "0.27.0", features = [ "event-stream" ] }
crossterm = { version = "0.28.1", features = [ "event-stream" ] }
dirs = "5.0.1"
futures = "0.3.30"
globset = "0.4.14"
libc = "0.2.158"
md-5 = "0.10.6"
mlua = { version = "0.9.9", features = [ "lua54", "serialize", "macros", "async" ] }
parking_lot = "0.12.3"
ratatui = { version = "0.27.0", features = [ "unstable-rendered-line-info" ] }
ratatui = { version = "0.28.1", features = [ "unstable-rendered-line-info" ] }
regex = "1.10.6"
scopeguard = "1.2.0"
serde = { version = "1.0.209", features = [ "derive" ] }
Expand Down
2 changes: 1 addition & 1 deletion yazi-adapter/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ tokio = { workspace = true }
tracing = { workspace = true }

[target.'cfg(target_os = "macos")'.dependencies]
crossterm = { workspace = true, features = [ "use-dev-tty" ] }
crossterm = { workspace = true, features = [ "use-dev-tty", "libc" ] }
2 changes: 1 addition & 1 deletion yazi-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ serde_json = { workspace = true }
vergen-gitcl = { version = "1.0.0", features = [ "build" ] }

[target.'cfg(target_os = "macos")'.dependencies]
crossterm = { workspace = true, features = [ "use-dev-tty" ] }
crossterm = { workspace = true, features = [ "use-dev-tty", "libc" ] }

[[bin]]
name = "ya"
Expand Down
2 changes: 1 addition & 1 deletion yazi-config/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ toml = { version = "0.8.19", features = [ "preserve_order" ] }
validator = { version = "0.18.1", features = [ "derive" ] }

[target.'cfg(target_os = "macos")'.dependencies]
crossterm = { workspace = true, features = [ "use-dev-tty" ] }
crossterm = { workspace = true, features = [ "use-dev-tty", "libc" ] }
2 changes: 1 addition & 1 deletion yazi-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ unicode-width = { workspace = true }
libc = { workspace = true }

[target.'cfg(target_os = "macos")'.dependencies]
crossterm = { workspace = true, features = [ "use-dev-tty" ] }
crossterm = { workspace = true, features = [ "use-dev-tty", "libc" ] }
2 changes: 1 addition & 1 deletion yazi-fm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ libc = { workspace = true }
signal-hook-tokio = { version = "0.3.1", features = [ "futures-v0_3" ] }

[target.'cfg(target_os = "macos")'.dependencies]
crossterm = { workspace = true, features = [ "use-dev-tty" ] }
crossterm = { workspace = true, features = [ "use-dev-tty", "libc" ] }

[target.'cfg(all(not(target_os = "macos"), not(target_os = "windows")))'.dependencies]
tikv-jemallocator = "0.6.0"
Expand Down
22 changes: 11 additions & 11 deletions yazi-fm/src/app/commands/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ impl App {
let collision = COLLISION.swap(false, Ordering::Relaxed);
let frame = term
.draw(|f| {
_ = Lives::scope(&self.cx, |_| Ok(f.render_widget(Root::new(&self.cx), f.size())));
_ = Lives::scope(&self.cx, |_| Ok(f.render_widget(Root::new(&self.cx), f.area())));

if let Some((x, y)) = self.cx.cursor() {
f.set_cursor(x, y);
if let Some(pos) = self.cx.cursor() {
f.set_cursor_position(pos);
}
})
.unwrap();
Expand Down Expand Up @@ -51,10 +51,10 @@ impl App {

let frame = term
.draw_partial(|f| {
f.render_widget(crate::notify::Layout::new(&self.cx), f.size());
f.render_widget(crate::notify::Layout::new(&self.cx), f.area());

if let Some((x, y)) = self.cx.cursor() {
f.set_cursor(x, y);
if let Some(pos) = self.cx.cursor() {
f.set_cursor_position(pos);
}
})
.unwrap();
Expand All @@ -69,20 +69,20 @@ impl App {
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.get(x, y);
let cell = &frame.buffer[(x, y)];
if cell.skip {
*new.get_mut(x, y) = cell.clone();
new[(x, y)] = cell.clone();
}
new.get_mut(x, y).set_skip(!cell.skip);
new[(x, y)].set_skip(!cell.skip);
}
}

let patches = frame.buffer.diff(&new);
let mut backend = CrosstermBackend::new(BufWriter::new(stderr().lock()));
backend.draw(patches.into_iter()).ok();
if let Some((x, y)) = cursor {
if let Some(pos) = cursor {
backend.show_cursor().ok();
backend.set_cursor(x, y).ok();
backend.set_cursor_position(pos).ok();
}
backend.flush().ok();
}
Expand Down
4 changes: 2 additions & 2 deletions yazi-fm/src/app/commands/update_progress.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ impl App {
_ = Lives::scope(&self.cx, |_| {
for patch in Progress::partial_render(term.current_buffer_mut()) {
term.backend_mut().draw(patch.iter().map(|(x, y, cell)| (*x, *y, cell)))?;
if let Some((x, y)) = self.cx.cursor() {
if let Some(pos) = self.cx.cursor() {
term.show_cursor()?;
term.set_cursor(x, y)?;
term.set_cursor_position(pos)?;
}
term.backend_mut().flush()?;
}
Expand Down
2 changes: 1 addition & 1 deletion yazi-fm/src/components/progress.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ impl Progress {
let mut patch = Vec::with_capacity(area.width as usize * area.height as usize);
for y in area.top()..area.bottom() {
for x in area.left()..area.right() {
patch.push((x, y, mem::take(buf.get_mut(x, y))));
patch.push((x, y, mem::take(&mut buf[(x, y)])));
}
}

Expand Down
6 changes: 3 additions & 3 deletions yazi-fm/src/term.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,9 @@ impl Term {
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.get(x, y).clone();
let mut cell = self.last_buffer[(x, y)].clone();
cell.skip = false;
*buffer.get_mut(x, y) = cell;
buffer[(x, y)] = cell;
}
}

Expand All @@ -130,7 +130,7 @@ impl Term {

#[inline]
pub(super) fn can_partial(&mut self) -> bool {
self.inner.autoresize().is_ok() && self.last_area == self.inner.get_frame().size()
self.inner.autoresize().is_ok() && self.last_area == self.inner.get_frame().area()
}

#[inline]
Expand Down
2 changes: 1 addition & 1 deletion yazi-plugin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@ uzers = { workspace = true }
clipboard-win = "5.4.0"

[target.'cfg(target_os = "macos")'.dependencies]
crossterm = { workspace = true, features = [ "use-dev-tty" ] }
crossterm = { workspace = true, features = [ "use-dev-tty", "libc" ] }
2 changes: 1 addition & 1 deletion yazi-plugin/src/bindings/range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ impl<'lua, T> IntoLua<'lua> for Range<T>
where
T: IntoLua<'lua>,
{
fn into_lua(self, lua: &'lua mlua::Lua) -> mlua::Result<mlua::Value> {
fn into_lua(self, lua: &'lua mlua::Lua) -> mlua::Result<mlua::Value<'lua>> {
lua.create_sequence_from([self.0.start, self.0.end])?.into_lua(lua)
}
}
8 changes: 4 additions & 4 deletions yazi-plugin/src/elements/bar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,15 @@ impl Renderable for Bar {

if self.direction.contains(Borders::LEFT) {
for y in self.area.top()..self.area.bottom() {
let cell = buf.get_mut(self.area.left(), y).set_symbol(symbol);
let cell = buf[(self.area.left(), y)].set_symbol(symbol);
if let Some(style) = self.style {
cell.set_style(style);
}
}
}
if self.direction.contains(Borders::TOP) {
for x in self.area.left()..self.area.right() {
let cell = buf.get_mut(x, self.area.top()).set_symbol(symbol);
let cell = buf[(x, self.area.top())].set_symbol(symbol);
if let Some(style) = self.style {
cell.set_style(style);
}
Expand All @@ -98,7 +98,7 @@ impl Renderable for Bar {
if self.direction.contains(Borders::RIGHT) {
let x = self.area.right() - 1;
for y in self.area.top()..self.area.bottom() {
let cell = buf.get_mut(x, y).set_symbol(symbol);
let cell = buf[(x, y)].set_symbol(symbol);
if let Some(style) = self.style {
cell.set_style(style);
}
Expand All @@ -107,7 +107,7 @@ impl Renderable for Bar {
if self.direction.contains(Borders::BOTTOM) {
let y = self.area.bottom() - 1;
for x in self.area.left()..self.area.right() {
let cell = buf.get_mut(x, y).set_symbol(symbol);
let cell = buf[(x, y)].set_symbol(symbol);
if let Some(style) = self.style {
cell.set_style(style);
}
Expand Down
2 changes: 1 addition & 1 deletion yazi-plugin/src/elements/clear.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ impl ratatui::widgets::Widget for Clear {
COLLISION.store(true, Ordering::Relaxed);
for y in r.top()..r.bottom() {
for x in r.left()..r.right() {
buf.get_mut(x, y).set_skip(true);
buf[(x, y)].set_skip(true);
}
}
}
Expand Down
14 changes: 13 additions & 1 deletion yazi-plugin/src/elements/rect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ impl Rect {
})
})?;

let rect = lua.create_table_from([("default", Rect::cast(lua, Default::default())?)])?;
let rect =
lua.create_table_from([("default", Rect::cast(lua, ratatui::layout::Rect::default())?)])?;

rect.set_metatable(Some(lua.create_table_from([("__call", new)])?));

Expand Down Expand Up @@ -57,3 +58,14 @@ impl Cast<ratatui::layout::Rect> for Rect {
lua.create_any_userdata(data)
}
}

impl Cast<ratatui::layout::Size> for Rect {
fn cast(lua: &Lua, data: ratatui::layout::Size) -> mlua::Result<AnyUserData> {
lua.create_any_userdata(ratatui::layout::Rect {
x: 0,
y: 0,
width: data.width,
height: data.height,
})
}
}
2 changes: 1 addition & 1 deletion yazi-scheduler/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ tracing = { workspace = true }
libc = { workspace = true }

[target.'cfg(not(target_os = "android"))'.dependencies]
trash = "5.1.0"
trash = "5.1.1"
2 changes: 1 addition & 1 deletion yazi-shared/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ uzers = { workspace = true }
windows-sys = { version = "0.59.0", features = [ "Win32_Storage_FileSystem", "Win32_UI_Shell" ] }

[target.'cfg(target_os = "macos")'.dependencies]
crossterm = { workspace = true, features = [ "use-dev-tty" ] }
crossterm = { workspace = true, features = [ "use-dev-tty", "libc" ] }

0 comments on commit ff04e2d

Please sign in to comment.