| 248 | del self.data[startline] |
| 249 | |
| 250 | def compare(self, index1, op, index2): |
| 251 | line1, char1 = self._decode(index1) |
| 252 | line2, char2 = self._decode(index2) |
| 253 | if op == '<': |
| 254 | return line1 < line2 or line1 == line2 and char1 < char2 |
| 255 | elif op == '<=': |
| 256 | return line1 < line2 or line1 == line2 and char1 <= char2 |
| 257 | elif op == '>': |
| 258 | return line1 > line2 or line1 == line2 and char1 > char2 |
| 259 | elif op == '>=': |
| 260 | return line1 > line2 or line1 == line2 and char1 >= char2 |
| 261 | elif op == '==': |
| 262 | return line1 == line2 and char1 == char2 |
| 263 | elif op == '!=': |
| 264 | return line1 != line2 or char1 != char2 |
| 265 | else: |
| 266 | raise TclError('''bad comparison operator "%s": ''' |
| 267 | '''must be <, <=, ==, >=, >, or !=''' % op) |
| 268 | |
| 269 | # The following Text methods normally do something and return None. |
| 270 | # Whether doing nothing is sufficient for a test will depend on the test. |