about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-08-06 18:12:57 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-08-06 18:12:57 -0700
commit9a61eb40b6e35e2ca2bdbd8200f0b458fe4fc600 (patch)
tree83f5b2d29f1ca22e29c88e27f91f26df24074527
parentf7834cb11d03e1c66fb67f1641e565af789ca9f9 (diff)
downloadmu-9a61eb40b6e35e2ca2bdbd8200f0b458fe4fc600.tar.gz
1947 - done with situations needing scroll-up
-rw-r--r--edit.mu56
1 files changed, 54 insertions, 2 deletions
diff --git a/edit.mu b/edit.mu
index f74aeff4..e79b8e0b 100644
--- a/edit.mu
+++ b/edit.mu
@@ -1271,8 +1271,15 @@ recipe move-cursor-coordinates-left [
     reply editor/same-as-ingredient:0
   }
   # if at left margin, we must move to previous row:
-  assert *cursor-row, [unimplemented: moving cursor above top of screen]
-  *cursor-row <- subtract *cursor-row, 1
+  top-of-screen?:boolean <- equal *cursor-row, 1  # exclude menu bar
+  {
+    break-if top-of-screen?
+    *cursor-row <- subtract *cursor-row, 1
+  }
+  {
+    break-unless top-of-screen?
+    +scroll-up
+  }
   {
     # case 1: if previous character was newline, figure out how long the previous line is
     previous-character:character <- get *before-cursor, value:offset
@@ -3260,6 +3267,51 @@ m]
   ]
 ]
 
+scenario editor-scrolls-up-on-left-arrow [
+  # screen has 1 line for menu + 3 lines
+  assume-screen 5/width, 4/height
+  # editor contains >3 lines
+  1:address:array:character <- new [a
+b
+c
+d
+e]
+  2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0/left, 5/right
+  # position cursor at top of second page
+  assume-console [
+    press 65518  # page-down
+  ]
+  run [
+    editor-event-loop screen:address, console:address, 2:address:editor-data
+  ]
+  screen-should-contain [
+    .     .
+    .c    .
+    .d    .
+    .e    .
+  ]
+  # now try to move left
+  assume-console [
+    press 65515  # left arrow
+  ]
+  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    .
+    .c    .
+    .d    .
+  ]
+  memory-should-contain [
+    3 <- 1
+    4 <- 1
+  ]
+]
+
 ## putting the environment together out of editors
 
 container programming-environment-data [