diff --git a/Cargo.lock b/Cargo.lock index f05084e..4ff9d1c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,6 +2,18 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "ahash" +version = "0.8.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" +dependencies = [ + "cfg-if", + "once_cell", + "version_check", + "zerocopy", +] + [[package]] name = "aho-corasick" version = "1.1.2" @@ -11,6 +23,12 @@ dependencies = [ "memchr", ] +[[package]] +name = "allocator-api2" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" + [[package]] name = "android-tzdata" version = "0.1.1" @@ -120,6 +138,15 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "df8670b8c7b9dae1793364eafadf7239c40d669904660c5960d74cfd80b46a53" +[[package]] +name = "castaway" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a17ed5635fc8536268e5d4de1e22e81ac34419e5f052d4d51f4e01dcc263fcc" +dependencies = [ + "rustversion", +] + [[package]] name = "cc" version = "1.0.86" @@ -184,7 +211,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn", + "syn 2.0.50", ] [[package]] @@ -199,6 +226,19 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" +[[package]] +name = "compact_str" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f86b9c4c00838774a6d902ef931eff7470720c51d90c2e32cfe15dc304737b3f" +dependencies = [ + "castaway", + "cfg-if", + "itoa", + "ryu", + "static_assertions", +] + [[package]] name = "core-foundation-sys" version = "0.8.6" @@ -221,6 +261,22 @@ dependencies = [ "winapi", ] +[[package]] +name = "crossterm" +version = "0.27.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f476fe445d41c9e991fd07515a6f463074b782242ccf4a5b7b1d1012e70824df" +dependencies = [ + "bitflags 2.4.2", + "crossterm_winapi", + "libc", + "mio", + "parking_lot", + "signal-hook", + "signal-hook-mio", + "winapi", +] + [[package]] name = "crossterm_winapi" version = "0.9.1" @@ -240,6 +296,12 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "either" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11157ac094ffbdde99aa67b23417ebdd801842852b500e395a45a9c0aac03e4a" + [[package]] name = "equivalent" version = "1.0.1" @@ -302,7 +364,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.50", ] [[package]] @@ -351,6 +413,10 @@ name = "hashbrown" version = "0.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" +dependencies = [ + "ahash", + "allocator-api2", +] [[package]] name = "heck" @@ -405,6 +471,12 @@ dependencies = [ "hashbrown", ] +[[package]] +name = "indoc" +version = "2.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e186cfbae8084e513daff4240b4797e342f988cecda4fb6c939150f96315fd8" + [[package]] name = "io-kit-sys" version = "0.4.0" @@ -415,6 +487,15 @@ dependencies = [ "mach2", ] +[[package]] +name = "itertools" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" +dependencies = [ + "either", +] + [[package]] name = "itoa" version = "1.0.10" @@ -472,6 +553,15 @@ version = "0.4.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" +[[package]] +name = "lru" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3262e75e648fce39813cb56ac41f3c3e3f65217ebf3844d818d1f9398cfb0dc" +dependencies = [ + "hashbrown", +] + [[package]] name = "mach2" version = "0.4.2" @@ -571,6 +661,12 @@ dependencies = [ "windows-targets 0.48.5", ] +[[package]] +name = "paste" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" + [[package]] name = "pin-project-lite" version = "0.2.13" @@ -643,6 +739,26 @@ dependencies = [ "getrandom", ] +[[package]] +name = "ratatui" +version = "0.26.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bcb12f8fbf6c62614b0d56eb352af54f6a22410c3b079eb53ee93c7b97dd31d8" +dependencies = [ + "bitflags 2.4.2", + "cassowary", + "compact_str", + "crossterm 0.27.0", + "indoc", + "itertools", + "lru", + "paste", + "stability", + "strum", + "unicode-segmentation", + "unicode-width", +] + [[package]] name = "redox_syscall" version = "0.4.1" @@ -705,6 +821,12 @@ dependencies = [ "pkg-config", ] +[[package]] +name = "rustversion" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4" + [[package]] name = "ryu" version = "1.0.17" @@ -718,16 +840,16 @@ dependencies = [ "anyhow", "chrono", "clap", - "crossterm", + "crossterm 0.25.0", "ctrlc", "homedir", "rand", + "ratatui", "regex", "rlua", "serde", "serde_yaml", "serialport", - "tui", ] [[package]] @@ -753,7 +875,7 @@ checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.50", ] [[package]] @@ -833,12 +955,61 @@ version = "1.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6ecd384b10a64542d77071bd64bd7b231f4ed5940fba55e98c3de13824cf3d7" +[[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]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + [[package]] name = "strsim" version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5ee073c9e4cd00e28217186dbe12796d692868f432bf2e97ee73bed0c56dfa01" +[[package]] +name = "strum" +version = "0.26.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d8cec3501a5194c432b2b7976db6b7d10ec95c253208b45f83f7136aa985e29" +dependencies = [ + "strum_macros", +] + +[[package]] +name = "strum_macros" +version = "0.26.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6cf59daf282c0a494ba14fd21610a0325f9f90ec9d1231dea26bcb1d696c946" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "rustversion", + "syn 2.0.50", +] + +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + [[package]] name = "syn" version = "2.0.50" @@ -867,20 +1038,7 @@ checksum = "a953cb265bef375dae3de6663da4d3804eee9682ea80d8e2542529b73c531c81" dependencies = [ "proc-macro2", "quote", - "syn", -] - -[[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", - "unicode-segmentation", - "unicode-width", + "syn 2.0.50", ] [[package]] @@ -922,6 +1080,12 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" @@ -949,7 +1113,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn", + "syn 2.0.50", "wasm-bindgen-shared", ] @@ -971,7 +1135,7 @@ checksum = "642f325be6301eb8107a83d12a8ac6c1e1c54345a7ef1a9261962dfefda09e66" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.50", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -1039,7 +1203,7 @@ checksum = "12168c33176773b86799be25e2a2ba07c7aab9968b37541f1094dbd7a60c8946" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.50", ] [[package]] @@ -1050,7 +1214,7 @@ checksum = "9d8dc32e0095a7eeccebd0e3f09e9509365ecb3fc6ac4d6f5f14a3f6392942d1" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.50", ] [[package]] @@ -1198,3 +1362,23 @@ dependencies = [ "thiserror", "windows", ] + +[[package]] +name = "zerocopy" +version = "0.7.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74d4d3961e53fa4c9a25a8637fc2bfaf2595b3d3ae34875568a5cf64787716be" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.50", +] diff --git a/Cargo.toml b/Cargo.toml index 0441aeb..8738564 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,7 +21,7 @@ path = "src/main.rs" [dependencies] serialport = "4.3.0" -tui = "0.19.0" +ratatui = "0.26.1" crossterm = "0.25.0" chrono = "0.4.23" serde = "1.0" diff --git a/src/command_bar.rs b/src/command_bar.rs index 8200a48..d31c568 100644 --- a/src/command_bar.rs +++ b/src/command_bar.rs @@ -4,10 +4,14 @@ use crate::messages::{SerialRxData, UserTxData}; use crate::plugin_manager::PluginManager; use crate::serial::SerialIF; use crate::text::TextView; -use crate::ConcreteBackend; use chrono::Local; use crossterm::event::{Event, KeyCode, KeyEvent, KeyModifiers, MouseEventKind}; use rand::seq::SliceRandom; +use ratatui::layout::{Constraint, Direction, Layout, Rect}; +use ratatui::style::{Color, Style}; +use ratatui::text::{Line, Span}; +use ratatui::widgets::{Block, BorderType, Borders, Clear, Paragraph}; +use ratatui::Frame; use std::cmp::{max, min}; use std::collections::btree_map::BTreeMap; use std::collections::HashMap; @@ -17,11 +21,6 @@ use std::sync::{Arc, Mutex}; use std::thread; use std::thread::sleep; use std::time::Duration; -use tui::layout::{Constraint, Direction, Layout, Rect}; -use tui::style::{Color, Style}; -use tui::text::{Span, Spans}; -use tui::widgets::{Block, BorderType, Borders, Clear, Paragraph}; -use tui::Frame; pub struct CommandBar { interface: Arc>, @@ -103,7 +102,7 @@ impl CommandBar { } } - pub fn draw(&self, f: &mut Frame) { + pub fn draw(&self, f: &mut Frame) { let chunks = Layout::default() .direction(Direction::Vertical) .constraints( @@ -567,7 +566,7 @@ impl CommandList { self.pattern = pattern; } - pub fn draw(&self, f: &mut Frame, command_bar_y: u16, color: Color) { + pub fn draw(&self, f: &mut Frame, command_bar_y: u16, color: Color) { if self.commands.is_empty() { return; } @@ -598,7 +597,7 @@ impl CommandList { let is_last = (x == commands.last().unwrap()) && (commands.len() < self.commands.len()); - Spans::from(vec![ + Line::from(vec![ Span::styled( format!(" {}", if !is_last { &self.pattern } else { "" }), Style::default().fg(color), diff --git a/src/error_pop_up.rs b/src/error_pop_up.rs index d3f21cb..74e9bbb 100644 --- a/src/error_pop_up.rs +++ b/src/error_pop_up.rs @@ -1,10 +1,9 @@ -use crate::ConcreteBackend; +use ratatui::layout::{Alignment, Rect}; +use ratatui::style::{Color, Style}; +use ratatui::text::Span; +use ratatui::widgets::{Block, Borders, Clear, Paragraph}; +use ratatui::Frame; use std::time::{Duration, Instant}; -use tui::layout::{Alignment, Rect}; -use tui::style::{Color, Style}; -use tui::text::Span; -use tui::widgets::{Block, Borders, Clear, Paragraph}; -use tui::Frame; pub struct ErrorPopUp { message: String, @@ -21,7 +20,7 @@ impl ErrorPopUp { } } - pub fn draw(&self, f: &mut Frame, command_bar_y: u16) { + pub fn draw(&self, f: &mut Frame, command_bar_y: u16) { let area_size = (self.message.chars().count() as u16 + 4, 3); let area = Rect::new( (f.size().width - area_size.0) / 2, diff --git a/src/main.rs b/src/main.rs index 1f5d94b..77a69d7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -11,11 +11,11 @@ use crossterm::execute; use crossterm::terminal::{ disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen, }; +use ratatui::backend::{Backend, CrosstermBackend}; +use ratatui::Terminal; use std::io; use std::io::Stdout; use std::path::PathBuf; -use tui::backend::{Backend, CrosstermBackend}; -use tui::Terminal; mod command_bar; mod error_pop_up; diff --git a/src/messages.rs b/src/messages.rs index e0143e2..4821336 100644 --- a/src/messages.rs +++ b/src/messages.rs @@ -1,7 +1,7 @@ use crate::rich_string::RichText; use crate::text::ViewData; use chrono::{DateTime, Local}; -use tui::style::Color; +use ratatui::style::Color; pub enum UserTxData { Exit, diff --git a/src/rich_string.rs b/src/rich_string.rs index 032c81f..5e2e4e1 100644 --- a/src/rich_string.rs +++ b/src/rich_string.rs @@ -1,8 +1,8 @@ use crate::text::ViewData; use chrono::{DateTime, Local}; +use ratatui::style::{Color, Style}; +use ratatui::text::Span; use std::collections::HashMap; -use tui::style::{Color, Style}; -use tui::text::Span; pub struct RichText { content: Vec, diff --git a/src/text.rs b/src/text.rs index ec97582..26434c1 100644 --- a/src/text.rs +++ b/src/text.rs @@ -1,12 +1,11 @@ use crate::messages::SerialRxData; use crate::rich_string::RichText; -use crate::ConcreteBackend; use chrono::{DateTime, Local}; -use tui::layout::Rect; -use tui::style::{Color, Modifier, Style}; -use tui::text::{Span, Spans}; -use tui::widgets::{Block, BorderType, Borders, Paragraph}; -use tui::Frame; +use ratatui::layout::Rect; +use ratatui::style::{Color, Modifier, Style}; +use ratatui::text::{Line, Span}; +use ratatui::widgets::{Block, BorderType, Borders, Paragraph}; +use ratatui::Frame; pub struct TextView { history: Vec, @@ -38,7 +37,7 @@ impl TextView { } } - pub fn draw(&self, f: &mut Frame, rect: Rect) { + pub fn draw(&self, f: &mut Frame, rect: Rect) { let scroll = if self.auto_scroll { (self.max_main_axis(), self.scroll.1) } else { @@ -87,7 +86,7 @@ impl TextView { })) .collect::>(); - Spans::from(content) + Line::from(content) }) .collect::>(); let paragraph = Paragraph::new(text).block(block);