about summary refs log blame commit diff stats
path: root/html/080display.cc.html
blob: e3546ae01edc7d6c8468b3390deafd934ea66348 (plain) (tree)
1
2
3
4
5
6
7
8
9
10



                                                                                          
                                 

                                                
                                  

                                                                                         

                       
                                                                                                 
                                                                                            
                                      
                             

                             
                              
                                   

                                                                           
                            

        





                               

       
                         


                                                                                                          
 


                                                                

                                                                                                                
                                                                                                                 
 

















                                                                                                                                                                                                                                                                                                                                                                               
                                                                                      
                                            
                                                                                 

                                                                                                                                                                                                                      
                                                                               

                                                                       
                                                                                         
                                                                               

                                                                                                

                                                                                      

                                                                                                                                                                                                                                            
                                                                                                                                                                                                                                                                                 
                                                                                                                                              
                                                                                                                                                                                                                                                                                  



                                                                                      
                                             
                                                                                 

                                                                                                                                                                                                                        
                                                                                

                                                                       
                                                                                         
                                                                                



                                                                       


                                                                 


                                                                                      

                                                                                                                                                                                                                        
                                                                                

                                                                       
                                                                                         
                                                                                
                                              





                                                                                                

                                                                                 

                                                                                                                                                                                                                      
                                                                               

                                                                       
                                                                                         
                                                                               
                                              




                                                                                      

                                                                                 

                                                                                                                                                                                                                                        
                                                                                        

                                                                       
                                                                                         
                                                                                        
                                              

                                                                                                                                                                                                                                                                      
                                                                                                                                                                                                                                                                                    

                                                                                                                                          
                                                                                                                                                         





                                                                                      

                                                                                                                                                                                                                                                  

                                                                                                                                                                                                                        
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

                                                                         
                                                                                                                                                                                                                                                                                                                                 
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         

                                                                         

                                                                                                                                                                                                                                                                                                                                   
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          


                                                                           

                                                                                                                                                                                                                                                                                                                                   
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         





                                                                                         
                                                                                             
                                              
                                                                                                                            


                                                                                                                                                                                                                                                                                     

                                                                                                                                                                                                                                                      
                                                                                                                                                                                                                                                           
                                  

                                                                                                                                                                                                                                                      
                                                                                                                                                                                                                                                              
                                                                                                                                                                                                  

                                                                                                                                                                                                                                                            

                                                                                                                                                                                                                    


                                                                                                                                              
                                                                                                                                                             


                                                                         

                                                                                                                                                                                       
                                                                                                                                                                                                                                                                                                                                

                                                                                                                                              
                                                                                                                                                             


                                                                         
                                                                                                                                                                                           
                                                    

                                                                                                                                            
                                                                                                                                                         





                                                                                      

                                                                                                                                                                                                                                                  
                                                                                             

                                                                       
                                                                                         
                                                                                             
                                              


                                                                                                                                                                                                                                    





                                                                                      

                                                                                                                                                                                                                                          

                                                                                                                                                                                                                                                                                        
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

                                                                         
                                                                                                                                                                                                                                                                                                                                 
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      

                                                                         
                                                                                                                                                                                                                                                                                                                                 
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          

                                                                         


                                                                                         
                                                                                         
                                              
                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                  
                                                                                                                                          
                                                                                                                                                         





                                                                                      

                                                                                                                                                                                                                                                    
                                                                                              

                                                                       
                                                                                         
                                                                                              
                                              
                                                                               
                                                                                                                                                                                                                        
                                                                                                                                                                                         
                                                 
                                                                                                                                            
                                                                                                                                                           
                                  





                                                                                      

                                                                                                                                                                                                                                                
                                                                                            

                                                                       
                                                                                         
                                                                                            
                                              
                                                                                                                                                                                  
                                                 
                                                                                                                                            
                                                                                                                                                           
                                  





                                                                                      

                                                                                                                                                                                                                                                      
                                                                                               

                                                                       
                                                                                         
                                                                                               
                                              
                                                                              
                                                                                                                                                                                                                       
                                                                                                                                                                                           
                                                    
                                                                                                                                            
                                                                                                                                                           
                                  





                                                                                      

                                                                                                                                                                                                                                                    
                                                                                              

                                                                       
                                                                                         
                                                                                              
                                              
                                                                                                                                                                                     
                                                    
                                                                                                                                            
                                                                                                                                                           
                                  


                                                                       






                                                                                                                                                                               
                                                                                                                                                                                                                                          





                                                                                                                                                         


                                                                                      

                                                                                                                                                                                                                        
                                                                                

                                                                       
                                                                                         
                                                                                
                                              







                                                                                                                                                                                                                                

                                                                                                                                                                                                                          
                                                                                 

                                                                       
                                                                                         
                                                                                 
                                              




                                                                                                                                                                                                                                 


                                                                                      

                                                                                                                                                                                                                                          
                                                                                         

                                                                       
                                                                                         
                                                                                         
                                              






                                                                                                                                             

                                                                                                                                                                                                                                          
                                                                                         

                                                                       
                                                                                         
                                                                                         
                                              






                                                                                                                                          

                                                                                                                                                                                                                      
                                                                               

                                                                       
                                                                                         
                                                                               
                                              






                                                                                      

                                                                                                                                                                                                                      
                                                                               

                                                                       
                                                                                         
                                                                               
                                              




                                                                                  
                                                                  

                                                                                      
                                                         
                                                                                 

                                                                                                                                                                                                                                                
                                                                                            

                                                                       
                                                                                         
                                                                                            
                                              
                                                
                                                                                          



                                                                                      
                                                     
                                                                                 

                                                                                                                                                                                                                                        
                                                                                        

                                                                       
                                                                                         
                                                                                        
                                               
                                                                                                                                                                                                   
                                                

                                                                                                                                                                                                                                                                                                    







                                                                                                                                                                                                                                                                                                                                                            
                                                                                                                                                                                                                                                        
                                                                                                                                                                                                                                                                                                                                                            
                                                                                                                                                                                             
                                                   

                                                                                                          

                                                                                                                                                                                                                                                               






                                                                                                                                                                                                                                                                                                                                                          
                                                                                                                                                            





                                                                                                                                                                                                                                                                                                                                                               
                                  
                                                                                                                                                              
                                                                                                                                                                                                                                                                                                                                                             





                                                                                                                                                                                                                                                                                                                                                          
                                                                                                                                                               







                                                                                                                                                                                                                                                                                                                                                              




                                                                                                                                                                                                                                                                                                                                                         

                                                                       



                                                                                      

                                                                                                                                                                                                                                 
                                                                                    

                                                                       
                                                                                         
                                                                                    
                                               



                                                                                                                                                                                                                                      





                                                                                      

                                                                                                                                                                                                                                  
                                                                                     

                                                                       
                                                                                         
                                                                                     
                                              
                                                      






                                                                                                                                                                                                                                                                                                                               


                                                                                                                                                                                                                                                                                   
                                                                                                                                                         

                                                                       


       
                                     
<!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 - 080display.cc</title>
<meta name="Generator" content="Vim/7.4">
<meta name="plugin-version" content="vim7.4_v2">
<meta name="syntax" content="cpp">
<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; }
.Constant { color: #00a0a0; }
.cSpecial { color: #008000; }
.Comment { color: #9090ff; }
.Delimiter { color: #800080; }
.SalientComment { color: #00ffff; }
.Identifier { color: #fcb165; }
.Normal { color: #eeeeee; background-color: #080808; padding-bottom: 1px; }
.PreProc { color: #800080; }
-->
</style>

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

-->
</script>
</head>
<body>
<pre id='vimCodeElement'>
<span class="Comment">//: Take raw control of the text-mode display and console, putting it in</span>
<span class="Comment">//: 'console' mode rather than the usual automatically-scrolling 'typewriter'</span>
<span class="Comment">//: mode.</span>

<span class="SalientComment">//:: Display management</span>

<span class="Delimiter">:(before &quot;End Globals&quot;)</span>
<span class="Normal">int</span> Display_row = <span class="Constant">0</span><span class="Delimiter">;</span>
<span class="Normal">int</span> Display_column = <span class="Constant">0</span><span class="Delimiter">;</span>
<span class="Normal">bool</span> Autodisplay = <span class="Constant">true</span><span class="Delimiter">;</span>

<span class="Delimiter">:(before &quot;End Includes&quot;)</span>
<span class="PreProc">#define CHECK_SCREEN \</span>
<span class="PreProc">    </span><span class="Normal">if</span><span class="PreProc"> (!tb_is_active()) </span><span class="Delimiter">{</span><span class="PreProc"> \</span>
<span class="PreProc">      </span><span class="Normal">if</span><span class="PreProc"> (Run_tests) \</span>
<span class="PreProc">        raise &lt;&lt; maybe(current_recipe_name()) &lt;&lt; </span><span class="Constant">&quot;tried to print to real screen before 'open-console'</span><span class="cSpecial">\n</span><span class="Constant">&quot;</span><span class="PreProc"> &lt;&lt; end()</span><span class="Delimiter">;</span><span class="PreProc"> \</span>
<span class="PreProc">      </span><span class="Normal">else</span><span class="PreProc"> \</span>
<span class="PreProc">        raise &lt;&lt; maybe(current_recipe_name()) &lt;&lt; </span><span class="Constant">&quot;tried to print to real screen in a test!</span><span class="cSpecial">\n</span><span class="Constant">&quot;</span><span class="PreProc"> &lt;&lt; end()</span><span class="Delimiter">;</span><span class="PreProc"> \</span>
<span class="PreProc">      </span><span class="Identifier">break</span><span class="Delimiter">;</span><span class="PreProc"> \</span>
<span class="PreProc">    </span><span class="Delimiter">}</span>
<span class="PreProc">#define CHECK_CONSOLE \</span>
<span class="PreProc">    </span><span class="Normal">if</span><span class="PreProc"> (!tb_is_active()) </span><span class="Delimiter">{</span><span class="PreProc"> \</span>
<span class="PreProc">      </span><span class="Normal">if</span><span class="PreProc"> (Run_tests) \</span>
<span class="PreProc">        raise &lt;&lt; maybe(current_recipe_name()) &lt;&lt; </span><span class="Constant">&quot;tried to read event from real keyboard/mouse before 'open-console'</span><span class="cSpecial">\n</span><span class="Constant">&quot;</span><span class="PreProc"> &lt;&lt; end()</span><span class="Delimiter">;</span><span class="PreProc"> \</span>
<span class="PreProc">      </span><span class="Normal">else</span><span class="PreProc"> \</span>
<span class="PreProc">        raise &lt;&lt; maybe(current_recipe_name()) &lt;&lt; </span><span class="Constant">&quot;tried to read event from real keyboard/mouse in a test!</span><span class="cSpecial">\n</span><span class="Constant">&quot;</span><span class="PreProc"> &lt;&lt; end()</span><span class="Delimiter">;</span><span class="PreProc"> \</span>
<span class="PreProc">      </span><span class="Identifier">break</span><span class="Delimiter">;</span><span class="PreProc"> \</span>
<span class="PreProc">    </span><span class="Delimiter">}</span>

<span class="Delimiter">:(before &quot;End Primitive Recipe Declarations&quot;)</span>
OPEN_CONSOLE<span class="Delimiter">,</span>
<span class="Delimiter">:(before &quot;End Primitive Recipe Numbers&quot;)</span>
put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> <span class="Constant">&quot;open-console&quot;</span><span class="Delimiter">,</span> OPEN_CONSOLE<span class="Delimiter">);</span>
<span class="Delimiter">:(before &quot;End Primitive Recipe Checks&quot;)</span>
<span class="Normal">case</span> OPEN_CONSOLE: <span class="Delimiter">{</span>
  <span class="Identifier">break</span><span class="Delimiter">;</span>
<span class="Delimiter">}</span>
<span class="Delimiter">:(before &quot;End Primitive Recipe Implementations&quot;)</span>
<span class="Normal">case</span> OPEN_CONSOLE: <span class="Delimiter">{</span>
  tb_init<span class="Delimiter">();</span>
  Display_row = Display_column = <span class="Constant">0</span><span class="Delimiter">;</span>
  <span class="Normal">int</span> width = tb_width<span class="Delimiter">();</span>
  <span class="Normal">int</span> height = tb_height<span class="Delimiter">();</span>
  <span class="Normal">if</span> <span class="Delimiter">(</span>width &gt; <span class="Constant">222</span> || height &gt; <span class="Constant">222</span><span class="Delimiter">)</span> tb_shutdown<span class="Delimiter">();</span>
  <span class="Normal">if</span> <span class="Delimiter">(</span>width &gt; <span class="Constant">222</span><span class="Delimiter">)</span>
    raise &lt;&lt; <span class="Constant">&quot;sorry, mu doesn't support windows wider than 222 characters in console mode. Please resize your window.</span><span class="cSpecial">\n</span><span class="Constant">&quot;</span> &lt;&lt; end<span class="Delimiter">();</span>
  <span class="Normal">if</span> <span class="Delimiter">(</span>height &gt; <span class="Constant">222</span><span class="Delimiter">)</span>
    raise &lt;&lt; <span class="Constant">&quot;sorry, mu doesn't support windows taller than 222 characters in console mode. Please resize your window.</span><span class="cSpecial">\n</span><span class="Constant">&quot;</span> &lt;&lt; end<span class="Delimiter">();</span>
  <span class="Identifier">break</span><span class="Delimiter">;</span>
<span class="Delimiter">}</span>

<span class="Delimiter">:(before &quot;End Primitive Recipe Declarations&quot;)</span>
CLOSE_CONSOLE<span class="Delimiter">,</span>
<span class="Delimiter">:(before &quot;End Primitive Recipe Numbers&quot;)</span>
put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> <span class="Constant">&quot;close-console&quot;</span><span class="Delimiter">,</span> CLOSE_CONSOLE<span class="Delimiter">);</span>
<span class="Delimiter">:(before &quot;End Primitive Recipe Checks&quot;)</span>
<span class="Normal">case</span> CLOSE_CONSOLE: <span class="Delimiter">{</span>
  <span class="Identifier">break</span><span class="Delimiter">;</span>
<span class="Delimiter">}</span>
<span class="Delimiter">:(before &quot;End Primitive Recipe Implementations&quot;)</span>
<span class="Normal">case</span> CLOSE_CONSOLE: <span class="Delimiter">{</span>
  tb_shutdown<span class="Delimiter">();</span>
  <span class="Identifier">break</span><span class="Delimiter">;</span>
<span class="Delimiter">}</span>

<span class="Delimiter">:(before &quot;End Teardown&quot;)</span>
tb_shutdown<span class="Delimiter">();</span>

<span class="Delimiter">:(before &quot;End Primitive Recipe Declarations&quot;)</span>
CLEAR_DISPLAY<span class="Delimiter">,</span>
<span class="Delimiter">:(before &quot;End Primitive Recipe Numbers&quot;)</span>
put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> <span class="Constant">&quot;clear-display&quot;</span><span class="Delimiter">,</span> CLEAR_DISPLAY<span class="Delimiter">);</span>
<span class="Delimiter">:(before &quot;End Primitive Recipe Checks&quot;)</span>
<span class="Normal">case</span> CLEAR_DISPLAY: <span class="Delimiter">{</span>
  <span class="Identifier">break</span><span class="Delimiter">;</span>
<span class="Delimiter">}</span>
<span class="Delimiter">:(before &quot;End Primitive Recipe Implementations&quot;)</span>
<span class="Normal">case</span> CLEAR_DISPLAY: <span class="Delimiter">{</span>
  CHECK_SCREEN<span class="Delimiter">;</span>
  tb_clear<span class="Delimiter">();</span>
  Display_row = Display_column = <span class="Constant">0</span><span class="Delimiter">;</span>
  <span class="Identifier">break</span><span class="Delimiter">;</span>
<span class="Delimiter">}</span>

<span class="Delimiter">:(before &quot;End Primitive Recipe Declarations&quot;)</span>
SYNC_DISPLAY<span class="Delimiter">,</span>
<span class="Delimiter">:(before &quot;End Primitive Recipe Numbers&quot;)</span>
put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> <span class="Constant">&quot;sync-display&quot;</span><span class="Delimiter">,</span> SYNC_DISPLAY<span class="Delimiter">);</span>
<span class="Delimiter">:(before &quot;End Primitive Recipe Checks&quot;)</span>
<span class="Normal">case</span> SYNC_DISPLAY: <span class="Delimiter">{</span>
  <span class="Identifier">break</span><span class="Delimiter">;</span>
<span class="Delimiter">}</span>
<span class="Delimiter">:(before &quot;End Primitive Recipe Implementations&quot;)</span>
<span class="Normal">case</span> SYNC_DISPLAY: <span class="Delimiter">{</span>
  CHECK_SCREEN<span class="Delimiter">;</span>
  tb_sync<span class="Delimiter">();</span>
  <span class="Identifier">break</span><span class="Delimiter">;</span>
<span class="Delimiter">}</span>

<span class="Delimiter">:(before &quot;End Primitive Recipe Declarations&quot;)</span>
CLEAR_LINE_ON_DISPLAY<span class="Delimiter">,</span>
<span class="Delimiter">:(before &quot;End Primitive Recipe Numbers&quot;)</span>
put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> <span class="Constant">&quot;clear-line-on-display&quot;</span><span class="Delimiter">,</span> CLEAR_LINE_ON_DISPLAY<span class="Delimiter">);</span>
<span class="Delimiter">:(before &quot;End Primitive Recipe Checks&quot;)</span>
<span class="Normal">case</span> CLEAR_LINE_ON_DISPLAY: <span class="Delimiter">{</span>
  <span class="Identifier">break</span><span class="Delimiter">;</span>
<span class="Delimiter">}</span>
<span class="Delimiter">:(before &quot;End Primitive Recipe Implementations&quot;)</span>
<span class="Normal">case</span> CLEAR_LINE_ON_DISPLAY: <span class="Delimiter">{</span>
  CHECK_SCREEN<span class="Delimiter">;</span>
  <span class="Normal">int</span> width = tb_width<span class="Delimiter">();</span>
  <span class="Normal">for</span> <span class="Delimiter">(</span><span class="Normal">int</span> x = Display_column<span class="Delimiter">;</span> x &lt; width<span class="Delimiter">;</span> ++x<span class="Delimiter">)</span> <span class="Delimiter">{</span>
    tb_change_cell<span class="Delimiter">(</span>x<span class="Delimiter">,</span> Display_row<span class="Delimiter">,</span> <span class="Constant">' '</span><span class="Delimiter">,</span> TB_WHITE<span class="Delimiter">,</span> TB_BLACK<span class="Delimiter">);</span>
  <span class="Delimiter">}</span>
  tb_set_cursor<span class="Delimiter">(</span>Display_column<span class="Delimiter">,</span> Display_row<span class="Delimiter">);</span>
  <span class="Normal">if</span> <span class="Delimiter">(</span>Autodisplay<span class="Delimiter">)</span> tb_present<span class="Delimiter">();</span>
  <span class="Identifier">break</span><span class="Delimiter">;</span>
<span class="Delimiter">}</span>

<span class="Delimiter">:(before &quot;End Primitive Recipe Declarations&quot;)</span>
PRINT_CHARACTER_TO_DISPLAY<span class="Delimiter">,</span>
<span class="Delimiter">:(before &quot;End Primitive Recipe Numbers&quot;)</span>
put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> <span class="Constant">&quot;print-character-to-display&quot;</span><span class="Delimiter">,</span> PRINT_CHARACTER_TO_DISPLAY<span class="Delimiter">);</span>
<span class="Delimiter">:(before &quot;End Primitive Recipe Checks&quot;)</span>
<span class="Normal">case</span> PRINT_CHARACTER_TO_DISPLAY: <span class="Delimiter">{</span>
  <span class="Normal">if</span> <span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>empty<span class="Delimiter">())</span> <span class="Delimiter">{</span>
    raise &lt;&lt; maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> &lt;&lt; <span class="Constant">&quot;'print-character-to-display' requires at least one ingredient, but got '&quot;</span> &lt;&lt; inst<span class="Delimiter">.</span>original_string &lt;&lt; <span class="Constant">&quot;'</span><span class="cSpecial">\n</span><span class="Constant">&quot;</span> &lt;&lt; end<span class="Delimiter">();</span>
    <span class="Identifier">break</span><span class="Delimiter">;</span>
  <span class="Delimiter">}</span>
  <span class="Normal">if</span> <span class="Delimiter">(</span>!is_mu_number<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)))</span> <span class="Delimiter">{</span>
    raise &lt;&lt; maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> &lt;&lt; <span class="Constant">&quot;first ingredient of 'print-character-to-display' should be a character, but got '&quot;</span> &lt;&lt; inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>original_string &lt;&lt; <span class="Constant">&quot;'</span><span class="cSpecial">\n</span><span class="Constant">&quot;</span> &lt;&lt; end<span class="Delimiter">();</span>
    <span class="Identifier">break</span><span class="Delimiter">;</span>
  <span class="Delimiter">}</span>
  <span class="Normal">if</span> <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">)</span> &gt; <span class="Constant">1</span><span class="Delimiter">)</span> <span class="Delimiter">{</span>
    <span class="Normal">if</span> <span class="Delimiter">(</span>!is_mu_number<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">)))</span> <span class="Delimiter">{</span>
      raise &lt;&lt; maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> &lt;&lt; <span class="Constant">&quot;second ingredient of 'print-character-to-display' should be a foreground color number, but got '&quot;</span> &lt;&lt; inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>original_string &lt;&lt; <span class="Constant">&quot;'</span><span class="cSpecial">\n</span><span class="Constant">&quot;</span> &lt;&lt; end<span class="Delimiter">();</span>
      <span class="Identifier">break</span><span class="Delimiter">;</span>
    <span class="Delimiter">}</span>
  <span class="Delimiter">}</span>
  <span class="Normal">if</span> <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">)</span> &gt; <span class="Constant">2</span><span class="Delimiter">)</span> <span class="Delimiter">{</span>
    <span class="Normal">if</span> <span class="Delimiter">(</span>!is_mu_number<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">2</span><span class="Delimiter">)))</span> <span class="Delimiter">{</span>
      raise &lt;&lt; maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> &lt;&lt; <span class="Constant">&quot;third ingredient of 'print-character-to-display' should be a background color number, but got '&quot;</span> &lt;&lt; inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">2</span><span class="Delimiter">).</span>original_string &lt;&lt; <span class="Constant">&quot;'</span><span class="cSpecial">\n</span><span class="Constant">&quot;</span> &lt;&lt; end<span class="Delimiter">();</span>
      <span class="Identifier">break</span><span class="Delimiter">;</span>
    <span class="Delimiter">}</span>
  <span class="Delimiter">}</span>
  <span class="Identifier">break</span><span class="Delimiter">;</span>
<span class="Delimiter">}</span>
<span class="Delimiter">:(before &quot;End Primitive Recipe Implementations&quot;)</span>
<span class="Normal">case</span> PRINT_CHARACTER_TO_DISPLAY: <span class="Delimiter">{</span>
  CHECK_SCREEN<span class="Delimiter">;</span>
  <span class="Normal">int</span> h=tb_height<span class="Delimiter">(),</span> w=tb_width<span class="Delimiter">();</span>
  <span class="Normal">int</span> height = <span class="Delimiter">(</span>h &gt;= <span class="Constant">0</span><span class="Delimiter">)</span> ? h : <span class="Constant">0</span><span class="Delimiter">;</span>
  <span class="Normal">int</span> width = <span class="Delimiter">(</span>w &gt;= <span class="Constant">0</span><span class="Delimiter">)</span> ? w : <span class="Constant">0</span><span class="Delimiter">;</span>
  <span class="Normal">int</span> c = ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span>
  <span class="Normal">int</span> color = TB_BLACK<span class="Delimiter">;</span>
  <span class="Normal">if</span> <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>ingredients<span class="Delimiter">)</span> &gt; <span class="Constant">1</span><span class="Delimiter">)</span> <span class="Delimiter">{</span>
    color = ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span>
  <span class="Delimiter">}</span>
  <span class="Normal">int</span> bg_color = TB_BLACK<span class="Delimiter">;</span>
  <span class="Normal">if</span> <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>ingredients<span class="Delimiter">)</span> &gt; <span class="Constant">2</span><span class="Delimiter">)</span> <span class="Delimiter">{</span>
    bg_color = ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">2</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span>
    <span class="Normal">if</span> <span class="Delimiter">(</span>bg_color == <span class="Constant">0</span><span class="Delimiter">)</span> bg_color = TB_BLACK<span class="Delimiter">;</span>
  <span class="Delimiter">}</span>
  tb_change_cell<span class="Delimiter">(</span>Display_column<span class="Delimiter">,</span> Display_row<span class="Delimiter">,</span> c<span class="Delimiter">,</span> color<span class="Delimiter">,</span> bg_color<span class="Delimiter">);</span>
  <span class="Normal">if</span> <span class="Delimiter">(</span>c == <span class="cSpecial">'\n'</span> || c == <span class="cSpecial">'\r'</span><span class="Delimiter">)</span> <span class="Delimiter">{</span>
    <span class="Normal">if</span> <span class="Delimiter">(</span>Display_row &lt; height-<span class="Constant">1</span><span class="Delimiter">)</span> <span class="Delimiter">{</span>
      Display_column = <span class="Constant">0</span><span class="Delimiter">;</span>
      ++Display_row<span class="Delimiter">;</span>
      tb_set_cursor<span class="Delimiter">(</span>Display_column<span class="Delimiter">,</span> Display_row<span class="Delimiter">);</span>
      <span class="Normal">if</span> <span class="Delimiter">(</span>Autodisplay<span class="Delimiter">)</span> tb_present<span class="Delimiter">();</span>
    <span class="Delimiter">}</span>
    <span class="Identifier">break</span><span class="Delimiter">;</span>
  <span class="Delimiter">}</span>
  <span class="Normal">if</span> <span class="Delimiter">(</span>c == <span class="cSpecial">'\b'</span><span class="Delimiter">)</span> <span class="Delimiter">{</span>
    <span class="Normal">if</span> <span class="Delimiter">(</span>Display_column &gt; <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Delimiter">{</span>
      tb_change_cell<span class="Delimiter">(</span>Display_column-<span class="Constant">1</span><span class="Delimiter">,</span> Display_row<span class="Delimiter">,</span> <span class="Constant">' '</span><span class="Delimiter">,</span> color<span class="Delimiter">,</span> bg_color<span class="Delimiter">);</span>
      --Display_column<span class="Delimiter">;</span>
      tb_set_cursor<span class="Delimiter">(</span>Display_column<span class="Delimiter">,</span> Display_row<span class="Delimiter">);</span>
      <span class="Normal">if</span> <span class="Delimiter">(</span>Autodisplay<span class="Delimiter">)</span> tb_present<span class="Delimiter">();</span>
    <span class="Delimiter">}</span>
    <span class="Identifier">break</span><span class="Delimiter">;</span>
  <span class="Delimiter">}</span>
  <span class="Normal">if</span> <span class="Delimiter">(</span>Display_column &lt; width-<span class="Constant">1</span><span class="Delimiter">)</span> <span class="Delimiter">{</span>
    ++Display_column<span class="Delimiter">;</span>
    tb_set_cursor<span class="Delimiter">(</span>Display_column<span class="Delimiter">,</span> Display_row<span class="Delimiter">);</span>
  <span class="Delimiter">}</span>
  <span class="Normal">if</span> <span class="Delimiter">(</span>Autodisplay<span class="Delimiter">)</span> tb_present<span class="Delimiter">();</span>
  <span class="Identifier">break</span><span class="Delimiter">;</span>
<span class="Delimiter">}</span>

<span class="Delimiter">:(before &quot;End Primitive Recipe Declarations&quot;)</span>
CURSOR_POSITION_ON_DISPLAY<span class="Delimiter">,</span>
<span class="Delimiter">:(before &quot;End Primitive Recipe Numbers&quot;)</span>
put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> <span class="Constant">&quot;cursor-position-on-display&quot;</span><span class="Delimiter">,</span> CURSOR_POSITION_ON_DISPLAY<span class="Delimiter">);</span>
<span class="Delimiter">:(before &quot;End Primitive Recipe Checks&quot;)</span>
<span class="Normal">case</span> CURSOR_POSITION_ON_DISPLAY: <span class="Delimiter">{</span>
  <span class="Identifier">break</span><span class="Delimiter">;</span>
<span class="Delimiter">}</span>
<span class="Delimiter">:(before &quot;End Primitive Recipe Implementations&quot;)</span>
<span class="Normal">case</span> CURSOR_POSITION_ON_DISPLAY: <span class="Delimiter">{</span>
  CHECK_SCREEN<span class="Delimiter">;</span>
  products<span class="Delimiter">.</span>resize<span class="Delimiter">(</span><span class="Constant">2</span><span class="Delimiter">);</span>
  products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span>Display_row<span class="Delimiter">);</span>
  products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span>Display_column<span class="Delimiter">);</span>
  <span class="Identifier">break</span><span class="Delimiter">;</span>
<span class="Delimiter">}</span>

<span class="Delimiter">:(before &quot;End Primitive Recipe Declarations&quot;)</span>
MOVE_CURSOR_ON_DISPLAY<span class="Delimiter">,</span>
<span class="Delimiter">:(before &quot;End Primitive Recipe Numbers&quot;)</span>
put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> <span class="Constant">&quot;move-cursor-on-display&quot;</span><span class="Delimiter">,</span> MOVE_CURSOR_ON_DISPLAY<span class="Delimiter">);</span>
<span class="Delimiter">:(before &quot;End Primitive Recipe Checks&quot;)</span>
<span class="Normal">case</span> MOVE_CURSOR_ON_DISPLAY: <span class="Delimiter">{</span>
  <span class="Normal">if</span> <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">)</span> != <span class="Constant">2</span><span class="Delimiter">)</span> <span class="Delimiter">{</span>
    raise &lt;&lt; maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> &lt;&lt; <span class="Constant">&quot;'move-cursor-on-display' requires two ingredients, but got '&quot;</span> &lt;&lt; inst<span class="Delimiter">.</span>original_string &lt;&lt; <span class="Constant">&quot;'</span><span class="cSpecial">\n</span><span class="Constant">&quot;</span> &lt;&lt; end<span class="Delimiter">();</span>
    <span class="Identifier">break</span><span class="Delimiter">;</span>
  <span class="Delimiter">}</span>
  <span class="Normal">if</span> <span class="Delimiter">(</span>!is_mu_number<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)))</span> <span class="Delimiter">{</span>
    raise &lt;&lt; maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> &lt;&lt; <span class="Constant">&quot;first ingredient of 'move-cursor-on-display' should be a row number, but got '&quot;</span> &lt;&lt; inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>original_string &lt;&lt; <span class="Constant">&quot;'</span><span class="cSpecial">\n</span><span class="Constant">&quot;</span> &lt;&lt; end<span class="Delimiter">();</span>
    <span class="Identifier">break</span><span class="Delimiter">;</span>
  <span class="Delimiter">}</span>
  <span class="Normal">if</span> <span class="Delimiter">(</span>!is_mu_number<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">)))</span> <span class="Delimiter">{</span>
    raise &lt;&lt; maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> &lt;&lt; <span class="Constant">&quot;second ingredient of 'move-cursor-on-display' should be a column number, but got '&quot;</span> &lt;&lt; inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>original_string &lt;&lt; <span class="Constant">&quot;'</span><span class="cSpecial">\n</span><span class="Constant">&quot;</span> &lt;&lt; end<span class="Delimiter">();</span>
    <span class="Identifier">break</span><span class="Delimiter">;</span>
  <span class="Delimiter">}</span>
  <span class="Identifier">break</span><span class="Delimiter">;</span>
<span class="Delimiter">}</span>
<span class="Delimiter">:(before &quot;End Primitive Recipe Implementations&quot;)</span>
<span class="Normal">case</span> MOVE_CURSOR_ON_DISPLAY: <span class="Delimiter">{</span>
  CHECK_SCREEN<span class="Delimiter">;</span>
  Display_row = ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span>
  Display_column = ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span>
  tb_set_cursor<span class="Delimiter">(</span>Display_column<span class="Delimiter">,</span> Display_row<span class="Delimiter">);</span>
  <span class="Normal">if</span> <span class="Delimiter">(</span>Autodisplay<span class="Delimiter">)</span> tb_present<span class="Delimiter">();</span>
  <span class="Identifier">break</span><span class="Delimiter">;</span>
<span class="Delimiter">}</span>

<span class="Delimiter">:(before &quot;End Primitive Recipe Declarations&quot;)</span>
MOVE_CURSOR_DOWN_ON_DISPLAY<span class="Delimiter">,</span>
<span class="Delimiter">:(before &quot;End Primitive Recipe Numbers&quot;)</span>
put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> <span class="Constant">&quot;move-cursor-down-on-display&quot;</span><span class="Delimiter">,</span> MOVE_CURSOR_DOWN_ON_DISPLAY<span class="Delimiter">);</span>
<span class="Delimiter">:(before &quot;End Primitive Recipe Checks&quot;)</span>
<span class="Normal">case</span> MOVE_CURSOR_DOWN_ON_DISPLAY: <span class="Delimiter">{</span>
  <span class="Identifier">break</span><span class="Delimiter">;</span>
<span class="Delimiter">}</span>
<span class="Delimiter">:(before &quot;End Primitive Recipe Implementations&quot;)</span>
<span class="Normal">case</span> MOVE_CURSOR_DOWN_ON_DISPLAY: <span class="Delimiter">{</span>
  CHECK_SCREEN<span class="Delimiter">;</span>
  <span class="Normal">int</span> h=tb_height<span class="Delimiter">();</span>
  <span class="Normal">int</span> height = <span class="Delimiter">(</span>h &gt;= <span class="Constant">0</span><span class="Delimiter">)</span> ? h : <span class="Constant">0</span><span class="Delimiter">;</span>
  <span class="Normal">if</span> <span class="Delimiter">(</span>Display_row &lt; height-<span class="Constant">1</span><span class="Delimiter">)</span> <span class="Delimiter">{</span>
    ++Display_row<span class="Delimiter">;</span>
    tb_set_cursor<span class="Delimiter">(</span>Display_column<span class="Delimiter">,</span> Display_row<span class="Delimiter">);</span>
    <span class="Normal">if</span> <span class="Delimiter">(</span>Autodisplay<span class="Delimiter">)</span> tb_present<span class="Delimiter">();</span>
  <span class="Delimiter">}</span>
  <span class="Identifier">break</span><span class="Delimiter">;</span>
<span class="Delimiter">}</span>

<span class="Delimiter">:(before &quot;End Primitive Recipe Declarations&quot;)</span>
MOVE_CURSOR_UP_ON_DISPLAY<span class="Delimiter">,</span>
<span class="Delimiter">:(before &quot;End Primitive Recipe Numbers&quot;)</span>
put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> <span class="Constant">&quot;move-cursor-up-on-display&quot;</span><span class="Delimiter">,</span> MOVE_CURSOR_UP_ON_DISPLAY<span class="Delimiter">);</span>
<span class="Delimiter">:(before &quot;End Primitive Recipe Checks&quot;)</span>
<span class="Normal">case</span> MOVE_CURSOR_UP_ON_DISPLAY: <span class="Delimiter">{</span>
  <span class="Identifier">break</span><span class="Delimiter">;</span>
<span class="Delimiter">}</span>
<span class="Delimiter">:(before &quot;End Primitive Recipe Implementations&quot;)</span>
<span class="Normal">case</span> MOVE_CURSOR_UP_ON_DISPLAY: <span class="Delimiter">{</span>
  CHECK_SCREEN<span class="Delimiter">;</span>
  <span class="Normal">if</span> <span class="Delimiter">(</span>Display_row &gt; <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Delimiter">{</span>
    --Display_row<span class="Delimiter">;</span>
    tb_set_cursor<span class="Delimiter">(</span>Display_column<span class="Delimiter">,</span> Display_row<span class="Delimiter">);</span>
    <span class="Normal">if</span> <span class="Delimiter">(</span>Autodisplay<span class="Delimiter">)</span> tb_present<span class="Delimiter">();</span>
  <span class="Delimiter">}</span>
  <span class="Identifier">break</span><span class="Delimiter">;</span>
<span class="Delimiter">}</span>

<span class="Delimiter">:(before &quot;End Primitive Recipe Declarations&quot;)</span>
MOVE_CURSOR_RIGHT_ON_DISPLAY<span class="Delimiter">,</span>
<span class="Delimiter">:(before &quot;End Primitive Recipe Numbers&quot;)</span>
put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> <span class="Constant">&quot;move-cursor-right-on-display&quot;</span><span class="Delimiter">,</span> MOVE_CURSOR_RIGHT_ON_DISPLAY<span class="Delimiter">);</span>
<span class="Delimiter">:(before &quot;End Primitive Recipe Checks&quot;)</span>
<span class="Normal">case</span> MOVE_CURSOR_RIGHT_ON_DISPLAY: <span class="Delimiter">{</span>
  <span class="Identifier">break</span><span class="Delimiter">;</span>
<span class="Delimiter">}</span>
<span class="Delimiter">:(before &quot;End Primitive Recipe Implementations&quot;)</span>
<span class="Normal">case</span> MOVE_CURSOR_RIGHT_ON_DISPLAY: <span class="Delimiter">{</span>
  CHECK_SCREEN<span class="Delimiter">;</span>
  <span class="Normal">int</span> w=tb_width<span class="Delimiter">();</span>
  <span class="Normal">int</span> width = <span class="Delimiter">(</span>w &gt;= <span class="Constant">0</span><span class="Delimiter">)</span> ? w : <span class="Constant">0</span><span class="Delimiter">;</span>
  <span class="Normal">if</span> <span class="Delimiter">(</span>Display_column &lt; width-<span class="Constant">1</span><span class="Delimiter">)</span> <span class="Delimiter">{</span>
    ++Display_column<span class="Delimiter">;</span>
    tb_set_cursor<span class="Delimiter">(</span>Display_column<span class="Delimiter">,</span> Display_row<span class="Delimiter">);</span>
    <span class="Normal">if</span> <span class="Delimiter">(</span>Autodisplay<span class="Delimiter">)</span> tb_present<span class="Delimiter">();</span>
  <span class="Delimiter">}</span>
  <span class="Identifier">break</span><span class="Delimiter">;</span>
<span class="Delimiter">}</span>

<span class="Delimiter">:(before &quot;End Primitive Recipe Declarations&quot;)</span>
MOVE_CURSOR_LEFT_ON_DISPLAY<span class="Delimiter">,</span>
<span class="Delimiter">:(before &quot;End Primitive Recipe Numbers&quot;)</span>
put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> <span class="Constant">&quot;move-cursor-left-on-display&quot;</span><span class="Delimiter">,</span> MOVE_CURSOR_LEFT_ON_DISPLAY<span class="Delimiter">);</span>
<span class="Delimiter">:(before &quot;End Primitive Recipe Checks&quot;)</span>
<span class="Normal">case</span> MOVE_CURSOR_LEFT_ON_DISPLAY: <span class="Delimiter">{</span>
  <span class="Identifier">break</span><span class="Delimiter">;</span>
<span class="Delimiter">}</span>
<span class="Delimiter">:(before &quot;End Primitive Recipe Implementations&quot;)</span>
<span class="Normal">case</span> MOVE_CURSOR_LEFT_ON_DISPLAY: <span class="Delimiter">{</span>
  CHECK_SCREEN<span class="Delimiter">;</span>
  <span class="Normal">if</span> <span class="Delimiter">(</span>Display_column &gt; <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Delimiter">{</span>
    --Display_column<span class="Delimiter">;</span>
    tb_set_cursor<span class="Delimiter">(</span>Display_column<span class="Delimiter">,</span> Display_row<span class="Delimiter">);</span>
    <span class="Normal">if</span> <span class="Delimiter">(</span>Autodisplay<span class="Delimiter">)</span> tb_present<span class="Delimiter">();</span>
  <span class="Delimiter">}</span>
  <span class="Identifier">break</span><span class="Delimiter">;</span>
<span class="Delimiter">}</span>

<span class="Comment">//: as a convenience, make $print mostly work in console mode</span>
<span class="Delimiter">:(before &quot;End $print 10/newline Special-cases&quot;)</span>
<span class="Normal">else</span> <span class="Normal">if</span> <span class="Delimiter">(</span>tb_is_active<span class="Delimiter">())</span> <span class="Delimiter">{</span>
  move_cursor_to_start_of_next_line_on_display<span class="Delimiter">();</span>
<span class="Delimiter">}</span>
<span class="Delimiter">:(code)</span>
<span class="Normal">void</span> move_cursor_to_start_of_next_line_on_display<span class="Delimiter">()</span> <span class="Delimiter">{</span>
  <span class="Normal">if</span> <span class="Delimiter">(</span>Display_row &lt; tb_height<span class="Delimiter">()</span>-<span class="Constant">1</span><span class="Delimiter">)</span> ++Display_row<span class="Delimiter">;</span>
  <span class="Normal">else</span> Display_row = <span class="Constant">0</span><span class="Delimiter">;</span>
  Display_column = <span class="Constant">0</span><span class="Delimiter">;</span>
  tb_set_cursor<span class="Delimiter">(</span>Display_column<span class="Delimiter">,</span> Display_row<span class="Delimiter">);</span>
  <span class="Normal">if</span> <span class="Delimiter">(</span>Autodisplay<span class="Delimiter">)</span> tb_present<span class="Delimiter">();</span>
<span class="Delimiter">}</span>

<span class="Delimiter">:(before &quot;End Primitive Recipe Declarations&quot;)</span>
DISPLAY_WIDTH<span class="Delimiter">,</span>
<span class="Delimiter">:(before &quot;End Primitive Recipe Numbers&quot;)</span>
put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> <span class="Constant">&quot;display-width&quot;</span><span class="Delimiter">,</span> DISPLAY_WIDTH<span class="Delimiter">);</span>
<span class="Delimiter">:(before &quot;End Primitive Recipe Checks&quot;)</span>
<span class="Normal">case</span> DISPLAY_WIDTH: <span class="Delimiter">{</span>
  <span class="Identifier">break</span><span class="Delimiter">;</span>
<span class="Delimiter">}</span>
<span class="Delimiter">:(before &quot;End Primitive Recipe Implementations&quot;)</span>
<span class="Normal">case</span> DISPLAY_WIDTH: <span class="Delimiter">{</span>
  CHECK_SCREEN<span class="Delimiter">;</span>
  products<span class="Delimiter">.</span>resize<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">);</span>
  products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span>tb_width<span class="Delimiter">());</span>
  <span class="Identifier">break</span><span class="Delimiter">;</span>
<span class="Delimiter">}</span>

<span class="Delimiter">:(before &quot;End Primitive Recipe Declarations&quot;)</span>
DISPLAY_HEIGHT<span class="Delimiter">,</span>
<span class="Delimiter">:(before &quot;End Primitive Recipe Numbers&quot;)</span>
put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> <span class="Constant">&quot;display-height&quot;</span><span class="Delimiter">,</span> DISPLAY_HEIGHT<span class="Delimiter">);</span>
<span class="Delimiter">:(before &quot;End Primitive Recipe Checks&quot;)</span>
<span class="Normal">case</span> DISPLAY_HEIGHT: <span class="Delimiter">{</span>
  <span class="Identifier">break</span><span class="Delimiter">;</span>
<span class="Delimiter">}</span>
<span class="Delimiter">:(before &quot;End Primitive Recipe Implementations&quot;)</span>
<span class="Normal">case</span> DISPLAY_HEIGHT: <span class="Delimiter">{</span>
  CHECK_SCREEN<span class="Delimiter">;</span>
  products<span class="Delimiter">.</span>resize<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">);</span>
  products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span>tb_height<span class="Delimiter">());</span>
  <span class="Identifier">break</span><span class="Delimiter">;</span>
<span class="Delimiter">}</span>

<span class="Delimiter">:(before &quot;End Primitive Recipe Declarations&quot;)</span>
HIDE_CURSOR_ON_DISPLAY<span class="Delimiter">,</span>
<span class="Delimiter">:(before &quot;End Primitive Recipe Numbers&quot;)</span>
put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> <span class="Constant">&quot;hide-cursor-on-display&quot;</span><span class="Delimiter">,</span> HIDE_CURSOR_ON_DISPLAY<span class="Delimiter">);</span>
<span class="Delimiter">:(before &quot;End Primitive Recipe Checks&quot;)</span>
<span class="Normal">case</span> HIDE_CURSOR_ON_DISPLAY: <span class="Delimiter">{</span>
  <span class="Identifier">break</span><span class="Delimiter">;</span>
<span class="Delimiter">}</span>
<span class="Delimiter">:(before &quot;End Primitive Recipe Implementations&quot;)</span>
<span class="Normal">case</span> HIDE_CURSOR_ON_DISPLAY: <span class="Delimiter">{</span>
  CHECK_SCREEN<span class="Delimiter">;</span>
  tb_set_cursor<span class="Delimiter">(</span>TB_HIDE_CURSOR<span class="Delimiter">,</span> TB_HIDE_CURSOR<span class="Delimiter">);</span>
  <span class="Identifier">break</span><span class="Delimiter">;</span>
<span class="Delimiter">}</span>

<span class="Delimiter">:(before &quot;End Primitive Recipe Declarations&quot;)</span>
SHOW_CURSOR_ON_DISPLAY<span class="Delimiter">,</span>
<span class="Delimiter">:(before &quot;End Primitive Recipe Numbers&quot;)</span>
put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> <span class="Constant">&quot;show-cursor-on-display&quot;</span><span class="Delimiter">,</span> SHOW_CURSOR_ON_DISPLAY<span class="Delimiter">);</span>
<span class="Delimiter">:(before &quot;End Primitive Recipe Checks&quot;)</span>
<span class="Normal">case</span> SHOW_CURSOR_ON_DISPLAY: <span class="Delimiter">{</span>
  <span class="Identifier">break</span><span class="Delimiter">;</span>
<span class="Delimiter">}</span>
<span class="Delimiter">:(before &quot;End Primitive Recipe Implementations&quot;)</span>
<span class="Normal">case</span> SHOW_CURSOR_ON_DISPLAY: <span class="Delimiter">{</span>
  CHECK_SCREEN<span class="Delimiter">;</span>
  tb_set_cursor<span class="Delimiter">(</span>Display_row<span class="Delimiter">,</span> Display_column<span class="Delimiter">);</span>
  <span class="Identifier">break</span><span class="Delimiter">;</span>
<span class="Delimiter">}</span>

<span class="Delimiter">:(before &quot;End Primitive Recipe Declarations&quot;)</span>
HIDE_DISPLAY<span class="Delimiter">,</span>
<span class="Delimiter">:(before &quot;End Primitive Recipe Numbers&quot;)</span>
put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> <span class="Constant">&quot;hide-display&quot;</span><span class="Delimiter">,</span> HIDE_DISPLAY<span class="Delimiter">);</span>
<span class="Delimiter">:(before &quot;End Primitive Recipe Checks&quot;)</span>
<span class="Normal">case</span> HIDE_DISPLAY: <span class="Delimiter">{</span>
  <span class="Identifier">break</span><span class="Delimiter">;</span>
<span class="Delimiter">}</span>
<span class="Delimiter">:(before &quot;End Primitive Recipe Implementations&quot;)</span>
<span class="Normal">case</span> HIDE_DISPLAY: <span class="Delimiter">{</span>
  CHECK_SCREEN<span class="Delimiter">;</span>
  Autodisplay = <span class="Constant">false</span><span class="Delimiter">;</span>
  <span class="Identifier">break</span><span class="Delimiter">;</span>
<span class="Delimiter">}</span>

<span class="Delimiter">:(before &quot;End Primitive Recipe Declarations&quot;)</span>
SHOW_DISPLAY<span class="Delimiter">,</span>
<span class="Delimiter">:(before &quot;End Primitive Recipe Numbers&quot;)</span>
put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> <span class="Constant">&quot;show-display&quot;</span><span class="Delimiter">,</span> SHOW_DISPLAY<span class="Delimiter">);</span>
<span class="Delimiter">:(before &quot;End Primitive Recipe Checks&quot;)</span>
<span class="Normal">case</span> SHOW_DISPLAY: <span class="Delimiter">{</span>
  <span class="Identifier">break</span><span class="Delimiter">;</span>
<span class="Delimiter">}</span>
<span class="Delimiter">:(before &quot;End Primitive Recipe Implementations&quot;)</span>
<span class="Normal">case</span> SHOW_DISPLAY: <span class="Delimiter">{</span>
  CHECK_SCREEN<span class="Delimiter">;</span>
  Autodisplay = <span class="Constant">true</span><span class="Delimiter">;</span>
  tb_present<span class="Delimiter">();</span>
  <span class="Identifier">break</span><span class="Delimiter">;</span>
<span class="Delimiter">}</span>

<span class="SalientComment">//:: Keyboard/mouse management</span>

<span class="Delimiter">:(before &quot;End Primitive Recipe Declarations&quot;)</span>
WAIT_FOR_SOME_INTERACTION<span class="Delimiter">,</span>
<span class="Delimiter">:(before &quot;End Primitive Recipe Numbers&quot;)</span>
put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> <span class="Constant">&quot;wait-for-some-interaction&quot;</span><span class="Delimiter">,</span> WAIT_FOR_SOME_INTERACTION<span class="Delimiter">);</span>
<span class="Delimiter">:(before &quot;End Primitive Recipe Checks&quot;)</span>
<span class="Normal">case</span> WAIT_FOR_SOME_INTERACTION: <span class="Delimiter">{</span>
  <span class="Identifier">break</span><span class="Delimiter">;</span>
<span class="Delimiter">}</span>
<span class="Delimiter">:(before &quot;End Primitive Recipe Implementations&quot;)</span>
<span class="Normal">case</span> WAIT_FOR_SOME_INTERACTION: <span class="Delimiter">{</span>
  CHECK_SCREEN<span class="Delimiter">;</span>
  tb_event event<span class="Delimiter">;</span>
  tb_poll_event<span class="Delimiter">(</span>&amp;event<span class="Delimiter">);</span>
  <span class="Identifier">break</span><span class="Delimiter">;</span>
<span class="Delimiter">}</span>

<span class="Delimiter">:(before &quot;End Primitive Recipe Declarations&quot;)</span>
CHECK_FOR_INTERACTION<span class="Delimiter">,</span>
<span class="Delimiter">:(before &quot;End Primitive Recipe Numbers&quot;)</span>
put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> <span class="Constant">&quot;check-for-interaction&quot;</span><span class="Delimiter">,</span> CHECK_FOR_INTERACTION<span class="Delimiter">);</span>
<span class="Delimiter">:(before &quot;End Primitive Recipe Checks&quot;)</span>
<span class="Normal">case</span> CHECK_FOR_INTERACTION: <span class="Delimiter">{</span>
  <span class="Identifier">break</span><span class="Delimiter">;</span>
<span class="Delimiter">}</span>
<span class="Delimiter">:(before &quot;End Primitive Recipe Implementations&quot;)</span>
<span class="Normal">case</span> CHECK_FOR_INTERACTION: <span class="Delimiter">{</span>
  CHECK_CONSOLE<span class="Delimiter">;</span>
  products<span class="Delimiter">.</span>resize<span class="Delimiter">(</span><span class="Constant">2</span><span class="Delimiter">);</span>  <span class="Comment">// result and status</span>
  tb_event event<span class="Delimiter">;</span>
  <span class="Normal">int</span> event_type = tb_peek_event<span class="Delimiter">(</span>&amp;event<span class="Delimiter">,</span> <span class="Constant">5</span><span class="Comment">/*</span><span class="Comment">ms</span><span class="Comment">*/</span><span class="Delimiter">);</span>
  <span class="Normal">if</span> <span class="Delimiter">(</span>event_type == TB_EVENT_KEY &amp;&amp; event<span class="Delimiter">.</span>ch<span class="Delimiter">)</span> <span class="Delimiter">{</span>
    products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span><span class="Comment">/*</span><span class="Comment">text event</span><span class="Comment">*/</span><span class="Constant">0</span><span class="Delimiter">);</span>
    products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span>event<span class="Delimiter">.</span>ch<span class="Delimiter">);</span>
    products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span>
    products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span>
    products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span><span class="Comment">/*</span><span class="Comment">found</span><span class="Comment">*/</span><span class="Constant">true</span><span class="Delimiter">);</span>
    <span class="Identifier">break</span><span class="Delimiter">;</span>
  <span class="Delimiter">}</span>
  <span class="Comment">// treat keys within ascii as unicode characters</span>
  <span class="Normal">if</span> <span class="Delimiter">(</span>event_type == TB_EVENT_KEY &amp;&amp; event<span class="Delimiter">.</span>key &lt; <span class="Constant">0xff</span><span class="Delimiter">)</span> <span class="Delimiter">{</span>
    products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span><span class="Comment">/*</span><span class="Comment">text event</span><span class="Comment">*/</span><span class="Constant">0</span><span class="Delimiter">);</span>
    <span class="Normal">if</span> <span class="Delimiter">(</span>event<span class="Delimiter">.</span>key == TB_KEY_CTRL_C<span class="Delimiter">)</span> <span class="Delimiter">{</span>
      tb_shutdown<span class="Delimiter">();</span>
      exit<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">);</span>
    <span class="Delimiter">}</span>
    <span class="Normal">if</span> <span class="Delimiter">(</span>event<span class="Delimiter">.</span>key == TB_KEY_BACKSPACE2<span class="Delimiter">)</span> event<span class="Delimiter">.</span>key = TB_KEY_BACKSPACE<span class="Delimiter">;</span>
    <span class="Normal">if</span> <span class="Delimiter">(</span>event<span class="Delimiter">.</span>key == TB_KEY_CARRIAGE_RETURN<span class="Delimiter">)</span> event<span class="Delimiter">.</span>key = TB_KEY_NEWLINE<span class="Delimiter">;</span>
    products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span>event<span class="Delimiter">.</span>key<span class="Delimiter">);</span>
    products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span>
    products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span>
    products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span><span class="Comment">/*</span><span class="Comment">found</span><span class="Comment">*/</span><span class="Constant">true</span><span class="Delimiter">);</span>
    <span class="Identifier">break</span><span class="Delimiter">;</span>
  <span class="Delimiter">}</span>
  <span class="Comment">// keys outside ascii aren't unicode characters but arbitrary termbox inventions</span>
  <span class="Normal">if</span> <span class="Delimiter">(</span>event_type == TB_EVENT_KEY<span class="Delimiter">)</span> <span class="Delimiter">{</span>
    products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span><span class="Comment">/*</span><span class="Comment">keycode event</span><span class="Comment">*/</span><span class="Constant">1</span><span class="Delimiter">);</span>
    products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span>event<span class="Delimiter">.</span>key<span class="Delimiter">);</span>
    products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span>
    products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span>
    products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span><span class="Comment">/*</span><span class="Comment">found</span><span class="Comment">*/</span><span class="Constant">true</span><span class="Delimiter">);</span>
    <span class="Identifier">break</span><span class="Delimiter">;</span>
  <span class="Delimiter">}</span>
  <span class="Normal">if</span> <span class="Delimiter">(</span>event_type == TB_EVENT_MOUSE<span class="Delimiter">)</span> <span class="Delimiter">{</span>
    products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span><span class="Comment">/*</span><span class="Comment">touch event</span><span class="Comment">*/</span><span class="Constant">2</span><span class="Delimiter">);</span>
    products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span>event<span class="Delimiter">.</span>key<span class="Delimiter">);</span>  <span class="Comment">// which button, etc.</span>
    products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span>event<span class="Delimiter">.</span>y<span class="Delimiter">);</span>  <span class="Comment">// row</span>
    products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span>event<span class="Delimiter">.</span>x<span class="Delimiter">);</span>  <span class="Comment">// column</span>
    products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span><span class="Comment">/*</span><span class="Comment">found</span><span class="Comment">*/</span><span class="Constant">true</span><span class="Delimiter">);</span>
    <span class="Identifier">break</span><span class="Delimiter">;</span>
  <span class="Delimiter">}</span>
  <span class="Normal">if</span> <span class="Delimiter">(</span>event_type == TB_EVENT_RESIZE<span class="Delimiter">)</span> <span class="Delimiter">{</span>
    products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span><span class="Comment">/*</span><span class="Comment">resize event</span><span class="Comment">*/</span><span class="Constant">3</span><span class="Delimiter">);</span>
    products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span>event<span class="Delimiter">.</span>w<span class="Delimiter">);</span>  <span class="Comment">// width</span>
    products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span>event<span class="Delimiter">.</span>h<span class="Delimiter">);</span>  <span class="Comment">// height</span>
    products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span>
    products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span><span class="Comment">/*</span><span class="Comment">found</span><span class="Comment">*/</span><span class="Constant">true</span><span class="Delimiter">);</span>
    <span class="Identifier">break</span><span class="Delimiter">;</span>
  <span class="Delimiter">}</span>
  assert<span class="Delimiter">(</span>event_type == <span class="Constant">0</span><span class="Delimiter">);</span>
  products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span>
  products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span>
  products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span>
  products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span>
  products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span><span class="Comment">/*</span><span class="Comment">found</span><span class="Comment">*/</span><span class="Constant">false</span><span class="Delimiter">);</span>
  <span class="Identifier">break</span><span class="Delimiter">;</span>
<span class="Delimiter">}</span>

<span class="Delimiter">:(before &quot;End Primitive Recipe Declarations&quot;)</span>
INTERACTIONS_LEFT<span class="Delimiter">,</span>
<span class="Delimiter">:(before &quot;End Primitive Recipe Numbers&quot;)</span>
put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> <span class="Constant">&quot;interactions-left?&quot;</span><span class="Delimiter">,</span> INTERACTIONS_LEFT<span class="Delimiter">);</span>
<span class="Delimiter">:(before &quot;End Primitive Recipe Checks&quot;)</span>
<span class="Normal">case</span> INTERACTIONS_LEFT: <span class="Delimiter">{</span>
  <span class="Identifier">break</span><span class="Delimiter">;</span>
<span class="Delimiter">}</span>
<span class="Delimiter">:(before &quot;End Primitive Recipe Implementations&quot;)</span>
<span class="Normal">case</span> INTERACTIONS_LEFT: <span class="Delimiter">{</span>
  CHECK_CONSOLE<span class="Delimiter">;</span>
  products<span class="Delimiter">.</span>resize<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">);</span>
  products<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>push_back<span class="Delimiter">(</span>tb_event_ready<span class="Delimiter">());</span>
  <span class="Identifier">break</span><span class="Delimiter">;</span>
<span class="Delimiter">}</span>

<span class="Comment">//: a hack to make edit.mu more responsive</span>

<span class="Delimiter">:(before &quot;End Primitive Recipe Declarations&quot;)</span>
CLEAR_DISPLAY_FROM<span class="Delimiter">,</span>
<span class="Delimiter">:(before &quot;End Primitive Recipe Numbers&quot;)</span>
put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span> <span class="Constant">&quot;clear-display-from&quot;</span><span class="Delimiter">,</span> CLEAR_DISPLAY_FROM<span class="Delimiter">);</span>
<span class="Delimiter">:(before &quot;End Primitive Recipe Checks&quot;)</span>
<span class="Normal">case</span> CLEAR_DISPLAY_FROM: <span class="Delimiter">{</span>
  <span class="Identifier">break</span><span class="Delimiter">;</span>
<span class="Delimiter">}</span>
<span class="Delimiter">:(before &quot;End Primitive Recipe Implementations&quot;)</span>
<span class="Normal">case</span> CLEAR_DISPLAY_FROM: <span class="Delimiter">{</span>
  CHECK_SCREEN<span class="Delimiter">;</span>
  <span class="Comment">// todo: error checking</span>
  <span class="Normal">int</span> row = ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span>
  <span class="Normal">int</span> column = ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">1</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span>
  <span class="Normal">int</span> left = ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">2</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span>
  <span class="Normal">int</span> right = ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">3</span><span class="Delimiter">).</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span>
  <span class="Normal">int</span> height=tb_height<span class="Delimiter">();</span>
  <span class="Normal">for</span> <span class="Delimiter">(;</span> row &lt; height<span class="Delimiter">;</span> ++row<span class="Delimiter">,</span> column=left<span class="Delimiter">)</span> <span class="Delimiter">{</span>  <span class="Comment">// start column from left in every inner loop except first</span>
    <span class="Normal">for</span> <span class="Delimiter">(;</span> column &lt;= right<span class="Delimiter">;</span> ++column<span class="Delimiter">)</span> <span class="Delimiter">{</span>
      tb_change_cell<span class="Delimiter">(</span>column<span class="Delimiter">,</span> row<span class="Delimiter">,</span> <span class="Constant">' '</span><span class="Delimiter">,</span> TB_WHITE<span class="Delimiter">,</span> TB_BLACK<span class="Delimiter">);</span>
    <span class="Delimiter">}</span>
  <span class="Delimiter">}</span>
  <span class="Normal">if</span> <span class="Delimiter">(</span>Autodisplay<span class="Delimiter">)</span> tb_present<span class="Delimiter">();</span>
  <span class="Identifier">break</span><span class="Delimiter">;</span>
<span class="Delimiter">}</span>
</pre>
</body>
</html>
<!-- vim: set foldmethod=manual : -->