--- /usr/lib/python2.3/curses/textpad.py 2004-06-07 21:52:02.000000000 +0200 +++ textpad.py 2004-10-17 21:57:23.660657440 +0200 @@ -58,19 +58,29 @@ last = last - 1 return last + def _insert_printable_char(self, ch): + (y, x) = self.win.getyx() + if y < self.maxy or x < self.maxx: + oldch = self.win.inch() + # The try-catch ignores the error we trigger from some curses + # versions by trying to write into the lowest-rightmost spot + # in the window. + try: + self.win.addch(ch) + except curses.error: + return + (backy, backx) = self.win.getyx() + if ascii.isprint(oldch): + self._insert_printable_char(oldch) + self.win.move(backy, backx) + def do_command(self, ch): "Process a single editing command." (y, x) = self.win.getyx() self.lastcmd = ch if ascii.isprint(ch): if y < self.maxy or x < self.maxx: - # The try-catch ignores the error we trigger from some curses - # versions by trying to write into the lowest-rightmost spot - # in the window. - try: - self.win.addch(ch) - except curses.error: - pass + self._insert_printable_char(ch) elif ch == ascii.SOH: # ^a self.win.move(y, 0) elif ch in (ascii.STX,curses.KEY_LEFT, ascii.BS,curses.KEY_BACKSPACE):