view.synchroScrollVertical(this,firstLine); view.synchroScrollHorizontal(this,horizontalOffset);
	public void scrollToCaret(boolean doElectricScroll)	{		int caretLine = getCaretLine();		int offset = getCaretPosition() - getLineStartOffset(caretLine);		// visibleLines == 0 before the component is realized		// we can't do any proper scrolling then, so we have		// this hack...		if(visibleLines == 0)		{			setFirstLine(Math.max(0,caretLine - electricScroll));			return;		}		int electricScroll = (doElectricScroll ? this.electricScroll : 0);		boolean changed = false;		int _firstLine = firstLine + electricScroll;		int _lastLine = firstLine + visibleLines - electricScroll;		if(caretLine > _firstLine && caretLine < _lastLine)		{			// vertical scroll position is correct already		}		else if(_firstLine - caretLine > visibleLines || caretLine - _lastLine > visibleLines)		{			int markLine = getMarkLine();			// center {markLine,caretLine} on screen			firstLine = markLine - (visibleLines				- caretLine + markLine) / 2;			firstLine = Math.max(caretLine - visibleLines + electricScroll,firstLine);			firstLine = Math.min(caretLine /* + visibleLines */ - electricScroll,firstLine);			changed = true;		}		else if(caretLine < _firstLine)		{			firstLine = Math.max(0,caretLine - electricScroll);			changed = true;		}		else if(caretLine >= _lastLine)		{			firstLine = (caretLine - visibleLines) + electricScroll + 1;			if(_firstLine >= getLineCount() - visibleLines)				firstLine = getLineCount() - visibleLines;			if(firstLine < 0)				firstLine = 0;			changed = true;		}		int x = offsetToX(caretLine,offset);		int width = painter.getFontMetrics().charWidth('w');		if(x < 0)		{			horizontalOffset = Math.min(0,horizontalOffset				- x + width + 5);			changed = true;		}		else if(x >= painter.getWidth() - width - 5)		{			horizontalOffset = horizontalOffset +				(painter.getWidth() - x) - width - 5;			changed = true;		}		if(changed)		{			updateScrollBars();			painter.repaint();			if(!gutter.isCollapsed())				gutter.repaint();		}	}