mirror of
https://github.com/gitui-org/gitui
synced 2026-05-23 08:58:21 +00:00
ratatui 0.24 update
This commit is contained in:
parent
45c34e5675
commit
2b39c6465a
53 changed files with 168 additions and 337 deletions
62
Cargo.lock
generated
62
Cargo.lock
generated
|
|
@ -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",
|
||||
]
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ log = "0.4"
|
|||
notify = "6.1"
|
||||
notify-debouncer-mini = "0.4"
|
||||
once_cell = "1"
|
||||
ratatui = { version = "0.23", default-features = false, features = [
|
||||
ratatui = { version = "0.24", default-features = false, features = [
|
||||
'crossterm',
|
||||
'serde',
|
||||
] }
|
||||
|
|
|
|||
|
|
@ -42,7 +42,6 @@ use asyncgit::{
|
|||
use crossbeam_channel::Sender;
|
||||
use crossterm::event::{Event, KeyEvent};
|
||||
use ratatui::{
|
||||
backend::Backend,
|
||||
layout::{
|
||||
Alignment, Constraint, Direction, Layout, Margin, Rect,
|
||||
},
|
||||
|
|
@ -227,7 +226,7 @@ impl App {
|
|||
}
|
||||
|
||||
///
|
||||
pub fn draw<B: Backend>(&self, f: &mut Frame<B>) -> Result<()> {
|
||||
pub fn draw(&self, f: &mut Frame) -> Result<()> {
|
||||
let fsize = f.size();
|
||||
|
||||
self.cmdbar.borrow_mut().refresh_width(fsize.width);
|
||||
|
|
@ -1070,7 +1069,7 @@ impl App {
|
|||
}
|
||||
|
||||
//TODO: make this dynamic
|
||||
fn draw_top_bar<B: Backend>(&self, f: &mut Frame<B>, r: Rect) {
|
||||
fn draw_top_bar(&self, f: &mut Frame, r: Rect) {
|
||||
const DIVIDER_PAD_SPACES: usize = 2;
|
||||
const SIDE_PADS: usize = 2;
|
||||
const MARGIN_LEFT_AND_RIGHT: usize = 2;
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ use crate::{
|
|||
ui::style::SharedTheme,
|
||||
};
|
||||
use ratatui::{
|
||||
backend::Backend,
|
||||
layout::{Alignment, Rect},
|
||||
text::{Line, Span},
|
||||
widgets::Paragraph,
|
||||
|
|
@ -139,7 +138,7 @@ impl CommandBar {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn draw<B: Backend>(&self, f: &mut Frame<B>, r: Rect) {
|
||||
pub fn draw(&self, f: &mut Frame, r: Rect) {
|
||||
if r.width < MORE_WIDTH {
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ use asyncgit::{
|
|||
StatusItem, StatusItemType,
|
||||
};
|
||||
use crossterm::event::Event;
|
||||
use ratatui::{backend::Backend, layout::Rect, Frame};
|
||||
use ratatui::{layout::Rect, Frame};
|
||||
use std::path::Path;
|
||||
|
||||
///
|
||||
|
|
@ -187,11 +187,7 @@ impl ChangesComponent {
|
|||
}
|
||||
|
||||
impl DrawableComponent for ChangesComponent {
|
||||
fn draw<B: Backend>(
|
||||
&self,
|
||||
f: &mut Frame<B>,
|
||||
r: Rect,
|
||||
) -> Result<()> {
|
||||
fn draw(&self, f: &mut Frame, r: Rect) -> Result<()> {
|
||||
self.files.draw(f, r)?;
|
||||
|
||||
Ok(())
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ use asyncgit::sync::{
|
|||
};
|
||||
use crossterm::event::Event;
|
||||
use ratatui::{
|
||||
backend::Backend,
|
||||
layout::{Constraint, Direction, Layout, Rect},
|
||||
text::{Line, Span, Text},
|
||||
Frame,
|
||||
|
|
@ -102,11 +101,7 @@ impl CompareDetailsComponent {
|
|||
}
|
||||
|
||||
impl DrawableComponent for CompareDetailsComponent {
|
||||
fn draw<B: Backend>(
|
||||
&self,
|
||||
f: &mut Frame<B>,
|
||||
rect: Rect,
|
||||
) -> Result<()> {
|
||||
fn draw(&self, f: &mut Frame, rect: Rect) -> Result<()> {
|
||||
let chunks = Layout::default()
|
||||
.direction(Direction::Vertical)
|
||||
.constraints(
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@ use asyncgit::sync::{
|
|||
};
|
||||
use crossterm::event::Event;
|
||||
use ratatui::{
|
||||
backend::Backend,
|
||||
layout::{Constraint, Direction, Layout, Rect},
|
||||
style::{Modifier, Style},
|
||||
text::{Line, Span, Text},
|
||||
|
|
@ -255,11 +254,7 @@ impl DetailsComponent {
|
|||
}
|
||||
|
||||
impl DrawableComponent for DetailsComponent {
|
||||
fn draw<B: Backend>(
|
||||
&self,
|
||||
f: &mut Frame<B>,
|
||||
rect: Rect,
|
||||
) -> Result<()> {
|
||||
fn draw(&self, f: &mut Frame, rect: Rect) -> Result<()> {
|
||||
const CANSCROLL_STRING: &str = "[\u{2026}]";
|
||||
const EMPTY_STRING: &str = "";
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ use compare_details::CompareDetailsComponent;
|
|||
use crossterm::event::Event;
|
||||
use details::DetailsComponent;
|
||||
use ratatui::{
|
||||
backend::Backend,
|
||||
layout::{Constraint, Direction, Layout, Rect},
|
||||
Frame,
|
||||
};
|
||||
|
|
@ -140,11 +139,7 @@ impl CommitDetailsComponent {
|
|||
}
|
||||
|
||||
impl DrawableComponent for CommitDetailsComponent {
|
||||
fn draw<B: Backend>(
|
||||
&self,
|
||||
f: &mut Frame<B>,
|
||||
rect: Rect,
|
||||
) -> Result<()> {
|
||||
fn draw(&self, f: &mut Frame, rect: Rect) -> Result<()> {
|
||||
if !self.visible {
|
||||
return Ok(());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@ use crossterm::event::Event;
|
|||
use indexmap::IndexSet;
|
||||
use itertools::Itertools;
|
||||
use ratatui::{
|
||||
backend::Backend,
|
||||
layout::{Alignment, Rect},
|
||||
style::Style,
|
||||
text::{Line, Span},
|
||||
|
|
@ -772,11 +771,7 @@ impl CommitList {
|
|||
}
|
||||
|
||||
impl DrawableComponent for CommitList {
|
||||
fn draw<B: Backend>(
|
||||
&self,
|
||||
f: &mut Frame<B>,
|
||||
area: Rect,
|
||||
) -> Result<()> {
|
||||
fn draw(&self, f: &mut Frame, area: Rect) -> Result<()> {
|
||||
let current_size = (
|
||||
area.width.saturating_sub(2),
|
||||
area.height.saturating_sub(2),
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use anyhow::Result;
|
||||
use crossterm::event::Event;
|
||||
use ratatui::{backend::Backend, layout::Rect, Frame};
|
||||
use ratatui::{layout::Rect, Frame};
|
||||
|
||||
use asyncgit::sync::cred::BasicAuthCredential;
|
||||
|
||||
|
|
@ -60,11 +60,7 @@ impl CredComponent {
|
|||
}
|
||||
|
||||
impl DrawableComponent for CredComponent {
|
||||
fn draw<B: Backend>(
|
||||
&self,
|
||||
f: &mut Frame<B>,
|
||||
rect: Rect,
|
||||
) -> Result<()> {
|
||||
fn draw(&self, f: &mut Frame, rect: Rect) -> Result<()> {
|
||||
if self.visible {
|
||||
self.input_username.draw(f, rect)?;
|
||||
self.input_password.draw(f, rect)?;
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ use asyncgit::{
|
|||
use bytesize::ByteSize;
|
||||
use crossterm::event::Event;
|
||||
use ratatui::{
|
||||
backend::Backend,
|
||||
layout::Rect,
|
||||
symbols,
|
||||
text::{Line, Span},
|
||||
|
|
@ -683,11 +682,7 @@ impl DiffComponent {
|
|||
}
|
||||
|
||||
impl DrawableComponent for DiffComponent {
|
||||
fn draw<B: Backend>(
|
||||
&self,
|
||||
f: &mut Frame<B>,
|
||||
r: Rect,
|
||||
) -> Result<()> {
|
||||
fn draw(&self, f: &mut Frame, r: Rect) -> Result<()> {
|
||||
self.current_size.set((
|
||||
r.width.saturating_sub(2),
|
||||
r.height.saturating_sub(2),
|
||||
|
|
|
|||
|
|
@ -30,7 +30,6 @@ use crate::ui::style::Theme;
|
|||
use anyhow::Result;
|
||||
use crossterm::event::Event;
|
||||
use ratatui::{
|
||||
backend::Backend,
|
||||
layout::{Alignment, Rect},
|
||||
text::{Span, Text},
|
||||
widgets::{Block, Borders, Paragraph},
|
||||
|
|
@ -72,7 +71,7 @@ macro_rules! any_popup_visible {
|
|||
#[macro_export]
|
||||
macro_rules! draw_popups {
|
||||
($self:ident, [$($element:ident),+]) => {
|
||||
fn draw_popups<B: Backend>(& $self, mut f: &mut Frame<B>) -> Result<()>{
|
||||
fn draw_popups(& $self, mut f: &mut Frame) -> Result<()>{
|
||||
//TODO: move the layout part out and feed it into `draw_popups`
|
||||
let size = Layout::default()
|
||||
.direction(Direction::Vertical)
|
||||
|
|
@ -176,11 +175,7 @@ pub fn visibility_blocking<T: Component>(
|
|||
///
|
||||
pub trait DrawableComponent {
|
||||
///
|
||||
fn draw<B: Backend>(
|
||||
&self,
|
||||
f: &mut Frame<B>,
|
||||
rect: Rect,
|
||||
) -> Result<()>;
|
||||
fn draw(&self, f: &mut Frame, rect: Rect) -> Result<()>;
|
||||
}
|
||||
|
||||
///
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@ use asyncgit::{
|
|||
use crossterm::event::Event;
|
||||
use filetreelist::{FileTree, FileTreeItem};
|
||||
use ratatui::{
|
||||
backend::Backend,
|
||||
layout::{Constraint, Direction, Layout, Rect},
|
||||
text::Span,
|
||||
widgets::{Block, Borders},
|
||||
|
|
@ -277,11 +276,7 @@ impl RevisionFilesComponent {
|
|||
}
|
||||
}
|
||||
|
||||
fn draw_tree<B: Backend>(
|
||||
&self,
|
||||
f: &mut Frame<B>,
|
||||
area: Rect,
|
||||
) -> Result<()> {
|
||||
fn draw_tree(&self, f: &mut Frame, area: Rect) -> Result<()> {
|
||||
let tree_height = usize::from(area.height.saturating_sub(2));
|
||||
let tree_width = usize::from(area.width);
|
||||
|
||||
|
|
@ -389,11 +384,7 @@ impl RevisionFilesComponent {
|
|||
}
|
||||
|
||||
impl DrawableComponent for RevisionFilesComponent {
|
||||
fn draw<B: Backend>(
|
||||
&self,
|
||||
f: &mut Frame<B>,
|
||||
area: Rect,
|
||||
) -> Result<()> {
|
||||
fn draw(&self, f: &mut Frame, area: Rect) -> Result<()> {
|
||||
if self.is_visible() {
|
||||
let chunks = Layout::default()
|
||||
.direction(Direction::Horizontal)
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ use crate::{
|
|||
use anyhow::Result;
|
||||
use asyncgit::{hash, sync::CommitId, StatusItem, StatusItemType};
|
||||
use crossterm::event::Event;
|
||||
use ratatui::{backend::Backend, layout::Rect, text::Span, Frame};
|
||||
use ratatui::{layout::Rect, text::Span, Frame};
|
||||
use std::{borrow::Cow, cell::Cell, path::Path};
|
||||
|
||||
//TODO: use new `filetreelist` crate
|
||||
|
|
@ -319,11 +319,7 @@ struct TextDrawInfo<'a> {
|
|||
}
|
||||
|
||||
impl DrawableComponent for StatusTreeComponent {
|
||||
fn draw<B: Backend>(
|
||||
&self,
|
||||
f: &mut Frame<B>,
|
||||
r: Rect,
|
||||
) -> Result<()> {
|
||||
fn draw(&self, f: &mut Frame, r: Rect) -> Result<()> {
|
||||
if !self.is_visible() {
|
||||
return Ok(());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ use crossterm::event::Event;
|
|||
use filetreelist::MoveSelection;
|
||||
use itertools::Either;
|
||||
use ratatui::{
|
||||
backend::Backend,
|
||||
layout::Rect,
|
||||
text::Text,
|
||||
widgets::{Block, Borders, Wrap},
|
||||
|
|
@ -184,11 +183,7 @@ impl SyntaxTextComponent {
|
|||
}
|
||||
|
||||
impl DrawableComponent for SyntaxTextComponent {
|
||||
fn draw<B: Backend>(
|
||||
&self,
|
||||
f: &mut Frame<B>,
|
||||
area: Rect,
|
||||
) -> Result<()> {
|
||||
fn draw(&self, f: &mut Frame, area: Rect) -> Result<()> {
|
||||
let text = self.current_file.as_ref().map_or_else(
|
||||
|| Text::from(""),
|
||||
|(_, content)| match content {
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@ use anyhow::Result;
|
|||
use crossterm::event::Event;
|
||||
use ratatui::widgets::{Block, Borders};
|
||||
use ratatui::{
|
||||
backend::Backend,
|
||||
layout::{Alignment, Rect},
|
||||
widgets::{Clear, Paragraph},
|
||||
Frame,
|
||||
|
|
@ -197,7 +196,7 @@ impl TextInputComponent {
|
|||
}
|
||||
}
|
||||
|
||||
fn draw_char_count<B: Backend>(&self, f: &mut Frame<B>, r: Rect) {
|
||||
fn draw_char_count(&self, f: &mut Frame, r: Rect) {
|
||||
let count = self.get_text().len();
|
||||
if count > 0 {
|
||||
let w = Paragraph::new(format!("[{count} chars]"))
|
||||
|
|
@ -611,11 +610,7 @@ impl TextInputComponent {
|
|||
}
|
||||
|
||||
impl DrawableComponent for TextInputComponent {
|
||||
fn draw<B: Backend>(
|
||||
&self,
|
||||
f: &mut Frame<B>,
|
||||
rect: Rect,
|
||||
) -> Result<()> {
|
||||
fn draw(&self, f: &mut Frame, rect: Rect) -> Result<()> {
|
||||
// this should always be true since draw should only be being called
|
||||
// is control is visible
|
||||
if let Some(ta) = &self.textarea {
|
||||
|
|
|
|||
|
|
@ -1,11 +1,9 @@
|
|||
use std::cell::Cell;
|
||||
|
||||
use ratatui::{backend::Backend, layout::Rect, Frame};
|
||||
|
||||
use crate::{
|
||||
components::HorizontalScrollType,
|
||||
ui::{draw_scrollbar, style::SharedTheme, Orientation},
|
||||
};
|
||||
use ratatui::{layout::Rect, Frame};
|
||||
use std::cell::Cell;
|
||||
|
||||
pub struct HorizontalScroll {
|
||||
right: Cell<usize>,
|
||||
|
|
@ -84,12 +82,7 @@ impl HorizontalScroll {
|
|||
self.update(self.get_right(), column_count, visual_width)
|
||||
}
|
||||
|
||||
pub fn draw<B: Backend>(
|
||||
&self,
|
||||
f: &mut Frame<B>,
|
||||
r: Rect,
|
||||
theme: &SharedTheme,
|
||||
) {
|
||||
pub fn draw(&self, f: &mut Frame, r: Rect, theme: &SharedTheme) {
|
||||
draw_scrollbar(
|
||||
f,
|
||||
r,
|
||||
|
|
|
|||
|
|
@ -1,11 +1,9 @@
|
|||
use std::cell::Cell;
|
||||
|
||||
use ratatui::{backend::Backend, layout::Rect, Frame};
|
||||
|
||||
use crate::{
|
||||
components::ScrollType,
|
||||
ui::{draw_scrollbar, style::SharedTheme, Orientation},
|
||||
};
|
||||
use ratatui::{layout::Rect, Frame};
|
||||
use std::cell::Cell;
|
||||
|
||||
pub struct VerticalScroll {
|
||||
top: Cell<usize>,
|
||||
|
|
@ -109,12 +107,7 @@ impl VerticalScroll {
|
|||
self.update(self.get_top(), line_count, visual_height)
|
||||
}
|
||||
|
||||
pub fn draw<B: Backend>(
|
||||
&self,
|
||||
f: &mut Frame<B>,
|
||||
r: Rect,
|
||||
theme: &SharedTheme,
|
||||
) {
|
||||
pub fn draw(&self, f: &mut Frame, r: Rect, theme: &SharedTheme) {
|
||||
draw_scrollbar(
|
||||
f,
|
||||
r,
|
||||
|
|
|
|||
20
src/main.rs
20
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<CrosstermBackend<io::Stdout>>;
|
||||
|
||||
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<CrosstermBackend<io::Stdout>>,
|
||||
terminal: &mut Terminal,
|
||||
) -> Result<QuitState, anyhow::Error> {
|
||||
let (tx_git, rx_git) = unbounded();
|
||||
let (tx_app, rx_app) = unbounded();
|
||||
|
|
@ -302,10 +301,7 @@ fn shutdown_terminal() {
|
|||
}
|
||||
}
|
||||
|
||||
fn draw<B: Backend>(
|
||||
terminal: &mut Terminal<B>,
|
||||
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<W: Write>(
|
||||
buf: W,
|
||||
) -> io::Result<Terminal<CrosstermBackend<W>>> {
|
||||
fn start_terminal(buf: Stdout) -> io::Result<Terminal> {
|
||||
let backend = CrosstermBackend::new(buf);
|
||||
let mut terminal = Terminal::new(backend)?;
|
||||
terminal.hide_cursor()?;
|
||||
|
|
|
|||
|
|
@ -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<B: Backend>(
|
||||
&self,
|
||||
f: &mut Frame<B>,
|
||||
area: Rect,
|
||||
) -> Result<()> {
|
||||
fn draw(&self, f: &mut Frame, area: Rect) -> Result<()> {
|
||||
if self.is_visible() {
|
||||
let title = self.get_title();
|
||||
|
||||
|
|
|
|||
|
|
@ -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<B: Backend>(
|
||||
&self,
|
||||
f: &mut Frame<B>,
|
||||
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<B: Backend>(&self, f: &mut Frame<B>, 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<B: Backend>(
|
||||
&self,
|
||||
f: &mut Frame<B>,
|
||||
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()?);
|
||||
|
||||
|
|
|
|||
|
|
@ -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<B: Backend>(&self, f: &mut Frame<B>) {
|
||||
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<B: Backend>(&self, f: &mut Frame<B>) {
|
||||
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<B: Backend>(
|
||||
&self,
|
||||
f: &mut Frame<B>,
|
||||
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);
|
||||
|
|
|
|||
|
|
@ -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<B: Backend>(
|
||||
&self,
|
||||
f: &mut Frame<B>,
|
||||
rect: Rect,
|
||||
) -> Result<()> {
|
||||
fn draw(&self, f: &mut Frame, rect: Rect) -> Result<()> {
|
||||
if self.is_visible() {
|
||||
let percentages = if self.diff.focused() {
|
||||
(0, 100)
|
||||
|
|
|
|||
|
|
@ -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<B: Backend>(
|
||||
&self,
|
||||
f: &mut Frame<B>,
|
||||
_rect: Rect,
|
||||
) -> Result<()> {
|
||||
fn draw(&self, f: &mut Frame, _rect: Rect) -> Result<()> {
|
||||
if self.visible {
|
||||
let (title, msg) = self.get_text();
|
||||
|
||||
|
|
|
|||
|
|
@ -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<B: Backend>(
|
||||
&self,
|
||||
f: &mut Frame<B>,
|
||||
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<B: Backend>(&self, f: &mut Frame<B>) {
|
||||
fn draw_warnings(&self, f: &mut Frame) {
|
||||
let current_text = self.input.get_text();
|
||||
|
||||
if !current_text.is_empty() {
|
||||
|
|
|
|||
|
|
@ -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<B: Backend>(
|
||||
&self,
|
||||
f: &mut Frame<B>,
|
||||
_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)
|
||||
|
|
|
|||
|
|
@ -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<B: Backend>(
|
||||
&self,
|
||||
f: &mut Frame<B>,
|
||||
rect: Rect,
|
||||
) -> Result<()> {
|
||||
fn draw(&self, f: &mut Frame, rect: Rect) -> Result<()> {
|
||||
if self.visible {
|
||||
let progress = self.progress.unwrap_or_default().progress;
|
||||
|
||||
|
|
|
|||
|
|
@ -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<B: Backend>(&self, f: &mut Frame<B>, 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<B: Backend>(
|
||||
&self,
|
||||
f: &mut Frame<B>,
|
||||
area: Rect,
|
||||
) -> Result<()> {
|
||||
fn draw(&self, f: &mut Frame, area: Rect) -> Result<()> {
|
||||
if self.visible {
|
||||
let percentages = if self.diff.focused() {
|
||||
(0, 100)
|
||||
|
|
|
|||
|
|
@ -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<B: Backend>(
|
||||
&self,
|
||||
f: &mut Frame<B>,
|
||||
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<B: Backend>(
|
||||
&self,
|
||||
f: &mut Frame<B>,
|
||||
area: Rect,
|
||||
) -> Result<()> {
|
||||
fn draw(&self, f: &mut Frame, area: Rect) -> Result<()> {
|
||||
if self.is_visible() {
|
||||
const MAX_SIZE: (u16, u16) = (50, 20);
|
||||
|
||||
|
|
|
|||
|
|
@ -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<B: Backend>(
|
||||
&self,
|
||||
f: &mut Frame<B>,
|
||||
_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;
|
||||
|
|
|
|||
|
|
@ -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<B: Backend>(
|
||||
&self,
|
||||
f: &mut Frame<B>,
|
||||
rect: Rect,
|
||||
) -> Result<()> {
|
||||
fn draw(&self, f: &mut Frame, rect: Rect) -> Result<()> {
|
||||
if self.is_visible() {
|
||||
let percentages = if self.diff.focused() {
|
||||
(0, 100)
|
||||
|
|
|
|||
|
|
@ -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<B: Backend>(
|
||||
fn draw_search_mode(
|
||||
&self,
|
||||
f: &mut Frame<B>,
|
||||
f: &mut Frame,
|
||||
area: Rect,
|
||||
) -> Result<()> {
|
||||
const SIZE: (u16, u16) = (60, 10);
|
||||
|
|
@ -399,9 +398,9 @@ impl LogSearchPopupPopup {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn draw_commit_sha_mode<B: Backend>(
|
||||
fn draw_commit_sha_mode(
|
||||
&self,
|
||||
f: &mut Frame<B>,
|
||||
f: &mut Frame,
|
||||
area: Rect,
|
||||
) -> Result<()> {
|
||||
const SIZE: (u16, u16) = (60, 3);
|
||||
|
|
@ -445,7 +444,7 @@ impl LogSearchPopupPopup {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn draw_invalid_sha<B: Backend>(&self, f: &mut Frame<B>) {
|
||||
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<B: Backend>(
|
||||
&self,
|
||||
f: &mut Frame<B>,
|
||||
area: Rect,
|
||||
) -> Result<()> {
|
||||
fn draw(&self, f: &mut Frame, area: Rect) -> Result<()> {
|
||||
if self.is_visible() {
|
||||
match self.mode {
|
||||
PopupMode::Search => {
|
||||
|
|
|
|||
|
|
@ -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<B: Backend>(
|
||||
&self,
|
||||
f: &mut Frame<B>,
|
||||
_rect: Rect,
|
||||
) -> Result<()> {
|
||||
fn draw(&self, f: &mut Frame, _rect: Rect) -> Result<()> {
|
||||
if !self.visible {
|
||||
return Ok(());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<B: Backend>(
|
||||
&self,
|
||||
f: &mut Frame<B>,
|
||||
area: Rect,
|
||||
) -> Result<()> {
|
||||
fn draw(&self, f: &mut Frame, area: Rect) -> Result<()> {
|
||||
if self.is_visible() {
|
||||
const SIZE: (u16, u16) = (50, 10);
|
||||
let area =
|
||||
|
|
|
|||
|
|
@ -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<B: Backend>(
|
||||
&self,
|
||||
f: &mut Frame<B>,
|
||||
rect: Rect,
|
||||
) -> Result<()> {
|
||||
fn draw(&self, f: &mut Frame, rect: Rect) -> Result<()> {
|
||||
if self.visible {
|
||||
let (state, progress) =
|
||||
PushPopup::get_progress(&self.progress);
|
||||
|
|
|
|||
|
|
@ -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<B: Backend>(
|
||||
&self,
|
||||
f: &mut Frame<B>,
|
||||
rect: Rect,
|
||||
) -> Result<()> {
|
||||
fn draw(&self, f: &mut Frame, rect: Rect) -> Result<()> {
|
||||
if self.visible {
|
||||
let (state, progress) =
|
||||
Self::get_progress(&self.progress);
|
||||
|
|
|
|||
|
|
@ -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<B: Backend>(
|
||||
&self,
|
||||
f: &mut Frame<B>,
|
||||
rect: Rect,
|
||||
) -> Result<()> {
|
||||
fn draw(&self, f: &mut Frame, rect: Rect) -> Result<()> {
|
||||
if self.visible {
|
||||
let (state, progress) =
|
||||
Self::get_progress(&self.progress);
|
||||
|
|
|
|||
|
|
@ -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<B: Backend>(
|
||||
&self,
|
||||
f: &mut Frame<B>,
|
||||
rect: Rect,
|
||||
) -> Result<()> {
|
||||
fn draw(&self, f: &mut Frame, rect: Rect) -> Result<()> {
|
||||
self.input.draw(f, rect)?;
|
||||
|
||||
Ok(())
|
||||
|
|
|
|||
|
|
@ -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<B: Backend>(
|
||||
&self,
|
||||
f: &mut Frame<B>,
|
||||
area: Rect,
|
||||
) -> Result<()> {
|
||||
fn draw(&self, f: &mut Frame, area: Rect) -> Result<()> {
|
||||
if self.is_visible() {
|
||||
const SIZE: (u16, u16) = (55, 5);
|
||||
let area =
|
||||
|
|
|
|||
|
|
@ -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<B: Backend>(
|
||||
&self,
|
||||
f: &mut Frame<B>,
|
||||
area: Rect,
|
||||
) -> Result<()> {
|
||||
fn draw(&self, f: &mut Frame, area: Rect) -> Result<()> {
|
||||
if self.is_visible() {
|
||||
f.render_widget(Clear, area);
|
||||
|
||||
|
|
|
|||
|
|
@ -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<B: Backend>(
|
||||
&self,
|
||||
f: &mut Frame<B>,
|
||||
rect: Rect,
|
||||
) -> Result<()> {
|
||||
fn draw(&self, f: &mut Frame, rect: Rect) -> Result<()> {
|
||||
self.input.draw(f, rect)?;
|
||||
|
||||
Ok(())
|
||||
|
|
|
|||
|
|
@ -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<B: Backend>(
|
||||
&self,
|
||||
f: &mut Frame<B>,
|
||||
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<B: Backend>(
|
||||
&self,
|
||||
f: &mut Frame<B>,
|
||||
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<B: Backend>(&self, f: &mut Frame<B>, 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<B: Backend>(&self, f: &mut Frame<B>, 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))
|
||||
|
|
|
|||
|
|
@ -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<B: Backend>(
|
||||
&self,
|
||||
f: &mut Frame<B>,
|
||||
rect: Rect,
|
||||
) -> Result<()> {
|
||||
fn draw(&self, f: &mut Frame, rect: Rect) -> Result<()> {
|
||||
self.input.draw(f, rect)?;
|
||||
|
||||
Ok(())
|
||||
|
|
|
|||
|
|
@ -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<B: Backend>(
|
||||
&self,
|
||||
f: &mut Frame<B>,
|
||||
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);
|
||||
|
|
|
|||
|
|
@ -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<B: Backend>(
|
||||
pub fn draw(
|
||||
&self,
|
||||
terminal: &mut Terminal<B>,
|
||||
terminal: &mut Terminal<CrosstermBackend<io::Stdout>>,
|
||||
) -> 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(())
|
||||
|
|
|
|||
|
|
@ -61,9 +61,9 @@ impl FilesTab {
|
|||
}
|
||||
|
||||
impl DrawableComponent for FilesTab {
|
||||
fn draw<B: ratatui::backend::Backend>(
|
||||
fn draw(
|
||||
&self,
|
||||
f: &mut ratatui::Frame<B>,
|
||||
f: &mut ratatui::Frame,
|
||||
rect: ratatui::layout::Rect,
|
||||
) -> Result<()> {
|
||||
if self.is_visible() {
|
||||
|
|
|
|||
|
|
@ -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<B: Backend>(&self, f: &mut Frame<B>, 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<B: Backend>(
|
||||
&self,
|
||||
f: &mut Frame<B>,
|
||||
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)
|
||||
|
|
|
|||
|
|
@ -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<B: ratatui::backend::Backend>(
|
||||
fn draw(
|
||||
&self,
|
||||
f: &mut ratatui::Frame<B>,
|
||||
f: &mut ratatui::Frame,
|
||||
rect: ratatui::layout::Rect,
|
||||
) -> Result<()> {
|
||||
let chunks = Layout::default()
|
||||
|
|
|
|||
|
|
@ -135,9 +135,9 @@ impl StashList {
|
|||
}
|
||||
|
||||
impl DrawableComponent for StashList {
|
||||
fn draw<B: ratatui::backend::Backend>(
|
||||
fn draw(
|
||||
&self,
|
||||
f: &mut ratatui::Frame<B>,
|
||||
f: &mut ratatui::Frame,
|
||||
rect: ratatui::layout::Rect,
|
||||
) -> Result<()> {
|
||||
self.list.draw(f, rect)?;
|
||||
|
|
|
|||
|
|
@ -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<B: ratatui::backend::Backend>(
|
||||
fn draw(
|
||||
&self,
|
||||
f: &mut ratatui::Frame<B>,
|
||||
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<B: ratatui::backend::Backend>(
|
||||
fn draw_branch_state(
|
||||
&self,
|
||||
f: &mut ratatui::Frame<B>,
|
||||
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<B: ratatui::backend::Backend>(
|
||||
fn draw_repo_state(
|
||||
&self,
|
||||
f: &mut ratatui::Frame<B>,
|
||||
f: &mut ratatui::Frame,
|
||||
r: ratatui::layout::Rect,
|
||||
) {
|
||||
if self.git_state != RepoState::Clean {
|
||||
|
|
|
|||
|
|
@ -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<B: Backend>(
|
||||
f: &mut Frame<B>,
|
||||
pub fn draw_scrollbar(
|
||||
f: &mut Frame,
|
||||
r: Rect,
|
||||
theme: &SharedTheme,
|
||||
max: usize,
|
||||
|
|
|
|||
|
|
@ -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<B>,
|
||||
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<B>,
|
||||
pub fn draw_list_block<'b, L, S>(
|
||||
f: &mut Frame,
|
||||
r: Rect,
|
||||
block: Block<'b>,
|
||||
items: L,
|
||||
|
|
|
|||
0
typos.toml
Normal file
0
typos.toml
Normal file
Loading…
Reference in a new issue