mirror of https://github.com/helix-editor/helix
ensure we don't form invalid Rects with 'split_***' API
parent
c63246651b
commit
4a2ad21247
|
@ -256,6 +256,7 @@ impl Rect {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn split_left(self, width: u16) -> (Rect, Rect) {
|
pub fn split_left(self, width: u16) -> (Rect, Rect) {
|
||||||
|
let width = width.min(self.width);
|
||||||
(
|
(
|
||||||
Rect { width, ..self },
|
Rect { width, ..self },
|
||||||
Rect {
|
Rect {
|
||||||
|
@ -267,6 +268,7 @@ impl Rect {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn split_right(self, width: u16) -> (Rect, Rect) {
|
pub fn split_right(self, width: u16) -> (Rect, Rect) {
|
||||||
|
let width = width.min(self.width);
|
||||||
(
|
(
|
||||||
Rect {
|
Rect {
|
||||||
width: self.width - width,
|
width: self.width - width,
|
||||||
|
@ -281,6 +283,7 @@ impl Rect {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn split_top(self, height: u16) -> (Rect, Rect) {
|
pub fn split_top(self, height: u16) -> (Rect, Rect) {
|
||||||
|
let height = height.min(self.height);
|
||||||
(
|
(
|
||||||
Rect { height, ..self },
|
Rect { height, ..self },
|
||||||
Rect {
|
Rect {
|
||||||
|
@ -292,6 +295,7 @@ impl Rect {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn split_bottom(self, height: u16) -> (Rect, Rect) {
|
pub fn split_bottom(self, height: u16) -> (Rect, Rect) {
|
||||||
|
let height = height.min(self.height);
|
||||||
(
|
(
|
||||||
Rect {
|
Rect {
|
||||||
height: self.height - height,
|
height: self.height - height,
|
||||||
|
@ -306,6 +310,7 @@ impl Rect {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn split_centre_vertical(self, width: u16) -> (Rect, Rect, Rect) {
|
pub fn split_centre_vertical(self, width: u16) -> (Rect, Rect, Rect) {
|
||||||
|
let width = width.min(self.width);
|
||||||
let l = (self.width - width) / 2;
|
let l = (self.width - width) / 2;
|
||||||
let r = self.width - width - l;
|
let r = self.width - width - l;
|
||||||
(
|
(
|
||||||
|
|
Loading…
Reference in New Issue