about summary refs log tree commit diff stats
path: root/ranger.py
Commit message (Expand)AuthorAgeFilesLines
...
* tons of stuffhut2009-12-171-1/+1
* merged main with __init__hut2009-12-121-1/+1
* restructurationshut2009-12-111-2/+4
* changing implementation of optionshut2009-12-061-3/+6
* structural improvementshut2009-12-011-46/+9
* random improvementshut2009-11-291-2/+2
* implemented colorschemes.hut2009-11-291-10/+10
* started to implement colorschemeshut2009-11-291-6/+11
* restructurationhut2009-11-281-33/+33
* embedded wrapper.sh into ranger.pyhut2009-11-271-0/+12
* cd-after-exithut2009-11-271-4/+17
* general improvementhut2009-11-271-1/+1
* more VROOMhut2009-11-271-0/+38
ik.com> 2017-03-07 01:41:48 -0800 committer Kartik K. Agaram <vc@akkartik.com> 2017-03-07 01:41:48 -0800 3761' href='/akkartik/mu/commit/html/057immutable.cc.html?h=main&id=9e751bb8c0cdf771d34c839cb6591d892b8e62de'>9e751bb8 ^
2f02189d ^
4a39d12d ^
2f02189d ^
e5c11a51 ^
6d007fda ^
4a39d12d ^
9e751bb8 ^

2f02189d ^





e5c11a51 ^






















2f02189d ^


e5c11a51 ^
2f02189d ^
204dae92 ^







201458e3 ^
204dae92 ^






2c678a4e ^
204dae92 ^



201458e3 ^
204dae92 ^







2c678a4e ^
204dae92 ^



201458e3 ^
204dae92 ^












201458e3 ^
204dae92 ^







2c678a4e ^
204dae92 ^









201458e3 ^
204dae92 ^









201458e3 ^
204dae92 ^


201458e3 ^
204dae92 ^












2c678a4e ^
204dae92 ^
201458e3 ^
204dae92 ^

201458e3 ^
204dae92 ^













201458e3 ^
204dae92 ^












201458e3 ^
204dae92 ^


201458e3 ^
204dae92 ^














201458e3 ^
204dae92 ^


201458e3 ^
204dae92 ^







2c678a4e ^
204dae92 ^
201458e3 ^
204dae92 ^

201458e3 ^
204dae92 ^







2c678a4e ^
204dae92 ^







201458e3 ^
204dae92 ^







201458e3 ^
204dae92 ^




201458e3 ^
204dae92 ^













201458e3 ^
204dae92 ^







201458e3 ^
204dae92 ^

201458e3 ^
204dae92 ^




201458e3 ^
204dae92 ^






201458e3 ^
204dae92 ^













201458e3 ^
204dae92 ^
















201458e3 ^
204dae92 ^



















201458e3 ^
204dae92 ^













201458e3 ^
204dae92 ^


201458e3 ^
204dae92 ^


















201458e3 ^
204dae92 ^

201458e3 ^
204dae92 ^




1c2d788b ^
204dae92 ^
2c678a4e ^
9e751bb8 ^




2c678a4e ^
9e751bb8 ^

2c678a4e ^
9e751bb8 ^

204dae92 ^


201458e3 ^

204dae92 ^
9e751bb8 ^


1c2d788b ^
9e751bb8 ^












204dae92 ^

9e751bb8 ^

1c2d788b ^
2c678a4e ^
9e751bb8 ^

204dae92 ^


201458e3 ^
204dae92 ^

1c2d788b ^
2c678a4e ^
9e751bb8 ^
204dae92 ^

2c678a4e ^
9e751bb8 ^

1c2d788b ^
9e751bb8 ^
204dae92 ^










201458e3 ^
204dae92 ^







2c678a4e ^
204dae92 ^





201458e3 ^
204dae92 ^

