int line = getCaretLine(); int lineStart = getLineStartOffset(line); int offset = Math.max(0,Math.min(getLineLength(line) - 1, getCaretPosition() - lineStart)); scrollTo(line,offset); painter.repaint();  fireCaretEvent();
if(!scrollToCaret()) painter.repaint();
	public void select(int start, int end)	{		int newStart, newEnd;		boolean newBias;		if(start <= end)		{			newStart = start;			newEnd = end;			newBias = false;		}		else		{			newStart = end;			newEnd = start;			newBias = true;		}		if(newStart < 0 || newEnd > getDocumentLength())		{			throw new IllegalArgumentException("Bounds out of"				+ " range: " + newStart + "," +				newEnd);		}		if(newStart == selectionStart && newEnd == selectionEnd			&& newBias == biasLeft)			return;		int newStartLine = getLineOfOffset(newStart);		int newEndLine = getLineOfOffset(newEnd);		if(painter.isBracketHighlightEnabled())		{			if(bracketLine != -1)				painter._invalidateLine(bracketLine);			updateBracketHighlight(end);			if(bracketLine != -1)				painter._invalidateLine(bracketLine);		}		painter._invalidateLineRange(selectionStartLine,selectionEndLine);		painter._invalidateLineRange(newStartLine,newEndLine);		selectionStart = newStart;		selectionEnd = newEnd;		selectionStartLine = newStartLine;		selectionEndLine = newEndLine;		biasLeft = newBias;		// When the user is typing, etc, we don't want the caret		// to blink		blink = true;		caretTimer.restart();		// Clear the `magic' caret position used by up/down		magicCaret = -1;		int line = getCaretLine();		int lineStart = getLineStartOffset(line);		int offset = Math.max(0,Math.min(getLineLength(line) - 1,			getCaretPosition() - lineStart));		scrollTo(line,offset);		painter.repaint();		fireCaretEvent();	}