mirror of
https://github.com/gitui-org/gitui
synced 2026-05-23 00:48:35 +00:00
visualize pending load of a diff (#160)
This commit is contained in:
parent
ed730c2fa1
commit
a54fbf7f63
5 changed files with 27 additions and 12 deletions
|
|
@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
## [Unreleased]
|
||||
|
||||
### Added
|
||||
- pending load of a diff is visualized better ([#160](https://github.com/extrawurst/gitui/issues/160))
|
||||
- entry on [git-scm.com](https://git-scm.com/downloads/guis) in the list of GUI tools [[@Vidar314](https://github.com/Vidar314)] (see [PR](https://github.com/git/git-scm.com/pull/1485))
|
||||
- commits can be tagged in revlog [[@cruessler](https://github.com/cruessler)] ([#103](https://github.com/extrawurst/gitui/issues/103))
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ use crossterm::event::Event;
|
|||
use std::{borrow::Cow, cell::Cell, cmp, path::Path};
|
||||
use tui::{
|
||||
backend::Backend,
|
||||
layout::{Alignment, Rect},
|
||||
layout::Rect,
|
||||
symbols,
|
||||
widgets::{Block, Borders, Paragraph, Text},
|
||||
Frame,
|
||||
|
|
@ -30,6 +30,7 @@ struct Current {
|
|||
///
|
||||
pub struct DiffComponent {
|
||||
diff: Option<FileDiff>,
|
||||
pending: bool,
|
||||
selection: usize,
|
||||
selected_hunk: Option<usize>,
|
||||
current_size: Cell<(u16, u16)>,
|
||||
|
|
@ -47,6 +48,7 @@ impl DiffComponent {
|
|||
focused: false,
|
||||
queue,
|
||||
current: Current::default(),
|
||||
pending: false,
|
||||
selected_hunk: None,
|
||||
diff: None,
|
||||
current_size: Cell::new((0, 0)),
|
||||
|
|
@ -67,12 +69,13 @@ impl DiffComponent {
|
|||
(self.current.path.clone(), self.current.is_stage)
|
||||
}
|
||||
///
|
||||
pub fn clear(&mut self) -> Result<()> {
|
||||
pub fn clear(&mut self, pending: bool) -> Result<()> {
|
||||
self.current = Current::default();
|
||||
self.diff = None;
|
||||
self.scroll_top.set(0);
|
||||
self.selection = 0;
|
||||
self.selected_hunk = None;
|
||||
self.pending = pending;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
@ -83,6 +86,8 @@ impl DiffComponent {
|
|||
is_stage: bool,
|
||||
diff: FileDiff,
|
||||
) -> Result<()> {
|
||||
self.pending = false;
|
||||
|
||||
let hash = hash(&diff);
|
||||
|
||||
if self.current.hash != hash {
|
||||
|
|
@ -432,19 +437,24 @@ impl DrawableComponent for DiffComponent {
|
|||
|
||||
let title =
|
||||
format!("{}{}", strings::TITLE_DIFF, self.current.path);
|
||||
|
||||
let txt = if self.pending {
|
||||
vec![Text::Styled(
|
||||
Cow::from(strings::LOADING_TEXT),
|
||||
self.theme.text(false, false),
|
||||
)]
|
||||
} else {
|
||||
self.get_text(r.width, self.current_size.get().1)?
|
||||
};
|
||||
|
||||
f.render_widget(
|
||||
Paragraph::new(
|
||||
self.get_text(r.width, self.current_size.get().1)?
|
||||
.iter(),
|
||||
)
|
||||
.block(
|
||||
Paragraph::new(txt.iter()).block(
|
||||
Block::default()
|
||||
.title(title.as_str())
|
||||
.borders(Borders::ALL)
|
||||
.border_style(self.theme.block(self.focused))
|
||||
.title_style(self.theme.title(self.focused)),
|
||||
)
|
||||
.alignment(Alignment::Left),
|
||||
),
|
||||
r,
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -222,10 +222,12 @@ impl InspectCommitComponent {
|
|||
}
|
||||
|
||||
self.git_diff.request(diff_params)?;
|
||||
self.diff.clear(true)?;
|
||||
return Ok(());
|
||||
}
|
||||
}
|
||||
|
||||
self.diff.clear()?;
|
||||
self.diff.clear(false)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
|
|
|||
|
|
@ -38,6 +38,8 @@ pub static HELP_TITLE: &str = "Help: all commands";
|
|||
pub static STASHING_FILES_TITLE: &str = "Files to Stash";
|
||||
pub static STASHING_OPTIONS_TITLE: &str = "Options";
|
||||
|
||||
pub static LOADING_TEXT: &str = "Loading ...";
|
||||
|
||||
pub mod commit {
|
||||
pub static DETAILS_AUTHOR: &str = "Author: ";
|
||||
pub static DETAILS_COMMITTER: &str = "Committer: ";
|
||||
|
|
|
|||
|
|
@ -271,11 +271,11 @@ impl Status {
|
|||
{
|
||||
self.diff.update(path, is_stage, diff)?;
|
||||
} else {
|
||||
self.diff.clear()?;
|
||||
self.diff.clear(true)?;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
self.diff.clear()?;
|
||||
self.diff.clear(false)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
|
|
|||
Loading…
Reference in a new issue