summary refs log tree commit diff stats
Commit message (Expand)AuthorAgeFilesLines
...
| * | :meta may be used on multiple selected filesWojciech Siewierski2015-01-171-1/+3
|/ /
* | add .paperinfo->.metadata.json conversion scripthut2015-01-171-0/+69
* | core.metadata: added another TODO entryhut2015-01-171-0/+1
* | Merge branch 'cd-select_file' of https://github.com/NoSuck/ranger into cd-sel...hut2015-01-171-1/+2
|\ \
| * | Modified cd command to select original file, when following links.The Flying Rapist2015-01-131-1/+2
* | | container.directory: don't crash get_selection if files is Nonehut2015-01-171-0/+2
* | | core.metadata: add some TODO entrieshut2015-01-171-0/+3
* | | Merge branch 'metadata'hut2015-01-1712-328/+272
|\ \ \
| * | | core.metadata: delete keys if value is emptyhut2015-01-171-0/+5
| * | | updated documentation of :paper/:meta commandshut2015-01-172-72/+57
| * | | core.metadata: use DefaultOpenStruct instead of OpenStructhut2015-01-172-8/+8
| * | | ext.openstruct: added DefaultOpenStructhut2015-01-171-0/+15
| * | | core.metadata: use basenames by defaulthut2015-01-171-2/+4
| * | | core.metadata: works well now, at first glancehut2015-01-173-111/+71
| * | | core.metadata: added comments for self.meta{file,data}_cachehut2015-01-171-0/+2
| * | | started porting core.metadata from csv to jsonhut2015-01-171-12/+24
| * | | adapted commands for MetadataManagerhut2015-01-165-72/+42
| * | | start turning ext.papermanager to core.metadatahut2015-01-137-45/+38
| |/ /
* / / gui.ui: removed some finished TODO entrieshut2015-01-161-2/+0
|/ /
* | ext.direction: fixed "move up=1 cycle=false"hut2015-01-041-1/+1
* | Merge branch 'move-cycle' of https://github.com/PotatoesMaster/rangerhut2015-01-041-0/+5
|\ \
| * | Add a 'cycle' option to directionEmanuel Guevel2014-12-151-0/+5
* | | doc/ranger.1: added doc for "rename_append"hut2015-01-012-1/+12
* | | config/rc.conf: make "a" binding use :rename_appendhut2015-01-011-1/+1
* | | Merge branch 'rename_append' of https://github.com/NoSuck/rangerhut2015-01-011-6/+6
|\ \ \
| * | | renameConsole -> rename_append; added special cases for hidden files and dire...The Flying Rapist2015-01-021-6/+6
|/ / /
* | | Merge branch 'master' of https://github.com/aureooms/rangerhut2014-12-282-15/+18
|\ \ \ | |/ / |/| |
| * | add javascript file type to mime.types and rifle.confaureooms2014-12-192-15/+18
|/ /
* | config/commands.py: fixed py3-specific encoding bughut2014-12-141-4/+1
* | rebuilt man pagehut2014-12-111-3/+3
* | Merge branch 'doc-typo' of https://github.com/mathstuf/rangerhut2014-12-111-1/+1
|\ \
| * | doc: match the default configuration for untag mapBen Boeckel2014-12-111-1/+1
|/ /
* | HACKING.md: better specification of python versionshut2014-12-111-1/+1
* | update email addresshut2014-12-1159-60/+60
* | Merge branch 'fix-hacking-references' of https://github.com/threeifbywhiskey/...hut2014-12-114-7/+7
|\ \
| * | Fixed references to doc/HACKING (for real)Dorien Snake2014-12-104-4/+4
| * | Fixed references to doc/HACKINGDorien Snake2014-12-104-7/+7
|/ /
* | HACKING.md: clarificationshut2014-12-101-4/+4
* | HACKING.md: typohut2014-12-101-1/+1
* | HACKING.md: use markdown list in "Starting Points" subsectionhut2014-12-101-5/+7
* | use markdown in HACKING.md, update it, fix typoshut2014-12-101-28/+46
* | mv doc/HACKING ./HACKING.mdhut2014-12-101-0/+0
* | config/commands.py: fix bulkrename on OSX 10.8, fixes #136hut2014-12-101-4/+6
* | fix typo in previous commithut2014-12-101-1/+1
* | container.directory: filtering optimizationshut2014-12-101-3/+6
* | container.directory: more efficient filteringhut2014-12-101-7/+8
* | container.directory: Fixed :scout -tf, fixes #195hut2014-12-101-0/+3
* | api.commands: sort commands when tabbing in the console, fixes #171hut2014-12-101-1/+1
* | config/commands.py: fix input delay, fixes #181hut2014-12-101-1/+1
* | api.commands: Added attribute Command.quickly_executedhut2014-12-102-1/+8
iv>
45c08fea ^


2dab0edb ^
45c08fea ^


2dab0edb ^

45c08fea ^




























8f060500 ^
45c08fea ^







2dab0edb ^

4938a720 ^
fedebaf5 ^

























4938a720 ^



































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




                                                                       

                            


                                
              

       



                                                                                  

                         








                                


   
                                
                                                                     

                                                  

                                   
                                     
                                
 
                                                                            

                                             
               
                                        
                                                 
                                                
                      
                                                                                    



                                                                                    
                                                  








                                                                          
                                                                                                         





                                                                                                                                 
                                    
                                                                                                     
                                                                                 
                                                                                 

                                                







                                                                   
                                                               
                                                               
                                                                                                    


                                                                      
                                                                    








                                                                                          
                                           
                                             



                                                                                                     


        


                              
              


                           

       




























                                                        
                        







                           

   
 

























                                                                                          



































                                                                    
//: Clean syntax to manipulate and check the console in scenarios.
//: Instruction 'assume-console' implicitly creates a variable called
//: 'console' that is accessible inside other 'run' instructions in the
//: scenario. Like with the fake screen, 'assume-console' transparently
//: supports unicode.

:(scenarios run_mu_scenario)
:(scenario keyboard_in_scenario)
scenario keyboard-in-scenario [
  assume-console [
    type [abc]
  ]
  run [
    1:character, console:address, 2:boolean <- read-key console:address
    3:character, console:address, 4:boolean <- read-key console:address
    5:character, console:address, 6:boolean <- read-key console:address
    7:character, console:address, 8:boolean, 9:boolean <- read-key console:address
  ]
  memory-should-contain [
    1 <- 97  # 'a'
    2 <- 1
    3 <- 98  # 'b'
    4 <- 1
    5 <- 99  # 'c'
    6 <- 1
    7 <- 0  # unset
    8 <- 1
    9 <- 1  # end of test events
  ]
]

:(before "End Scenario Globals")
const long long int CONSOLE = Next_predefined_global_for_scenarios++;
:(before "End Special Scenario Variable Names(r)")
Name[r]["console"] = CONSOLE;

//: allow naming just for 'console'
:(before "End is_special_name Cases")
if (s == "console") return true;

//: Unlike assume-keyboard, assume-console is easiest to implement as just a
//: primitive recipe.
:(before "End Primitive Recipe Declarations")
ASSUME_CONSOLE,
:(before "End Primitive Recipe Numbers")
Recipe_number["assume-console"] = ASSUME_CONSOLE;
:(before "End Primitive Recipe Implementations")
case ASSUME_CONSOLE: {
//?   cerr << "aaa: " << current_instruction().ingredients.at(0).name << '\n'; //? 2
  // create a temporary recipe just for parsing; it won't contain valid instructions
  istringstream in("[" + current_instruction().ingredients.at(0).name + "]");
  recipe r = slurp_recipe(in);
  long long int num_events = count_events(r);
//?   cerr << "fff: " << num_events << '\n'; //? 3
  // initialize the events
  long long int size = num_events*size_of_event() + /*space for length*/1;
  ensure_space(size);
  long long int event_data_address = Current_routine->alloc;
  Memory[event_data_address] = num_events;
  ++Current_routine->alloc;
  for (long long int i = 0; i < SIZE(r.steps); ++i) {
    const instruction& curr = r.steps.at(i);
    if (curr.name == "left-click") {
      Memory[Current_routine->alloc] = /*tag for 'touch-event' variant of 'event' exclusive-container*/2;
      Memory[Current_routine->alloc+1+/*offset of 'type' in 'mouse-event'*/0] = TB_KEY_MOUSE_LEFT;
      Memory[Current_routine->alloc+1+/*offset of 'row' in 'mouse-event'*/1] = to_integer(curr.ingredients.at(0).name);
      Memory[Current_routine->alloc+1+/*offset of 'column' in 'mouse-event'*/2] = to_integer(curr.ingredients.at(1).name);
//?       cerr << "AA left click: " << Memory[Current_routine->alloc+2] << ' ' << Memory[Current_routine->alloc+3] << '\n'; //? 1
      Current_routine->alloc += size_of_event();
    }
    else if (curr.name == "press") {
      Memory[Current_routine->alloc] = /*tag for 'keycode' variant of 'event' exclusive-container*/1;
      Memory[Current_routine->alloc+1] = to_integer(curr.ingredients.at(0).name);
//?       cerr << "AA press: " << Memory[Current_routine->alloc+1] << '\n'; //? 3
      Current_routine->alloc += size_of_event();
    }
    // End Event Handlers
    else {
      // keyboard input
      assert(curr.name == "type");
      const string& contents = curr.ingredients.at(0).name;
      const char* raw_contents = contents.c_str();
      long long int num_keyboard_events = unicode_length(contents);
      long long int curr = 0;
//?       cerr << "AAA: " << num_keyboard_events << '\n'; //? 1
      for (long long int i = 0; i < num_keyboard_events; ++i) {
        Memory[Current_routine->alloc] = /*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]);
//?         cerr << "AA keyboard: " << curr_character << '\n'; //? 3
        Memory[Current_routine->alloc+/*skip exclusive container tag*/1] = curr_character;
        curr += tb_utf8_char_length(raw_contents[curr]);
        Current_routine->alloc += size_of_event();
      }
    }
  }
  assert(Current_routine->alloc == event_data_address+size);
  // wrap the array of events in an event object
  ensure_space(size_of_events());
  Memory[CONSOLE] = Current_routine->alloc;
  Current_routine->alloc += size_of_events();
