mirror of
https://github.com/gitui-org/gitui
synced 2026-05-23 17:08:21 +00:00
parent
b59526c86c
commit
9ca6068a17
2 changed files with 50 additions and 2 deletions
|
|
@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
* fix key binding shown in bottom bar for `stash_open` ([#1454](https://github.com/extrawurst/gitui/issues/1454))
|
||||
* `--bugreport` does not require param ([#1466](https://github.com/extrawurst/gitui/issues/1466))
|
||||
* `edit`-file command shown on commits msg ([#1461](https://github.com/extrawurst/gitui/issues/1461))
|
||||
* crash on branches popup in small terminal ([#1470](https://github.com/extrawurst/gitui/issues/1470))
|
||||
|
||||
## [0.22.1] - 2022-11-22
|
||||
|
||||
|
|
|
|||
|
|
@ -87,8 +87,18 @@ pub fn centered_rect(
|
|||
|
||||
/// makes sure Rect `r` at least stays as big as min and not bigger than max
|
||||
pub fn rect_inside(min: Size, max: Size, r: Rect) -> Rect {
|
||||
let new_width = r.width.clamp(min.width, max.width);
|
||||
let new_height = r.height.clamp(min.height, max.height);
|
||||
let new_width = if min.width > max.width {
|
||||
max.width
|
||||
} else {
|
||||
r.width.clamp(min.width, max.width)
|
||||
};
|
||||
|
||||
let new_height = if min.height > max.height {
|
||||
max.width
|
||||
} else {
|
||||
r.height.clamp(min.height, max.height)
|
||||
};
|
||||
|
||||
let diff_width = new_width.saturating_sub(r.width);
|
||||
let diff_height = new_height.saturating_sub(r.height);
|
||||
|
||||
|
|
@ -142,3 +152,40 @@ pub fn common_nav(
|
|||
None
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::{rect_inside, Size};
|
||||
use pretty_assertions::assert_eq;
|
||||
use tui::layout::Rect;
|
||||
|
||||
#[test]
|
||||
fn test_small_rect_in_rect() {
|
||||
let rect = rect_inside(
|
||||
Size {
|
||||
width: 2,
|
||||
height: 2,
|
||||
},
|
||||
Size {
|
||||
width: 1,
|
||||
height: 1,
|
||||
},
|
||||
Rect {
|
||||
x: 0,
|
||||
y: 0,
|
||||
width: 10,
|
||||
height: 10,
|
||||
},
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
rect,
|
||||
Rect {
|
||||
x: 0,
|
||||
y: 0,
|
||||
width: 1,
|
||||
height: 1
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue