about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-09-01 09:53:26 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-09-01 09:53:26 -0700
commit2e69df9fe5e59c6336e5bc9af07f14d00f36a899 (patch)
tree3602e20251c9b190e250946d213bff69f6db5709
parent0883318f8d45979b30e726bf236f460c2db88b8a (diff)
downloadmu-2e69df9fe5e59c6336e5bc9af07f14d00f36a899.tar.gz
2120
-rw-r--r--edit.mu66
1 files changed, 40 insertions, 26 deletions
diff --git a/edit.mu b/edit.mu
index 6ee6e705..280aff84 100644
--- a/edit.mu
+++ b/edit.mu
@@ -1764,34 +1764,48 @@ after +handle-special-key [
   {
     delete-next-character?:boolean <- equal *k, 65522/delete
     break-unless delete-next-character?
-    curr:address:duplex-list <- next-duplex *before-cursor
-    reply-unless curr, editor/same-as-ingredient:0, screen/same-as-ingredient:1, 0/no-more-render
+    +delete-character-begin
+    editor, screen, go-render?:boolean <- delete-at-cursor editor, screen
+    +delete-character-end
+    reply screen/same-as-ingredient:0, editor/same-as-ingredient:1, go-render?
+  }
+]
+
+recipe delete-at-cursor [
+  local-scope
+  editor:address:editor-data <- next-ingredient
+  screen:address <- next-ingredient
+  before-cursor:address:address:duplex-list <- get-address *editor, before-cursor:offset
+  curr:address:duplex-list <- next-duplex *before-cursor
+  reply-unless curr, editor/same-as-ingredient:0, screen/same-as-ingredient:1, 0/no-more-render
+  currc:character <- get *curr, value:offset
+  remove-duplex curr
+  deleted-newline?:boolean <- equal currc, 10/newline
+  reply-if deleted-newline?, screen/same-as-ingredient:0, editor/same-as-ingredient:1, 1/go-render
+  # wasn't a newline? render rest of line
+  curr:address:duplex-list <- next-duplex *before-cursor  # refresh after remove-duplex above
+  cursor-row:address:number <- get-address *editor, cursor-row:offset
+  cursor-column:address:number <- get-address *editor, cursor-column:offset
+  screen <- move-cursor screen, *cursor-row, *cursor-column
+  curr-column:number <- copy *cursor-column
+  screen-width:number <- screen-width screen
+  {
+    # hit right margin? give up and let caller render
+    at-right?:boolean <- greater-or-equal curr-column, screen-width
+    reply-if at-right?, screen/same-as-ingredient:0, editor/same-as-ingredient:1, 1/go-render
+    break-unless curr
+    # newline? done.
     currc:character <- get *curr, value:offset
-    remove-duplex curr
-    deleted-newline?:boolean <- equal currc, 10/newline
-    reply-if deleted-newline?, screen/same-as-ingredient:0, editor/same-as-ingredient:1, 1/go-render
-    # wasn't a newline? render rest of line
-    curr:address:duplex-list <- next-duplex *before-cursor  # refresh after remove-duplex above
-    screen <- move-cursor screen, *cursor-row, *cursor-column
-    curr-column:number <- copy *cursor-column
-    {
-      # hit right margin? give up and let caller render
-      at-right?:boolean <- greater-or-equal curr-column, screen-width
-      reply-if at-right?, editor/same-as-ingredient:0, screen/same-as-ingredient:1, 1/go-render
-      break-unless curr
-      # newline? done.
-      currc:character <- get *curr, value:offset
-      at-newline?:boolean <- equal currc, 10/newline
-      break-if at-newline?
-      screen <- print-character screen, currc
-      curr-column <- add curr-column, 1
-      curr <- next-duplex curr
-      loop
-    }
-    # we're guaranteed not to be at the right margin
-    screen <- print-character screen, 32/space
-    reply screen/same-as-ingredient:0, editor/same-as-ingredient:1, 0/no-more-render
+    at-newline?:boolean <- equal currc, 10/newline
+    break-if at-newline?
+    screen <- print-character screen, currc
+    curr-column <- add curr-column, 1
+    curr <- next-duplex curr
+    loop
   }
+  # we're guaranteed not to be at the right margin
+  screen <- print-character screen, 32/space
+  reply screen/same-as-ingredient:0, editor/same-as-ingredient:1, 0/no-more-render
 ]
 
 # right arrow