From 01e000169dab710ea78cc38b0c58b648f190f6b6 Mon Sep 17 00:00:00 2001 From: Jack Wills <32690432+mrjackwills@users.noreply.github.com> Date: Fri, 29 Apr 2022 01:12:44 +0000 Subject: [PATCH] feat: help box "m" explanation --- src/ui/draw_blocks.rs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/ui/draw_blocks.rs b/src/ui/draw_blocks.rs index 3d492b2..362735e 100644 --- a/src/ui/draw_blocks.rs +++ b/src/ui/draw_blocks.rs @@ -634,8 +634,20 @@ pub fn draw_info(f: &mut Frame<'_, B>, text: String) { /// draw a box in the center of the screen, based on max line width + number of lines fn draw_popup(text_lines: u16, text_width: u16, r: Rect, box_location: BoxLocation) -> Rect { // This can panic if number_lines or max_line_width is larger than r.height or r.width - let blank_vertical = (r.height - text_lines) / 2; - let blank_horizontal = (r.width - text_width) / 2; + + + + let blank_vertical = if r.height > text_lines { + (r.height - text_lines) / 2 + } else { + r.height / 2 + }; + let blank_horizontal = if r.width > text_width { + (r.width - text_width) / 2 + }else { + r.width / 2 + + }; let vertical_constraints = box_location.get_vertical_constraints(blank_vertical, text_lines); let horizontal_constraints =