about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--edit/003-shortcuts.mu85
-rw-r--r--edit/005-sandbox.mu54
-rw-r--r--edit/011-errors.mu10
-rw-r--r--sandbox/003-shortcuts.mu47
4 files changed, 65 insertions, 131 deletions
diff --git a/edit/003-shortcuts.mu b/edit/003-shortcuts.mu
index 7089a26b..ae9609a7 100644
--- a/edit/003-shortcuts.mu
+++ b/edit/003-shortcuts.mu
@@ -1360,9 +1360,31 @@ def move-to-next-line editor:&:editor, screen-height:num -> go-render?:bool, edi
   left:num <- get *editor, left:offset
   right:num <- get *editor, right:offset
   last-line:num <- subtract screen-height, 1
-  break-unless before-cursor, +try-to-scroll
+  bottom:num <- get *editor, bottom:offset
+  at-bottom-of-screen?:bool <- greater-or-equal bottom, last-line
+  {
+    break-if before-cursor
+    {
+      break-if at-bottom-of-screen?
+      return 0/don't-render
+    }
+    {
+      break-unless at-bottom-of-screen?
+      jump +try-to-scroll
+    }
+  }
   next:&:duplex-list:char <- next before-cursor
-  break-unless next, +try-to-scroll
+  {
+    break-if next
+    {
+      break-if at-bottom-of-screen?
+      return 0/don't-render
+    }
+    {
+      break-unless at-bottom-of-screen?
+      jump +try-to-scroll
+    }
+  }
   already-at-bottom?:bool <- greater-or-equal cursor-row, last-line
   {
     # if cursor not at bottom, move it
@@ -1381,7 +1403,17 @@ def move-to-next-line editor:&:editor, screen-height:num -> go-render?:bool, edi
       break-if at-newline?
       loop
     }
-    break-unless next  # at bottom of editor; scroll
+    {
+      break-if next
+      {
+        break-if at-bottom-of-screen?
+        return 0/don't-render
+      }
+      {
+        break-unless at-bottom-of-screen?
+        jump +try-to-scroll
+      }
+    }
     cursor-row <- add cursor-row, 1
     cursor-column <- copy left
     {
@@ -3012,51 +3044,10 @@ de]
     3:num/raw <- get *e, cursor-row:offset
     4:num/raw <- get *e, cursor-column:offset
   ]
-  # screen should scroll, moving cursor to end of text
+  # no change
   memory-should-contain [
-    3 <- 1
-    4 <- 2
-  ]
-  assume-console [
-    type [0]
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .de0       .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
-  ]
-  # try to move down again
-  $clear-trace
-  assume-console [
-    left-click 2, 0
-    press down-arrow
-  ]
-  run [
-    editor-event-loop screen, console, e
-    3:num/raw <- get *e, cursor-row:offset
-    4:num/raw <- get *e, cursor-column:offset
-  ]
-  # screen stops scrolling because cursor is already at top
-  memory-should-contain [
-    3 <- 1
-    4 <- 3
-  ]
-  check-trace-count-for-label 0, [print-character]
-  assume-console [
-    type [1]
-  ]
-  run [
-    editor-event-loop screen, console, e
-  ]
-  screen-should-contain [
-    .          .
-    .de01      .
-    .┈┈┈┈┈┈┈┈┈┈.
-    .          .
+    3 <- 2
+    4 <- 0
   ]
 ]
 
diff --git a/edit/005-sandbox.mu b/edit/005-sandbox.mu
index e154b69c..d8058d18 100644
--- a/edit/005-sandbox.mu
+++ b/edit/005-sandbox.mu
@@ -754,60 +754,6 @@ scenario cursor-down-in-recipe-editor [
   ]
 ]
 
