about summary refs log tree commit diff stats
path: root/sandbox
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-12-28 08:44:36 -0800
committerKartik K. Agaram <vc@akkartik.com>2015-12-28 08:44:36 -0800
commitbbe0801ab1e0b0859c3529ed33fde40b139addd6 (patch)
treefa534bbbb3b345d154432746cd585f9262bd80cd /sandbox
parente94453100dda87a42dee36b2671f850ab6824f54 (diff)
downloadmu-bbe0801ab1e0b0859c3529ed33fde40b139addd6.tar.gz
2548 - teach 'print' to print integers
Still can't print non-integer numbers, so this is a bit hacky.

The big consequence is that you can't print literal characters anymore
because of our rules about how we pick which variant to statically
dispatch to. You have to save to a character variable first.

Maybe I can add an annotation to literals..
Diffstat (limited to 'sandbox')
-rw-r--r--sandbox/001-editor.mu6
-rw-r--r--sandbox/003-shortcuts.mu6
-rw-r--r--sandbox/004-programming-environment.mu12
-rw-r--r--sandbox/005-sandbox.mu15
-rw-r--r--sandbox/009-sandbox-trace.mu5
5 files changed, 28 insertions, 16 deletions
diff --git a/sandbox/001-editor.mu b/sandbox/001-editor.mu
index 4ef9be36..fd44d493 100644
--- a/sandbox/001-editor.mu
+++ b/sandbox/001-editor.mu
@@ -193,7 +193,8 @@ recipe render screen:address:screen, editor:address:editor-data -> last-row:numb
       at-right?:boolean <- equal column, right
       break-unless at-right?
       # print wrap icon
-      print screen, 8617/loop-back-to-left, 245/grey
+      wrap-icon:character <- copy 8617/loop-back-to-left
+      print screen, wrap-icon, 245/grey
       column <- copy left
       row <- add row, 1
       screen <- move-cursor screen, row, column
@@ -227,10 +228,11 @@ recipe render screen:address:screen, editor:address:editor-data -> last-row:numb
 recipe clear-line-delimited screen:address:screen, column:number, right:number -> screen:address:screen [
   local-scope
   load-ingredients
+  space:character <- copy 32/space
   {
     done?:boolean <- greater-than column, right
     break-if done?
-    screen <- print screen, 32/space
+    screen <- print screen, space
     column <- add column, 1
     loop
   }
diff --git a/sandbox/003-shortcuts.mu b/sandbox/003-shortcuts.mu
index 79d53b2a..feab04ea 100644
--- a/sandbox/003-shortcuts.mu
+++ b/sandbox/003-shortcuts.mu
@@ -125,7 +125,8 @@ recipe delete-before-cursor editor:address:editor-data, screen:address:screen ->
     loop
   }
   # we're guaranteed not to be at the right margin
-  screen <- print screen, 32/space
+  space:character <- copy 32/space
+  screen <- print screen, space
   go-render? <- copy 0/false
 ]
 
@@ -366,7 +367,8 @@ recipe delete-at-cursor editor:address:editor-data, screen:address:screen -> edi
     loop
   }
   # we're guaranteed not to be at the right margin
-  screen <- print screen, 32/space
+  space:character <- copy 32/space
+  screen <- print screen, space
   go-render? <- copy 0/false
 ]
 
diff --git a/sandbox/004-programming-environment.mu b/sandbox/004-programming-environment.mu
index 1535e75c..4a16d2fa 100644
--- a/sandbox/004-programming-environment.mu
+++ b/sandbox/004-programming-environment.mu
@@ -223,7 +223,8 @@ recipe render screen:address:screen, s:address:array:character, left:number, rig
       at-right?:boolean <- equal column, right
       break-unless at-right?
       # print wrap icon
-      print screen, 8617/loop-back-to-left, 245/grey
+      wrap-icon:character <- copy 8617/loop-back-to-left
+      print screen, wrap-icon, 245/grey
       column <- copy left
       row <- add row, 1
       screen <- move-cursor screen, row, column
