setSelectedText(selection[i],selectedText);
int tmp = end; end = start; start = tmp; }  int lastNewline = 0; int currNewline = 0;  for(int i = s.startLine; i <= s.endLine; i++) { int lineStart = getLineStartOffset(i); int lineEnd = getLineEndOffset(i) - 1; int rectStart = Math.min(lineEnd,lineStart + start);  buffer.remove(rectStart,Math.min(lineEnd - rectStart, end - start));  if(selectedText == null) continue;  currNewline = selectedText.indexOf('\n',lastNewline); if(currNewline == -1) currNewline = selectedText.length();  buffer.insert(rectStart,selectedText .substring(lastNewline,currNewline));  lastNewline = Math.min(selectedText.length(), currNewline + 1); }  if(selectedText != null && currNewline != selectedText.length()) { int offset = getLineEndOffset(s.endLine) - 1; buffer.insert(offset,"\n"); buffer.insert(offset + 1,selectedText .substring(currNewline + 1));
	public void setSelectedText(String selectedText)	{		if(!isEditable())		{			throw new InternalError("Text component"				+ " read only");		}		Selection[] selection = getSelection();		if(selection.length == 0)		{			// for compatibility with older jEdit versions			buffer.insert(caret,selectedText);		}		else		{			try			{				buffer.beginCompoundEdit();				for(int i = 0; i < selection.length; i++)				{					setSelectedText(selection[i],selectedText);				}			}			finally			{				buffer.endCompoundEdit();			}		}		selectNone();	} //}}}