-# we'll not use the recipe-editor's 'bottom' element directly, because later
-# layers will add other stuff to the left side below the editor (error messages)
-
-container environment [
-  recipe-bottom:num
-]
-
-after <render-recipe-components-end> [
-  *env <- put *env, recipe-bottom:offset, row
-]
-
-after <global-keypress> [
-  {
-    break-if sandbox-in-focus?
-    down-arrow?:bool <- equal k, 65516/down-arrow
-    break-unless down-arrow?
-    recipe-editor:&:editor <- get *env, recipes:offset
-    recipe-cursor-row:num <- get *recipe-editor, cursor-row:offset
-    recipe-editor-bottom:num <- get *recipe-editor, bottom:offset
-    at-bottom-of-editor?:bool <- greater-or-equal recipe-cursor-row, recipe-editor-bottom
-    break-unless at-bottom-of-editor?
-    more-to-scroll?:bool <- more-to-scroll? env, screen
-    break-if more-to-scroll?
-    loop +next-event
-  }
-  {
-    break-if sandbox-in-focus?
-    page-down?:bool <- equal k, 65518/page-down
-    break-unless page-down?
-    more-to-scroll?:bool <- more-to-scroll? env, screen
-    break-if more-to-scroll?
-    loop +next-event
-  }
-]
-
-after <global-type> [
-  {
-    break-if sandbox-in-focus?
-    page-down?:bool <- equal k, 6/ctrl-f
-    break-unless page-down?
-    more-to-scroll?:bool <- more-to-scroll? env, screen
-    break-if more-to-scroll?
-    loop +next-event
-  }
-]
-
-def more-to-scroll? env:&:environment, screen:&:screen -> result:bool [
-  local-scope
-  load-ingredients
-  recipe-bottom:num <- get *env, recipe-bottom:offset
-  height:num <- screen-height screen
-  result <- greater-or-equal recipe-bottom, height
-]
-
 scenario scrolling-down-past-bottom-of-recipe-editor-2 [
   local-scope
   trace-until 100/app
diff --git a/edit/011-errors.mu b/edit/011-errors.mu
index 049a0853..b12286ed 100644
--- a/edit/011-errors.mu
+++ b/edit/011-errors.mu
@@ -30,7 +30,7 @@ after <render-recipe-errors-on-F4> [
     recipes:&:editor <- get *env, recipes:offset
     left:num <- get *recipes, left:offset
     right:num <- get *recipes, right:offset
-    row:num <- get *env, recipe-bottom:offset
+    row:num <- get *recipes, bottom:offset
     row, screen <- render-text screen, recipe-errors, left, right, 1/red, row
     # draw dotted line after recipes
     draw-horizontal screen, row, left, right, 9480/horizontal-dotted
@@ -146,7 +146,6 @@ scenario run-shows-errors-in-get [
     .recipe foo [                                      ┊foo                                              .
     .  get 123:num, foo:offset                         ┊─────────────────────────────────────────────────.
     .]                                                 ┊                                                 .
-    .                                                  ┊                                                 .
     .foo: unknown element 'foo' in container 'number'  ┊                                                 .
     .foo: first ingredient of 'get' should be a contai↩┊                                                 .
     .ner, but got '123:num'                            ┊                                                 .
@@ -158,7 +157,6 @@ scenario run-shows-errors-in-get [
     .                                                                                                    .
     .                                                                                                    .
     .                                                                                                    .
-    .                                                                                                    .
     .foo: unknown element 'foo' in container 'number'                                                    .
     .foo: first ingredient of 'get' should be a contai                                                   .
     .ner, but got '123:num'                                                                              .
@@ -400,7 +398,6 @@ scenario run-shows-missing-type-errors [
     .recipe foo [                                      ┊foo                                              .
     .  x <- copy 0                                     ┊─────────────────────────────────────────────────.
     .]                                                 ┊                                                 .
-    .                                                  ┊                                                 .
     .foo: missing type for 'x' in 'x <- copy 0'        ┊                                                 .
     .foo: can't copy '0' to 'x'; types don't match     ┊                                                 .
     .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊                                                 .
@@ -431,7 +428,6 @@ scenario run-shows-unbalanced-bracket-errors [
     .  errors found                                                                   run (F4)           .
     .recipe foo \\[                                      ┊foo                                              .
     .  x <- copy 0                                     ┊─────────────────────────────────────────────────.
-    .                                                  ┊                                                 .
     .9: unbalanced '\\[' for recipe                      ┊                                                 .
     .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊                                                 .
     .                                                  ┊                                                 .
@@ -466,7 +462,6 @@ scenario run-shows-get-on-non-container-errors [
     .  x:&:point <- new point:type                     ┊                                                 .
     .  get x:&:point, 1:offset                         ┊                                                 .
     .]                                                 ┊                                                 .
-    .                                                  ┊                                                 .
     .foo: first ingredient of 'get' should be a contai↩┊                                                 .
     .ner, but got 'x:&:point'                          ┊                                                 .
     .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊                                                 .
@@ -504,7 +499,6 @@ scenario run-shows-non-literal-get-argument-errors [
     .  y:&:point <- new point:type                     ┊                                                 .
     .  get *y:&:point, x:num                           ┊                                                 .
     .]                                                 ┊                                                 .
-    .                                                  ┊                                                 .
     .foo: second ingredient of 'get' should have type ↩┊                                                 .
     .'offset', but got 'x:num'                         ┊                                                 .
     .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊                                                 .
@@ -537,7 +531,6 @@ scenario run-shows-errors-everytime [
     .  local-scope                                     ┊─────────────────────────────────────────────────.
     .  x:num <- copy y:num                             ┊                                                 .
     .]                                                 ┊                                                 .
-    .                                                  ┊                                                 .
     .foo: tried to read ingredient 'y' in 'x:num <- co↩┊                                                 .
     .py y:num' but it hasn't been written to yet       ┊                                                 .
     .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊                                                 .
@@ -556,7 +549,6 @@ scenario run-shows-errors-everytime [
     .  local-scope                                     ┊─────────────────────────────────────────────────.
     .  x:num <- copy y:num                             ┊                                                 .
     .]                                                 ┊                                                 .
-    .                                                  ┊                                                 .
     .foo: tried to read ingredient 'y' in 'x:num <- co↩┊                                                 .
     .py y:num' but it hasn't been written to yet       ┊                                                 .
     .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊                                                 .
diff --git a/sandbox/003-shortcuts.mu b/sandbox/003-shortcuts.mu
index 6fdd70b8..adee48a7 100644
--- a/sandbox/003-shortcuts.mu
+++ b/sandbox/003-shortcuts.mu
@@ -1348,38 +1348,43 @@ def move-to-next-line editor:&:editor, screen-height:num -> editor:&:editor [
   left:num <- get *editor, left:offset
   right:num <- get *editor, right:offset
   last-line:num <- subtract screen-height, 1
+  bottom:num <- get *editor, bottom:offset
+  at-bottom-of-screen?:bool <- greater-or-equal bottom, last-line
+  return-unless before-cursor
+  next:&:duplex-list:char <- next before-cursor
+  return-unless next
   already-at-bottom?:bool <- greater-or-equal cursor-row, last-line
-    # incorrect indent to help diff with edit/
     # if cursor not at bottom, move it
     return-if already-at-bottom?
-    # scan to start of next line, then to right column or until end of line
-    max:num <- subtract right, left
-    next-line:&:duplex-list:char <- before-start-of-next-line before-cursor, max
-    # already at end of buffer? do nothing
-    no-motion?:bool <- equal next-line, before-cursor
-    return-if no-motion?
-    cursor-row <- add cursor-row, 1
-    *editor <- put *editor, cursor-row:offset, cursor-row
-    before-cursor <- copy next-line
-    *editor <- put *editor, before-cursor:offset, before-cursor
     target-column:num <- copy cursor-column
+    # scan to start of next line
+    {
+      next:&:duplex-list:char <- next before-cursor
+      break-unless next
+      done?:bool <- greater-or-equal cursor-column, right
+      break-if done?
+      cursor-column <- add cursor-column, 1
+      before-cursor <- copy next
+      c:char <- get *next, value:offset
+      at-newline?:bool <- equal c, 10/newline
+      break-if at-newline?
+      loop
+    }
+    return-unless next
+    cursor-row <- add cursor-row, 1
     cursor-column <- copy left
-    *editor <- put *editor, cursor-column:offset, cursor-column
     {
+      next:&:duplex-list:char <- next before-cursor
+      break-unless next
       done?:bool <- greater-or-equal cursor-column, target-column
       break-if done?
-      curr:&:duplex-list:char <- next before-cursor
-      break-unless curr
-      currc:char <- get *curr, value:offset
-      at-newline?:bool <- equal currc, 10/newline
-      break-if at-newline?
-      #
-      before-cursor <- copy curr
-      *editor <- put *editor, before-cursor:offset, before-cursor
       cursor-column <- add cursor-column, 1
-      *editor <- put *editor, cursor-column:offset, cursor-column
+      before-cursor <- copy next
       loop
     }
+    *editor <- put *editor, before-cursor:offset, before-cursor
+    *editor <- put *editor, cursor-column:offset, cursor-column
+    *editor <- put *editor, cursor-row:offset, cursor-row
 ]
 
 scenario editor-adjusts-column-at-next-line [