Record Class TextFacet
- Record Components:
text- the whole text, already masked where it is masked; nevernullcaretOffset- where the caret sitscaretAffinity- which side ofcaretOffsetthe caret is onselectionStart- where the selection begins, equal toselectionEndwhen there is noneselectionEnd- where it endslineCount- how many lines the text has, counting a trailing empty onecaretRect- the caret's rectangle in the window's coordinates, the space the node's own box is published in, transforms above it applied (the box that holds the turned caret);nullwhen the node has no caret to draw
Every offset here is a UTF-16 code unit. The unit is stated once, in this sentence, because the three platforms disagree — one counts UTF-16, one counts characters — and a model that left it implicit produces silently wrong carets in emoji and in the CJK extensions. UTF-16 is chosen because it is what the toolkit's own editing model counts in and what one of the three platforms wants unchanged; the bridge that needs characters converts at that one boundary and nowhere else.
A caret is not an index. An offset on a direction boundary is two points on the line, so the caret carries its affinity as well as its offset. A bridge drops the affinity only where its platform has nowhere to put it.
A masked field publishes the mask. A password field that is not revealed puts one mask character per caret stop here and never its own text, and its caret and selection offsets are offsets into that string: the secret's own offsets would run past the end of a mask that is shorter by an astral character.
-
Constructor Summary
ConstructorsConstructorDescriptionTextFacet(String text, int caretOffset, ShapedText.Affinity caretAffinity, int selectionStart, int selectionEnd, int lineCount, @Nullable Rect caretRect) Creates an instance of aTextFacetrecord class. -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of thecaretAffinityrecord component.intReturns the value of thecaretOffsetrecord component.@Nullable RectReturns the value of thecaretRectrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.booleanintReturns the value of thelineCountrecord component.intReturns the value of theselectionEndrecord component.intReturns the value of theselectionStartrecord component.text()Returns the value of thetextrecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
TextFacet
public TextFacet(String text, int caretOffset, ShapedText.Affinity caretAffinity, int selectionStart, int selectionEnd, int lineCount, @Nullable Rect caretRect) Creates an instance of aTextFacetrecord class.- Parameters:
text- the value for thetextrecord componentcaretOffset- the value for thecaretOffsetrecord componentcaretAffinity- the value for thecaretAffinityrecord componentselectionStart- the value for theselectionStartrecord componentselectionEnd- the value for theselectionEndrecord componentlineCount- the value for thelineCountrecord componentcaretRect- the value for thecaretRectrecord component
-
-
Method Details
-
hasSelection
public boolean hasSelection()- Returns:
- whether any text is selected
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
text
Returns the value of thetextrecord component.- Returns:
- the value of the
textrecord component
-
caretOffset
public int caretOffset()Returns the value of thecaretOffsetrecord component.- Returns:
- the value of the
caretOffsetrecord component
-
caretAffinity
Returns the value of thecaretAffinityrecord component.- Returns:
- the value of the
caretAffinityrecord component
-
selectionStart
public int selectionStart()Returns the value of theselectionStartrecord component.- Returns:
- the value of the
selectionStartrecord component
-
selectionEnd
public int selectionEnd()Returns the value of theselectionEndrecord component.- Returns:
- the value of the
selectionEndrecord component
-
lineCount
public int lineCount()Returns the value of thelineCountrecord component.- Returns:
- the value of the
lineCountrecord component
-
caretRect
Returns the value of thecaretRectrecord component.- Returns:
- the value of the
caretRectrecord component
-