StyledText.setStyleRanges

Sets styles to be used for rendering the widget content. <p> All styles in the widget will be replaced with the given set of ranges and styles. The ranges array contains start and length pairs. Each pair refers to the corresponding style in the styles array. For example, the pair that starts at rangesn with length ranges[n+1] uses the style at styles[n/2]. The range fields within each StyleRange are ignored. If either argument is null, the styles are cleared. </p><p> Note: It is expected that the same instance of a StyleRange will occur multiple times within the styles array, reducing memory usage. </p><p> Should not be called if a LineStyleListener has been set since the listener maintains the styles. </p>

@param ranges the array of ranges. The ranges must not overlap and must be in order. @param styles the array of StyleRanges. The range fields within the StyleRange are unused.

@exception SWTException <ul> <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> </ul> @exception IllegalArgumentException <ul> <li>ERROR_NULL_ARGUMENT when an element in the styles array is null</li> <li>ERROR_INVALID_RANGE when the number of ranges and style do not match (ranges.length * 2 is styles.length)</li> <li>ERROR_INVALID_RANGE when a range is outside the valid range (> getCharCount() or less than zero)</li> <li>ERROR_INVALID_RANGE when a range overlaps</li> </ul>

@since 3.2

  1. void setStyleRanges(int start, int length, int[] ranges, StyleRange[] styles)
  2. void setStyleRanges(int[] ranges, StyleRange[] styles)
    class StyledText
    void
    setStyleRanges
  3. void setStyleRanges(StyleRange[] ranges)

Meta