editor: Ring bell when trying to move cursor out of bounds.
- At the start or end of file.
This commit is contained in:
parent
8b24095d63
commit
ac340dd0ca
1 changed files with 4 additions and 5 deletions
|
|
@ -541,10 +541,7 @@ class Editor:
|
||||||
print("\a", end="")
|
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
|
||||||
|
|
@ -578,8 +575,10 @@ class Editor:
|
||||||
if term_code != terminal.CTRL_UNDERSCORE:
|
if term_code != terminal.CTRL_UNDERSCORE:
|
||||||
self.add_to_history()
|
self.add_to_history()
|
||||||
if term_code in Editor.KEY_MAP:
|
if term_code in Editor.KEY_MAP:
|
||||||
with contextlib.suppress(IndexError):
|
try:
|
||||||
Editor.KEY_MAP[term_code](self)
|
Editor.KEY_MAP[term_code](self)
|
||||||
|
except IndexError:
|
||||||
|
self.ring_bell()
|
||||||
elif term_code in self._PRINTABLE:
|
elif term_code in self._PRINTABLE:
|
||||||
self.insert_text(term_code)
|
self.insert_text(term_code)
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue