aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src/ui/overlay.rs
diff options
context:
space:
mode:
authorwongjiahau2024-05-01 20:42:31 +0000
committerJJ2024-05-01 23:06:08 +0000
commit3bff36ab90aba7de8bb5bff7dbb8230d81cdf582 (patch)
tree733bdb4ff30a35c2212910d48a635ddf4c23b2e3 /helix-term/src/ui/overlay.rs
parent2cadec0b1182332338a5a1cc3062776f834d8835 (diff)
Add file explorer and tree helper
ref: https://github.com/helix-editor/helix/issues/200 ref: https://github.com/helix-editor/helix/pull/2377 ref: https://github.com/helix-editor/helix/pull/5566 ref: https://github.com/helix-editor/helix/pull/5768 Co-authored-by: cossonleo <cossonleo@foxmail.com> Co-authored-by: JJ <git@toki.la> Co-authored-by: Quan Tong <quantonganh@gmail.com>
Diffstat (limited to 'helix-term/src/ui/overlay.rs')
-rw-r--r--helix-term/src/ui/overlay.rs21
1 files changed, 1 insertions, 20 deletions
diff --git a/helix-term/src/ui/overlay.rs b/helix-term/src/ui/overlay.rs
index ff184d40..7b9c0391 100644
--- a/helix-term/src/ui/overlay.rs
+++ b/helix-term/src/ui/overlay.rs
@@ -19,26 +19,7 @@ pub struct Overlay<T> {
pub fn overlaid<T>(content: T) -> Overlay<T> {
Overlay {
content,
- calc_child_size: Box::new(|rect: Rect| clip_rect_relative(rect.clip_bottom(2), 90, 90)),
- }
-}
-
-fn clip_rect_relative(rect: Rect, percent_horizontal: u8, percent_vertical: u8) -> Rect {
- fn mul_and_cast(size: u16, factor: u8) -> u16 {
- ((size as u32) * (factor as u32) / 100).try_into().unwrap()
- }
-
- let inner_w = mul_and_cast(rect.width, percent_horizontal);
- let inner_h = mul_and_cast(rect.height, percent_vertical);
-
- let offset_x = rect.width.saturating_sub(inner_w) / 2;
- let offset_y = rect.height.saturating_sub(inner_h) / 2;
-
- Rect {
- x: rect.x + offset_x,
- y: rect.y + offset_y,
- width: inner_w,
- height: inner_h,
+ calc_child_size: Box::new(|rect: Rect| rect.overlaid()),
}
}