about summary refs log tree commit diff stats
path: root/mu.arc.t
Commit message (Collapse)AuthorAgeFilesLines
* 881Kartik K. Agaram2015-03-101-0/+1
|
* 742 - turns out chessboard test logs were incompleteKartik K. Agaram2015-02-111-9/+4
| | | | | Now that we aren't loading system software for every test we can afford to log the loading of test functions.
* 722 - split at substring, and assorted helpersKartik K. Agaram2015-02-081-0/+70
|
* 720 - substring matching and searchingKartik K. Agaram2015-02-081-0/+169
|
* 718 - disable raw memory warnings in testsKartik K. Agaram2015-02-081-0/+2
|
* 712Kartik K. Agaram2015-02-071-0/+14
|
* 711 - extract method: string-copyKartik K. Agaram2015-02-071-0/+1
|
* 708Kartik K. Agaram2015-02-051-10/+10
|
* 706Kartik K. Agaram2015-02-041-0/+83
|
* 705 - clean up traces before we try to parse themKartik K. Agaram2015-02-031-14/+16
| | | | | | | | | | For now we want to parse two labels: 'run', identifying call stack, op and args 'mem', distinguishing reads and writes This should give us fodder for a few weeks, to build both a folding UI for individual statements and descending the call stack, and also a query engine that can figure out sources and sinks in the trace graph.
* 689Kartik K. Agaram2015-01-311-1/+3
| | | | Typo in a recent test.
* 677 - more improvements for names in shared spacesKartik K. Agaram2015-01-291-1/+54
|
* 676 - allow routines to share *names* for localsKartik K. Agaram2015-01-291-0/+26
|
* 675Kartik K. Agaram2015-01-291-2/+2
|
* 635Kartik K. Agaram2015-01-261-1/+39
|
* 634Kartik K. Agaram2015-01-261-0/+35
|
* 630 - routines can now allocate unlimited memoryKartik K. Agaram2015-01-261-0/+2
|
* 629Kartik K. Agaram2015-01-261-1/+33
|
* 628Kartik K. Agaram2015-01-261-0/+27
|
* 627Kartik K. Agaram2015-01-261-0/+25
|
* 626 - start eliminating the memory-per-routine limitKartik K. Agaram2015-01-261-0/+23
|
* 625 - guard against errors with input-output argsKartik K. Agaram2015-01-251-0/+30
| | | | | | | | | | | (Another attempt at 623.) I dunno, this may all be a wild goose chase. I haven't been disciplined in tagging in-out arguments in 'read-move' and its helpers. Maybe I should just drop those 'nochange' oargs in 'read' and 'write'. Maybe I should reserve output args only for return values that callers might actually care about, and use more conventional metadata like 'const' or 'unique' or 'inout' on other args.
* 624 - no, that's all wrong, scratch 623Kartik K. Agaram2015-01-251-53/+23
|
* 623 - 'nochange' to guard against race conditionsKartik K. Agaram2015-01-251-23/+53
| | | | | | | | | I dunno, this may all be a wild goose chase. I haven't been disciplined in tagging in-out arguments in 'read-move' and its helpers. Maybe I should just drop those 'nochange' oargs in 'read' and 'write'. Maybe I should reserve output args only for return values that callers might actually care about, and use more conventional metadata like 'const' or 'unique' or 'inout' on other args.
* 616 - buffered-stdin handles backspaceKartik K. Agaram2015-01-251-0/+34
| | | | Chessboard now *almost* handles backspace perfectly.
* 604 - new function to buffer stdinKartik K. Agaram2015-01-241-0/+72
| | | | | Still surprisingly hard to debug. We might be barking up the wrong tree. Or we might just need to lump it. System software is hard.
* 600 - fake keyboardKartik K. Agaram2015-01-221-3/+31
| | | | | Use asynchronous channels like 'stdin' for most tests. Use the synchronous fakes for testing low-level stdin helpers.
* 599Kartik K. Agaram2015-01-211-1/+0
|
* 598 - clear up a minor mysteryKartik K. Agaram2015-01-211-0/+1
|
* 597Kartik K. Agaram2015-01-211-0/+14
|
* 592Kartik K. Agaram2015-01-181-2/+5
|
* 582 - first tests for printing to screenKartik K. Agaram2015-01-171-0/+26
|
* 576 - helper for printing integersKartik K. Agaram2015-01-171-0/+35
| | | | | | | | | | | | | | | This requires creating a new data structure called buffer, because strings are too inefficient for appending to, and we need to know how long they need to be before we clear them. But I'm not gonna bother to write tests for all the new primitives I just introduced, because that's not expedient. One test for mu is how nicely it handles situations like this without requiring perfect test hygiene. In this case, I can imagine tools that will extract tests for a particular function out of all known tests. Especially if it's a pure function that should be easy. Then just show each test to the programmer and ask him to give it a reasonable name.
* 569 - ah, the right way to do generic functionsKartik K. Agaram2015-01-141-0/+2
| | | | | | | | | | Each clause creates its own default-space for local variables. Now we can justify prepending bodies on every 'function' form. Later we can optimize away the duplicate default-spaces. Another cost: we can't mindlessly use 'next-input' anymore. Pity.
* 564Kartik K. Agaram2015-01-141-679/+679
|
* 542Kartik K. Agaram2015-01-121-0/+52
| | | | Tests for terminating when there's just helpers left.
* 529 - 'sleep' can now wait for a routine to completeKartik K. Agaram2015-01-101-0/+26
|
* 528Kartik K. Agaram2015-01-101-3/+4
|
* 525 - 'fork' now returns a routine idKartik K. Agaram2015-01-101-0/+30
|
* 524Kartik K. Agaram2015-01-101-14/+14
|
* 522 - another arg for 'fork'Kartik K. Agaram2015-01-101-5/+23
| | | | Fork syntax is now: fork <function> [global space] [max cycle limit] args*
* 519 - ooh, use metadata to disambiguate argsKartik K. Agaram2015-01-101-5/+5
|
* 515 - support time limits for threadsKartik K. Agaram2015-01-101-0/+124
| | | | | Disquieting that I can't make each of these five tests fail in isolation. We have to fix them all at once.
* 514Kartik K. Agaram2015-01-091-16/+18
|
* 512 - update html renderingKartik K. Agaram2015-01-091-191/+227
|
* 511 - make 'sleep' clearerKartik K. Agaram2015-01-081-13/+13
|
* 510Kartik K. Agaram2015-01-081-2/+2
|
* 509Kartik K. Agaram2015-01-081-23/+23
|
* 506 - continue 505Kartik K. Agaram2015-01-061-21/+27
| | | | Still no reason uncovered to avoid non-pointers.
* 505 - simplify tagged-valueKartik K. Agaram2015-01-051-37/+26
| | | | | | | I could swear there was an issue earlier where tagged-values had to contain pointers for some core function. But I can't find it anymore. Ok, assume we can store primitives in it and pointers only for aggregates (and-records and arrays).
mp;id=5ccf2653fb7d31b013f77df4e92e964e45c54f8a'>^
db1f56c8 ^
4690ce81 ^
f344b250 ^


f5465e12 ^
f344b250 ^
f5465e12 ^
9570363a ^
f344b250 ^
f5465e12 ^

762b099e ^
4690ce81 ^
f5465e12 ^
4690ce81 ^
762b099e ^

f344b250 ^
f5465e12 ^
db1f56c8 ^
f344b250 ^
f5465e12 ^
4bbd3ded ^
f5465e12 ^


f344b250 ^
f5465e12 ^
d5d908dd ^
f5465e12 ^


f344b250 ^

f5465e12 ^
672e3e50 ^
65361948 ^
db1f56c8 ^
f344b250 ^

762b099e ^
f344b250 ^

4690ce81 ^
32b8fac2 ^
4690ce81 ^
f344b250 ^
32b8fac2 ^
4690ce81 ^
32b8fac2 ^
4690ce81 ^
32b8fac2 ^
65361948 ^
f5465e12 ^
f344b250 ^
f5465e12 ^

65361948 ^
f344b250 ^

f5465e12 ^
65361948 ^
32b8fac2 ^



f5465e12 ^
4690ce81 ^
f5465e12 ^
672e3e50 ^
f344b250 ^
32b8fac2 ^
f344b250 ^

65361948 ^
f5465e12 ^
f344b250 ^
f5465e12 ^

65361948 ^
f344b250 ^
f5465e12 ^
65361948 ^
32b8fac2 ^

f5465e12 ^
32b8fac2 ^

f5465e12 ^
4690ce81 ^
f5465e12 ^
32b8fac2 ^

672e3e50 ^
f5465e12 ^
f344b250 ^

f5465e12 ^
32b8fac2 ^

f5465e12 ^
4690ce81 ^
f5465e12 ^
672e3e50 ^
f5465e12 ^
65361948 ^
672e3e50 ^
f5465e12 ^
6c69569a ^

65361948 ^
f344b250 ^



4bbd3ded ^

a0decd22 ^




4bbd3ded ^


db1f56c8 ^
6c69569a ^

4bbd3ded ^
f344b250 ^



65361948 ^

a0decd22 ^




65361948 ^

672e3e50 ^
f5465e12 ^
6c69569a ^



65361948 ^
f344b250 ^
a0decd22 ^
f344b250 ^


dbe12410 ^

a0decd22 ^





dbe12410 ^


