summary refs log tree commit diff stats
Commit message (Collapse)AuthorAgeFilesLines
...
| * | api.apps: added generic app handlershut2010-04-272-62/+45
| | |
* | | Closed #83 since I implemented :markhut2010-04-271-1/+1
| | |
* | | Fixed #85: no automatic reload after using :filterhut2010-04-272-1/+2
| | |
* | | defaults.options: slight rearranginghut2010-04-271-4/+4
| | |
* | | defaults.commands: Added :unmarkhut2010-04-272-8/+17
| | |
* | | defaults.commands: redraw after using :markhut2010-04-271-0/+2
| | |
* | | defaults.commands: added optional "minus" argument for :markhut2010-04-272-4/+8
| | |
* | | Added :mark commandhut2010-04-272-0/+25
|/ /
* | defaults.apps: don't run *.swf in elinks ;(hut2010-04-261-2/+2
| |
* | defaults.apps: moved INTERPRETED_LANGUAGES to the bottomhut2010-04-261-5/+5
| |
* | defaults.apps: use "f = c.file" in the examplehut2010-04-261-2/+3
| |
* | api.apps: Removed unnecessary (?) docstringhut2010-04-261-4/+0
| |
* | removed trailing whitespacehut2010-04-261-1/+1
| |
* | api.options: removed unused importhut2010-04-261-1/+0
| |
* | defaults.commands: use octal literal instead of decimal number in chmod()hut2010-04-261-1/+1
| |
* | defaults.commands: fixed :find with uppercase search stringshut2010-04-261-1/+5
| |
* | widgets.pager: Fixed off-by-one error for boundarieshut2010-04-261-2/+2
| |
* | Added tc_loaderhut2010-04-262-1/+186
| |
* | TODO: moved #60 to "General"hut2010-04-261-1/+1
| |
* | Fixed bug #65 by adding flag "--fail-if-run"hut2010-04-265-5/+12
| |
* | fixed bug #78: broken preview when deleting all files in a directoryhut2010-04-262-1/+3
| |
* | core.actions: implemented "move_parent", improve this later!hut2010-04-261-0/+5
| |
* | widgets.browsercolumn: fixed width-check for infostringhut2010-04-261-1/+1
| |
* | shutil_generatorized: fixed bad destination name on move+overwritehut2010-04-261-2/+2
| |
* | gui.colorscheme: fixed error when using custom colorschemeshut2010-04-261-0/+4
| |
* | fsobject.directory: removed invalid signal binding 'setopt.filter'hut2010-04-261-1/+1
| |
* | TODO: updatehut2010-04-261-0/+2
| |
* | ranger.defaults.apps: use "make" for Makefileshut2010-04-231-0/+3
| |
* | main: fixed "ranger /path/to/a/file"hut2010-04-231-4/+6
| |
* | main: new function "load_apps"hut2010-04-231-0/+13
| |
* | main: new function "allow_access_to_confdir"hut2010-04-231-6/+14
|/
* Move loader.py from ranger.fsobject to ranger.corehut2010-04-204-3/+2
|
* updated pydochut2010-04-205-248/+10
|
* ext.shutil_generatorized: fixed __all__hut2010-04-201-1/+1
|
* ext.shutil_generatorized: little optimizationhut2010-04-201-2/+2
|
* ext.shutil_generatorized: remove unused functions/importshut2010-04-201-36/+0
|
* updated pydochut2010-04-1941-2286/+247
|
* defaults.commands: bugfixhut2010-04-191-1/+1
|
* defaults.keys: quit pager with F3hut2010-04-191-2/+2
|
* TODO: updatedhut2010-04-191-1/+2
|
* Added midnight commander-like function keyshut2010-04-192-1/+23
|
* ranger.api: import common variableshut2010-04-196-2/+7
|
* Turn keycomb ".term" into command ":terminal"hut2010-04-193-1/+13
|
* Clean uphut2010-04-1915-53/+39
| | | | | Mostly remove unused imports and move imports from functions to the module level
* Use "/" for root in tabname if "dirname_in_tab" is truehut2010-04-191-1/+1
|
* added option "dirname_in_tabs"hut2010-04-193-3/+16
|
* ext.keybinding_parser: added aliases for common special keyshut2010-04-191-0/+3
|
* ext.keybinding_parser: fixed function keyshut2010-04-192-1/+4
|
* defaults.apps: added fceuxhut2010-04-191-0/+6
|
* README: Removed finished parts of roadmaphut2010-04-191-2/+0
|
title='Blame the previous revision' href='/akkartik/mu/blame/subx/054string-equal.subx?h=hlt&id=1076cc4cf93bd4a8df72caeae67a57010f7e53bc'>^
33352536 ^
db268970 ^
33352536 ^
db268970 ^
33352536 ^
d20fbf71 ^
db268970 ^
33352536 ^
db268970 ^
33352536 ^
d20fbf71 ^

33352536 ^
d20fbf71 ^

33352536 ^
d20fbf71 ^
ee9a9237 ^
33352536 ^



7a583220 ^
33352536 ^

6030d7e2 ^
d11372f6 ^
9d27e966 ^
d11372f6 ^
03d50cc8 ^
33352536 ^
ee9a9237 ^
6030d7e2 ^

ee9a9237 ^
71ee78f2 ^
ee9a9237 ^
33352536 ^

ee9a9237 ^
6030d7e2 ^

33352536 ^
ee9a9237 ^
6030d7e2 ^
ee9a9237 ^
33352536 ^
6030d7e2 ^
d11372f6 ^
bfcc0f85 ^
33352536 ^
ee9a9237 ^
6030d7e2 ^

ee9a9237 ^
71ee78f2 ^
ee9a9237 ^
33352536 ^

ee9a9237 ^
6030d7e2 ^

33352536 ^
ee9a9237 ^
6030d7e2 ^
ee9a9237 ^
33352536 ^
6030d7e2 ^
d11372f6 ^
03d50cc8 ^
33352536 ^
ee9a9237 ^
6030d7e2 ^

ee9a9237 ^
71ee78f2 ^
ee9a9237 ^
33352536 ^

ee9a9237 ^
6030d7e2 ^

33352536 ^
ee9a9237 ^
6030d7e2 ^
ee9a9237 ^
33352536 ^
6030d7e2 ^
d11372f6 ^
bfcc0f85 ^
33352536 ^
ee9a9237 ^
6030d7e2 ^

ee9a9237 ^
71ee78f2 ^
ee9a9237 ^
33352536 ^

ee9a9237 ^
bfcc0f85 ^
6030d7e2 ^
33352536 ^
ee9a9237 ^
6030d7e2 ^
ee9a9237 ^
33352536 ^
6030d7e2 ^
ed0e64a9 ^
0b2d2d97 ^
71eb22a5 ^
7a583220 ^
33352536 ^

0b2d2d97 ^
33352536 ^
71eb22a5 ^
0b2d2d97 ^
33352536 ^

0b2d2d97 ^


33352536 ^

0b2d2d97 ^
33352536 ^
0b2d2d97 ^
33352536 ^
0b2d2d97 ^


33352536 ^
8d543783 ^
0b2d2d97 ^
33352536 ^
7a583220 ^
33352536 ^

0b2d2d97 ^


8d543783 ^

0b2d2d97 ^



8d543783 ^
0b2d2d97 ^
33352536 ^
0b2d2d97 ^

ee9a9237 ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
                                            

       


                                                                                                                                                 
 
                       
                                                
                                                                                                                                         
                                      
                                                                                                                                                                                      
                                
 
                                                                                           
                 
                                                    












                                                                                                                                                                             
                   
                                                                                                                                                                        

                                              





                                                                                                                                                                            
                                                                                                                                                                      














                                                                                                                                                                       
                                                                                                 
                 
                                                   

                               
                                                
                          


                                    
                          
                   
     
                




                  
     
                

                                                                                                                                                                       
                      







                                                                                                                                                                             
                                          
                                                                                                                                                                        

                                       

                                                                                                                                                                             
                                          
                                                                                                                                                                  
                                                  
                                                                                                                                                                  
                                                                   
                                                                                                                                                                      
                          
                                                                                                                                                                 
                          
                                                                                                                                                                 
                          
                                    

                                                                                                                                                                            
                 
                                                                                                                                                                               
                 
                                                                                                                                                                               
                                
                                                                                                                                                                           
                                                   
             
                    
             
                    

                                            
                           

                                           
                           
                         
                         



                 
                

                                                                                                                                                                       
             
 
         
 
                                     
                                 
                   

                     
              
                                 
                      

                                                                                                                                                                  
                   

                                                             
               
              
                                    
                      
                                                                                                                                                                  
             
 
                                                                                
                                    
                   

                        
              
                                 
                      

                                                                                                                                                                  
                   

                                                                 
               
              
                                    
                      
                                                                                                                                                                  
             
 
                           
                                       
                   

                        
              
                                 
                      

                                                                                                                                                                  
                   

                                                   
               
              
                                    
                      
                                                                                                                                                                  
             
 
                                         
                                       
                   

                        
              
                                 
                      

                                                                                                                                                                  
                   
                                                                 
                          
               
              
                                    
                      
                                                                                                                                                                  
             
 
                        
                                                                                                 
                

                                                                                                                                                                       
                      
               
                                                   
                   

                                                                                                                                                                      


                                 

                                                                                                                                                                  
                   
                                                                                                                                                                      
                    
               


                                    
                                                                                                                                                                  
                         
                         
                 
                

                                                                                                                                                                       


                 

                                        



                        
                                       
                      
                                                                                                                                                                  

             
                            
lt'>
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517


                                                                             
 

                       
                       
                                        
                        
 
                                             
             
                                        
                                                  



                                       
                                                
                    

                                   

                           

                                                 
                                                                                                                                  
                   
                                                                                                                                   



                                             
              
                                        
                                                    



                                       
                                                
                     
                


        


                        
                                             

                                        
                                                    



                                       

                                                

                                   



                                             

                                        
                                                  



                                       






                                                

                                        
                                                                    



                                       

                                                

                                                
                                                            

                                             
                                





                                             
                                                                              

                                       
                                 
                                                                                                                                                                


                                              
                                                                                                                                                                                           



                                                
                                                                                                                                                                                                            




                                                
                                                                                                                                                                                                           


            

        

                                                
                                  


                                  

                              
                                    


                              



                                                                  

                                 


                                                 
                                    


          

                             
                                                                          

                                                 
                                    


          

                                 

                                               
                                





                                             
                                                                              



                                       

                                                


                                           





                                             
                                                                      
                                       
                              
                                    
                                                                                                                                                    

          
                                              
                                                                                                                                                                                        

          
                                              
                                                                                                                                                                                            

          




                                                
                                           
                                             
                                


        


                                             
                                                                                



                                       

                                                
                    
                                


                                               
                                  
   





                                             
                                                                            



                                       

                                                


                                               
                                  
   





                                             
                                                                                  



                                       

                                                
                   
                               


                                               
                                  
   





                                             
                                                                                



                                       

                                                


                                               
                                  
   


        







                                                             
                       




                                             


                                             
                                                    



                                       









                                                
                                                      



                                       






                                                


                                             
                                                                      



                                       








                                                
                                                                      



                                       





                                                


                                             
                                                  



                                       








                                                
                                                  



                                       






                                                
                              

                                             
                          
                                        
                                                                            



                                       
                                                
                                 
                 
                        



                                             
                      
                                        
                                                                    



                                       
                                                

                                           
                 
                                                  










                                                       

                                     

              








                                                                                  
                                   





                                                 
   
                                     
                                               





                                                               








                                                 




                                           

        



                                             
                                                             



                                       





                                                





                                             
                                                              



                                       















                                                                                                        
//: Take raw control of the text-mode display and console, putting it in
//: 'console' mode rather than the usual automatically-scrolling 'typewriter'
//: mode.

//:: Display management

:(before "End Globals")
int Display_row = 0, Display_column = 0;
bool Autodisplay = true;

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

:(before "End Primitive Recipe Declarations")
CLOSE_CONSOLE,
:(before "End Primitive Recipe Numbers")
put(Recipe_ordinal, "close-console", CLOSE_CONSOLE);
:(before "End Primitive Recipe Checks")
case CLOSE_CONSOLE: {
  break;
}
:(before "End Primitive Recipe Implementations")
case CLOSE_CONSOLE: {
  tb_shutdown();
  break;
}

:(before "End Teardown")
tb_shutdown();

:(before "End Primitive Recipe Declarations")
CLEAR_DISPLAY,
:(before "End Primitive Recipe Numbers")
put(Recipe_ordinal, "clear-display", CLEAR_DISPLAY);
:(before "End Primitive Recipe Checks")
case CLEAR_DISPLAY: {
  break;
}
:(before "End Primitive Recipe Implementations")
case CLEAR_DISPLAY: {
  tb_clear();
  Display_row = Display_column = 0;
  break;
}

:(before "End Primitive Recipe Declarations")
SYNC_DISPLAY,
:(before "End Primitive Recipe Numbers")
put(Recipe_ordinal, "sync-display", SYNC_DISPLAY);
:(before "End Primitive Recipe Checks")
case SYNC_DISPLAY: {
  break;
}
:(before "End Primitive Recipe Implementations")
case SYNC_DISPLAY: {
  tb_sync();
  break;
}

