| 68 | return last |
| 69 | |
| 70 | def _insert_printable_char(self, ch): |
| 71 | self._update_max_yx() |
| 72 | (y, x) = self.win.getyx() |
| 73 | backyx = None |
| 74 | while y < self.maxy or x < self.maxx: |
| 75 | if self.insert_mode: |
| 76 | oldch = self.win.inch() |
| 77 | # The try-catch ignores the error we trigger from some curses |
| 78 | # versions by trying to write into the lowest-rightmost spot |
| 79 | # in the window. |
| 80 | try: |
| 81 | self.win.addch(ch) |
| 82 | except curses.error: |
| 83 | pass |
| 84 | if not self.insert_mode or not curses.ascii.isprint(oldch): |
| 85 | break |
| 86 | ch = oldch |
| 87 | (y, x) = self.win.getyx() |
| 88 | # Remember where to put the cursor back since we are in insert_mode |
| 89 | if backyx is None: |
| 90 | backyx = y, x |
| 91 | |
| 92 | if backyx is not None: |
| 93 | self.win.move(*backyx) |
| 94 | |
| 95 | def do_command(self, ch): |
| 96 | "Process a single editing command." |