diff options
author | extrawurst <mail@rusticorn.com> | 2024-02-20 14:59:33 +0100 |
---|---|---|
committer | extrawurst <776816+extrawurst@users.noreply.github.com> | 2024-02-20 15:41:31 +0100 |
commit | 2b39c6465aa01b06600040053fe3086f92590692 (patch) | |
tree | a02c7fe9ac73c97bf2bc70d97b8aef2a4516db77 | |
parent | 45c34e5675e83285f99db77309dd1c6b78fc245f (diff) |
ratatui 0.24 update
53 files changed, 168 insertions, 337 deletions
@@ -18,6 +18,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" [[package]] +name = "ahash" +version = "0.8.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d713b3834d76b85304d4d525563c1276e2e30dc97cc67bfb4585a4a29fc2c89f" +dependencies = [ + "cfg-if", + "once_cell", + "version_check", + "zerocopy", +] + +[[package]] name = "aho-corasick" version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -27,6 +39,12 @@ dependencies = [ ] [[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" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -752,6 +770,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" @@ -995,6 +1017,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" [[package]] +name = "lru" +version = "0.12.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db2c024b41519440580066ba82aab04092b333e09066a5eb86c7c4890df31f22" +dependencies = [ + "hashbrown", +] + +[[package]] name = "memchr" version = "2.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1244,15 +1275,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.2", "cassowary", "crossterm", "indoc", "itertools 0.11.0", + "lru", "paste", "serde", "strum", @@ -1781,6 +1813,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" [[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + +[[package]] name = "walkdir" version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -2040,3 +2078,23 @@ name = "yansi" version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09041cd90cf85f7f8b2df60c646f853b7f535ce68f85244eb6731cf89fa498ec" + +[[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", +] @@ -36,7 +36,7 @@ log = "0.4" notify = "6.1" notify-debouncer-mini = "0.4" once_cell = "1" -ratatui = { version = "0.23", default-features = false, features = [ +ratatui = { version = "0.24", default-features = false, features = [ 'crossterm', 'serde', ] } @@ -42,7 +42,6 @@ use asyncgit::{ use crossbeam_channel::Sender; use crossterm::event::{Event, KeyEvent}; use ratatui::{ - backend::Backend, layout::{ Alignment, Constraint, Direction, Layout, Margin, Rect, }, @@ -227,7 +226,7 @@ impl App { } /// - pub fn draw<B: Backend>(&self, f: &mut Frame<B>) -> Result<()> { + pub fn draw(&self, f: &mut Frame) -> Result<()> { let fsize = f.size(); self.cmdbar.borrow_mut().refresh_width(fsize.width); @@ -1070,7 +1069,7 @@ impl App { } //TODO: make this dynamic - fn draw_top_bar<B: Backend>(&self, f: &mut Frame<B>, r: Rect) { + fn draw_top_bar(&self, f: &mut Frame, r: Rect) { const DIVIDER_PAD_SPACES: usize = 2; const SIDE_PADS: usize = 2; const MARGIN_LEFT_AND_RIGHT: usize = 2; diff --git a/src/cmdbar.rs b/src/cmdbar.rs index 2479cc31..790d0f09 100644 --- a/src/cmdbar.rs +++ b/src/cmdbar.rs @@ -3,7 +3,6 @@ use crate::{ ui::style::SharedTheme, }; use ratatui::{ - backend::Backend, layout::{Alignment, Rect}, text::{Line, Span}, widgets::Paragraph, @@ -139,7 +138,7 @@ impl CommandBar { } } - pub fn draw<B: Backend>(&self, f: &mut Frame<B>, r: Rect) { + pub fn draw(&self, f: &mut Frame, r: Rect) { if r.width < MORE_WIDTH { return; } diff --git a/src/components/changes.rs b/src/components/changes.rs index 30c0ab68..e2a32cb0 100644 --- a/src/components/changes.rs +++ b/src/components/changes.rs @@ -17,7 +17,7 @@ use asyncgit::{ StatusItem, StatusItemType, }; use crossterm::event::Event; -use ratatui::{backend::Backend, layout::Rect, Frame}; +use ratatui::{layout::Rect, Frame}; use std::path::Path; /// @@ -187,11 +187,7 @@ impl ChangesComponent { } impl DrawableComponent for ChangesComponent { - fn draw<B: Backend>( - &self, - f: &mut Frame<B>, - r: Rect, - ) -> Result<()> { + fn draw(&self, f: &mut Frame, r: Rect) -> Result<()> { self.files.draw(f, r)?; Ok(()) diff --git a/src/components/commit_details/compare_details.rs b/src/components/commit_details/compare_details.rs index 2e908b2b..e10974f3 100644 --- a/src/components/commit_details/compare_details.rs +++ b/src/components/commit_details/compare_details.rs @@ -18,7 +18,6 @@ use asyncgit::sync::{ }; use crossterm::event::Event; use ratatui::{ - backend::Backend, layout::{Constraint, Direction, Layout, Rect}, text::{Line, Span, Text}, Frame, @@ -102,11 +101,7 @@ impl CompareDetailsComponent { } impl DrawableComponent for CompareDetailsComponent { - fn draw<B: Backend>( - &self, - f: &mut Frame<B>, - rect: Rect, - ) -> Result<()> { + fn draw(&self, f: &mut Frame, rect: Rect) -> Result<()> { let chunks = Layout::default() .direction(Direction::Vertical) .constraints( diff --git a/src/components/commit_details/details.rs b/src/components/commit_details/details.rs index cd24e1df..95e4737e 100644 --- a/src/components/commit_details/details.rs +++ b/src/components/commit_details/details.rs @@ -17,7 +17,6 @@ use asyncgit::sync::{ }; use crossterm::event::Event; use ratatui::{ - backend::Backend, layout::{Constraint, Direction, Layout, Rect}, style::{Modifier, Style}, text::{Line, Span, Text}, @@ -255,11 +254,7 @@ impl DetailsComponent { } impl DrawableComponent for DetailsComponent { - fn draw<B: Backend>( - &self, - f: &mut Frame<B>, - rect: Rect, - ) -> Result<()> { + fn draw(&self, f: &mut Frame, rect: Rect) -> Result<()> { const CANSCROLL_STRING: &str = "[\u{2026}]"; const EMPTY_STRING: &str = ""; diff --git a/src/components/commit_details/mod.rs b/src/components/commit_details/mod.rs index b8a42bcc..229c2a9a 100644 --- a/src/components/commit_details/mod.rs +++ b/src/components/commit_details/mod.rs @@ -21,7 +21,6 @@ use compare_details::CompareDetailsComponent; use crossterm::event::Event; use details::DetailsComponent; use ratatui::{ - backend::Backend, layout::{Constraint, Direction, Layout, Rect}, Frame, }; @@ -140,11 +139,7 @@ impl CommitDetailsComponent { } impl DrawableComponent for CommitDetailsComponent { - fn draw<B: Backend>( - &self, - f: &mut Frame<B>, - rect: Rect, - ) -> Result<()> { + fn draw(&self, f: &mut Frame, rect: Rect) -> Result<()> { if !self.visible { return Ok(()); } diff --git a/src/components/commitlist.rs b/src/components/commitlist.rs index 64e41e89..84f9c3ae 100644 --- a/src/components/commitlist.rs +++ b/src/components/commitlist.rs @@ -22,7 +22,6 @@ use crossterm::event::Event; use indexmap::IndexSet; use itertools::Itertools; use ratatui::{ - backend::Backend, layout::{Alignment, Rect}, style::Style, text::{Line, Span}, @@ -772,11 +771,7 @@ impl CommitList { } impl DrawableComponent for CommitList { - fn draw<B: Backend>( - &self, - f: &mut Frame<B>, - area: Rect, - ) -> Result<()> { + fn draw(&self, f: &mut Frame, area: Rect) -> Result<()> { let current_size = ( area.width.saturating_sub(2), area.height.saturating_sub(2), diff --git a/src/components/cred.rs b/src/components/cred.rs index f801a550..f92d486a 100644 --- a/src/components/cred.rs +++ b/src/components/cred.rs @@ -1,6 +1,6 @@ use anyhow::Result; use crossterm::event::Event; -use ratatui::{backend::Backend, layout::Rect, Frame}; +use ratatui::{layout::Rect, Frame}; use asyncgit::sync::cred::BasicAuthCredential; @@ -60,11 +60,7 @@ impl CredComponent { } impl DrawableComponent for CredComponent { - fn draw<B: Backend>( - &self, - f: &mut Frame<B>, - rect: Rect, - ) -> Result<()> { + fn draw(&self, f: &mut Frame, rect: Rect) -> Result<()> { if self.visible { self.input_username.draw(f, rect)?; self.input_password.draw(f, rect)?; diff --git a/src/components/diff.rs b/src/components/diff.rs index 1c7e0622..c402bc69 100644 --- a/src/components/diff.rs +++ b/src/components/diff.rs @@ -23,7 +23,6 @@ use asyncgit::{ use bytesize::ByteSize; use crossterm::event::Event; use ratatui::{ - backend::Backend, layout::Rect, symbols, text::{Line, Span}, @@ -683,11 +682,7 @@ impl DiffComponent { } impl DrawableComponent for DiffComponent { - fn draw<B: Backend>( - &self, - f: &mut Frame<B>, - r: Rect, - ) -> Result<()> { + fn draw(&self, f: &mut Frame, r: Rect) -> Result<()> { self.current_size.set(( r.width.saturating_sub(2), r.height.saturating_sub(2), diff --git a/src/components/mod.rs b/src/components/mod.rs index 7b2b5a7e..4f1f3f40 100644 --- a/src/components/mod.rs +++ b/src/components/mod.rs @@ -30,7 +30,6 @@ use crate::ui::style::Theme; use anyhow::Result; use crossterm::event::Event; use ratatui::{ - backend::Backend, layout::{Alignment, Rect}, text::{Span, Text}, widgets::{Block, Borders, Paragraph}, @@ -72,7 +71,7 @@ macro_rules! any_popup_visible { #[macro_export] macro_rules! draw_popups { ($self:ident, [$($element:ident),+]) => { - fn draw_popups<B: Backend>(& $self, mut f: &mut Frame<B>) -> Result<()>{ + fn draw_popups(& $self, mut f: &mut Frame) -> Result<()>{ //TODO: move the layout part out and feed it into `draw_popups` let size = Layout::default() .direction(Direction::Vertical) @@ -176,11 +175,7 @@ pub fn visibility_blocking<T: Component>( /// pub trait DrawableComponent { /// - fn draw<B: Backend>( - &self, - f: &mut Frame<B>, - rect: Rect, - ) -> Result<()>; + fn draw(&self, f: &mut Frame, rect: Rect) -> Result<()>; } /// diff --git a/src/components/revision_files.rs b/src/components/revision_files.rs index d8725619..fdd71866 100644 --- a/src/components/revision_files.rs +++ b/src/components/revision_files.rs @@ -24,7 +24,6 @@ use asyncgit::{ use crossterm::event::Event; use filetreelist::{FileTree, FileTreeItem}; use ratatui::{ - backend::Backend, layout::{Constraint, Direction, Layout, Rect}, text::Span, widgets::{Block, Borders}, @@ -277,11 +276,7 @@ impl RevisionFilesComponent { } } - fn draw_tree<B: Backend>( - &self, - f: &mut Frame<B>, - area: Rect, - ) -> Result<()> { + fn draw_tree(&self, f: &mut Frame, area: Rect) -> Result<()> { let tree_height = usize::from(area.height.saturating_sub(2)); let tree_width = usize::from(area.width); @@ -389,11 +384,7 @@ impl RevisionFilesComponent { } impl DrawableComponent for RevisionFilesComponent { - fn draw<B: Backend>( - &self, - f: &mut Frame<B>, - area: Rect, - ) -> Result<()> { + fn draw(&self, f: &mut Frame, area: Rect) -> Result<()> { if self.is_visible() { let chunks = Layout::default() .direction(Direction::Horizontal) diff --git a/src/components/status_tree.rs b/src/components/status_tree.rs index a3087de3..8aa58ce7 100644 --- a/src/components/status_tree.rs +++ b/src/components/status_tree.rs @@ -17,7 +17,7 @@ use crate::{ use anyhow::Result; use asyncgit::{hash, sync::CommitId, StatusItem, StatusItemType}; use crossterm::event::Event; -use ratatui::{backend::Backend, layout::Rect, text::Span, Frame}; +use ratatui::{layout::Rect, text::Span, Frame}; use std::{borrow::Cow, cell::Cell, path::Path}; //TODO: use new `filetreelist` crate @@ -319,11 +319,7 @@ struct TextDrawInfo<'a> { } impl DrawableComponent for StatusTreeComponent { - fn draw<B: Backend>( - &self, - f: &mut Frame<B>, - r: Rect, - ) -> Result<()> { + fn draw(&self, f: &mut Frame, r: Rect) -> Result<()> { if !self.is_visible() { return Ok(()); } diff --git a/src/components/syntax_text.rs b/src/components/syntax_text.rs index f031fdb6..9da5d2cc 100644 --- a/src/components/syntax_text.rs +++ b/src/components/syntax_text.rs @@ -23,7 +23,6 @@ use crossterm::event::Event; use filetreelist::MoveSelection; use itertools::Either; use ratatui::{ - backend::Backend, layout::Rect, text::Text, widgets::{Block, Borders, Wrap}, @@ -184,11 +183,7 @@ impl SyntaxTextComponent { } impl DrawableComponent for SyntaxTextComponent { - fn draw<B: Backend>( - &self, - f: &mut Frame<B>, - area: Rect, - ) -> Result<()> { + fn draw(&self, f: &mut Frame, area: Rect) -> Result<()> { let text = self.current_file.as_ref().map_or_else( || Text::from(""), |(_, content)| match content { diff --git a/src/components/textinput.rs b/src/components/textinput.rs index 0dfe96a8..a92519b3 100644 --- a/src/components/textinput.rs +++ b/src/components/textinput.rs @@ -14,7 +14,6 @@ use anyhow::Result; use crossterm::event::Event; use ratatui::widgets::{Block, Borders}; use ratatui::{ - backend::Backend, layout::{Alignment, Rect}, widgets::{Clear, Paragraph}, Frame, @@ -197,7 +196,7 @@ impl TextInputComponent { } } - fn draw_char_count<B: Backend>(&self, f: &mut Frame<B>, r: Rect) { + fn draw_char_count(&self, f: &mut Frame, r: Rect) { let count = self.get_text().len(); if count > 0 { let w = Paragraph::new(format!("[{count} chars]")) @@ -611,11 +610,7 @@ impl TextInputComponent { } impl DrawableComponent for TextInputComponent { - fn draw<B: Backend>( - &self, - f: &mut Frame<B>, - rect: Rect, - ) -> Result<()> { + fn draw(&self, f: &mut Frame, rect: Rect) -> Result<()> { // this should always be true since draw should only be being called // is control is visible if let Some(ta) = &self.textarea { diff --git a/src/components/utils/scroll_horizontal.rs b/src/components/utils/scroll_horizontal.rs index 4cfe53b0..67825744 100644 --- a/src/components/utils/scroll_horizontal.rs +++ b/src/components/utils/scroll_horizontal.rs @@ -1,11 +1,9 @@ -use std::cell::Cell; - -use ratatui::{backend::Backend, layout::Rect, Frame}; - use crate::{ components::HorizontalScrollType, ui::{draw_scrollbar, style::SharedTheme, Orientation}, }; +use ratatui::{layout::Rect, Frame}; +use std::cell::Cell; pub struct HorizontalScroll { right: Cell<usize>, @@ -84,12 +82,7 @@ impl HorizontalScroll { self.update(self.get_right(), column_count, visual_width) } - pub fn draw<B: Backend>( - &self, - f: &mut Frame<B>, - r: Rect, - theme: &SharedTheme, - ) { + pub fn draw(&self, f: &mut Frame, r: Rect, theme: &SharedTheme) { draw_scrollbar( f, r, diff --git a/src/components/utils/scroll_vertical.rs b/src/components/utils/scroll_vertical.rs index 70d68eef..d78dcb26 100644 --- a/src/components/utils/scroll_vertical.rs +++ b/src/components/utils/scroll_vertical.rs @@ -1,11 +1,9 @@ -use std::cell::Cell; - -use ratatui::{backend::Backend, layout::Rect, Frame}; - use crate::{ components::ScrollType, ui::{draw_scrollbar, style::SharedTheme, Orientation}, }; +use ratatui::{layout::Rect, Frame}; +use std::cell::Cell; pub struct VerticalScroll { top: Cell<usize>, @@ -109,12 +107,7 @@ impl VerticalScroll { self.update(self.get_top(), line_count, visual_height) } - pub fn draw<B: Backend>( |