f5465e12 ^
6c69569a ^



dbe12410 ^
f344b250 ^
a0decd22 ^
6c69569a ^
f344b250 ^


65361948 ^

a0decd22 ^





65361948 ^


db1f56c8 ^
6c69569a ^






dbe12410 ^
6c69569a ^
f344b250 ^
a0decd22 ^
f344b250 ^


dbe12410 ^

a0decd22 ^







dbe12410 ^


f5465e12 ^
6c69569a ^



65361948 ^
f344b250 ^
a0decd22 ^
f344b250 ^



65361948 ^

a0decd22 ^






65361948 ^


f5465e12 ^
6c69569a ^




dbe12410 ^
6c69569a ^
a0decd22 ^
f344b250 ^

dbe12410 ^
6c69569a ^
dbe12410 ^
a0decd22 ^

dbe12410 ^


db1f56c8 ^
6c69569a ^










dbe12410 ^
6c69569a ^
f344b250 ^
a0decd22 ^
f344b250 ^



dbe12410 ^

a0decd22 ^

d009e158 ^








a0decd22 ^
d009e158 ^
dbe12410 ^


f344b250 ^
f5465e12 ^
db1f56c8 ^
f344b250 ^
672e3e50 ^
f5465e12 ^
db1f56c8 ^
f344b250 ^


672e3e50 ^
f5465e12 ^
f344b250 ^

f5465e12 ^
32b8fac2 ^

f5465e12 ^

672e3e50 ^
32b8fac2 ^
4690ce81 ^
f5465e12 ^
672e3e50 ^

65361948 ^
672e3e50 ^
f344b250 ^
2f02189d ^

f344b250 ^


2f02189d ^





f344b250 ^
2f02189d ^






f344b250 ^
f5465e12 ^
db1f56c8 ^
672e3e50 ^
f5465e12 ^
db1f56c8 ^
f344b250 ^

4690ce81 ^
f5465e12 ^
9570363a ^
65361948 ^
672e3e50 ^
f344b250 ^
f5465e12 ^
db1f56c8 ^
672e3e50 ^
f5465e12 ^
db1f56c8 ^
32b8fac2 ^

4690ce81 ^
f5465e12 ^
672e3e50 ^
f5465e12 ^
65361948 ^
672e3e50 ^
f5465e12 ^
6c69569a ^






65361948 ^
a0decd22 ^
f344b250 ^

65361948 ^
672e3e50 ^
65361948 ^
a0decd22 ^










d009e158 ^

65361948 ^

672e3e50 ^
f344b250 ^
f5465e12 ^
db1f56c8 ^
672e3e50 ^
f5465e12 ^
db1f56c8 ^
f5465e12 ^
eaeb9552 ^
f344b250 ^



f5465e12 ^
32b8fac2 ^

f5465e12 ^
4690ce81 ^
f5465e12 ^
672e3e50 ^

65361948 ^
672e3e50 ^
f344b250 ^
f5465e12 ^
db1f56c8 ^
672e3e50 ^
f5465e12 ^
db1f56c8 ^
f5465e12 ^
eaeb9552 ^
f344b250 ^

f5465e12 ^
32b8fac2 ^

f5465e12 ^
4690ce81 ^
f5465e12 ^
672e3e50 ^

65361948 ^
672e3e50 ^
f344b250 ^
f5465e12 ^
db1f56c8 ^
672e3e50 ^
f5465e12 ^
db1f56c8 ^
f5465e12 ^
eaeb9552 ^
f344b250 ^



f5465e12 ^
32b8fac2 ^

f5465e12 ^
4690ce81 ^
f5465e12 ^
672e3e50 ^

65361948 ^
672e3e50 ^
f344b250 ^
f5465e12 ^
db1f56c8 ^
672e3e50 ^
f5465e12 ^
db1f56c8 ^
f5465e12 ^
eaeb9552 ^
f344b250 ^

f5465e12 ^
32b8fac2 ^

f5465e12 ^
4690ce81 ^
f5465e12 ^
672e3e50 ^

65361948 ^

f344b250 ^
f5465e12 ^
db1f56c8 ^
f344b250 ^

db1f56c8 ^
65361948 ^

f344b250 ^
f5465e12 ^
db1f56c8 ^
9570363a ^

65361948 ^

f344b250 ^
2f02189d ^

f344b250 ^
2f02189d ^


f344b250 ^
f5465e12 ^
db1f56c8 ^
e8b1d3ff ^
f5465e12 ^
db1f56c8 ^

4690ce81 ^
f5465e12 ^
e8b1d3ff ^
db1f56c8 ^
e8b1d3ff ^

f344b250 ^
f5465e12 ^
db1f56c8 ^
e8b1d3ff ^
f5465e12 ^
db1f56c8 ^

4690ce81 ^
f5465e12 ^
e8b1d3ff ^
db1f56c8 ^
e8b1d3ff ^

f344b250 ^
f5465e12 ^
db1f56c8 ^
62a52ffb ^
f5465e12 ^

4690ce81 ^
f5465e12 ^
62a52ffb ^

62a52ffb ^

f344b250 ^
f5465e12 ^
db1f56c8 ^
62a52ffb ^
f5465e12 ^

4690ce81 ^
f5465e12 ^
62a52ffb ^

62a52ffb ^

f344b250 ^
f5465e12 ^
db1f56c8 ^
62a52ffb ^
90560d71 ^
f5465e12 ^

4690ce81 ^
f5465e12 ^
62a52ffb ^

62a52ffb ^

f344b250 ^
f5465e12 ^
db1f56c8 ^
62a52ffb ^
90560d71 ^
f5465e12 ^

4690ce81 ^
f5465e12 ^
62a52ffb ^

62a52ffb ^

f344b250 ^
f5465e12 ^
db1f56c8 ^
f344b250 ^
f5465e12 ^
e8b1d3ff ^
f5465e12 ^


f344b250 ^
f5465e12 ^
d5d908dd ^
f5465e12 ^


f344b250 ^

f5465e12 ^
f344b250 ^
f5465e12 ^
f344b250 ^
db1f56c8 ^
f5465e12 ^


65361948 ^

db1f56c8 ^
6c69569a ^

dbe12410 ^
6c69569a ^
f344b250 ^

dbe12410 ^

a0decd22 ^








dbe12410 ^


f344b250 ^
f5465e12 ^
d009e158 ^
f344b250 ^
f5465e12 ^
e8b1d3ff ^
f5465e12 ^


f344b250 ^
f5465e12 ^
d5d908dd ^
f5465e12 ^


65361948 ^
0ca56ed8 ^
db1f56c8 ^
65361948 ^
d009e158 ^

f344b250 ^
d009e158 ^

f344b250 ^
d009e158 ^




f344b250 ^
d009e158 ^








f344b250 ^
d009e158 ^

f344b250 ^
d009e158 ^




f344b250 ^
d009e158 ^




f344b250 ^
d009e158 ^

672e3e50 ^


