about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-08-03 00:47:35 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-08-03 00:47:35 -0700
commitd3cc25b4d64d81e31be228fa2fc1347b63f4729c (patch)
treebe78c81d50c563a06462fbc68f72697abd8b5773
parentcfb142b9601cc648f15bf5738a3df09a23835e41 (diff)
downloadmu-d3cc25b4d64d81e31be228fa2fc1347b63f4729c.tar.gz
1924 - handle delete key in editor
-rw-r--r--edit.mu36
1 files changed, 36 insertions, 0 deletions
diff --git a/edit.mu b/edit.mu
index 381e47e1..40819a62 100644
--- a/edit.mu
+++ b/edit.mu
@@ -731,6 +731,14 @@ recipe handle-event [
     move-to-end-of-line editor
     reply
   }
+  # delete
+  {
+    delete?:boolean <- equal *k, 65522/delete
+    break-unless delete?
+    curr:address:duplex-list <- get **before-cursor, next:offset
+    _ <- remove-duplex curr
+    reply
+  }
 ]
 
 # process click, return if it was on current editor
@@ -1443,6 +1451,34 @@ ef]
   ]
 ]
 
+scenario editor-handles-delete-key [
+  assume-screen 10/width, 5/height
+  1:address:array:character <- new [abc]
+  2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0/left, 10/right
+  assume-console [
+    press 65522  # delete
+  ]
+  run [
+    editor-event-loop screen:address, console:address, 2:address:editor-data
+  ]
+  screen-should-contain [
+    .          .
+    .bc        .
+    .          .
+  ]
+  assume-console [
+    press 65522  # delete
+  ]
+  run [
+    editor-event-loop screen:address, console:address, 2:address:editor-data
+  ]
+  screen-should-contain [
+    .          .
+    .c         .
+    .          .
+  ]
+]
+
 scenario editor-handles-backspace-key [
   assume-screen 10/width, 5/height
   1:address:array:character <- new [abc]