From 904885e001bddd3c2b36311d69debbc26c3623ca Mon Sep 17 00:00:00 2001 From: extrawurst Date: Wed, 19 Apr 2023 14:46:09 +0200 Subject: [PATCH] tui -> ratatui tui is not maintained anymore and it seems that ratatui is the successor: https://github.com/fdehau/tui-rs/issues/654 --- Cargo.lock | 34 +++++++++---------- Cargo.toml | 4 +-- src/app.rs | 12 +++---- src/cmdbar.rs | 4 +-- src/components/blame_file.rs | 4 +-- src/components/branchlist.rs | 4 +-- src/components/changes.rs | 2 +- src/components/commit.rs | 10 +++--- .../commit_details/compare_details.rs | 2 +- src/components/commit_details/details.rs | 8 ++--- src/components/commit_details/mod.rs | 2 +- src/components/commit_details/style.rs | 2 +- src/components/commitlist.rs | 10 +++--- src/components/compare_commits.rs | 2 +- src/components/create_branch.rs | 2 +- src/components/cred.rs | 2 +- src/components/diff.rs | 4 +-- src/components/externaleditor.rs | 8 ++--- src/components/fetch.rs | 2 +- src/components/file_find_popup.rs | 4 +-- src/components/file_revlog.rs | 2 +- src/components/help.rs | 4 +-- src/components/inspect_commit.rs | 2 +- src/components/mod.rs | 4 +-- src/components/msg.rs | 4 +-- src/components/options_popup.rs | 2 +- src/components/pull.rs | 2 +- src/components/push.rs | 2 +- src/components/push_tags.rs | 2 +- src/components/rename_branch.rs | 2 +- src/components/reset.rs | 4 +-- src/components/reset_popup.rs | 2 +- src/components/revision_files.rs | 14 ++++---- src/components/revision_files_popup.rs | 4 ++- src/components/stashmsg.rs | 2 +- src/components/status_tree.rs | 12 ++++--- src/components/submodules.rs | 6 ++-- src/components/syntax_text.rs | 4 +-- src/components/tag_commit.rs | 2 +- src/components/taglist.rs | 4 +-- src/components/textinput.rs | 6 ++-- src/components/utils/scroll_horizontal.rs | 2 +- src/components/utils/scroll_vertical.rs | 2 +- src/main.rs | 8 ++--- src/spinner.rs | 6 ++-- src/tabs/files.rs | 6 ++-- src/tabs/revlog.rs | 6 ++-- src/tabs/stashing.rs | 10 +++--- src/tabs/stashlist.rs | 6 ++-- src/tabs/status.rs | 24 ++++++------- src/ui/mod.rs | 4 +-- src/ui/reflow.rs | 2 +- src/ui/scrollbar.rs | 4 +-- src/ui/scrolllist.rs | 4 +-- src/ui/stateful_paragraph.rs | 4 +-- src/ui/style.rs | 2 +- src/ui/syntax_text.rs | 19 ++++++----- 57 files changed, 161 insertions(+), 156 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 893f2beeda..d51e3e9556 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -331,9 +331,9 @@ dependencies = [ [[package]] name = "crossterm" -version = "0.25.0" +version = "0.26.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e64e6c0fbe2c17357405f7c758c1ef960fce08bdfb2c03d88d2a18d7e09c4b67" +checksum = "a84cda67535339806297f1b331d6dd6320470d2a0fe65381e79ee9e156dd3d13" dependencies = [ "bitflags", "crossterm_winapi", @@ -785,6 +785,7 @@ dependencies = [ "once_cell", "pprof", "pretty_assertions", + "ratatui", "rayon-core", "ron", "scopeguard", @@ -795,7 +796,6 @@ dependencies = [ "syntect", "tempfile", "textwrap", - "tui", "unicode-segmentation", "unicode-truncate", "unicode-width", @@ -1450,6 +1450,20 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "ratatui" +version = "0.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dcc0d032bccba900ee32151ec0265667535c230169f5a011154cdcd984e16829" +dependencies = [ + "bitflags", + "cassowary", + "crossterm", + "serde", + "unicode-segmentation", + "unicode-width", +] + [[package]] name = "rayon-core" version = "1.11.0" @@ -1926,20 +1940,6 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" -[[package]] -name = "tui" -version = "0.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccdd26cbd674007e649a272da4475fb666d3aa0ad0531da7136db6fab0e5bad1" -dependencies = [ - "bitflags", - "cassowary", - "crossterm", - "serde", - "unicode-segmentation", - "unicode-width", -] - [[package]] name = "unicode-bidi" version = "0.3.10" diff --git a/Cargo.toml b/Cargo.toml index 785ab7ea61..1f9cb58987 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,7 +29,7 @@ bytesize = { version = "1.2", default-features = false } chrono = { version = "0.4", default-features = false, features = [ "clock" ] } clap = { version = "4.1", features = [ "env", "cargo" ] } crossbeam-channel = "0.5" -crossterm = { version = "0.25", features = [ "serde" ] } +crossterm = { version = "0.26.1", features = [ "serde" ] } dirs-next = "2.0" easy-cast = "0.5" filetreelist = { path = "./filetreelist", version = "0.5" } @@ -40,6 +40,7 @@ log = "0.4" notify = "5.1" notify-debouncer-mini = "0.2" once_cell = "1" +ratatui = { version = "0.20", default-features = false, features = ['crossterm', 'serde'] } rayon-core = "1.11" ron = "0.8" scopeguard = "1.1" @@ -49,7 +50,6 @@ simplelog = { version = "0.12", default-features = false } struct-patch = "0.2" syntect = { version = "5.0", default-features = false, features = ["parsing", "default-syntaxes", "default-themes", "html"] } textwrap = "0.16" -tui = { version = "0.19", default-features = false, features = ['crossterm', 'serde'] } unicode-segmentation = "1.10" unicode-truncate = "0.2" unicode-width = "0.1" diff --git a/src/app.rs b/src/app.rs index cb90c51509..60db251d5e 100644 --- a/src/app.rs +++ b/src/app.rs @@ -34,12 +34,7 @@ use asyncgit::{ }; use crossbeam_channel::Sender; use crossterm::event::{Event, KeyEvent}; -use std::{ - cell::{Cell, RefCell}, - path::Path, - rc::Rc, -}; -use tui::{ +use ratatui::{ backend::Backend, layout::{ Alignment, Constraint, Direction, Layout, Margin, Rect, @@ -48,6 +43,11 @@ use tui::{ widgets::{Block, Borders, Paragraph, Tabs}, Frame, }; +use std::{ + cell::{Cell, RefCell}, + path::Path, + rc::Rc, +}; use unicode_width::UnicodeWidthStr; #[derive(Clone)] diff --git a/src/cmdbar.rs b/src/cmdbar.rs index fa8b28425b..f3888a058f 100644 --- a/src/cmdbar.rs +++ b/src/cmdbar.rs @@ -2,14 +2,14 @@ use crate::{ components::CommandInfo, keys::SharedKeyConfig, strings, ui::style::SharedTheme, }; -use std::borrow::Cow; -use tui::{ +use ratatui::{ backend::Backend, layout::{Alignment, Rect}, text::{Span, Spans}, widgets::Paragraph, Frame, }; +use std::borrow::Cow; use unicode_width::UnicodeWidthStr; enum DrawListEntry { diff --git a/src/components/blame_file.rs b/src/components/blame_file.rs index 85336824c0..632006fa6e 100644 --- a/src/components/blame_file.rs +++ b/src/components/blame_file.rs @@ -18,8 +18,7 @@ use asyncgit::{ }; use crossbeam_channel::Sender; use crossterm::event::Event; -use std::convert::TryInto; -use tui::{ +use ratatui::{ backend::Backend, layout::{Constraint, Rect}, symbols::line::VERTICAL, @@ -27,6 +26,7 @@ use tui::{ widgets::{Block, Borders, Cell, Clear, Row, Table, TableState}, Frame, }; +use std::convert::TryInto; static NO_COMMIT_ID: &str = "0000000"; static NO_AUTHOR: &str = ""; diff --git a/src/components/branchlist.rs b/src/components/branchlist.rs index 2657725a14..2da368b211 100644 --- a/src/components/branchlist.rs +++ b/src/components/branchlist.rs @@ -26,8 +26,7 @@ use asyncgit::{ AsyncGitNotification, }; use crossterm::event::Event; -use std::{cell::Cell, convert::TryInto}; -use tui::{ +use ratatui::{ backend::Backend, layout::{ Alignment, Constraint, Direction, Layout, Margin, Rect, @@ -36,6 +35,7 @@ use tui::{ widgets::{Block, BorderType, Borders, Clear, Paragraph, Tabs}, Frame, }; +use std::{cell::Cell, convert::TryInto}; use ui::style::SharedTheme; use unicode_truncate::UnicodeTruncateStr; diff --git a/src/components/changes.rs b/src/components/changes.rs index 27458e8e91..3b573a9910 100644 --- a/src/components/changes.rs +++ b/src/components/changes.rs @@ -17,8 +17,8 @@ use asyncgit::{ StatusItem, StatusItemType, }; use crossterm::event::Event; +use ratatui::{backend::Backend, layout::Rect, Frame}; use std::path::Path; -use tui::{backend::Backend, layout::Rect, Frame}; /// pub struct ChangesComponent { diff --git a/src/components/commit.rs b/src/components/commit.rs index 605c70c907..edbd6617d2 100644 --- a/src/components/commit.rs +++ b/src/components/commit.rs @@ -21,16 +21,16 @@ use asyncgit::{ }; use crossterm::event::Event; use easy_cast::Cast; -use std::{ - fs::{read_to_string, File}, - io::{Read, Write}, -}; -use tui::{ +use ratatui::{ backend::Backend, layout::{Alignment, Rect}, widgets::Paragraph, Frame, }; +use std::{ + fs::{read_to_string, File}, + io::{Read, Write}, +}; enum CommitResult { ComitDone, diff --git a/src/components/commit_details/compare_details.rs b/src/components/commit_details/compare_details.rs index c993b8d139..6a3911ea81 100644 --- a/src/components/commit_details/compare_details.rs +++ b/src/components/commit_details/compare_details.rs @@ -14,7 +14,7 @@ use crate::{ use anyhow::Result; use asyncgit::sync::{self, CommitDetails, CommitId, RepoPathRef}; use crossterm::event::Event; -use tui::{ +use ratatui::{ backend::Backend, layout::{Constraint, Direction, Layout, Rect}, text::{Span, Spans, Text}, diff --git a/src/components/commit_details/details.rs b/src/components/commit_details/details.rs index 83430a28bd..254f6e787e 100644 --- a/src/components/commit_details/details.rs +++ b/src/components/commit_details/details.rs @@ -15,16 +15,16 @@ use asyncgit::sync::{ self, CommitDetails, CommitId, CommitMessage, RepoPathRef, Tag, }; use crossterm::event::Event; -use std::clone::Clone; -use std::{borrow::Cow, cell::Cell}; -use sync::CommitTags; -use tui::{ +use ratatui::{ backend::Backend, layout::{Constraint, Direction, Layout, Rect}, style::{Modifier, Style}, text::{Span, Spans, Text}, Frame, }; +use std::clone::Clone; +use std::{borrow::Cow, cell::Cell}; +use sync::CommitTags; use super::style::Detail; diff --git a/src/components/commit_details/mod.rs b/src/components/commit_details/mod.rs index 0612bdcc0b..35317670e5 100644 --- a/src/components/commit_details/mod.rs +++ b/src/components/commit_details/mod.rs @@ -22,7 +22,7 @@ use compare_details::CompareDetailsComponent; use crossbeam_channel::Sender; use crossterm::event::Event; use details::DetailsComponent; -use tui::{ +use ratatui::{ backend::Backend, layout::{Constraint, Direction, Layout, Rect}, Frame, diff --git a/src/components/commit_details/style.rs b/src/components/commit_details/style.rs index 97555c19b3..5082497c71 100644 --- a/src/components/commit_details/style.rs +++ b/src/components/commit_details/style.rs @@ -1,6 +1,6 @@ use crate::{strings, ui::style::SharedTheme}; +use ratatui::text::Span; use std::borrow::Cow; -use tui::text::Span; pub enum Detail { Author, diff --git a/src/components/commitlist.rs b/src/components/commitlist.rs index 48cccc1a36..f340b9bdc2 100644 --- a/src/components/commitlist.rs +++ b/src/components/commitlist.rs @@ -19,17 +19,17 @@ use asyncgit::sync::{ use chrono::{DateTime, Local}; use crossterm::event::Event; use itertools::Itertools; -use std::{ - borrow::Cow, cell::Cell, cmp, collections::BTreeMap, - convert::TryFrom, time::Instant, -}; -use tui::{ +use ratatui::{ backend::Backend, layout::{Alignment, Rect}, text::{Span, Spans}, widgets::{Block, Borders, Paragraph}, Frame, }; +use std::{ + borrow::Cow, cell::Cell, cmp, collections::BTreeMap, + convert::TryFrom, time::Instant, +}; const ELEMENTS_PER_LINE: usize = 9; diff --git a/src/components/compare_commits.rs b/src/components/compare_commits.rs index 3475c114e8..6fa1186ece 100644 --- a/src/components/compare_commits.rs +++ b/src/components/compare_commits.rs @@ -18,7 +18,7 @@ use asyncgit::{ }; use crossbeam_channel::Sender; use crossterm::event::Event; -use tui::{ +use ratatui::{ backend::Backend, layout::{Constraint, Direction, Layout, Rect}, widgets::Clear, diff --git a/src/components/create_branch.rs b/src/components/create_branch.rs index 393eb54e42..c81a45b66a 100644 --- a/src/components/create_branch.rs +++ b/src/components/create_branch.rs @@ -13,7 +13,7 @@ use anyhow::Result; use asyncgit::sync::{self, RepoPathRef}; use crossterm::event::Event; use easy_cast::Cast; -use tui::{ +use ratatui::{ backend::Backend, layout::Rect, widgets::Paragraph, Frame, }; diff --git a/src/components/cred.rs b/src/components/cred.rs index 2a72d4cd5b..7cecc85acd 100644 --- a/src/components/cred.rs +++ b/src/components/cred.rs @@ -1,6 +1,6 @@ use anyhow::Result; use crossterm::event::Event; -use tui::{backend::Backend, layout::Rect, Frame}; +use ratatui::{backend::Backend, layout::Rect, Frame}; use asyncgit::sync::cred::BasicAuthCredential; diff --git a/src/components/diff.rs b/src/components/diff.rs index 6a1500338a..76b174f3c5 100644 --- a/src/components/diff.rs +++ b/src/components/diff.rs @@ -20,8 +20,7 @@ use asyncgit::{ }; use bytesize::ByteSize; use crossterm::event::Event; -use std::{borrow::Cow, cell::Cell, cmp, path::Path}; -use tui::{ +use ratatui::{ backend::Backend, layout::Rect, symbols, @@ -29,6 +28,7 @@ use tui::{ widgets::{Block, Borders, Paragraph}, Frame, }; +use std::{borrow::Cow, cell::Cell, cmp, path::Path}; #[derive(Default)] struct Current { diff --git a/src/components/externaleditor.rs b/src/components/externaleditor.rs index 3c9c918602..fd9bd8b65a 100644 --- a/src/components/externaleditor.rs +++ b/src/components/externaleditor.rs @@ -16,16 +16,16 @@ use crossterm::{ terminal::{EnterAlternateScreen, LeaveAlternateScreen}, ExecutableCommand, }; -use scopeguard::defer; -use std::ffi::OsStr; -use std::{env, io, path::Path, process::Command}; -use tui::{ +use ratatui::{ backend::Backend, layout::Rect, text::{Span, Spans}, widgets::{Block, BorderType, Borders, Clear, Paragraph}, Frame, }; +use scopeguard::defer; +use std::ffi::OsStr; +use std::{env, io, path::Path, process::Command}; /// pub struct ExternalEditorComponent { diff --git a/src/components/fetch.rs b/src/components/fetch.rs index 17b3f829e3..80edaf642f 100644 --- a/src/components/fetch.rs +++ b/src/components/fetch.rs @@ -22,7 +22,7 @@ use asyncgit::{ }; use crossbeam_channel::Sender; use crossterm::event::Event; -use tui::{ +use ratatui::{ backend::Backend, layout::Rect, text::Span, diff --git a/src/components/file_find_popup.rs b/src/components/file_find_popup.rs index 36f1c98308..1385e63e61 100644 --- a/src/components/file_find_popup.rs +++ b/src/components/file_find_popup.rs @@ -13,14 +13,14 @@ use anyhow::Result; use asyncgit::sync::TreeFile; use crossterm::event::Event; use fuzzy_matcher::FuzzyMatcher; -use std::borrow::Cow; -use tui::{ +use ratatui::{ backend::Backend, layout::{Constraint, Direction, Layout, Margin, Rect}, text::{Span, Spans}, widgets::{Block, Borders, Clear}, Frame, }; +use std::borrow::Cow; pub struct FileFindPopup { queue: Queue, diff --git a/src/components/file_revlog.rs b/src/components/file_revlog.rs index 2017091812..477e5a84e0 100644 --- a/src/components/file_revlog.rs +++ b/src/components/file_revlog.rs @@ -24,7 +24,7 @@ use asyncgit::{ use chrono::{DateTime, Local}; use crossbeam_channel::Sender; use crossterm::event::Event; -use tui::{ +use ratatui::{ backend::Backend, layout::{Constraint, Direction, Layout, Rect}, text::{Span, Spans, Text}, diff --git a/src/components/help.rs b/src/components/help.rs index a965f295ba..f2c45e3d64 100644 --- a/src/components/help.rs +++ b/src/components/help.rs @@ -11,8 +11,7 @@ use anyhow::Result; use asyncgit::hash; use crossterm::event::Event; use itertools::Itertools; -use std::{borrow::Cow, cmp, convert::TryFrom}; -use tui::{ +use ratatui::{ backend::Backend, layout::{Alignment, Constraint, Direction, Layout, Rect}, style::{Modifier, Style}, @@ -20,6 +19,7 @@ use tui::{ widgets::{Block, BorderType, Borders, Clear, Paragraph}, Frame, }; +use std::{borrow::Cow, cmp, convert::TryFrom}; use ui::style::SharedTheme; /// diff --git a/src/components/inspect_commit.rs b/src/components/inspect_commit.rs index a95db88f4f..63cf2f8295 100644 --- a/src/components/inspect_commit.rs +++ b/src/components/inspect_commit.rs @@ -17,7 +17,7 @@ use asyncgit::{ }; use crossbeam_channel::Sender; use crossterm::event::Event; -use tui::{ +use ratatui::{ backend::Backend, layout::{Constraint, Direction, Layout, Rect}, widgets::Clear, diff --git a/src/components/mod.rs b/src/components/mod.rs index 77824de80d..aca4610640 100644 --- a/src/components/mod.rs +++ b/src/components/mod.rs @@ -72,14 +72,14 @@ pub use utils::filetree::FileTreeItemKind; use crate::ui::style::Theme; use anyhow::Result; use crossterm::event::Event; -use std::convert::From; -use tui::{ +use ratatui::{ backend::Backend, layout::{Alignment, Rect}, text::{Span, Text}, widgets::{Block, BorderType, Borders, Paragraph, Wrap}, Frame, }; +use std::convert::From; /// creates accessors for a list of components /// diff --git a/src/components/msg.rs b/src/components/msg.rs index 29a3ece736..31cb5c3724 100644 --- a/src/components/msg.rs +++ b/src/components/msg.rs @@ -7,14 +7,14 @@ use crate::{ strings, ui, }; use crossterm::event::Event; -use std::convert::TryFrom; -use tui::{ +use ratatui::{ backend::Backend, layout::{Alignment, Rect}, text::Span, widgets::{Block, BorderType, Borders, Clear, Paragraph, Wrap}, Frame, }; +use std::convert::TryFrom; use ui::style::SharedTheme; pub struct MsgComponent { title: String, diff --git a/src/components/options_popup.rs b/src/components/options_popup.rs index 09a98501d3..96968b608c 100644 --- a/src/components/options_popup.rs +++ b/src/components/options_popup.rs @@ -13,7 +13,7 @@ use crate::{ use anyhow::Result; use asyncgit::sync::ShowUntrackedFilesConfig; use crossterm::event::Event; -use tui::{ +use ratatui::{ backend::Backend, layout::{Alignment, Rect}, style::{Modifier, Style}, diff --git a/src/components/pull.rs b/src/components/pull.rs index 4ac525fa49..76c91414f0 100644 --- a/src/components/pull.rs +++ b/src/components/pull.rs @@ -23,7 +23,7 @@ use asyncgit::{ }; use crossbeam_channel::Sender; use crossterm::event::Event; -use tui::{ +use ratatui::{ backend::Backend, layout::Rect, text::Span, diff --git a/src/components/push.rs b/src/components/push.rs index a8295a7e3f..e272cefe1b 100644 --- a/src/components/push.rs +++ b/src/components/push.rs @@ -22,7 +22,7 @@ use asyncgit::{ }; use crossbeam_channel::Sender; use crossterm::event::Event; -use tui::{ +use ratatui::{ backend::Backend, layout::Rect, text::Span, diff --git a/src/components/push_tags.rs b/src/components/push_tags.rs index 0d5e9a048e..89668c807e 100644 --- a/src/components/push_tags.rs +++ b/src/components/push_tags.rs @@ -22,7 +22,7 @@ use asyncgit::{ }; use crossbeam_channel::Sender; use crossterm::event::Event; -use tui::{ +use ratatui::{ backend::Backend, layout::Rect, text::Span, diff --git a/src/components/rename_branch.rs b/src/components/rename_branch.rs index 08215e4fb4..6ac5dd4ea2 100644 --- a/src/components/rename_branch.rs +++ b/src/components/rename_branch.rs @@ -12,7 +12,7 @@ use crate::{ use anyhow::Result; use asyncgit::sync::{self, RepoPathRef}; use crossterm::event::Event; -use tui::{backend::Backend, layout::Rect, Frame}; +use ratatui::{backend::Backend, layout::Rect, Frame}; pub struct RenameBranchComponent { repo: RepoPathRef, diff --git a/src/components/reset.rs b/src/components/reset.rs index c5e9f0cde3..6130419f65 100644 --- a/src/components/reset.rs +++ b/src/components/reset.rs @@ -9,10 +9,10 @@ use crate::{ }; use anyhow::Result; use crossterm::event::Event; -use std::borrow::Cow; -use tui::{ +use ratatui::{ backend::Backend, layout::Rect, text::Text, widgets::Clear, Frame, }; +use std::borrow::Cow; use ui::style::SharedTheme; /// diff --git a/src/components/reset_popup.rs b/src/components/reset_popup.rs index cbe3316c5c..f316c45a15 100644 --- a/src/components/reset_popup.rs +++ b/src/components/reset_popup.rs @@ -14,7 +14,7 @@ use asyncgit::{ sync::{CommitId, RepoPath, RepoPathRef, ResetType}, }; use crossterm::event::Event; -use tui::{ +use ratatui::{ backend::Backend, layout::{Alignment, Rect}, text::{Span, Spans}, diff --git a/src/components/revision_files.rs b/src/components/revision_files.rs index a6fccd150f..c71feb99af 100644 --- a/src/components/revision_files.rs +++ b/src/components/revision_files.rs @@ -22,19 +22,19 @@ use asyncgit::{ use crossbeam_channel::Sender; use crossterm::event::Event; use filetreelist::{FileTree, FileTreeItem}; -use std::{borrow::Cow, fmt::Write}; -use std::{ - collections::BTreeSet, - convert::From, - path::{Path, PathBuf}, -}; -use tui::{ +use ratatui::{ backend::Backend, layout::{Constraint, Direction, Layout, Rect}, text::Span, widgets::{Block, Borders}, Frame, }; +use std::{borrow::Cow, fmt::Write}; +use std::{ + collections::BTreeSet, + convert::From, + path::{Path, PathBuf}, +}; use unicode_truncate::UnicodeTruncateStr; use unicode_width::UnicodeWidthStr; diff --git a/src/components/revision_files_popup.rs b/src/components/revision_files_popup.rs index 032a769679..9c24b72aa6 100644 --- a/src/components/revision_files_popup.rs +++ b/src/components/revision_files_popup.rs @@ -19,7 +19,9 @@ use asyncgit::{ }; use crossbeam_channel::Sender; use crossterm::event::Event; -use tui::{backend::Backend, layout::Rect, widgets::Clear, Frame}; +use ratatui::{ + backend::Backend, layout::Rect, widgets::Clear, Frame, +}; #[derive(Clone, Debug)] pub struct FileTreeOpen { diff --git a/src/components/stashmsg.rs b/src/components/stashmsg.rs index 7ea0dca5f0..bd73931142 100644 --- a/src/components/stashmsg.rs +++ b/src/components/stashmsg.rs @@ -13,7 +13,7 @@ use crate::{ use anyhow::Result; use asyncgit::sync::{self, RepoPathRef}; use crossterm::event::Event; -use tui::{backend::Backend, layout::Rect, Frame}; +use ratatui::{backend::Backend, layout::Rect, Frame}; pub struct StashMsgComponent { repo: RepoPathRef, diff --git a/src/components/status_tree.rs b/src/components/status_tree.rs index d389741b58..3c3031257b 100644 --- a/src/components/status_tree.rs +++ b/src/components/status_tree.rs @@ -16,8 +16,8 @@ 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 std::{borrow::Cow, cell::Cell, convert::From, path::Path}; -use tui::{backend::Backend, layout::Rect, text::Span, Frame}; //TODO: use new `filetreelist` crate @@ -599,8 +599,9 @@ mod tests { //5 c1 // Set up test terminal - let test_backend = tui::backend::TestBackend::new(100, 100); - let mut terminal = tui::Terminal::new(test_backend) + let test_backend = + ratatui::backend::TestBackend::new(100, 100); + let mut terminal = ratatui::Terminal::new(test_backend) .expect("Unable to set up terminal"); let mut frame = terminal.get_frame(); @@ -640,8 +641,9 @@ mod tests { //5 d2 // Set up test terminal - let test_backend = tui::backend::TestBackend::new(100, 100); - let mut terminal = tui::Terminal::new(test_backend) + let test_backend = + ratatui::backend::TestBackend::new(100, 100); + let mut terminal = ratatui::Terminal::new(test_backend) .expect("Unable to set up terminal"); let mut frame = terminal.get_frame(); diff --git a/src/components/submodules.rs b/src/components/submodules.rs index 949f01c0ab..3ec36268d1 100644 --- a/src/components/submodules.rs +++ b/src/components/submodules.rs @@ -16,8 +16,7 @@ use asyncgit::sync::{ SubmoduleParentInfo, }; use crossterm::event::Event; -use std::{cell::Cell, convert::TryInto}; -use tui::{ +use ratatui::{ backend::Backend, layout::{ Alignment, Constraint, Direction, Layout, Margin, Rect, @@ -26,6 +25,7 @@ use tui::{ widgets::{Block, Borders, Clear, Paragraph}, Frame, }; +use std::{cell::Cell, convert::TryInto}; use ui::style::SharedTheme; use unicode_truncate::UnicodeTruncateStr; @@ -67,7 +67,7 @@ impl DrawableComponent for SubmodulesListComponent { f.render_widget( Block::default() .title(strings::POPUP_TITLE_SUBMODULES) - .border_type(tui::widgets::BorderType::Thick) + .border_type(ratatui::widgets::BorderType::Thick) .borders(Borders::ALL), area, ); diff --git a/src/components/syntax_text.rs b/src/components/syntax_text.rs index d959917677..d96705d7a8 100644 --- a/src/components/syntax_text.rs +++ b/src/components/syntax_text.rs @@ -22,14 +22,14 @@ use crossbeam_channel::Sender; use crossterm::event::Event; use filetreelist::MoveSelection; use itertools::Either; -use std::{cell::Cell, convert::From, path::Path}; -use tui::{ +use ratatui::{ backend::Backend, layout::Rect, text::Text, widgets::{Block, Borders, Wrap}, Frame, }; +use std::{cell::Cell, convert::From, path::Path}; pub struct SyntaxTextComponent { repo: RepoPathRef, diff --git a/src/components/tag_commit.rs b/src/components/tag_commit.rs index cf82dfa3fd..e3f6e435d9 100644 --- a/src/components/tag_commit.rs +++ b/src/components/tag_commit.rs @@ -12,7 +12,7 @@ use crate::{ use anyhow::Result; use asyncgit::sync::{self, CommitId, RepoPathRef}; use crossterm::event::Event; -use tui::{backend::Backend, layout::Rect, Frame}; +use ratatui::{backend::Backend, layout::Rect, Frame}; enum Mode { Name, diff --git a/src/components/taglist.rs b/src/components/taglist.rs index 2020d8a9fa..eba6a03213 100644 --- a/src/components/taglist.rs +++ b/src/components/taglist.rs @@ -25,8 +25,7 @@ use asyncgit::{ }; use crossbeam_channel::Sender; use crossterm::event::Event; -use std::convert::TryInto; -use tui::{ +use ratatui::{ backend::Backend, layout::{Constraint, Margin, Rect}, text::Span, @@ -36,6 +35,7 @@ use tui::{ }, Frame, }; +use std::convert::TryInto; use ui::style::SharedTheme; /// diff --git a/src/components/textinput.rs b/src/components/textinput.rs index a87e50ba14..34547161ec 100644 --- a/src/components/textinput.rs +++ b/src/components/textinput.rs @@ -13,8 +13,7 @@ use crate::{ use anyhow::Result; use crossterm::event::{Event, KeyCode, KeyModifiers}; use itertools::Itertools; -use std::{cell::Cell, collections::HashMap, ops::Range}; -use tui::{ +use ratatui::{ backend::Backend, layout::{Alignment, Rect}, style::Modifier, @@ -22,6 +21,7 @@ use tui::{ widgets::{Clear, Paragraph}, Frame, }; +use std::{cell::Cell, collections::HashMap, ops::Range}; #[derive(PartialEq, Eq)] pub enum InputType { @@ -523,7 +523,7 @@ impl Component for TextInputComponent { #[cfg(test)] mod tests { use super::*; - use tui::{style::Style, text::Span}; + use ratatui::{style::Style, text::Span}; #[test] fn test_smoke() { diff --git a/src/components/utils/scroll_horizontal.rs b/src/components/utils/scroll_horizontal.rs index 58ea31a77d..4cfe53b04a 100644 --- a/src/components/utils/scroll_horizontal.rs +++ b/src/components/utils/scroll_horizontal.rs @@ -1,6 +1,6 @@ use std::cell::Cell; -use tui::{backend::Backend, layout::Rect, Frame}; +use ratatui::{backend::Backend, layout::Rect, Frame}; use crate::{ components::HorizontalScrollType, diff --git a/src/components/utils/scroll_vertical.rs b/src/components/utils/scroll_vertical.rs index a8a62a0697..02b46ac9b5 100644 --- a/src/components/utils/scroll_vertical.rs +++ b/src/components/utils/scroll_vertical.rs @@ -1,6 +1,6 @@ use std::cell::Cell; -use tui::{backend::Backend, layout::Rect, Frame}; +use ratatui::{backend::Backend, layout::Rect, Frame}; use crate::{ components::ScrollType, diff --git a/src/main.rs b/src/main.rs index 2faa4f0317..26e4b5aa71 100644 --- a/src/main.rs +++ b/src/main.rs @@ -67,6 +67,10 @@ use crossterm::{ use input::{Input, InputEvent, InputState}; use keys::KeyConfig; use profiler::Profiler; +use ratatui::{ + backend::{Backend, CrosstermBackend}, + Terminal, +}; use scopeguard::defer; use scopetime::scope_time; use spinner::Spinner; @@ -76,10 +80,6 @@ use std::{ panic, process, time::{Duration, Instant}, }; -use tui::{ - backend::{Backend, CrosstermBackend}, - Terminal, -}; use ui::style::Theme; use watcher::RepoWatcher; diff --git a/src/spinner.rs b/src/spinner.rs index 6c561c3cdc..a3a164b136 100644 --- a/src/spinner.rs +++ b/src/spinner.rs @@ -1,5 +1,5 @@ +use ratatui::{backend::Backend, Terminal}; use std::{cell::Cell, char, io}; -use tui::{backend::Backend, Terminal}; // static SPINNER_CHARS: &[char] = &['◢', '◣', '◤', '◥']; // static SPINNER_CHARS: &[char] = &['⢹', '⢺', '⢼', '⣸', '⣇', '⡧', '⡗', '⡏']; @@ -48,7 +48,7 @@ impl Spinner { if self.last_char.get() != char_to_draw { self.last_char.set(char_to_draw); - let c = tui::buffer::Cell::default() + let c = ratatui::buffer::Cell::default() .set_char(char_to_draw) .clone(); @@ -56,7 +56,7 @@ impl Spinner { .backend_mut() .draw(vec![(0_u16, 0_u16, &c)].into_iter())?; - tui::backend::Backend::flush(terminal.backend_mut())?; + ratatui::backend::Backend::flush(terminal.backend_mut())?; } Ok(()) diff --git a/src/tabs/files.rs b/src/tabs/files.rs index dbc194dd72..2d6446d584 100644 --- a/src/tabs/files.rs +++ b/src/tabs/files.rs @@ -81,10 +81,10 @@ impl FilesTab { } impl DrawableComponent for FilesTab { - fn draw( + fn draw( &self, - f: &mut tui::Frame, - rect: tui::layout::Rect, + f: &mut ratatui::Frame, + rect: ratatui::layout::Rect, ) -> Result<()> { if self.is_visible() { self.files.draw(f, rect)?; diff --git a/src/tabs/revlog.rs b/src/tabs/revlog.rs index dfbc71b1db..73ecef0dbb 100644 --- a/src/tabs/revlog.rs +++ b/src/tabs/revlog.rs @@ -19,13 +19,13 @@ use asyncgit::{ }; use crossbeam_channel::Sender; use crossterm::event::Event; -use std::time::Duration; -use sync::CommitTags; -use tui::{ +use ratatui::{ backend::Backend, layout::{Constraint, Direction, Layout, Rect}, Frame, }; +use std::time::Duration; +use sync::CommitTags; const SLICE_SIZE: usize = 1200; diff --git a/src/tabs/stashing.rs b/src/tabs/stashing.rs index 4d50d8d294..9991e21199 100644 --- a/src/tabs/stashing.rs +++ b/src/tabs/stashing.rs @@ -17,12 +17,12 @@ use asyncgit::{ }; use crossbeam_channel::Sender; use crossterm::event::Event; -use std::borrow::Cow; -use tui::{ +use ratatui::{ layout::{Alignment, Constraint, Direction, Layout}, text::{Span, Spans}, widgets::{Block, Borders, Paragraph}, }; +use std::borrow::Cow; #[derive(Default, Clone, Copy, Debug)] pub struct StashingOptions { @@ -140,10 +140,10 @@ impl Stashing { } impl DrawableComponent for Stashing { - fn draw( + fn draw( &self, - f: &mut tui::Frame, - rect: tui::layout::Rect, + f: &mut ratatui::Frame, + rect: ratatui::layout::Rect, ) -> Result<()> { let chunks = Layout::default() .direction(Direction::Horizontal) diff --git a/src/tabs/stashlist.rs b/src/tabs/stashlist.rs index 4a9e1449dd..151ec87be1 100644 --- a/src/tabs/stashlist.rs +++ b/src/tabs/stashlist.rs @@ -148,10 +148,10 @@ impl StashList { } impl DrawableComponent for StashList { - fn draw( + fn draw( &self, - f: &mut tui::Frame, - rect: tui::layout::Rect, + 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 331fe68dc0..0539d5bae6 100644 --- a/src/tabs/status.rs +++ b/src/tabs/status.rs @@ -26,12 +26,12 @@ use asyncgit::{ use crossbeam_channel::Sender; use crossterm::event::Event; use itertools::Itertools; -use std::convert::Into; -use tui::{ +use ratatui::{ layout::{Alignment, Constraint, Direction, Layout}, style::{Color, Style}, widgets::{Block, BorderType, Borders, Paragraph}, }; +use std::convert::Into; /// what part of the screen is focused #[derive(PartialEq)] @@ -82,10 +82,10 @@ pub struct Status { } impl DrawableComponent for Status { - fn draw( + fn draw( &self, - f: &mut tui::Frame, - rect: tui::layout::Rect, + f: &mut ratatui::Frame, + rect: ratatui::layout::Rect, ) -> Result<()> { let repo_unclean = self.repo_state_unclean(); let rects = if repo_unclean { @@ -97,7 +97,7 @@ impl DrawableComponent for Status { ) .split(rect) } else { - vec![rect] + std::rc::Rc::new([rect]) }; let chunks = Layout::default() @@ -215,10 +215,10 @@ impl Status { } } - fn draw_branch_state( + fn draw_branch_state( &self, - f: &mut tui::Frame, - chunks: &[tui::layout::Rect], + f: &mut ratatui::Frame, + chunks: &[ratatui::layout::Rect], ) { if let Some(branch_name) = self.git_branch_name.last() { let ahead_behind = self @@ -296,10 +296,10 @@ impl Status { } } - fn draw_repo_state( + fn draw_repo_state( &self, - f: &mut tui::Frame, - r: tui::layout::Rect, + f: &mut ratatui::Frame, + r: ratatui::layout::Rect, ) { if self.git_state != RepoState::Clean { let txt = Self::repo_state_text( diff --git a/src/ui/mod.rs b/src/ui/mod.rs index 4b1db6ebd1..3bff9e46a8 100644 --- a/src/ui/mod.rs +++ b/src/ui/mod.rs @@ -6,13 +6,13 @@ pub mod style; mod syntax_text; use filetreelist::MoveSelection; +use ratatui::layout::{Constraint, Direction, Layout, Rect}; pub use scrollbar::{draw_scrollbar, Orientation}; pub use scrolllist::{draw_list, draw_list_block}; pub use stateful_paragraph::{ ParagraphState, ScrollPos, StatefulParagraph, }; pub use syntax_text::{AsyncSyntaxJob, SyntaxText}; -use tui::layout::{Constraint, Direction, Layout, Rect}; use crate::keys::{key_match, SharedKeyConfig}; @@ -157,7 +157,7 @@ pub fn common_nav( mod test { use super::{rect_inside, Size}; use pretty_assertions::assert_eq; - use tui::layout::Rect; + use ratatui::layout::Rect; #[test] fn test_small_rect_in_rect() { diff --git a/src/ui/reflow.rs b/src/ui/reflow.rs index 81de4b840c..028d9b2176 100644 --- a/src/ui/reflow.rs +++ b/src/ui/reflow.rs @@ -1,6 +1,6 @@ use crate::string_utils::trim_offset; use easy_cast::Cast; -use tui::text::StyledGrapheme; +use ratatui::text::StyledGrapheme; use unicode_width::UnicodeWidthStr; const NBSP: &str = "\u{00a0}"; diff --git a/src/ui/scrollbar.rs b/src/ui/scrollbar.rs index 3a28fe8213..f2e710d211 100644 --- a/src/ui/scrollbar.rs +++ b/src/ui/scrollbar.rs @@ -1,7 +1,6 @@ use super::style::SharedTheme; use easy_cast::CastFloat; -use std::convert::TryFrom; -use tui::{ +use ratatui::{ backend::Backend, buffer::Buffer, layout::{Margin, Rect}, @@ -13,6 +12,7 @@ use tui::{ widgets::Widget, Frame, }; +use std::convert::TryFrom; pub enum Orientation { Vertical, diff --git a/src/ui/scrolllist.rs b/src/ui/scrolllist.rs index b2af2d6454..6fdc4ed8b6 100644 --- a/src/ui/scrolllist.rs +++ b/src/ui/scrolllist.rs @@ -1,6 +1,5 @@ use super::style::SharedTheme; -use std::iter::Iterator; -use tui::{ +use ratatui::{ backend::Backend, buffer::Buffer, layout::Rect, @@ -9,6 +8,7 @@ use tui::{ widgets::{Block, Borders, List, ListItem, Widget}, Frame, }; +use std::iter::Iterator; /// struct ScrollableList<'b, L, S> diff --git a/src/ui/stateful_paragraph.rs b/src/ui/stateful_paragraph.rs index 40f52f6554..ea4f01800e 100644 --- a/src/ui/stateful_paragraph.rs +++ b/src/ui/stateful_paragraph.rs @@ -1,12 +1,12 @@ use easy_cast::Cast; -use std::iter; -use tui::{ +use ratatui::{ buffer::Buffer, layout::{Alignment, Rect}, style::Style, text::{StyledGrapheme, Text}, widgets::{Block, StatefulWidget, Widget, Wrap}, }; +use std::iter; use unicode_width::UnicodeWidthStr; use super::reflow::{LineComposer, LineTruncator, WordWrapper}; diff --git a/src/ui/style.rs b/src/ui/style.rs index 8fca7e7760..fe6c3cd8a7 100644 --- a/src/ui/style.rs +++ b/src/ui/style.rs @@ -1,5 +1,6 @@ use anyhow::Result; use asyncgit::{DiffLineType, StatusItemType}; +use ratatui::style::{Color, Modifier, Style}; use ron::{ de::from_bytes, ser::{to_string_pretty, PrettyConfig}, @@ -11,7 +12,6 @@ use std::{ path::PathBuf, rc::Rc, }; -use tui::style::{Color, Modifier, Style}; pub type SharedTheme = Rc; diff --git a/src/ui/syntax_text.rs b/src/ui/syntax_text.rs index 2e7de2d1ab..7a90be1c21 100644 --- a/src/ui/syntax_text.rs +++ b/src/ui/syntax_text.rs @@ -3,6 +3,7 @@ use asyncgit::{ ProgressPercent, }; use once_cell::sync::Lazy; +use ratatui::text::{Span, Spans}; use scopetime::scope_time; use std::{ ffi::OsStr, @@ -18,7 +19,6 @@ use syntect::{ }, parsing::{ParseState, ScopeStack, SyntaxSet}, }; -use tui::text::{Span, Spans}; use crate::{AsyncAppNotification, SyntaxHighlightProgress}; @@ -162,7 +162,7 @@ impl SyntaxText { } } -impl<'a> From<&'a SyntaxText> for tui::text::Text<'a> { +impl<'a> From<&'a SyntaxText> for ratatui::text::Text<'a> { fn from(v: &'a SyntaxText) -> Self { let mut result_lines: Vec = Vec::with_capacity(v.lines.len()); @@ -189,22 +189,23 @@ impl<'a> From<&'a SyntaxText> for tui::text::Text<'a> { } } -fn syntact_style_to_tui(style: &Style) -> tui::style::Style { - let mut res = - tui::style::Style::default().fg(tui::style::Color::Rgb( +fn syntact_style_to_tui(style: &Style) -> ratatui::style::Style { + let mut res = ratatui::style::Style::default().fg( + ratatui::style::Color::Rgb( style.foreground.r, style.foreground.g, style.foreground.b, - )); + ), + ); if style.font_style.contains(FontStyle::BOLD) { - res = res.add_modifier(tui::style::Modifier::BOLD); + res = res.add_modifier(ratatui::style::Modifier::BOLD); } if style.font_style.contains(FontStyle::ITALIC) { - res = res.add_modifier(tui::style::Modifier::ITALIC); + res = res.add_modifier(ratatui::style::Modifier::ITALIC); } if style.font_style.contains(FontStyle::UNDERLINE) { - res = res.add_modifier(tui::style::Modifier::UNDERLINED); + res = res.add_modifier(ratatui::style::Modifier::UNDERLINED); } res