From d3cc25b4d64d81e31be228fa2fc1347b63f4729c Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Mon, 3 Aug 2015 00:47:35 -0700 Subject: 1924 - handle delete key in editor --- edit.mu | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) 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] -- cgit 1.4.1-2-gfad0