about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-08-06 16:40:32 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-08-06 16:49:29 -0700
commit1132c9878e893e6dc356171dbf7826bfa47b4a38 (patch)
tree6961986e237c832005132356c75382cf6912303a
parent176d9003c8e53074ce9147855afd71d960e68a27 (diff)
downloadmu-1132c9878e893e6dc356171dbf7826bfa47b4a38.tar.gz
1944
Amazing, now I can change behavior simply by adding a label rather than
any code.
-rw-r--r--edit.mu42
1 files changed, 38 insertions, 4 deletions
diff --git a/edit.mu b/edit.mu
index 30929d92..9a30f8b2 100644
--- a/edit.mu
+++ b/edit.mu
@@ -951,10 +951,13 @@ after +insert-character-special-case [
     break-unless at-wrap?
     *cursor-column <- subtract *cursor-column, wrap-column
     *cursor-row <- add *cursor-row, 1
-    # todo: what happens when cursor is too far down?
-    screen-height:number <- screen-height screen
-    above-screen-bottom?:boolean <- lesser-than *cursor-row, screen-height
-    assert above-screen-bottom?, [unimplemented: typing past bottom of screen]
+    # if we're out of the screen, scroll down
+    {
+      screen-height:number <- screen-height screen
+      below-screen?:boolean <- greater-or-equal *cursor-row, screen-height
+      break-unless below-screen?
+      +scroll-down
+    }
     reply
   }
 ]
@@ -2931,6 +2934,37 @@ m]
   ]
 ]
 
+scenario editor-scrolls-down-when-line-wraps [
+  # screen has 1 line for menu + 3 lines
+  assume-screen 5/width, 4/height
+  # editor contains a long line in the third line
+  1:address:array:character <- new [a
+b
+cdef]
+  2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0/left, 5/right
+  # position cursor at end, type a character
+  assume-console [
+    left-click 3, 4
+    type [g]
+  ]
+  run [
+    editor-event-loop screen:address, console:address, 2:address:editor-data
+    3:number <- get *2:address:editor-data, cursor-row:offset
+    4:number <- get *2:address:editor-data, cursor-column:offset
+  ]
+  # screen scrolls
+  screen-should-contain [
+    .     .
+    .b    .
+    .cdef↩.
+    .g    .
+  ]
+  memory-should-contain [
+    3 <- 3
+    4 <- 1
+  ]
+]
+
 # cursor-up can scroll if necessary
 
 scenario editor-can-scroll-up-using-arrow-keys [