diff --git a/src/display/frame.rs b/src/display/frame.rs index 012b2e5..520499b 100644 --- a/src/display/frame.rs +++ b/src/display/frame.rs @@ -18,7 +18,7 @@ pub struct Frame { // Both are (w, h) start: (u16, u16), end: (u16, u16), - width: u16, + border: u16, theme: ColorSet, } @@ -37,13 +37,13 @@ impl Frame { #[inline(always)] pub fn goto(&self, x: u16, y: u16) -> String { let cg = cursor::Goto( - self.width.max( - (self.width + self.start.0 + x) - .min(self.end.0 - self.width), + self.border.max( + (self.border + self.start.0 + x) + .min(self.end.0 - self.border), ), - self.width.max( - (self.width + self.start.1 + y) - .min(self.end.1 - self.width), + self.border.max( + (self.border + self.start.1 + y) + .min(self.end.1 - self.border), ), ); cg.into() @@ -62,7 +62,7 @@ impl Frame { fn write_clear_to_end(&self, s: &str) -> String { let clear_length = self.size().0 as usize - s.len() - - (self.width * 2) as usize; + - (self.border * 2) as usize; format!("{}{}", s, " ".repeat(clear_length)) } @@ -129,13 +129,13 @@ impl Frame { Self { start: (1.max(term_w - pos_w), 1.max(term_h - pos_h)), end: (pos_w, pos_h), - width, + border: width, theme, } } pub fn frame_str(&self, body_theme: String) -> String { - if self.width == 0 { + if self.border == 0 { return body_theme + &clear::All.to_string(); } self.goto_internal(0, 0); @@ -149,22 +149,22 @@ impl Frame { body_theme.clone() + &" ".repeat(w_len as usize); frame.push(self.theme.to_string()); - for y in 0..self.width { + for y in 0..self.border { frame.push(self.write_frame_line(y, w_len)); } - for y in self.width..h_len - self.width { + for y in self.border..h_len - self.border { frame.push(format!( "{left}{body_clear}{frame_theme}{left}{char}{right}{char}", body_clear = &body_clear, frame_theme = &frame_theme, left = self.goto_internal(0, y), - right = self.goto_internal(w_len - self.width, y), + right = self.goto_internal(w_len - self.border, y), char = FRAME_CHAR_VERTICAL .to_string() - .repeat(self.width as usize), + .repeat(self.border as usize), )); } - for y in h_len - self.width..h_len { + for y in h_len - self.border..h_len { frame.push(self.write_frame_line(y, w_len)); } frame.push(self.goto(0, 0));