aboutsummaryrefslogtreecommitdiff
path: root/azalea-chat/src
diff options
context:
space:
mode:
authormat <git@matdoes.dev>2025-08-12 11:00:11 -1000
committermat <git@matdoes.dev>2025-08-12 11:00:11 -1000
commit7f4e3c583dd669561e8502822952fc9afe26e005 (patch)
tree831fbcb717493858c31ad58796e01494da276d76 /azalea-chat/src
parentc36c3c0ed02b3727ba61b45a6a7febf1a008a7dc (diff)
downloadazalea-drasl-7f4e3c583dd669561e8502822952fc9afe26e005.tar.xz
add nearest_entity_by and improve some docs
Diffstat (limited to 'azalea-chat/src')
-rw-r--r--azalea-chat/src/component.rs15
1 files changed, 8 insertions, 7 deletions
diff --git a/azalea-chat/src/component.rs b/azalea-chat/src/component.rs
index bf064c8f..62e5e151 100644
--- a/azalea-chat/src/component.rs
+++ b/azalea-chat/src/component.rs
@@ -131,7 +131,6 @@ impl FormattedText {
&mut output,
&mut style_formatter,
&mut text_formatter,
- &mut cleanup_formatter,
&default_style.clone(),
&mut running_style,
);
@@ -140,18 +139,16 @@ impl FormattedText {
output
}
- fn to_custom_format_recursive<F, S, C>(
+ fn to_custom_format_recursive<F, S>(
&self,
output: &mut String,
style_formatter: &mut F,
text_formatter: &mut S,
- cleanup_formatter: &mut C,
parent_style: &Style,
running_style: &mut Style,
) where
F: FnMut(&Style, &Style) -> (String, String),
S: FnMut(&str) -> String,
- C: FnMut(&Style) -> String,
{
let component_text = match &self {
Self::Text(c) => c.text.to_string(),
@@ -166,7 +163,7 @@ impl FormattedText {
if !component_text.is_empty() {
let (formatted_style_prefix, formatted_style_suffix) =
- style_formatter(&running_style, &new_style);
+ style_formatter(running_style, &new_style);
let formatted_text = text_formatter(&component_text);
output.push_str(&formatted_style_prefix);
@@ -181,7 +178,6 @@ impl FormattedText {
output,
style_formatter,
text_formatter,
- cleanup_formatter,
&new_style,
running_style,
);
@@ -211,7 +207,7 @@ impl FormattedText {
/// colored white.
///
/// If you don't want the result to be styled at all, use
- /// [`Self::to_string`].
+ /// [`Self::to_string`](#method.fmt-1).
///
/// # Examples
///
@@ -230,6 +226,7 @@ impl FormattedText {
self.to_ansi_with_custom_style(&DEFAULT_STYLE)
}
+ /// Similar to [`Self::to_ansi`] but renders the result as HTML instead.
pub fn to_html(&self) -> String {
self.to_custom_format(
|running, new| {
@@ -664,6 +661,10 @@ impl From<TextComponent> for FormattedText {
}
impl Display for FormattedText {
+ /// Render the text in the component but without any formatting/styling.
+ ///
+ /// If you want the text to be styled, consider using [`Self::to_ansi`] or
+ /// [`Self::to_html`].
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
FormattedText::Text(c) => c.fmt(f),