editor: Add the abort command
- For now it only unsets the current selection.
This commit is contained in:
parent
3c1e34ca5e
commit
0497a8f7a9
2 changed files with 10 additions and 1 deletions
|
|
@ -540,6 +540,9 @@ class Editor:
|
|||
def undo(self):
|
||||
self.text_widget[:], self._cursor_x, self._cursor_y = self.history.pop()
|
||||
|
||||
def abort_command(self):
|
||||
self.mark = None
|
||||
|
||||
def get_text(self):
|
||||
return self.text_widget.get_text()
|
||||
|
||||
|
|
@ -644,7 +647,7 @@ class Editor:
|
|||
terminal.CTRL_L: center_cursor, terminal.ALT_SEMICOLON: comment_lines,
|
||||
terminal.ALT_c: cycle_syntax_highlighting, terminal.CTRL_X: prefix, terminal.ESC: quit,
|
||||
terminal.CTRL_C: ctrl_c, terminal.CTRL_K: delete_line, terminal.TAB: tab_align,
|
||||
terminal.CTRL_UNDERSCORE: undo}
|
||||
terminal.CTRL_UNDERSCORE: undo, terminal.CTRL_G: abort_command}
|
||||
|
||||
|
||||
def main():
|
||||
|
|
|
|||
|
|
@ -224,6 +224,12 @@ class EditorTestCase(unittest.TestCase):
|
|||
self._assert_change(self.editor.undo, "a\nb", (0, 1))
|
||||
self._assert_change(self.editor.undo, "ab", (1, 0))
|
||||
|
||||
def test_abort_command(self):
|
||||
self._set_editor("", (0, 0))
|
||||
self.editor.set_mark()
|
||||
self.editor.abort_command()
|
||||
self.assertEqual(self.editor.mark, None)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue