mirror of
https://github.com/gitui-org/gitui
synced 2026-05-24 09:28:21 +00:00
keep highlighting current diff file
This commit is contained in:
parent
76fcdac063
commit
8b37a22e4d
3 changed files with 24 additions and 8 deletions
|
|
@ -15,7 +15,6 @@ Over the last 2 years my go-to GUI tool for this was [fork](https://git-fork.com
|
|||
* [x] inspect diffs
|
||||
* [x] commit
|
||||
* [x] [input polling in thread](assets/perf_compare.jpg)
|
||||
* [ ] highlight current file being diffed
|
||||
* [ ] support non-root git folder wd
|
||||
* [ ] show content of new files
|
||||
* [ ] indicate file status (modified,added,removed)
|
||||
|
|
|
|||
18
src/app.rs
18
src/app.rs
|
|
@ -19,6 +19,7 @@ use tui::{
|
|||
};
|
||||
|
||||
///
|
||||
#[derive(PartialEq)]
|
||||
enum DiffTarget {
|
||||
Stage,
|
||||
WorkingDir,
|
||||
|
|
@ -271,26 +272,31 @@ impl App {
|
|||
|
||||
match self.focus {
|
||||
Focus::Status => {
|
||||
self.diff_target = DiffTarget::WorkingDir;
|
||||
self.index_wd.focus(true);
|
||||
self.index.focus(false);
|
||||
self.set_diff_target(DiffTarget::WorkingDir);
|
||||
self.diff.focus(false);
|
||||
}
|
||||
Focus::Stage => {
|
||||
self.diff_target = DiffTarget::Stage;
|
||||
self.index.focus(true);
|
||||
self.index_wd.focus(false);
|
||||
self.set_diff_target(DiffTarget::Stage);
|
||||
self.diff.focus(false);
|
||||
}
|
||||
Focus::Diff => {
|
||||
self.index.focus(false);
|
||||
self.index_wd.focus(false);
|
||||
|
||||
self.diff.focus(true);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
fn set_diff_target(&mut self, target: DiffTarget) {
|
||||
self.diff_target = target;
|
||||
let is_stage = self.diff_target == DiffTarget::Stage;
|
||||
|
||||
self.index_wd.focus_select(!is_stage);
|
||||
self.index.focus_select(is_stage);
|
||||
}
|
||||
|
||||
fn index_add_remove(&mut self) {
|
||||
if self.index_wd.focused() {
|
||||
if let Some(i) = self.index_wd.selection() {
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ pub struct IndexComponent {
|
|||
index_type: StatusShow,
|
||||
selection: Option<usize>,
|
||||
focused: bool,
|
||||
show_selection: bool,
|
||||
}
|
||||
|
||||
impl IndexComponent {
|
||||
|
|
@ -31,6 +32,7 @@ impl IndexComponent {
|
|||
index_type,
|
||||
selection: None,
|
||||
focused: focus,
|
||||
show_selection: focus,
|
||||
}
|
||||
}
|
||||
///
|
||||
|
|
@ -53,6 +55,11 @@ impl IndexComponent {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn focus_select(&mut self, focus: bool) {
|
||||
self.focus(focus);
|
||||
self.show_selection = focus;
|
||||
}
|
||||
|
||||
fn move_selection(&mut self, delta: i32) {
|
||||
let items_len = self.items.len();
|
||||
if items_len > 0 {
|
||||
|
|
@ -79,7 +86,11 @@ impl Component for IndexComponent {
|
|||
.map(|e| e.path.clone())
|
||||
.collect::<Vec<_>>()
|
||||
.as_slice(),
|
||||
if self.focused { self.selection } else { None },
|
||||
if self.show_selection {
|
||||
self.selection
|
||||
} else {
|
||||
None
|
||||
},
|
||||
self.focused,
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue