Class InlineStyles
java.lang.Object
com.codename1.ui.editor.InlineStyles
The per character inline style model for the pure rich text editor. It keeps one
TextStyle
reference for every character in the document, kept in lockstep with the text through #applyEdit.
Runs of identical style are coalesced only at render time, which keeps edits simple and correct at
the cost of one reference per character (rich documents are small enough for this to be a non issue).-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceA predicate over a style, used by#allInRange.static interfaceA transform applied to a character's style, used to toggle bold, set a color, etc. -
Constructor Summary
ConstructorsConstructorDescriptionInlineStyles(int length) Creates a model of the given length, all default style. -
Method Summary
Modifier and TypeMethodDescriptionbooleanallInRange(int start, int end, InlineStyles.StylePredicate p) True when every character in[start, end)satisfies the predicate.voidKeeps the model in sync with a text replacement: removesremovedLenstyles atstartand insertsinsertedLencopies ofstyle.intlength()Returns the number of characters covered.voidreset(int length) Resets the model to the given length, all default style.voidSets the style of a single character.styleAt(int index) Returns the style of the character atindex, or the default style out of range.voidtransformRange(int start, int end, InlineStyles.StyleTransform t) Applies a transform to every character's style in[start, end).
-
Constructor Details
-
InlineStyles
public InlineStyles(int length) Creates a model of the given length, all default style.
-
-
Method Details
-
reset
public void reset(int length) Resets the model to the given length, all default style. -
length
public int length()Returns the number of characters covered. -
styleAt
Returns the style of the character atindex, or the default style out of range. -
applyEdit
Keeps the model in sync with a text replacement: removes
removedLenstyles atstartand insertsinsertedLencopies ofstyle.Parameters
-
start: the offset of the edit -
removedLen: number of characters removed -
insertedLen: number of characters inserted -
style: the style applied to the inserted characters
-
-
setAt
Sets the style of a single character. -
transformRange
Applies a transform to every character's style in[start, end). -
allInRange
True when every character in[start, end)satisfies the predicate. An empty range checks the character just before the caret (the style typing would continue with).
-