Skip to content

Commit

Permalink
feat: migrate to ratatui (#26)
Browse files Browse the repository at this point in the history
Co-authored-by: Ben PHL <benphawke@gmail.com>
  • Loading branch information
EdJoPaTo and Ben-PH committed Sep 4, 2023
1 parent 100a816 commit 3f30eff
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ include = ["src/**/*", "README.md"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
tui = { version = "0.19", default-features = false }
ratatui = { version = "0.23", default-features = false }
unicode-width = "0.1"

[dev-dependencies]
crossterm = "0.27"
tui = "0.19"
ratatui = "0.23"
4 changes: 2 additions & 2 deletions examples/example.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ use crossterm::{
execute,
terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen},
};
use std::{error::Error, io};
use tui::{
use ratatui::{
backend::{Backend, CrosstermBackend},
style::{Color, Modifier, Style},
widgets::{Block, Borders},
Terminal,
};
use std::{error::Error, io};

use tui_tree_widget::{Tree, TreeItem};

Expand Down
4 changes: 2 additions & 2 deletions src/flatten.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ fn internal<'a>(
}

#[cfg(test)]
fn get_naive_string_from_text(text: &tui::text::Text<'_>) -> String {
fn get_naive_string_from_text(text: &ratatui::text::Text<'_>) -> String {
text.lines
.first()
.unwrap()
.0
.spans
.first()
.unwrap()
.content
Expand Down
18 changes: 9 additions & 9 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

use std::collections::HashSet;

use tui::buffer::Buffer;
use tui::layout::{Corner, Rect};
use tui::style::Style;
use tui::text::Text;
use tui::widgets::{Block, StatefulWidget, Widget};
use ratatui::buffer::Buffer;
use ratatui::layout::{Corner, Rect};
use ratatui::style::Style;
use ratatui::text::Text;
use ratatui::widgets::{Block, StatefulWidget, Widget};
use unicode_width::UnicodeWidthStr;

mod flatten;
Expand Down Expand Up @@ -247,9 +247,9 @@ impl<'a> TreeItem<'a> {
///
/// ```
/// # use tui_tree_widget::{Tree, TreeItem, TreeState};
/// # use tui::backend::TestBackend;
/// # use tui::Terminal;
/// # use tui::widgets::{Block, Borders};
/// # use ratatui::backend::TestBackend;
/// # use ratatui::Terminal;
/// # use ratatui::widgets::{Block, Borders};
/// # fn main() -> std::io::Result<()> {
/// # let mut terminal = Terminal::new(TestBackend::new(32, 32)).unwrap();
/// let mut state = TreeState::default();
Expand Down Expand Up @@ -480,7 +480,7 @@ impl<'a> StatefulWidget for Tree<'a> {

let max_element_width = area.width.saturating_sub(after_depth_x - x);
for (j, line) in item.item.text.lines.iter().enumerate() {
buf.set_spans(after_depth_x, y + j as u16, line, max_element_width);
buf.set_line(after_depth_x, y + j as u16, line, max_element_width);
}
if is_selected {
buf.set_style(area, self.highlight_style);
Expand Down

0 comments on commit 3f30eff

Please sign in to comment.