Class StringFormatter<K,T extends games.stendhal.client.gui.textformat.FormatSet<K,T>>
java.lang.Object
games.stendhal.client.gui.textformat.StringFormatter<K,T>
- Type Parameters:
K
- type of the TextFormatSet internal dataT
- type holding the text attributes
public class StringFormatter<K,T extends games.stendhal.client.gui.textformat.FormatSet<K,T>>
extends Object
A class for creating attributed strings from strings using the stendhal
style markup. The rules are:
- Text starts in a defined font and color mode.
- A special character changes to a mode specific to that character.
- If a new special mode is started while the previous is in effect, their effects are combined, the definitions of the newer mode overriding the other where they would be in conflict.
- If the markup character is followed by a single quote " ' ", the mode ends at the next single quote. Otherwise the mode ends at the next white space or punctuation character. Only the last active mode is terminated.
- If a markup character would start a new mode that is the same as the current effective, the markup character is treated as if it was a normal character.
- The backslash character '\' can be used to prevent the normal effect of the special characters to allow printing them. Backslash can be printed by escaping it with itself '\\'.
-
Constructor Summary
-
Method Summary
-
Constructor Details
-
StringFormatter
public StringFormatter()
-
-
Method Details
-
addStyle
Add a formatting style.- Parameters:
c
- character for turning on the styleattributes
- attributes to be used for the text in the style
-
format
Format a string.- Parameters:
s
- string which may contain formatting markupnormalAttributes
- attributes for the normal textdest
- destination to write parsed and attributed output
-