@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 |
---|---|
Style |
getStyleAt(OrderedText text,
int x)
Gets the style at the
x position in a text. |
Style |
getStyleAt(StringVisitable text,
int x)
Gets the style at the
x position in a text. |
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(OrderedText text) |
float |
getWidth(String text)
Returns the width of a string.
|
float |
getWidth(StringVisitable text)
Returns the width of a text.
|
void |
method_29971(StringVisitable stringVisitable,
int int2,
Style style,
BiConsumer<StringVisitable,Boolean> biConsumer) |
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. |
StringVisitable |
trimToWidth(StringVisitable 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<StringVisitable> |
wrapLines(String text,
int maxWidth,
Style style) |
void |
wrapLines(String text,
int maxWidth,
Style style,
boolean retainTrailingWordSplit,
TextHandler.LineWrappingConsumer consumer) |
List<StringVisitable> |
wrapLines(StringVisitable stringVisitable,
int maxWidth,
Style style) |
private final TextHandler.WidthRetriever widthRetriever
public TextHandler(TextHandler.WidthRetriever widthRetriever)
public float getWidth(StringVisitable text)
public float getWidth(OrderedText 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 getStyleAt(StringVisitable text, int x)
x
position in a text.x
- the position in the text@Nullable public Style getStyleAt(OrderedText text, int x)
x
position in a text.x
- the position in the textpublic StringVisitable trimToWidth(StringVisitable 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<StringVisitable> wrapLines(String text, int maxWidth, Style style)
public List<StringVisitable> wrapLines(StringVisitable stringVisitable, int maxWidth, Style style)
public void method_29971(StringVisitable stringVisitable, int int2, Style style, BiConsumer<StringVisitable,Boolean> biConsumer)