Point selection = styledText.internalGetSelection();
Point selection = styledText.getSelection();
int drawLine(String line, int lineIndex, int paintX, int paintY, GC gc, Color widgetBackground, Color widgetForeground, boolean clearBackground) {	if (styledText == null) return 0;	StyledTextContent content = getContent();	int lineOffset = content.getOffsetAtLine(lineIndex);	int lineLength = line.length();	Point selection = styledText.internalGetSelection();	int selectionStart = selection.x;	int selectionEnd = selection.y;	TextLayout layout = getTextLayout(line, lineOffset);	Rectangle client = styledText.getClientArea();  	StyledTextEvent event = styledText.getLineBackgroundData(lineOffset, line);	Color lineBackground = null;	if (event != null) {		lineBackground = event.lineBackground;	}	if (lineBackground == null) {		lineBackground = widgetBackground;	}	boolean fullSelection = (styledText.getStyle() & SWT.FULL_SELECTION) != 0;	if (clearBackground &&		(!fullSelection || 		 selectionStart > lineOffset || 		 selectionEnd <= lineOffset + lineLength)) {		// draw background if full selection is off or if line is not 		// completely selected		gc.setBackground(lineBackground);		gc.fillRectangle(client.x, paintY, client.width, layout.getBounds().height);	}	if (selectionStart != selectionEnd) {		int y = paintY;		int[] offsets = layout.getLineOffsets();		int lineCount = layout.getLineCount();		gc.setBackground(styledText.getSelectionBackground());		for (int i = 0; i < lineCount; i++) {			int lineStart = offsets[i];			int lineEnd = Math.max(0, offsets[i + 1] - 1);			if (lineStart >= selectionEnd - lineOffset) break;			Rectangle lineBounds = layout.getLineBounds(i);			if (selectionStart - lineOffset <= lineEnd && lineEnd < selectionEnd - lineOffset - 1) {				int x = paintX + lineBounds.x + lineBounds.width;				if (fullSelection) {					gc.fillRectangle(x, y, client.width - x, lineBounds.height);				} else {					if (i == lineCount - 1) {						gc.fillRectangle(x, y, lineEndSpaceWidth, lineBounds.height);					}				}			}			y += lineBounds.height;		}	}	gc.setForeground(widgetForeground);	gc.setBackground(lineBackground);		if (selectionStart == selectionEnd || (selectionEnd <= lineOffset && selectionStart > lineOffset + lineLength - 1)) {		layout.draw(gc, paintX, paintY);	} else {		int start = Math.max(0, selectionStart - lineOffset);		int end = Math.min(lineLength, selectionEnd - lineOffset);		Color selectionFk = styledText.getSelectionForeground();		Color selectionBk = styledText.getSelectionBackground();		layout.draw(gc, paintX, paintY, start, end - 1, selectionFk, selectionBk);	}	int height = layout.getBounds().height;	disposeTextLayout(layout);	return height;}