added the ability for custom borders to actually affect the bubble output

This commit is contained in:
spiders 2022-05-03 23:10:44 -07:00
parent 46af7774a5
commit 6e0aeb53e7
2 changed files with 27 additions and 7 deletions

View file

@ -42,6 +42,7 @@ impl BubbleConfig {
middle_right: "|".to_string(),
};
};
//
let left = if let Some(item) = chars.get(1) {
item.to_string()
} else {
@ -145,12 +146,22 @@ impl BubbleConfig {
};
let bubble_top = manipulate::pad_left(
&format!(" _{}_ \n", "_".repeat(line_length)),
&format!(
" {}{}{} \n",
self.top,
self.top.repeat(line_length),
self.top
),
left_pad_length,
" ",
);
let bubble_bottom = manipulate::pad_left(
&format!(" -{}- ", "-".repeat(line_length)),
&format!(
" {}{}{} ",
self.bottom,
self.bottom.repeat(line_length),
self.bottom
),
left_pad_length,
" ",
);
@ -161,27 +172,36 @@ impl BubbleConfig {
return format!(
"{}{}{}",
bubble_top,
manipulate::pad_left(&format!("< {} >\n", lines[0]), left_pad_length, " "),
manipulate::pad_left(
&format!("{} {} {}\n", self.left, lines[0], self.right),
left_pad_length,
" "
),
bubble_bottom
)
}
n => {
bubble_body.push_str(&manipulate::pad_left(
&format!("/ {} \\\n", lines[0]),
&format!("{} {} {}\n", self.top_left, lines[0], self.top_right),
left_pad_length,
" ",
));
if n > 2 {
for i in 1..n - 1 {
bubble_body.push_str(&manipulate::pad_left(
&format!("| {} |\n", lines[i]),
&format!("{} {} {}\n", self.middle_left, lines[i], self.middle_right),
left_pad_length,
" ",
));
}
}
bubble_body.push_str(&manipulate::pad_left(
&format!("\\ {} /\n", lines[n - 1]),
&format!(
"{} {} {}\n",
self.bottom_left,
lines[n - 1],
self.bottom_right
),
left_pad_length,
" ",
));

View file

@ -189,7 +189,7 @@ impl Args {
let bubble_config = BubbleConfig::config_from_string(
critter_config.template.anchor,
DEFAULT_MAXIMUM_LINE_LENGTH,
None,
Some("".to_string()),
);
(critter_config, bubble_config)