201458e3 ^
204dae92 ^
2c678a4e ^
9e751bb8 ^
1c2d788b ^
9e751bb8 ^

2b250717 ^
9e751bb8 ^
1c2d788b ^
9e751bb8 ^

204dae92 ^

201458e3 ^
204dae92 ^
1c2d788b ^
9e751bb8 ^












2b250717 ^
9e751bb8 ^
1c2d788b ^
9e751bb8 ^






2b250717 ^
9e751bb8 ^
1c2d788b ^
9e751bb8 ^

204dae92 ^


201458e3 ^
204dae92 ^

9e751bb8 ^

204dae92 ^
2c678a4e ^
201458e3 ^
204dae92 ^

201458e3 ^
2c678a4e ^
9e751bb8 ^

204dae92 ^



201458e3 ^
204dae92 ^
2c678a4e ^
9e751bb8 ^
1c2d788b ^
9e751bb8 ^
204dae92 ^




















201458e3 ^
204dae92 ^

















2c678a4e ^
204dae92 ^






9e751bb8 ^

1c2d788b ^
204dae92 ^














2f02189d ^



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







                                                                                          
                                                                                                               


                                           


                                                                                                 
                                       
                                      
                            
                             


                             
                            
                                                        
                              
                           
                               
                                                                           

                                  





                               






















                                                                                 


         
                             
                         







                                                                                                                                                  
                                                                                                                           






                                                                                                                                                                                                                         
                                                                                                                                                                                                                                                                



                                                                                                                                   
                                                                                                                            







                                                                                                                                                                                                
                                                                                                                                                                                                                                                                  



                                                                                                                                   
                                                                                                                            












                                                                                                                                                                                                                                                                 
                                                                                                                            







                                                                                                                                                                                          
                                                                                                                                                                                                                                                                                                                  









                                                                                                                       
                                                                                                                            









                                                                                                                                                                                               
                                                                                                                                                                                                                                            


                                                                                                                      
                                                                                                                            












                                                                                                                                                                                                                                                                                                 
                                                                                                                                                                                                                                                                
                                           
                                                                                                                                                                                                                                                                                                                  

                                                                                                                  
                                                                                                                             













                                                                                                                                                                                                
                                                                                                                             












                                                                                                                                                                                                
                                                                                                                                                                                                                                             


                                                                                                                     sh from unicode
        put(Memory, curr_address, /*tag for 'keycode' variant of 'event' exclusive-container*/1);
      }
      curr_address += size_of_event();
    }
    // End Event Handlers
    else {
      // keyboard input
      assert(inst.name == "type");
      trace(9999, "mem") << "storing 'type' event starting at " << curr_address << end();
      const string& contents = inst.ingredients.at(0).name;
      const char* raw_contents = contents.c_str();
      int num_keyboard_events = unicode_length(contents);
      int curr = 0;
      for (int i = 0;  i < num_keyboard_events;  ++i) {
        trace(9999, "mem") << "storing 'text' tag at " << curr_address << end();
        put(Memory, curr_address, /*tag for 'text' variant of 'event' exclusive-container*/0);
        uint32_t curr_character;
        assert(curr < SIZE(contents));
        tb_utf8_char_to_unicode(&curr_character, &raw_contents[curr]);
        trace(9999, "mem") << "storing character " << curr_character << " at " << curr_address+/*skip exclusive container tag*/1 << end();
        put(Memory, curr_address+/*skip exclusive container tag*/1, curr_character);
        curr += tb_utf8_char_length(raw_contents[curr]);
        curr_address += size_of_event();
      }
    }
  }
  assert(curr_address == event_data_address+size);
  // wrap the array of events in a console object
  int console_address = allocate(size_of_console());
  trace(9999, "mem") << "storing console in " << console_address << end();
  put(Memory, CONSOLE, console_address);
  trace(9999, "mem") << "storing console data in " << console_address+/*skip refcount*/1+/*offset of 'data' in container 'events'*/1 << end();
  put(Memory, console_address+/*skip refcount*/1+/*offset of 'data' in container 'events'*/1, event_data_address);
  // increment refcount for event data
  put(Memory, event_data_address, 1);
  // increment refcount for console
  put(Memory, console_address, 1);
  break;
}

:(before "End Globals")
map<string, int> Key;
:(before "End One-time Setup")
initialize_key_names();
:(code)
void initialize_key_names() {
  Key["F1"] = TB_KEY_F1;
  Key["F2"] = TB_KEY_F2;
  Key["F3"] = TB_KEY_F3;
  Key["F4"] = TB_KEY_F4;
  Key["F5"] = TB_KEY_F5;
  Key["F6"] = TB_KEY_F6;
  Key["F7"] = TB_KEY_F7;
  Key["F8"] = TB_KEY_F8;
  Key["F9"] = TB_KEY_F9;
  Key["F10"] = TB_KEY_F10;
  Key["F11"] = TB_KEY_F11;
  Key["F12"] = TB_KEY_F12;
  Key["insert"] = TB_KEY_INSERT;
  Key["delete"] = TB_KEY_DELETE;
  Key["home"] = TB_KEY_HOME;
  Key["end"] = TB_KEY_END;
  Key["page-up"] = TB_KEY_PGUP;
  Key["page-down"] = TB_KEY_PGDN;
  Key["up-arrow"] = TB_KEY_ARROW_UP;
  Key["down-arrow"] = TB_KEY_ARROW_DOWN;
  Key["left-arrow"] = TB_KEY_ARROW_LEFT;
  Key["right-arrow"] = TB_KEY_ARROW_RIGHT;
  Key["ctrl-a"] = TB_KEY_CTRL_A;
  Key["ctrl-b"] = TB_KEY_CTRL_B;
  Key["ctrl-c"] = TB_KEY_CTRL_C;
  Key["ctrl-d"] = TB_KEY_CTRL_D;
  Key["ctrl-e"] = TB_KEY_CTRL_E;
  Key["ctrl-f"] = TB_KEY_CTRL_F;
  Key["ctrl-g"] = TB_KEY_CTRL_G;
  Key["backspace"] = TB_KEY_BACKSPACE;
  Key["ctrl-h"] = TB_KEY_CTRL_H;
  Key["tab"] = TB_KEY_TAB;
  Key["ctrl-i"] = TB_KEY_CTRL_I;
  Key["ctrl-j"] = TB_KEY_CTRL_J;
  Key["enter"] = TB_KEY_NEWLINE;  // ignore CR/LF distinction; there is only 'enter'
  Key["ctrl-k"] = TB_KEY_CTRL_K;
  Key["ctrl-l"] = TB_KEY_CTRL_L;
  Key["ctrl-m"] = TB_KEY_CTRL_M;
  Key["ctrl-n"] = TB_KEY_CTRL_N;
  Key["ctrl-o"] = TB_KEY_CTRL_O;
  Key["ctrl-p"] = TB_KEY_CTRL_P;
  Key["ctrl-q"] = TB_KEY_CTRL_Q;
  Key["ctrl-r"] = TB_KEY_CTRL_R;
  Key["ctrl-s"] = TB_KEY_CTRL_S;
  Key["ctrl-t"] = TB_KEY_CTRL_T;
  Key["ctrl-u"] = TB_KEY_CTRL_U;
  Key["ctrl-v"] = TB_KEY_CTRL_V;
  Key["ctrl-w"] = TB_KEY_CTRL_W;
  Key["ctrl-x"] = TB_KEY_CTRL_X;
  Key["ctrl-y"] = TB_KEY_CTRL_Y;
  Key["ctrl-z"] = TB_KEY_CTRL_Z;
  Key["escape"] = TB_KEY_ESC;
  Key["ctrl-slash"] = TB_KEY_CTRL_SLASH;
}

:(after "Begin check_or_set_invalid_types(r)")
if (is_scenario(caller))
  initialize_special_name(r);
:(code)
bool is_scenario(const recipe& caller) {
  return starts_with(caller.name, "scenario_");
}
void initialize_special_name(reagent& r) {
  if (r.type) return;
  // no need for screen
  if (r.name == "console") r.type = new_type_tree("address:console");
  // End Initialize Type Of Special Name In Scenario(r)
}

:(scenario events_in_scenario)
scenario events-in-scenario [
  assume-console [
    type [abc]
    left-click 0, 1
    press up-arrow
    type [d]
  ]
  run [
    # 3 keyboard events; each event occupies 4 locations
    1:event <- read-event console
    5:event <- read-event console
    9:event <- read-event console
    # mouse click
    13:event <- read-event console
    # non-character keycode
    17:event <- read-event console
    # final keyboard event
    21:event <- read-event console
  ]
  memory-should-contain [
    1 <- 0  # 'text'
    2 <- 97  # 'a'
    3 <- 0  # unused
    4 <- 0  # unused
    5 <- 0  # 'text'
    6 <- 98  # 'b'
    7 <- 0  # unused
    8 <- 0  # unused
    9 <- 0  # 'text'
    10 <- 99  # 'c'
    11 <- 0  # unused
    12 <- 0  # unused
    13 <- 2  # 'mouse'
    14 <- 65513  # mouse click
    15 <- 0  # row
    16 <- 1  # column
    17 <- 1  # 'keycode'
    18 <- 65517  # up arrow
    19 <- 0  # unused
    20 <- 0  # unused
    21 <- 0  # 'text'
    22 <- 100  # 'd'
    23 <- 0  # unused
    24 <- 0  # unused
    25 <- 0
  ]
]

//: Deal with special keys and unmatched brackets by allowing each test to
//: independently choose the unicode symbol to denote them.
:(before "End Primitive Recipe Declarations")
REPLACE_IN_CONSOLE,
:(before "End Primitive Recipe Numbers")
put(Recipe_ordinal, "replace-in-console", REPLACE_IN_CONSOLE);
:(before "End Primitive Recipe Checks")
case REPLACE_IN_CONSOLE: {
  break;
}
:(before "End Primitive Recipe Implementations")
case REPLACE_IN_CONSOLE: {
  assert(scalar(ingredients.at(0)));
  if (!get_or_insert(Memory, CONSOLE)) {
    raise << "console not initialized\n" << end();
    break;
  }
  int console_address = get_or_insert(Memory, CONSOLE);
  int console_data = get_or_insert(Memory, console_address+1);
  int length = get_or_insert(Memory, console_data);  // array length
  for (int i = 0, curr = console_data+1;  i < length;  ++i, curr+=size_of_event()) {
    if (get_or_insert(Memory, curr) != /*text*/0) continue;
    if (get_or_insert(Memory, curr+1) != ingredients.at(0).at(0)) continue;
    for (int n = 0;  n < size_of_event();  ++n)
      put(Memory, curr+n, ingredients.at(1).at(n));
  }
  break;
}

:(code)
int count_events(const recipe& r) {
  int result = 0;
  for (int i = 0;  i < SIZE(r.steps);  ++i) {
    const instruction& curr = r.steps.at(i);
    if (curr.name == "type")
      result += unicode_length(curr.ingredients.at(0).name);
    else
      ++result;
  }
  return result;
}

int size_of_event() {
  // memoize result if already computed
  static int result = 0;
  if (result) return result;
  type_tree* type = new type_tree("event");
  result = size_of(type);
  delete type;
  return result;
}

int size_of_console() {
  // memoize result if already computed
  static int result = 0;
  if (result) return result;
  assert(get(Type_ordinal, "console"));
  type_tree* type = new type_tree("console");
  result = size_of(type)+/*refcount*/1;
  delete type;
  return result;
}