editor: Use bell sound.

- Ring bell when no more changes to undo, or when aborting command.
This commit is contained in:
Andrew Hamilton 2022-01-13 14:09:55 +10:00
parent 1a71188944
commit 8b24095d63

View file

@ -537,11 +537,18 @@ class Editor:
if self.previous_term_code == terminal.CTRL_X: if self.previous_term_code == terminal.CTRL_X:
self.quit() self.quit()
def ring_bell(self):
print("\a", end="")
def undo(self): def undo(self):
try:
self.text_widget[:], self._cursor_x, self._cursor_y = self.history.pop() self.text_widget[:], self._cursor_x, self._cursor_y = self.history.pop()
except IndexError:
self.ring_bell()
def abort_command(self): def abort_command(self):
self.mark = None self.mark = None
self.ring_bell()
def get_text(self): def get_text(self):
return self.text_widget.get_text() return self.text_widget.get_text()