From 2b39c6465aa01b06600040053fe3086f92590692 Mon Sep 17 00:00:00 2001 From: extrawurst Date: Tue, 20 Feb 2024 14:59:33 +0100 Subject: [PATCH] ratatui 0.24 update --- Cargo.lock | 62 ++++++++++++++++++- Cargo.toml | 2 +- src/app.rs | 5 +- src/cmdbar.rs | 3 +- src/components/changes.rs | 8 +-- .../commit_details/compare_details.rs | 7 +-- src/components/commit_details/details.rs | 7 +-- src/components/commit_details/mod.rs | 7 +-- src/components/commitlist.rs | 7 +-- src/components/cred.rs | 8 +-- src/components/diff.rs | 7 +-- src/components/mod.rs | 9 +-- src/components/revision_files.rs | 13 +--- src/components/status_tree.rs | 8 +-- src/components/syntax_text.rs | 7 +-- src/components/textinput.rs | 9 +-- src/components/utils/scroll_horizontal.rs | 13 +--- src/components/utils/scroll_vertical.rs | 13 +--- src/main.rs | 20 +++--- src/popups/blame_file.rs | 7 +-- src/popups/branchlist.rs | 15 +---- src/popups/commit.rs | 11 +--- src/popups/compare_commits.rs | 7 +-- src/popups/confirm.rs | 10 +-- src/popups/create_branch.rs | 12 +--- src/popups/externaleditor.rs | 7 +-- src/popups/fetch.rs | 8 +-- src/popups/file_revlog.rs | 9 +-- src/popups/fuzzy_find.rs | 13 +--- src/popups/help.rs | 7 +-- src/popups/inspect_commit.rs | 7 +-- src/popups/log_search.rs | 17 ++--- src/popups/msg.rs | 7 +-- src/popups/options.rs | 7 +-- src/popups/pull.rs | 7 +-- src/popups/push.rs | 7 +-- src/popups/push_tags.rs | 7 +-- src/popups/rename_branch.rs | 8 +-- src/popups/reset.rs | 7 +-- src/popups/revision_files.rs | 10 +-- src/popups/stashmsg.rs | 8 +-- src/popups/submodules.rs | 17 ++--- src/popups/tag_commit.rs | 8 +-- src/popups/taglist.rs | 7 +-- src/spinner.rs | 11 ++-- src/tabs/files.rs | 4 +- src/tabs/revlog.rs | 9 +-- src/tabs/stashing.rs | 5 +- src/tabs/stashlist.rs | 4 +- src/tabs/status.rs | 13 ++-- src/ui/scrollbar.rs | 5 +- src/ui/scrolllist.rs | 9 ++- typos.toml | 0 53 files changed, 168 insertions(+), 337 deletions(-) create mode 100644 typos.toml diff --git a/Cargo.lock b/Cargo.lock index fe577c8b..56b009bd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -17,6 +17,18 @@ version = "1.0.2" 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" @@ -26,6 +38,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" @@ -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" @@ -994,6 +1016,15 @@ version = "0.4.20" 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" @@ -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", @@ -1780,6 +1812,12 @@ version = "0.2.15" 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" @@ -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", +] diff --git a/Cargo.toml b/Cargo.toml index a99af6f9..8f209405 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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', ] } diff --git a/src/app.rs b/src/app.rs index c25f72bf..f2b4a4a9 100644 --- a/src/app.rs +++ b/src/app.rs @@ -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(&self, f: &mut Frame) -> 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(&self, f: &mut Frame, 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(&self, f: &mut Frame, 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( - &self, - f: &mut Frame, - 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( - &self, - f: &mut Frame, - 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( - &self, - f: &mut Frame, - 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( - &self, - f: &mut Frame, - 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( - &self, - f: &mut Frame, - 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( - &self, - f: &mut Frame, - 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( - &self, - f: &mut Frame, - 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(& $self, mut f: &mut Frame) -> 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( /// pub trait DrawableComponent { /// - fn draw( - &self, - f: &mut Frame, - 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( - &self, - f: &mut Frame, - 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( - &self, - f: &mut Frame, - 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( - &self, - f: &mut Frame, - 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( - &self, - f: &mut Frame, - 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(&self, f: &mut Frame, 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( - &self, - f: &mut Frame, - 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, @@ -84,12 +82,7 @@ impl HorizontalScroll { self.update(self.get_right(), column_count, visual_width) } - pub fn draw( - &self, - f: &mut Frame, - 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, @@ -109,12 +107,7 @@ impl VerticalScroll { self.update(self.get_top(), line_count, visual_height) } - pub fn draw( - &self, - f: &mut Frame, - r: Rect, - theme: &SharedTheme, - ) { + pub fn draw(&self, f: &mut Frame, r: Rect, theme: &SharedTheme) { draw_scrollbar( f, r, diff --git a/src/main.rs b/src/main.rs index 96c806d9..f1810a3e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -66,22 +66,21 @@ use crossterm::{ }; use input::{Input, InputEvent, InputState}; use keys::KeyConfig; -use ratatui::{ - backend::{Backend, CrosstermBackend}, - Terminal, -}; +use ratatui::backend::CrosstermBackend; use scopeguard::defer; use scopetime::scope_time; use spinner::Spinner; use std::{ cell::RefCell, - io::{self, Write}, + io::{self, Stdout}, panic, process, time::{Duration, Instant}, }; use ui::style::Theme; use watcher::RepoWatcher; +type Terminal = ratatui::Terminal>; + static TICK_INTERVAL: Duration = Duration::from_secs(5); static SPINNER_INTERVAL: Duration = Duration::from_millis(80); @@ -183,7 +182,7 @@ fn run_app( key_config: KeyConfig, input: &Input, updater: Updater, - terminal: &mut Terminal>, + terminal: &mut Terminal, ) -> Result { let (tx_git, rx_git) = unbounded(); let (tx_app, rx_app) = unbounded(); @@ -302,10 +301,7 @@ fn shutdown_terminal() { } } -fn draw( - terminal: &mut Terminal, - app: &App, -) -> io::Result<()> { +fn draw(terminal: &mut Terminal, app: &App) -> io::Result<()> { if app.requires_redraw() { terminal.resize(terminal.size()?)?; } @@ -364,9 +360,7 @@ fn select_event( Ok(ev) } -fn start_terminal( - buf: W, -) -> io::Result>> { +fn start_terminal(buf: Stdout) -> io::Result { let backend = CrosstermBackend::new(buf); let mut terminal = Terminal::new(backend)?; terminal.hide_cursor()?; diff --git a/src/popups/blame_file.rs b/src/popups/blame_file.rs index 26366e75..62d1c748 100644 --- a/src/popups/blame_file.rs +++ b/src/popups/blame_file.rs @@ -22,7 +22,6 @@ use asyncgit::{ use crossbeam_channel::Sender; use crossterm::event::Event; use ratatui::{ - backend::Backend, layout::{Constraint, Rect}, symbols::line::VERTICAL, text::{Span, Text}, @@ -101,11 +100,7 @@ pub struct BlameFilePopup { } impl DrawableComponent for BlameFilePopup { - fn draw( - &self, - f: &mut Frame, - area: Rect, - ) -> Result<()> { + fn draw(&self, f: &mut Frame, area: Rect) -> Result<()> { if self.is_visible() { let title = self.get_title(); diff --git a/src/popups/branchlist.rs b/src/popups/branchlist.rs index 7b36ca60..f7c9b94d 100644 --- a/src/popups/branchlist.rs +++ b/src/popups/branchlist.rs @@ -27,7 +27,6 @@ use asyncgit::{ }; use crossterm::event::{Event, KeyEvent}; use ratatui::{ - backend::Backend, layout::{ Alignment, Constraint, Direction, Layout, Margin, Rect, }, @@ -57,11 +56,7 @@ pub struct BranchListPopup { } impl DrawableComponent for BranchListPopup { - fn draw( - &self, - f: &mut Frame, - rect: Rect, - ) -> Result<()> { + fn draw(&self, f: &mut Frame, rect: Rect) -> Result<()> { if self.is_visible() { const PERCENT_SIZE: Size = Size::new(80, 50); const MIN_SIZE: Size = Size::new(60, 20); @@ -694,7 +689,7 @@ impl BranchListPopup { Ok(()) } - fn draw_tabs(&self, f: &mut Frame, r: Rect) { + fn draw_tabs(&self, f: &mut Frame, r: Rect) { let tabs = [Span::raw("Local"), Span::raw("Remote")] .iter() .cloned() @@ -716,11 +711,7 @@ impl BranchListPopup { ); } - fn draw_list( - &self, - f: &mut Frame, - r: Rect, - ) -> Result<()> { + fn draw_list(&self, f: &mut Frame, r: Rect) -> Result<()> { let height_in_lines = r.height as usize; self.current_height.set(height_in_lines.try_into()?); diff --git a/src/popups/commit.rs b/src/popups/commit.rs index 4bf4a07b..7385c004 100644 --- a/src/popups/commit.rs +++ b/src/popups/commit.rs @@ -22,7 +22,6 @@ use asyncgit::{ use crossterm::event::Event; use easy_cast::Cast; use ratatui::{ - backend::Backend, layout::{Alignment, Rect}, widgets::Paragraph, Frame, @@ -95,7 +94,7 @@ impl CommitPopup { self.git_branch_name.lookup().ok(); } - fn draw_branch_name(&self, f: &mut Frame) { + fn draw_branch_name(&self, f: &mut Frame) { if let Some(name) = self.git_branch_name.last() { let w = Paragraph::new(format!("{{{name}}}")) .alignment(Alignment::Right); @@ -111,7 +110,7 @@ impl CommitPopup { } } - fn draw_warnings(&self, f: &mut Frame) { + fn draw_warnings(&self, f: &mut Frame) { let first_line = self .input .get_text() @@ -488,11 +487,7 @@ impl CommitPopup { } impl DrawableComponent for CommitPopup { - fn draw( - &self, - f: &mut Frame, - rect: Rect, - ) -> Result<()> { + fn draw(&self, f: &mut Frame, rect: Rect) -> Result<()> { if self.is_visible() { self.input.draw(f, rect)?; self.draw_branch_name(f); diff --git a/src/popups/compare_commits.rs b/src/popups/compare_commits.rs index 31a164cb..ef5d8276 100644 --- a/src/popups/compare_commits.rs +++ b/src/popups/compare_commits.rs @@ -20,7 +20,6 @@ use asyncgit::{ }; use crossterm::event::Event; use ratatui::{ - backend::Backend, layout::{Constraint, Direction, Layout, Rect}, widgets::Clear, Frame, @@ -39,11 +38,7 @@ pub struct CompareCommitsPopup { } impl DrawableComponent for CompareCommitsPopup { - fn draw( - &self, - f: &mut Frame, - rect: Rect, - ) -> Result<()> { + fn draw(&self, f: &mut Frame, rect: Rect) -> Result<()> { if self.is_visible() { let percentages = if self.diff.focused() { (0, 100) diff --git a/src/popups/confirm.rs b/src/popups/confirm.rs index acdd9021..a588f425 100644 --- a/src/popups/confirm.rs +++ b/src/popups/confirm.rs @@ -10,9 +10,7 @@ use crate::{ }; use anyhow::Result; use crossterm::event::Event; -use ratatui::{ - backend::Backend, layout::Rect, text::Text, widgets::Clear, Frame, -}; +use ratatui::{layout::Rect, text::Text, widgets::Clear, Frame}; use std::borrow::Cow; use ui::style::SharedTheme; @@ -28,11 +26,7 @@ pub struct ConfirmPopup { } impl DrawableComponent for ConfirmPopup { - fn draw( - &self, - f: &mut Frame, - _rect: Rect, - ) -> Result<()> { + fn draw(&self, f: &mut Frame, _rect: Rect) -> Result<()> { if self.visible { let (title, msg) = self.get_text(); diff --git a/src/popups/create_branch.rs b/src/popups/create_branch.rs index 7dacd0fb..ed69d392 100644 --- a/src/popups/create_branch.rs +++ b/src/popups/create_branch.rs @@ -13,9 +13,7 @@ use anyhow::Result; use asyncgit::sync::{self, RepoPathRef}; use crossterm::event::Event; use easy_cast::Cast; -use ratatui::{ - backend::Backend, layout::Rect, widgets::Paragraph, Frame, -}; +use ratatui::{layout::Rect, widgets::Paragraph, Frame}; pub struct CreateBranchPopup { repo: RepoPathRef, @@ -26,11 +24,7 @@ pub struct CreateBranchPopup { } impl DrawableComponent for CreateBranchPopup { - fn draw( - &self, - f: &mut Frame, - rect: Rect, - ) -> Result<()> { + fn draw(&self, f: &mut Frame, rect: Rect) -> Result<()> { if self.is_visible() { self.input.draw(f, rect)?; self.draw_warnings(f); @@ -143,7 +137,7 @@ impl CreateBranchPopup { } } - fn draw_warnings(&self, f: &mut Frame) { + fn draw_warnings(&self, f: &mut Frame) { let current_text = self.input.get_text(); if !current_text.is_empty() { diff --git a/src/popups/externaleditor.rs b/src/popups/externaleditor.rs index e13ae3fd..dc0d5aef 100644 --- a/src/popups/externaleditor.rs +++ b/src/popups/externaleditor.rs @@ -18,7 +18,6 @@ use crossterm::{ ExecutableCommand, }; use ratatui::{ - backend::Backend, layout::Rect, text::{Line, Span}, widgets::{Block, BorderType, Borders, Clear, Paragraph}, @@ -121,11 +120,7 @@ impl ExternalEditorPopup { } impl DrawableComponent for ExternalEditorPopup { - fn draw( - &self, - f: &mut Frame, - _rect: Rect, - ) -> Result<()> { + fn draw(&self, f: &mut Frame, _rect: Rect) -> Result<()> { if self.visible { let txt = Line::from( strings::msg_opening_editor(&self.key_config) diff --git a/src/popups/fetch.rs b/src/popups/fetch.rs index 9c03f61c..daf015f2 100644 --- a/src/popups/fetch.rs +++ b/src/popups/fetch.rs @@ -21,10 +21,8 @@ use asyncgit::{ }, AsyncFetchJob, AsyncGitNotification, ProgressPercent, }; - use crossterm::event::Event; use ratatui::{ - backend::Backend, layout::Rect, text::Span, widgets::{Block, BorderType, Borders, Clear, Gauge}, @@ -117,11 +115,7 @@ impl FetchPopup { } impl DrawableComponent for FetchPopup { - fn draw( - &self, - f: &mut Frame, - rect: Rect, - ) -> Result<()> { + fn draw(&self, f: &mut Frame, rect: Rect) -> Result<()> { if self.visible { let progress = self.progress.unwrap_or_default().progress; diff --git a/src/popups/file_revlog.rs b/src/popups/file_revlog.rs index 8fb8349f..5450a27b 100644 --- a/src/popups/file_revlog.rs +++ b/src/popups/file_revlog.rs @@ -22,7 +22,6 @@ use chrono::{DateTime, Local}; use crossbeam_channel::Sender; use crossterm::event::Event; use ratatui::{ - backend::Backend, layout::{Constraint, Direction, Layout, Rect}, text::{Line, Span, Text}, widgets::{Block, Borders, Cell, Clear, Row, Table, TableState}, @@ -377,7 +376,7 @@ impl FileRevlogPopup { selection } - fn draw_revlog(&self, f: &mut Frame, area: Rect) { + fn draw_revlog(&self, f: &mut Frame, area: Rect) { let constraints = [ // type of change: (A)dded, (M)odified, (D)eleted Constraint::Length(1), @@ -464,11 +463,7 @@ impl FileRevlogPopup { } impl DrawableComponent for FileRevlogPopup { - fn draw( - &self, - f: &mut Frame, - area: Rect, - ) -> Result<()> { + fn draw(&self, f: &mut Frame, area: Rect) -> Result<()> { if self.visible { let percentages = if self.diff.focused() { (0, 100) diff --git a/src/popups/fuzzy_find.rs b/src/popups/fuzzy_find.rs index 07dc1383..ccee1b9c 100644 --- a/src/popups/fuzzy_find.rs +++ b/src/popups/fuzzy_find.rs @@ -15,7 +15,6 @@ use anyhow::Result; use crossterm::event::Event; use fuzzy_matcher::FuzzyMatcher; use ratatui::{ - backend::Backend, layout::{Constraint, Direction, Layout, Margin, Rect}, text::{Line, Span}, widgets::{Block, Borders, Clear}, @@ -167,11 +166,7 @@ impl FuzzyFindPopup { } #[inline] - fn draw_matches_list( - &self, - f: &mut Frame, - mut area: Rect, - ) { + fn draw_matches_list(&self, f: &mut Frame, mut area: Rect) { { // Block has two lines up and down which need to be considered const HEIGHT_BLOCK_MARGIN: usize = 2; @@ -252,11 +247,7 @@ impl FuzzyFindPopup { } impl DrawableComponent for FuzzyFindPopup { - fn draw( - &self, - f: &mut Frame, - area: Rect, - ) -> Result<()> { + fn draw(&self, f: &mut Frame, area: Rect) -> Result<()> { if self.is_visible() { const MAX_SIZE: (u16, u16) = (50, 20); diff --git a/src/popups/help.rs b/src/popups/help.rs index 716216f0..9933d5c7 100644 --- a/src/popups/help.rs +++ b/src/popups/help.rs @@ -13,7 +13,6 @@ use asyncgit::hash; use crossterm::event::Event; use itertools::Itertools; use ratatui::{ - backend::Backend, layout::{Alignment, Constraint, Direction, Layout, Rect}, style::{Modifier, Style}, text::{Line, Span}, @@ -33,11 +32,7 @@ pub struct HelpPopup { } impl DrawableComponent for HelpPopup { - fn draw( - &self, - f: &mut Frame, - _rect: Rect, - ) -> Result<()> { + fn draw(&self, f: &mut Frame, _rect: Rect) -> Result<()> { if self.visible { const SIZE: (u16, u16) = (65, 24); let scroll_threshold = SIZE.1 / 3; diff --git a/src/popups/inspect_commit.rs b/src/popups/inspect_commit.rs index 96eba3fc..42c95dd2 100644 --- a/src/popups/inspect_commit.rs +++ b/src/popups/inspect_commit.rs @@ -18,7 +18,6 @@ use asyncgit::{ }; use crossterm::event::Event; use ratatui::{ - backend::Backend, layout::{Constraint, Direction, Layout, Rect}, widgets::Clear, Frame, @@ -65,11 +64,7 @@ pub struct InspectCommitPopup { } impl DrawableComponent for InspectCommitPopup { - fn draw( - &self, - f: &mut Frame, - rect: Rect, - ) -> Result<()> { + fn draw(&self, f: &mut Frame, rect: Rect) -> Result<()> { if self.is_visible() { let percentages = if self.diff.focused() { (0, 100) diff --git a/src/popups/log_search.rs b/src/popups/log_search.rs index 7179a348..e7e868ad 100644 --- a/src/popups/log_search.rs +++ b/src/popups/log_search.rs @@ -17,7 +17,6 @@ use asyncgit::sync::{ use crossterm::event::Event; use easy_cast::Cast; use ratatui::{ - backend::Backend, layout::{ Alignment, Constraint, Direction, Layout, Margin, Rect, }, @@ -352,9 +351,9 @@ impl LogSearchPopupPopup { .enabled(matches!(self.selection, Selection::EnterText)); } - fn draw_search_mode( + fn draw_search_mode( &self, - f: &mut Frame, + f: &mut Frame, area: Rect, ) -> Result<()> { const SIZE: (u16, u16) = (60, 10); @@ -399,9 +398,9 @@ impl LogSearchPopupPopup { Ok(()) } - fn draw_commit_sha_mode( + fn draw_commit_sha_mode( &self, - f: &mut Frame, + f: &mut Frame, area: Rect, ) -> Result<()> { const SIZE: (u16, u16) = (60, 3); @@ -445,7 +444,7 @@ impl LogSearchPopupPopup { Ok(()) } - fn draw_invalid_sha(&self, f: &mut Frame) { + fn draw_invalid_sha(&self, f: &mut Frame) { let msg_length: u16 = POPUP_COMMIT_SHA_INVALID.len().cast(); let w = Paragraph::new(POPUP_COMMIT_SHA_INVALID) .style(self.theme.text_danger()); @@ -525,11 +524,7 @@ impl LogSearchPopupPopup { } impl DrawableComponent for LogSearchPopupPopup { - fn draw( - &self, - f: &mut Frame, - area: Rect, - ) -> Result<()> { + fn draw(&self, f: &mut Frame, area: Rect) -> Result<()> { if self.is_visible() { match self.mode { PopupMode::Search => { diff --git a/src/popups/msg.rs b/src/popups/msg.rs index eb6d7611..d217328d 100644 --- a/src/popups/msg.rs +++ b/src/popups/msg.rs @@ -9,7 +9,6 @@ use crate::{ }; use crossterm::event::Event; use ratatui::{ - backend::Backend, layout::{Alignment, Rect}, text::Span, widgets::{Block, BorderType, Borders, Clear, Paragraph, Wrap}, @@ -28,11 +27,7 @@ pub struct MsgPopup { use anyhow::Result; impl DrawableComponent for MsgPopup { - fn draw( - &self, - f: &mut Frame, - _rect: Rect, - ) -> Result<()> { + fn draw(&self, f: &mut Frame, _rect: Rect) -> Result<()> { if !self.visible { return Ok(()); } diff --git a/src/popups/options.rs b/src/popups/options.rs index 5ffa050f..afe5adec 100644 --- a/src/popups/options.rs +++ b/src/popups/options.rs @@ -14,7 +14,6 @@ use anyhow::Result; use asyncgit::sync::ShowUntrackedFilesConfig; use crossterm::event::Event; use ratatui::{ - backend::Backend, layout::{Alignment, Rect}, style::{Modifier, Style}, text::{Line, Span}, @@ -256,11 +255,7 @@ impl OptionsPopup { } impl DrawableComponent for OptionsPopup { - fn draw( - &self, - f: &mut Frame, - area: Rect, - ) -> Result<()> { + fn draw(&self, f: &mut Frame, area: Rect) -> Result<()> { if self.is_visible() { const SIZE: (u16, u16) = (50, 10); let area = diff --git a/src/popups/pull.rs b/src/popups/pull.rs index 7eb478c8..58c720a5 100644 --- a/src/popups/pull.rs +++ b/src/popups/pull.rs @@ -25,7 +25,6 @@ use asyncgit::{ use crossterm::event::Event; use ratatui::{ - backend::Backend, layout::Rect, text::Span, widgets::{Block, BorderType, Borders, Clear, Gauge}, @@ -198,11 +197,7 @@ impl PullPopup { } impl DrawableComponent for PullPopup { - fn draw( - &self, - f: &mut Frame, - rect: Rect, - ) -> Result<()> { + fn draw(&self, f: &mut Frame, rect: Rect) -> Result<()> { if self.visible { let (state, progress) = PushPopup::get_progress(&self.progress); diff --git a/src/popups/push.rs b/src/popups/push.rs index b20818d9..a192e2ea 100644 --- a/src/popups/push.rs +++ b/src/popups/push.rs @@ -23,7 +23,6 @@ use asyncgit::{ }; use crossterm::event::Event; use ratatui::{ - backend::Backend, layout::Rect, text::Span, widgets::{Block, BorderType, Borders, Clear, Gauge}, @@ -227,11 +226,7 @@ impl PushPopup { } impl DrawableComponent for PushPopup { - fn draw( - &self, - f: &mut Frame, - rect: Rect, - ) -> Result<()> { + fn draw(&self, f: &mut Frame, rect: Rect) -> Result<()> { if self.visible { let (state, progress) = Self::get_progress(&self.progress); diff --git a/src/popups/push_tags.rs b/src/popups/push_tags.rs index 73c1af42..e6e09048 100644 --- a/src/popups/push_tags.rs +++ b/src/popups/push_tags.rs @@ -23,7 +23,6 @@ use asyncgit::{ }; use crossterm::event::Event; use ratatui::{ - backend::Backend, layout::Rect, text::Span, widgets::{Block, BorderType, Borders, Clear, Gauge}, @@ -158,11 +157,7 @@ impl PushTagsPopup { } impl DrawableComponent for PushTagsPopup { - fn draw( - &self, - f: &mut Frame, - rect: Rect, - ) -> Result<()> { + fn draw(&self, f: &mut Frame, rect: Rect) -> Result<()> { if self.visible { let (state, progress) = Self::get_progress(&self.progress); diff --git a/src/popups/rename_branch.rs b/src/popups/rename_branch.rs index 14311544..d8243417 100644 --- a/src/popups/rename_branch.rs +++ b/src/popups/rename_branch.rs @@ -11,7 +11,7 @@ use crate::{ use anyhow::Result; use asyncgit::sync::{self, RepoPathRef}; use crossterm::event::Event; -use ratatui::{backend::Backend, layout::Rect, Frame}; +use ratatui::{layout::Rect, Frame}; pub struct RenameBranchPopup { repo: RepoPathRef, @@ -22,11 +22,7 @@ pub struct RenameBranchPopup { } impl DrawableComponent for RenameBranchPopup { - fn draw( - &self, - f: &mut Frame, - rect: Rect, - ) -> Result<()> { + fn draw(&self, f: &mut Frame, rect: Rect) -> Result<()> { self.input.draw(f, rect)?; Ok(()) diff --git a/src/popups/reset.rs b/src/popups/reset.rs index 8a32da45..eb99d93a 100644 --- a/src/popups/reset.rs +++ b/src/popups/reset.rs @@ -16,7 +16,6 @@ use asyncgit::{ }; use crossterm::event::Event; use ratatui::{ - backend::Backend, layout::{Alignment, Rect}, text::{Line, Span}, widgets::{Block, Borders, Clear, Paragraph}, @@ -156,11 +155,7 @@ impl ResetPopup { } impl DrawableComponent for ResetPopup { - fn draw( - &self, - f: &mut Frame, - area: Rect, - ) -> Result<()> { + fn draw(&self, f: &mut Frame, area: Rect) -> Result<()> { if self.is_visible() { const SIZE: (u16, u16) = (55, 5); let area = diff --git a/src/popups/revision_files.rs b/src/popups/revision_files.rs index 7b3e3643..92560ccf 100644 --- a/src/popups/revision_files.rs +++ b/src/popups/revision_files.rs @@ -12,9 +12,7 @@ use crate::{ use anyhow::Result; use asyncgit::sync::CommitId; use crossterm::event::Event; -use ratatui::{ - backend::Backend, layout::Rect, widgets::Clear, Frame, -}; +use ratatui::{layout::Rect, widgets::Clear, Frame}; use std::path::Path; #[derive(Clone, Debug)] @@ -94,11 +92,7 @@ impl RevisionFilesPopup { } impl DrawableComponent for RevisionFilesPopup { - fn draw( - &self, - f: &mut Frame, - area: Rect, - ) -> Result<()> { + fn draw(&self, f: &mut Frame, area: Rect) -> Result<()> { if self.is_visible() { f.render_widget(Clear, area); diff --git a/src/popups/stashmsg.rs b/src/popups/stashmsg.rs index 11c87053..8c7a7a07 100644 --- a/src/popups/stashmsg.rs +++ b/src/popups/stashmsg.rs @@ -12,7 +12,7 @@ use crate::{ use anyhow::Result; use asyncgit::sync::{self, RepoPathRef}; use crossterm::event::Event; -use ratatui::{backend::Backend, layout::Rect, Frame}; +use ratatui::{layout::Rect, Frame}; pub struct StashMsgPopup { repo: RepoPathRef, @@ -23,11 +23,7 @@ pub struct StashMsgPopup { } impl DrawableComponent for StashMsgPopup { - fn draw( - &self, - f: &mut Frame, - rect: Rect, - ) -> Result<()> { + fn draw(&self, f: &mut Frame, rect: Rect) -> Result<()> { self.input.draw(f, rect)?; Ok(()) diff --git a/src/popups/submodules.rs b/src/popups/submodules.rs index 6cdd3fa7..8a758a49 100644 --- a/src/popups/submodules.rs +++ b/src/popups/submodules.rs @@ -17,7 +17,6 @@ use asyncgit::sync::{ }; use crossterm::event::Event; use ratatui::{ - backend::Backend, layout::{ Alignment, Constraint, Direction, Layout, Margin, Rect, }, @@ -45,11 +44,7 @@ pub struct SubmodulesListPopup { } impl DrawableComponent for SubmodulesListPopup { - fn draw( - &self, - f: &mut Frame, - rect: Rect, - ) -> Result<()> { + fn draw(&self, f: &mut Frame, rect: Rect) -> Result<()> { if self.is_visible() { const PERCENT_SIZE: Size = Size::new(80, 80); const MIN_SIZE: Size = Size::new(60, 30); @@ -473,11 +468,7 @@ impl SubmodulesListPopup { Text::from(spans) } - fn draw_list( - &self, - f: &mut Frame, - r: Rect, - ) -> Result<()> { + fn draw_list(&self, f: &mut Frame, r: Rect) -> Result<()> { let height_in_lines = r.height as usize; self.current_height.set(height_in_lines.try_into()?); @@ -507,7 +498,7 @@ impl SubmodulesListPopup { Ok(()) } - fn draw_info(&self, f: &mut Frame, r: Rect) { + fn draw_info(&self, f: &mut Frame, r: Rect) { f.render_widget( Paragraph::new(self.get_info_text(&self.theme)) .alignment(Alignment::Left), @@ -515,7 +506,7 @@ impl SubmodulesListPopup { ); } - fn draw_local_info(&self, f: &mut Frame, r: Rect) { + fn draw_local_info(&self, f: &mut Frame, r: Rect) { f.render_widget( Paragraph::new(self.get_local_info_text(&self.theme)) .block(Block::default().borders(Borders::TOP)) diff --git a/src/popups/tag_commit.rs b/src/popups/tag_commit.rs index 3d7f4b47..4f522747 100644 --- a/src/popups/tag_commit.rs +++ b/src/popups/tag_commit.rs @@ -13,7 +13,7 @@ use asyncgit::sync::{ self, get_config_string, CommitId, RepoPathRef, }; use crossterm::event::Event; -use ratatui::{backend::Backend, layout::Rect, Frame}; +use ratatui::{layout::Rect, Frame}; enum Mode { Name, @@ -30,11 +30,7 @@ pub struct TagCommitPopup { } impl DrawableComponent for TagCommitPopup { - fn draw( - &self, - f: &mut Frame, - rect: Rect, - ) -> Result<()> { + fn draw(&self, f: &mut Frame, rect: Rect) -> Result<()> { self.input.draw(f, rect)?; Ok(()) diff --git a/src/popups/taglist.rs b/src/popups/taglist.rs index 941e8afb..ce3da32c 100644 --- a/src/popups/taglist.rs +++ b/src/popups/taglist.rs @@ -27,7 +27,6 @@ use asyncgit::{ use crossterm::event::Event; use ratatui::{ - backend::Backend, layout::{Constraint, Margin, Rect}, text::Span, widgets::{ @@ -55,11 +54,7 @@ pub struct TagListPopup { } impl DrawableComponent for TagListPopup { - fn draw( - &self, - f: &mut Frame, - rect: Rect, - ) -> Result<()> { + fn draw(&self, f: &mut Frame, rect: Rect) -> Result<()> { if self.visible { const PERCENT_SIZE: Size = Size::new(80, 50); const MIN_SIZE: Size = Size::new(60, 20); diff --git a/src/spinner.rs b/src/spinner.rs index a3a164b1..2fc6b3a2 100644 --- a/src/spinner.rs +++ b/src/spinner.rs @@ -1,4 +1,7 @@ -use ratatui::{backend::Backend, Terminal}; +use ratatui::{ + backend::{Backend, CrosstermBackend}, + Terminal, +}; use std::{cell::Cell, char, io}; // static SPINNER_CHARS: &[char] = &['◢', '◣', '◤', '◥']; @@ -36,9 +39,9 @@ impl Spinner { } /// draws or removes spinner char depending on `pending` state - pub fn draw( + pub fn draw( &self, - terminal: &mut Terminal, + terminal: &mut Terminal>, ) -> io::Result<()> { let idx = self.idx; @@ -56,7 +59,7 @@ impl Spinner { .backend_mut() .draw(vec![(0_u16, 0_u16, &c)].into_iter())?; - ratatui::backend::Backend::flush(terminal.backend_mut())?; + Backend::flush(terminal.backend_mut())?; } Ok(()) diff --git a/src/tabs/files.rs b/src/tabs/files.rs index 81da2618..79a071f2 100644 --- a/src/tabs/files.rs +++ b/src/tabs/files.rs @@ -61,9 +61,9 @@ impl FilesTab { } impl DrawableComponent for FilesTab { - fn draw( + fn draw( &self, - f: &mut ratatui::Frame, + f: &mut ratatui::Frame, rect: ratatui::layout::Rect, ) -> Result<()> { if self.is_visible() { diff --git a/src/tabs/revlog.rs b/src/tabs/revlog.rs index 33d8998b..2d135000 100644 --- a/src/tabs/revlog.rs +++ b/src/tabs/revlog.rs @@ -27,7 +27,6 @@ use crossbeam_channel::Sender; use crossterm::event::Event; use indexmap::IndexSet; use ratatui::{ - backend::Backend, layout::{Alignment, Constraint, Direction, Layout, Rect}, text::Span, widgets::{Block, Borders, Paragraph}, @@ -308,7 +307,7 @@ impl Revlog { !matches!(self.search, LogSearch::Off) } - fn draw_search(&self, f: &mut Frame, area: Rect) { + fn draw_search(&self, f: &mut Frame, area: Rect) { let (text, title) = match &self.search { LogSearch::Searching(_, options, progress) => ( format!("'{}'", options.search_pattern.clone()), @@ -368,11 +367,7 @@ impl Revlog { } impl DrawableComponent for Revlog { - fn draw( - &self, - f: &mut Frame, - area: Rect, - ) -> Result<()> { + fn draw(&self, f: &mut Frame, area: Rect) -> Result<()> { let area = if self.is_in_search_mode() { Layout::default() .direction(Direction::Vertical) diff --git a/src/tabs/stashing.rs b/src/tabs/stashing.rs index 2489f949..7afe6ae3 100644 --- a/src/tabs/stashing.rs +++ b/src/tabs/stashing.rs @@ -16,7 +16,6 @@ use asyncgit::{ sync::{self, status::StatusType, RepoPathRef}, AsyncGitNotification, AsyncStatus, StatusParams, }; - use crossterm::event::Event; use ratatui::{ layout::{Alignment, Constraint, Direction, Layout}, @@ -134,9 +133,9 @@ impl Stashing { } impl DrawableComponent for Stashing { - fn draw( + fn draw( &self, - f: &mut ratatui::Frame, + f: &mut ratatui::Frame, rect: ratatui::layout::Rect, ) -> Result<()> { let chunks = Layout::default() diff --git a/src/tabs/stashlist.rs b/src/tabs/stashlist.rs index db38f87c..cdaaa2df 100644 --- a/src/tabs/stashlist.rs +++ b/src/tabs/stashlist.rs @@ -135,9 +135,9 @@ impl StashList { } impl DrawableComponent for StashList { - fn draw( + fn draw( &self, - f: &mut ratatui::Frame, + f: &mut ratatui::Frame, rect: ratatui::layout::Rect, ) -> Result<()> { self.list.draw(f, rect)?; diff --git a/src/tabs/status.rs b/src/tabs/status.rs index f9d53cf9..47548565 100644 --- a/src/tabs/status.rs +++ b/src/tabs/status.rs @@ -23,7 +23,6 @@ use asyncgit::{ AsyncDiff, AsyncGitNotification, AsyncStatus, DiffParams, DiffType, PushType, StatusItem, StatusParams, }; - use crossterm::event::Event; use itertools::Itertools; use ratatui::{ @@ -80,9 +79,9 @@ pub struct Status { } impl DrawableComponent for Status { - fn draw( + fn draw( &self, - f: &mut ratatui::Frame, + f: &mut ratatui::Frame, rect: ratatui::layout::Rect, ) -> Result<()> { let repo_unclean = self.repo_state_unclean(); @@ -196,9 +195,9 @@ impl Status { } } - fn draw_branch_state( + fn draw_branch_state( &self, - f: &mut ratatui::Frame, + f: &mut ratatui::Frame, chunks: &[ratatui::layout::Rect], ) { if let Some(branch_name) = self.git_branch_name.last() { @@ -277,9 +276,9 @@ impl Status { } } - fn draw_repo_state( + fn draw_repo_state( &self, - f: &mut ratatui::Frame, + f: &mut ratatui::Frame, r: ratatui::layout::Rect, ) { if self.git_state != RepoState::Clean { diff --git a/src/ui/scrollbar.rs b/src/ui/scrollbar.rs index 6e33a0b7..b0aafde8 100644 --- a/src/ui/scrollbar.rs +++ b/src/ui/scrollbar.rs @@ -1,7 +1,6 @@ use super::style::SharedTheme; use easy_cast::CastFloat; use ratatui::{ - backend::Backend, buffer::Buffer, layout::{Margin, Rect}, style::Style, @@ -129,8 +128,8 @@ impl Widget for Scrollbar { } } -pub fn draw_scrollbar( - f: &mut Frame, +pub fn draw_scrollbar( + f: &mut Frame, r: Rect, theme: &SharedTheme, max: usize, diff --git a/src/ui/scrolllist.rs b/src/ui/scrolllist.rs index bf0b8a3b..9d4f80a8 100644 --- a/src/ui/scrolllist.rs +++ b/src/ui/scrolllist.rs @@ -1,6 +1,5 @@ use super::style::SharedTheme; use ratatui::{ - backend::Backend, buffer::Buffer, layout::Rect, style::Style, @@ -58,8 +57,8 @@ where } } -pub fn draw_list<'b, B: Backend, L, S>( - f: &mut Frame, +pub fn draw_list<'b, L, S>( + f: &mut Frame, r: Rect, title: &'b str, items: L, @@ -78,8 +77,8 @@ pub fn draw_list<'b, B: Backend, L, S>( f.render_widget(list, r); } -pub fn draw_list_block<'b, B: Backend, L, S>( - f: &mut Frame, +pub fn draw_list_block<'b, L, S>( + f: &mut Frame, r: Rect, block: Block<'b>, items: L, diff --git a/typos.toml b/typos.toml new file mode 100644 index 00000000..e69de29b