@@ -238,7 +239,8 @@ recipe render screen:address:screen, s:address:array:character, left:number, rig
       {
         done?:boolean <- greater-than column, right
         break-if done?
-        print screen, 32/space
+        space:character <- copy 32/space
+        print screen, space
         column <- add column, 1
         loop
       }
@@ -284,7 +286,8 @@ recipe render-code screen:address:screen, s:address:array:character, left:number
       at-right?:boolean <- equal column, right
       break-unless at-right?
       # print wrap icon
-      print screen, 8617/loop-back-to-left, 245/grey
+      wrap-icon:character <- copy 8617/loop-back-to-left
+      print screen, wrap-icon, 245/grey
       column <- copy left
       row <- add row, 1
       screen <- move-cursor screen, row, column
@@ -299,7 +302,8 @@ recipe render-code screen:address:screen, s:address:array:character, left:number
       {
         done?:boolean <- greater-than column, right
         break-if done?
-        print screen, 32/space
+        space:character <- copy 32/space
+        print screen, space
         column <- add column, 1
         loop
       }
diff --git a/sandbox/005-sandbox.mu b/sandbox/005-sandbox.mu
index db0a195b..a424209a 100644
--- a/sandbox/005-sandbox.mu
+++ b/sandbox/005-sandbox.mu
@@ -234,7 +234,8 @@ recipe render-sandboxes screen:address:screen, sandbox:address:sandbox-data, lef
   row <- add row, 1
   screen <- move-cursor screen, row, left
   clear-line-delimited screen, left, right
-  print screen, 120/x, 245/grey
+  delete-icon:character <- copy 120/x
+  print screen, delete-icon, 245/grey
   # save menu row so we can detect clicks to it later
   starting-row:address:number <- get-address *sandbox, starting-row-on-screen:offset
   *starting-row <- copy row
@@ -330,9 +331,11 @@ recipe render-screen screen:address:screen, sandbox-screen:address:screen, left:
     column <- copy left
     screen <- move-cursor screen, row, column
     # initial leader for each row: two spaces and a '.'
-    print screen, 32/space, 245/grey
-    print screen, 32/space, 245/grey
-    print screen, 46/full-stop, 245/grey
+    space:character <- copy 32/space
+    print screen, space, 245/grey
+    print screen, space, 245/grey
+    full-stop:character <- copy 46/period
+    print screen, full-stop, 245/grey
     column <- add left, 3
     {
       # print row
@@ -353,13 +356,13 @@ recipe render-screen screen:address:screen, sandbox-screen:address:screen, left:
       loop
     }
     # print final '.'
-    print screen, 46/full-stop, 245/grey
+    print screen, full-stop, 245/grey
     column <- add column, 1
     {
       # clear rest of current line
       line-done?:boolean <- greater-than column, right
       break-if line-done?
-      print screen, 32/space
+      print screen, space
       column <- add column, 1
       loop
     }
diff --git a/sandbox/009-sandbox-trace.mu b/sandbox/009-sandbox-trace.mu
index df74df47..45759b75 100644
--- a/sandbox/009-sandbox-trace.mu
+++ b/sandbox/009-sandbox-trace.mu
@@ -25,7 +25,8 @@ scenario sandbox-click-on-code-toggles-app-trace [
   ]
   run [
     event-loop screen:address:screen, console:address:console, 2:address:programming-environment-data
-    print screen:address:screen, 9251/␣/cursor
+    4:character/cursor-icon <- copy 9251/␣
+    print screen:address:screen, 4:character/cursor-icon
   ]
   # trace now printed and cursor shouldn't have budged
   screen-should-contain [
@@ -54,7 +55,7 @@ scenario sandbox-click-on-code-toggles-app-trace [
   ]
   run [
     event-loop screen:address:screen, console:address:console, 2:address:programming-environment-data
-    print screen:address:screen, 9251/␣/cursor
+    print screen:address:screen, 4:character/cursor-icon
   ]
   # trace hidden again
   screen-should-contain [