chore(dep): replace unmaintained dependency tui with ratatui (#6114)

This commit is contained in:
zerosnacks
2024-01-18 12:52:02 +01:00
committed by GitHub
parent 28921d966d
commit 7c9949962b
3 changed files with 48 additions and 43 deletions

70
Cargo.lock generated
View File

@ -1449,7 +1449,7 @@ version = "7.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7c64043d6c7b7a4c58e39e7efccfdea7b93d885a795d0c054a69dbbf4dd52686" checksum = "7c64043d6c7b7a4c58e39e7efccfdea7b93d885a795d0c054a69dbbf4dd52686"
dependencies = [ dependencies = [
"crossterm 0.27.0", "crossterm",
"strum", "strum",
"strum_macros", "strum_macros",
"unicode-width", "unicode-width",
@ -1664,22 +1664,6 @@ version = "0.8.19"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "248e3bacc7dc6baa3b21e405ee045c3047101a49145e7e9eca583ab4c2ca5345" checksum = "248e3bacc7dc6baa3b21e405ee045c3047101a49145e7e9eca583ab4c2ca5345"
[[package]]
name = "crossterm"
version = "0.25.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e64e6c0fbe2c17357405f7c758c1ef960fce08bdfb2c03d88d2a18d7e09c4b67"
dependencies = [
"bitflags 1.3.2",
"crossterm_winapi",
"libc",
"mio",
"parking_lot 0.12.1",
"signal-hook",
"signal-hook-mio",
"winapi",
]
[[package]] [[package]]
name = "crossterm" name = "crossterm"
version = "0.27.0" version = "0.27.0"
@ -3696,6 +3680,12 @@ dependencies = [
"serde", "serde",
] ]
[[package]]
name = "indoc"
version = "2.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e186cfbae8084e513daff4240b4797e342f988cecda4fb6c939150f96315fd8"
[[package]] [[package]]
name = "infer" name = "infer"
version = "0.2.3" version = "0.2.3"
@ -5517,6 +5507,25 @@ dependencies = [
"rand_core 0.6.4", "rand_core 0.6.4",
] ]
[[package]]
name = "ratatui"
version = "0.25.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a5659e52e4ba6e07b2dad9f1158f578ef84a73762625ddb51536019f34d180eb"
dependencies = [
"bitflags 2.4.1",
"cassowary",
"crossterm",
"indoc",
"itertools 0.12.0",
"lru 0.12.1",
"paste",
"stability",
"strum",
"unicode-segmentation",
"unicode-width",
]
[[package]] [[package]]
name = "raw-cpuid" name = "raw-cpuid"
version = "10.7.0" version = "10.7.0"
@ -5691,7 +5700,7 @@ dependencies = [
"comfy-table", "comfy-table",
"confy", "confy",
"const-str", "const-str",
"crossterm 0.27.0", "crossterm",
"dirs-next", "dirs-next",
"eyre", "eyre",
"fdlimit", "fdlimit",
@ -5714,6 +5723,7 @@ dependencies = [
"procfs", "procfs",
"proptest", "proptest",
"rand 0.8.5", "rand 0.8.5",
"ratatui",
"rayon", "rayon",
"reth-auto-seal-consensus", "reth-auto-seal-consensus",
"reth-basic-payload-builder", "reth-basic-payload-builder",
@ -5762,7 +5772,6 @@ dependencies = [
"tokio", "tokio",
"toml 0.8.8", "toml 0.8.8",
"tracing", "tracing",
"tui",
"vergen", "vergen",
] ]
@ -7806,6 +7815,16 @@ version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3b9b39299b249ad65f3b7e96443bad61c02ca5cd3589f46cb6d610a0fd6c0d6a" checksum = "3b9b39299b249ad65f3b7e96443bad61c02ca5cd3589f46cb6d610a0fd6c0d6a"
[[package]]
name = "stability"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ebd1b177894da2a2d9120208c3386066af06a488255caabc5de8ddca22dbc3ce"
dependencies = [
"quote",
"syn 1.0.109",
]
[[package]] [[package]]
name = "stable_deref_trait" name = "stable_deref_trait"
version = "1.2.0" version = "1.2.0"
@ -8657,19 +8676,6 @@ dependencies = [
"termcolor", "termcolor",
] ]
[[package]]
name = "tui"
version = "0.19.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ccdd26cbd674007e649a272da4475fb666d3aa0ad0531da7136db6fab0e5bad1"
dependencies = [
"bitflags 1.3.2",
"cassowary",
"crossterm 0.25.0",
"unicode-segmentation",
"unicode-width",
]
[[package]] [[package]]
name = "tungstenite" name = "tungstenite"
version = "0.20.1" version = "0.20.1"

View File

@ -90,7 +90,7 @@ rand.workspace = true
# tui # tui
comfy-table = "7.0" comfy-table = "7.0"
crossterm = "0.27.0" crossterm = "0.27.0"
tui = "0.19.0" ratatui = "0.25.0"
human_bytes = "0.4.1" human_bytes = "0.4.1"
# async # async

View File

@ -3,6 +3,13 @@ use crossterm::{
execute, execute,
terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen}, terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen},
}; };
use ratatui::{
backend::{Backend, CrosstermBackend},
layout::{Alignment, Constraint, Direction, Layout},
style::{Color, Modifier, Style},
widgets::{Block, Borders, List, ListItem, ListState, Paragraph, Wrap},
Frame, Terminal,
};
use reth_db::{ use reth_db::{
table::{Table, TableRow}, table::{Table, TableRow},
RawValue, RawValue,
@ -12,13 +19,6 @@ use std::{
time::{Duration, Instant}, time::{Duration, Instant},
}; };
use tracing::error; use tracing::error;
use tui::{
backend::{Backend, CrosstermBackend},
layout::{Alignment, Constraint, Corner, Direction, Layout},
style::{Color, Modifier, Style},
widgets::{Block, Borders, List, ListItem, ListState, Paragraph, Wrap},
Frame, Terminal,
};
/// Available keybindings for the [DbListTUI] /// Available keybindings for the [DbListTUI]
static CMDS: [(&str, &str); 6] = [ static CMDS: [(&str, &str); 6] = [
@ -356,7 +356,7 @@ where
} }
/// Render the UI /// Render the UI
fn ui<B: Backend, F, T: Table>(f: &mut Frame<'_, B>, app: &mut DbListTUI<F, T>) fn ui<F, T: Table>(f: &mut Frame<'_>, app: &mut DbListTUI<F, T>)
where where
F: FnMut(usize, usize) -> Vec<TableRow<T>>, F: FnMut(usize, usize) -> Vec<TableRow<T>>,
{ {
@ -392,8 +392,7 @@ where
))) )))
.style(Style::default().fg(Color::White)) .style(Style::default().fg(Color::White))
.highlight_style(Style::default().fg(Color::Cyan).add_modifier(Modifier::ITALIC)) .highlight_style(Style::default().fg(Color::Cyan).add_modifier(Modifier::ITALIC))
.highlight_symbol("") .highlight_symbol("");
.start_corner(Corner::TopLeft);
f.render_stateful_widget(key_list, inner_chunks[0], &mut app.list_state); f.render_stateful_widget(key_list, inner_chunks[0], &mut app.list_state);
let value_display = Paragraph::new( let value_display = Paragraph::new(