Class FormattingVisitor
java.lang.Object
com.blamejared.searchables.api.formatter.FormattingVisitor
- All Implemented Interfaces:
ContextAwareVisitor<TokenRange,,FormattingContext> Consumer<String>,net.minecraft.client.gui.components.EditBox.TextFormatter
public class FormattingVisitor
extends Object
implements ContextAwareVisitor<TokenRange,FormattingContext>, Consumer<String>, net.minecraft.client.gui.components.EditBox.TextFormatter
Applies style formatting for an
EditBox, intended to be passed into EditBox.addFormatter(EditBox.TextFormatter)}.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid@Nullable net.minecraft.util.FormattedCharSequencevoidreset()Resets this visitor to a state that allows it to run again.Optional<com.mojang.datafixers.util.Pair<TokenRange, net.minecraft.network.chat.Style>> tokenAt(int position) List<com.mojang.datafixers.util.Pair<TokenRange, net.minecraft.network.chat.Style>> tokens()visitComponent(ComponentExpression expr, FormattingContext context) visitGrouping(GroupingExpression expr, FormattingContext context) visitLiteral(LiteralExpression expr, FormattingContext context) visitPaired(PairedExpression expr, FormattingContext context) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.blamejared.searchables.lang.expression.visitor.ContextAwareVisitor
postVisit
-
Constructor Details
-
FormattingVisitor
-
-
Method Details
-
reset
public void reset()Resets this visitor to a state that allows it to run again. -
tokens
-
tokenAt
public Optional<com.mojang.datafixers.util.Pair<TokenRange,net.minecraft.network.chat.Style>> tokenAt(int position) - Parameters:
position- The current cursor position.- Returns:
- An
Optional<com.mojang.datafixers.util.Pair>ofTokenRangeandStyleat the given position, or an empty optional if out of bounds.
-
visitGrouping
- Specified by:
visitGroupingin interfaceContextAwareVisitor<TokenRange,FormattingContext>
-
visitComponent
- Specified by:
visitComponentin interfaceContextAwareVisitor<TokenRange,FormattingContext>
-
visitLiteral
- Specified by:
visitLiteralin interfaceContextAwareVisitor<TokenRange,FormattingContext>
-
visitPaired
- Specified by:
visitPairedin interfaceContextAwareVisitor<TokenRange,FormattingContext>
-
accept
-
format
@Nullable public @Nullable net.minecraft.util.FormattedCharSequence format(String currentString, int offset) - Specified by:
formatin interfacenet.minecraft.client.gui.components.EditBox.TextFormatter
-