:(before "End Primitive Recipe Declarations")
CLEAR_LINE_ON_DISPLAY,
:(before "End Primitive Recipe Numbers")
put(Recipe_ordinal, "clear-line-on-display", CLEAR_LINE_ON_DISPLAY);
:(before "End Primitive Recipe Checks")
case CLEAR_LINE_ON_DISPLAY: {
  break;
}
:(before "End Primitive Recipe Implementations")
case CLEAR_LINE_ON_DISPLAY: {
  int width = tb_width();
  for (int x = Display_column; x < width; ++x) {
    tb_change_cell(x, Display_row, ' ', TB_WHITE, TB_BLACK);
  }
  tb_set_cursor(Display_column, Display_row);
  if (Autodisplay) tb_present();
  break;
}

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

:(before "End Primitive Recipe Declarations")
CURSOR_POSITION_ON_DISPLAY,
:(before "End Primitive Recipe Numbers")
put(Recipe_ordinal, "cursor-position-on-display", CURSOR_POSITION_ON_DISPLAY);
:(before "End Primitive Recipe Checks")
case CURSOR_POSITION_ON_DISPLAY: {
  break;
}
:(before "End Primitive Recipe Implementations")
case CURSOR_POSITION_ON_DISPLAY: {
  products.resize(2);
  products.at(0).push_back(Display_row);
  products.at(1).push_back(Display_column);
  break;
}

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

:(before "End Primitive Recipe Declarations")
MOVE_CURSOR_DOWN_ON_DISPLAY,
:(before "End Primitive Recipe Numbers")
put(Recipe_ordinal, "move-cursor-down-on-display", MOVE_CURSOR_DOWN_ON_DISPLAY);
:(before "End Primitive Recipe Checks")
case MOVE_CURSOR_DOWN_ON_DISPLAY: {
  break;
}
:(before "End Primitive Recipe Implementations")
case MOVE_CURSOR_DOWN_ON_DISPLAY: {
  int h=tb_height();
  int height = (h >= 0) ? h : 0;
  if (Display_row < height-1) {
    Display_row++;
    tb_set_cursor(Display_column, Display_row);
    if (Autodisplay) tb_present();
  }
  break;
}

:(before "End Primitive Recipe Declarations")
MOVE_CURSOR_UP_ON_DISPLAY,
:(before "End Primitive Recipe Numbers")
put(Recipe_ordinal, "move-cursor-up-on-display", MOVE_CURSOR_UP_ON_DISPLAY);
:(before "End Primitive Recipe Checks")
case MOVE_CURSOR_UP_ON_DISPLAY: {
  break;
}
:(before "End Primitive Recipe Implementations")
case MOVE_CURSOR_UP_ON_DISPLAY: {
  if (Display_row > 0) {
    Display_row--;
    tb_set_cursor(Display_column, Display_row);
    if (Autodisplay) tb_present();
  }
  break;
}

:(before "End Primitive Recipe Declarations")
MOVE_CURSOR_RIGHT_ON_DISPLAY,
:(before "End Primitive Recipe Numbers")
put(Recipe_ordinal, "move-cursor-right-on-display", MOVE_CURSOR_RIGHT_ON_DISPLAY);
:(before "End Primitive Recipe Checks")
case MOVE_CURSOR_RIGHT_ON_DISPLAY: {
  break;
}
:(before "End Primitive Recipe Implementations")
case MOVE_CURSOR_RIGHT_ON_DISPLAY: {
  int w=tb_width();
  int width = (w >= 0) ? w : 0;
  if (Display_column < width-1) {
    Display_column++;
    tb_set_cursor(Display_column, Display_row);
    if (Autodisplay) tb_present();
  }
  break;
}

:(before "End Primitive Recipe Declarations")
MOVE_CURSOR_LEFT_ON_DISPLAY,
:(before "End Primitive Recipe Numbers")
put(Recipe_ordinal, "move-cursor-left-on-display", MOVE_CURSOR_LEFT_ON_DISPLAY);
:(before "End Primitive Recipe Checks")
case MOVE_CURSOR_LEFT_ON_DISPLAY: {
  break;
}
:(before "End Primitive Recipe Implementations")
case MOVE_CURSOR_LEFT_ON_DISPLAY: {
  if (Display_column > 0) {
    Display_column--;
    tb_set_cursor(Display_column, Display_row);
    if (Autodisplay) tb_present();
  }
  break;
}

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

:(before "End Primitive Recipe Declarations")
DISPLAY_WIDTH,
:(before "End Primitive Recipe Numbers")
put(Recipe_ordinal, "display-width", DISPLAY_WIDTH);
:(before "End Primitive Recipe Checks")
case DISPLAY_WIDTH: {
  break;
}
:(before "End Primitive Recipe Implementations")
case DISPLAY_WIDTH: {
  products.resize(1);
  products.at(0).push_back(tb_width());
  break;
}

