Insert chars before the character at index.
(self, index, chars)
| 184 | return n, len(self.data[n]) + endflag |
| 185 | |
| 186 | def insert(self, index, chars): |
| 187 | "Insert chars before the character at index." |
| 188 | |
| 189 | if not chars: # ''.splitlines() is [], not [''] |
| 190 | return |
| 191 | chars = chars.splitlines(True) |
| 192 | if chars[-1][-1] == '\n': |
| 193 | chars.append('') |
| 194 | line, char = self._decode(index, -1) |
| 195 | before = self.data[line][:char] |
| 196 | after = self.data[line][char:] |
| 197 | self.data[line] = before + chars[0] |
| 198 | self.data[line+1:line+1] = chars[1:] |
| 199 | self.data[line+len(chars)-1] += after |
| 200 | |
| 201 | def get(self, index1, index2=None): |
| 202 | "Return slice from index1 to index2 (default is 'index1+1')." |