tui -> ratatui

tui is not maintained anymore and it seems that ratatui is the successor: https://github.com/fdehau/tui-rs/issues/654
This commit is contained in:
extrawurst 2023-04-19 14:46:09 +02:00
parent 19b820bb35
commit 904885e001
57 changed files with 161 additions and 156 deletions

34
Cargo.lock generated
View file

@ -331,9 +331,9 @@ dependencies = [
[[package]] [[package]]
name = "crossterm" name = "crossterm"
version = "0.25.0" version = "0.26.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e64e6c0fbe2c17357405f7c758c1ef960fce08bdfb2c03d88d2a18d7e09c4b67" checksum = "a84cda67535339806297f1b331d6dd6320470d2a0fe65381e79ee9e156dd3d13"
dependencies = [ dependencies = [
"bitflags", "bitflags",
"crossterm_winapi", "crossterm_winapi",
@ -785,6 +785,7 @@ dependencies = [
"once_cell", "once_cell",
"pprof", "pprof",
"pretty_assertions", "pretty_assertions",
"ratatui",
"rayon-core", "rayon-core",
"ron", "ron",
"scopeguard", "scopeguard",
@ -795,7 +796,6 @@ dependencies = [
"syntect", "syntect",
"tempfile", "tempfile",
"textwrap", "textwrap",
"tui",
"unicode-segmentation", "unicode-segmentation",
"unicode-truncate", "unicode-truncate",
"unicode-width", "unicode-width",
@ -1450,6 +1450,20 @@ dependencies = [
"proc-macro2", "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]] [[package]]
name = "rayon-core" name = "rayon-core"
version = "1.11.0" version = "1.11.0"
@ -1926,20 +1940,6 @@ version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" 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]] [[package]]
name = "unicode-bidi" name = "unicode-bidi"
version = "0.3.10" version = "0.3.10"

View file

@ -29,7 +29,7 @@ bytesize = { version = "1.2", default-features = false }
chrono = { version = "0.4", default-features = false, features = [ "clock" ] } chrono = { version = "0.4", default-features = false, features = [ "clock" ] }
clap = { version = "4.1", features = [ "env", "cargo" ] } clap = { version = "4.1", features = [ "env", "cargo" ] }
crossbeam-channel = "0.5" crossbeam-channel = "0.5"
crossterm = { version = "0.25", features = [ "serde" ] } crossterm = { version = "0.26.1", features = [ "serde" ] }
dirs-next = "2.0" dirs-next = "2.0"
easy-cast = "0.5" easy-cast = "0.5"
filetreelist = { path = "./filetreelist", version = "0.5" } filetreelist = { path = "./filetreelist", version = "0.5" }
@ -40,6 +40,7 @@ log = "0.4"
notify = "5.1" notify = "5.1"
notify-debouncer-mini = "0.2" notify-debouncer-mini = "0.2"
once_cell = "1" once_cell = "1"
ratatui = { version = "0.20", default-features = false, features = ['crossterm', 'serde'] }
rayon-core = "1.11" rayon-core = "1.11"
ron = "0.8" ron = "0.8"
scopeguard = "1.1" scopeguard = "1.1"
@ -49,7 +50,6 @@ simplelog = { version = "0.12", default-features = false }
struct-patch = "0.2" struct-patch = "0.2"
syntect = { version = "5.0", default-features = false, features = ["parsing", "default-syntaxes", "default-themes", "html"] } syntect = { version = "5.0", default-features = false, features = ["parsing", "default-syntaxes", "default-themes", "html"] }
textwrap = "0.16" textwrap = "0.16"
tui = { version = "0.19", default-features = false, features = ['crossterm', 'serde'] }
unicode-segmentation = "1.10" unicode-segmentation = "1.10"
unicode-truncate = "0.2" unicode-truncate = "0.2"
unicode-width = "0.1" unicode-width = "0.1"

View file

@ -34,12 +34,7 @@ use asyncgit::{
}; };
use crossbeam_channel::Sender; use crossbeam_channel::Sender;
use crossterm::event::{Event, KeyEvent}; use crossterm::event::{Event, KeyEvent};
use std::{ use ratatui::{
cell::{Cell, RefCell},
path::Path,
rc::Rc,
};
use tui::{
backend::Backend, backend::Backend,
layout::{ layout::{
Alignment, Constraint, Direction, Layout, Margin, Rect, Alignment, Constraint, Direction, Layout, Margin, Rect,
@ -48,6 +43,11 @@ use tui::{
widgets::{Block, Borders, Paragraph, Tabs}, widgets::{Block, Borders, Paragraph, Tabs},
Frame, Frame,
}; };
use std::{
cell::{Cell, RefCell},
path::Path,
rc::Rc,
};
use unicode_width::UnicodeWidthStr; use unicode_width::UnicodeWidthStr;
#[derive(Clone)] #[derive(Clone)]

View file

@ -2,14 +2,14 @@ use crate::{
components::CommandInfo, keys::SharedKeyConfig, strings, components::CommandInfo, keys::SharedKeyConfig, strings,
ui::style::SharedTheme, ui::style::SharedTheme,
}; };
use std::borrow::Cow; use ratatui::{
use tui::{
backend::Backend, backend::Backend,
layout::{Alignment, Rect}, layout::{Alignment, Rect},
text::{Span, Spans}, text::{Span, Spans},
widgets::Paragraph, widgets::Paragraph,
Frame, Frame,
}; };
use std::borrow::Cow;
use unicode_width::UnicodeWidthStr; use unicode_width::UnicodeWidthStr;
enum DrawListEntry { enum DrawListEntry {

View file

@ -18,8 +18,7 @@ use asyncgit::{
}; };
use crossbeam_channel::Sender; use crossbeam_channel::Sender;
use crossterm::event::Event; use crossterm::event::Event;
use std::convert::TryInto; use ratatui::{
use tui::{
backend::Backend, backend::Backend,
layout::{Constraint, Rect}, layout::{Constraint, Rect},
symbols::line::VERTICAL, symbols::line::VERTICAL,
@ -27,6 +26,7 @@ use tui::{
widgets::{Block, Borders, Cell, Clear, Row, Table, TableState}, widgets::{Block, Borders, Cell, Clear, Row, Table, TableState},
Frame, Frame,
}; };
use std::convert::TryInto;
static NO_COMMIT_ID: &str = "0000000"; static NO_COMMIT_ID: &str = "0000000";
static NO_AUTHOR: &str = "<no author>"; static NO_AUTHOR: &str = "<no author>";

View file

@ -26,8 +26,7 @@ use asyncgit::{
AsyncGitNotification, AsyncGitNotification,
}; };
use crossterm::event::Event; use crossterm::event::Event;
use std::{cell::Cell, convert::TryInto}; use ratatui::{
use tui::{
backend::Backend, backend::Backend,
layout::{ layout::{
Alignment, Constraint, Direction, Layout, Margin, Rect, Alignment, Constraint, Direction, Layout, Margin, Rect,
@ -36,6 +35,7 @@ use tui::{
widgets::{Block, BorderType, Borders, Clear, Paragraph, Tabs}, widgets::{Block, BorderType, Borders, Clear, Paragraph, Tabs},
Frame, Frame,
}; };
use std::{cell::Cell, convert::TryInto};
use ui::style::SharedTheme; use ui::style::SharedTheme;
use unicode_truncate::UnicodeTruncateStr; use unicode_truncate::UnicodeTruncateStr;

View file

@ -17,8 +17,8 @@ use asyncgit::{
StatusItem, StatusItemType, StatusItem, StatusItemType,
}; };
use crossterm::event::Event; use crossterm::event::Event;
use ratatui::{backend::Backend, layout::Rect, Frame};
use std::path::Path; use std::path::Path;
use tui::{backend::Backend, layout::Rect, Frame};
/// ///
pub struct ChangesComponent { pub struct ChangesComponent {

View file

@ -21,16 +21,16 @@ use asyncgit::{
}; };
use crossterm::event::Event; use crossterm::event::Event;
use easy_cast::Cast; use easy_cast::Cast;
use std::{ use ratatui::{
fs::{read_to_string, File},
io::{Read, Write},
};
use tui::{
backend::Backend, backend::Backend,
layout::{Alignment, Rect}, layout::{Alignment, Rect},
widgets::Paragraph, widgets::Paragraph,
Frame, Frame,
}; };
use std::{
fs::{read_to_string, File},
io::{Read, Write},
};
enum CommitResult { enum CommitResult {
ComitDone, ComitDone,

View file

@ -14,7 +14,7 @@ use crate::{
use anyhow::Result; use anyhow::Result;
use asyncgit::sync::{self, CommitDetails, CommitId, RepoPathRef}; use asyncgit::sync::{self, CommitDetails, CommitId, RepoPathRef};
use crossterm::event::Event; use crossterm::event::Event;
use tui::{ use ratatui::{
backend::Backend, backend::Backend,
layout::{Constraint, Direction, Layout, Rect}, layout::{Constraint, Direction, Layout, Rect},
text::{Span, Spans, Text}, text::{Span, Spans, Text},

View file

@ -15,16 +15,16 @@ use asyncgit::sync::{
self, CommitDetails, CommitId, CommitMessage, RepoPathRef, Tag, self, CommitDetails, CommitId, CommitMessage, RepoPathRef, Tag,
}; };
use crossterm::event::Event; use crossterm::event::Event;
use std::clone::Clone; use ratatui::{
use std::{borrow::Cow, cell::Cell};
use sync::CommitTags;
use tui::{
backend::Backend, backend::Backend,
layout::{Constraint, Direction, Layout, Rect}, layout::{Constraint, Direction, Layout, Rect},
style::{Modifier, Style}, style::{Modifier, Style},
text::{Span, Spans, Text}, text::{Span, Spans, Text},
Frame, Frame,
}; };
use std::clone::Clone;
use std::{borrow::Cow, cell::Cell};
use sync::CommitTags;
use super::style::Detail; use super::style::Detail;

View file

@ -22,7 +22,7 @@ use compare_details::CompareDetailsComponent;
use crossbeam_channel::Sender; use crossbeam_channel::Sender;
use crossterm::event::Event; use crossterm::event::Event;
use details::DetailsComponent; use details::DetailsComponent;
use tui::{ use ratatui::{
backend::Backend, backend::Backend,
layout::{Constraint, Direction, Layout, Rect}, layout::{Constraint, Direction, Layout, Rect},
Frame, Frame,

View file

@ -1,6 +1,6 @@
use crate::{strings, ui::style::SharedTheme}; use crate::{strings, ui::style::SharedTheme};
use ratatui::text::Span;
use std::borrow::Cow; use std::borrow::Cow;
use tui::text::Span;
pub enum Detail { pub enum Detail {
Author, Author,

View file

@ -19,17 +19,17 @@ use asyncgit::sync::{
use chrono::{DateTime, Local}; use chrono::{DateTime, Local};
use crossterm::event::Event; use crossterm::event::Event;
use itertools::Itertools; use itertools::Itertools;
use std::{ use ratatui::{
borrow::Cow, cell::Cell, cmp, collections::BTreeMap,
convert::TryFrom, time::Instant,
};
use tui::{
backend::Backend, backend::Backend,
layout::{Alignment, Rect}, layout::{Alignment, Rect},
text::{Span, Spans}, text::{Span, Spans},
widgets::{Block, Borders, Paragraph}, widgets::{Block, Borders, Paragraph},
Frame, Frame,
}; };
use std::{
borrow::Cow, cell::Cell, cmp, collections::BTreeMap,
convert::TryFrom, time::Instant,
};
const ELEMENTS_PER_LINE: usize = 9; const ELEMENTS_PER_LINE: usize = 9;

View file

@ -18,7 +18,7 @@ use asyncgit::{
}; };
use crossbeam_channel::Sender; use crossbeam_channel::Sender;
use crossterm::event::Event; use crossterm::event::Event;
use tui::{ use ratatui::{
backend::Backend, backend::Backend,
layout::{Constraint, Direction, Layout, Rect}, layout::{Constraint, Direction, Layout, Rect},
widgets::Clear, widgets::Clear,

View file

@ -13,7 +13,7 @@ use anyhow::Result;
use asyncgit::sync::{self, RepoPathRef}; use asyncgit::sync::{self, RepoPathRef};
use crossterm::event::Event; use crossterm::event::Event;
use easy_cast::Cast; use easy_cast::Cast;
use tui::{ use ratatui::{
backend::Backend, layout::Rect, widgets::Paragraph, Frame, backend::Backend, layout::Rect, widgets::Paragraph, Frame,
}; };

View file

@ -1,6 +1,6 @@
use anyhow::Result; use anyhow::Result;
use crossterm::event::Event; use crossterm::event::Event;
use tui::{backend::Backend, layout::Rect, Frame}; use ratatui::{backend::Backend, layout::Rect, Frame};
use asyncgit::sync::cred::BasicAuthCredential; use asyncgit::sync::cred::BasicAuthCredential;

View file

@ -20,8 +20,7 @@ use asyncgit::{
}; };
use bytesize::ByteSize; use bytesize::ByteSize;
use crossterm::event::Event; use crossterm::event::Event;
use std::{borrow::Cow, cell::Cell, cmp, path::Path}; use ratatui::{
use tui::{
backend::Backend, backend::Backend,
layout::Rect, layout::Rect,
symbols, symbols,
@ -29,6 +28,7 @@ use tui::{
widgets::{Block, Borders, Paragraph}, widgets::{Block, Borders, Paragraph},
Frame, Frame,
}; };
use std::{borrow::Cow, cell::Cell, cmp, path::Path};
#[derive(Default)] #[derive(Default)]
struct Current { struct Current {

View file

@ -16,16 +16,16 @@ use crossterm::{
terminal::{EnterAlternateScreen, LeaveAlternateScreen}, terminal::{EnterAlternateScreen, LeaveAlternateScreen},
ExecutableCommand, ExecutableCommand,
}; };
use scopeguard::defer; use ratatui::{
use std::ffi::OsStr;
use std::{env, io, path::Path, process::Command};
use tui::{
backend::Backend, backend::Backend,
layout::Rect, layout::Rect,
text::{Span, Spans}, text::{Span, Spans},
widgets::{Block, BorderType, Borders, Clear, Paragraph}, widgets::{Block, BorderType, Borders, Clear, Paragraph},
Frame, Frame,
}; };
use scopeguard::defer;
use std::ffi::OsStr;
use std::{env, io, path::Path, process::Command};
/// ///
pub struct ExternalEditorComponent { pub struct ExternalEditorComponent {

View file

@ -22,7 +22,7 @@ use asyncgit::{
}; };
use crossbeam_channel::Sender; use crossbeam_channel::Sender;
use crossterm::event::Event; use crossterm::event::Event;
use tui::{ use ratatui::{
backend::Backend, backend::Backend,
layout::Rect, layout::Rect,
text::Span, text::Span,

View file

@ -13,14 +13,14 @@ use anyhow::Result;
use asyncgit::sync::TreeFile; use asyncgit::sync::TreeFile;
use crossterm::event::Event; use crossterm::event::Event;
use fuzzy_matcher::FuzzyMatcher; use fuzzy_matcher::FuzzyMatcher;
use std::borrow::Cow; use ratatui::{
use tui::{
backend::Backend, backend::Backend,
layout::{Constraint, Direction, Layout, Margin, Rect}, layout::{Constraint, Direction, Layout, Margin, Rect},
text::{Span, Spans}, text::{Span, Spans},
widgets::{Block, Borders, Clear}, widgets::{Block, Borders, Clear},
Frame, Frame,
}; };
use std::borrow::Cow;
pub struct FileFindPopup { pub struct FileFindPopup {
queue: Queue, queue: Queue,

View file

@ -24,7 +24,7 @@ use asyncgit::{
use chrono::{DateTime, Local}; use chrono::{DateTime, Local};
use crossbeam_channel::Sender; use crossbeam_channel::Sender;
use crossterm::event::Event; use crossterm::event::Event;
use tui::{ use ratatui::{
backend::Backend, backend::Backend,
layout::{Constraint, Direction, Layout, Rect}, layout::{Constraint, Direction, Layout, Rect},
text::{Span, Spans, Text}, text::{Span, Spans, Text},

View file

@ -11,8 +11,7 @@ use anyhow::Result;
use asyncgit::hash; use asyncgit::hash;
use crossterm::event::Event; use crossterm::event::Event;
use itertools::Itertools; use itertools::Itertools;
use std::{borrow::Cow, cmp, convert::TryFrom}; use ratatui::{
use tui::{
backend::Backend, backend::Backend,
layout::{Alignment, Constraint, Direction, Layout, Rect}, layout::{Alignment, Constraint, Direction, Layout, Rect},
style::{Modifier, Style}, style::{Modifier, Style},
@ -20,6 +19,7 @@ use tui::{
widgets::{Block, BorderType, Borders, Clear, Paragraph}, widgets::{Block, BorderType, Borders, Clear, Paragraph},
Frame, Frame,
}; };
use std::{borrow::Cow, cmp, convert::TryFrom};
use ui::style::SharedTheme; use ui::style::SharedTheme;
/// ///

View file

@ -17,7 +17,7 @@ use asyncgit::{
}; };
use crossbeam_channel::Sender; use crossbeam_channel::Sender;
use crossterm::event::Event; use crossterm::event::Event;
use tui::{ use ratatui::{
backend::Backend, backend::Backend,
layout::{Constraint, Direction, Layout, Rect}, layout::{Constraint, Direction, Layout, Rect},
widgets::Clear, widgets::Clear,

View file

@ -72,14 +72,14 @@ pub use utils::filetree::FileTreeItemKind;
use crate::ui::style::Theme; use crate::ui::style::Theme;
use anyhow::Result; use anyhow::Result;
use crossterm::event::Event; use crossterm::event::Event;
use std::convert::From; use ratatui::{
use tui::{
backend::Backend, backend::Backend,
layout::{Alignment, Rect}, layout::{Alignment, Rect},
text::{Span, Text}, text::{Span, Text},
widgets::{Block, BorderType, Borders, Paragraph, Wrap}, widgets::{Block, BorderType, Borders, Paragraph, Wrap},
Frame, Frame,
}; };
use std::convert::From;
/// creates accessors for a list of components /// creates accessors for a list of components
/// ///

View file

@ -7,14 +7,14 @@ use crate::{
strings, ui, strings, ui,
}; };
use crossterm::event::Event; use crossterm::event::Event;
use std::convert::TryFrom; use ratatui::{
use tui::{
backend::Backend, backend::Backend,
layout::{Alignment, Rect}, layout::{Alignment, Rect},
text::Span, text::Span,
widgets::{Block, BorderType, Borders, Clear, Paragraph, Wrap}, widgets::{Block, BorderType, Borders, Clear, Paragraph, Wrap},
Frame, Frame,
}; };
use std::convert::TryFrom;
use ui::style::SharedTheme; use ui::style::SharedTheme;
pub struct MsgComponent { pub struct MsgComponent {
title: String, title: String,

View file

@ -13,7 +13,7 @@ use crate::{
use anyhow::Result; use anyhow::Result;
use asyncgit::sync::ShowUntrackedFilesConfig; use asyncgit::sync::ShowUntrackedFilesConfig;
use crossterm::event::Event; use crossterm::event::Event;
use tui::{ use ratatui::{
backend::Backend, backend::Backend,
layout::{Alignment, Rect}, layout::{Alignment, Rect},
style::{Modifier, Style}, style::{Modifier, Style},

View file

@ -23,7 +23,7 @@ use asyncgit::{
}; };
use crossbeam_channel::Sender; use crossbeam_channel::Sender;
use crossterm::event::Event; use crossterm::event::Event;
use tui::{ use ratatui::{
backend::Backend, backend::Backend,
layout::Rect, layout::Rect,
text::Span, text::Span,

View file

@ -22,7 +22,7 @@ use asyncgit::{
}; };
use crossbeam_channel::Sender; use crossbeam_channel::Sender;
use crossterm::event::Event; use crossterm::event::Event;
use tui::{ use ratatui::{
backend::Backend, backend::Backend,
layout::Rect, layout::Rect,
text::Span, text::Span,

View file

@ -22,7 +22,7 @@ use asyncgit::{
}; };
use crossbeam_channel::Sender; use crossbeam_channel::Sender;
use crossterm::event::Event; use crossterm::event::Event;
use tui::{ use ratatui::{
backend::Backend, backend::Backend,
layout::Rect, layout::Rect,
text::Span, text::Span,

View file

@ -12,7 +12,7 @@ use crate::{
use anyhow::Result; use anyhow::Result;
use asyncgit::sync::{self, RepoPathRef}; use asyncgit::sync::{self, RepoPathRef};
use crossterm::event::Event; use crossterm::event::Event;
use tui::{backend::Backend, layout::Rect, Frame}; use ratatui::{backend::Backend, layout::Rect, Frame};
pub struct RenameBranchComponent { pub struct RenameBranchComponent {
repo: RepoPathRef, repo: RepoPathRef,

View file

@ -9,10 +9,10 @@ use crate::{
}; };
use anyhow::Result; use anyhow::Result;
use crossterm::event::Event; use crossterm::event::Event;
use std::borrow::Cow; use ratatui::{
use tui::{
backend::Backend, layout::Rect, text::Text, widgets::Clear, Frame, backend::Backend, layout::Rect, text::Text, widgets::Clear, Frame,
}; };
use std::borrow::Cow;
use ui::style::SharedTheme; use ui::style::SharedTheme;
/// ///

View file

@ -14,7 +14,7 @@ use asyncgit::{
sync::{CommitId, RepoPath, RepoPathRef, ResetType}, sync::{CommitId, RepoPath, RepoPathRef, ResetType},
}; };
use crossterm::event::Event; use crossterm::event::Event;
use tui::{ use ratatui::{
backend::Backend, backend::Backend,
layout::{Alignment, Rect}, layout::{Alignment, Rect},
text::{Span, Spans}, text::{Span, Spans},

View file

@ -22,19 +22,19 @@ use asyncgit::{
use crossbeam_channel::Sender; use crossbeam_channel::Sender;
use crossterm::event::Event; use crossterm::event::Event;
use filetreelist::{FileTree, FileTreeItem}; use filetreelist::{FileTree, FileTreeItem};
use std::{borrow::Cow, fmt::Write}; use ratatui::{
use std::{
collections::BTreeSet,
convert::From,
path::{Path, PathBuf},
};
use tui::{
backend::Backend, backend::Backend,
layout::{Constraint, Direction, Layout, Rect}, layout::{Constraint, Direction, Layout, Rect},
text::Span, text::Span,
widgets::{Block, Borders}, widgets::{Block, Borders},
Frame, Frame,
}; };
use std::{borrow::Cow, fmt::Write};
use std::{
collections::BTreeSet,
convert::From,
path::{Path, PathBuf},
};
use unicode_truncate::UnicodeTruncateStr; use unicode_truncate::UnicodeTruncateStr;
use unicode_width::UnicodeWidthStr; use unicode_width::UnicodeWidthStr;

View file

@ -19,7 +19,9 @@ use asyncgit::{
}; };
use crossbeam_channel::Sender; use crossbeam_channel::Sender;
use crossterm::event::Event; 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)] #[derive(Clone, Debug)]
pub struct FileTreeOpen { pub struct FileTreeOpen {

View file

@ -13,7 +13,7 @@ use crate::{
use anyhow::Result; use anyhow::Result;
use asyncgit::sync::{self, RepoPathRef}; use asyncgit::sync::{self, RepoPathRef};
use crossterm::event::Event; use crossterm::event::Event;
use tui::{backend::Backend, layout::Rect, Frame}; use ratatui::{backend::Backend, layout::Rect, Frame};
pub struct StashMsgComponent { pub struct StashMsgComponent {
repo: RepoPathRef, repo: RepoPathRef,

View file

@ -16,8 +16,8 @@ use crate::{
use anyhow::Result; use anyhow::Result;
use asyncgit::{hash, sync::CommitId, StatusItem, StatusItemType}; use asyncgit::{hash, sync::CommitId, StatusItem, StatusItemType};
use crossterm::event::Event; use crossterm::event::Event;
use ratatui::{backend::Backend, layout::Rect, text::Span, Frame};
use std::{borrow::Cow, cell::Cell, convert::From, path::Path}; use std::{borrow::Cow, cell::Cell, convert::From, path::Path};
use tui::{backend::Backend, layout::Rect, text::Span, Frame};
//TODO: use new `filetreelist` crate //TODO: use new `filetreelist` crate
@ -599,8 +599,9 @@ mod tests {
//5 c1 //5 c1
// Set up test terminal // Set up test terminal
let test_backend = tui::backend::TestBackend::new(100, 100); let test_backend =
let mut terminal = tui::Terminal::new(test_backend) ratatui::backend::TestBackend::new(100, 100);
let mut terminal = ratatui::Terminal::new(test_backend)
.expect("Unable to set up terminal"); .expect("Unable to set up terminal");
let mut frame = terminal.get_frame(); let mut frame = terminal.get_frame();
@ -640,8 +641,9 @@ mod tests {
//5 d2 //5 d2
// Set up test terminal // Set up test terminal
let test_backend = tui::backend::TestBackend::new(100, 100); let test_backend =
let mut terminal = tui::Terminal::new(test_backend) ratatui::backend::TestBackend::new(100, 100);
let mut terminal = ratatui::Terminal::new(test_backend)
.expect("Unable to set up terminal"); .expect("Unable to set up terminal");
let mut frame = terminal.get_frame(); let mut frame = terminal.get_frame();

View file

@ -16,8 +16,7 @@ use asyncgit::sync::{
SubmoduleParentInfo, SubmoduleParentInfo,
}; };
use crossterm::event::Event; use crossterm::event::Event;
use std::{cell::Cell, convert::TryInto}; use ratatui::{
use tui::{
backend::Backend, backend::Backend,
layout::{ layout::{
Alignment, Constraint, Direction, Layout, Margin, Rect, Alignment, Constraint, Direction, Layout, Margin, Rect,
@ -26,6 +25,7 @@ use tui::{
widgets::{Block, Borders, Clear, Paragraph}, widgets::{Block, Borders, Clear, Paragraph},
Frame, Frame,
}; };
use std::{cell::Cell, convert::TryInto};
use ui::style::SharedTheme; use ui::style::SharedTheme;
use unicode_truncate::UnicodeTruncateStr; use unicode_truncate::UnicodeTruncateStr;
@ -67,7 +67,7 @@ impl DrawableComponent for SubmodulesListComponent {
f.render_widget( f.render_widget(
Block::default() Block::default()
.title(strings::POPUP_TITLE_SUBMODULES) .title(strings::POPUP_TITLE_SUBMODULES)
.border_type(tui::widgets::BorderType::Thick) .border_type(ratatui::widgets::BorderType::Thick)
.borders(Borders::ALL), .borders(Borders::ALL),
area, area,
); );

View file

@ -22,14 +22,14 @@ use crossbeam_channel::Sender;
use crossterm::event::Event; use crossterm::event::Event;
use filetreelist::MoveSelection; use filetreelist::MoveSelection;
use itertools::Either; use itertools::Either;
use std::{cell::Cell, convert::From, path::Path}; use ratatui::{
use tui::{
backend::Backend, backend::Backend,
layout::Rect, layout::Rect,
text::Text, text::Text,
widgets::{Block, Borders, Wrap}, widgets::{Block, Borders, Wrap},
Frame, Frame,
}; };
use std::{cell::Cell, convert::From, path::Path};
pub struct SyntaxTextComponent { pub struct SyntaxTextComponent {
repo: RepoPathRef, repo: RepoPathRef,

View file

@ -12,7 +12,7 @@ use crate::{
use anyhow::Result; use anyhow::Result;
use asyncgit::sync::{self, CommitId, RepoPathRef}; use asyncgit::sync::{self, CommitId, RepoPathRef};
use crossterm::event::Event; use crossterm::event::Event;
use tui::{backend::Backend, layout::Rect, Frame}; use ratatui::{backend::Backend, layout::Rect, Frame};
enum Mode { enum Mode {
Name, Name,

View file

@ -25,8 +25,7 @@ use asyncgit::{
}; };
use crossbeam_channel::Sender; use crossbeam_channel::Sender;
use crossterm::event::Event; use crossterm::event::Event;
use std::convert::TryInto; use ratatui::{
use tui::{
backend::Backend, backend::Backend,
layout::{Constraint, Margin, Rect}, layout::{Constraint, Margin, Rect},
text::Span, text::Span,
@ -36,6 +35,7 @@ use tui::{
}, },
Frame, Frame,
}; };
use std::convert::TryInto;
use ui::style::SharedTheme; use ui::style::SharedTheme;
/// ///

View file

@ -13,8 +13,7 @@ use crate::{
use anyhow::Result; use anyhow::Result;
use crossterm::event::{Event, KeyCode, KeyModifiers}; use crossterm::event::{Event, KeyCode, KeyModifiers};
use itertools::Itertools; use itertools::Itertools;
use std::{cell::Cell, collections::HashMap, ops::Range}; use ratatui::{
use tui::{
backend::Backend, backend::Backend,
layout::{Alignment, Rect}, layout::{Alignment, Rect},
style::Modifier, style::Modifier,
@ -22,6 +21,7 @@ use tui::{
widgets::{Clear, Paragraph}, widgets::{Clear, Paragraph},
Frame, Frame,
}; };
use std::{cell::Cell, collections::HashMap, ops::Range};
#[derive(PartialEq, Eq)] #[derive(PartialEq, Eq)]
pub enum InputType { pub enum InputType {
@ -523,7 +523,7 @@ impl Component for TextInputComponent {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
use tui::{style::Style, text::Span}; use ratatui::{style::Style, text::Span};
#[test] #[test]
fn test_smoke() { fn test_smoke() {

View file

@ -1,6 +1,6 @@
use std::cell::Cell; use std::cell::Cell;
use tui::{backend::Backend, layout::Rect, Frame}; use ratatui::{backend::Backend, layout::Rect, Frame};
use crate::{ use crate::{
components::HorizontalScrollType, components::HorizontalScrollType,

View file

@ -1,6 +1,6 @@
use std::cell::Cell; use std::cell::Cell;
use tui::{backend::Backend, layout::Rect, Frame}; use ratatui::{backend::Backend, layout::Rect, Frame};
use crate::{ use crate::{
components::ScrollType, components::ScrollType,

View file

@ -67,6 +67,10 @@ use crossterm::{
use input::{Input, InputEvent, InputState}; use input::{Input, InputEvent, InputState};
use keys::KeyConfig; use keys::KeyConfig;
use profiler::Profiler; use profiler::Profiler;
use ratatui::{
backend::{Backend, CrosstermBackend},
Terminal,
};
use scopeguard::defer; use scopeguard::defer;
use scopetime::scope_time; use scopetime::scope_time;
use spinner::Spinner; use spinner::Spinner;
@ -76,10 +80,6 @@ use std::{
panic, process, panic, process,
time::{Duration, Instant}, time::{Duration, Instant},
}; };
use tui::{
backend::{Backend, CrosstermBackend},
Terminal,
};
use ui::style::Theme; use ui::style::Theme;
use watcher::RepoWatcher; use watcher::RepoWatcher;

View file

@ -1,5 +1,5 @@
use ratatui::{backend::Backend, Terminal};
use std::{cell::Cell, char, io}; use std::{cell::Cell, char, io};
use tui::{backend::Backend, Terminal};
// static SPINNER_CHARS: &[char] = &['◢', '◣', '◤', '◥']; // static SPINNER_CHARS: &[char] = &['◢', '◣', '◤', '◥'];
// static SPINNER_CHARS: &[char] = &['⢹', '⢺', '⢼', '⣸', '⣇', '⡧', '⡗', '⡏']; // static SPINNER_CHARS: &[char] = &['⢹', '⢺', '⢼', '⣸', '⣇', '⡧', '⡗', '⡏'];
@ -48,7 +48,7 @@ impl Spinner {
if self.last_char.get() != char_to_draw { if self.last_char.get() != char_to_draw {
self.last_char.set(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) .set_char(char_to_draw)
.clone(); .clone();
@ -56,7 +56,7 @@ impl Spinner {
.backend_mut() .backend_mut()
.draw(vec![(0_u16, 0_u16, &c)].into_iter())?; .draw(vec![(0_u16, 0_u16, &c)].into_iter())?;
tui::backend::Backend::flush(terminal.backend_mut())?; ratatui::backend::Backend::flush(terminal.backend_mut())?;
} }
Ok(()) Ok(())

View file

@ -81,10 +81,10 @@ impl FilesTab {
} }
impl DrawableComponent for FilesTab { impl DrawableComponent for FilesTab {
fn draw<B: tui::backend::Backend>( fn draw<B: ratatui::backend::Backend>(
&self, &self,
f: &mut tui::Frame<B>, f: &mut ratatui::Frame<B>,
rect: tui::layout::Rect, rect: ratatui::layout::Rect,
) -> Result<()> { ) -> Result<()> {
if self.is_visible() { if self.is_visible() {
self.files.draw(f, rect)?; self.files.draw(f, rect)?;

View file

@ -19,13 +19,13 @@ use asyncgit::{
}; };
use crossbeam_channel::Sender; use crossbeam_channel::Sender;
use crossterm::event::Event; use crossterm::event::Event;
use std::time::Duration; use ratatui::{
use sync::CommitTags;
use tui::{
backend::Backend, backend::Backend,
layout::{Constraint, Direction, Layout, Rect}, layout::{Constraint, Direction, Layout, Rect},
Frame, Frame,
}; };
use std::time::Duration;
use sync::CommitTags;
const SLICE_SIZE: usize = 1200; const SLICE_SIZE: usize = 1200;

View file

@ -17,12 +17,12 @@ use asyncgit::{
}; };
use crossbeam_channel::Sender; use crossbeam_channel::Sender;
use crossterm::event::Event; use crossterm::event::Event;
use std::borrow::Cow; use ratatui::{
use tui::{
layout::{Alignment, Constraint, Direction, Layout}, layout::{Alignment, Constraint, Direction, Layout},
text::{Span, Spans}, text::{Span, Spans},
widgets::{Block, Borders, Paragraph}, widgets::{Block, Borders, Paragraph},
}; };
use std::borrow::Cow;
#[derive(Default, Clone, Copy, Debug)] #[derive(Default, Clone, Copy, Debug)]
pub struct StashingOptions { pub struct StashingOptions {
@ -140,10 +140,10 @@ impl Stashing {
} }
impl DrawableComponent for Stashing { impl DrawableComponent for Stashing {
fn draw<B: tui::backend::Backend>( fn draw<B: ratatui::backend::Backend>(
&self, &self,
f: &mut tui::Frame<B>, f: &mut ratatui::Frame<B>,
rect: tui::layout::Rect, rect: ratatui::layout::Rect,
) -> Result<()> { ) -> Result<()> {
let chunks = Layout::default() let chunks = Layout::default()
.direction(Direction::Horizontal) .direction(Direction::Horizontal)

View file

@ -148,10 +148,10 @@ impl StashList {
} }
impl DrawableComponent for StashList { impl DrawableComponent for StashList {
fn draw<B: tui::backend::Backend>( fn draw<B: ratatui::backend::Backend>(
&self, &self,
f: &mut tui::Frame<B>, f: &mut ratatui::Frame<B>,
rect: tui::layout::Rect, rect: ratatui::layout::Rect,
) -> Result<()> { ) -> Result<()> {
self.list.draw(f, rect)?; self.list.draw(f, rect)?;

View file

@ -26,12 +26,12 @@ use asyncgit::{
use crossbeam_channel::Sender; use crossbeam_channel::Sender;
use crossterm::event::Event; use crossterm::event::Event;
use itertools::Itertools; use itertools::Itertools;
use std::convert::Into; use ratatui::{
use tui::{
layout::{Alignment, Constraint, Direction, Layout}, layout::{Alignment, Constraint, Direction, Layout},
style::{Color, Style}, style::{Color, Style},
widgets::{Block, BorderType, Borders, Paragraph}, widgets::{Block, BorderType, Borders, Paragraph},
}; };
use std::convert::Into;
/// what part of the screen is focused /// what part of the screen is focused
#[derive(PartialEq)] #[derive(PartialEq)]
@ -82,10 +82,10 @@ pub struct Status {
} }
impl DrawableComponent for Status { impl DrawableComponent for Status {
fn draw<B: tui::backend::Backend>( fn draw<B: ratatui::backend::Backend>(
&self, &self,
f: &mut tui::Frame<B>, f: &mut ratatui::Frame<B>,
rect: tui::layout::Rect, rect: ratatui::layout::Rect,
) -> Result<()> { ) -> Result<()> {
let repo_unclean = self.repo_state_unclean(); let repo_unclean = self.repo_state_unclean();
let rects = if repo_unclean { let rects = if repo_unclean {
@ -97,7 +97,7 @@ impl DrawableComponent for Status {
) )
.split(rect) .split(rect)
} else { } else {
vec![rect] std::rc::Rc::new([rect])
}; };
let chunks = Layout::default() let chunks = Layout::default()
@ -215,10 +215,10 @@ impl Status {
} }
} }
fn draw_branch_state<B: tui::backend::Backend>( fn draw_branch_state<B: ratatui::backend::Backend>(
&self, &self,
f: &mut tui::Frame<B>, f: &mut ratatui::Frame<B>,
chunks: &[tui::layout::Rect], chunks: &[ratatui::layout::Rect],
) { ) {
if let Some(branch_name) = self.git_branch_name.last() { if let Some(branch_name) = self.git_branch_name.last() {
let ahead_behind = self let ahead_behind = self
@ -296,10 +296,10 @@ impl Status {
} }
} }
fn draw_repo_state<B: tui::backend::Backend>( fn draw_repo_state<B: ratatui::backend::Backend>(
&self, &self,
f: &mut tui::Frame<B>, f: &mut ratatui::Frame<B>,
r: tui::layout::Rect, r: ratatui::layout::Rect,
) { ) {
if self.git_state != RepoState::Clean { if self.git_state != RepoState::Clean {
let txt = Self::repo_state_text( let txt = Self::repo_state_text(

View file

@ -6,13 +6,13 @@ pub mod style;
mod syntax_text; mod syntax_text;
use filetreelist::MoveSelection; use filetreelist::MoveSelection;
use ratatui::layout::{Constraint, Direction, Layout, Rect};
pub use scrollbar::{draw_scrollbar, Orientation}; pub use scrollbar::{draw_scrollbar, Orientation};
pub use scrolllist::{draw_list, draw_list_block}; pub use scrolllist::{draw_list, draw_list_block};
pub use stateful_paragraph::{ pub use stateful_paragraph::{
ParagraphState, ScrollPos, StatefulParagraph, ParagraphState, ScrollPos, StatefulParagraph,
}; };
pub use syntax_text::{AsyncSyntaxJob, SyntaxText}; pub use syntax_text::{AsyncSyntaxJob, SyntaxText};
use tui::layout::{Constraint, Direction, Layout, Rect};
use crate::keys::{key_match, SharedKeyConfig}; use crate::keys::{key_match, SharedKeyConfig};
@ -157,7 +157,7 @@ pub fn common_nav(
mod test { mod test {
use super::{rect_inside, Size}; use super::{rect_inside, Size};
use pretty_assertions::assert_eq; use pretty_assertions::assert_eq;
use tui::layout::Rect; use ratatui::layout::Rect;
#[test] #[test]
fn test_small_rect_in_rect() { fn test_small_rect_in_rect() {

View file

@ -1,6 +1,6 @@
use crate::string_utils::trim_offset; use crate::string_utils::trim_offset;
use easy_cast::Cast; use easy_cast::Cast;
use tui::text::StyledGrapheme; use ratatui::text::StyledGrapheme;
use unicode_width::UnicodeWidthStr; use unicode_width::UnicodeWidthStr;
const NBSP: &str = "\u{00a0}"; const NBSP: &str = "\u{00a0}";

View file

@ -1,7 +1,6 @@
use super::style::SharedTheme; use super::style::SharedTheme;
use easy_cast::CastFloat; use easy_cast::CastFloat;
use std::convert::TryFrom; use ratatui::{
use tui::{
backend::Backend, backend::Backend,
buffer::Buffer, buffer::Buffer,
layout::{Margin, Rect}, layout::{Margin, Rect},
@ -13,6 +12,7 @@ use tui::{
widgets::Widget, widgets::Widget,
Frame, Frame,
}; };
use std::convert::TryFrom;
pub enum Orientation { pub enum Orientation {
Vertical, Vertical,

View file

@ -1,6 +1,5 @@
use super::style::SharedTheme; use super::style::SharedTheme;
use std::iter::Iterator; use ratatui::{
use tui::{
backend::Backend, backend::Backend,
buffer::Buffer, buffer::Buffer,
layout::Rect, layout::Rect,
@ -9,6 +8,7 @@ use tui::{
widgets::{Block, Borders, List, ListItem, Widget}, widgets::{Block, Borders, List, ListItem, Widget},
Frame, Frame,
}; };
use std::iter::Iterator;
/// ///
struct ScrollableList<'b, L, S> struct ScrollableList<'b, L, S>

View file

@ -1,12 +1,12 @@
use easy_cast::Cast; use easy_cast::Cast;
use std::iter; use ratatui::{
use tui::{
buffer::Buffer, buffer::Buffer,
layout::{Alignment, Rect}, layout::{Alignment, Rect},
style::Style, style::Style,
text::{StyledGrapheme, Text}, text::{StyledGrapheme, Text},
widgets::{Block, StatefulWidget, Widget, Wrap}, widgets::{Block, StatefulWidget, Widget, Wrap},
}; };
use std::iter;
use unicode_width::UnicodeWidthStr; use unicode_width::UnicodeWidthStr;
use super::reflow::{LineComposer, LineTruncator, WordWrapper}; use super::reflow::{LineComposer, LineTruncator, WordWrapper};

View file

@ -1,5 +1,6 @@
use anyhow::Result; use anyhow::Result;
use asyncgit::{DiffLineType, StatusItemType}; use asyncgit::{DiffLineType, StatusItemType};
use ratatui::style::{Color, Modifier, Style};
use ron::{ use ron::{
de::from_bytes, de::from_bytes,
ser::{to_string_pretty, PrettyConfig}, ser::{to_string_pretty, PrettyConfig},
@ -11,7 +12,6 @@ use std::{
path::PathBuf, path::PathBuf,
rc::Rc, rc::Rc,
}; };
use tui::style::{Color, Modifier, Style};
pub type SharedTheme = Rc<Theme>; pub type SharedTheme = Rc<Theme>;

View file

@ -3,6 +3,7 @@ use asyncgit::{
ProgressPercent, ProgressPercent,
}; };
use once_cell::sync::Lazy; use once_cell::sync::Lazy;
use ratatui::text::{Span, Spans};
use scopetime::scope_time; use scopetime::scope_time;
use std::{ use std::{
ffi::OsStr, ffi::OsStr,
@ -18,7 +19,6 @@ use syntect::{
}, },
parsing::{ParseState, ScopeStack, SyntaxSet}, parsing::{ParseState, ScopeStack, SyntaxSet},
}; };
use tui::text::{Span, Spans};
use crate::{AsyncAppNotification, SyntaxHighlightProgress}; 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 { fn from(v: &'a SyntaxText) -> Self {
let mut result_lines: Vec<Spans> = let mut result_lines: Vec<Spans> =
Vec::with_capacity(v.lines.len()); 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 { fn syntact_style_to_tui(style: &Style) -> ratatui::style::Style {
let mut res = let mut res = ratatui::style::Style::default().fg(
tui::style::Style::default().fg(tui::style::Color::Rgb( ratatui::style::Color::Rgb(
style.foreground.r, style.foreground.r,
style.foreground.g, style.foreground.g,
style.foreground.b, style.foreground.b,
)); ),
);
if style.font_style.contains(FontStyle::BOLD) { 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) { 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) { if style.font_style.contains(FontStyle::UNDERLINE) {
res = res.add_modifier(tui::style::Modifier::UNDERLINED); res = res.add_modifier(ratatui::style::Modifier::UNDERLINED);
} }
res res