@Environment(value=CLIENT) public class TextHandler extends Object
| Modifier and Type | Class and Description |
|---|---|
(package private) class |
TextHandler.LineBreakingVisitor |
(package private) static class |
TextHandler.LineWrappingCollector |
static interface |
TextHandler.LineWrappingConsumer
A consumer of the line-breaking information.
|
(package private) static class |
TextHandler.StyledString |
(package private) class |
TextHandler.WidthLimitingVisitor |
static interface |
TextHandler.WidthRetriever
A retriever of character width.
|
| Modifier and Type | Field and Description |
|---|---|
private TextHandler.WidthRetriever |
widthRetriever |
| Constructor and Description |
|---|
TextHandler(TextHandler.WidthRetriever widthRetriever) |
| Modifier and Type | Method and Description |
|---|---|
int |
getTrimmedLength(String text,
int maxWidth,
Style style)
Returns the length of a string when it is trimmed to be at most
maxWidth wide. |
float |
getWidth(String text)
Returns the width of a string.
|
float |
getWidth(StringRenderable text)
Returns the width of a text.
|
List<StringRenderable> |
method_29971(StringRenderable stringRenderable,
int int2,
Style style,
StringRenderable stringRenderable2) |
private StringRenderable |
method_29972(StringRenderable stringRenderable,
boolean bool,
StringRenderable stringRenderable2) |
static int |
moveCursorByWords(String text,
int offset,
int cursor,
boolean consumeSpaceOrBreak) |
String |
trimToWidth(String text,
int maxWidth,
Style style)
Trim a string to be at most
maxWidth wide. |
Style |
trimToWidth(StringRenderable text,
int maxWidth)
Trim a text to be at most
maxWidth wide. |
StringRenderable |
trimToWidth(StringRenderable text,
int width,
Style style) |
String |
trimToWidthBackwards(String text,
int maxWidth,
Style style)
Trim a string from right to left to be at most
maxWidth wide. |
List<StringRenderable> |
wrapLines(String text,
int maxWidth,
Style style) |
void |
wrapLines(String text,
int maxWidth,
Style style,
boolean retainTrailingWordSplit,
TextHandler.LineWrappingConsumer consumer) |
List<StringRenderable> |
wrapLines(StringRenderable stringRenderable,
int maxWidth,
Style style) |
private final TextHandler.WidthRetriever widthRetriever
public TextHandler(TextHandler.WidthRetriever widthRetriever)
public float getWidth(StringRenderable text)
public int getTrimmedLength(String text, int maxWidth, Style style)
maxWidth wide.text - the string to trimmaxWidth - the max width of the trimmed stringstyle - the style of the trimmed stringpublic String trimToWidth(String text, int maxWidth, Style style)
maxWidth wide.text - the string to trimmaxWidth - the max width of the trimmed stringstyle - the style of the trimmed stringpublic String trimToWidthBackwards(String text, int maxWidth, Style style)
maxWidth wide.text - the string to trimmaxWidth - the max width of the trimmed stringstyle - the style of the trimmed string@Nullable public Style trimToWidth(StringRenderable text, int maxWidth)
maxWidth wide.maxWidth - the max width of the trimmed textpublic StringRenderable trimToWidth(StringRenderable text, int width, Style style)
public static int moveCursorByWords(String text, int offset, int cursor, boolean consumeSpaceOrBreak)
public void wrapLines(String text, int maxWidth, Style style, boolean retainTrailingWordSplit, TextHandler.LineWrappingConsumer consumer)
public List<StringRenderable> wrapLines(String text, int maxWidth, Style style)
public List<StringRenderable> wrapLines(StringRenderable stringRenderable, int maxWidth, Style style)
public List<StringRenderable> method_29971(StringRenderable stringRenderable, int int2, Style style, @Nullable StringRenderable stringRenderable2)
private StringRenderable method_29972(StringRenderable stringRenderable, boolean bool, StringRenderable stringRenderable2)