about summary refs log tree commit diff stats
path: root/sandbox
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2017-05-12 07:32:46 -0700
committerKartik K. Agaram <vc@akkartik.com>2017-05-12 07:34:07 -0700
commit43f634adb0eda2fc0377423e5c5b2a7d8f087780 (patch)
tree9413077799113f237d12684aed955caf1f35c983 /sandbox
parentcd0577aeb288f57aaccd93bf88874499e3e4af1d (diff)
downloadmu-43f634adb0eda2fc0377423e5c5b2a7d8f087780.tar.gz
3852
Bugfix of commit 3850 for the sandbox/ app. I'd hoped to just quickly move
past this ugly approach, but a cleaner way is more involved than I thought.

This way is ugly partly because I'm introducing a bunch of conditionals
without testing them. One or more of my additions may well be hiding bugs.
Or I may need to add them in a few other places.

The clean way is to update the fake screen model to accurately mimic the
new real screen, where out of bounds prints aren't silently ignored, and
where scrolling is a fact of life.
Diffstat (limited to 'sandbox')
-rw-r--r--sandbox/002-typing.mu7
-rw-r--r--sandbox/004-programming-environment.mu7
-rw-r--r--sandbox/005-sandbox.mu23
3 files changed, 35 insertions, 2 deletions
diff --git a/sandbox/002-typing.mu b/sandbox/002-typing.mu
index 4f704f0d..d5120f2f 100644
--- a/sandbox/002-typing.mu
+++ b/sandbox/002-typing.mu
@@ -266,10 +266,17 @@ def editor-render screen:&:screen, editor:&:editor -> screen:&:screen, editor:&:
   left:num <- get *editor, left:offset
   right:num <- get *editor, right:offset
   row:num, column:num <- render screen, editor
+  screen-height:num <- screen-height screen
+  space-left?:bool <- lesser-than row, screen-height
+  return-unless space-left?
   clear-line-until screen, right
   row <- add row, 1
+  space-left?:bool <- lesser-than row, screen-height
+  return-unless space-left?
   draw-horizontal screen, row, left, right, 9480/horizontal-dotted
   row <- add row, 1
+  space-left?:bool <- lesser-than row, screen-height
+  return-unless space-left?
   clear-screen-from screen, row, left, left, right
 ]
 
diff --git a/sandbox/004-programming-environment.mu b/sandbox/004-programming-environment.mu
index 1ebb696d..a29324b0 100644
--- a/sandbox/004-programming-environment.mu
+++ b/sandbox/004-programming-environment.mu
@@ -208,11 +208,18 @@ def render-sandbox-side screen:&:screen, env:&:environment, {render-editor: (rec
   left:num <- get *current-sandbox, left:offset
   right:num <- get *current-sandbox, right:offset
   row:num, column:num, screen, current-sandbox <- call render-editor, screen, current-sandbox
+  screen-height:num <- screen-height screen
+  space-left?:bool <- lesser-than row, screen-height
+  return-unless space-left?
   clear-line-until screen, right
   row <- add row, 1
+  space-left? <- lesser-than row, screen-height
+  return-unless space-left?
   # draw solid line after code (you'll see why in later layers)
   draw-horizontal screen, row, left, right
   row <- add row, 1
+  space-left? <- lesser-than row, screen-height
+  return-unless space-left?
   clear-screen-from screen, row, left, left, right
 ]
 
diff --git a/sandbox/005-sandbox.mu b/sandbox/005-sandbox.mu
index da8bc487..06262d72 100644
--- a/sandbox/005-sandbox.mu
+++ b/sandbox/005-sandbox.mu
@@ -234,19 +234,26 @@ def! render-sandbox-side screen:&:screen, env:&:environment, {render-editor: (re
   row:num, column:num <- copy 1, 0
   left:num <- get *current-sandbox, left:offset
   right:num <- get *current-sandbox, right:offset
+  screen-height:num <- screen-height screen
   # render sandbox editor
   render-from:num <- get *env, render-from:offset
   {
     render-current-sandbox?:bool <- equal render-from, -1
     break-unless render-current-sandbox?
     row, column, screen, current-sandbox <- call render-editor, screen, current-sandbox
+    space-left?:bool <- lesser-than row, screen-height
+    return-unless space-left?
     clear-screen-from screen, row, column, left, right
     row <- add row, 1
+    space-left? <- lesser-than row, screen-height
+    return-unless space-left?
   }
   # render sandboxes
   draw-horizontal screen, row, left, right
   sandbox:&:sandbox <- get *env, sandbox:offset
   row, screen <- render-sandboxes screen, sandbox, left, right, row, render-from, 0, env
+  space-left? <- lesser-than row, screen-height
+  return-unless space-left?
   clear-rest-of-screen screen, row, left, right
 ]
 
@@ -263,16 +270,22 @@ def render-sandboxes screen:&:screen, sandbox:&:sandbox, left:num, right:num, ro
     break-if hidden?
     # render sandbox menu
     row <- add row, 1
+    space-left?:bool <- lesser-than row, screen-height
+    return-unless space-left?
     screen <- move-cursor screen, row, left
     screen <- render-sandbox-menu screen, idx, left, right
     # save menu row so we can detect clicks to it later
     *sandbox <- put *sandbox, starting-row-on-screen:offset, row
     # render sandbox contents
     row <- add row, 1
+    space-left? <- lesser-than row, screen-height
+    return-unless space-left?
     screen <- move-cursor screen, row, left
     sandbox-data:text <- get *sandbox, data:offset
     row, screen <- render-code screen, sandbox-data, left, right, row
     *sandbox <- put *sandbox, code-ending-row-on-screen:offset, row
+    space-left? <- lesser-than row, screen-height
+    return-unless space-left?
     # render sandbox warnings, screen or response, in that order
     sandbox-response:text <- get *sandbox, response:offset
     <render-sandbox-results>
@@ -288,8 +301,8 @@ def render-sandboxes screen:&:screen, sandbox:&:sandbox, left:num, right:num, ro
       row, screen <- render-text screen, sandbox-response, left, right, 245/grey, row
     }
     +render-sandbox-end
-    at-bottom?:bool <- greater-or-equal row, screen-height
-    return-if at-bottom?
+    space-left? <- lesser-than row, screen-height
+    return-unless space-left?
     # draw solid line after sandbox
     draw-horizontal screen, row, left, right
   }
@@ -301,6 +314,8 @@ def render-sandboxes screen:&:screen, sandbox:&:sandbox, left:num, right:num, ro
     <end-render-sandbox-reset-hidden>
   }
   # draw next sandbox
+  space-left? <- lesser-than row, screen-height
+  return-unless space-left?
   next-sandbox:&:sandbox <- get *sandbox, next-sandbox:offset
   next-idx:num <- add idx, 1
   row, screen <- render-sandboxes screen, next-sandbox, left, right, row, render-from, next-idx, env
@@ -401,6 +416,8 @@ def render-text screen:&:screen, s:text, left:num, right:num, color:num, row:num
     column <- add column, 1
     loop
   }
+  space-left?:bool <- lesser-than row, screen-height
+  return-unless space-left?
   was-at-left?:bool <- equal column, left
   clear-line-until screen, right
   {
@@ -466,6 +483,8 @@ def render-code screen:&:screen, s:text, left:num, right:num, row:num -> row:num
     column <- add column, 1
     loop
   }
+  space-left?:bool <- lesser-than row, screen-height
+  return-unless space-left?
   was-at-left?:bool <- equal column, left
   clear-line-until screen, right
   {