for (int i = 0; i < text.length(); i++)
for (int i = 0; i < text.length(); i++) {
void insert(int position, String text) {		if (text.length() == 0) return;					int startLine = getLineAtOffset(position);	int change = text.length();	boolean endInsert = position == getCharCount();	adjustGap(position, change, startLine);	// during an insert the gap will be adjusted to start at	// position and it will be associated with startline, the	// inserted text will be placed in the gap			int startLineOffset = getOffsetAtLine(startLine);	// at this point, startLineLength will include the start line	// and all of the newly inserted text	int	startLineLength = getPhysicalLine(startLine).length();		if (change > 0) {		// shrink gap 		gapStart += (change);		for (int i = 0; i < text.length(); i++)			textStore[position + i]= text.charAt(i);	}			// figure out the number of new lines that have been inserted	int [][] newLines = indexLines(startLineOffset, startLineLength, 10);	// only insert an empty line if it is the last line in the text	int numNewLines = newLines.length - 1;	if (newLines[numNewLines][1] == 0) {		// last inserted line is a new line		if (endInsert) {			// insert happening at end of the text, leave numNewLines as			// is since the last new line will not be concatenated with another			// line 			numNewLines += 1;		} else {			numNewLines -= 1;		}	}		// make room for the new lines	expandLinesBy(numNewLines);	// shift down the lines after the replace line	for (int i = lineCount-1; i > startLine; i--) {		lines[i + numNewLines]=lines[i];	}	// insert the new lines	for (int i=0; i<numNewLines; i++) {		newLines[i][0] += startLineOffset;		lines[startLine + i]=newLines[i];	}	// update the last inserted line	if (numNewLines < newLines.length) {		newLines[numNewLines][0] += startLineOffset;		lines[startLine + numNewLines] = newLines[numNewLines];	}		lineCount += numNewLines;	gapLine = getLineAtPhysicalOffset(gapStart);		}