gc.fillRectangle(client.x, paintY, client.width, layout.getBounds().height);
styledText.drawBackground(gc, client.x, paintY, client.width, layout.getBounds().height);
int drawLine(int lineIndex, int paintX, int paintY, GC gc, Color widgetBackground, Color widgetForeground) {	TextLayout layout = getTextLayout(lineIndex);	String line = content.getLine(lineIndex);	int lineOffset = content.getOffsetAtLine(lineIndex);	int lineLength = line.length();	Point selection = styledText.getSelection();	int selectionStart = selection.x;	int selectionEnd = selection.y;	Rectangle client = styledText.getClientArea();  	Color lineBackground = getLineBackground(lineIndex, widgetBackground);	StyledTextEvent event = styledText.getLineBackgroundData(lineOffset, line);	if (event != null && event.lineBackground != null) lineBackground = event.lineBackground;		boolean fullSelection = (styledText.getStyle() & SWT.FULL_SELECTION) != 0;	if (!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;		gc.setBackground(styledText.getSelectionBackground());		int lineCount = layout.getLineCount();		if (fullSelection) {			int[] offsets = layout.getLineOffsets();			for (int i = 0; i < lineCount - 1; i++) {				int lineStart = offsets[i];				if (lineStart >= selectionEnd - lineOffset) break;				int lineEnd = offsets[i + 1];				Rectangle lineBounds = layout.getLineBounds(i);				if (selectionStart - lineOffset <= lineEnd && lineEnd <= selectionEnd - lineOffset) {					int x = paintX + lineBounds.x + lineBounds.width;					gc.fillRectangle(x, y, client.width - x, lineBounds.height);				}				y += lineBounds.height + layout.getSpacing();			}		}		if (selectionStart - lineOffset <= lineLength && lineLength < selectionEnd - lineOffset) {			Rectangle lineBounds = layout.getLineBounds(lineCount - 1);			int x = paintX + lineBounds.x + lineBounds.width;			if (fullSelection) {				gc.fillRectangle(x, paintY + lineBounds.y, client.width - styledText.rightMargin - x, lineBounds.height);			} else {				gc.fillRectangle(x, paintY + lineBounds.y, lineEndSpaceWidth, 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 selectionFg = styledText.getSelectionForeground();		Color selectionBg = styledText.getSelectionBackground();		layout.draw(gc, paintX, paintY, start, end - 1, selectionFg, selectionBg);	}	// draw objects	Bullet bullet = null;	int bulletIndex = -1;	if (bullets != null) {		if (bulletsIndices != null) {			int index = lineIndex - topIndex;			if (0 <= index && index < CACHE_SIZE) {				bullet = bullets[index];				bulletIndex = bulletsIndices[index];			}		} else {			for (int i = 0; i < bullets.length; i++) {				bullet = bullets[i];				bulletIndex = bullet.indexOf(lineIndex);				if (bulletIndex != -1) break;			}		}	}	if (bulletIndex != -1 && bullet != null) {		FontMetrics metrics = layout.getLineMetrics(0);		int lineAscent = metrics.getAscent() + metrics.getLeading();		if (bullet.type == ST.BULLET_CUSTOM) {			bullet.style.start = lineOffset;			styledText.paintObject(gc, paintX, paintY, lineAscent, metrics.getDescent(), bullet.style, bullet, bulletIndex);		} else {			drawBullet(bullet, gc, paintX, paintY, bulletIndex, lineAscent, metrics.getDescent());		}	}		TextStyle[] styles = layout.getStyles();	int[] ranges = null;	for (int i = 0; i < styles.length; i++) {		if (styles[i].metrics != null) {			if (ranges == null) ranges = layout.getRanges();			int start = ranges[i << 1];			int length = ranges[(i << 1) + 1] - start;			Point point = layout.getLocation(start, false);			FontMetrics metrics = layout.getLineMetrics(layout.getLineIndex(start));			StyleRange style = (StyleRange)((StyleRange)styles[i]).clone();			style.start = start + lineOffset;			style.length = length;			int lineAscent = metrics.getAscent() + metrics.getLeading();			styledText.paintObject(gc, point.x + paintX, point.y + paintY, lineAscent, metrics.getDescent(), style, null, 0);		}	}	int height = layout.getBounds().height;	disposeTextLayout(layout);	return height;}