a654e4ec ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795



                                                                                          
                               

                                                
                                   

                                                                                         

                       
                                                                                                 
                                                                                            
                                      
                           
                              
                              
                            


                                  

                               

        





                               

       
                         


                                                                                                        
                                              




                          

 
                                                   

               
 
 
                                                                                                                        
                                           

                                                                                         

                                                                                                                         
                                                                                                                                                                             
                                                               
 
 
                                                                                                                            
                                           
                                                
                                            
                                  
                                                      
                                                    


                                                                                                                     
                                    
                                                                           
                                                   

                                                                                                                                            


                                                                                 
                                               

                                                                                                                                               
                                         
                                  

                                                       

 
                                                                                                                           
                                           
                                                
                                  
                                                  
                
                                  


                                                            
                                                                                                                             
                                           
                                                
                                                                                           


                                                                                                                   
                                  
                                                                         
                                                 
                                                                     
                                                                                                                 

                                                                               
                                        
                                                                               
                                  
                                                                            

 
                                                                                                                             
                                           
                                                
                                                                                                               
                                  
                                                         


                                                                                       
                                                                                                                     
                                  
                                                            


                                                                                          

                                                                                             
                                  
                                              
                                                                                         
                                                      

                                                                                                              
                                                                            

                                                                                                           
                                                       
                                                                     
                                                       
                                                                                                                 
                                                                                                      
                                                       
                                                                       
                                                       
                                                                                                             
                                                        
                                    
                                                                                                        

                                                          
                                                                         

                                                                                                      
                                                          
                                                              



                                                                                                                          
                                      
                                           
                                    
                                                                
                                                                    
                                                              

                                                                                                                     
                                                          
                                    
                                                                                                 

                                                            
                                                                              
                                                                                                                
                                                        
                                                              

                                                                                                                          
                                                                                                

                                                                                                                                                 
                                      
                                           
                                    

                                                                         
                                                                                                
                                    

                                                                                                  
                                                       

                                                                                                                        
                                    
                                         
                                  
                                                       
                                               
 
 
                                                                      

                                                                                                                                                           
       



                                                                                                                           

                         




                                                                                                                                                   


   
                                                                   

                                                                                                                                                           
       



                                                                                                                           

                         




                                                                                                                                                   

   
 
                                                                    



                                                                                                                                                           
       
                                                                                                    
                                                                               


                                                                                                                                                    

                         





                                                                                                                                                       


   
                                                                          



                                                                                                                                                           
       
                                                                                                    
                                                                               
                                                                                                                                             


                                                                                                                                                   

                         





                                                                                                                                                      


   
                                                                          






                                                                                                                                                           
       
                                                             
                                                                                     
                                                                       


                                                                                                                                                    

                         







                                                                                                                                                     


   
                                                                  



                                                                                                                                                           
       
                                                                                                 
                                                                             



                                                                                                                                                    

                         






                                                                                                                                                     


   
                                                                       




                                                                                                                                                           
       
                                                                 
                                                                             

                                                                                                                                                    
   
                                                          
                         

                                                                                                                                                     


   
                                                                          










                                                                                                                                                           
       
                                                             
                                                                                      
                                                                       



                                                                                                                                                    

                         

                                                                                                                                                     








                                                                                                                                                                          
                                                          
                                                                                                       


   
                                                                                                                          
                                           
                                                
                                                                                        
                                                                       
                                  
                                                      


                                                                                                                 
                                                             
                                    

                                                                                                  
                                                   

                                                                                           

                                         
                                                                   
                                                                                                                               
                                         
                                  

                                                       
 
 
                                                                                                                                                     

                                                


                                                                                                                     





                                                                                          
                                                                            






                                                                                                                                                                                                                               
                                                                                                                               
                                           
                                                
                                                                          
                                  
                                                      

                                                                                                                 
                                         
                                  
                                                                           
 
 
                                                                                                                                                        
                                           
                                                
                                                                        
                                  
                                                      

                                                                                                                          
                                         
                                  
                                                       
                                            
 
 
                                                                               






                                                                                                                                                           
       
                                                                         

                                                                                                                           
   
                                                       
                         










                                                                                                                                                    

                                                                                                       

   
 
                                                                                                                           
                                           
                                                
                                                                        
                                  
                                                      
                                    
                                                                                       



                                                                                                              
                                                        

                                                                                                                  
                                    
                                         
                                  

                                                       
 
 
                                                                                                                         
                                           
                                                
                                                                        
                                  
                                                      
                                    
                                                                                     

                                                                                                             
                                                     

                                                                                                                  
                                    
                                         
                                  

                                                       
 
 
                                                                                                                            
                                           
                                                
                                                                        
                                  
                                                      
                                    
                                                                                                  



                                                                                                                   
                                                        

                                                                                                                        
                                    
                                         
                                  

                                                       
 
 
                                                                                                                           
                                           
                                                
                                                                        
                                  
                                                      
                                    
                                                                                                 

                                                                                                                   
                                                     

                                                                                                                        
                                    
                                         
                                  

                                                       

 
                                                                                                                                       
                                           
                                                

                                                                                    
                                                                           

 
                                                                                                                                   
                                           
                                                

                                                                          

 
                                                                                                                                                 

                                                
                                                                      


                                 
                                                                                                                  
                                           
                                                
                                                                        
                                  

                                                                                                          
                                         
                                  
                                                       
                                                        

 
                                                                                                                    
                                           
                                                
                                                                        
                                  

                                                                                                        
                                         
                                  
                                                       
                                                          

 
                                                                                                                           
                                           
                                                
                                                                           

                                                      
                                         
                                  

                                                       

 
                                                                                                                           
                                           
                                                
                                                                           

                                                      
                                         
                                  

                                                       

 
                                                                                                                           
                                           
                                                
                                                                           
                                                     

                                                      
                                         
                                  

                                                       

 
                                                                                                                           
                                           
                                                
                                                                           
                                                     

                                                      
                                         
                                  

                                                       

 
                                                                                                                             
                                           
                                                
                                                                                                               
                                  
                                                         


                                                                                       
                                                                                                                     
                                  
                                                            


                                                                                          

                                                                               
                                  
                                                                         
                                                 
                                                         
                                    


                                                                               

 
                                                                           

                                                                                                                                                           
       
                                                                                                          

                                                                                                                           

                         








                                                                                                                                                            


   
                                                                                                                                    
                                           
                                                
                                                                                                               
                                  
                                                         


                                                                                       
                                                                                                                     
                                  
                                                            


                                                                                          
                                                                  
                                                     
                                                                            
 

                                                                  
                                                                                                                            

                                                
                                                                                                               




                                                                                       
                                                                                                                     








                                                                                          
                                                                                                                                    

                                                
                                                                                                               




                                                                                       
                                                                                                                     




                                                                                          
                                                  

                                                                                     


       
                                     
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>Mu - 081print.mu</title>
<meta name="Generator" content="Vim/7.4">
<meta name="plugin-version" content="vim7.4_v2">
<meta name="syntax" content="none">
<meta name="settings" content="use_css,pre_wrap,no_foldcolumn,expand_tabs,prevent_copy=">
<meta name="colorscheme" content="minimal">
<style type="text/css">
<!--
pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; }
body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color: #080808; }
* { font-size: 12pt; font-size: 1em; }
.muData { color: #ffff00; }
.muControl { color: #c0a020; }
.Delimiter { color: #800080; }
.Comment { color: #9090ff; }
.Constant { color: #00a0a0; }
.Special { color: #c00000; }
.CommentedCode { color: #6c6c6c; }
.muRecipe { color: #ff8700; }
.muScenario { color: #00af00; }
-->
</style>

<script type='text/javascript'>
<!--

-->
</script>
</head>
<body>
<pre id='vimCodeElement'>
<span class="Comment"># Wrappers around print primitives that take a 'screen' object and are thus</span>
<span class="Comment"># easier to test.</span>

<span class="muData">container</span> screen [
  num-rows:num
  num-columns:num
  cursor-row:num
  cursor-column:num
  data:&amp;:@:screen-cell
]

<span class="muData">container</span> screen-cell [
  contents:char
  color:num
]

<span class="muRecipe">def</span> new-fake-screen w:num, h:num<span class="muRecipe"> -&gt; </span>result:&amp;:screen [
  <span class="Constant">local-scope</span>
  <span class="Constant">load-ingredients</span>
  result<span class="Special"> &lt;- </span>new <span class="Constant">screen:type</span>
  bufsize:num<span class="Special"> &lt;- </span>multiply w, h
  data:&amp;:@:screen-cell<span class="Special"> &lt;- </span>new <span class="Constant">screen-cell:type</span>, bufsize
  *result<span class="Special"> &lt;- </span>merge h/num-rows, w/num-columns, <span class="Constant">0/cursor-row</span>, <span class="Constant">0/cursor-column</span>, data
  result<span class="Special"> &lt;- </span>clear-screen result
]

<span class="muRecipe">def</span> clear-screen screen:&amp;:screen<span class="muRecipe"> -&gt; </span>screen:&amp;:screen [
  <span class="Constant">local-scope</span>
  <span class="Constant">load-ingredients</span>
  <span class="Comment"># if x exists</span>
  <span class="Delimiter">{</span>
    <span class="muControl">break-unless</span> screen
    <span class="Comment"># clear fake screen</span>
    buf:&amp;:@:screen-cell<span class="Special"> &lt;- </span>get *screen, <span class="Constant">data:offset</span>
    max:num<span class="Special"> &lt;- </span>length *buf
    i:num<span class="Special"> &lt;- </span>copy <span class="Constant">0</span>
    <span class="Delimiter">{</span>
      done?:bool<span class="Special"> &lt;- </span>greater-or-equal i, max
      <span class="muControl">break-if</span> done?
      curr:screen-cell<span class="Special"> &lt;- </span>merge <span class="Constant">0/empty</span>, <span class="Constant">7/white</span>
      *buf<span class="Special"> &lt;- </span>put-index *buf, i, curr
      i<span class="Special"> &lt;- </span>add i, <span class="Constant">1</span>
      <span class="muControl">loop</span>
    <span class="Delimiter">}</span>
    <span class="Comment"># reset cursor</span>
    *screen<span class="Special"> &lt;- </span>put *screen, <span class="Constant">cursor-row:offset</span>, <span class="Constant">0</span>
    *screen<span class="Special"> &lt;- </span>put *screen, <span class="Constant">cursor-column:offset</span>, <span class="Constant">0</span>
    <span class="muControl">return</span>
  <span class="Delimiter">}</span>
  <span class="Comment"># otherwise, real screen</span>
  clear-display
]

<span class="muRecipe">def</span> sync-screen screen:&amp;:screen<span class="muRecipe"> -&gt; </span>screen:&amp;:screen [
  <span class="Constant">local-scope</span>
  <span class="Constant">load-ingredients</span>
  <span class="Delimiter">{</span>
    <span class="muControl">break-if</span> screen
    sync-display
  <span class="Delimiter">}</span>
  <span class="Comment"># do nothing for fake screens</span>
]

<span class="muRecipe">def</span> fake-screen-is-empty? screen:&amp;:screen<span class="muRecipe"> -&gt; </span>result:bool [
  <span class="Constant">local-scope</span>
  <span class="Constant">load-ingredients</span>
  <span class="muControl">return-unless</span> screen, <span class="Constant">1/true</span>
  buf:&amp;:@:screen-cell<span class="Special"> &lt;- </span>get *screen, <span class="Constant">data:offset</span>
  i:num<span class="Special"> &lt;- </span>copy <span class="Constant">0</span>
  len:num<span class="Special"> &lt;- </span>length *buf
  <span class="Delimiter">{</span>
    done?:bool<span class="Special"> &lt;- </span>greater-or-equal i, len
    <span class="muControl">break-if</span> done?
    curr:screen-cell<span class="Special"> &lt;- </span>index *buf, i
    curr-contents:char<span class="Special"> &lt;- </span>get curr, <span class="Constant">contents:offset</span>
    i<span class="Special"> &lt;- </span>add i, <span class="Constant">1</span>
    <span class="muControl">loop-unless</span> curr-contents
    <span class="Comment"># not 0</span>
    <span class="muControl">return</span> <span class="Constant">0/false</span>
  <span class="Delimiter">}</span>
  <span class="muControl">return</span> <span class="Constant">1/true</span>
]

<span class="muRecipe">def</span> print screen:&amp;:screen, c:char<span class="muRecipe"> -&gt; </span>screen:&amp;:screen [
  <span class="Constant">local-scope</span>
  <span class="Constant">load-ingredients</span>
  color:num, color-found?:bool<span class="Special"> &lt;- </span><span class="Constant">next-ingredient</span>
  <span class="Delimiter">{</span>
    <span class="Comment"># default color to white</span>
    <span class="muControl">break-if</span> color-found?
    color<span class="Special"> &lt;- </span>copy <span class="Constant">7/white</span>
  <span class="Delimiter">}</span>
  bg-color:num, bg-color-found?:bool<span class="Special"> &lt;- </span><span class="Constant">next-ingredient</span>
  <span class="Delimiter">{</span>
    <span class="Comment"># default bg-color to black</span>
    <span class="muControl">break-if</span> bg-color-found?
    bg-color<span class="Special"> &lt;- </span>copy <span class="Constant">0/black</span>
  <span class="Delimiter">}</span>
  c2:num<span class="Special"> &lt;- </span>character-to-code c
  trace <span class="Constant">90</span>, <span class="Constant">[print-character]</span>, c2
  <span class="Delimiter">{</span>
    <span class="Comment"># if x exists</span>
    <span class="Comment"># (handle special cases exactly like in the real screen)</span>
    <span class="muControl">break-unless</span> screen
    width:num<span class="Special"> &lt;- </span>get *screen, <span class="Constant">num-columns:offset</span>
    height:num<span class="Special"> &lt;- </span>get *screen, <span class="Constant">num-rows:offset</span>
    <span class="Comment"># if cursor is out of bounds, silently exit</span>
    row:num<span class="Special"> &lt;- </span>get *screen, <span class="Constant">cursor-row:offset</span>
    legal?:bool<span class="Special"> &lt;- </span>greater-or-equal row, <span class="Constant">0</span>
    <span class="muControl">return-unless</span> legal?
    legal?<span class="Special"> &lt;- </span>lesser-than row, height
    <span class="muControl">return-unless</span> legal?
    column:num<span class="Special"> &lt;- </span>get *screen, <span class="Constant">cursor-column:offset</span>
    legal?<span class="Special"> &lt;- </span>greater-or-equal column, <span class="Constant">0</span>
    <span class="muControl">return-unless</span> legal?
    legal?<span class="Special"> &lt;- </span>lesser-than column, width
    <span class="muControl">return-unless</span> legal?
<span class="CommentedCode">#?     $print [print-character (], row, [, ], column, [): ], c, 10/newline</span>
    <span class="Comment"># special-case: newline</span>
    <span class="Delimiter">{</span>
      newline?:bool<span class="Special"> &lt;- </span>equal c, <span class="Constant">10/newline</span>
      <span class="muControl">break-unless</span> newline?
      <span class="Delimiter">{</span>
        <span class="Comment"># unless cursor is already at bottom</span>
        bottom:num<span class="Special"> &lt;- </span>subtract height, <span class="Constant">1</span>
        at-bottom?:bool<span class="Special"> &lt;- </span>greater-or-equal row, bottom
        <span class="muControl">break-if</span> at-bottom?
        <span class="Comment"># move it to the next row</span>
        column<span class="Special"> &lt;- </span>copy <span class="Constant">0</span>
        *screen<span class="Special"> &lt;- </span>put *screen, <span class="Constant">cursor-column:offset</span>, column
        row<span class="Special"> &lt;- </span>add row, <span class="Constant">1</span>
        *screen<span class="Special"> &lt;- </span>put *screen, <span class="Constant">cursor-row:offset</span>, row
      <span class="Delimiter">}</span>
      <span class="muControl">return</span>
    <span class="Delimiter">}</span>
    <span class="Comment"># save character in fake screen</span>
    index:num<span class="Special"> &lt;- </span>multiply row, width
    index<span class="Special"> &lt;- </span>add index, column
    buf:&amp;:@:screen-cell<span class="Special"> &lt;- </span>get *screen, <span class="Constant">data:offset</span>
    len:num<span class="Special"> &lt;- </span>length *buf
    <span class="Comment"># special-case: backspace</span>
    <span class="Delimiter">{</span>
      backspace?:bool<span class="Special"> &lt;- </span>equal c, <span class="Constant">8</span>
      <span class="muControl">break-unless</span> backspace?
      <span class="Delimiter">{</span>
        <span class="Comment"># unless cursor is already at left margin</span>
        at-left?:bool<span class="Special"> &lt;- </span>lesser-or-equal column, <span class="Constant">0</span>
        <span class="muControl">break-if</span> at-left?
        <span class="Comment"># clear previous location</span>
        column<span class="Special"> &lt;- </span>subtract column, <span class="Constant">1</span>
        *screen<span class="Special"> &lt;- </span>put *screen, <span class="Constant">cursor-column:offset</span>, column
        index<span class="Special"> &lt;- </span>subtract index, <span class="Constant">1</span>
        cursor:screen-cell<span class="Special"> &lt;- </span>merge <span class="Constant">32/space</span>, <span class="Constant">7/white</span>
        *buf<span class="Special"> &lt;- </span>put-index *buf, index, cursor
      <span class="Delimiter">}</span>
      <span class="muControl">return</span>
    <span class="Delimiter">}</span>
    cursor:screen-cell<span class="Special"> &lt;- </span>merge c, color
    *buf<span class="Special"> &lt;- </span>put-index *buf, index, cursor
    <span class="Comment"># increment column unless it's already all the way to the right</span>
    <span class="Delimiter">{</span>
      right:num<span class="Special"> &lt;- </span>subtract width, <span class="Constant">1</span>
      at-right?:bool<span class="Special"> &lt;- </span>greater-or-equal column, right
      <span class="muControl">break-if</span> at-right?
      column<span class="Special"> &lt;- </span>add column, <span class="Constant">1</span>
      *screen<span class="Special"> &lt;- </span>put *screen, <span class="Constant">cursor-column:offset</span>, column
    <span class="Delimiter">}</span>
    <span class="muControl">return</span>
  <span class="Delimiter">}</span>
  <span class="Comment"># otherwise, real screen</span>
  print-character-to-display c, color, bg-color
]

<span class="muScenario">scenario</span> print-character-at-top-left [
  <span class="Constant">local-scope</span>
  fake-screen:&amp;:screen<span class="Special"> &lt;- </span>new-fake-screen <span class="Constant">3/width</span>, <span class="Constant">2/height</span>
  run [
    a:char<span class="Special"> &lt;- </span>copy <span class="Constant">97/a</span>
    fake-screen<span class="Special"> &lt;- </span>print fake-screen, a:char
    cell:&amp;:@:screen-cell<span class="Special"> &lt;- </span>get *fake-screen, <span class="Constant">data:offset</span>
    <span class="Constant">1</span>:@:screen-cell/<span class="Special">raw &lt;- </span>copy *cell
  ]
  memory-should-contain [
    <span class="Constant">1</span><span class="Special"> &lt;- </span><span class="Constant">6</span>  <span class="Comment"># width*height</span>
    <span class="Constant">2</span><span class="Special"> &lt;- </span><span class="Constant">97</span>  <span class="Comment"># 'a'</span>
    <span class="Constant">3</span><span class="Special"> &lt;- </span><span class="Constant">7</span>  <span class="Comment"># white</span>
    <span class="Comment"># rest of screen is empty</span>
    <span class="Constant">4</span><span class="Special"> &lt;- </span><span class="Constant">0</span>
  ]
]

<span class="muScenario">scenario</span> print-character-in-color [
  <span class="Constant">local-scope</span>
  fake-screen:&amp;:screen<span class="Special"> &lt;- </span>new-fake-screen <span class="Constant">3/width</span>, <span class="Constant">2/height</span>
  run [
    a:char<span class="Special"> &lt;- </span>copy <span class="Constant">97/a</span>
    fake-screen<span class="Special"> &lt;- </span>print fake-screen, a:char, <span class="Constant">1/red</span>
    cell:&amp;:@:screen-cell<span class="Special"> &lt;- </span>get *fake-screen, <span class="Constant">data:offset</span>
    <span class="Constant">1</span>:@:screen-cell/<span class="Special">raw &lt;- </span>copy *cell
  ]
  memory-should-contain [
    <span class="Constant">1</span><span class="Special"> &lt;- </span><span class="Constant">6</span>  <span class="Comment"># width*height</span>
    <span class="Constant">2</span><span class="Special"> &lt;- </span><span class="Constant">97</span>  <span class="Comment"># 'a'</span>
    <span class="Constant">3</span><span class="Special"> &lt;- </span><span class="Constant">1</span>  <span class="Comment"># red</span>
    <span class="Comment"># rest of screen is empty</span>
    <span class="Constant">4</span><span class="Special"> &lt;- </span><span class="Constant">0</span>
  ]
]

<span class="muScenario">scenario</span> print-backspace-character [
  <span class="Constant">local-scope</span>
  fake-screen:&amp;:screen<span class="Special"> &lt;- </span>new-fake-screen <span class="Constant">3/width</span>, <span class="Constant">2/height</span>
  a:char<span class="Special"> &lt;- </span>copy <span class="Constant">97/a</span>
  fake-screen<span class="Special"> &lt;- </span>print fake-screen, a
  run [
    backspace:char<span class="Special"> &lt;- </span>copy <span class="Constant">8/backspace</span>
    fake-screen<span class="Special"> &lt;- </span>print fake-screen, backspace
    <span class="Constant">10</span>:num/<span class="Special">raw &lt;- </span>get *fake-screen, <span class="Constant">cursor-column:offset</span>
    cell:&amp;:@:screen-cell<span class="Special"> &lt;- </span>get *fake-screen, <span class="Constant">data:offset</span>
    <span class="Constant">11</span>:@:screen-cell/<span class="Special">raw &lt;- </span>copy *cell
  ]
  memory-should-contain [
    <span class="Constant">10</span><span class="Special"> &lt;- </span><span class="Constant">0</span>  <span class="Comment"># cursor column</span>
    <span class="Constant">11</span><span class="Special"> &lt;- </span><span class="Constant">6</span>  <span class="Comment"># width*height</span>
    <span class="Constant">12</span><span class="Special"> &lt;- </span><span class="Constant">32</span>  <span class="Comment"># space, not 'a'</span>
    <span class="Constant">13</span><span class="Special"> &lt;- </span><span class="Constant">7</span>  <span class="Comment"># white</span>
    <span class="Comment"># rest of screen is empty</span>
    <span class="Constant">14</span><span class="Special"> &lt;- </span><span class="Constant">0</span>
  ]
]

<span class="muScenario">scenario</span> print-extra-backspace-character [
  <span class="Constant">local-scope</span>
  fake-screen:&amp;:screen<span class="Special"> &lt;- </span>new-fake-screen <span class="Constant">3/width</span>, <span class="Constant">2/height</span>
  a:char<span class="Special"> &lt;- </span>copy <span class="Constant">97/a</span>
  fake-screen<span class="Special"> &lt;- </span>print fake-screen, a
  run [
    backspace:char<span class="Special"> &lt;- </span>copy <span class="Constant">8/backspace</span>
    fake-screen<span class="Special"> &lt;- </span>print fake-screen, backspace
    fake-screen<span class="Special"> &lt;- </span>print fake-screen, backspace  <span class="Comment"># cursor already at left margin</span>
    <span class="Constant">1</span>:num/<span class="Special">raw &lt;- </span>get *fake-screen, <span class="Constant">cursor-column:offset</span>
    cell:&amp;:@:screen-cell<span class="Special"> &lt;- </span>get *fake-screen, <span class="Constant">data:offset</span>
    <span class="Constant">3</span>:@:screen-cell/<span class="Special">raw &lt;- </span>copy *cell
  ]
  memory-should-contain [
    <span class="Constant">1</span><span class="Special"> &lt;- </span><span class="Constant">0</span>  <span class="Comment"># cursor column</span>
    <span class="Constant">3</span><span class="Special"> &lt;- </span><span class="Constant">6</span>  <span class="Comment"># width*height</span>
    <span class="Constant">4</span><span class="Special"> &lt;- </span><span class="Constant">32</span>  <span class="Comment"># space, not 'a'</span>
    <span class="Constant">5</span><span class="Special"> &lt;- </span><span class="Constant">7</span>  <span class="Comment"># white</span>
    <span class="Comment"># rest of screen is empty</span>
    <span class="Constant">6</span><span class="Special"> &lt;- </span><span class="Constant">0</span>
  ]
]

<span class="muScenario">scenario</span> print-character-at-right-margin [
  <span class="Comment"># fill top row of screen with text</span>
  <span class="Constant">local-scope</span>
  fake-screen:&amp;:screen<span class="Special"> &lt;- </span>new-fake-screen <span class="Constant">2/width</span>, <span class="Constant">2/height</span>
  a:char<span class="Special"> &lt;- </span>copy <span class="Constant">97/a</span>
  fake-screen<span class="Special"> &lt;- </span>print fake-screen, a
  b:char<span class="Special"> &lt;- </span>copy <span class="Constant">98/b</span>
  fake-screen<span class="Special"> &lt;- </span>print fake-screen, b
  run [
    <span class="Comment"># cursor now at right margin</span>
    c:char<span class="Special"> &lt;- </span>copy <span class="Constant">99/c</span>
    fake-screen<span class="Special"> &lt;- </span>print fake-screen, c
    <span class="Constant">10</span>:num/<span class="Special">raw &lt;- </span>get *fake-screen, <span class="Constant">cursor-column:offset</span>
    cell:&amp;:@:screen-cell<span class="Special"> &lt;- </span>get *fake-screen, <span class="Constant">data:offset</span>
    <span class="Constant">11</span>:@:screen-cell/<span class="Special">raw &lt;- </span>copy *cell
  ]
  memory-should-contain [
    <span class="Constant">10</span><span class="Special"> &lt;- </span><span class="Constant">1</span>  <span class="Comment"># cursor column</span>
    <span class="Constant">11</span><span class="Special"> &lt;- </span><span class="Constant">4</span>  <span class="Comment"># width*height</span>
    <span class="Constant">12</span><span class="Special"> &lt;- </span><span class="Constant">97</span>  <span class="Comment"># 'a'</span>
    <span class="Constant">13</span><span class="Special"> &lt;- </span><span class="Constant">7</span>  <span class="Comment"># white</span>
    <span class="Constant">14</span><span class="Special"> &lt;- </span><span class="Constant">99</span>  <span class="Comment"># 'c' over 'b'</span>
    <span class="Constant">15</span><span class="Special"> &lt;- </span><span class="Constant">7</span>  <span class="Comment"># white</span>
    <span class="Comment"># rest of screen is empty</span>
    <span class="Constant">16</span><span class="Special"> &lt;- </span><span class="Constant">0</span>
  ]
]

<span class="muScenario">scenario</span> print-newline-character [
  <span class="Constant">local-scope</span>
  fake-screen:&amp;:screen<span class="Special"> &lt;- </span>new-fake-screen <span class="Constant">3/width</span>, <span class="Constant">2/height</span>
  a:char<span class="Special"> &lt;- </span>copy <span class="Constant">97/a</span>
  fake-screen<span class="Special"> &lt;- </span>print fake-screen, a
  run [
    newline:char<span class="Special"> &lt;- </span>copy <span class="Constant">10/newline</span>
    fake-screen<span class="Special"> &lt;- </span>print fake-screen, newline
    <span class="Constant">10</span>:num/<span class="Special">raw &lt;- </span>get *fake-screen, <span class="Constant">cursor-row:offset</span>
    <span class="Constant">11</span>:num/<span class="Special">raw &lt;- </span>get *fake-screen, <span class="Constant">cursor-column:offset</span>
    cell:&amp;:@:screen-cell<span class="Special"> &lt;- </span>get *fake-screen, <span class="Constant">data:offset</span>
    <span class="Constant">12</span>:@:screen-cell/<span class="Special">raw &lt;- </span>copy *cell
  ]
  memory-should-contain [
    <span class="Constant">10</span><span class="Special"> &lt;- </span><span class="Constant">1</span>  <span class="Comment"># cursor row</span>
    <span class="Constant">11</span><span class="Special"> &lt;- </span><span class="Constant">0</span>  <span class="Comment"># cursor column</span>
    <span class="Constant">12</span><span class="Special"> &lt;- </span><span class="Constant">6</span>  <span class="Comment"># width*height</span>
    <span class="Constant">13</span><span class="Special"> &lt;- </span><span class="Constant">97</span>  <span class="Comment"># 'a'</span>
    <span class="Constant">14</span><span class="Special"> &lt;- </span><span class="Constant">7</span>  <span class="Comment"># white</span>
    <span class="Comment"># rest of screen is empty</span>
    <span class="Constant">15</span><span class="Special"> &lt;- </span><span class="Constant">0</span>
  ]
]

<span class="muScenario">scenario</span> print-newline-at-bottom-line [
  <span class="Constant">local-scope</span>
  fake-screen:&amp;:screen<span class="Special"> &lt;- </span>new-fake-screen <span class="Constant">3/width</span>, <span class="Constant">2/height</span>
  newline:char<span class="Special"> &lt;- </span>copy <span class="Constant">10/newline</span>
  fake-screen<span class="Special"> &lt;- </span>print fake-screen, newline
  fake-screen<span class="Special"> &lt;- </span>print fake-screen, newline
  run [
    <span class="Comment"># cursor now at bottom of screen</span>
    fake-screen<span class="Special"> &lt;- </span>print fake-screen, newline
    <span class="Constant">10</span>:num/<span class="Special">raw &lt;- </span>get *fake-screen, <span class="Constant">cursor-row:offset</span>
    <span class="Constant">11</span>:num/<span class="Special">raw &lt;- </span>get *fake-screen, <span class="Constant">cursor-column:offset</span>
  ]
  <span class="Comment"># doesn't move further down</span>
  memory-should-contain [
    <span class="Constant">10</span><span class="Special"> &lt;- </span><span class="Constant">1</span>  <span class="Comment"># cursor row</span>
    <span class="Constant">11</span><span class="Special"> &lt;- </span><span class="Constant">0</span>  <span class="Comment"># cursor column</span>
  ]
]

<span class="muScenario">scenario</span> print-character-at-bottom-right [
  <span class="Constant">local-scope</span>
  fake-screen:&amp;:screen<span class="Special"> &lt;- </span>new-fake-screen <span class="Constant">2/width</span>, <span class="Constant">2/height</span>
  newline:char<span class="Special"> &lt;- </span>copy <span class="Constant">10/newline</span>
  fake-screen<span class="Special"> &lt;- </span>print fake-screen, newline
  a:char<span class="Special"> &lt;- </span>copy <span class="Constant">97/a</span>
  fake-screen<span class="Special"> &lt;- </span>print fake-screen, a
  b:char<span class="Special"> &lt;- </span>copy <span class="Constant">98/b</span>
  fake-screen<span class="Special"> &lt;- </span>print fake-screen, b
  c:char<span class="Special"> &lt;- </span>copy <span class="Constant">99/c</span>
  fake-screen<span class="Special"> &lt;- </span>print fake-screen, c
  fake-screen<span class="Special"> &lt;- </span>print fake-screen, newline
  run [
    <span class="Comment"># cursor now at bottom right</span>
    d:char<span class="Special"> &lt;- </span>copy <span class="Constant">100/d</span>
    fake-screen<span class="Special"> &lt;- </span>print fake-screen, d
    <span class="Constant">10</span>:num/<span class="Special">raw &lt;- </span>get *fake-screen, <span class="Constant">cursor-row:offset</span>
    <span class="Constant">11</span>:num/<span class="Special">raw &lt;- </span>get *fake-screen, <span class="Constant">cursor-column:offset</span>
    cell:&amp;:@:screen-cell<span class="Special"> &lt;- </span>get *fake-screen, <span class="Constant">data:offset</span>
    <span class="Constant">20</span>:@:screen-cell/<span class="Special">raw &lt;- </span>copy *cell
  ]
  memory-should-contain [
    <span class="Constant">10</span><span class="Special"> &lt;- </span><span class="Constant">1</span>  <span class="Comment"># cursor row</span>
    <span class="Constant">11</span><span class="Special"> &lt;- </span><span class="Constant">1</span>  <span class="Comment"># cursor column</span>
    <span class="Constant">20</span><span class="Special"> &lt;- </span><span class="Constant">4</span>  <span class="Comment"># width*height</span>
    <span class="Constant">21</span><span class="Special"> &lt;- </span><span class="Constant">0</span>  <span class="Comment"># unused</span>
    <span class="Constant">22</span><span class="Special"> &lt;- </span><span class="Constant">7</span>  <span class="Comment"># white</span>
    <span class="Constant">23</span><span class="Special"> &lt;- </span><span class="Constant">0</span>  <span class="Comment"># unused</span>
    <span class="Constant">24</span><span class="Special"> &lt;- </span><span class="Constant">7</span>  <span class="Comment"># white</span>
    <span class="Constant">25</span><span class="Special"> &lt;- </span><span class="Constant">97</span> <span class="Comment"># 'a'</span>
    <span class="Constant">26</span><span class="Special"> &lt;- </span><span class="Constant">7</span>  <span class="Comment"># white</span>
    <span class="Constant">27</span><span class="Special"> &lt;- </span><span class="Constant">100</span>  <span class="Comment"># 'd' over 'b' and 'c' and newline</span>
    <span class="Constant">28</span><span class="Special"> &lt;- </span><span class="Constant">7</span>  <span class="Comment"># white</span>
    <span class="Comment"># rest of screen is empty</span>
    <span class="Constant">29</span><span class="Special"> &lt;- </span><span class="Constant">0</span>
  ]
]

<span class="muRecipe">def</span> clear-line screen:&amp;:screen<span class="muRecipe"> -&gt; </span>screen:&amp;:screen [
  <span class="Constant">local-scope</span>
  <span class="Constant">load-ingredients</span>
  space:char<span class="Special"> &lt;- </span>copy <span class="Constant">0/nul</span>
  <span class="Comment"># if x exists, clear line in fake screen</span>
  <span class="Delimiter">{</span>
    <span class="muControl">break-unless</span> screen
    width:num<span class="Special"> &lt;- </span>get *screen, <span class="Constant">num-columns:offset</span>
    column:num<span class="Special"> &lt;- </span>get *screen, <span class="Constant">cursor-column:offset</span>
    original-column:num<span class="Special"> &lt;- </span>copy column
    <span class="Comment"># space over the entire line</span>
    <span class="Delimiter">{</span>
      right:num<span class="Special"> &lt;- </span>subtract width, <span class="Constant">1</span>
      done?:bool<span class="Special"> &lt;- </span>greater-or-equal column, right
      <span class="muControl">break-if</span> done?
      print screen, space
      column<span class="Special"> &lt;- </span>add column, <span class="Constant">1</span>
      <span class="muControl">loop</span>
    <span class="Delimiter">}</span>
    <span class="Comment"># now back to where the cursor was</span>
    *screen<span class="Special"> &lt;- </span>put *screen, <span class="Constant">cursor-column:offset</span>, original-column
    <span class="muControl">return</span>
  <span class="Delimiter">}</span>
  <span class="Comment"># otherwise, real screen</span>
  clear-line-on-display
]

<span class="muRecipe">def</span> clear-line-until screen:&amp;:screen, right:num/inclusive<span class="muRecipe"> -&gt; </span>screen:&amp;:screen [
  <span class="Constant">local-scope</span>
  <span class="Constant">load-ingredients</span>
  _, column:num<span class="Special"> &lt;- </span>cursor-position screen
  space:char<span class="Special"> &lt;- </span>copy <span class="Constant">32/space</span>
  bg-color:num, bg-color-found?:bool<span class="Special"> &lt;- </span><span class="Constant">next-ingredient</span>
  <span class="Delimiter">{</span>
    <span class="Comment"># default bg-color to black</span>
    <span class="muControl">break-if</span> bg-color-found?
    bg-color<span class="Special"> &lt;- </span>copy <span class="Constant">0/black</span>
  <span class="Delimiter">}</span>
  <span class="Delimiter">{</span>
    done?:bool<span class="Special"> &lt;- </span>greater-than column, right
    <span class="muControl">break-if</span> done?
    screen<span class="Special"> &lt;- </span>print screen, space, <span class="Constant">7/white</span>, bg-color  <span class="Comment"># foreground color is mostly unused except if the cursor shows up at this cell</span>
    column<span class="Special"> &lt;- </span>add column, <span class="Constant">1</span>
    <span class="muControl">loop</span>
  <span class="Delimiter">}</span>
]

<span class="muRecipe">def</span> cursor-position screen:&amp;:screen<span class="muRecipe"> -&gt; </span>row:num, column:num [
  <span class="Constant">local-scope</span>
  <span class="Constant">load-ingredients</span>
  <span class="Comment"># if x exists, lookup cursor in fake screen</span>
  <span class="Delimiter">{</span>
    <span class="muControl">break-unless</span> screen
    row:num<span class="Special"> &lt;- </span>get *screen, <span class="Constant">cursor-row:offset</span>
    column:num<span class="Special"> &lt;- </span>get *screen, <span class="Constant">cursor-column:offset</span>
    <span class="muControl">return</span>
  <span class="Delimiter">}</span>
  row, column<span class="Special"> &lt;- </span>cursor-position-on-display
]

<span class="muRecipe">def</span> move-cursor screen:&amp;:screen, new-row:num, new-column:num<span class="muRecipe"> -&gt; </span>screen:&amp;:screen [
  <span class="Constant">local-scope</span>
  <span class="Constant">load-ingredients</span>
  <span class="Comment"># if x exists, move cursor in fake screen</span>
  <span class="Delimiter">{</span>
    <span class="muControl">break-unless</span> screen
    *screen<span class="Special"> &lt;- </span>put *screen, <span class="Constant">cursor-row:offset</span>, new-row
    *screen<span class="Special"> &lt;- </span>put *screen, <span class="Constant">cursor-column:offset</span>, new-column
    <span class="muControl">return</span>
  <span class="Delimiter">}</span>
  <span class="Comment"># otherwise, real screen</span>
  move-cursor-on-display new-row, new-column
]

<span class="muScenario">scenario</span> clear-line-erases-printed-characters [
  <span class="Constant">local-scope</span>
  fake-screen:&amp;:screen<span class="Special"> &lt;- </span>new-fake-screen <span class="Constant">3/width</span>, <span class="Constant">2/height</span>
  <span class="Comment"># print a character</span>
  a:char<span class="Special"> &lt;- </span>copy <span class="Constant">97/a</span>
  fake-screen<span class="Special"> &lt;- </span>print fake-screen, a
  <span class="Comment"># move cursor to start of line</span>
  fake-screen<span class="Special"> &lt;- </span>move-cursor fake-screen, <span class="Constant">0/row</span>, <span class="Constant">0/column</span>
  run [
    fake-screen<span class="Special"> &lt;- </span>clear-line fake-screen
    cell:&amp;:@:screen-cell<span class="Special"> &lt;- </span>get *fake-screen, <span class="Constant">data:offset</span>
    <span class="Constant">10</span>:@:screen-cell/<span class="Special">raw &lt;- </span>copy *cell
  ]
  <span class="Comment"># screen should be blank</span>
  memory-should-contain [
    <span class="Constant">10</span><span class="Special"> &lt;- </span><span class="Constant">6</span>  <span class="Comment"># width*height</span>
    <span class="Constant">11</span><span class="Special"> &lt;- </span><span class="Constant">0</span>
    <span class="Constant">12</span><span class="Special"> &lt;- </span><span class="Constant">7</span>
    <span class="Constant">13</span><span class="Special"> &lt;- </span><span class="Constant">0</span>
    <span class="Constant">14</span><span class="Special"> &lt;- </span><span class="Constant">7</span>
    <span class="Constant">15</span><span class="Special"> &lt;- </span><span class="Constant">0</span>
    <span class="Constant">16</span><span class="Special"> &lt;- </span><span class="Constant">7</span>
    <span class="Constant">17</span><span class="Special"> &lt;- </span><span class="Constant">0</span>
    <span class="Constant">18</span><span class="Special"> &lt;- </span><span class="Constant">7</span>
    <span class="Constant">19</span><span class="Special"> &lt;- </span><span class="Constant">0</span>
    <span class="Constant">20</span><span class="Special"> &lt;- </span><span class="Constant">7</span>
    <span class="Constant">21</span><span class="Special"> &lt;- </span><span class="Constant">0</span>
    <span class="Constant">22</span><span class="Special"> &lt;- </span><span class="Constant">7</span>
  ]
]

<span class="muRecipe">def</span> cursor-down screen:&amp;:screen<span class="muRecipe"> -&gt; </span>screen:&amp;:screen [
  <span class="Constant">local-scope</span>
  <span class="Constant">load-ingredients</span>
  <span class="Comment"># if x exists, move cursor in fake screen</span>
  <span class="Delimiter">{</span>
    <span class="muControl">break-unless</span> screen
    <span class="Delimiter">{</span>
      <span class="Comment"># increment row unless it's already all the way down</span>
      height:num<span class="Special"> &lt;- </span>get *screen, <span class="Constant">num-rows:offset</span>
      row:num<span class="Special"> &lt;- </span>get *screen, <span class="Constant">cursor-row:offset</span>
      max:num<span class="Special"> &lt;- </span>subtract height, <span class="Constant">1</span>
      at-bottom?:bool<span class="Special"> &lt;- </span>greater-or-equal row, max
      <span class="muControl">break-if</span> at-bottom?
      row<span class="Special"> &lt;- </span>add row, <span class="Constant">1</span>
      *screen<span class="Special"> &lt;- </span>put *screen, <span class="Constant">cursor-row:offset</span>, row
    <span class="Delimiter">}</span>
    <span class="muControl">return</span>
  <span class="Delimiter">}</span>
  <span class="Comment"># otherwise, real screen</span>
  move-cursor-down-on-display
]

<span class="muRecipe">def</span> cursor-up screen:&amp;:screen<span class="muRecipe"> -&gt; </span>screen:&amp;:screen [
  <span class="Constant">local-scope</span>
  <span class="Constant">load-ingredients</span>
  <span class="Comment"># if x exists, move cursor in fake screen</span>
  <span class="Delimiter">{</span>
    <span class="muControl">break-unless</span> screen
    <span class="Delimiter">{</span>
      <span class="Comment"># decrement row unless it's already all the way up</span>
      row:num<span class="Special"> &lt;- </span>get *screen, <span class="Constant">cursor-row:offset</span>
      at-top?:bool<span class="Special"> &lt;- </span>lesser-or-equal row, <span class="Constant">0</span>
      <span class="muControl">break-if</span> at-top?
      row<span class="Special"> &lt;- </span>subtract row, <span class="Constant">1</span>
      *screen<span class="Special"> &lt;- </span>put *screen, <span class="Constant">cursor-row:offset</span>, row
    <span class="Delimiter">}</span>
    <span class="muControl">return</span>
  <span class="Delimiter">}</span>
  <span class="Comment"># otherwise, real screen</span>
  move-cursor-up-on-display
]

<span class="muRecipe">def</span> cursor-right screen:&amp;:screen<span class="muRecipe"> -&gt; </span>screen:&amp;:screen [
  <span class="Constant">local-scope</span>
  <span class="Constant">load-ingredients</span>
  <span class="Comment"># if x exists, move cursor in fake screen</span>
  <span class="Delimiter">{</span>
    <span class="muControl">break-unless</span> screen
    <span class="Delimiter">{</span>
      <span class="Comment"># increment column unless it's already all the way to the right</span>
      width:num<span class="Special"> &lt;- </span>get *screen, <span class="Constant">num-columns:offset</span>
      column:num<span class="Special"> &lt;- </span>get *screen, <span class="Constant">cursor-column:offset</span>
      max:num<span class="Special"> &lt;- </span>subtract width, <span class="Constant">1</span>
      at-bottom?:bool<span class="Special"> &lt;- </span>greater-or-equal column, max
      <span class="muControl">break-if</span> at-bottom?
      column<span class="Special"> &lt;- </span>add column, <span class="Constant">1</span>
      *screen<span class="Special"> &lt;- </span>put *screen, <span class="Constant">cursor-column:offset</span>, column
    <span class="Delimiter">}</span>
    <span class="muControl">return</span>
  <span class="Delimiter">}</span>
  <span class="Comment"># otherwise, real screen</span>
  move-cursor-right-on-display
]

<span class="muRecipe">def</span> cursor-left screen:&amp;:screen<span class="muRecipe"> -&gt; </span>screen:&amp;:screen [
  <span class="Constant">local-scope</span>
  <span class="Constant">load-ingredients</span>
  <span class="Comment"># if x exists, move cursor in fake screen</span>
  <span class="Delimiter">{</span>
    <span class="muControl">break-unless</span> screen
    <span class="Delimiter">{</span>
      <span class="Comment"># decrement column unless it's already all the way to the left</span>
      column:num<span class="Special"> &lt;- </span>get *screen, <span class="Constant">cursor-column:offset</span>
      at-top?:bool<span class="Special"> &lt;- </span>lesser-or-equal column, <span class="Constant">0</span>
      <span class="muControl">break-if</span> at-top?
      column<span class="Special"> &lt;- </span>subtract column, <span class="Constant">1</span>
      *screen<span class="Special"> &lt;- </span>put *screen, <span class="Constant">cursor-column:offset</span>, column
    <span class="Delimiter">}</span>
    <span class="muControl">return</span>
  <span class="Delimiter">}</span>
  <span class="Comment"># otherwise, real screen</span>
  move-cursor-left-on-display
]

<span class="muRecipe">def</span> cursor-to-start-of-line screen:&amp;:screen<span class="muRecipe"> -&gt; </span>screen:&amp;:screen [
  <span class="Constant">local-scope</span>
  <span class="Constant">load-ingredients</span>
  row:num<span class="Special"> &lt;- </span>cursor-position screen
  column:num<span class="Special"> &lt;- </span>copy <span class="Constant">0</span>
  screen<span class="Special"> &lt;- </span>move-cursor screen, row, column
]

<span class="muRecipe">def</span> cursor-to-next-line screen:&amp;:screen<span class="muRecipe"> -&gt; </span>screen:&amp;:screen [
  <span class="Constant">local-scope</span>
  <span class="Constant">load-ingredients</span>
  screen<span class="Special"> &lt;- </span>cursor-down screen
  screen<span class="Special"> &lt;- </span>cursor-to-start-of-line screen
]

<span class="muRecipe">def</span> move-cursor-to-column screen:&amp;:screen, column:num<span class="muRecipe"> -&gt; </span>screen:&amp;:screen [
  <span class="Constant">local-scope</span>
  <span class="Constant">load-ingredients</span>
  row:num, _<span class="Special"> &lt;- </span>cursor-position screen
  move-cursor screen, row, column
]

<span class="muRecipe">def</span> screen-width screen:&amp;:screen<span class="muRecipe"> -&gt; </span>width:num [
  <span class="Constant">local-scope</span>
  <span class="Constant">load-ingredients</span>
  <span class="Comment"># if x exists, move cursor in fake screen</span>
  <span class="Delimiter">{</span>
    <span class="muControl">break-unless</span> screen
    width<span class="Special"> &lt;- </span>get *screen, <span class="Constant">num-columns:offset</span>
    <span class="muControl">return</span>
  <span class="Delimiter">}</span>
  <span class="Comment"># otherwise, real screen</span>
  width<span class="Special"> &lt;- </span>display-width
]

<span class="muRecipe">def</span> screen-height screen:&amp;:screen<span class="muRecipe"> -&gt; </span>height:num [
  <span class="Constant">local-scope</span>
  <span class="Constant">load-ingredients</span>
  <span class="Comment"># if x exists, move cursor in fake screen</span>
  <span class="Delimiter">{</span>
    <span class="muControl">break-unless</span> screen
    height<span class="Special"> &lt;- </span>get *screen, <span class="Constant">num-rows:offset</span>
    <span class="muControl">return</span>
  <span class="Delimiter">}</span>
  <span class="Comment"># otherwise, real screen</span>
  height<span class="Special"> &lt;- </span>display-height
]

<span class="muRecipe">def</span> hide-cursor screen:&amp;:screen<span class="muRecipe"> -&gt; </span>screen:&amp;:screen [
  <span class="Constant">local-scope</span>
  <span class="Constant">load-ingredients</span>
  <span class="Comment"># if x exists (not real display), do nothing</span>
  <span class="Delimiter">{</span>
    <span class="muControl">break-unless</span> screen
    <span class="muControl">return</span>
  <span class="Delimiter">}</span>
  <span class="Comment"># otherwise, real screen</span>
  hide-cursor-on-display
]

<span class="muRecipe">def</span> show-cursor screen:&amp;:screen<span class="muRecipe"> -&gt; </span>screen:&amp;:screen [
  <span class="Constant">local-scope</span>
  <span class="Constant">load-ingredients</span>
  <span class="Comment"># if x exists (not real display), do nothing</span>
  <span class="Delimiter">{</span>
    <span class="muControl">break-unless</span> screen
    <span class="muControl">return</span>
  <span class="Delimiter">}</span>
  <span class="Comment"># otherwise, real screen</span>
  show-cursor-on-display
]

<span class="muRecipe">def</span> hide-screen screen:&amp;:screen<span class="muRecipe"> -&gt; </span>screen:&amp;:screen [
  <span class="Constant">local-scope</span>
  <span class="Constant">load-ingredients</span>
  <span class="Comment"># if x exists (not real display), do nothing</span>
  <span class="Comment"># todo: help test this</span>
  <span class="Delimiter">{</span>
    <span class="muControl">break-unless</span> screen
    <span class="muControl">return</span>
  <span class="Delimiter">}</span>
  <span class="Comment"># otherwise, real screen</span>
  hide-display
]

<span class="muRecipe">def</span> show-screen screen:&amp;:screen<span class="muRecipe"> -&gt; </span>screen:&amp;:screen [
  <span class="Constant">local-scope</span>
  <span class="Constant">load-ingredients</span>
  <span class="Comment"># if x exists (not real display), do nothing</span>
  <span class="Comment"># todo: help test this</span>
  <span class="Delimiter">{</span>
    <span class="muControl">break-unless</span> screen
    <span class="muControl">return</span>
  <span class="Delimiter">}</span>
  <span class="Comment"># otherwise, real screen</span>
  show-display
]

<span class="muRecipe">def</span> print screen:&amp;:screen, s:text<span class="muRecipe"> -&gt; </span>screen:&amp;:screen [
  <span class="Constant">local-scope</span>
  <span class="Constant">load-ingredients</span>
  color:num, color-found?:bool<span class="Special"> &lt;- </span><span class="Constant">next-ingredient</span>
  <span class="Delimiter">{</span>
    <span class="Comment"># default color to white</span>
    <span class="muControl">break-if</span> color-found?
    color<span class="Special"> &lt;- </span>copy <span class="Constant">7/white</span>
  <span class="Delimiter">}</span>
  bg-color:num, bg-color-found?:bool<span class="Special"> &lt;- </span><span class="Constant">next-ingredient</span>
  <span class="Delimiter">{</span>
    <span class="Comment"># default bg-color to black</span>
    <span class="muControl">break-if</span> bg-color-found?
    bg-color<span class="Special"> &lt;- </span>copy <span class="Constant">0/black</span>
  <span class="Delimiter">}</span>
  len:num<span class="Special"> &lt;- </span>length *s
  i:num<span class="Special"> &lt;- </span>copy <span class="Constant">0</span>
  <span class="Delimiter">{</span>
    done?:bool<span class="Special"> &lt;- </span>greater-or-equal i, len
    <span class="muControl">break-if</span> done?
    c:char<span class="Special"> &lt;- </span>index *s, i
    print screen, c, color, bg-color
    i<span class="Special"> &lt;- </span>add i, <span class="Constant">1</span>
    <span class="muControl">loop</span>
  <span class="Delimiter">}</span>
]

<span class="muScenario">scenario</span> print-text-stops-at-right-margin [
  <span class="Constant">local-scope</span>
  fake-screen:&amp;:screen<span class="Special"> &lt;- </span>new-fake-screen <span class="Constant">3/width</span>, <span class="Constant">2/height</span>
  run [
    fake-screen<span class="Special"> &lt;- </span>print fake-screen, <span class="Constant">[abcd]</span>
    cell:&amp;:@:screen-cell<span class="Special"> &lt;- </span>get *fake-screen, <span class="Constant">data:offset</span>
    <span class="Constant">10</span>:@:screen-cell/<span class="Special">raw &lt;- </span>copy *cell
  ]
  memory-should-contain [
    <span class="Constant">10</span><span class="Special"> &lt;- </span><span class="Constant">6</span>  <span class="Comment"># width*height</span>
    <span class="Constant">11</span><span class="Special"> &lt;- </span><span class="Constant">97</span>  <span class="Comment"># 'a'</span>
    <span class="Constant">12</span><span class="Special"> &lt;- </span><span class="Constant">7</span>  <span class="Comment"># white</span>
    <span class="Constant">13</span><span class="Special"> &lt;- </span><span class="Constant">98</span>  <span class="Comment"># 'b'</span>
    <span class="Constant">14</span><span class="Special"> &lt;- </span><span class="Constant">7</span>  <span class="Comment"># white</span>
    <span class="Constant">15</span><span class="Special"> &lt;- </span><span class="Constant">100</span>  <span class="Comment"># 'd' overwrites 'c'</span>
    <span class="Constant">16</span><span class="Special"> &lt;- </span><span class="Constant">7</span>  <span class="Comment"># white</span>
    <span class="Comment"># rest of screen is empty</span>
    <span class="Constant">17</span><span class="Special"> &lt;- </span><span class="Constant">0</span>
  ]
]

<span class="muRecipe">def</span> print-integer screen:&amp;:screen, n:num<span class="muRecipe"> -&gt; </span>screen:&amp;:screen [
  <span class="Constant">local-scope</span>
  <span class="Constant">load-ingredients</span>
  color:num, color-found?:bool<span class="Special"> &lt;- </span><span class="Constant">next-ingredient</span>
  <span class="Delimiter">{</span>
    <span class="Comment"># default color to white</span>
    <span class="muControl">break-if</span> color-found?
    color<span class="Special"> &lt;- </span>copy <span class="Constant">7/white</span>
  <span class="Delimiter">}</span>
  bg-color:num, bg-color-found?:bool<span class="Special"> &lt;- </span><span class="Constant">next-ingredient</span>
  <span class="Delimiter">{</span>
    <span class="Comment"># default bg-color to black</span>
    <span class="muControl">break-if</span> bg-color-found?
    bg-color<span class="Special"> &lt;- </span>copy <span class="Constant">0/black</span>
  <span class="Delimiter">}</span>
  <span class="Comment"># todo: other bases besides decimal</span>
  s:text<span class="Special"> &lt;- </span>to-text n
  screen<span class="Special"> &lt;- </span>print screen, s, color, bg-color
]

<span class="Comment"># for now, we can only print integers</span>
<span class="muRecipe">def</span> print screen:&amp;:screen, n:num<span class="muRecipe"> -&gt; </span>screen:&amp;:screen [
  <span class="Constant">local-scope</span>
  <span class="Constant">load-ingredients</span>
  color:num, color-found?:bool<span class="Special"> &lt;- </span><span class="Constant">next-ingredient</span>
  <span class="Delimiter">{</span>
    <span class="Comment"># default color to white</span>
    <span class="muControl">break-if</span> color-found?
    color<span class="Special"> &lt;- </span>copy <span class="Constant">7/white</span>
  <span class="Delimiter">}</span>
  bg-color:num, bg-color-found?:bool<span class="Special"> &lt;- </span><span class="Constant">next-ingredient</span>
  <span class="Delimiter">{</span>
    <span class="Comment"># default bg-color to black</span>
    <span class="muControl">break-if</span> bg-color-found?
    bg-color<span class="Special"> &lt;- </span>copy <span class="Constant">0/black</span>
  <span class="Delimiter">}</span>
  screen<span class="Special"> &lt;- </span>print-integer screen, n, color, bg-color
]

<span class="Comment"># addresses</span>
<span class="muRecipe">def</span> print screen:&amp;:screen, n:&amp;:_elem<span class="muRecipe"> -&gt; </span>screen:&amp;:screen [
  <span class="Constant">local-scope</span>
  <span class="Constant">load-ingredients</span>
  color:num, color-found?:bool<span class="Special"> &lt;- </span><span class="Constant">next-ingredient</span>
  <span class="Delimiter">{</span>
    <span class="Comment"># default color to white</span>
    <span class="muControl">break-if</span> color-found?
    color<span class="Special"> &lt;- </span>copy <span class="Constant">7/white</span>
  <span class="Delimiter">}</span>
  bg-color:num, bg-color-found?:bool<span class="Special"> &lt;- </span><span class="Constant">next-ingredient</span>
  <span class="Delimiter">{</span>
    <span class="Comment"># default bg-color to black</span>
    <span class="muControl">break-if</span> bg-color-found?
    bg-color<span class="Special"> &lt;- </span>copy <span class="Constant">0/black</span>
  <span class="Delimiter">}</span>
  n2:num<span class="Special"> &lt;- </span>copy n
  screen<span class="Special"> &lt;- </span>print-integer screen, n2, color, bg-color
]
</pre>
</body>
</html>
<!-- vim: set foldmethod=manual : -->