Skip to content

Commit

Permalink
fix deprecated ratatui code
Browse files Browse the repository at this point in the history
  • Loading branch information
kamiyaa committed Aug 13, 2024
1 parent ef2a3dc commit 24520a4
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/commands/bookmark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ fn poll_for_bookmark_key(app_state: &mut AppState, backend: &mut AppBackend) ->
let terminal = backend.terminal_mut();
loop {
let _ = terminal.draw(|frame| {
let area = frame.size();
let area = frame.area();
if area.height < 5 {
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/types/state/preview_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ impl PreviewState {
} else {
path.clone()
};
let proto = image::io::Reader::open(thumb_path.as_path())
let proto = image::ImageReader::open(thumb_path.as_path())
.and_then(|reader| reader.decode().map_err(Self::map_io_err))
.and_then(|dyn_img| {
picker
Expand Down
2 changes: 1 addition & 1 deletion src/ui/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ impl AppBackend {
W: Widget,
{
let _ = self.terminal_mut().draw(|frame| {
let rect = frame.size();
let rect = frame.area();
frame.render_widget(widget, rect);
});
}
Expand Down
23 changes: 14 additions & 9 deletions src/ui/views/tui_folder_view.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use ratatui::buffer::Buffer;
use ratatui::layout::{Constraint, Direction, Layout, Rect};
use ratatui::buffer::{Buffer, Cell};
use ratatui::layout::{Constraint, Direction, Layout, Position, Rect};
use ratatui::style::{Color, Style};
use ratatui::symbols::line::{HORIZONTAL_DOWN, HORIZONTAL_UP};
use ratatui::text::Span;
Expand Down Expand Up @@ -254,15 +254,20 @@ struct Intersections {

impl Intersections {
fn render_left(&self, buf: &mut Buffer) {
buf.get_mut(self.left, self.top).set_symbol(HORIZONTAL_DOWN);
buf.get_mut(self.left, self.bottom)
.set_symbol(HORIZONTAL_UP);
if let Some(cell) = buf.cell_mut(Position::new(self.left, self.top)) {
*cell = Cell::new(HORIZONTAL_DOWN);
}
if let Some(cell) = buf.cell_mut(Position::new(self.left, self.bottom)) {
*cell = Cell::new(HORIZONTAL_UP);
}
}
fn render_right(&self, buf: &mut Buffer) {
buf.get_mut(self.right, self.top)
.set_symbol(HORIZONTAL_DOWN);
buf.get_mut(self.right, self.bottom)
.set_symbol(HORIZONTAL_UP);
if let Some(cell) = buf.cell_mut(Position::new(self.right, self.top)) {
*cell = Cell::new(HORIZONTAL_DOWN);
}
if let Some(cell) = buf.cell_mut(Position::new(self.right, self.bottom)) {
*cell = Cell::new(HORIZONTAL_UP);
}
}
}

Expand Down
9 changes: 6 additions & 3 deletions src/ui/views/tui_textfield.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use rustyline::line_buffer::{self, ChangeListener, DeleteListener, Direction, Li
use rustyline::{At, Word};

use lazy_static::lazy_static;
use ratatui::layout::Rect;
use ratatui::layout::{Position, Rect};
use ratatui::widgets::Clear;
use termion::event::{Event, Key};
use unicode_width::UnicodeWidthStr;
Expand Down Expand Up @@ -158,7 +158,7 @@ impl<'a> TuiTextField<'a> {
loop {
terminal
.draw(|frame| {
let area: Rect = frame.size();
let area: Rect = frame.area();
if area.height == 0 {
return;
}
Expand Down Expand Up @@ -220,7 +220,10 @@ impl<'a> TuiTextField<'a> {
frame.render_widget(multiline, multiline_rect);

// render cursor
frame.set_cursor(cursor_info.x as u16, cursor_info.y as u16);
frame.set_cursor_position(Position::new(
cursor_info.x as u16,
cursor_info.y as u16,
));
})
.unwrap();

Expand Down
2 changes: 1 addition & 1 deletion src/ui/widgets/tui_prompt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ impl<'a> TuiPrompt<'a> {
app_state.flush_event();
loop {
let _ = terminal.draw(|frame| {
let f_size: Rect = frame.size();
let f_size: Rect = frame.area();
if f_size.height == 0 {
return;
}
Expand Down

0 comments on commit 24520a4

Please sign in to comment.