for (int i = 0; i < styles.length; i++) {
int endOffset = startOffset + super.getCharCount(); int lineEndOffset = Math.min(lineLength, endOffset - lineOffset); for (int i = 0; i < styles.length; i++) {
	void writeStyledLine(String line, int lineOffset, StyleRange[] styles, Color lineBackground) {		int lineLength = line.length();		int lineIndex;		int copyEnd;		int startOffset = getStart();				int endOffset = startOffset + super.getCharCount();		int lineEndOffset = Math.min(lineLength, endOffset - lineOffset);		int writeOffset = startOffset - lineOffset;				if (writeOffset >= line.length()) {			return;					// whole line is outside write range		}		else		if (writeOffset > 0) {			lineIndex = writeOffset;		// line starts before RTF write start		}		else {			lineIndex = 0;		}		if (lineBackground != null) {			write("{\\highlight");			write(getColorIndex(lineBackground, DEFAULT_BACKGROUND));			write(" "); 		}		for (int i = 0; i < styles.length; i++) {					StyleRange style = styles[i];			int start = style.start - lineOffset;			int end = start + style.length;			int colorIndex;			// skip over partial first line			if (end < writeOffset) {				continue;			}			// style starts beyond line end or RTF write end			if (start >= lineEndOffset) {				break;			}			// write any unstyled text			if (lineIndex < start) { 				// copy to start of style				// style starting betond end of write range or end of line 				// is guarded against above.				write(line, lineIndex, start);				lineIndex = start;			}			// write styled text			colorIndex = getColorIndex(style.background, DEFAULT_BACKGROUND);			write("{\\cf");			write(getColorIndex(style.foreground, DEFAULT_FOREGROUND));			if (colorIndex != DEFAULT_BACKGROUND) {				write("\\highlight");				write(colorIndex);			}			if ((style.fontStyle & SWT.BOLD) != 0) {				write("\\b"); 			}			if ((style.fontStyle & SWT.ITALIC) != 0) {				write("\\i"); 			}			if (style.underline) {				write("\\ul");			}			if (style.strikeout) {				write("\\strike");			}			write(" "); 			// copy to end of style or end of write range or end of line			copyEnd = Math.min(end, lineEndOffset);			// guard against invalid styles and let style processing continue			copyEnd = Math.max(copyEnd, lineIndex);			write(line, lineIndex, copyEnd);			if ((style.fontStyle & SWT.BOLD) != 0) {				write("\\b0"); 			}			if ((style.fontStyle & SWT.ITALIC) != 0) {				write("\\i0"); 			}			if (style.underline) {				write("\\ul0");			}						if (style.strikeout) {				write("\\strike0");			}			write("}");			lineIndex = copyEnd;		}		// write unstyled text at the end of the line		if (lineIndex < lineEndOffset) {			write(line, lineIndex, lineEndOffset);		}		if (lineBackground != null) {			write("}");		}	}