/** * Inserts the specified string into the source at the current location * * @param str the string to insert. */ public void insert(String str) { LineInfo line = lines.get(lineno - 1); int originalColno = colno; if (line.edits == null) { line.edits = new ArrayList<Integer>(); } Iterator<Integer> iter = line.edits.iterator(); // Adjust colno to account for prior insertions while (iter.hasNext()) { int offset = iter.next(); int count = iter.next(); if (offset <= colno) { colno += count; } else { break; } } // insert the string at position colno line.str = line.str.substring(0, colno) + str + line.str.substring(colno); line.edits.add(originalColno); line.edits.add(str.length()); modified = true; }