From 6e0aeb53e7bffe79d5edbbdead082a72204b6e6f Mon Sep 17 00:00:00 2001 From: spiders Date: Tue, 3 May 2022 23:10:44 -0700 Subject: [PATCH] added the ability for custom borders to actually affect the bubble output --- src/bubbles.rs | 32 ++++++++++++++++++++++++++------ src/main.rs | 2 +- 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/src/bubbles.rs b/src/bubbles.rs index 4ba8aa5..5675070 100644 --- a/src/bubbles.rs +++ b/src/bubbles.rs @@ -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, " ", )); diff --git a/src/main.rs b/src/main.rs index 985179d..6edded6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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)