mirror of
https://github.com/gitui-org/gitui
synced 2026-05-24 09:28:21 +00:00
commit popup centered
This commit is contained in:
parent
7b289ab71b
commit
472bec5db3
4 changed files with 31 additions and 2 deletions
|
|
@ -19,7 +19,7 @@ Over the last 2 years my go to GUI tool for this was [fork](https://git-fork.com
|
||||||
* [x] support staging
|
* [x] support staging
|
||||||
* [x] show added files on working dir changes
|
* [x] show added files on working dir changes
|
||||||
* [x] support committing
|
* [x] support committing
|
||||||
* [ ] popup centered
|
* [x] popup centered
|
||||||
* [ ] crash: adding a pic to index crashes
|
* [ ] crash: adding a pic to index crashes
|
||||||
* [ ] crash: renamed files cannot be added to index
|
* [ ] crash: renamed files cannot be added to index
|
||||||
* [ ] allow selecting/diff index items
|
* [ ] allow selecting/diff index items
|
||||||
|
|
|
||||||
BIN
assets/main.jpg
BIN
assets/main.jpg
Binary file not shown.
|
Before Width: | Height: | Size: 189 KiB After Width: | Height: | Size: 166 KiB |
|
|
@ -186,7 +186,7 @@ impl App {
|
||||||
.block(Block::default().title("Commit").borders(Borders::ALL))
|
.block(Block::default().title("Commit").borders(Borders::ALL))
|
||||||
.alignment(Alignment::Left),
|
.alignment(Alignment::Left),
|
||||||
)
|
)
|
||||||
.render(f, Rect::new(20, 0, 100, 10));
|
.render(f, git_utils::centered_rect(60, 20, f.size()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
use git2::{DiffFormat, DiffOptions, Repository};
|
use git2::{DiffFormat, DiffOptions, Repository};
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
use tui::layout::{Constraint, Direction, Layout, Rect};
|
||||||
|
|
||||||
///
|
///
|
||||||
#[derive(Copy, Clone, PartialEq)]
|
#[derive(Copy, Clone, PartialEq)]
|
||||||
|
|
@ -103,3 +104,31 @@ pub fn commit(msg: &String) {
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// use layouts to create a rects that
|
||||||
|
/// centers inside `r` and sizes `percent_x`/`percent_x` of `r`
|
||||||
|
pub fn centered_rect(percent_x: u16, percent_y: u16, r: Rect) -> Rect {
|
||||||
|
let popup_layout = Layout::default()
|
||||||
|
.direction(Direction::Vertical)
|
||||||
|
.constraints(
|
||||||
|
[
|
||||||
|
Constraint::Percentage((100 - percent_y) / 2),
|
||||||
|
Constraint::Percentage(percent_y),
|
||||||
|
Constraint::Percentage((100 - percent_y) / 2),
|
||||||
|
]
|
||||||
|
.as_ref(),
|
||||||
|
)
|
||||||
|
.split(r);
|
||||||
|
|
||||||
|
Layout::default()
|
||||||
|
.direction(Direction::Horizontal)
|
||||||
|
.constraints(
|
||||||
|
[
|
||||||
|
Constraint::Percentage((100 - percent_x) / 2),
|
||||||
|
Constraint::Percentage(percent_x),
|
||||||
|
Constraint::Percentage((100 - percent_x) / 2),
|
||||||
|
]
|
||||||
|
.as_ref(),
|
||||||
|
)
|
||||||
|
.split(popup_layout[1])[1]
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue