aboutsummaryrefslogtreecommitdiff
path: root/azalea-chat/src
diff options
context:
space:
mode:
Diffstat (limited to 'azalea-chat/src')
-rwxr-xr-xazalea-chat/src/component.rs12
-rwxr-xr-xazalea-chat/src/style.rs3
-rwxr-xr-xazalea-chat/src/text_component.rs14
3 files changed, 18 insertions, 11 deletions
diff --git a/azalea-chat/src/component.rs b/azalea-chat/src/component.rs
index 3a232ee5..ea485049 100755
--- a/azalea-chat/src/component.rs
+++ b/azalea-chat/src/component.rs
@@ -61,8 +61,8 @@ impl Component {
/// [ANSI string](https://en.wikipedia.org/wiki/ANSI_escape_code), so you
/// can print it to your terminal and get styling.
///
- /// This is technically a shortcut for [`Component::to_ansi_custom_style`] with a
- /// default [`Style`] colored white.
+ /// This is technically a shortcut for [`Component::to_ansi_custom_style`]
+ /// with a default [`Style`] colored white.
///
/// # Examples
///
@@ -166,8 +166,9 @@ impl<'de> Deserialize<'de> for Component {
.ok_or_else(|| de::Error::custom("\"with\" must be an array"))?;
let mut with_array = Vec::with_capacity(with.len());
for item in with {
- // if it's a string component with no styling and no siblings, just add a string to with_array
- // otherwise add the component to the array
+ // if it's a string component with no styling and no siblings, just add a
+ // string to with_array otherwise add the component
+ // to the array
let c = Component::deserialize(item).map_err(de::Error::custom)?;
if let Component::Text(text_component) = c {
if text_component.base.siblings.is_empty()
@@ -253,7 +254,8 @@ impl<'de> Deserialize<'de> for Component {
));
}
let json_array = json.as_array().unwrap();
- // the first item in the array is the one that we're gonna return, the others are siblings
+ // the first item in the array is the one that we're gonna return, the others
+ // are siblings
let mut component = Component::deserialize(&json_array[0]).map_err(de::Error::custom)?;
for i in 1..json_array.len() {
component.append(
diff --git a/azalea-chat/src/style.rs b/azalea-chat/src/style.rs
index cb708982..ed800c71 100755
--- a/azalea-chat/src/style.rs
+++ b/azalea-chat/src/style.rs
@@ -435,7 +435,8 @@ impl Style {
if !before.underlined.unwrap_or(false) && after.underlined.unwrap_or(false) {
ansi_codes.push_str(Ansi::UNDERLINED);
}
- // if strikethrough used to be false/default and now it's true, set strikethrough
+ // if strikethrough used to be false/default and now it's true, set
+ // strikethrough
if !before.strikethrough.unwrap_or(false) && after.strikethrough.unwrap_or(false) {
ansi_codes.push_str(Ansi::STRIKETHROUGH);
}
diff --git a/azalea-chat/src/text_component.rs b/azalea-chat/src/text_component.rs
index e5cc054e..44bcbcf1 100755
--- a/azalea-chat/src/text_component.rs
+++ b/azalea-chat/src/text_component.rs
@@ -27,13 +27,16 @@ impl Serialize for TextComponent {
const LEGACY_FORMATTING_CODE_SYMBOL: char = 'ยง';
/// Convert a legacy color code string into a Component
-/// Technically in Minecraft this is done when displaying the text, but AFAIK it's the same as just doing it in TextComponent
+/// Technically in Minecraft this is done when displaying the text, but AFAIK
+/// it's the same as just doing it in TextComponent
pub fn legacy_color_code_to_text_component(legacy_color_code: &str) -> TextComponent {
let mut components: Vec<TextComponent> = Vec::with_capacity(1);
- // iterate over legacy_color_code, if it starts with LEGACY_COLOR_CODE_SYMBOL then read the next character and get the style from that
- // otherwise, add the character to the text
+ // iterate over legacy_color_code, if it starts with LEGACY_COLOR_CODE_SYMBOL
+ // then read the next character and get the style from that otherwise, add
+ // the character to the text
- // we don't use a normal for loop since we need to be able to skip after reading the formatter code symbol
+ // we don't use a normal for loop since we need to be able to skip after reading
+ // the formatter code symbol
let mut i = 0;
while i < legacy_color_code.chars().count() {
if legacy_color_code.chars().nth(i).unwrap() == LEGACY_FORMATTING_CODE_SYMBOL {
@@ -72,7 +75,8 @@ pub fn legacy_color_code_to_text_component(legacy_color_code: &str) -> TextCompo
return TextComponent::new("".to_string());
}
- // create the final component by using the first one as the base, and then adding the rest as siblings
+ // create the final component by using the first one as the base, and then
+ // adding the rest as siblings
let mut final_component = components.remove(0);
for component in components {
final_component.base.siblings.push(component.get());