Using a LineStyleListener : StyledText LineStyle « SWT « Java Tutorial






LineStyleListeners examine single lines at a time.

LineStyleEvent Fields

FieldDescription
int lineOffsetThe zero-based offset, relative to the whole text, of the line the StyledText needs style information for. Note: this is the character offset, not the line number.
String lineTextThe text of the line the StyledText needs style information for.
StyleRange [] stylesThe array that holds the StyleRange objects you create for the line.


To calcualate the offset for StyleRanges

int styleRangeOffset = offsetIntoLine + event.lineOffset;
17.47.StyledText LineStyle
17.47.1.Using a LineStyleListener
17.47.2.Creating a LineStyleListenerCreating a LineStyleListener
17.47.3.Crossing LinesCrossing Lines