Frame.width -> frame.border
This commit is contained in:
parent
c70ecf5fbe
commit
9dbc2fc471
|
@ -18,7 +18,7 @@ pub struct Frame {
|
||||||
// Both are (w, h)
|
// Both are (w, h)
|
||||||
start: (u16, u16),
|
start: (u16, u16),
|
||||||
end: (u16, u16),
|
end: (u16, u16),
|
||||||
width: u16,
|
border: u16,
|
||||||
theme: ColorSet,
|
theme: ColorSet,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,13 +37,13 @@ impl Frame {
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn goto(&self, x: u16, y: u16) -> String {
|
pub fn goto(&self, x: u16, y: u16) -> String {
|
||||||
let cg = cursor::Goto(
|
let cg = cursor::Goto(
|
||||||
self.width.max(
|
self.border.max(
|
||||||
(self.width + self.start.0 + x)
|
(self.border + self.start.0 + x)
|
||||||
.min(self.end.0 - self.width),
|
.min(self.end.0 - self.border),
|
||||||
),
|
),
|
||||||
self.width.max(
|
self.border.max(
|
||||||
(self.width + self.start.1 + y)
|
(self.border + self.start.1 + y)
|
||||||
.min(self.end.1 - self.width),
|
.min(self.end.1 - self.border),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
cg.into()
|
cg.into()
|
||||||
|
@ -62,7 +62,7 @@ impl Frame {
|
||||||
fn write_clear_to_end(&self, s: &str) -> String {
|
fn write_clear_to_end(&self, s: &str) -> String {
|
||||||
let clear_length = self.size().0 as usize
|
let clear_length = self.size().0 as usize
|
||||||
- s.len()
|
- s.len()
|
||||||
- (self.width * 2) as usize;
|
- (self.border * 2) as usize;
|
||||||
format!("{}{}", s, " ".repeat(clear_length))
|
format!("{}{}", s, " ".repeat(clear_length))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,13 +129,13 @@ impl Frame {
|
||||||
Self {
|
Self {
|
||||||
start: (1.max(term_w - pos_w), 1.max(term_h - pos_h)),
|
start: (1.max(term_w - pos_w), 1.max(term_h - pos_h)),
|
||||||
end: (pos_w, pos_h),
|
end: (pos_w, pos_h),
|
||||||
width,
|
border: width,
|
||||||
theme,
|
theme,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn frame_str(&self, body_theme: String) -> String {
|
pub fn frame_str(&self, body_theme: String) -> String {
|
||||||
if self.width == 0 {
|
if self.border == 0 {
|
||||||
return body_theme + &clear::All.to_string();
|
return body_theme + &clear::All.to_string();
|
||||||
}
|
}
|
||||||
self.goto_internal(0, 0);
|
self.goto_internal(0, 0);
|
||||||
|
@ -149,22 +149,22 @@ impl Frame {
|
||||||
body_theme.clone() + &" ".repeat(w_len as usize);
|
body_theme.clone() + &" ".repeat(w_len as usize);
|
||||||
frame.push(self.theme.to_string());
|
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));
|
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!(
|
frame.push(format!(
|
||||||
"{left}{body_clear}{frame_theme}{left}{char}{right}{char}",
|
"{left}{body_clear}{frame_theme}{left}{char}{right}{char}",
|
||||||
body_clear = &body_clear,
|
body_clear = &body_clear,
|
||||||
frame_theme = &frame_theme,
|
frame_theme = &frame_theme,
|
||||||
left = self.goto_internal(0, y),
|
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
|
char = FRAME_CHAR_VERTICAL
|
||||||
.to_string()
|
.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.write_frame_line(y, w_len));
|
||||||
}
|
}
|
||||||
frame.push(self.goto(0, 0));
|
frame.push(self.goto(0, 0));
|
||||||
|
|
Loading…
Reference in New Issue