aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2013-09-11 11:57:28 +0200
committerMattias Andrée <maandree@operamail.com>2013-09-11 11:57:28 +0200
commit8cb593daf31cfddc634ade3b73ca3c9de5f45ded (patch)
tree02c1e5f871e2fddfb34531cdd11148eeb8508236
parentm (diff)
downloadpytagomacs-8cb593daf31cfddc634ade3b73ca3c9de5f45ded.tar.gz
pytagomacs-8cb593daf31cfddc634ade3b73ca3c9de5f45ded.tar.bz2
pytagomacs-8cb593daf31cfddc634ade3b73ca3c9de5f45ded.tar.xz
add key combinations for undo actions
Signed-off-by: Mattias Andrée <maandree@operamail.com>
-rw-r--r--src/editor.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/editor.py b/src/editor.py
index cab4e73..d76e146 100644
--- a/src/editor.py
+++ b/src/editor.py
@@ -35,7 +35,7 @@ limit = lambda x_min, x, x_max : min(max(x_min, x), x_max)
Limit a value to a closed set
'''
-ctrl = lambda key : chr(ord(key) - ord('@'))
+ctrl = lambda key : chr(ord(key) ^ ord('@'))
'''
Return the symbol for a specific letter pressed in combination with Ctrl
'''
@@ -81,7 +81,7 @@ class TextArea():
'''
self.fields, self.datamap, self.left, self.top, self.width, self.height = fields, datamap, left, top, width - 1, height
self.innerleft = len(max(self.fields, key = len)) + 3
- self.killring = Killring()
+ self.killring, self.editring = Killring(), Editring()
data = lambda field : datamap[field] if field in datamap else ''
self.lines = [TextArea.Line(self, self.fields[y], data(self.fields[y]), y) for y in range(len(self.fields))]
self.areawidth = self.width - self.innerleft
@@ -523,6 +523,12 @@ class TextArea():
elif d == ctrl('K'): edit(lambda L : L.kill(), 'At end')
elif d == ctrl('W'): edit(lambda L : L.cut(), 'No text is selected')
elif d == ctrl('Y'): edit(lambda L : L.yank(), 'Killring is empty')
+ elif d == ctrl('R'): self.editring.change_direction()
+ elif d in (ctrl('_'), ctrl('U')):
+ if self.editring.is_empty():
+ self.alert('Nothing to undo')
+ else:
+ pass # TODO undo/redo
elif d == ctrl('X'):
self.alert('C-x')
sys.stdout.flush()