mirror of
https://github.com/gitui-org/gitui
synced 2026-05-24 01:18:21 +00:00
min rect size for commit popup (fixes #179)
This commit is contained in:
parent
dc5911de20
commit
18f3bd981d
4 changed files with 19 additions and 2 deletions
|
|
@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
- `add_to_ignore` failed on files without a newline at EOF ([#191](https://github.com/extrawurst/gitui/issues/191))
|
||||
- new tags were not picked up in revlog view ([#190](https://github.com/extrawurst/gitui/issues/190))
|
||||
- tags not shown in commit details popup ([#193](https://github.com/extrawurst/gitui/issues/193))
|
||||
- min size for relative popups on small terminals ([#179](https://github.com/extrawurst/gitui/issues/179))
|
||||
|
||||
## [0.8.1] - 2020-07-07
|
||||
|
||||
|
|
|
|||
|
|
@ -16,8 +16,7 @@ use crate::{
|
|||
use anyhow::Result;
|
||||
use asyncgit::{hash, StatusItem, StatusItemType};
|
||||
use crossterm::event::Event;
|
||||
use std::cell::Cell;
|
||||
use std::{borrow::Cow, convert::From, path::Path};
|
||||
use std::{borrow::Cow, cell::Cell, convert::From, path::Path};
|
||||
use tui::{backend::Backend, layout::Rect, widgets::Text, Frame};
|
||||
|
||||
///
|
||||
|
|
|
|||
|
|
@ -170,6 +170,8 @@ impl DrawableComponent for TextInputComponent {
|
|||
};
|
||||
|
||||
let area = ui::centered_rect(60, 20, f.size());
|
||||
let area = ui::rect_min(10, 3, area);
|
||||
|
||||
f.render_widget(Clear, area);
|
||||
f.render_widget(
|
||||
popup_paragraph(
|
||||
|
|
|
|||
|
|
@ -57,6 +57,21 @@ pub fn centered_rect(
|
|||
.split(popup_layout[1])[1]
|
||||
}
|
||||
|
||||
/// makes sure Rect `r` at least stays as big as `width`/`height`
|
||||
pub fn rect_min(width: u16, height: u16, r: Rect) -> Rect {
|
||||
let new_width = r.width.max(width);
|
||||
let new_height = r.height.max(height);
|
||||
let diff_width = new_width.saturating_sub(r.width);
|
||||
let diff_height = new_height.saturating_sub(r.height);
|
||||
|
||||
Rect::new(
|
||||
r.x.saturating_sub(diff_width / 2),
|
||||
r.y.saturating_sub(diff_height / 2),
|
||||
new_width,
|
||||
new_height,
|
||||
)
|
||||
}
|
||||
|
||||
pub fn centered_rect_absolute(
|
||||
width: u16,
|
||||
height: u16,
|
||||
|
|
|
|||
Loading…
Reference in a new issue