def prompt_undo(self): """Returns how many lines to undo, 0 means don't undo""" if (self.config.single_undo_time < 0 or self.interp.timer.estimate() < self.config.single_undo_time): return 1 est = self.interp.timer.estimate() n = self.interact.file_prompt( _("Undo how many lines? (Undo will take up to ~%.1f seconds) [1]") % (est,)) try: if n == '': n = '1' n = int(n) except ValueError: self.interact.notify(_('Undo canceled'), .1) return 0 else: if n == 0: self.interact.notify(_('Undo canceled'), .1) return 0 else: message = ngettext('Undoing %d line... (est. %.1f seconds)', 'Undoing %d lines... (est. %.1f seconds)', n) self.interact.notify(message % (n, est), .1) return n