//?   cerr << "writing " << event_data_address << " to location " << Memory[CONSOLE]+1 << '\n'; //? 1
  Memory[Memory[CONSOLE]+/*offset of 'data' in container 'events'*/1] = event_data_address;
//?   cerr << Memory[Memory[CONSOLE]+1] << '\n'; //? 1
//?   cerr << "alloc now " << Current_routine->alloc << '\n'; //? 1
  break;
}

:(scenario events_in_scenario)
scenario events-in-scenario [
  assume-console [
    type [abc]
    left-click 0, 1
    press 65515  # up arrow
    type [d]
  ]
  run [
    # 3 keyboard events; each event occupies 4 locations
#?     $start-tracing #? 2
    1:event <- read-event console:address
    5:event <- read-event console:address
    9:event <- read-event console:address
    # mouse click
    13:event <- read-event console:address
    # non-character keycode
    17:event <- read-event console:address
    # final keyboard event
    21:event <- read-event console:address
  ]
  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 <- 65515  # 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")
Recipe_number["replace-in-console"] = REPLACE_IN_CONSOLE;
:(before "End Primitive Recipe Implementations")
case REPLACE_IN_CONSOLE: {
  assert(scalar(ingredients.at(0)));
//?   cerr << "console: " << Memory[CONSOLE] << '\n'; //? 1
  if (!Memory[CONSOLE])
    raise << "console not initialized\n" << die();
  long long int console_data = Memory[Memory[CONSOLE]+1];
//?   cerr << "console data starts at " << console_data << '\n'; //? 1
  long long int size = Memory[console_data];  // array size
//?   cerr << "size of console data is " << size << '\n'; //? 1
  for (long long int i = 0, curr = console_data+1; i < size; ++i, curr+=size_of_event()) {
//?     cerr << curr << '\n'; //? 1
    if (Memory[curr] != /*text*/0) continue;
    if (Memory[curr+1] != ingredients.at(0).at(0)) continue;
    for (long long int n = 0; n < size_of_event(); ++n)
      Memory[curr+n] = ingredients.at(1).at(n);
  }
  break;
}

:(code)
long long int count_events(const recipe& r) {
  long long int result = 0;
  for (long long int i = 0; i < SIZE(r.steps); ++i) {
    const instruction& curr = r.steps.at(i);
//?     cerr << "aa: " << curr.name << '\n'; //? 3
//?     cerr << "bb: " << curr.ingredients.at(0).name << '\n'; //? 1
    if (curr.name == "type")
      result += unicode_length(curr.ingredients.at(0).name);
    else
      result++;
//?     cerr << "cc: " << result << '\n'; //? 1
  }
  return result;
}

long long int size_of_event() {
  // memoize result if already computed
  static long long int result = 0;
  if (result) return result;
  vector<type_number> type;
  type.push_back(Type_number["event"]);
  result = size_of(type);
  return result;
}

long long int size_of_events() {
  // memoize result if already computed
  static long long int result = 0;
  if (result) return result;
  vector<type_number> type;
  assert(Type_number["console"]);
  type.push_back(Type_number["console"]);
  result = size_of(type);
  return result;
}