about summary refs log tree commit diff stats
path: root/main.lua
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2022-06-02 23:48:35 -0700
committerKartik K. Agaram <vc@akkartik.com>2022-06-02 23:48:35 -0700
commitdcdcd07902035183bfa3b6d412e56a5f582a7cda (patch)
tree86c4b3233604c77083900c3236b9e41b75517e06 /main.lua
parent1fc4214029c166adeb8a478e814dd77043576f46 (diff)
downloadtext.love-dcdcd07902035183bfa3b6d412e56a5f582a7cda.tar.gz
switch undo/redo to ctrl- hotkeys
Diffstat (limited to 'main.lua')
-rw-r--r--main.lua18
1 files changed, 18 insertions, 0 deletions
diff --git a/main.lua b/main.lua
index 2892baf..589de0a 100644
--- a/main.lua
+++ b/main.lua
@@ -276,6 +276,24 @@ function App.keychord_pressed(chord)
     love.graphics.setFont(love.graphics.newFont(Font_height))
     Text.redraw_all()
     Line_height = 26
+  elseif chord == 'C-z' then
+    local event = undo_event()
+    if event then
+      local src = event.before
+      Screen_top1 = deepcopy(src.screen_top)
+      Cursor1 = deepcopy(src.cursor)
+      Selection1 = deepcopy(src.selection)
+      patch(Lines, event.after, event.before)
+    end
+  elseif chord == 'C-y' then
+    local event = redo_event()
+    if event then
+      local src = event.after
+      Screen_top1 = deepcopy(src.screen_top)
+      Cursor1 = deepcopy(src.cursor)
+      Selection1 = deepcopy(src.selection)
+      patch(Lines, event.before, event.after)
+    end
   elseif love.mouse.isDown('1') or chord:sub(1,2) == 'C-' then
     Drawing.keychord_pressed(chord)
   elseif chord == 'escape' and love.mouse.isDown('1') then