diff --git a/Cargo.lock b/Cargo.lock index f4731fc..5ba50de 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -17,6 +17,24 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" +[[package]] +name = "ahash" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91429305e9f0a25f6205c5b8e0d2db09e0708a7a6df0f42212bb56c32c8ac97a" +dependencies = [ + "cfg-if", + "once_cell", + "version_check", + "zerocopy", +] + +[[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" @@ -109,9 +127,9 @@ dependencies = [ [[package]] name = "base64" -version = "0.21.4" +version = "0.21.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ba43ea6f343b788c8764558649e08df62f86c6ef251fdaeb1ffd010a9ae50a2" +checksum = "35636a1494ede3b646cc98f74f8e62c773a38a659ebc777a2cf26b9b74171df9" [[package]] name = "bitflags" @@ -219,9 +237,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.4.6" +version = "4.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d04704f56c2cde07f43e8e2c154b43f216dc5c92fc98ada720177362f953b956" +checksum = "ac495e00dcec98c83465d5ad66c5c4fabd652fd6686e7c6269b117e729a6f17b" dependencies = [ "clap_builder", "clap_derive", @@ -229,9 +247,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.4.6" +version = "4.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e231faeaca65ebd1ea3c737966bf858971cd38c3849107aa3ea7de90a804e45" +checksum = "c77ed9a32a62e6ca27175d00d29d05ca32e396ea1eb5fb01d8256b669cec7663" dependencies = [ "anstream", "anstyle", @@ -243,9 +261,9 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.4.2" +version = "4.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0862016ff20d69b84ef8247369fabf5c008a7417002411897d40ee1f4532b873" +checksum = "cf9804afaaf59a91e75b022a30fb7229a7901f60c755489cc61c9b423b836442" dependencies = [ "heck", "proc-macro2", @@ -255,9 +273,9 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.5.1" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd7cc57abe963c6d3b9d8be5b06ba7c8957a930305ca90304f24ef040aa6f961" +checksum = "702fc72eb24e5a1e48ce58027a675bc24edd52096d5397d4aea7c6dd9eca0bd1" [[package]] name = "colorchoice" @@ -432,6 +450,10 @@ name = "hashbrown" version = "0.14.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f93e7192158dbcda357bdec5fb5788eebf8bbac027f3f33e719d29135ae84156" +dependencies = [ + "ahash", + "allocator-api2", +] [[package]] name = "heck" @@ -635,6 +657,15 @@ version = "0.4.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" +[[package]] +name = "lru" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1efa59af2ddfad1854ae27d75009d538d0998b4b2fd47083e743ac1a10e46c60" +dependencies = [ + "hashbrown 0.14.2", +] + [[package]] name = "memchr" version = "2.6.4" @@ -652,9 +683,9 @@ dependencies = [ [[package]] name = "mio" -version = "0.8.8" +version = "0.8.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "927a765cd3fc26206e66b296465fa9d3e5ab003e651c1b3c060e7956d96b19d2" +checksum = "3dce281c5e46beae905d4de1870d8b1509a9142b62eedf18b443b011ca8343d0" dependencies = [ "libc", "log", @@ -859,15 +890,16 @@ dependencies = [ [[package]] name = "ratatui" -version = "0.23.0" +version = "0.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e2e4cd95294a85c3b4446e63ef054eea43e0205b1fd60120c16b74ff7ff96ad" +checksum = "0ebc917cfb527a566c37ecb94c7e3fd098353516fb4eb6bea17015ade0182425" dependencies = [ "bitflags 2.4.1", "cassowary", "crossterm", "indoc", "itertools", + "lru", "paste", "strum", "unicode-segmentation", @@ -1196,9 +1228,9 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.9" +version = "0.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d68074620f57a0b21594d9735eb2e98ab38b17f80d3fcb189fca266771ca60d" +checksum = "5419f34732d9eb6ee4c3578b7989078579b7f039cbbb9ca2c4da015749371e15" dependencies = [ "bytes", "futures-core", @@ -1248,12 +1280,12 @@ dependencies = [ [[package]] name = "tracing-log" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78ddad33d2d10b1ed7eb9d1f518a5674713876e97e5bb9b7345a7984fbb4f922" +checksum = "f751112709b4e791d8ce53e32c4ed2d353565a795ce84da2285393f41557bdf2" dependencies = [ - "lazy_static", "log", + "once_cell", "tracing-core", ] @@ -1523,3 +1555,23 @@ name = "windows_x86_64_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" + +[[package]] +name = "zerocopy" +version = "0.7.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81ba595b9f2772fbee2312de30eeb80ec773b4cb2f1e8098db024afadda6c06f" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "772666c41fb6dceaf520b564b962d738a8e1a83b41bd48945f50837aed78bb1d" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] diff --git a/Cargo.toml b/Cargo.toml index e0055f6..9adde00 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,7 +22,7 @@ parking_lot = { version= "0.12" } tokio = { version = "1.33", features = ["full"] } tracing = "0.1" tracing-subscriber = "0.3" -ratatui = "0.23" +ratatui = "0.24" uuid = { version = "1.5", features = ["v4", "fast-rng"] } [dev-dependencies] diff --git a/src/ui/draw_blocks.rs b/src/ui/draw_blocks.rs index 4080966..da3c3c2 100644 --- a/src/ui/draw_blocks.rs +++ b/src/ui/draw_blocks.rs @@ -1,6 +1,5 @@ use parking_lot::Mutex; use ratatui::{ - backend::Backend, layout::{Alignment, Constraint, Direction, Layout, Rect}, style::{Color, Modifier, Style}, symbols, @@ -85,10 +84,10 @@ fn generate_block<'a>( } /// Draw the command panel -pub fn commands( +pub fn commands( app_data: &Arc>, area: Rect, - f: &mut Frame<'_, B>, + f: &mut Frame, gui_state: &Arc>, ) { let block = || generate_block(app_data, area, gui_state, SelectablePanel::Commands); @@ -120,10 +119,10 @@ pub fn commands( } /// Draw the containers panel -pub fn containers( +pub fn containers( app_data: &Arc>, area: Rect, - f: &mut Frame<'_, B>, + f: &mut Frame, gui_state: &Arc>, widths: &Columns, ) { @@ -219,10 +218,10 @@ pub fn containers( } /// Draw the logs panel -pub fn logs( +pub fn logs( app_data: &Arc>, area: Rect, - f: &mut Frame<'_, B>, + f: &mut Frame, gui_state: &Arc>, loading_icon: &str, ) { @@ -256,7 +255,7 @@ pub fn logs( } /// Draw the cpu + mem charts -pub fn chart(f: &mut Frame<'_, B>, area: Rect, app_data: &Arc>) { +pub fn chart(f: &mut Frame, area: Rect, app_data: &Arc>) { if let Some((cpu, mem)) = app_data.lock().get_chart_data() { let area = Layout::default() .direction(Direction::Horizontal) @@ -337,10 +336,10 @@ fn make_chart<'a, T: Stats + Display>( /// Draw heading bar at top of program, always visible /// TODO Should separate into loading icon/headers/help functions #[allow(clippy::too_many_lines)] -pub fn heading_bar( +pub fn heading_bar( area: Rect, columns: &Columns, - f: &mut Frame<'_, B>, + f: &mut Frame, has_containers: bool, loading_icon: &str, sorted_by: Option<(Header, SortedOrder)>, @@ -646,7 +645,7 @@ impl HelpInfo { } /// Draw the help box in the centre of the screen -pub fn help_box(f: &mut Frame<'_, B>) { +pub fn help_box(f: &mut Frame) { let title = format!(" {VERSION} "); let name_info = HelpInfo::gen_name(); @@ -725,8 +724,8 @@ pub fn help_box(f: &mut Frame<'_, B>) { /// Draw the delete confirm box in the centre of the screen /// take in container id and container name here? -pub fn delete_confirm( - f: &mut Frame<'_, B>, +pub fn delete_confirm( + f: &mut Frame, gui_state: &Arc>, name: &str, ) { @@ -834,7 +833,7 @@ pub fn delete_confirm( } /// Draw an error popup over whole screen -pub fn error(f: &mut Frame<'_, B>, error: AppError, seconds: Option) { +pub fn error(f: &mut Frame, error: AppError, seconds: Option) { let block = Block::default() .title(" Error ") .border_type(BorderType::Rounded) @@ -876,7 +875,7 @@ pub fn error(f: &mut Frame<'_, B>, error: AppError, seconds: Option< } /// Draw info box in one of the 9 BoxLocations -pub fn info(f: &mut Frame<'_, B>, text: String) { +pub fn info(f: &mut Frame, text: String) { let block = Block::default() .title("") .title_alignment(Alignment::Center) @@ -928,7 +927,7 @@ fn popup(text_lines: usize, text_width: usize, r: Rect, box_location: BoxLocatio } // Draw nothing, as in a blank screen -// pub fn nothing(f: &mut Frame<'_, B>) { +// pub fn nothing(f: &mut Frame) { // let whole_layout = Layout::default() // .direction(Direction::Vertical) // .constraints([Constraint::Min(100)].as_ref()) diff --git a/src/ui/mod.rs b/src/ui/mod.rs index c8b8da6..b7c3a1f 100644 --- a/src/ui/mod.rs +++ b/src/ui/mod.rs @@ -6,7 +6,7 @@ use crossterm::{ }; use parking_lot::Mutex; use ratatui::{ - backend::{Backend, CrosstermBackend}, + backend::CrosstermBackend, layout::{Constraint, Direction, Layout}, Frame, Terminal, }; @@ -208,8 +208,8 @@ macro_rules! value_capture { /// Draw the main ui to a frame of the terminal /// TODO add a single line area for debug message - if not in release mode? -fn draw_frame( - f: &mut Frame<'_, B>, +fn draw_frame( + f: &mut Frame, app_data: &Arc>, gui_state: &Arc>, ) {