:(before "End Primitive Recipe Declarations")
DISPLAY_HEIGHT,
:(before "End Primitive Recipe Numbers")
put(Recipe_ordinal, "display-height", DISPLAY_HEIGHT);
:(before "End Primitive Recipe Checks")
case DISPLAY_HEIGHT: {
  break;
}
:(before "End Primitive Recipe Implementations")
case DISPLAY_HEIGHT: {
  products.resize(1);
  products.at(0).push_back(tb_height());
  break;
}

:(before "End Primitive Recipe Declarations")
HIDE_CURSOR_ON_DISPLAY,
:(before "End Primitive Recipe Numbers")
put(Recipe_ordinal, "hide-cursor-on-display", HIDE_CURSOR_ON_DISPLAY);
:(before "End Primitive Recipe Checks")
case HIDE_CURSOR_ON_DISPLAY: {
  break;
}
:(before "End Primitive Recipe Implementations")
case HIDE_CURSOR_ON_DISPLAY: {
  tb_set_cursor(TB_HIDE_CURSOR, TB_HIDE_CURSOR);
  break;
}

:(before "End Primitive Recipe Declarations")
SHOW_CURSOR_ON_DISPLAY,
:(before "End Primitive Recipe Numbers")
put(Recipe_ordinal, "show-cursor-on-display", SHOW_CURSOR_ON_DISPLAY);
:(before "End Primitive Recipe Checks")
case SHOW_CURSOR_ON_DISPLAY: {
  break;
}
:(before "End Primitive Recipe Implementations")
case SHOW_CURSOR_ON_DISPLAY: {
  tb_set_cursor(Display_row, Display_column);
  break;
}

:(before "End Primitive Recipe Declarations")
HIDE_DISPLAY,
:(before "End Primitive Recipe Numbers")
put(Recipe_ordinal, "hide-display", HIDE_DISPLAY);
:(before "End Primitive Recipe Checks")
case HIDE_DISPLAY: {
  break;
}
:(before "End Primitive Recipe Implementations")
case HIDE_DISPLAY: {
  Autodisplay = false;
  break;
}

:(before "End Primitive Recipe Declarations")
SHOW_DISPLAY,
:(before "End Primitive Recipe Numbers")
put(Recipe_ordinal, "show-display", SHOW_DISPLAY);
:(before "End Primitive Recipe Checks")
case SHOW_DISPLAY: {
  break;
}
:(before "End Primitive Recipe Implementations")
case SHOW_DISPLAY: {
  Autodisplay = true;
  tb_present();
  break;
}

//:: Keyboard/mouse management

:(before "End Primitive Recipe Declarations")
WAIT_FOR_SOME_INTERACTION,
:(before "End Primitive Recipe Numbers")
put(Recipe_ordinal, "wait-for-some-interaction", WAIT_FOR_SOME_INTERACTION);
:(before "End Primitive Recipe Checks")
case WAIT_FOR_SOME_INTERACTION: {
  break;
}
:(before "End Primitive Recipe Implementations")
case WAIT_FOR_SOME_INTERACTION: {
  tb_event event;
  tb_poll_event(&event);
  break;
}

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

:(before "End Primitive Recipe Declarations")
INTERACTIONS_LEFT,
:(before "End Primitive Recipe Numbers")
put(Recipe_ordinal, "interactions-left?", INTERACTIONS_LEFT);
:(before "End Primitive Recipe Checks")
case INTERACTIONS_LEFT: {
  break;
}
:(before "End Primitive Recipe Implementations")
case INTERACTIONS_LEFT: {
  products.resize(1);
  products.at(0).push_back(tb_event_ready());
  break;
}

//: a hack to make edit.mu more responsive

:(before "End Primitive Recipe Declarations")
CLEAR_DISPLAY_FROM,
:(before "End Primitive Recipe Numbers")
put(Recipe_ordinal, "clear-display-from", CLEAR_DISPLAY_FROM);
:(before "End Primitive Recipe Checks")
case CLEAR_DISPLAY_FROM: {
  break;
}
:(before "End Primitive Recipe Implementations")
case CLEAR_DISPLAY_FROM: {
  // todo: error checking
  int row = ingredients.at(0).at(0);
  int column = ingredients.at(1).at(0);
  int left = ingredients.at(2).at(0);
  int right = ingredients.at(3).at(0);
  int height=tb_height();
  for (; row < height; ++row, column=left) {  // start column from left in every inner loop except first
    for (; column <= right; ++column) {
      tb_change_cell(column, row, ' ', TB_WHITE, TB_BLACK);
    }
  }
  if (Autodisplay) tb_present();
  break;
}