Imported Upstream version 1.4
Lifeng Sun
10 years ago
0 | _build/ | |
1 | /lambda-term-*.tar.gz | |
2 | /setup.data | |
3 | /setup.log | |
4 | /setup.exe | |
5 | /setup-dev.exe | |
6 | /man/*.gz |
0 | ===== 1.1 (2011-08-06) ===== | |
1 | ||
2 | * fix a blinking problem on OS-X | |
3 | * bind the kill-{prev,next}-word editing actions | |
4 | * bind the undo action | |
5 | * add doc for edition actions | |
6 | * add LTerm_key.to_string_compact to print keys like emacs | |
7 | * use Zed_input for key bindings instead of hash tables | |
8 | * add support for macros | |
9 | * add the break action to interrupt read-line | |
10 | * add manual pages | |
11 | * allow to get the current pending key sequence in read-line | |
12 | * make the LTerm_read_line.term class more flexible |
0 | Sat Aug 6 13:30:44 CEST 2011 Jeremie Dimino <jeremie@dimino.org> | |
1 | tagged 1.1 | |
2 | ||
3 | Sat Aug 6 13:30:38 CEST 2011 Jeremie Dimino <jeremie@dimino.org> | |
4 | * version 1.1 | |
5 | ||
6 | Thu Aug 4 16:18:54 CEST 2011 Jeremie Dimino <jeremie@dimino.org> | |
7 | * allow to filter actions sent to a read-line instance | |
8 | ||
9 | Thu Aug 4 13:00:16 CEST 2011 Jeremie Dimino <jeremie@dimino.org> | |
10 | * allow to modify the macro counter | |
11 | ||
12 | Thu Aug 4 09:39:48 CEST 2011 Jeremie Dimino <jeremie@dimino.org> | |
13 | * allow to bind characters | |
14 | ||
15 | Thu Aug 4 09:35:37 CEST 2011 Jeremie Dimino <jeremie@dimino.org> | |
16 | * add LTerm_read_line.term#key_sequence | |
17 | ||
18 | Wed Aug 3 19:13:33 CEST 2011 Jeremie Dimino <jeremie@dimino.org> | |
19 | * install configuration example | |
20 | ||
21 | Tue Aug 2 22:54:23 CEST 2011 Jeremie Dimino <jeremie@dimino.org> | |
22 | * add the Break action | |
23 | ||
24 | Tue Aug 2 18:20:43 CEST 2011 Jeremie Dimino <jeremie@dimino.org> | |
25 | * typo | |
26 | ||
27 | Tue Aug 2 18:19:26 CEST 2011 Jeremie Dimino <jeremie@dimino.org> | |
28 | * add manual pages | |
29 | ||
30 | Tue Aug 2 14:36:18 CEST 2011 Jeremie Dimino <jeremie@dimino.org> | |
31 | * add support for user configurable key bindings | |
32 | ||
33 | Tue Aug 2 10:07:13 CEST 2011 Jeremie Dimino <jeremie@dimino.org> | |
34 | * add support for macro counter | |
35 | ||
36 | Tue Aug 2 10:00:34 CEST 2011 Jeremie Dimino <jeremie@dimino.org> | |
37 | * move macro stuff to LTerm_edit | |
38 | ||
39 | Tue Aug 2 00:26:40 CEST 2011 Jeremie Dimino <jeremie@dimino.org> | |
40 | * typo | |
41 | ||
42 | Mon Aug 1 23:47:02 CEST 2011 Jeremie Dimino <jeremie@dimino.org> | |
43 | * handle macros | |
44 | ||
45 | Mon Aug 1 22:32:44 CEST 2011 Jeremie Dimino <jeremie@dimino.org> | |
46 | * use Zed_input for bindings | |
47 | ||
48 | Mon Aug 1 19:40:15 CEST 2011 Jeremie Dimino <jeremie@dimino.org> | |
49 | * typo | |
50 | ||
51 | Mon Aug 1 19:39:00 CEST 2011 Jeremie Dimino <jeremie@dimino.org> | |
52 | * add a binding for undo | |
53 | ||
54 | Mon Aug 1 17:32:24 CEST 2011 Jeremie Dimino <jeremie@dimino.org> | |
55 | * add LTerm_key.to_string_compact | |
56 | ||
57 | Mon Aug 1 17:17:35 CEST 2011 Jeremie Dimino <jeremie@dimino.org> | |
58 | * add doc for actions and string<->action functions | |
59 | ||
60 | Mon Aug 1 15:59:43 CEST 2011 Jeremie Dimino <jeremie@dimino.org> | |
61 | * use kill-{next,prev}-word instead of delete-{next,prev}-word | |
62 | ||
63 | Mon Aug 1 15:18:03 CEST 2011 Jeremie Dimino <jeremie@dimino.org> | |
64 | * avoid a conflict in keybindings | |
65 | ||
66 | Mon Aug 1 08:56:21 CEST 2011 Jeremie Dimino <jeremie@dimino.org> | |
67 | * map C-w and M-d to delete-{prev,next}-word | |
68 | ||
69 | Sun Jul 31 14:15:07 CEST 2011 Jeremie Dimino <jeremie@dimino.org> | |
70 | * fix a blinking problem on MacOS-X | |
71 | ||
72 | Fri Jul 29 10:01:08 CEST 2011 Jeremie Dimino <jeremie@dimino.org> | |
73 | * add a constraint on Lwt version | |
74 | ||
75 | Thu Jul 28 22:37:22 CEST 2011 Jeremie Dimino <jeremie@dimino.org> | |
76 | tagged 1.0 | |
77 | ||
78 | Thu Jul 28 22:05:45 CEST 2011 Jeremie Dimino <jeremie@dimino.org> | |
79 | * add a ?style parameter to all drawing functions | |
80 | ||
81 | Thu Jul 28 21:52:31 CEST 2011 Jeremie Dimino <jeremie@dimino.org> | |
82 | * add the LICENSE file | |
83 | ||
84 | Wed Jul 27 18:14:02 CEST 2011 Jeremie Dimino <jeremie@dimino.org> | |
85 | * fix completion index when the completion changes | |
86 | ||
87 | Wed Jul 27 16:52:26 CEST 2011 Jeremie Dimino <jeremie@dimino.org> | |
88 | * add a parameter to LTerm_read_line.#stylise | |
89 | ||
90 | Wed Jul 27 15:43:41 CEST 2011 Jeremie Dimino <jeremie@dimino.org> | |
91 | * fix escaping of history | |
92 | ||
93 | Wed Jul 27 07:51:31 CEST 2011 Jeremie Dimino <jeremie@dimino.org> | |
94 | * change the semantic of LTerm_read_line.lookup | |
95 | ||
96 | Tue Jul 26 19:47:12 CEST 2011 Jeremie Dimino <jeremie@dimino.org> | |
97 | * fix final drawing of read-lines | |
98 | ||
99 | Sun Jul 24 16:03:23 CEST 2011 Jeremie Dimino <jeremie@dimino.org> | |
100 | * change the way the completion is computed | |
101 | ||
102 | Sun Jul 24 15:49:15 CEST 2011 Jeremie Dimino <jeremie@dimino.org> | |
103 | * simplify LTerm.render_update_unix | |
104 | ||
105 | Sun Jul 24 13:10:16 CEST 2011 Jeremie Dimino <jeremie@dimino.org> | |
106 | * change the color of the line in the shell example | |
107 | ||
108 | Sun Jul 24 13:03:22 CEST 2011 Jeremie Dimino <jeremie@dimino.org> | |
109 | * various fixes | |
110 | ||
111 | Sat Jul 23 22:02:08 CEST 2011 Jeremie Dimino <jeremie@dimino.org> | |
112 | * do not fail if the resources file does not exist | |
113 | ||
114 | Sat Jul 23 16:03:26 CEST 2011 Jeremie Dimino <jeremie@dimino.org> | |
115 | * fixes | |
116 | ||
117 | Sat Jul 23 15:41:36 CEST 2011 Jeremie Dimino <jeremie@dimino.org> | |
118 | * fix print_box in windows | |
119 | ||
120 | Sat Jul 23 15:38:39 CEST 2011 Jeremie Dimino <jeremie@dimino.org> | |
121 | * fix windows stubs using rectangles | |
122 | ||
123 | Sat Jul 23 15:03:18 CEST 2011 Jeremie Dimino <jeremie@dimino.org> | |
124 | * better rendering of readline | |
125 | ||
126 | Sat Jul 23 11:54:09 CEST 2011 Jeremie Dimino <jeremie@dimino.org> | |
127 | * do not show the completion box on windows | |
128 | ||
129 | Sat Jul 23 11:45:16 CEST 2011 Jeremie Dimino <jeremie@dimino.org> | |
130 | * fix fprints on windows | |
131 | ||
132 | Sat Jul 23 11:31:24 CEST 2011 Jeremie Dimino <jeremie@dimino.org> | |
133 | * better windows_map_char function | |
134 | ||
135 | Sat Jul 23 09:53:50 CEST 2011 Jeremie Dimino <jeremie@dimino.org> | |
136 | * add X11 colors | |
137 | ||
138 | Fri Jul 22 21:02:13 CEST 2011 Jeremie Dimino <jeremie@dimino.org> | |
139 | * draw current line in a different style | |
140 | ||
141 | Fri Jul 22 20:42:16 CEST 2011 Jeremie Dimino <jeremie@dimino.org> | |
142 | * fix displaying of marked text | |
143 | ||
144 | Fri Jul 22 20:24:23 CEST 2011 Jeremie Dimino <jeremie@dimino.org> | |
145 | * use Zed_edit.update | |
146 | ||
147 | Fri Jul 22 15:58:36 CEST 2011 Jeremie Dimino <jeremie@dimino.org> | |
148 | * add resources and edition widget | |
149 | ||
150 | Tue Jul 19 19:20:25 CEST 2011 Jeremie Dimino <jeremie@dimino.org> | |
151 | * rename LTerm_ui.loop to LTerm_ui.wait | |
152 | ||
153 | Tue Jul 19 19:17:28 CEST 2011 Jeremie Dimino <jeremie@dimino.org> | |
154 | * rename { line; column } to { row; col } | |
155 | ||
156 | Tue Jul 19 15:17:17 CEST 2011 Jeremie Dimino <jeremie@dimino.org> | |
157 | * renaming | |
158 | ||
159 | Tue Jul 19 10:15:10 CEST 2011 Jeremie Dimino <jeremie@dimino.org> | |
160 | * smart naviguation between widgets | |
161 | ||
162 | Mon Jul 18 22:32:40 CEST 2011 Jeremie Dimino <jeremie@dimino.org> | |
163 | * rewrite Lt_widget using objects | |
164 | ||
165 | Mon Jul 18 14:54:29 CEST 2011 Jeremie Dimino <jeremie@dimino.org> | |
166 | * add more terminals in Lt_term.colors_of_term | |
167 | ||
168 | Mon Jul 18 14:38:36 CEST 2011 Jeremie Dimino <jeremie@dimino.org> | |
169 | * add an read yes/no example | |
170 | ||
171 | Sun Jul 17 20:33:05 CEST 2011 Jeremie Dimino <jeremie@dimino.org> | |
172 | * use Lt_ui in Lt_widget | |
173 | ||
174 | Sun Jul 17 20:23:17 CEST 2011 Jeremie Dimino <jeremie@dimino.org> | |
175 | * add Lt_ui | |
176 | ||
177 | Sat Jul 2 21:22:02 CEST 2011 Jeremie Dimino <jeremie@dimino.org> | |
178 | * simplify setup.ml | |
179 | ||
180 | Sat Jul 2 17:59:08 CEST 2011 Jeremie Dimino <jeremie@dimino.org> | |
181 | * wait before returning the escape key | |
182 | ||
183 | Sat Jul 2 15:02:29 CEST 2011 Jeremie Dimino <jeremie@dimino.org> | |
184 | * use windows_map_char in Lt_term.fprints | |
185 | ||
186 | Sat Jun 18 21:34:03 CEST 2011 Jeremie Dimino <jeremie@dimino.org> | |
187 | * add rxvt-unicode-256color | |
188 | ||
189 | Sat Jun 18 21:14:01 CEST 2011 Jeremie Dimino <jeremie@dimino.org> | |
190 | * add setup.ml | |
191 | ||
192 | Tue Apr 26 17:01:52 CEST 2011 Jeremie Dimino <jeremie@dimino.org> | |
193 | * typo | |
194 | ||
195 | Sat Jun 18 20:39:53 CEST 2011 Jeremie Dimino <jeremie@dimino.org> | |
196 | * remove oasis files | |
197 | ||
198 | Tue Apr 5 21:13:16 CEST 2011 Jeremie Dimino <jeremie@dimino.org> | |
199 | * add bindings for functions working on words | |
200 | ||
201 | Mon Apr 4 21:43:33 CEST 2011 Jeremie Dimino <jeremie@dimino.org> | |
202 | * unknown missing directories in the shell example | |
203 | ||
204 | Sun Apr 3 15:25:36 CEST 2011 Jeremie Dimino <jeremie@dimino.org> | |
205 | * rename requested_size to size_request | |
206 | ||
207 | Sun Mar 27 22:41:37 CEST 2011 Jeremie Dimino <dimino@crans.org> | |
208 | * reimplement widgets without classes | |
209 | ||
210 | Sat Mar 26 21:21:12 CET 2011 Jeremie Dimino <jeremie@dimino.org> | |
211 | * rewrite the widget system | |
212 | ||
213 | Fri Mar 25 22:37:27 CET 2011 Jeremie Dimino <jeremie@dimino.org> | |
214 | * put mutexes at different places in read-line | |
215 | ||
216 | Fri Mar 25 22:32:11 CET 2011 Jeremie Dimino <jeremie@dimino.org> | |
217 | * faster box drawing in read-line | |
218 | ||
219 | Fri Mar 25 21:50:50 CET 2011 Jeremie Dimino <jeremie@dimino.org> | |
220 | * typo | |
221 | ||
222 | Fri Mar 25 21:50:02 CET 2011 Jeremie Dimino <jeremie@dimino.org> | |
223 | * better result for read_keyword | |
224 | ||
225 | Fri Mar 25 21:45:28 CET 2011 Jeremie Dimino <jeremie@dimino.org> | |
226 | * handle backward search in read-line | |
227 | ||
228 | Fri Mar 25 09:48:36 CET 2011 Jeremie Dimino <jeremie@dimino.org> | |
229 | * better title class | |
230 | ||
231 | Thu Mar 24 23:56:49 CET 2011 Jeremie Dimino <dimino@crans.org> | |
232 | * draw a line for the title widget | |
233 | ||
234 | Thu Mar 24 23:02:30 CET 2011 Jeremie Dimino <dimino@crans.org> | |
235 | * add a title widget | |
236 | ||
237 | Thu Mar 24 15:46:59 CET 2011 Jeremie Dimino <jeremie@dimino.org> | |
238 | * handle vertical alignment | |
239 | ||
240 | Thu Mar 24 13:34:50 CET 2011 Jeremie Dimino <jeremie@dimino.org> | |
241 | * handle alignment | |
242 | ||
243 | Fri Mar 25 09:29:34 CET 2011 Jeremie Dimino <jeremie@dimino.org> | |
244 | * allow more configurable lines | |
245 | ||
246 | Thu Mar 24 09:16:49 CET 2011 Jeremie Dimino <jeremie@dimino.org> | |
247 | * add function for creating interfaces more conveniently | |
248 | ||
249 | Wed Mar 23 16:27:45 CET 2011 Jeremie Dimino <jeremie@dimino.org> | |
250 | * reimplement the render example with widgets | |
251 | ||
252 | Wed Mar 23 14:42:42 CET 2011 Jeremie Dimino <jeremie@dimino.org> | |
253 | * implement size contraints | |
254 | ||
255 | Wed Mar 23 10:59:48 CET 2011 Jeremie Dimino <jeremie@dimino.org> | |
256 | * add frame and line widgets | |
257 | ||
258 | Wed Mar 16 21:43:30 CET 2011 Jeremie Dimino <jeremie@dimino.org> | |
259 | * add piece drawing | |
260 | ||
261 | Tue Mar 15 14:59:30 CET 2011 Jeremie Dimino <jeremie@dimino.org> | |
262 | * make Lt_widget.t take no parameter | |
263 | ||
264 | Mon Mar 14 17:31:57 CET 2011 Jeremie Dimino <jeremie@dimino.org> | |
265 | * rename Lt_types to Lt_geom | |
266 | ||
267 | Mon Mar 14 17:29:11 CET 2011 Jeremie Dimino <jeremie@dimino.org> | |
268 | * add markup strings | |
269 | ||
270 | Sun Mar 13 23:01:35 CET 2011 Jeremie Dimino <jeremie@dimino.org> | |
271 | * change the type of styled strings | |
272 | ||
273 | Sun Mar 13 11:36:26 CET 2011 Jeremie Dimino <jeremie@dimino.org> | |
274 | * renaming | |
275 | ||
276 | Sun Mar 13 10:57:40 CET 2011 Jeremie Dimino <jeremie@dimino.org> | |
277 | * allow to overload the completion function | |
278 | ||
279 | Sat Mar 12 19:08:56 CET 2011 Jeremie Dimino <jeremie@dimino.org> | |
280 | * insert a newline when meta+return is pressed in readline | |
281 | ||
282 | Sat Mar 12 11:09:54 CET 2011 Jeremie Dimino <jeremie@dimino.org> | |
283 | * add exception printers | |
284 | ||
285 | Sat Mar 12 03:25:50 CET 2011 Jeremie Dimino <jeremie@dimino.org> | |
286 | * make Lt_term.create return a thread | |
287 | ||
288 | Sat Mar 12 03:07:22 CET 2011 Jeremie Dimino <jeremie@dimino.org> | |
289 | * pass the channels to the terminal creation function | |
290 | ||
291 | Sat Mar 12 02:54:57 CET 2011 Jeremie Dimino <jeremie@dimino.org> | |
292 | * stop drawing when a read-line run is terminated | |
293 | ||
294 | Fri Mar 11 20:44:11 CET 2011 Jeremie Dimino <jeremie@dimino.org> | |
295 | * change the interface for the raw mode | |
296 | ||
297 | Fri Mar 11 19:27:19 CET 2011 Jeremie Dimino <jeremie@dimino.org> | |
298 | * add a mutex for drawing read-line | |
299 | ||
300 | Fri Mar 11 17:42:55 CET 2011 Jeremie Dimino <jeremie@dimino.org> | |
301 | * fix rendering in read-line | |
302 | ||
303 | Fri Mar 11 17:02:38 CET 2011 Jeremie Dimino <jeremie@dimino.org> | |
304 | * typo | |
305 | ||
306 | Thu Mar 10 23:11:48 CET 2011 Jeremie Dimino <jeremie@dimino.org> | |
307 | * use HSV components for computing distances between colors | |
308 | ||
309 | Thu Mar 10 20:24:32 CET 2011 Jeremie Dimino <jeremie@dimino.org> | |
310 | * ad the Lt_read_line.read_keyword class | |
311 | ||
312 | Thu Mar 10 20:06:03 CET 2011 Jeremie Dimino <jeremie@dimino.org> | |
313 | * add the Lt_read_line.read_password class | |
314 | ||
315 | Thu Mar 10 19:27:30 CET 2011 Jeremie Dimino <jeremie@dimino.org> | |
316 | * use Lwt_react instead of Lwt_event/Lwt_signal | |
317 | ||
318 | Wed Mar 9 23:04:45 CET 2011 Jeremie Dimino <jeremie@dimino.org> | |
319 | * implement the completion bar | |
320 | ||
321 | Mon Mar 7 18:58:14 CET 2011 Jeremie Dimino <jeremie@dimino.org> | |
322 | * handle completion | |
323 | ||
324 | Mon Mar 7 16:07:37 CET 2011 Jeremie Dimino <jeremie@dimino.org> | |
325 | * handle history in read-line | |
326 | ||
327 | Mon Mar 7 15:56:53 CET 2011 Jeremie Dimino <jeremie@dimino.org> | |
328 | * add Lt_read_line | |
329 | ||
330 | Sun Mar 6 17:41:36 CET 2011 Jeremie Dimino <jeremie@dimino.org> | |
331 | * add primitives for erasing the current line or the screen | |
332 | ||
333 | Sat Mar 5 16:46:35 CET 2011 Jeremie Dimino <jeremie@dimino.org> | |
334 | * add buttons | |
335 | ||
336 | Sat Mar 5 09:38:05 CET 2011 Jeremie Dimino <jeremie@dimino.org> | |
337 | * start of boxes | |
338 | ||
339 | Fri Mar 4 15:22:26 CET 2011 Jeremie Dimino <jeremie@dimino.org> | |
340 | * start of widgets | |
341 | ||
342 | Fri Mar 4 14:45:09 CET 2011 Jeremie Dimino <jeremie@dimino.org> | |
343 | * add drawing primitives | |
344 | ||
345 | Fri Mar 4 13:42:11 CET 2011 Jeremie Dimino <jeremie@dimino.org> | |
346 | * use camomile | |
347 | ||
348 | Fri Mar 4 09:15:14 CET 2011 Jeremie Dimino <jeremie@dimino.org> | |
349 | * handle the case when the input or output is not a tty | |
350 | ||
351 | Fri Mar 4 08:54:20 CET 2011 Jeremie Dimino <jeremie@dimino.org> | |
352 | * renaming | |
353 | ||
354 | Thu Mar 3 15:16:43 CET 2011 Jeremie Dimino <jeremie@dimino.org> | |
355 | * use zed | |
356 | ||
357 | Wed Mar 2 13:10:03 CET 2011 Jeremie Dimino <jeremie@dimino.org> | |
358 | * renaming | |
359 | ||
360 | Wed Mar 2 11:10:52 CET 2011 Jeremie Dimino <jeremie@dimino.org> | |
361 | * remove noalloc from stubs that may raise exceptions | |
362 | ||
363 | Wed Mar 2 10:43:35 CET 2011 Jeremie Dimino <jeremie@dimino.org> | |
364 | * fix the type of argument of Get/SetConsoleMode | |
365 | ||
366 | Wed Mar 2 10:41:55 CET 2011 Jeremie Dimino <jeremie@dimino.org> | |
367 | * handle the shift modifier | |
368 | ||
369 | Tue Mar 1 18:00:54 CET 2011 Jeremie Dimino <jeremie@dimino.org> | |
370 | * maps control keys on windows | |
371 | ||
372 | Tue Mar 1 17:53:07 CET 2011 Jeremie Dimino <jeremie@dimino.org> | |
373 | * set the console mode on windows | |
374 | ||
375 | Tue Mar 1 17:36:55 CET 2011 Jeremie Dimino <jeremie@dimino.org> | |
376 | * add Lt_term.goto_bol | |
377 | ||
378 | Tue Mar 1 08:15:13 CET 2011 Jeremie Dimino <jeremie@dimino.org> | |
379 | * make ml_iconv* static | |
380 | ||
381 | Tue Mar 1 08:10:16 CET 2011 Jeremie Dimino <jeremie@dimino.org> | |
382 | * fix lt_windows_set_console_cursor_position | |
383 | ||
384 | Tue Mar 1 07:41:12 CET 2011 Jeremie Dimino <jeremie@dimino.org> | |
385 | * allow to flush a terminal | |
386 | ||
387 | Mon Feb 28 23:52:11 CET 2011 Jeremie Dimino <jeremie@dimino.org> | |
388 | * fix Lt_term.render_update | |
389 | ||
390 | Mon Feb 28 23:42:04 CET 2011 Jeremie Dimino <jeremie@dimino.org> | |
391 | * add Lt_term.goto | |
392 | ||
393 | Mon Feb 28 22:37:33 CET 2011 Jeremie Dimino <jeremie@dimino.org> | |
394 | * do not set control to true for enter, tab, ... | |
395 | ||
396 | Mon Feb 28 22:29:17 CET 2011 Jeremie Dimino <jeremie@dimino.org> | |
397 | * add missing modules to _oasis | |
398 | ||
399 | Mon Feb 28 19:40:00 CET 2011 Jeremie Dimino <jeremie@dimino.org> | |
400 | * map drawing characters on windows | |
401 | ||
402 | Mon Feb 28 19:07:09 CET 2011 Jeremie Dimino <jeremie@dimino.org> | |
403 | * handle rendering on windows | |
404 | ||
405 | Mon Feb 28 16:32:43 CET 2011 Jeremie Dimino <jeremie@dimino.org> | |
406 | * handle cursor hiding/showing on windows | |
407 | ||
408 | Mon Feb 28 16:19:36 CET 2011 Jeremie Dimino <jeremie@dimino.org> | |
409 | * implement offscreen rendering | |
410 | ||
411 | Mon Feb 28 14:12:17 CET 2011 Jeremie Dimino <jeremie@dimino.org> | |
412 | * handle rgb colors | |
413 | ||
414 | Mon Feb 28 10:54:18 CET 2011 Jeremie Dimino <jeremie@dimino.org> | |
415 | * remove Lt_style.Light | |
416 | ||
417 | Mon Feb 28 10:49:01 CET 2011 Jeremie Dimino <jeremie@dimino.org> | |
418 | * add the colors_256 example | |
419 | ||
420 | Mon Feb 28 10:43:21 CET 2011 Jeremie Dimino <jeremie@dimino.org> | |
421 | * better handling of mouse position on windows | |
422 | ||
423 | Mon Feb 28 10:39:53 CET 2011 Jeremie Dimino <jeremie@dimino.org> | |
424 | * handle colors on windows | |
425 | ||
426 | Sun Feb 27 22:52:37 CET 2011 Jeremie Dimino <jeremie@dimino.org> | |
427 | * handle styles | |
428 | ||
429 | Sun Feb 27 19:05:24 CET 2011 Jeremie Dimino <jeremie@dimino.org> | |
430 | * better handling of the mouse under windows | |
431 | ||
432 | Sun Feb 27 19:00:01 CET 2011 Jeremie Dimino <jeremie@dimino.org> | |
433 | * do not use classes | |
434 | ||
435 | Sun Feb 27 15:11:14 CET 2011 Jeremie Dimino <jeremie@dimino.org> | |
436 | * handle mouse events | |
437 | ||
438 | Sun Feb 27 10:35:24 CET 2011 Jeremie Dimino <jeremie@dimino.org> | |
439 | * better handling of escape sequences | |
440 | ||
441 | Sat Feb 26 12:58:06 CET 2011 Jeremie Dimino <jeremie@dimino.org> | |
442 | * save/load does nothing on windows | |
443 | ||
444 | Wed Feb 23 14:01:48 CET 2011 Jeremie Dimino <jeremie@dimino.org> | |
445 | * handle more escape sequences | |
446 | ||
447 | Tue Feb 22 22:24:39 CET 2011 Jeremie Dimino <jeremie@dimino.org> | |
448 | * implement read_event on windows | |
449 | ||
450 | Tue Feb 22 19:37:44 CET 2011 Jeremie Dimino <jeremie@dimino.org> | |
451 | * more modules | |
452 | ||
453 | Sun Feb 20 23:14:54 CET 2011 Jeremie Dimino <jeremie@dimino.org> | |
454 | * initial import |
0 | 1.4 (2013-03-26) | |
1 | ---------------- | |
2 | ||
3 | * added `C-b`, `C-f`, `C-h`, `M-p`, `M-n` by default | |
4 | * fix a segfault when running utop in an emacs terminal buffer | |
5 | ||
6 | 1.3 (2012-10-08) | |
7 | ---------------- | |
8 | ||
9 | * fix the bindings for `C-n` and `C-p` | |
10 | * binds `C-h` to delete-prev-char | |
11 | ||
12 | 1.2 (2012-07-30) | |
13 | ---------------- | |
14 | ||
15 | * better handling of newlines in read-line (avoid square selection bug) | |
16 | * add a module for managing history | |
17 | * use camomile for character encoding (remove iconv dependency) | |
18 | * include generated tables for color mappings to speed up the build | |
19 | * Windows fixes | |
20 | * use unicode version of IO console functions | |
21 | * better rendering method for read-line | |
22 | ||
23 | 1.1 (2011-08-06) | |
24 | ---------------- | |
25 | ||
26 | * fix a blinking problem on OS-X | |
27 | * bind the `kill-{prev,next}-word` editing actions | |
28 | * bind the undo action | |
29 | * add doc for edition actions | |
30 | * add `LTerm_key.to_string_compact` to print keys like emacs | |
31 | * use `Zed_input` for key bindings instead of hash tables | |
32 | * add support for macros | |
33 | * add the break action to interrupt read-line | |
34 | * add manual pages | |
35 | * allow to get the current pending key sequence in read-line | |
36 | * make the `LTerm_read_line.term` class more flexible |
0 | Copyright (c) 2009, Jeremie Dimino <jeremie@dimino.org> | |
0 | Copyright (c) 2011, Jeremie Dimino <jeremie@dimino.org> | |
1 | 1 | All rights reserved. |
2 | 2 | Redistribution and use in source and binary forms, with or without |
3 | 3 | modification, are permitted provided that the following conditions are met: |
0 | # OASIS_START | |
1 | # DO NOT EDIT (digest: bc1e05bfc8b39b664f29dae8dbd3ebbb) | |
0 | # Makefile | |
1 | # -------- | |
2 | # Copyright : (c) 2012, Jeremie Dimino <jeremie@dimino.org> | |
3 | # Licence : BSD3 | |
4 | # | |
5 | # Generic Makefile for oasis project | |
2 | 6 | |
3 | SETUP = ocaml setup.ml | |
7 | # Set to setup.exe for the release | |
8 | SETUP := setup.exe | |
4 | 9 | |
5 | build: setup.data | |
6 | $(SETUP) -build $(BUILDFLAGS) | |
10 | # Default rule | |
11 | default: build | |
7 | 12 | |
8 | doc: setup.data build | |
9 | $(SETUP) -doc $(DOCFLAGS) | |
13 | # Setup for the development version | |
14 | setup-dev.exe: _oasis setup.ml | |
15 | sed '/^#/D' setup.ml > setup_dev.ml | |
16 | ocamlfind ocamlopt -o $@ -linkpkg -package ocamlbuild,oasis.dynrun setup_dev.ml || \ | |
17 | ocamlfind ocamlc -o $@ -linkpkg -package ocamlbuild,oasis.dynrun setup_dev.ml || true | |
18 | rm -f setup_dev.* | |
10 | 19 | |
11 | test: setup.data build | |
12 | $(SETUP) -test $(TESTFLAGS) | |
20 | # Setup for the release | |
21 | setup.exe: setup.ml | |
22 | ocamlopt.opt -o $@ $< || ocamlopt -o $@ $< || ocamlc -o $@ $< | |
23 | rm -f setup.cmx setup.cmi setup.o setup.obj setup.cmo | |
13 | 24 | |
14 | all: | |
15 | $(SETUP) -all $(ALLFLAGS) | |
25 | build: $(SETUP) setup.data | |
26 | ./$(SETUP) -build $(BUILDFLAGS) | |
16 | 27 | |
17 | install: setup.data | |
18 | $(SETUP) -install $(INSTALLFLAGS) | |
28 | doc: $(SETUP) setup.data build | |
29 | ./$(SETUP) -doc $(DOCFLAGS) | |
19 | 30 | |
20 | uninstall: setup.data | |
21 | $(SETUP) -uninstall $(UNINSTALLFLAGS) | |
31 | test: $(SETUP) setup.data build | |
32 | ./$(SETUP) -test $(TESTFLAGS) | |
22 | 33 | |
23 | reinstall: setup.data | |
24 | $(SETUP) -reinstall $(REINSTALLFLAGS) | |
34 | all: $(SETUP) | |
35 | ./$(SETUP) -all $(ALLFLAGS) | |
25 | 36 | |
26 | clean: | |
27 | $(SETUP) -clean $(CLEANFLAGS) | |
37 | install: $(SETUP) setup.data | |
38 | ./$(SETUP) -install $(INSTALLFLAGS) | |
28 | 39 | |
29 | distclean: | |
30 | $(SETUP) -distclean $(DISTCLEANFLAGS) | |
40 | uninstall: $(SETUP) setup.data | |
41 | ./$(SETUP) -uninstall $(UNINSTALLFLAGS) | |
31 | 42 | |
32 | setup.data: | |
33 | $(SETUP) -configure $(CONFIGUREFLAGS) | |
43 | reinstall: $(SETUP) setup.data | |
44 | ./$(SETUP) -reinstall $(REINSTALLFLAGS) | |
34 | 45 | |
35 | .PHONY: build doc test all install uninstall reinstall clean distclean configure | |
46 | clean: $(SETUP) | |
47 | ./$(SETUP) -clean $(CLEANFLAGS) | |
36 | 48 | |
37 | # OASIS_STOP | |
49 | distclean: $(SETUP) | |
50 | ./$(SETUP) -distclean $(DISTCLEANFLAGS) | |
51 | ||
52 | configure: $(SETUP) | |
53 | ./$(SETUP) -configure $(CONFIGUREFLAGS) | |
54 | ||
55 | setup.data: $(SETUP) | |
56 | ./$(SETUP) -configure $(CONFIGUREFLAGS) | |
57 | ||
58 | .PHONY: default build doc test all install uninstall reinstall clean distclean configure |
0 | Lambda-Term | |
1 | =========== | |
2 | ||
3 | Lambda-Term is a cross-platform library for manipulating the | |
4 | terminal. It provides an abstraction for keys, mouse events, colors, | |
5 | as well as a set of widgets to write curses-like applications. | |
6 | ||
7 | The main objective of Lambda-Term is to provide a higher level | |
8 | functional interface to terminal manipulation than, for example, | |
9 | ncurses, by providing a native OCaml interface instead of bindings to | |
10 | a C library. | |
11 | ||
12 | Lambda-Term integrates with zed to provide text edition facilities in | |
13 | console applications. | |
14 | ||
15 | Dependencies | |
16 | ------------ | |
17 | ||
18 | * [OCaml](http://caml.inria.fr/ocaml/) (>= 3.12) | |
19 | * [findlib](http://projects.camlcity.org/projects/findlib.html) | |
20 | * [react](http://erratique.ch/software/react) | |
21 | * [lwt](http://ocsigen.org/lwt/) (>= 2.4.0) built with react support | |
22 | * [Camomile](http://github.com/yoriyuki/Camomile) (>= 0.8) | |
23 | * [zed](http://github.com/diml/zed) (>= 1.2) | |
24 | ||
25 | For building the development version, you also need to install | |
26 | [oasis](http://oasis.forge.ocamlcore.org/) (>= 0.3.0). | |
27 | ||
28 | Installation | |
29 | ------------ | |
30 | ||
31 | To build and install Lambda-Term: | |
32 | ||
33 | $ ./configure | |
34 | $ make | |
35 | $ make install | |
36 | ||
37 | ### Documentation and manual pages _(optional)_ | |
38 | ||
39 | To build the documentation: | |
40 | ||
41 | $ make doc | |
42 | ||
43 | It will then be installed by `make install`. | |
44 | ||
45 | ### Tests _(optionnal)_ | |
46 | ||
47 | To build and execute tests: | |
48 | ||
49 | $ ./configure --enable-tests | |
50 | $ make test | |
51 | ||
52 | Terminal emulators compatibility | |
53 | -------------------------------- | |
54 | ||
55 | All terminal emulators behave differently, especially regarding how | |
56 | keystrokes are reported to the application on its standard | |
57 | input. Lambda-Term tries to handle all of them, but it may happen that | |
58 | a particular key of combination of keys is not recognized by | |
59 | Lambda-Term, and thus does not produce the expected effect (for | |
60 | example: arrow keys or backspace not working). | |
61 | ||
62 | To check what is reported by your terminal you can run the script | |
63 | `print_sequences.ml` which at the root of the repository: | |
64 | ||
65 | $ ocaml print_sequences.ml | |
66 | press 'q' to quit | |
67 | \027[A | |
68 | \027[D | |
69 | \027[C | |
70 | \027[A | |
71 | \027[D | |
72 | a | |
73 | z | |
74 | e | |
75 | q | |
76 | ||
77 | You can then send the result to jeremie@dimino.org, including: | |
78 | ||
79 | * the application you are using as terminal emulator, | |
80 | * the contents of the `TERM` environment variable inside the terminal (`echo $TERM`), | |
81 | * the output of `print_sequences.ml` with, for each line, the keystroke. | |
82 | ||
83 | Main modules | |
84 | ------------ | |
85 | ||
86 | * `LTerm`: basic interface to the terminal, it allows to put the terminal | |
87 | in _raw_ mode, hide the cursor, render an offscreen array of points, ... | |
88 | * `LTerm_draw`: drawing functions, for rendering in an offscreen array. | |
89 | * `LTerm_read_line`: line edition. | |
90 | * `LTerm_inputrc`: parsing of configurations files for key bindings. | |
91 | * `LTerm_history`: history and history file management. | |
92 | * `LTerm_ui`: helpers for writing full-screen applications. | |
93 | * `LTerm_widget`: widget system (not stable). | |
94 | * `LTerm_resources`: resources loading for widgets. |
1 | 1 | # | Package parameters | |
2 | 2 | # +-------------------------------------------------------------------+ |
3 | 3 | |
4 | OASISFormat: 0.1 | |
4 | OASISFormat: 0.3 | |
5 | 5 | OCamlVersion: >= 3.12 |
6 | 6 | Name: lambda-term |
7 | Version: 1.1 | |
7 | Version: 1.4 | |
8 | 8 | LicenseFile: LICENSE |
9 | 9 | License: BSD3 |
10 | 10 | Authors: Jérémie Dimino |
11 | 11 | Homepage: http://lambda-term.forge.ocamlcore.org/ |
12 | 12 | BuildTools: ocamlbuild |
13 | Plugins: DevFiles (0.2), META (0.2) | |
14 | Synopsis: Lambda-Term | |
15 | Description: Corss-platform library for terminal manipulation | |
13 | Plugins: DevFiles (0.3), META (0.3) | |
14 | XDevFilesEnableMakefile: false | |
15 | Synopsis: Terminal manipulation library for OCaml | |
16 | Description: | |
17 | Lambda-term is a cross-platform library for manipulating the | |
18 | terminal. It provides an abstraction for keys, mouse events, colors, | |
19 | as well as a set of widgets to write curses-like applications. | |
20 | . | |
21 | The main objective of lambda-term is to provide a higher level | |
22 | functional interface to terminal manipulation than, for example, | |
23 | ncurses, by providing a native OCaml interface instead of bindings to | |
24 | a C library. | |
25 | . | |
26 | Lambda-term integrates with zed to provide text edition facilities in | |
27 | console applications. | |
16 | 28 | |
17 | 29 | # +-------------------------------------------------------------------+ |
18 | 30 | # | The library | |
20 | 32 | |
21 | 33 | Library "lambda-term" |
22 | 34 | FindlibName: lambda-term |
23 | BuildDepends: lwt (>= 2.3.0), lwt.unix, lwt.syntax, lwt.react, zed (>= 1.1) | |
35 | BuildDepends: lwt (>= 2.4.0), lwt.unix, lwt.syntax, lwt.react, zed (>= 1.2) | |
24 | 36 | XMETADescription: Corss-platform library for terminal manipulation |
25 | 37 | XMETARequires: lwt.unix, lwt.react, zed |
26 | 38 | Path: src |
31 | 43 | LTerm_event, |
32 | 44 | LTerm_unix, |
33 | 45 | LTerm_windows, |
34 | LTerm_iconv, | |
35 | 46 | LTerm_style, |
36 | 47 | LTerm_geom, |
37 | 48 | LTerm_draw, |
38 | 49 | LTerm_mouse, |
39 | LTerm_color_mappings, | |
40 | 50 | LTerm_widget, |
41 | 51 | LTerm_edit, |
42 | 52 | LTerm_read_line, |
43 | 53 | LTerm_text, |
44 | 54 | LTerm_ui, |
45 | 55 | LTerm_resources, |
46 | LTerm_inputrc | |
56 | LTerm_inputrc, | |
57 | LTerm_history | |
47 | 58 | InternalModules: |
59 | LTerm_color_mappings, | |
48 | 60 | LTerm_resource_lexer |
49 | 61 | CSources: |
50 | 62 | lTerm_term_stubs.c, |
51 | 63 | lTerm_unix_stubs.c, |
52 | lTerm_windows_stubs.c, | |
53 | lTerm_iconv_stubs.c | |
64 | lTerm_windows_stubs.c | |
54 | 65 | |
55 | 66 | # +-------------------------------------------------------------------+ |
56 | 67 | # | Examples | |
152 | 163 | BuildDepends: lambda-term |
153 | 164 | |
154 | 165 | # +-------------------------------------------------------------------+ |
166 | # | Tests | | |
167 | # +-------------------------------------------------------------------+ | |
168 | ||
169 | Executable "history-stress-test" | |
170 | Path: tests | |
171 | Install: false | |
172 | CompiledObject: best | |
173 | MainIs: history_stress_test.ml | |
174 | BuildDepends: lambda-term | |
175 | ||
176 | # +-------------------------------------------------------------------+ | |
155 | 177 | # | Doc | |
156 | 178 | # +-------------------------------------------------------------------+ |
157 | 179 | |
158 | 180 | Document "lambda-term-api" |
159 | 181 | Title: API reference for Lambda-Term |
160 | Type: ocamlbuild (0.2) | |
182 | Type: ocamlbuild (0.3) | |
161 | 183 | Install: true |
162 | 184 | InstallDir: $htmldir/api |
163 | 185 | DataFiles: style.css |
170 | 192 | # +-------------------------------------------------------------------+ |
171 | 193 | |
172 | 194 | Document "lambda-term-actions-man" |
173 | Type: custom (0.2) | |
195 | Type: custom (0.3) | |
174 | 196 | Title: Man page for lambda-term-actions |
175 | 197 | Install: true |
176 | 198 | BuildTools: gzip |
180 | 202 | InstallDir: $mandir/man1 |
181 | 203 | |
182 | 204 | Document "lambda-term-inputrc-man" |
183 | Type: custom (0.2) | |
205 | Type: custom (0.3) | |
184 | 206 | Title: Man page for ~/.lambda-term-inputrc |
185 | 207 | Install: true |
186 | 208 | BuildTools: gzip |
194 | 216 | # +-------------------------------------------------------------------+ |
195 | 217 | |
196 | 218 | Document "lamda-term-inputrc" |
197 | Type: custom (0.2) | |
219 | Type: custom (0.3) | |
198 | 220 | Title: lambda-term-inputrc example |
199 | 221 | XCustom: true |
200 | 222 | Install: true |
205 | 227 | # +-------------------------------------------------------------------+ |
206 | 228 | |
207 | 229 | SourceRepository head |
208 | Type: darcs | |
209 | Location: http://darcs.ocamlcore.org/repos/lambda-term | |
210 | Browser: http://darcs.ocamlcore.org/cgi-bin/darcsweb.cgi?r=lambda-term;a=summary | |
230 | Type: git | |
231 | Location: https://github.com/diml/lambda-term.git | |
232 | Browser: https://github.com/diml/lambda-term |
2 | 2 | <src/*>: use_iconv |
3 | 3 | |
4 | 4 | # OASIS_START |
5 | # DO NOT EDIT (digest: df02cf32ec7f7460394286f1bdb3ea6d) | |
5 | # DO NOT EDIT (digest: e78fd8b9674dd1ec0d4b08a2700288d0) | |
6 | 6 | # Ignore VCS directories, you can use the same kind of rule outside |
7 | 7 | # OASIS_START/STOP if you want to exclude directories that contains |
8 | 8 | # useless stuff for the build process |
17 | 17 | "_darcs": -traverse |
18 | 18 | "_darcs": not_hygienic |
19 | 19 | # Library lambda-term |
20 | "src": include | |
21 | 20 | "src/lambda-term.cmxs": use_lambda-term |
22 | <src/lambda-term.{cma,cmxa}>: use_liblambda-term | |
23 | <src/*.ml{,i}>: pkg_zed | |
21 | <src/lambda-term.{cma,cmxa}>: use_liblambda-term_stubs | |
22 | <src/*.ml{,i}>: pkg_lwt | |
24 | 23 | <src/*.ml{,i}>: pkg_lwt.unix |
25 | 24 | <src/*.ml{,i}>: pkg_lwt.syntax |
26 | 25 | <src/*.ml{,i}>: pkg_lwt.react |
27 | <src/*.ml{,i}>: pkg_lwt | |
28 | "src/lTerm_term_stubs.c": pkg_zed | |
26 | <src/*.ml{,i}>: pkg_zed | |
27 | "src/lTerm_term_stubs.c": pkg_lwt | |
29 | 28 | "src/lTerm_term_stubs.c": pkg_lwt.unix |
30 | 29 | "src/lTerm_term_stubs.c": pkg_lwt.syntax |
31 | 30 | "src/lTerm_term_stubs.c": pkg_lwt.react |
32 | "src/lTerm_term_stubs.c": pkg_lwt | |
33 | "src/lTerm_unix_stubs.c": pkg_zed | |
31 | "src/lTerm_term_stubs.c": pkg_zed | |
32 | "src/lTerm_unix_stubs.c": pkg_lwt | |
34 | 33 | "src/lTerm_unix_stubs.c": pkg_lwt.unix |
35 | 34 | "src/lTerm_unix_stubs.c": pkg_lwt.syntax |
36 | 35 | "src/lTerm_unix_stubs.c": pkg_lwt.react |
37 | "src/lTerm_unix_stubs.c": pkg_lwt | |
38 | "src/lTerm_windows_stubs.c": pkg_zed | |
36 | "src/lTerm_unix_stubs.c": pkg_zed | |
37 | "src/lTerm_windows_stubs.c": pkg_lwt | |
39 | 38 | "src/lTerm_windows_stubs.c": pkg_lwt.unix |
40 | 39 | "src/lTerm_windows_stubs.c": pkg_lwt.syntax |
41 | 40 | "src/lTerm_windows_stubs.c": pkg_lwt.react |
42 | "src/lTerm_windows_stubs.c": pkg_lwt | |
43 | "src/lTerm_iconv_stubs.c": pkg_zed | |
44 | "src/lTerm_iconv_stubs.c": pkg_lwt.unix | |
45 | "src/lTerm_iconv_stubs.c": pkg_lwt.syntax | |
46 | "src/lTerm_iconv_stubs.c": pkg_lwt.react | |
47 | "src/lTerm_iconv_stubs.c": pkg_lwt | |
41 | "src/lTerm_windows_stubs.c": pkg_zed | |
42 | # Executable events | |
43 | <examples/events.{native,byte}>: use_lambda-term | |
44 | <examples/events.{native,byte}>: pkg_lwt | |
45 | <examples/events.{native,byte}>: pkg_lwt.unix | |
46 | <examples/events.{native,byte}>: pkg_lwt.syntax | |
47 | <examples/events.{native,byte}>: pkg_lwt.react | |
48 | <examples/events.{native,byte}>: pkg_zed | |
49 | # Executable colors | |
50 | <examples/colors.{native,byte}>: use_lambda-term | |
51 | <examples/colors.{native,byte}>: pkg_lwt | |
52 | <examples/colors.{native,byte}>: pkg_lwt.unix | |
53 | <examples/colors.{native,byte}>: pkg_lwt.syntax | |
54 | <examples/colors.{native,byte}>: pkg_lwt.react | |
55 | <examples/colors.{native,byte}>: pkg_zed | |
56 | # Executable colors_256 | |
57 | <examples/colors_256.{native,byte}>: use_lambda-term | |
58 | <examples/colors_256.{native,byte}>: pkg_lwt | |
59 | <examples/colors_256.{native,byte}>: pkg_lwt.unix | |
60 | <examples/colors_256.{native,byte}>: pkg_lwt.syntax | |
61 | <examples/colors_256.{native,byte}>: pkg_lwt.react | |
62 | <examples/colors_256.{native,byte}>: pkg_zed | |
63 | # Executable rgb | |
64 | <examples/rgb.{native,byte}>: use_lambda-term | |
65 | <examples/rgb.{native,byte}>: pkg_lwt | |
66 | <examples/rgb.{native,byte}>: pkg_lwt.unix | |
67 | <examples/rgb.{native,byte}>: pkg_lwt.syntax | |
68 | <examples/rgb.{native,byte}>: pkg_lwt.react | |
69 | <examples/rgb.{native,byte}>: pkg_zed | |
70 | # Executable move | |
71 | <examples/move.{native,byte}>: use_lambda-term | |
72 | <examples/move.{native,byte}>: pkg_lwt | |
73 | <examples/move.{native,byte}>: pkg_lwt.unix | |
74 | <examples/move.{native,byte}>: pkg_lwt.syntax | |
75 | <examples/move.{native,byte}>: pkg_lwt.react | |
76 | <examples/move.{native,byte}>: pkg_zed | |
77 | # Executable hello | |
78 | <examples/hello.{native,byte}>: use_lambda-term | |
79 | <examples/hello.{native,byte}>: pkg_lwt | |
80 | <examples/hello.{native,byte}>: pkg_lwt.unix | |
81 | <examples/hello.{native,byte}>: pkg_lwt.syntax | |
82 | <examples/hello.{native,byte}>: pkg_lwt.react | |
83 | <examples/hello.{native,byte}>: pkg_zed | |
84 | # Executable clock | |
85 | <examples/clock.{native,byte}>: use_lambda-term | |
86 | <examples/clock.{native,byte}>: pkg_lwt | |
87 | <examples/clock.{native,byte}>: pkg_lwt.unix | |
88 | <examples/clock.{native,byte}>: pkg_lwt.syntax | |
89 | <examples/clock.{native,byte}>: pkg_lwt.react | |
90 | <examples/clock.{native,byte}>: pkg_zed | |
91 | # Executable buttons | |
92 | <examples/buttons.{native,byte}>: use_lambda-term | |
93 | <examples/buttons.{native,byte}>: pkg_lwt | |
94 | <examples/buttons.{native,byte}>: pkg_lwt.unix | |
95 | <examples/buttons.{native,byte}>: pkg_lwt.syntax | |
96 | <examples/buttons.{native,byte}>: pkg_lwt.react | |
97 | <examples/buttons.{native,byte}>: pkg_zed | |
48 | 98 | # Executable shell |
49 | 99 | <examples/shell.{native,byte}>: use_lambda-term |
50 | <examples/shell.{native,byte}>: pkg_zed | |
51 | 100 | <examples/shell.{native,byte}>: pkg_str |
101 | <examples/shell.{native,byte}>: pkg_lwt | |
52 | 102 | <examples/shell.{native,byte}>: pkg_lwt.unix |
53 | 103 | <examples/shell.{native,byte}>: pkg_lwt.syntax |
54 | 104 | <examples/shell.{native,byte}>: pkg_lwt.react |
55 | <examples/shell.{native,byte}>: pkg_lwt | |
105 | <examples/shell.{native,byte}>: pkg_zed | |
56 | 106 | <examples/*.ml{,i}>: pkg_str |
57 | # Executable events | |
58 | <examples/events.{native,byte}>: use_lambda-term | |
59 | <examples/events.{native,byte}>: pkg_zed | |
60 | <examples/events.{native,byte}>: pkg_lwt.unix | |
61 | <examples/events.{native,byte}>: pkg_lwt.syntax | |
62 | <examples/events.{native,byte}>: pkg_lwt.react | |
63 | <examples/events.{native,byte}>: pkg_lwt | |
64 | # Executable clock | |
65 | <examples/clock.{native,byte}>: use_lambda-term | |
66 | <examples/clock.{native,byte}>: pkg_zed | |
67 | <examples/clock.{native,byte}>: pkg_lwt.unix | |
68 | <examples/clock.{native,byte}>: pkg_lwt.syntax | |
69 | <examples/clock.{native,byte}>: pkg_lwt.react | |
70 | <examples/clock.{native,byte}>: pkg_lwt | |
71 | # Executable colors | |
72 | <examples/colors.{native,byte}>: use_lambda-term | |
73 | <examples/colors.{native,byte}>: pkg_zed | |
74 | <examples/colors.{native,byte}>: pkg_lwt.unix | |
75 | <examples/colors.{native,byte}>: pkg_lwt.syntax | |
76 | <examples/colors.{native,byte}>: pkg_lwt.react | |
77 | <examples/colors.{native,byte}>: pkg_lwt | |
78 | 107 | # Executable read-password |
79 | 108 | <examples/read_password.{native,byte}>: use_lambda-term |
80 | <examples/read_password.{native,byte}>: pkg_zed | |
109 | <examples/read_password.{native,byte}>: pkg_lwt | |
81 | 110 | <examples/read_password.{native,byte}>: pkg_lwt.unix |
82 | 111 | <examples/read_password.{native,byte}>: pkg_lwt.syntax |
83 | 112 | <examples/read_password.{native,byte}>: pkg_lwt.react |
84 | <examples/read_password.{native,byte}>: pkg_lwt | |
85 | # Executable hello | |
86 | <examples/hello.{native,byte}>: use_lambda-term | |
87 | <examples/hello.{native,byte}>: pkg_zed | |
88 | <examples/hello.{native,byte}>: pkg_lwt.unix | |
89 | <examples/hello.{native,byte}>: pkg_lwt.syntax | |
90 | <examples/hello.{native,byte}>: pkg_lwt.react | |
91 | <examples/hello.{native,byte}>: pkg_lwt | |
113 | <examples/read_password.{native,byte}>: pkg_zed | |
114 | # Executable read-yes-no | |
115 | <examples/read_yes_no.{native,byte}>: use_lambda-term | |
116 | <examples/read_yes_no.{native,byte}>: pkg_lwt | |
117 | <examples/read_yes_no.{native,byte}>: pkg_lwt.unix | |
118 | <examples/read_yes_no.{native,byte}>: pkg_lwt.syntax | |
119 | <examples/read_yes_no.{native,byte}>: pkg_lwt.react | |
120 | <examples/read_yes_no.{native,byte}>: pkg_zed | |
121 | # Executable editor | |
122 | <examples/editor.{native,byte}>: use_lambda-term | |
123 | <examples/editor.{native,byte}>: pkg_lwt | |
124 | <examples/editor.{native,byte}>: pkg_lwt.unix | |
125 | <examples/editor.{native,byte}>: pkg_lwt.syntax | |
126 | <examples/editor.{native,byte}>: pkg_lwt.react | |
127 | <examples/editor.{native,byte}>: pkg_zed | |
128 | <examples/*.ml{,i}>: use_lambda-term | |
129 | <examples/*.ml{,i}>: pkg_lwt | |
130 | <examples/*.ml{,i}>: pkg_lwt.unix | |
131 | <examples/*.ml{,i}>: pkg_lwt.syntax | |
132 | <examples/*.ml{,i}>: pkg_lwt.react | |
133 | <examples/*.ml{,i}>: pkg_zed | |
92 | 134 | # Executable lambda-term-actions |
93 | 135 | <tools/lambda_term_actions.{native,byte}>: use_lambda-term |
94 | <tools/lambda_term_actions.{native,byte}>: pkg_zed | |
136 | <tools/lambda_term_actions.{native,byte}>: pkg_lwt | |
95 | 137 | <tools/lambda_term_actions.{native,byte}>: pkg_lwt.unix |
96 | 138 | <tools/lambda_term_actions.{native,byte}>: pkg_lwt.syntax |
97 | 139 | <tools/lambda_term_actions.{native,byte}>: pkg_lwt.react |
98 | <tools/lambda_term_actions.{native,byte}>: pkg_lwt | |
140 | <tools/lambda_term_actions.{native,byte}>: pkg_zed | |
99 | 141 | <tools/*.ml{,i}>: use_lambda-term |
100 | <tools/*.ml{,i}>: pkg_zed | |
142 | <tools/*.ml{,i}>: pkg_lwt | |
101 | 143 | <tools/*.ml{,i}>: pkg_lwt.unix |
102 | 144 | <tools/*.ml{,i}>: pkg_lwt.syntax |
103 | 145 | <tools/*.ml{,i}>: pkg_lwt.react |
104 | <tools/*.ml{,i}>: pkg_lwt | |
105 | # Executable read-yes-no | |
106 | <examples/read_yes_no.{native,byte}>: use_lambda-term | |
107 | <examples/read_yes_no.{native,byte}>: pkg_zed | |
108 | <examples/read_yes_no.{native,byte}>: pkg_lwt.unix | |
109 | <examples/read_yes_no.{native,byte}>: pkg_lwt.syntax | |
110 | <examples/read_yes_no.{native,byte}>: pkg_lwt.react | |
111 | <examples/read_yes_no.{native,byte}>: pkg_lwt | |
112 | # Executable editor | |
113 | <examples/editor.{native,byte}>: use_lambda-term | |
114 | <examples/editor.{native,byte}>: pkg_zed | |
115 | <examples/editor.{native,byte}>: pkg_lwt.unix | |
116 | <examples/editor.{native,byte}>: pkg_lwt.syntax | |
117 | <examples/editor.{native,byte}>: pkg_lwt.react | |
118 | <examples/editor.{native,byte}>: pkg_lwt | |
119 | # Executable rgb | |
120 | <examples/rgb.{native,byte}>: use_lambda-term | |
121 | <examples/rgb.{native,byte}>: pkg_zed | |
122 | <examples/rgb.{native,byte}>: pkg_lwt.unix | |
123 | <examples/rgb.{native,byte}>: pkg_lwt.syntax | |
124 | <examples/rgb.{native,byte}>: pkg_lwt.react | |
125 | <examples/rgb.{native,byte}>: pkg_lwt | |
126 | # Executable colors_256 | |
127 | <examples/colors_256.{native,byte}>: use_lambda-term | |
128 | <examples/colors_256.{native,byte}>: pkg_zed | |
129 | <examples/colors_256.{native,byte}>: pkg_lwt.unix | |
130 | <examples/colors_256.{native,byte}>: pkg_lwt.syntax | |
131 | <examples/colors_256.{native,byte}>: pkg_lwt.react | |
132 | <examples/colors_256.{native,byte}>: pkg_lwt | |
133 | # Executable move | |
134 | <examples/move.{native,byte}>: use_lambda-term | |
135 | <examples/move.{native,byte}>: pkg_zed | |
136 | <examples/move.{native,byte}>: pkg_lwt.unix | |
137 | <examples/move.{native,byte}>: pkg_lwt.syntax | |
138 | <examples/move.{native,byte}>: pkg_lwt.react | |
139 | <examples/move.{native,byte}>: pkg_lwt | |
140 | # Executable buttons | |
141 | <examples/buttons.{native,byte}>: use_lambda-term | |
142 | <examples/buttons.{native,byte}>: pkg_zed | |
143 | <examples/buttons.{native,byte}>: pkg_lwt.unix | |
144 | <examples/buttons.{native,byte}>: pkg_lwt.syntax | |
145 | <examples/buttons.{native,byte}>: pkg_lwt.react | |
146 | <examples/buttons.{native,byte}>: pkg_lwt | |
147 | <examples/*.ml{,i}>: use_lambda-term | |
148 | <examples/*.ml{,i}>: pkg_zed | |
149 | <examples/*.ml{,i}>: pkg_lwt.unix | |
150 | <examples/*.ml{,i}>: pkg_lwt.syntax | |
151 | <examples/*.ml{,i}>: pkg_lwt.react | |
152 | <examples/*.ml{,i}>: pkg_lwt | |
146 | <tools/*.ml{,i}>: pkg_zed | |
147 | # Executable history-stress-test | |
148 | <tests/history_stress_test.{native,byte}>: use_lambda-term | |
149 | <tests/history_stress_test.{native,byte}>: pkg_lwt | |
150 | <tests/history_stress_test.{native,byte}>: pkg_lwt.unix | |
151 | <tests/history_stress_test.{native,byte}>: pkg_lwt.syntax | |
152 | <tests/history_stress_test.{native,byte}>: pkg_lwt.react | |
153 | <tests/history_stress_test.{native,byte}>: pkg_zed | |
154 | <tests/*.ml{,i}>: use_lambda-term | |
155 | <tests/*.ml{,i}>: pkg_lwt | |
156 | <tests/*.ml{,i}>: pkg_lwt.unix | |
157 | <tests/*.ml{,i}>: pkg_lwt.syntax | |
158 | <tests/*.ml{,i}>: pkg_lwt.react | |
159 | <tests/*.ml{,i}>: pkg_zed | |
153 | 160 | # OASIS_STOP |
71 | 71 | B_fg(if exit_code = 0 then lwhite else lred); S code; E_fg; |
72 | 72 | S" ]─"; |
73 | 73 | E_fg; |
74 | S"\n"; | |
74 | 75 | |
75 | 76 | B_fg lred; S(try Sys.getenv "USER" with Not_found -> ""); E_fg; |
76 | 77 | B_fg lgreen; S"@"; E_fg; |
144 | 145 | lwt binaries = get_binaries () in |
145 | 146 | match_lwt |
146 | 147 | try_lwt |
147 | lwt command = (new read_line ~term ~history ~exit_code ~binaries)#run in | |
148 | lwt command = (new read_line ~term ~history:(LTerm_history.contents history) ~exit_code ~binaries)#run in | |
148 | 149 | return (Some command) |
149 | 150 | with Sys.Break -> |
150 | 151 | return None |
151 | 152 | with |
152 | 153 | | Some command -> |
153 | lwt status = Lwt_process.exec (Lwt_process.shell command) in | |
154 | lwt status = | |
155 | try_lwt | |
156 | Lwt_process.exec (Lwt_process.shell command) | |
157 | with Unix.Unix_error (Unix.ENOENT, _, _) -> | |
158 | lwt () = LTerm.fprintls term (eval [B_fg lred; S "command not found"]) in | |
159 | return (Unix.WEXITED 127) | |
160 | in | |
161 | LTerm_history.add history command; | |
154 | 162 | loop |
155 | 163 | term |
156 | (LTerm_read_line.add_entry command history) | |
164 | history | |
157 | 165 | (match status with |
158 | 166 | | Unix.WEXITED code -> code |
159 | 167 | | Unix.WSIGNALED code -> code |
169 | 177 | lwt () = LTerm_inputrc.load () in |
170 | 178 | try_lwt |
171 | 179 | lwt term = Lazy.force LTerm.stdout in |
172 | loop term [] 0 | |
180 | loop term (LTerm_history.create []) 0 | |
173 | 181 | with LTerm_read_line.Interrupt -> |
174 | 182 | return () |
0 | 0 | # OASIS_START |
1 | # DO NOT EDIT (digest: 15b3d54b2e5297018fc18ed5e78346ec) | |
1 | # DO NOT EDIT (digest: 018d09151b8f722e940e6273f7eea50b) | |
2 | 2 | src/LTerm |
3 | 3 | src/LTerm_key |
4 | 4 | src/LTerm_event |
5 | 5 | src/LTerm_unix |
6 | 6 | src/LTerm_windows |
7 | src/LTerm_iconv | |
8 | 7 | src/LTerm_style |
9 | 8 | src/LTerm_geom |
10 | 9 | src/LTerm_draw |
11 | 10 | src/LTerm_mouse |
12 | src/LTerm_color_mappings | |
13 | 11 | src/LTerm_widget |
14 | 12 | src/LTerm_edit |
15 | 13 | src/LTerm_read_line |
17 | 15 | src/LTerm_ui |
18 | 16 | src/LTerm_resources |
19 | 17 | src/LTerm_inputrc |
18 | src/LTerm_history | |
20 | 19 | # OASIS_STOP |
7 | 7 | *) |
8 | 8 | |
9 | 9 | (* OASIS_START *) |
10 | (* DO NOT EDIT (digest: 58cb0bb2797c6f9456b5d520b2a6eb4d) *) | |
10 | (* DO NOT EDIT (digest: c2536d5c3dfc79582a4d8fb624ea092b) *) | |
11 | 11 | module OASISGettext = struct |
12 | # 21 "/home/dim/sources/oasis/src/oasis/OASISGettext.ml" | |
13 | ||
12 | (* # 21 "/mnt/local/sda1/jdimino/dot-opam/4.01.0dev+short-paths/build/oasis.0.3.0/src/oasis/OASISGettext.ml" *) | |
13 | ||
14 | 14 | let ns_ str = |
15 | 15 | str |
16 | ||
16 | ||
17 | 17 | let s_ str = |
18 | 18 | str |
19 | ||
19 | ||
20 | 20 | let f_ (str : ('a, 'b, 'c, 'd) format4) = |
21 | 21 | str |
22 | ||
22 | ||
23 | 23 | let fn_ fmt1 fmt2 n = |
24 | 24 | if n = 1 then |
25 | 25 | fmt1^^"" |
26 | 26 | else |
27 | 27 | fmt2^^"" |
28 | ||
28 | ||
29 | 29 | let init = |
30 | 30 | [] |
31 | ||
31 | ||
32 | 32 | end |
33 | 33 | |
34 | 34 | module OASISExpr = struct |
35 | # 21 "/home/dim/sources/oasis/src/oasis/OASISExpr.ml" | |
36 | ||
37 | ||
38 | ||
35 | (* # 21 "/mnt/local/sda1/jdimino/dot-opam/4.01.0dev+short-paths/build/oasis.0.3.0/src/oasis/OASISExpr.ml" *) | |
36 | ||
37 | ||
38 | ||
39 | 39 | open OASISGettext |
40 | ||
40 | ||
41 | 41 | type test = string |
42 | ||
42 | ||
43 | 43 | type flag = string |
44 | ||
44 | ||
45 | 45 | type t = |
46 | 46 | | EBool of bool |
47 | 47 | | ENot of t |
50 | 50 | | EFlag of flag |
51 | 51 | | ETest of test * string |
52 | 52 | |
53 | ||
53 | ||
54 | 54 | type 'a choices = (t * 'a) list |
55 | ||
55 | ||
56 | 56 | let eval var_get t = |
57 | 57 | let rec eval' = |
58 | 58 | function |
59 | 59 | | EBool b -> |
60 | 60 | b |
61 | ||
61 | ||
62 | 62 | | ENot e -> |
63 | 63 | not (eval' e) |
64 | ||
64 | ||
65 | 65 | | EAnd (e1, e2) -> |
66 | 66 | (eval' e1) && (eval' e2) |
67 | ||
67 | ||
68 | 68 | | EOr (e1, e2) -> |
69 | 69 | (eval' e1) || (eval' e2) |
70 | ||
70 | ||
71 | 71 | | EFlag nm -> |
72 | 72 | let v = |
73 | 73 | var_get nm |
74 | 74 | in |
75 | 75 | assert(v = "true" || v = "false"); |
76 | 76 | (v = "true") |
77 | ||
77 | ||
78 | 78 | | ETest (nm, vl) -> |
79 | 79 | let v = |
80 | 80 | var_get nm |
82 | 82 | (v = vl) |
83 | 83 | in |
84 | 84 | eval' t |
85 | ||
85 | ||
86 | 86 | let choose ?printer ?name var_get lst = |
87 | 87 | let rec choose_aux = |
88 | 88 | function |
118 | 118 | str_lst) |
119 | 119 | in |
120 | 120 | choose_aux (List.rev lst) |
121 | ||
121 | ||
122 | 122 | end |
123 | 123 | |
124 | 124 | |
125 | # 117 "myocamlbuild.ml" | |
125 | 126 | module BaseEnvLight = struct |
126 | # 21 "/home/dim/sources/oasis/src/base/BaseEnvLight.ml" | |
127 | ||
127 | (* # 21 "/mnt/local/sda1/jdimino/dot-opam/4.01.0dev+short-paths/build/oasis.0.3.0/src/base/BaseEnvLight.ml" *) | |
128 | ||
128 | 129 | module MapString = Map.Make(String) |
129 | ||
130 | ||
130 | 131 | type t = string MapString.t |
131 | ||
132 | ||
132 | 133 | let default_filename = |
133 | 134 | Filename.concat |
134 | 135 | (Sys.getcwd ()) |
135 | 136 | "setup.data" |
136 | ||
137 | ||
137 | 138 | let load ?(allow_empty=false) ?(filename=default_filename) () = |
138 | 139 | if Sys.file_exists filename then |
139 | 140 | begin |
190 | 191 | "Unable to load environment, the file '%s' doesn't exist." |
191 | 192 | filename) |
192 | 193 | end |
193 | ||
194 | ||
194 | 195 | let var_get name env = |
195 | 196 | let rec var_expand str = |
196 | 197 | let buff = |
211 | 212 | Buffer.contents buff |
212 | 213 | in |
213 | 214 | var_expand (MapString.find name env) |
214 | ||
215 | ||
215 | 216 | let var_choose lst env = |
216 | 217 | OASISExpr.choose |
217 | 218 | (fun nm -> var_get nm env) |
219 | 220 | end |
220 | 221 | |
221 | 222 | |
223 | # 215 "myocamlbuild.ml" | |
222 | 224 | module MyOCamlbuildFindlib = struct |
223 | # 21 "/home/dim/sources/oasis/src/plugins/ocamlbuild/MyOCamlbuildFindlib.ml" | |
224 | ||
225 | (* # 21 "/mnt/local/sda1/jdimino/dot-opam/4.01.0dev+short-paths/build/oasis.0.3.0/src/plugins/ocamlbuild/MyOCamlbuildFindlib.ml" *) | |
226 | ||
225 | 227 | (** OCamlbuild extension, copied from |
226 | 228 | * http://brion.inria.fr/gallium/index.php/Using_ocamlfind_with_ocamlbuild |
227 | 229 | * by N. Pouillard and others |
231 | 233 | * Modified by Sylvain Le Gall |
232 | 234 | *) |
233 | 235 | open Ocamlbuild_plugin |
234 | ||
236 | ||
235 | 237 | (* these functions are not really officially exported *) |
236 | 238 | let run_and_read = |
237 | 239 | Ocamlbuild_pack.My_unix.run_and_read |
238 | ||
240 | ||
239 | 241 | let blank_sep_strings = |
240 | 242 | Ocamlbuild_pack.Lexers.blank_sep_strings |
241 | ||
243 | ||
242 | 244 | let split s ch = |
243 | 245 | let x = |
244 | 246 | ref [] |
253 | 255 | try |
254 | 256 | go s |
255 | 257 | with Not_found -> !x |
256 | ||
258 | ||
257 | 259 | let split_nl s = split s '\n' |
258 | ||
260 | ||
259 | 261 | let before_space s = |
260 | 262 | try |
261 | 263 | String.before s (String.index s ' ') |
262 | 264 | with Not_found -> s |
263 | ||
265 | ||
264 | 266 | (* this lists all supported packages *) |
265 | 267 | let find_packages () = |
266 | 268 | List.map before_space (split_nl & run_and_read "ocamlfind list") |
267 | ||
269 | ||
268 | 270 | (* this is supposed to list available syntaxes, but I don't know how to do it. *) |
269 | 271 | let find_syntaxes () = ["camlp4o"; "camlp4r"] |
270 | ||
272 | ||
271 | 273 | (* ocamlfind command *) |
272 | 274 | let ocamlfind x = S[A"ocamlfind"; x] |
273 | ||
275 | ||
274 | 276 | let dispatch = |
275 | 277 | function |
276 | 278 | | Before_options -> |
300 | 302 | flag ["ocaml"; "infer_interface"; "pkg_"^pkg] & S[A"-package"; A pkg]; |
301 | 303 | end |
302 | 304 | (find_packages ()); |
303 | ||
305 | ||
304 | 306 | (* Like -package but for extensions syntax. Morover -syntax is useless |
305 | 307 | * when linking. *) |
306 | 308 | List.iter begin fun syntax -> |
309 | 311 | flag ["ocaml"; "doc"; "syntax_"^syntax] & S[A"-syntax"; A syntax]; |
310 | 312 | flag ["ocaml"; "infer_interface"; "syntax_"^syntax] & S[A"-syntax"; A syntax]; |
311 | 313 | end (find_syntaxes ()); |
312 | ||
314 | ||
313 | 315 | (* The default "thread" tag is not compatible with ocamlfind. |
314 | 316 | * Indeed, the default rules add the "threads.cma" or "threads.cmxa" |
315 | 317 | * options when using this tag. When using the "-linkpkg" option with |
322 | 324 | flag ["ocaml"; "pkg_threads"; "doc"] (S[A "-I"; A "+threads"]); |
323 | 325 | flag ["ocaml"; "pkg_threads"; "link"] (S[A "-thread"]); |
324 | 326 | flag ["ocaml"; "pkg_threads"; "infer_interface"] (S[A "-thread"]) |
325 | ||
327 | ||
326 | 328 | | _ -> |
327 | 329 | () |
328 | ||
330 | ||
329 | 331 | end |
330 | 332 | |
331 | 333 | module MyOCamlbuildBase = struct |
332 | # 21 "/home/dim/sources/oasis/src/plugins/ocamlbuild/MyOCamlbuildBase.ml" | |
333 | ||
334 | (* # 21 "/mnt/local/sda1/jdimino/dot-opam/4.01.0dev+short-paths/build/oasis.0.3.0/src/plugins/ocamlbuild/MyOCamlbuildBase.ml" *) | |
335 | ||
334 | 336 | (** Base functions for writing myocamlbuild.ml |
335 | 337 | @author Sylvain Le Gall |
336 | 338 | *) |
337 | ||
338 | ||
339 | ||
339 | ||
340 | ||
341 | ||
340 | 342 | open Ocamlbuild_plugin |
341 | ||
343 | module OC = Ocamlbuild_pack.Ocaml_compiler | |
344 | ||
342 | 345 | type dir = string |
343 | 346 | type file = string |
344 | 347 | type name = string |
345 | 348 | type tag = string |
346 | ||
347 | # 55 "/home/dim/sources/oasis/src/plugins/ocamlbuild/MyOCamlbuildBase.ml" | |
348 | ||
349 | ||
350 | (* # 56 "/mnt/local/sda1/jdimino/dot-opam/4.01.0dev+short-paths/build/oasis.0.3.0/src/plugins/ocamlbuild/MyOCamlbuildBase.ml" *) | |
351 | ||
349 | 352 | type t = |
350 | 353 | { |
351 | 354 | lib_ocaml: (name * dir list) list; |
352 | 355 | lib_c: (name * dir * file list) list; |
353 | 356 | flags: (tag list * (spec OASISExpr.choices)) list; |
357 | (* Replace the 'dir: include' from _tags by a precise interdepends in | |
358 | * directory. | |
359 | *) | |
360 | includes: (dir * dir list) list; | |
354 | 361 | } |
355 | ||
362 | ||
356 | 363 | let env_filename = |
357 | 364 | Pathname.basename |
358 | 365 | BaseEnvLight.default_filename |
359 | ||
366 | ||
360 | 367 | let dispatch_combine lst = |
361 | 368 | fun e -> |
362 | 369 | List.iter |
363 | 370 | (fun dispatch -> dispatch e) |
364 | 371 | lst |
365 | ||
372 | ||
373 | let tag_libstubs nm = | |
374 | "use_lib"^nm^"_stubs" | |
375 | ||
376 | let nm_libstubs nm = | |
377 | nm^"_stubs" | |
378 | ||
366 | 379 | let dispatch t e = |
367 | 380 | let env = |
368 | 381 | BaseEnvLight.load |
389 | 402 | Options.ext_lib, "ext_lib"; |
390 | 403 | Options.ext_dll, "ext_dll"; |
391 | 404 | ] |
392 | ||
405 | ||
393 | 406 | | After_rules -> |
394 | 407 | (* Declare OCaml libraries *) |
395 | 408 | List.iter |
396 | 409 | (function |
397 | | lib, [] -> | |
398 | ocaml_lib lib; | |
399 | | lib, dir :: tl -> | |
400 | ocaml_lib ~dir:dir lib; | |
410 | | nm, [] -> | |
411 | ocaml_lib nm | |
412 | | nm, dir :: tl -> | |
413 | ocaml_lib ~dir:dir (dir^"/"^nm); | |
401 | 414 | List.iter |
402 | 415 | (fun dir -> |
403 | flag | |
404 | ["ocaml"; "use_"^lib; "compile"] | |
405 | (S[A"-I"; P dir])) | |
416 | List.iter | |
417 | (fun str -> | |
418 | flag ["ocaml"; "use_"^nm; str] (S[A"-I"; P dir])) | |
419 | ["compile"; "infer_interface"; "doc"]) | |
406 | 420 | tl) |
407 | 421 | t.lib_ocaml; |
408 | ||
422 | ||
423 | (* Declare directories dependencies, replace "include" in _tags. *) | |
424 | List.iter | |
425 | (fun (dir, include_dirs) -> | |
426 | Pathname.define_context dir include_dirs) | |
427 | t.includes; | |
428 | ||
409 | 429 | (* Declare C libraries *) |
410 | 430 | List.iter |
411 | 431 | (fun (lib, dir, headers) -> |
412 | 432 | (* Handle C part of library *) |
413 | flag ["link"; "library"; "ocaml"; "byte"; "use_lib"^lib] | |
414 | (S[A"-dllib"; A("-l"^lib); A"-cclib"; A("-l"^lib)]); | |
415 | ||
416 | flag ["link"; "library"; "ocaml"; "native"; "use_lib"^lib] | |
417 | (S[A"-cclib"; A("-l"^lib)]); | |
433 | flag ["link"; "library"; "ocaml"; "byte"; tag_libstubs lib] | |
434 | (S[A"-dllib"; A("-l"^(nm_libstubs lib)); A"-cclib"; | |
435 | A("-l"^(nm_libstubs lib))]); | |
436 | ||
437 | flag ["link"; "library"; "ocaml"; "native"; tag_libstubs lib] | |
438 | (S[A"-cclib"; A("-l"^(nm_libstubs lib))]); | |
418 | 439 | |
419 | flag ["link"; "program"; "ocaml"; "byte"; "use_lib"^lib] | |
420 | (S[A"-dllib"; A("dll"^lib)]); | |
421 | ||
440 | flag ["link"; "program"; "ocaml"; "byte"; tag_libstubs lib] | |
441 | (S[A"-dllib"; A("dll"^(nm_libstubs lib))]); | |
442 | ||
422 | 443 | (* When ocaml link something that use the C library, then one |
423 | 444 | need that file to be up to date. |
424 | 445 | *) |
425 | dep ["link"; "ocaml"; "use_lib"^lib] | |
426 | [dir/"lib"^lib^"."^(!Options.ext_lib)]; | |
427 | ||
446 | dep ["link"; "ocaml"; "program"; tag_libstubs lib] | |
447 | [dir/"lib"^(nm_libstubs lib)^"."^(!Options.ext_lib)]; | |
448 | ||
449 | dep ["compile"; "ocaml"; "program"; tag_libstubs lib] | |
450 | [dir/"lib"^(nm_libstubs lib)^"."^(!Options.ext_lib)]; | |
451 | ||
428 | 452 | (* TODO: be more specific about what depends on headers *) |
429 | 453 | (* Depends on .h files *) |
430 | 454 | dep ["compile"; "c"] |
431 | 455 | headers; |
432 | ||
456 | ||
433 | 457 | (* Setup search path for lib *) |
434 | 458 | flag ["link"; "ocaml"; "use_"^lib] |
435 | 459 | (S[A"-I"; P(dir)]); |
436 | 460 | ) |
437 | 461 | t.lib_c; |
438 | ||
462 | ||
439 | 463 | (* Add flags *) |
440 | 464 | List.iter |
441 | 465 | (fun (tags, cond_specs) -> |
446 | 470 | t.flags |
447 | 471 | | _ -> |
448 | 472 | () |
449 | ||
473 | ||
450 | 474 | let dispatch_default t = |
451 | 475 | dispatch_combine |
452 | 476 | [ |
453 | 477 | dispatch t; |
454 | 478 | MyOCamlbuildFindlib.dispatch; |
455 | 479 | ] |
456 | ||
480 | ||
457 | 481 | end |
458 | 482 | |
459 | 483 | |
484 | # 476 "myocamlbuild.ml" | |
460 | 485 | open Ocamlbuild_plugin;; |
461 | 486 | let package_default = |
462 | 487 | { |
463 | MyOCamlbuildBase.lib_ocaml = [("src/lambda-term", ["src"])]; | |
488 | MyOCamlbuildBase.lib_ocaml = [("lambda-term", ["src"])]; | |
464 | 489 | lib_c = [("lambda-term", "src", [])]; |
465 | 490 | flags = []; |
491 | includes = | |
492 | [("tools", ["src"]); ("tests", ["src"]); ("examples", ["src"])]; | |
466 | 493 | } |
467 | 494 | ;; |
468 | 495 | |
469 | 496 | let dispatch_default = MyOCamlbuildBase.dispatch_default package_default;; |
470 | 497 | |
498 | # 491 "myocamlbuild.ml" | |
471 | 499 | (* OASIS_STOP *) |
472 | 500 | |
473 | 501 | open Ocamlbuild_plugin |
481 | 509 | Options.make_links := false |
482 | 510 | |
483 | 511 | | After_rules -> |
484 | flag ["c"; "compile"; "use_lwt_unix_h"] & S[A"-package"; A"lwt"]; | |
485 | ||
486 | rule "generation of color mappings" | |
487 | ~dep:"src/gen_color_mappings.byte" | |
488 | ~prod:"src/lTerm_color_mappings.ml" | |
489 | (fun _ _ -> | |
490 | Cmd(S[P"src/gen_color_mappings.byte"; A"src/lTerm_color_mappings.ml"])); | |
491 | ||
492 | let env = BaseEnvLight.load () in | |
493 | ||
494 | if BaseEnvLight.var_get "need_liconv" env = "true" then begin | |
495 | flag ["ocamlmklib"; "c"; "use_iconv"] & A"-liconv"; | |
496 | flag ["link"; "ocaml"; "use_iconv"] & S[A"-cclib"; A"-liconv"] | |
497 | end; | |
498 | ||
499 | let dir = BaseEnvLight.var_get "iconv_prefix" env in | |
500 | if dir <> "" then begin | |
501 | flag ["ocamlmklib"; "c"; "use_iconv"] & A("-L" ^ dir ^ "/lib"); | |
502 | flag ["c"; "compile"; "use_iconv"] & S[A"-ccopt"; A("-I" ^ dir ^ "/include")]; | |
503 | flag ["link"; "ocaml"; "use_iconv"] & S[A"-cclib"; A("-L" ^ dir ^ "/lib")] | |
504 | end | |
512 | flag ["c"; "compile"; "use_lwt_unix_h"] & S[A"-package"; A"lwt"] | |
505 | 513 | |
506 | 514 | | _ -> |
507 | 515 | ()) |
0 | (* | |
1 | * print_sequences.ml | |
2 | * ------------------ | |
3 | * Copyright : (c) 2012, Jeremie Dimino <jeremie@dimino.org> | |
4 | * Licence : BSD3 | |
5 | * | |
6 | * This file is a part of Lambda-Term. | |
7 | *) | |
8 | ||
9 | (* Script to print sequences returned by the terminal. You can execute | |
10 | it like this: | |
11 | ||
12 | # ocaml print_sequences.ml | |
13 | *) | |
14 | ||
15 | #load "unix.cma";; | |
16 | ||
17 | let () = | |
18 | (* Setup terminal attributes. *) | |
19 | let attr = Unix.tcgetattr Unix.stdin in | |
20 | Unix.tcsetattr Unix.stdin Unix.TCSAFLUSH { | |
21 | attr with | |
22 | Unix.c_brkint = false; | |
23 | Unix.c_inpck = false; | |
24 | Unix.c_istrip = false; | |
25 | Unix.c_ixon = false; | |
26 | Unix.c_csize = 8; | |
27 | Unix.c_parenb = false; | |
28 | Unix.c_echo = false; | |
29 | Unix.c_icanon = false; | |
30 | Unix.c_vmin = 1; | |
31 | Unix.c_vtime = 0; | |
32 | Unix.c_isig = false; | |
33 | }; | |
34 | (* Read and print key sequences. *) | |
35 | print_endline "press 'q' to quit"; | |
36 | let buf = String.create 128 in | |
37 | let rec loop () = | |
38 | let n = Unix.read Unix.stdin buf 0 (String.length buf) in | |
39 | let s = String.sub buf 0 n in | |
40 | print_endline (String.escaped s); | |
41 | if s <> "q" then loop () | |
42 | in | |
43 | let result = | |
44 | try | |
45 | loop (); | |
46 | `OK | |
47 | with exn -> | |
48 | `Exn exn | |
49 | in | |
50 | (* Reset terminal attributes. *) | |
51 | Unix.tcsetattr Unix.stdin Unix.TCSAFLUSH attr; | |
52 | match result with | |
53 | | `OK -> () | |
54 | | `Exn exn -> raise exn | |
55 |
3 | 3 | * Copyright : (c) 2011, Jeremie Dimino <jeremie@dimino.org> |
4 | 4 | * Licence : BSD3 |
5 | 5 | * |
6 | * This file is a part of Lambda-Term. | |
6 | * This file is a part of Zed, an editor engine. | |
7 | 7 | *) |
8 | 8 | |
9 | (* List of paths to search for iconv *) | |
10 | let search_paths = [ | |
11 | "/usr"; | |
12 | "/usr/local"; | |
13 | "/opt"; | |
14 | "/opt/local"; | |
15 | "/sw"; | |
16 | "/mingw"; | |
17 | "/mingw/local"; | |
18 | ] | |
19 | ||
20 | 9 | (* OASIS_START *) |
21 | (* DO NOT EDIT (digest: fc0fbe126ea51baf078319ddeeedf51e) *) | |
10 | (* DO NOT EDIT (digest: 196e721eb8f28d35d292d1cde7b5ccd3) *) | |
22 | 11 | (* |
23 | Regenerated by OASIS v0.2.1~alpha1 | |
12 | Regenerated by OASIS v0.3.0 | |
24 | 13 | Visit http://oasis.forge.ocamlcore.org for more information and |
25 | 14 | documentation about functions used in this file. |
26 | 15 | *) |
27 | 16 | module OASISGettext = struct |
28 | # 21 "/home/dim/sources/oasis/src/oasis/OASISGettext.ml" | |
29 | ||
17 | (* # 21 "/mnt/local/sda1/jdimino/dot-opam/4.01.0dev+short-paths/build/oasis.0.3.0/src/oasis/OASISGettext.ml" *) | |
18 | ||
30 | 19 | let ns_ str = |
31 | 20 | str |
32 | ||
21 | ||
33 | 22 | let s_ str = |
34 | 23 | str |
35 | ||
24 | ||
36 | 25 | let f_ (str : ('a, 'b, 'c, 'd) format4) = |
37 | 26 | str |
38 | ||
27 | ||
39 | 28 | let fn_ fmt1 fmt2 n = |
40 | 29 | if n = 1 then |
41 | 30 | fmt1^^"" |
42 | 31 | else |
43 | 32 | fmt2^^"" |
44 | ||
33 | ||
45 | 34 | let init = |
46 | 35 | [] |
47 | ||
36 | ||
48 | 37 | end |
49 | 38 | |
50 | 39 | module OASISContext = struct |
51 | # 21 "/home/dim/sources/oasis/src/oasis/OASISContext.ml" | |
52 | ||
40 | (* # 21 "/mnt/local/sda1/jdimino/dot-opam/4.01.0dev+short-paths/build/oasis.0.3.0/src/oasis/OASISContext.ml" *) | |
41 | ||
53 | 42 | open OASISGettext |
54 | ||
43 | ||
55 | 44 | type level = |
56 | 45 | [ `Debug |
57 | 46 | | `Info |
58 | 47 | | `Warning |
59 | 48 | | `Error] |
60 | ||
49 | ||
61 | 50 | type t = |
62 | 51 | { |
63 | verbose: bool; | |
52 | quiet: bool; | |
53 | info: bool; | |
64 | 54 | debug: bool; |
65 | 55 | ignore_plugins: bool; |
66 | 56 | ignore_unknown_fields: bool; |
67 | 57 | printf: level -> string -> unit; |
68 | 58 | } |
69 | ||
59 | ||
70 | 60 | let printf lvl str = |
71 | 61 | let beg = |
72 | 62 | match lvl with |
76 | 66 | | `Debug -> s_ "D: " |
77 | 67 | in |
78 | 68 | prerr_endline (beg^str) |
79 | ||
69 | ||
80 | 70 | let default = |
81 | 71 | ref |
82 | 72 | { |
83 | verbose = true; | |
73 | quiet = false; | |
74 | info = false; | |
84 | 75 | debug = false; |
85 | 76 | ignore_plugins = false; |
86 | 77 | ignore_unknown_fields = false; |
87 | 78 | printf = printf; |
88 | 79 | } |
89 | ||
80 | ||
90 | 81 | let quiet = |
91 | {!default with | |
92 | verbose = false; | |
93 | debug = false; | |
94 | } | |
95 | ||
96 | ||
82 | {!default with quiet = true} | |
83 | ||
84 | ||
97 | 85 | let args () = |
98 | 86 | ["-quiet", |
99 | Arg.Unit (fun () -> default := {!default with verbose = false}), | |
87 | Arg.Unit (fun () -> default := {!default with quiet = true}), | |
100 | 88 | (s_ " Run quietly"); |
101 | ||
89 | ||
90 | "-info", | |
91 | Arg.Unit (fun () -> default := {!default with info = true}), | |
92 | (s_ " Display information message"); | |
93 | ||
94 | ||
102 | 95 | "-debug", |
103 | 96 | Arg.Unit (fun () -> default := {!default with debug = true}), |
104 | 97 | (s_ " Output debug message")] |
105 | 98 | end |
106 | 99 | |
100 | module OASISString = struct | |
101 | (* # 1 "/mnt/local/sda1/jdimino/dot-opam/4.01.0dev+short-paths/build/oasis.0.3.0/src/oasis/OASISString.ml" *) | |
102 | ||
103 | ||
104 | ||
105 | (** Various string utilities. | |
106 | ||
107 | Mostly inspired by extlib and batteries ExtString and BatString libraries. | |
108 | ||
109 | @author Sylvain Le Gall | |
110 | *) | |
111 | ||
112 | let nsplitf str f = | |
113 | if str = "" then | |
114 | [] | |
115 | else | |
116 | let buf = Buffer.create 13 in | |
117 | let lst = ref [] in | |
118 | let push () = | |
119 | lst := Buffer.contents buf :: !lst; | |
120 | Buffer.clear buf | |
121 | in | |
122 | let str_len = String.length str in | |
123 | for i = 0 to str_len - 1 do | |
124 | if f str.[i] then | |
125 | push () | |
126 | else | |
127 | Buffer.add_char buf str.[i] | |
128 | done; | |
129 | push (); | |
130 | List.rev !lst | |
131 | ||
132 | (** [nsplit c s] Split the string [s] at char [c]. It doesn't include the | |
133 | separator. | |
134 | *) | |
135 | let nsplit str c = | |
136 | nsplitf str ((=) c) | |
137 | ||
138 | let find ~what ?(offset=0) str = | |
139 | let what_idx = ref 0 in | |
140 | let str_idx = ref offset in | |
141 | while !str_idx < String.length str && | |
142 | !what_idx < String.length what do | |
143 | if str.[!str_idx] = what.[!what_idx] then | |
144 | incr what_idx | |
145 | else | |
146 | what_idx := 0; | |
147 | incr str_idx | |
148 | done; | |
149 | if !what_idx <> String.length what then | |
150 | raise Not_found | |
151 | else | |
152 | !str_idx - !what_idx | |
153 | ||
154 | let sub_start str len = | |
155 | let str_len = String.length str in | |
156 | if len >= str_len then | |
157 | "" | |
158 | else | |
159 | String.sub str len (str_len - len) | |
160 | ||
161 | let sub_end ?(offset=0) str len = | |
162 | let str_len = String.length str in | |
163 | if len >= str_len then | |
164 | "" | |
165 | else | |
166 | String.sub str 0 (str_len - len) | |
167 | ||
168 | let starts_with ~what ?(offset=0) str = | |
169 | let what_idx = ref 0 in | |
170 | let str_idx = ref offset in | |
171 | let ok = ref true in | |
172 | while !ok && | |
173 | !str_idx < String.length str && | |
174 | !what_idx < String.length what do | |
175 | if str.[!str_idx] = what.[!what_idx] then | |
176 | incr what_idx | |
177 | else | |
178 | ok := false; | |
179 | incr str_idx | |
180 | done; | |
181 | if !what_idx = String.length what then | |
182 | true | |
183 | else | |
184 | false | |
185 | ||
186 | let strip_starts_with ~what str = | |
187 | if starts_with ~what str then | |
188 | sub_start str (String.length what) | |
189 | else | |
190 | raise Not_found | |
191 | ||
192 | let ends_with ~what ?(offset=0) str = | |
193 | let what_idx = ref ((String.length what) - 1) in | |
194 | let str_idx = ref ((String.length str) - 1) in | |
195 | let ok = ref true in | |
196 | while !ok && | |
197 | offset <= !str_idx && | |
198 | 0 <= !what_idx do | |
199 | if str.[!str_idx] = what.[!what_idx] then | |
200 | decr what_idx | |
201 | else | |
202 | ok := false; | |
203 | decr str_idx | |
204 | done; | |
205 | if !what_idx = -1 then | |
206 | true | |
207 | else | |
208 | false | |
209 | ||
210 | let strip_ends_with ~what str = | |
211 | if ends_with ~what str then | |
212 | sub_end str (String.length what) | |
213 | else | |
214 | raise Not_found | |
215 | ||
216 | let replace_chars f s = | |
217 | let buf = String.make (String.length s) 'X' in | |
218 | for i = 0 to String.length s - 1 do | |
219 | buf.[i] <- f s.[i] | |
220 | done; | |
221 | buf | |
222 | ||
223 | end | |
224 | ||
107 | 225 | module OASISUtils = struct |
108 | # 21 "/home/dim/sources/oasis/src/oasis/OASISUtils.ml" | |
109 | ||
226 | (* # 21 "/mnt/local/sda1/jdimino/dot-opam/4.01.0dev+short-paths/build/oasis.0.3.0/src/oasis/OASISUtils.ml" *) | |
227 | ||
228 | open OASISGettext | |
229 | ||
110 | 230 | module MapString = Map.Make(String) |
111 | ||
231 | ||
112 | 232 | let map_string_of_assoc assoc = |
113 | 233 | List.fold_left |
114 | 234 | (fun acc (k, v) -> MapString.add k v acc) |
115 | 235 | MapString.empty |
116 | 236 | assoc |
117 | ||
237 | ||
118 | 238 | module SetString = Set.Make(String) |
119 | ||
239 | ||
120 | 240 | let set_string_add_list st lst = |
121 | 241 | List.fold_left |
122 | 242 | (fun acc e -> SetString.add e acc) |
123 | 243 | st |
124 | 244 | lst |
125 | ||
245 | ||
126 | 246 | let set_string_of_list = |
127 | 247 | set_string_add_list |
128 | 248 | SetString.empty |
129 | ||
130 | ||
249 | ||
250 | ||
131 | 251 | let compare_csl s1 s2 = |
132 | 252 | String.compare (String.lowercase s1) (String.lowercase s2) |
133 | ||
253 | ||
134 | 254 | module HashStringCsl = |
135 | 255 | Hashtbl.Make |
136 | 256 | (struct |
137 | 257 | type t = string |
138 | ||
258 | ||
139 | 259 | let equal s1 s2 = |
140 | 260 | (String.lowercase s1) = (String.lowercase s2) |
141 | ||
261 | ||
142 | 262 | let hash s = |
143 | 263 | Hashtbl.hash (String.lowercase s) |
144 | 264 | end) |
145 | ||
146 | let split sep str = | |
147 | let str_len = | |
148 | String.length str | |
149 | in | |
150 | let rec split_aux acc pos = | |
151 | if pos < str_len then | |
152 | ( | |
153 | let pos_sep = | |
154 | try | |
155 | String.index_from str pos sep | |
156 | with Not_found -> | |
157 | str_len | |
158 | in | |
159 | let part = | |
160 | String.sub str pos (pos_sep - pos) | |
161 | in | |
162 | let acc = | |
163 | part :: acc | |
164 | in | |
165 | if pos_sep >= str_len then | |
166 | ( | |
167 | (* Nothing more in the string *) | |
168 | List.rev acc | |
169 | ) | |
170 | else if pos_sep = (str_len - 1) then | |
171 | ( | |
172 | (* String end with a separator *) | |
173 | List.rev ("" :: acc) | |
174 | ) | |
175 | else | |
176 | ( | |
177 | split_aux acc (pos_sep + 1) | |
178 | ) | |
179 | ) | |
180 | else | |
181 | ( | |
182 | List.rev acc | |
183 | ) | |
184 | in | |
185 | split_aux [] 0 | |
186 | ||
187 | ||
265 | ||
188 | 266 | let varname_of_string ?(hyphen='_') s = |
189 | 267 | if String.length s = 0 then |
190 | 268 | begin |
192 | 270 | end |
193 | 271 | else |
194 | 272 | begin |
195 | let buff = | |
196 | Buffer.create (String.length s) | |
197 | in | |
198 | (* Start with a _ if digit *) | |
199 | if '0' <= s.[0] && s.[0] <= '9' then | |
200 | Buffer.add_char buff hyphen; | |
201 | ||
202 | String.iter | |
273 | let buf = | |
274 | OASISString.replace_chars | |
203 | 275 | (fun c -> |
204 | 276 | if ('a' <= c && c <= 'z') |
205 | 277 | || |
206 | 278 | ('A' <= c && c <= 'Z') |
207 | 279 | || |
208 | 280 | ('0' <= c && c <= '9') then |
209 | Buffer.add_char buff c | |
281 | c | |
210 | 282 | else |
211 | Buffer.add_char buff hyphen) | |
283 | hyphen) | |
212 | 284 | s; |
213 | ||
214 | String.lowercase (Buffer.contents buff) | |
285 | in | |
286 | let buf = | |
287 | (* Start with a _ if digit *) | |
288 | if '0' <= s.[0] && s.[0] <= '9' then | |
289 | "_"^buf | |
290 | else | |
291 | buf | |
292 | in | |
293 | String.lowercase buf | |
215 | 294 | end |
216 | ||
295 | ||
217 | 296 | let varname_concat ?(hyphen='_') p s = |
297 | let what = String.make 1 hyphen in | |
218 | 298 | let p = |
219 | let p_len = | |
220 | String.length p | |
221 | in | |
222 | if p_len > 0 && p.[p_len - 1] = hyphen then | |
223 | String.sub p 0 (p_len - 1) | |
224 | else | |
225 | p | |
299 | try | |
300 | OASISString.strip_ends_with ~what p | |
301 | with Not_found -> | |
302 | p | |
226 | 303 | in |
227 | 304 | let s = |
228 | let s_len = | |
229 | String.length s | |
230 | in | |
231 | if s_len > 0 && s.[0] = hyphen then | |
232 | String.sub s 1 (s_len - 1) | |
233 | else | |
234 | s | |
235 | in | |
236 | Printf.sprintf "%s%c%s" p hyphen s | |
237 | ||
238 | ||
305 | try | |
306 | OASISString.strip_starts_with ~what s | |
307 | with Not_found -> | |
308 | s | |
309 | in | |
310 | p^what^s | |
311 | ||
312 | ||
239 | 313 | let is_varname str = |
240 | 314 | str = varname_of_string str |
241 | ||
315 | ||
242 | 316 | let failwithf fmt = Printf.ksprintf failwith fmt |
243 | ||
317 | ||
244 | 318 | end |
245 | 319 | |
246 | 320 | module PropList = struct |
247 | # 21 "/home/dim/sources/oasis/src/oasis/PropList.ml" | |
248 | ||
321 | (* # 21 "/mnt/local/sda1/jdimino/dot-opam/4.01.0dev+short-paths/build/oasis.0.3.0/src/oasis/PropList.ml" *) | |
322 | ||
249 | 323 | open OASISGettext |
250 | ||
324 | ||
251 | 325 | type name = string |
252 | ||
326 | ||
253 | 327 | exception Not_set of name * string option |
254 | 328 | exception No_printer of name |
255 | 329 | exception Unknown_field of name * name |
256 | ||
257 | let string_of_exception = | |
258 | function | |
259 | | Not_set (nm, Some rsn) -> | |
260 | Printf.sprintf (f_ "Field '%s' is not set: %s") nm rsn | |
261 | | Not_set (nm, None) -> | |
262 | Printf.sprintf (f_ "Field '%s' is not set") nm | |
263 | | No_printer nm -> | |
264 | Printf.sprintf (f_ "No default printer for value %s") nm | |
265 | | Unknown_field (nm, schm) -> | |
266 | Printf.sprintf (f_ "Field %s is not defined in schema %s") nm schm | |
267 | | e -> | |
268 | raise e | |
269 | ||
330 | ||
331 | let () = | |
332 | Printexc.register_printer | |
333 | (function | |
334 | | Not_set (nm, Some rsn) -> | |
335 | Some | |
336 | (Printf.sprintf (f_ "Field '%s' is not set: %s") nm rsn) | |
337 | | Not_set (nm, None) -> | |
338 | Some | |
339 | (Printf.sprintf (f_ "Field '%s' is not set") nm) | |
340 | | No_printer nm -> | |
341 | Some | |
342 | (Printf.sprintf (f_ "No default printer for value %s") nm) | |
343 | | Unknown_field (nm, schm) -> | |
344 | Some | |
345 | (Printf.sprintf (f_ "Field %s is not defined in schema %s") nm schm) | |
346 | | _ -> | |
347 | None) | |
348 | ||
270 | 349 | module Data = |
271 | 350 | struct |
272 | ||
351 | ||
273 | 352 | type t = |
274 | 353 | (name, unit -> unit) Hashtbl.t |
275 | ||
354 | ||
276 | 355 | let create () = |
277 | 356 | Hashtbl.create 13 |
278 | ||
357 | ||
279 | 358 | let clear t = |
280 | 359 | Hashtbl.clear t |
281 | ||
282 | # 66 "/home/dim/sources/oasis/src/oasis/PropList.ml" | |
360 | ||
361 | (* # 71 "/mnt/local/sda1/jdimino/dot-opam/4.01.0dev+short-paths/build/oasis.0.3.0/src/oasis/PropList.ml" *) | |
283 | 362 | end |
284 | ||
363 | ||
285 | 364 | module Schema = |
286 | 365 | struct |
287 | ||
366 | ||
288 | 367 | type ('ctxt, 'extra) value = |
289 | 368 | { |
290 | 369 | get: Data.t -> string; |
292 | 371 | help: (unit -> string) option; |
293 | 372 | extra: 'extra; |
294 | 373 | } |
295 | ||
374 | ||
296 | 375 | type ('ctxt, 'extra) t = |
297 | 376 | { |
298 | 377 | name: name; |
300 | 379 | order: name Queue.t; |
301 | 380 | name_norm: string -> string; |
302 | 381 | } |
303 | ||
382 | ||
304 | 383 | let create ?(case_insensitive=false) nm = |
305 | 384 | { |
306 | 385 | name = nm; |
312 | 391 | else |
313 | 392 | fun s -> s); |
314 | 393 | } |
315 | ||
394 | ||
316 | 395 | let add t nm set get extra help = |
317 | 396 | let key = |
318 | 397 | t.name_norm nm |
319 | 398 | in |
320 | ||
399 | ||
321 | 400 | if Hashtbl.mem t.fields key then |
322 | 401 | failwith |
323 | 402 | (Printf.sprintf |
333 | 412 | extra = extra; |
334 | 413 | }; |
335 | 414 | Queue.add nm t.order |
336 | ||
415 | ||
337 | 416 | let mem t nm = |
338 | 417 | Hashtbl.mem t.fields nm |
339 | ||
418 | ||
340 | 419 | let find t nm = |
341 | 420 | try |
342 | 421 | Hashtbl.find t.fields (t.name_norm nm) |
343 | 422 | with Not_found -> |
344 | 423 | raise (Unknown_field (nm, t.name)) |
345 | ||
424 | ||
346 | 425 | let get t data nm = |
347 | 426 | (find t nm).get data |
348 | ||
427 | ||
349 | 428 | let set t data nm ?context x = |
350 | 429 | (find t nm).set |
351 | 430 | data |
352 | 431 | ?context |
353 | 432 | x |
354 | ||
433 | ||
355 | 434 | let fold f acc t = |
356 | 435 | Queue.fold |
357 | 436 | (fun acc k -> |
361 | 440 | f acc k v.extra v.help) |
362 | 441 | acc |
363 | 442 | t.order |
364 | ||
443 | ||
365 | 444 | let iter f t = |
366 | 445 | fold |
367 | 446 | (fun () -> f) |
368 | 447 | () |
369 | 448 | t |
370 | ||
449 | ||
371 | 450 | let name t = |
372 | 451 | t.name |
373 | 452 | end |
374 | ||
453 | ||
375 | 454 | module Field = |
376 | 455 | struct |
377 | ||
456 | ||
378 | 457 | type ('ctxt, 'value, 'extra) t = |
379 | 458 | { |
380 | 459 | set: Data.t -> ?context:'ctxt -> 'value -> unit; |
384 | 463 | help: (unit -> string) option; |
385 | 464 | extra: 'extra; |
386 | 465 | } |
387 | ||
466 | ||
388 | 467 | let new_id = |
389 | 468 | let last_id = |
390 | 469 | ref 0 |
391 | 470 | in |
392 | 471 | fun () -> incr last_id; !last_id |
393 | ||
472 | ||
394 | 473 | let create ?schema ?name ?parse ?print ?default ?update ?help extra = |
395 | 474 | (* Default value container *) |
396 | 475 | let v = |
397 | 476 | ref None |
398 | 477 | in |
399 | ||
478 | ||
400 | 479 | (* If name is not given, create unique one *) |
401 | 480 | let nm = |
402 | 481 | match name with |
403 | 482 | | Some s -> s |
404 | 483 | | None -> Printf.sprintf "_anon_%d" (new_id ()) |
405 | 484 | in |
406 | ||
485 | ||
407 | 486 | (* Last chance to get a value: the default *) |
408 | 487 | let default () = |
409 | 488 | match default with |
410 | 489 | | Some d -> d |
411 | 490 | | None -> raise (Not_set (nm, Some (s_ "no default value"))) |
412 | 491 | in |
413 | ||
492 | ||
414 | 493 | (* Get data *) |
415 | 494 | let get data = |
416 | 495 | (* Get value *) |
422 | 501 | with Not_found -> |
423 | 502 | default () |
424 | 503 | in |
425 | ||
504 | ||
426 | 505 | (* Set data *) |
427 | 506 | let set data ?context x = |
428 | 507 | let x = |
442 | 521 | nm |
443 | 522 | (fun () -> v := Some x) |
444 | 523 | in |
445 | ||
524 | ||
446 | 525 | (* Parse string value, if possible *) |
447 | 526 | let parse = |
448 | 527 | match parse with |
456 | 535 | nm |
457 | 536 | s) |
458 | 537 | in |
459 | ||
538 | ||
460 | 539 | (* Set data, from string *) |
461 | 540 | let sets data ?context s = |
462 | 541 | set ?context data (parse ?context s) |
463 | 542 | in |
464 | ||
543 | ||
465 | 544 | (* Output value as string, if possible *) |
466 | 545 | let print = |
467 | 546 | match print with |
470 | 549 | | None -> |
471 | 550 | fun _ -> raise (No_printer nm) |
472 | 551 | in |
473 | ||
552 | ||
474 | 553 | (* Get data, as a string *) |
475 | 554 | let gets data = |
476 | 555 | print (get data) |
477 | 556 | in |
478 | ||
557 | ||
479 | 558 | begin |
480 | 559 | match schema with |
481 | 560 | | Some t -> |
483 | 562 | | None -> |
484 | 563 | () |
485 | 564 | end; |
486 | ||
565 | ||
487 | 566 | { |
488 | 567 | set = set; |
489 | 568 | get = get; |
492 | 571 | help = help; |
493 | 572 | extra = extra; |
494 | 573 | } |
495 | ||
574 | ||
496 | 575 | let fset data t ?context x = |
497 | 576 | t.set data ?context x |
498 | ||
577 | ||
499 | 578 | let fget data t = |
500 | 579 | t.get data |
501 | ||
580 | ||
502 | 581 | let fsets data t ?context s = |
503 | 582 | t.sets data ?context s |
504 | ||
583 | ||
505 | 584 | let fgets data t = |
506 | 585 | t.gets data |
507 | ||
586 | ||
508 | 587 | end |
509 | ||
588 | ||
510 | 589 | module FieldRO = |
511 | 590 | struct |
512 | ||
591 | ||
513 | 592 | let create ?schema ?name ?parse ?print ?default ?update ?help extra = |
514 | 593 | let fld = |
515 | 594 | Field.create ?schema ?name ?parse ?print ?default ?update ?help extra |
516 | 595 | in |
517 | 596 | fun data -> Field.fget data fld |
518 | ||
597 | ||
519 | 598 | end |
520 | 599 | end |
521 | 600 | |
522 | 601 | module OASISMessage = struct |
523 | # 21 "/home/dim/sources/oasis/src/oasis/OASISMessage.ml" | |
524 | ||
525 | ||
602 | (* # 21 "/mnt/local/sda1/jdimino/dot-opam/4.01.0dev+short-paths/build/oasis.0.3.0/src/oasis/OASISMessage.ml" *) | |
603 | ||
604 | ||
526 | 605 | open OASISGettext |
527 | 606 | open OASISContext |
528 | ||
607 | ||
529 | 608 | let generic_message ~ctxt lvl fmt = |
530 | 609 | let cond = |
531 | match lvl with | |
532 | | `Debug -> ctxt.debug | |
533 | | _ -> ctxt.verbose | |
610 | if ctxt.quiet then | |
611 | false | |
612 | else | |
613 | match lvl with | |
614 | | `Debug -> ctxt.debug | |
615 | | `Info -> ctxt.info | |
616 | | _ -> true | |
534 | 617 | in |
535 | 618 | Printf.ksprintf |
536 | 619 | (fun str -> |
539 | 622 | ctxt.printf lvl str |
540 | 623 | end) |
541 | 624 | fmt |
542 | ||
625 | ||
543 | 626 | let debug ~ctxt fmt = |
544 | 627 | generic_message ~ctxt `Debug fmt |
545 | ||
628 | ||
546 | 629 | let info ~ctxt fmt = |
547 | 630 | generic_message ~ctxt `Info fmt |
548 | ||
631 | ||
549 | 632 | let warning ~ctxt fmt = |
550 | 633 | generic_message ~ctxt `Warning fmt |
551 | ||
634 | ||
552 | 635 | let error ~ctxt fmt = |
553 | 636 | generic_message ~ctxt `Error fmt |
554 | ||
555 | ||
556 | let string_of_exception e = | |
557 | try | |
558 | PropList.string_of_exception e | |
559 | with | |
560 | | Failure s -> | |
561 | s | |
562 | | e -> | |
563 | Printexc.to_string e | |
564 | ||
565 | (* TODO | |
566 | let register_exn_printer f = | |
567 | *) | |
568 | ||
637 | ||
569 | 638 | end |
570 | 639 | |
571 | 640 | module OASISVersion = struct |
572 | # 21 "/home/dim/sources/oasis/src/oasis/OASISVersion.ml" | |
573 | ||
641 | (* # 21 "/mnt/local/sda1/jdimino/dot-opam/4.01.0dev+short-paths/build/oasis.0.3.0/src/oasis/OASISVersion.ml" *) | |
642 | ||
574 | 643 | open OASISGettext |
575 | ||
576 | ||
577 | ||
644 | ||
645 | ||
646 | ||
578 | 647 | type s = string |
579 | ||
648 | ||
580 | 649 | type t = string |
581 | ||
650 | ||
582 | 651 | type comparator = |
583 | 652 | | VGreater of t |
584 | 653 | | VGreaterEqual of t |
588 | 657 | | VOr of comparator * comparator |
589 | 658 | | VAnd of comparator * comparator |
590 | 659 | |
591 | ||
660 | ||
592 | 661 | (* Range of allowed characters *) |
593 | 662 | let is_digit c = |
594 | 663 | '0' <= c && c <= '9' |
595 | ||
664 | ||
596 | 665 | let is_alpha c = |
597 | 666 | ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z') |
598 | ||
667 | ||
599 | 668 | let is_special = |
600 | 669 | function |
601 | 670 | | '.' | '+' | '-' | '~' -> true |
602 | 671 | | _ -> false |
603 | ||
672 | ||
604 | 673 | let rec version_compare v1 v2 = |
605 | 674 | if v1 <> "" || v2 <> "" then |
606 | 675 | begin |
614 | 683 | else if is_alpha c then Char.code c |
615 | 684 | else (Char.code c) + 256 |
616 | 685 | in |
617 | ||
686 | ||
618 | 687 | let len1 = String.length v1 in |
619 | 688 | let len2 = String.length v2 in |
620 | ||
689 | ||
621 | 690 | let p = ref 0 in |
622 | ||
691 | ||
623 | 692 | (** Compare ascii part *) |
624 | 693 | let compare_vascii () = |
625 | 694 | let cmp = ref 0 in |
636 | 705 | else |
637 | 706 | !cmp |
638 | 707 | in |
639 | ||
708 | ||
640 | 709 | (** Compare digit part *) |
641 | 710 | let compare_digit () = |
642 | 711 | let extract_int v p = |
658 | 727 | let i2, tl2 = extract_int v2 (ref !p) in |
659 | 728 | i1 - i2, tl1, tl2 |
660 | 729 | in |
661 | ||
730 | ||
662 | 731 | match compare_vascii () with |
663 | 732 | | 0 -> |
664 | 733 | begin |
680 | 749 | begin |
681 | 750 | 0 |
682 | 751 | end |
683 | ||
684 | ||
685 | let version_of_string str = | |
686 | String.iter | |
687 | (fun c -> | |
688 | if is_alpha c || is_digit c || is_special c then | |
689 | () | |
690 | else | |
691 | failwith | |
692 | (Printf.sprintf | |
693 | (f_ "Char %C is not allowed in version '%s'") | |
694 | c str)) | |
695 | str; | |
696 | str | |
697 | ||
698 | let string_of_version t = | |
699 | t | |
700 | ||
752 | ||
753 | ||
754 | let version_of_string str = str | |
755 | ||
756 | let string_of_version t = t | |
757 | ||
701 | 758 | let chop t = |
702 | 759 | try |
703 | 760 | let pos = |
706 | 763 | String.sub t 0 pos |
707 | 764 | with Not_found -> |
708 | 765 | t |
709 | ||
766 | ||
710 | 767 | let rec comparator_apply v op = |
711 | 768 | match op with |
712 | 769 | | VGreater cv -> |
723 | 780 | (comparator_apply v op1) || (comparator_apply v op2) |
724 | 781 | | VAnd (op1, op2) -> |
725 | 782 | (comparator_apply v op1) && (comparator_apply v op2) |
726 | ||
783 | ||
727 | 784 | let rec string_of_comparator = |
728 | 785 | function |
729 | 786 | | VGreater v -> "> "^(string_of_version v) |
735 | 792 | (string_of_comparator c1)^" || "^(string_of_comparator c2) |
736 | 793 | | VAnd (c1, c2) -> |
737 | 794 | (string_of_comparator c1)^" && "^(string_of_comparator c2) |
738 | ||
795 | ||
739 | 796 | let rec varname_of_comparator = |
740 | 797 | let concat p v = |
741 | 798 | OASISUtils.varname_concat |
753 | 810 | (varname_of_comparator c1)^"_or_"^(varname_of_comparator c2) |
754 | 811 | | VAnd (c1, c2) -> |
755 | 812 | (varname_of_comparator c1)^"_and_"^(varname_of_comparator c2) |
756 | ||
813 | ||
814 | let version_0_3_or_after t = | |
815 | comparator_apply t (VGreaterEqual (string_of_version "0.3")) | |
816 | ||
757 | 817 | end |
758 | 818 | |
759 | 819 | module OASISLicense = struct |
760 | # 21 "/home/dim/sources/oasis/src/oasis/OASISLicense.ml" | |
761 | ||
820 | (* # 21 "/mnt/local/sda1/jdimino/dot-opam/4.01.0dev+short-paths/build/oasis.0.3.0/src/oasis/OASISLicense.ml" *) | |
821 | ||
762 | 822 | (** License for _oasis fields |
763 | 823 | @author Sylvain Le Gall |
764 | 824 | *) |
765 | ||
766 | ||
767 | ||
825 | ||
826 | ||
827 | ||
768 | 828 | type license = string |
769 | ||
829 | ||
770 | 830 | type license_exception = string |
771 | ||
831 | ||
772 | 832 | type license_version = |
773 | 833 | | Version of OASISVersion.t |
774 | 834 | | VersionOrLater of OASISVersion.t |
775 | 835 | | NoVersion |
776 | 836 | |
777 | ||
837 | ||
838 | type license_dep_5_unit = | |
839 | { | |
840 | license: license; | |
841 | excption: license_exception option; | |
842 | version: license_version; | |
843 | } | |
844 | ||
845 | ||
778 | 846 | type license_dep_5 = |
779 | { | |
780 | license: license; | |
781 | exceptions: license_exception list; | |
782 | version: license_version; | |
783 | } | |
784 | ||
847 | | DEP5Unit of license_dep_5_unit | |
848 | | DEP5Or of license_dep_5 list | |
849 | | DEP5And of license_dep_5 list | |
850 | ||
851 | ||
785 | 852 | type t = |
786 | 853 | | DEP5License of license_dep_5 |
787 | 854 | | OtherLicense of string (* URL *) |
788 | 855 | |
789 | ||
856 | ||
790 | 857 | end |
791 | 858 | |
792 | 859 | module OASISExpr = struct |
793 | # 21 "/home/dim/sources/oasis/src/oasis/OASISExpr.ml" | |
794 | ||
795 | ||
796 | ||
860 | (* # 21 "/mnt/local/sda1/jdimino/dot-opam/4.01.0dev+short-paths/build/oasis.0.3.0/src/oasis/OASISExpr.ml" *) | |
861 | ||
862 | ||
863 | ||
797 | 864 | open OASISGettext |
798 | ||
865 | ||
799 | 866 | type test = string |
800 | ||
867 | ||
801 | 868 | type flag = string |
802 | ||
869 | ||
803 | 870 | type t = |
804 | 871 | | EBool of bool |
805 | 872 | | ENot of t |
808 | 875 | | EFlag of flag |
809 | 876 | | ETest of test * string |
810 | 877 | |
811 | ||
878 | ||
812 | 879 | type 'a choices = (t * 'a) list |
813 | ||
880 | ||
814 | 881 | let eval var_get t = |
815 | 882 | let rec eval' = |
816 | 883 | function |
817 | 884 | | EBool b -> |
818 | 885 | b |
819 | ||
886 | ||
820 | 887 | | ENot e -> |
821 | 888 | not (eval' e) |
822 | ||
889 | ||
823 | 890 | | EAnd (e1, e2) -> |
824 | 891 | (eval' e1) && (eval' e2) |
825 | ||
892 | ||
826 | 893 | | EOr (e1, e2) -> |
827 | 894 | (eval' e1) || (eval' e2) |
828 | ||
895 | ||
829 | 896 | | EFlag nm -> |
830 | 897 | let v = |
831 | 898 | var_get nm |
832 | 899 | in |
833 | 900 | assert(v = "true" || v = "false"); |
834 | 901 | (v = "true") |
835 | ||
902 | ||
836 | 903 | | ETest (nm, vl) -> |
837 | 904 | let v = |
838 | 905 | var_get nm |
840 | 907 | (v = vl) |
841 | 908 | in |
842 | 909 | eval' t |
843 | ||
910 | ||
844 | 911 | let choose ?printer ?name var_get lst = |
845 | 912 | let rec choose_aux = |
846 | 913 | function |
876 | 943 | str_lst) |
877 | 944 | in |
878 | 945 | choose_aux (List.rev lst) |
879 | ||
946 | ||
880 | 947 | end |
881 | 948 | |
882 | 949 | module OASISTypes = struct |
883 | # 21 "/home/dim/sources/oasis/src/oasis/OASISTypes.ml" | |
884 | ||
885 | ||
886 | ||
887 | ||
950 | (* # 21 "/mnt/local/sda1/jdimino/dot-opam/4.01.0dev+short-paths/build/oasis.0.3.0/src/oasis/OASISTypes.ml" *) | |
951 | ||
952 | ||
953 | ||
954 | ||
888 | 955 | type name = string |
889 | 956 | type package_name = string |
890 | 957 | type url = string |
896 | 963 | type arg = string |
897 | 964 | type args = string list |
898 | 965 | type command_line = (prog * arg list) |
899 | ||
966 | ||
900 | 967 | type findlib_name = string |
901 | 968 | type findlib_full = string |
902 | ||
969 | ||
903 | 970 | type compiled_object = |
904 | 971 | | Byte |
905 | 972 | | Native |
906 | 973 | | Best |
907 | 974 | |
908 | ||
975 | ||
909 | 976 | type dependency = |
910 | 977 | | FindlibPackage of findlib_full * OASISVersion.comparator option |
911 | 978 | | InternalLibrary of name |
912 | 979 | |
913 | ||
980 | ||
914 | 981 | type tool = |
915 | 982 | | ExternalTool of name |
916 | 983 | | InternalExecutable of name |
917 | 984 | |
918 | ||
985 | ||
919 | 986 | type vcs = |
920 | 987 | | Darcs |
921 | 988 | | Git |
927 | 994 | | Monotone |
928 | 995 | | OtherVCS of url |
929 | 996 | |
930 | ||
997 | ||
931 | 998 | type plugin_kind = |
932 | 999 | [ `Configure |
933 | 1000 | | `Build |
936 | 1003 | | `Install |
937 | 1004 | | `Extra |
938 | 1005 | ] |
939 | ||
1006 | ||
940 | 1007 | type plugin_data_purpose = |
941 | 1008 | [ `Configure |
942 | 1009 | | `Build |
950 | 1017 | | `Extra |
951 | 1018 | | `Other of string |
952 | 1019 | ] |
953 | ||
1020 | ||
954 | 1021 | type 'a plugin = 'a * name * OASISVersion.t option |
955 | ||
1022 | ||
956 | 1023 | type all_plugin = plugin_kind plugin |
957 | ||
1024 | ||
958 | 1025 | type plugin_data = (all_plugin * plugin_data_purpose * (unit -> unit)) list |
959 | ||
960 | # 102 "/home/dim/sources/oasis/src/oasis/OASISTypes.ml" | |
961 | ||
1026 | ||
1027 | (* # 102 "/mnt/local/sda1/jdimino/dot-opam/4.01.0dev+short-paths/build/oasis.0.3.0/src/oasis/OASISTypes.ml" *) | |
1028 | ||
962 | 1029 | type 'a conditional = 'a OASISExpr.choices |
963 | ||
1030 | ||
964 | 1031 | type custom = |
965 | 1032 | { |
966 | 1033 | pre_command: (command_line option) conditional; |
967 | 1034 | post_command: (command_line option) conditional; |
968 | 1035 | } |
969 | 1036 | |
970 | ||
1037 | ||
971 | 1038 | type common_section = |
972 | 1039 | { |
973 | 1040 | cs_name: name; |
975 | 1042 | cs_plugin_data: plugin_data; |
976 | 1043 | } |
977 | 1044 | |
978 | ||
1045 | ||
979 | 1046 | type build_section = |
980 | 1047 | { |
981 | 1048 | bs_build: bool conditional; |
994 | 1061 | bs_nativeopt: args conditional; |
995 | 1062 | } |
996 | 1063 | |
997 | ||
1064 | ||
998 | 1065 | type library = |
999 | 1066 | { |
1000 | 1067 | lib_modules: string list; |
1068 | lib_pack: bool; | |
1001 | 1069 | lib_internal_modules: string list; |
1002 | 1070 | lib_findlib_parent: findlib_name option; |
1003 | 1071 | lib_findlib_name: findlib_name option; |
1004 | 1072 | lib_findlib_containers: findlib_name list; |
1005 | 1073 | } |
1006 | ||
1074 | ||
1007 | 1075 | type executable = |
1008 | 1076 | { |
1009 | 1077 | exec_custom: bool; |
1010 | 1078 | exec_main_is: unix_filename; |
1011 | 1079 | } |
1012 | ||
1080 | ||
1013 | 1081 | type flag = |
1014 | 1082 | { |
1015 | 1083 | flag_description: string option; |
1016 | 1084 | flag_default: bool conditional; |
1017 | 1085 | } |
1018 | ||
1086 | ||
1019 | 1087 | type source_repository = |
1020 | 1088 | { |
1021 | 1089 | src_repo_type: vcs; |
1026 | 1094 | src_repo_tag: string option; |
1027 | 1095 | src_repo_subdir: unix_filename option; |
1028 | 1096 | } |
1029 | ||
1097 | ||
1030 | 1098 | type test = |
1031 | 1099 | { |
1032 | 1100 | test_type: [`Test] plugin; |
1036 | 1104 | test_run: bool conditional; |
1037 | 1105 | test_tools: tool list; |
1038 | 1106 | } |
1039 | ||
1107 | ||
1040 | 1108 | type doc_format = |
1041 | 1109 | | HTML of unix_filename |
1042 | 1110 | | DocText |
1046 | 1114 | | DVI |
1047 | 1115 | | OtherDoc |
1048 | 1116 | |
1049 | ||
1117 | ||
1050 | 1118 | type doc = |
1051 | 1119 | { |
1052 | 1120 | doc_type: [`Doc] plugin; |
1061 | 1129 | doc_data_files: (unix_filename * unix_filename option) list; |
1062 | 1130 | doc_build_tools: tool list; |
1063 | 1131 | } |
1064 | ||
1132 | ||
1065 | 1133 | type section = |
1066 | 1134 | | Library of common_section * build_section * library |
1067 | 1135 | | Executable of common_section * build_section * executable |
1070 | 1138 | | Test of common_section * test |
1071 | 1139 | | Doc of common_section * doc |
1072 | 1140 | |
1073 | ||
1141 | ||
1074 | 1142 | type section_kind = |
1075 | 1143 | [ `Library | `Executable | `Flag | `SrcRepo | `Test | `Doc ] |
1076 | ||
1144 | ||
1077 | 1145 | type package = |
1078 | 1146 | { |
1079 | 1147 | oasis_version: OASISVersion.t; |
1090 | 1158 | synopsis: string; |
1091 | 1159 | description: string option; |
1092 | 1160 | categories: url list; |
1093 | ||
1161 | ||
1094 | 1162 | conf_type: [`Configure] plugin; |
1095 | 1163 | conf_custom: custom; |
1096 | ||
1164 | ||
1097 | 1165 | build_type: [`Build] plugin; |
1098 | 1166 | build_custom: custom; |
1099 | ||
1167 | ||
1100 | 1168 | install_type: [`Install] plugin; |
1101 | 1169 | install_custom: custom; |
1102 | 1170 | uninstall_custom: custom; |
1103 | ||
1171 | ||
1104 | 1172 | clean_custom: custom; |
1105 | 1173 | distclean_custom: custom; |
1106 | ||
1174 | ||
1107 | 1175 | files_ab: unix_filename list; |
1108 | 1176 | sections: section list; |
1109 | 1177 | plugins: [`Extra] plugin list; |
1110 | 1178 | schema_data: PropList.Data.t; |
1111 | 1179 | plugin_data: plugin_data; |
1112 | 1180 | } |
1113 | ||
1181 | ||
1114 | 1182 | end |
1115 | 1183 | |
1116 | 1184 | module OASISUnixPath = struct |
1117 | # 21 "/home/dim/sources/oasis/src/oasis/OASISUnixPath.ml" | |
1118 | ||
1185 | (* # 21 "/mnt/local/sda1/jdimino/dot-opam/4.01.0dev+short-paths/build/oasis.0.3.0/src/oasis/OASISUnixPath.ml" *) | |
1186 | ||
1119 | 1187 | type unix_filename = string |
1120 | 1188 | type unix_dirname = string |
1121 | ||
1189 | ||
1122 | 1190 | type host_filename = string |
1123 | 1191 | type host_dirname = string |
1124 | ||
1192 | ||
1125 | 1193 | let current_dir_name = "." |
1126 | ||
1194 | ||
1127 | 1195 | let parent_dir_name = ".." |
1128 | ||
1196 | ||
1197 | let is_current_dir fn = | |
1198 | fn = current_dir_name || fn = "" | |
1199 | ||
1129 | 1200 | let concat f1 f2 = |
1130 | if f1 = current_dir_name then | |
1201 | if is_current_dir f1 then | |
1131 | 1202 | f2 |
1132 | else if f2 = current_dir_name then | |
1133 | f1 | |
1134 | 1203 | else |
1135 | f1^"/"^f2 | |
1136 | ||
1204 | let f1' = | |
1205 | try OASISString.strip_ends_with ~what:"/" f1 with Not_found -> f1 | |
1206 | in | |
1207 | f1'^"/"^f2 | |
1208 | ||
1137 | 1209 | let make = |
1138 | 1210 | function |
1139 | 1211 | | hd :: tl -> |
1143 | 1215 | tl |
1144 | 1216 | | [] -> |
1145 | 1217 | invalid_arg "OASISUnixPath.make" |
1146 | ||
1218 | ||
1147 | 1219 | let dirname f = |
1148 | 1220 | try |
1149 | 1221 | String.sub f 0 (String.rindex f '/') |
1150 | 1222 | with Not_found -> |
1151 | 1223 | current_dir_name |
1152 | ||
1224 | ||
1153 | 1225 | let basename f = |
1154 | 1226 | try |
1155 | 1227 | let pos_start = |
1158 | 1230 | String.sub f pos_start ((String.length f) - pos_start) |
1159 | 1231 | with Not_found -> |
1160 | 1232 | f |
1161 | ||
1233 | ||
1162 | 1234 | let chop_extension f = |
1163 | 1235 | try |
1164 | 1236 | let last_dot = |
1177 | 1249 | f |
1178 | 1250 | with Not_found -> |
1179 | 1251 | sub |
1180 | ||
1252 | ||
1181 | 1253 | with Not_found -> |
1182 | 1254 | f |
1183 | ||
1255 | ||
1184 | 1256 | let capitalize_file f = |
1185 | 1257 | let dir = dirname f in |
1186 | 1258 | let base = basename f in |
1187 | 1259 | concat dir (String.capitalize base) |
1188 | ||
1260 | ||
1189 | 1261 | let uncapitalize_file f = |
1190 | 1262 | let dir = dirname f in |
1191 | 1263 | let base = basename f in |
1192 | 1264 | concat dir (String.uncapitalize base) |
1265 | ||
1193 | 1266 | end |
1194 | 1267 | |
1268 | module OASISHostPath = struct | |
1269 | (* # 21 "/mnt/local/sda1/jdimino/dot-opam/4.01.0dev+short-paths/build/oasis.0.3.0/src/oasis/OASISHostPath.ml" *) | |
1270 | ||
1271 | ||
1272 | open Filename | |
1273 | ||
1274 | module Unix = OASISUnixPath | |
1275 | ||
1276 | let make = | |
1277 | function | |
1278 | | [] -> | |
1279 | invalid_arg "OASISHostPath.make" | |
1280 | | hd :: tl -> | |
1281 | List.fold_left Filename.concat hd tl | |
1282 | ||
1283 | let of_unix ufn = | |
1284 | if Sys.os_type = "Unix" then | |
1285 | ufn | |
1286 | else | |
1287 | make | |
1288 | (List.map | |
1289 | (fun p -> | |
1290 | if p = Unix.current_dir_name then | |
1291 | current_dir_name | |
1292 | else if p = Unix.parent_dir_name then | |
1293 | parent_dir_name | |
1294 | else | |
1295 | p) | |
1296 | (OASISString.nsplit ufn '/')) | |
1297 | ||
1298 | ||
1299 | end | |
1300 | ||
1195 | 1301 | module OASISSection = struct |
1196 | # 1 "/home/dim/sources/oasis/src/oasis/OASISSection.ml" | |
1302 | (* # 21 "/mnt/local/sda1/jdimino/dot-opam/4.01.0dev+short-paths/build/oasis.0.3.0/src/oasis/OASISSection.ml" *) | |
1303 | ||
1197 | 1304 | open OASISTypes |
1198 | ||
1305 | ||
1199 | 1306 | let section_kind_common = |
1200 | 1307 | function |
1201 | 1308 | | Library (cs, _, _) -> |
1210 | 1317 | `Test, cs |
1211 | 1318 | | Doc (cs, _) -> |
1212 | 1319 | `Doc, cs |
1213 | ||
1320 | ||
1214 | 1321 | let section_common sct = |
1215 | 1322 | snd (section_kind_common sct) |
1216 | ||
1323 | ||
1217 | 1324 | let section_common_set cs = |
1218 | 1325 | function |
1219 | 1326 | | Library (_, bs, lib) -> Library (cs, bs, lib) |
1222 | 1329 | | SrcRepo (_, src_repo) -> SrcRepo (cs, src_repo) |
1223 | 1330 | | Test (_, tst) -> Test (cs, tst) |
1224 | 1331 | | Doc (_, doc) -> Doc (cs, doc) |
1225 | ||
1332 | ||
1226 | 1333 | (** Key used to identify section |
1227 | 1334 | *) |
1228 | 1335 | let section_id sct = |
1230 | 1337 | section_kind_common sct |
1231 | 1338 | in |
1232 | 1339 | k, cs.cs_name |
1233 | ||
1340 | ||
1234 | 1341 | let string_of_section sct = |
1235 | 1342 | let k, nm = |
1236 | 1343 | section_id sct |
1243 | 1350 | | `Test -> "test" |
1244 | 1351 | | `Doc -> "doc") |
1245 | 1352 | ^" "^nm |
1246 | ||
1353 | ||
1354 | let section_find id scts = | |
1355 | List.find | |
1356 | (fun sct -> id = section_id sct) | |
1357 | scts | |
1358 | ||
1359 | module CSection = | |
1360 | struct | |
1361 | type t = section | |
1362 | ||
1363 | let id = section_id | |
1364 | ||
1365 | let compare t1 t2 = | |
1366 | compare (id t1) (id t2) | |
1367 | ||
1368 | let equal t1 t2 = | |
1369 | (id t1) = (id t2) | |
1370 | ||
1371 | let hash t = | |
1372 | Hashtbl.hash (id t) | |
1373 | end | |
1374 | ||
1375 | module MapSection = Map.Make(CSection) | |
1376 | module SetSection = Set.Make(CSection) | |
1377 | ||
1247 | 1378 | end |
1248 | 1379 | |
1249 | 1380 | module OASISBuildSection = struct |
1250 | # 21 "/home/dim/sources/oasis/src/oasis/OASISBuildSection.ml" | |
1251 | ||
1381 | (* # 21 "/mnt/local/sda1/jdimino/dot-opam/4.01.0dev+short-paths/build/oasis.0.3.0/src/oasis/OASISBuildSection.ml" *) | |
1382 | ||
1252 | 1383 | end |
1253 | 1384 | |
1254 | 1385 | module OASISExecutable = struct |
1255 | # 21 "/home/dim/sources/oasis/src/oasis/OASISExecutable.ml" | |
1256 | ||
1386 | (* # 21 "/mnt/local/sda1/jdimino/dot-opam/4.01.0dev+short-paths/build/oasis.0.3.0/src/oasis/OASISExecutable.ml" *) | |
1387 | ||
1257 | 1388 | open OASISTypes |
1258 | ||
1389 | ||
1259 | 1390 | let unix_exec_is (cs, bs, exec) is_native ext_dll suffix_program = |
1260 | 1391 | let dir = |
1261 | 1392 | OASISUnixPath.concat |
1268 | 1399 | | Best -> is_native () |
1269 | 1400 | | Byte -> false |
1270 | 1401 | in |
1271 | ||
1402 | ||
1272 | 1403 | OASISUnixPath.concat |
1273 | 1404 | dir |
1274 | 1405 | (cs.cs_name^(suffix_program ())), |
1275 | ||
1406 | ||
1276 | 1407 | if not is_native_exec && |
1277 | 1408 | not exec.exec_custom && |
1278 | 1409 | bs.bs_c_sources <> [] then |
1279 | Some (dir^"/dll"^cs.cs_name^(ext_dll ())) | |
1410 | Some (dir^"/dll"^cs.cs_name^"_stubs"^(ext_dll ())) | |
1280 | 1411 | else |
1281 | 1412 | None |
1282 | ||
1413 | ||
1283 | 1414 | end |
1284 | 1415 | |
1285 | 1416 | module OASISLibrary = struct |
1286 | # 21 "/home/dim/sources/oasis/src/oasis/OASISLibrary.ml" | |
1287 | ||
1417 | (* # 21 "/mnt/local/sda1/jdimino/dot-opam/4.01.0dev+short-paths/build/oasis.0.3.0/src/oasis/OASISLibrary.ml" *) | |
1418 | ||
1288 | 1419 | open OASISTypes |
1289 | 1420 | open OASISUtils |
1290 | 1421 | open OASISGettext |
1291 | ||
1422 | open OASISSection | |
1423 | ||
1292 | 1424 | type library_name = name |
1293 | ||
1294 | let generated_unix_files ~ctxt (cs, bs, lib) | |
1295 | source_file_exists is_native ext_lib ext_dll = | |
1425 | type findlib_part_name = name | |
1426 | type 'a map_of_findlib_part_name = 'a OASISUtils.MapString.t | |
1427 | ||
1428 | exception InternalLibraryNotFound of library_name | |
1429 | exception FindlibPackageNotFound of findlib_name | |
1430 | ||
1431 | type group_t = | |
1432 | | Container of findlib_name * group_t list | |
1433 | | Package of (findlib_name * | |
1434 | common_section * | |
1435 | build_section * | |
1436 | library * | |
1437 | group_t list) | |
1438 | ||
1439 | (* Look for a module file, considering capitalization or not. *) | |
1440 | let find_module source_file_exists (cs, bs, lib) modul = | |
1441 | let possible_base_fn = | |
1442 | List.map | |
1443 | (OASISUnixPath.concat bs.bs_path) | |
1444 | [modul; | |
1445 | OASISUnixPath.uncapitalize_file modul; | |
1446 | OASISUnixPath.capitalize_file modul] | |
1447 | in | |
1448 | (* TODO: we should be able to be able to determine the source for every | |
1449 | * files. Hence we should introduce a Module(source: fn) for the fields | |
1450 | * Modules and InternalModules | |
1451 | *) | |
1452 | List.fold_left | |
1453 | (fun acc base_fn -> | |
1454 | match acc with | |
1455 | | `No_sources _ -> | |
1456 | begin | |
1457 | let file_found = | |
1458 | List.fold_left | |
1459 | (fun acc ext -> | |
1460 | if source_file_exists (base_fn^ext) then | |
1461 | (base_fn^ext) :: acc | |
1462 | else | |
1463 | acc) | |
1464 | [] | |
1465 | [".ml"; ".mli"; ".mll"; ".mly"] | |
1466 | in | |
1467 | match file_found with | |
1468 | | [] -> | |
1469 | acc | |
1470 | | lst -> | |
1471 | `Sources (base_fn, lst) | |
1472 | end | |
1473 | | `Sources _ -> | |
1474 | acc) | |
1475 | (`No_sources possible_base_fn) | |
1476 | possible_base_fn | |
1477 | ||
1478 | let source_unix_files ~ctxt (cs, bs, lib) source_file_exists = | |
1479 | List.fold_left | |
1480 | (fun acc modul -> | |
1481 | match find_module source_file_exists (cs, bs, lib) modul with | |
1482 | | `Sources (base_fn, lst) -> | |
1483 | (base_fn, lst) :: acc | |
1484 | | `No_sources _ -> | |
1485 | OASISMessage.warning | |
1486 | ~ctxt | |
1487 | (f_ "Cannot find source file matching \ | |
1488 | module '%s' in library %s") | |
1489 | modul cs.cs_name; | |
1490 | acc) | |
1491 | [] | |
1492 | (lib.lib_modules @ lib.lib_internal_modules) | |
1493 | ||
1494 | let generated_unix_files | |
1495 | ~ctxt | |
1496 | ~is_native | |
1497 | ~has_native_dynlink | |
1498 | ~ext_lib | |
1499 | ~ext_dll | |
1500 | ~source_file_exists | |
1501 | (cs, bs, lib) = | |
1502 | ||
1503 | let find_modules lst ext = | |
1504 | let find_module modul = | |
1505 | match find_module source_file_exists (cs, bs, lib) modul with | |
1506 | | `Sources (base_fn, _) -> | |
1507 | [base_fn] | |
1508 | | `No_sources lst -> | |
1509 | OASISMessage.warning | |
1510 | ~ctxt | |
1511 | (f_ "Cannot find source file matching \ | |
1512 | module '%s' in library %s") | |
1513 | modul cs.cs_name; | |
1514 | lst | |
1515 | in | |
1516 | List.map | |
1517 | (fun nm -> | |
1518 | List.map | |
1519 | (fun base_fn -> base_fn ^"."^ext) | |
1520 | (find_module nm)) | |
1521 | lst | |
1522 | in | |
1523 | ||
1296 | 1524 | (* The headers that should be compiled along *) |
1297 | 1525 | let headers = |
1298 | List.fold_left | |
1299 | (fun hdrs modul -> | |
1300 | try | |
1301 | let base_fn = | |
1302 | List.find | |
1303 | (fun fn -> | |
1304 | source_file_exists (fn^".ml") || | |
1305 | source_file_exists (fn^".mli") || | |
1306 | source_file_exists (fn^".mll") || | |
1307 | source_file_exists (fn^".mly")) | |
1308 | (List.map | |
1309 | (OASISUnixPath.concat bs.bs_path) | |
1310 | [modul; | |
1311 | OASISUnixPath.uncapitalize_file modul; | |
1312 | OASISUnixPath.capitalize_file modul]) | |
1313 | in | |
1314 | [base_fn^".cmi"] :: hdrs | |
1315 | with Not_found -> | |
1316 | OASISMessage.warning | |
1317 | ~ctxt | |
1318 | (f_ "Cannot find source file matching \ | |
1319 | module '%s' in library %s") | |
1320 | modul cs.cs_name; | |
1321 | (List.map (OASISUnixPath.concat bs.bs_path) | |
1322 | [modul^".cmi"; | |
1323 | OASISUnixPath.uncapitalize_file modul ^ ".cmi"; | |
1324 | OASISUnixPath.capitalize_file modul ^ ".cmi"]) | |
1325 | :: hdrs) | |
1526 | if lib.lib_pack then | |
1326 | 1527 | [] |
1327 | lib.lib_modules | |
1328 | in | |
1329 | ||
1528 | else | |
1529 | find_modules | |
1530 | lib.lib_modules | |
1531 | "cmi" | |
1532 | in | |
1533 | ||
1534 | (* The .cmx that be compiled along *) | |
1535 | let cmxs = | |
1536 | let should_be_built = | |
1537 | (not lib.lib_pack) && (* Do not install .cmx packed submodules *) | |
1538 | match bs.bs_compiled_object with | |
1539 | | Native -> true | |
1540 | | Best -> is_native | |
1541 | | Byte -> false | |
1542 | in | |
1543 | if should_be_built then | |
1544 | find_modules | |
1545 | (lib.lib_modules @ lib.lib_internal_modules) | |
1546 | "cmx" | |
1547 | else | |
1548 | [] | |
1549 | in | |
1550 | ||
1330 | 1551 | let acc_nopath = |
1331 | 1552 | [] |
1332 | 1553 | in |
1333 | ||
1554 | ||
1334 | 1555 | (* Compute what libraries should be built *) |
1335 | 1556 | let acc_nopath = |
1557 | (* Add the packed header file if required *) | |
1558 | let add_pack_header acc = | |
1559 | if lib.lib_pack then | |
1560 | [cs.cs_name^".cmi"] :: acc | |
1561 | else | |
1562 | acc | |
1563 | in | |
1336 | 1564 | let byte acc = |
1337 | [cs.cs_name^".cma"] :: acc | |
1565 | add_pack_header ([cs.cs_name^".cma"] :: acc) | |
1338 | 1566 | in |
1339 | 1567 | let native acc = |
1340 | [cs.cs_name^".cmxs"] :: [cs.cs_name^".cmxa"] :: [cs.cs_name^(ext_lib ())] :: acc | |
1568 | let acc = | |
1569 | add_pack_header | |
1570 | (if has_native_dynlink then | |
1571 | [cs.cs_name^".cmxs"] :: acc | |
1572 | else acc) | |
1573 | in | |
1574 | [cs.cs_name^".cmxa"] :: [cs.cs_name^ext_lib] :: acc | |
1341 | 1575 | in |
1342 | 1576 | match bs.bs_compiled_object with |
1343 | 1577 | | Native -> |
1344 | 1578 | byte (native acc_nopath) |
1345 | | Best when is_native () -> | |
1579 | | Best when is_native -> | |
1346 | 1580 | byte (native acc_nopath) |
1347 | 1581 | | Byte | Best -> |
1348 | 1582 | byte acc_nopath |
1349 | 1583 | in |
1350 | ||
1584 | ||
1351 | 1585 | (* Add C library to be built *) |
1352 | 1586 | let acc_nopath = |
1353 | 1587 | if bs.bs_c_sources <> [] then |
1354 | 1588 | begin |
1355 | ["lib"^cs.cs_name^(ext_lib ())] | |
1589 | ["lib"^cs.cs_name^"_stubs"^ext_lib] | |
1356 | 1590 | :: |
1357 | ["dll"^cs.cs_name^(ext_dll ())] | |
1591 | ["dll"^cs.cs_name^"_stubs"^ext_dll] | |
1358 | 1592 | :: |
1359 | 1593 | acc_nopath |
1360 | 1594 | end |
1361 | 1595 | else |
1362 | 1596 | acc_nopath |
1363 | 1597 | in |
1364 | ||
1598 | ||
1365 | 1599 | (* All the files generated *) |
1366 | 1600 | List.rev_append |
1367 | 1601 | (List.rev_map |
1368 | 1602 | (List.rev_map |
1369 | 1603 | (OASISUnixPath.concat bs.bs_path)) |
1370 | 1604 | acc_nopath) |
1371 | headers | |
1372 | ||
1373 | ||
1374 | type group_t = | |
1375 | | Container of findlib_name * (group_t list) | |
1376 | | Package of (findlib_name * | |
1377 | common_section * | |
1378 | build_section * | |
1379 | library * | |
1380 | (group_t list)) | |
1381 | ||
1382 | let group_libs pkg = | |
1383 | (** Associate a name with its children *) | |
1384 | let children = | |
1605 | (headers @ cmxs) | |
1606 | ||
1607 | type data = common_section * build_section * library | |
1608 | type tree = | |
1609 | | Node of (data option) * (tree MapString.t) | |
1610 | | Leaf of data | |
1611 | ||
1612 | let findlib_mapping pkg = | |
1613 | (* Map from library name to either full findlib name or parts + parent. *) | |
1614 | let fndlb_parts_of_lib_name = | |
1615 | let fndlb_parts cs lib = | |
1616 | let name = | |
1617 | match lib.lib_findlib_name with | |
1618 | | Some nm -> nm | |
1619 | | None -> cs.cs_name | |
1620 | in | |
1621 | let name = | |
1622 | String.concat "." (lib.lib_findlib_containers @ [name]) | |
1623 | in | |
1624 | name | |
1625 | in | |
1626 | List.fold_left | |
1627 | (fun mp -> | |
1628 | function | |
1629 | | Library (cs, _, lib) -> | |
1630 | begin | |
1631 | let lib_name = cs.cs_name in | |
1632 | let fndlb_parts = fndlb_parts cs lib in | |
1633 | if MapString.mem lib_name mp then | |
1634 | failwithf | |
1635 | (f_ "The library name '%s' is used more than once.") | |
1636 | lib_name; | |
1637 | match lib.lib_findlib_parent with | |
1638 | | Some lib_name_parent -> | |
1639 | MapString.add | |
1640 | lib_name | |
1641 | (`Unsolved (lib_name_parent, fndlb_parts)) | |
1642 | mp | |
1643 | | None -> | |
1644 | MapString.add | |
1645 | lib_name | |
1646 | (`Solved fndlb_parts) | |
1647 | mp | |
1648 | end | |
1649 | ||
1650 | | Executable _ | Test _ | Flag _ | SrcRepo _ | Doc _ -> | |
1651 | mp) | |
1652 | MapString.empty | |
1653 | pkg.sections | |
1654 | in | |
1655 | ||
1656 | (* Solve the above graph to be only library name to full findlib name. *) | |
1657 | let fndlb_name_of_lib_name = | |
1658 | let rec solve visited mp lib_name lib_name_child = | |
1659 | if SetString.mem lib_name visited then | |
1660 | failwithf | |
1661 | (f_ "Library '%s' is involved in a cycle \ | |
1662 | with regard to findlib naming.") | |
1663 | lib_name; | |
1664 | let visited = SetString.add lib_name visited in | |
1665 | try | |
1666 | match MapString.find lib_name mp with | |
1667 | | `Solved fndlb_nm -> | |
1668 | fndlb_nm, mp | |
1669 | | `Unsolved (lib_nm_parent, post_fndlb_nm) -> | |
1670 | let pre_fndlb_nm, mp = | |
1671 | solve visited mp lib_nm_parent lib_name | |
1672 | in | |
1673 | let fndlb_nm = pre_fndlb_nm^"."^post_fndlb_nm in | |
1674 | fndlb_nm, MapString.add lib_name (`Solved fndlb_nm) mp | |
1675 | with Not_found -> | |
1676 | failwithf | |
1677 | (f_ "Library '%s', which is defined as the findlib parent of \ | |
1678 | library '%s', doesn't exist.") | |
1679 | lib_name lib_name_child | |
1680 | in | |
1681 | let mp = | |
1682 | MapString.fold | |
1683 | (fun lib_name status mp -> | |
1684 | match status with | |
1685 | | `Solved _ -> | |
1686 | (* Solved initialy, no need to go further *) | |
1687 | mp | |
1688 | | `Unsolved _ -> | |
1689 | let _, mp = solve SetString.empty mp lib_name "<none>" in | |
1690 | mp) | |
1691 | fndlb_parts_of_lib_name | |
1692 | fndlb_parts_of_lib_name | |
1693 | in | |
1694 | MapString.map | |
1695 | (function | |
1696 | | `Solved fndlb_nm -> fndlb_nm | |
1697 | | `Unsolved _ -> assert false) | |
1698 | mp | |
1699 | in | |
1700 | ||
1701 | (* Convert an internal library name to a findlib name. *) | |
1702 | let findlib_name_of_library_name lib_nm = | |
1703 | try | |
1704 | MapString.find lib_nm fndlb_name_of_lib_name | |
1705 | with Not_found -> | |
1706 | raise (InternalLibraryNotFound lib_nm) | |
1707 | in | |
1708 | ||
1709 | (* Add a library to the tree. | |
1710 | *) | |
1711 | let add sct mp = | |
1712 | let fndlb_fullname = | |
1713 | let cs, _, _ = sct in | |
1714 | let lib_name = cs.cs_name in | |
1715 | findlib_name_of_library_name lib_name | |
1716 | in | |
1717 | let rec add_children nm_lst (children : tree MapString.t) = | |
1718 | match nm_lst with | |
1719 | | (hd :: tl) -> | |
1720 | begin | |
1721 | let node = | |
1722 | try | |
1723 | add_node tl (MapString.find hd children) | |
1724 | with Not_found -> | |
1725 | (* New node *) | |
1726 | new_node tl | |
1727 | in | |
1728 | MapString.add hd node children | |
1729 | end | |
1730 | | [] -> | |
1731 | (* Should not have a nameless library. *) | |
1732 | assert false | |
1733 | and add_node tl node = | |
1734 | if tl = [] then | |
1735 | begin | |
1736 | match node with | |
1737 | | Node (None, children) -> | |
1738 | Node (Some sct, children) | |
1739 | | Leaf (cs', _, _) | Node (Some (cs', _, _), _) -> | |
1740 | (* TODO: allow to merge Package, i.e. | |
1741 | * archive(byte) = "foo.cma foo_init.cmo" | |
1742 | *) | |
1743 | let cs, _, _ = sct in | |
1744 | failwithf | |
1745 | (f_ "Library '%s' and '%s' have the same findlib name '%s'") | |
1746 | cs.cs_name cs'.cs_name fndlb_fullname | |
1747 | end | |
1748 | else | |
1749 | begin | |
1750 | match node with | |
1751 | | Leaf data -> | |
1752 | Node (Some data, add_children tl MapString.empty) | |
1753 | | Node (data_opt, children) -> | |
1754 | Node (data_opt, add_children tl children) | |
1755 | end | |
1756 | and new_node = | |
1757 | function | |
1758 | | [] -> | |
1759 | Leaf sct | |
1760 | | hd :: tl -> | |
1761 | Node (None, MapString.add hd (new_node tl) MapString.empty) | |
1762 | in | |
1763 | add_children (OASISString.nsplit fndlb_fullname '.') mp | |
1764 | in | |
1765 | ||
1766 | let rec group_of_tree mp = | |
1767 | MapString.fold | |
1768 | (fun nm node acc -> | |
1769 | let cur = | |
1770 | match node with | |
1771 | | Node (Some (cs, bs, lib), children) -> | |
1772 | Package (nm, cs, bs, lib, group_of_tree children) | |
1773 | | Node (None, children) -> | |
1774 | Container (nm, group_of_tree children) | |
1775 | | Leaf (cs, bs, lib) -> | |
1776 | Package (nm, cs, bs, lib, []) | |
1777 | in | |
1778 | cur :: acc) | |
1779 | mp [] | |
1780 | in | |
1781 | ||
1782 | let group_mp = | |
1385 | 1783 | List.fold_left |
1386 | 1784 | (fun mp -> |
1387 | 1785 | function |
1388 | 1786 | | Library (cs, bs, lib) -> |
1389 | begin | |
1390 | match lib.lib_findlib_parent with | |
1391 | | Some p_nm -> | |
1392 | begin | |
1393 | let children = | |
1394 | try | |
1395 | MapString.find p_nm mp | |
1396 | with Not_found -> | |
1397 | [] | |
1398 | in | |
1399 | MapString.add p_nm ((cs, bs, lib) :: children) mp | |
1400 | end | |
1401 | | None -> | |
1402 | mp | |
1403 | end | |
1787 | add (cs, bs, lib) mp | |
1404 | 1788 | | _ -> |
1405 | 1789 | mp) |
1406 | 1790 | MapString.empty |
1407 | 1791 | pkg.sections |
1408 | 1792 | in |
1409 | ||
1410 | (* Compute findlib name of a single node *) | |
1411 | let findlib_name (cs, _, lib) = | |
1412 | match lib.lib_findlib_name with | |
1413 | | Some nm -> nm | |
1414 | | None -> cs.cs_name | |
1415 | in | |
1416 | ||
1417 | (** Build a package tree *) | |
1418 | let rec tree_of_library containers ((cs, bs, lib) as acc) = | |
1419 | match containers with | |
1420 | | hd :: tl -> | |
1421 | Container (hd, [tree_of_library tl acc]) | |
1422 | | [] -> | |
1423 | Package | |
1424 | (findlib_name acc, cs, bs, lib, | |
1425 | (try | |
1426 | List.rev_map | |
1427 | (fun ((_, _, child_lib) as child_acc) -> | |
1428 | tree_of_library | |
1429 | child_lib.lib_findlib_containers | |
1430 | child_acc) | |
1431 | (MapString.find cs.cs_name children) | |
1432 | with Not_found -> | |
1433 | [])) | |
1434 | in | |
1435 | ||
1436 | (** Merge containers with the same name *) | |
1437 | let rec merge_containers groups = | |
1438 | (* Collect packages and create the map "container name -> merged children" *) | |
1439 | let packages, containers = | |
1440 | List.fold_left | |
1441 | (fun (packages, containers) group -> | |
1442 | match group with | |
1443 | | Container(name, children) -> | |
1444 | let children' = | |
1445 | try | |
1446 | MapString.find name containers | |
1447 | with Not_found -> | |
1448 | [] | |
1449 | in | |
1450 | (packages, | |
1451 | MapString.add name (children' @ children) containers) | |
1452 | | Package(name, cs, bs, lib, children) -> | |
1453 | (Package(name, cs, bs, lib, merge_containers children) :: packages, | |
1454 | containers)) | |
1455 | ([], MapString.empty) | |
1456 | groups | |
1457 | in | |
1458 | (* Recreate the list of groups *) | |
1459 | packages @ | |
1460 | (MapString.fold | |
1461 | (fun name children acc -> | |
1462 | Container(name, merge_containers children) :: acc) | |
1463 | containers []) | |
1464 | in | |
1465 | ||
1466 | (* TODO: check that libraries are unique *) | |
1467 | merge_containers | |
1468 | (List.fold_left | |
1469 | (fun acc -> | |
1470 | function | |
1471 | | Library (cs, bs, lib) when lib.lib_findlib_parent = None -> | |
1472 | (tree_of_library lib.lib_findlib_containers (cs, bs, lib)) :: acc | |
1473 | | _ -> | |
1474 | acc) | |
1475 | [] | |
1476 | pkg.sections) | |
1477 | ||
1478 | (** Compute internal to findlib library matchings, including subpackage | |
1479 | and return a map of it. | |
1480 | *) | |
1481 | let findlib_name_map pkg = | |
1482 | ||
1483 | (* Compute names in a tree *) | |
1484 | let rec findlib_names_aux path mp grp = | |
1485 | let fndlb_nm, children, mp = | |
1486 | match grp with | |
1487 | | Container (fndlb_nm, children) -> | |
1488 | fndlb_nm, children, mp | |
1489 | ||
1490 | | Package (fndlb_nm, {cs_name = nm}, _, _, children) -> | |
1491 | fndlb_nm, children, (MapString.add nm (path, fndlb_nm) mp) | |
1492 | in | |
1493 | let fndlb_nm_full = | |
1494 | (match path with | |
1495 | | Some pth -> pth^"." | |
1496 | | None -> "")^ | |
1497 | fndlb_nm | |
1498 | in | |
1499 | List.fold_left | |
1500 | (findlib_names_aux (Some fndlb_nm_full)) | |
1501 | mp | |
1502 | children | |
1503 | in | |
1504 | ||
1505 | List.fold_left | |
1506 | (findlib_names_aux None) | |
1507 | MapString.empty | |
1508 | (group_libs pkg) | |
1509 | ||
1510 | ||
1511 | let findlib_of_name ?(recurse=false) map nm = | |
1512 | try | |
1513 | let (path, fndlb_nm) = | |
1514 | MapString.find nm map | |
1515 | in | |
1516 | match path with | |
1517 | | Some pth when recurse -> pth^"."^fndlb_nm | |
1518 | | _ -> fndlb_nm | |
1519 | ||
1520 | with Not_found -> | |
1521 | failwithf | |
1522 | (f_ "Unable to translate internal library '%s' to findlib name") | |
1523 | nm | |
1524 | ||
1525 | let name_findlib_map pkg = | |
1526 | let mp = | |
1527 | findlib_name_map pkg | |
1528 | in | |
1529 | MapString.fold | |
1530 | (fun nm _ acc -> | |
1531 | let fndlb_nm_full = | |
1532 | findlib_of_name | |
1533 | ~recurse:true | |
1534 | mp | |
1535 | nm | |
1536 | in | |
1537 | MapString.add fndlb_nm_full nm acc) | |
1538 | mp | |
1539 | MapString.empty | |
1540 | ||
1793 | ||
1794 | let groups = | |
1795 | group_of_tree group_mp | |
1796 | in | |
1797 | ||
1798 | let library_name_of_findlib_name = | |
1799 | Lazy.lazy_from_fun | |
1800 | (fun () -> | |
1801 | (* Revert findlib_name_of_library_name. *) | |
1802 | MapString.fold | |
1803 | (fun k v mp -> MapString.add v k mp) | |
1804 | fndlb_name_of_lib_name | |
1805 | MapString.empty) | |
1806 | in | |
1807 | let library_name_of_findlib_name fndlb_nm = | |
1808 | try | |
1809 | MapString.find fndlb_nm (Lazy.force library_name_of_findlib_name) | |
1810 | with Not_found -> | |
1811 | raise (FindlibPackageNotFound fndlb_nm) | |
1812 | in | |
1813 | ||
1814 | groups, | |
1815 | findlib_name_of_library_name, | |
1816 | library_name_of_findlib_name | |
1817 | ||
1541 | 1818 | let findlib_of_group = |
1542 | 1819 | function |
1543 | 1820 | | Container (fndlb_nm, _) |
1544 | 1821 | | Package (fndlb_nm, _, _, _, _) -> fndlb_nm |
1545 | ||
1822 | ||
1546 | 1823 | let root_of_group grp = |
1547 | 1824 | let rec root_lib_aux = |
1825 | (* We do a DFS in the group. *) | |
1548 | 1826 | function |
1549 | 1827 | | Container (_, children) -> |
1550 | root_lib_lst children | |
1551 | | Package (_, cs, bs, lib, children) -> | |
1552 | if lib.lib_findlib_parent = None then | |
1553 | cs, bs, lib | |
1554 | else | |
1555 | root_lib_lst children | |
1556 | and root_lib_lst = | |
1557 | function | |
1828 | List.fold_left | |
1829 | (fun res grp -> | |
1830 | if res = None then | |
1831 | root_lib_aux grp | |
1832 | else | |
1833 | res) | |
1834 | None | |
1835 | children | |
1836 | | Package (_, cs, bs, lib, _) -> | |
1837 | Some (cs, bs, lib) | |
1838 | in | |
1839 | match root_lib_aux grp with | |
1840 | | Some res -> | |
1841 | res | |
1842 | | None -> | |
1843 | failwithf | |
1844 | (f_ "Unable to determine root library of findlib library '%s'") | |
1845 | (findlib_of_group grp) | |
1846 | ||
1847 | end | |
1848 | ||
1849 | module OASISFlag = struct | |
1850 | (* # 21 "/mnt/local/sda1/jdimino/dot-opam/4.01.0dev+short-paths/build/oasis.0.3.0/src/oasis/OASISFlag.ml" *) | |
1851 | ||
1852 | end | |
1853 | ||
1854 | module OASISPackage = struct | |
1855 | (* # 21 "/mnt/local/sda1/jdimino/dot-opam/4.01.0dev+short-paths/build/oasis.0.3.0/src/oasis/OASISPackage.ml" *) | |
1856 | ||
1857 | end | |
1858 | ||
1859 | module OASISSourceRepository = struct | |
1860 | (* # 21 "/mnt/local/sda1/jdimino/dot-opam/4.01.0dev+short-paths/build/oasis.0.3.0/src/oasis/OASISSourceRepository.ml" *) | |
1861 | ||
1862 | end | |
1863 | ||
1864 | module OASISTest = struct | |
1865 | (* # 21 "/mnt/local/sda1/jdimino/dot-opam/4.01.0dev+short-paths/build/oasis.0.3.0/src/oasis/OASISTest.ml" *) | |
1866 | ||
1867 | end | |
1868 | ||
1869 | module OASISDocument = struct | |
1870 | (* # 21 "/mnt/local/sda1/jdimino/dot-opam/4.01.0dev+short-paths/build/oasis.0.3.0/src/oasis/OASISDocument.ml" *) | |
1871 | ||
1872 | end | |
1873 | ||
1874 | module OASISExec = struct | |
1875 | (* # 21 "/mnt/local/sda1/jdimino/dot-opam/4.01.0dev+short-paths/build/oasis.0.3.0/src/oasis/OASISExec.ml" *) | |
1876 | ||
1877 | open OASISGettext | |
1878 | open OASISUtils | |
1879 | open OASISMessage | |
1880 | ||
1881 | (* TODO: I don't like this quote, it is there because $(rm) foo expands to | |
1882 | * 'rm -f' foo... | |
1883 | *) | |
1884 | let run ~ctxt ?f_exit_code ?(quote=true) cmd args = | |
1885 | let cmd = | |
1886 | if quote then | |
1887 | if Sys.os_type = "Win32" then | |
1888 | if String.contains cmd ' ' then | |
1889 | (* Double the 1st double quote... win32... sigh *) | |
1890 | "\""^(Filename.quote cmd) | |
1891 | else | |
1892 | cmd | |
1893 | else | |
1894 | Filename.quote cmd | |
1895 | else | |
1896 | cmd | |
1897 | in | |
1898 | let cmdline = | |
1899 | String.concat " " (cmd :: args) | |
1900 | in | |
1901 | info ~ctxt (f_ "Running command '%s'") cmdline; | |
1902 | match f_exit_code, Sys.command cmdline with | |
1903 | | None, 0 -> () | |
1904 | | None, i -> | |
1905 | failwithf | |
1906 | (f_ "Command '%s' terminated with error code %d") | |
1907 | cmdline i | |
1908 | | Some f, i -> | |
1909 | f i | |
1910 | ||
1911 | let run_read_output ~ctxt ?f_exit_code cmd args = | |
1912 | let fn = | |
1913 | Filename.temp_file "oasis-" ".txt" | |
1914 | in | |
1915 | try | |
1916 | begin | |
1917 | let () = | |
1918 | run ~ctxt ?f_exit_code cmd (args @ [">"; Filename.quote fn]) | |
1919 | in | |
1920 | let chn = | |
1921 | open_in fn | |
1922 | in | |
1923 | let routput = | |
1924 | ref [] | |
1925 | in | |
1926 | begin | |
1927 | try | |
1928 | while true do | |
1929 | routput := (input_line chn) :: !routput | |
1930 | done | |
1931 | with End_of_file -> | |
1932 | () | |
1933 | end; | |
1934 | close_in chn; | |
1935 | Sys.remove fn; | |
1936 | List.rev !routput | |
1937 | end | |
1938 | with e -> | |
1939 | (try Sys.remove fn with _ -> ()); | |
1940 | raise e | |
1941 | ||
1942 | let run_read_one_line ~ctxt ?f_exit_code cmd args = | |
1943 | match run_read_output ~ctxt ?f_exit_code cmd args with | |
1944 | | [fst] -> | |
1945 | fst | |
1946 | | lst -> | |
1947 | failwithf | |
1948 | (f_ "Command return unexpected output %S") | |
1949 | (String.concat "\n" lst) | |
1950 | end | |
1951 | ||
1952 | module OASISFileUtil = struct | |
1953 | (* # 21 "/mnt/local/sda1/jdimino/dot-opam/4.01.0dev+short-paths/build/oasis.0.3.0/src/oasis/OASISFileUtil.ml" *) | |
1954 | ||
1955 | open OASISGettext | |
1956 | ||
1957 | let file_exists_case fn = | |
1958 | let dirname = Filename.dirname fn in | |
1959 | let basename = Filename.basename fn in | |
1960 | if Sys.file_exists dirname then | |
1961 | if basename = Filename.current_dir_name then | |
1962 | true | |
1963 | else | |
1964 | List.mem | |
1965 | basename | |
1966 | (Array.to_list (Sys.readdir dirname)) | |
1967 | else | |
1968 | false | |
1969 | ||
1970 | let find_file ?(case_sensitive=true) paths exts = | |
1971 | ||
1972 | (* Cardinal product of two list *) | |
1973 | let ( * ) lst1 lst2 = | |
1974 | List.flatten | |
1975 | (List.map | |
1976 | (fun a -> | |
1977 | List.map | |
1978 | (fun b -> a,b) | |
1979 | lst2) | |
1980 | lst1) | |
1981 | in | |
1982 | ||
1983 | let rec combined_paths lst = | |
1984 | match lst with | |
1985 | | p1 :: p2 :: tl -> | |
1986 | let acc = | |
1987 | (List.map | |
1988 | (fun (a,b) -> Filename.concat a b) | |
1989 | (p1 * p2)) | |
1990 | in | |
1991 | combined_paths (acc :: tl) | |
1992 | | [e] -> | |
1993 | e | |
1558 | 1994 | | [] -> |
1559 | raise Not_found | |
1560 | | hd :: tl -> | |
1561 | try | |
1562 | root_lib_aux hd | |
1563 | with Not_found -> | |
1564 | root_lib_lst tl | |
1565 | in | |
1566 | try | |
1567 | root_lib_aux grp | |
1568 | with Not_found -> | |
1569 | failwithf | |
1570 | (f_ "Unable to determine root library of findlib library '%s'") | |
1571 | (findlib_of_group grp) | |
1572 | ||
1573 | ||
1995 | [] | |
1996 | in | |
1997 | ||
1998 | let alternatives = | |
1999 | List.map | |
2000 | (fun (p,e) -> | |
2001 | if String.length e > 0 && e.[0] <> '.' then | |
2002 | p ^ "." ^ e | |
2003 | else | |
2004 | p ^ e) | |
2005 | ((combined_paths paths) * exts) | |
2006 | in | |
2007 | List.find | |
2008 | (if case_sensitive then | |
2009 | file_exists_case | |
2010 | else | |
2011 | Sys.file_exists) | |
2012 | alternatives | |
2013 | ||
2014 | let which ~ctxt prg = | |
2015 | let path_sep = | |
2016 | match Sys.os_type with | |
2017 | | "Win32" -> | |
2018 | ';' | |
2019 | | _ -> | |
2020 | ':' | |
2021 | in | |
2022 | let path_lst = OASISString.nsplit (Sys.getenv "PATH") path_sep in | |
2023 | let exec_ext = | |
2024 | match Sys.os_type with | |
2025 | | "Win32" -> | |
2026 | "" :: (OASISString.nsplit (Sys.getenv "PATHEXT") path_sep) | |
2027 | | _ -> | |
2028 | [""] | |
2029 | in | |
2030 | find_file ~case_sensitive:false [path_lst; [prg]] exec_ext | |
2031 | ||
2032 | (**/**) | |
2033 | let rec fix_dir dn = | |
2034 | (* Windows hack because Sys.file_exists "src\\" = false when | |
2035 | * Sys.file_exists "src" = true | |
2036 | *) | |
2037 | let ln = | |
2038 | String.length dn | |
2039 | in | |
2040 | if Sys.os_type = "Win32" && ln > 0 && dn.[ln - 1] = '\\' then | |
2041 | fix_dir (String.sub dn 0 (ln - 1)) | |
2042 | else | |
2043 | dn | |
2044 | ||
2045 | let q = Filename.quote | |
2046 | (**/**) | |
2047 | ||
2048 | let cp ~ctxt ?(recurse=false) src tgt = | |
2049 | if recurse then | |
2050 | match Sys.os_type with | |
2051 | | "Win32" -> | |
2052 | OASISExec.run ~ctxt | |
2053 | "xcopy" [q src; q tgt; "/E"] | |
2054 | | _ -> | |
2055 | OASISExec.run ~ctxt | |
2056 | "cp" ["-r"; q src; q tgt] | |
2057 | else | |
2058 | OASISExec.run ~ctxt | |
2059 | (match Sys.os_type with | |
2060 | | "Win32" -> "copy" | |
2061 | | _ -> "cp") | |
2062 | [q src; q tgt] | |
2063 | ||
2064 | let mkdir ~ctxt tgt = | |
2065 | OASISExec.run ~ctxt | |
2066 | (match Sys.os_type with | |
2067 | | "Win32" -> "md" | |
2068 | | _ -> "mkdir") | |
2069 | [q tgt] | |
2070 | ||
2071 | let rec mkdir_parent ~ctxt f tgt = | |
2072 | let tgt = | |
2073 | fix_dir tgt | |
2074 | in | |
2075 | if Sys.file_exists tgt then | |
2076 | begin | |
2077 | if not (Sys.is_directory tgt) then | |
2078 | OASISUtils.failwithf | |
2079 | (f_ "Cannot create directory '%s', a file of the same name already \ | |
2080 | exists") | |
2081 | tgt | |
2082 | end | |
2083 | else | |
2084 | begin | |
2085 | mkdir_parent ~ctxt f (Filename.dirname tgt); | |
2086 | if not (Sys.file_exists tgt) then | |
2087 | begin | |
2088 | f tgt; | |
2089 | mkdir ~ctxt tgt | |
2090 | end | |
2091 | end | |
2092 | ||
2093 | let rmdir ~ctxt tgt = | |
2094 | if Sys.readdir tgt = [||] then | |
2095 | begin | |
2096 | match Sys.os_type with | |
2097 | | "Win32" -> | |
2098 | OASISExec.run ~ctxt "rd" [q tgt] | |
2099 | | _ -> | |
2100 | OASISExec.run ~ctxt "rm" ["-r"; q tgt] | |
2101 | end | |
2102 | ||
2103 | let glob ~ctxt fn = | |
2104 | let basename = | |
2105 | Filename.basename fn | |
2106 | in | |
2107 | if String.length basename >= 2 && | |
2108 | basename.[0] = '*' && | |
2109 | basename.[1] = '.' then | |
2110 | begin | |
2111 | let ext_len = | |
2112 | (String.length basename) - 2 | |
2113 | in | |
2114 | let ext = | |
2115 | String.sub basename 2 ext_len | |
2116 | in | |
2117 | let dirname = | |
2118 | Filename.dirname fn | |
2119 | in | |
2120 | Array.fold_left | |
2121 | (fun acc fn -> | |
2122 | try | |
2123 | let fn_ext = | |
2124 | String.sub | |
2125 | fn | |
2126 | ((String.length fn) - ext_len) | |
2127 | ext_len | |
2128 | in | |
2129 | if fn_ext = ext then | |
2130 | (Filename.concat dirname fn) :: acc | |
2131 | else | |
2132 | acc | |
2133 | with Invalid_argument _ -> | |
2134 | acc) | |
2135 | [] | |
2136 | (Sys.readdir dirname) | |
2137 | end | |
2138 | else | |
2139 | begin | |
2140 | if file_exists_case fn then | |
2141 | [fn] | |
2142 | else | |
2143 | [] | |
2144 | end | |
1574 | 2145 | end |
1575 | 2146 | |
1576 | module OASISFlag = struct | |
1577 | # 21 "/home/dim/sources/oasis/src/oasis/OASISFlag.ml" | |
1578 | ||
1579 | end | |
1580 | ||
1581 | module OASISPackage = struct | |
1582 | # 21 "/home/dim/sources/oasis/src/oasis/OASISPackage.ml" | |
1583 | ||
1584 | end | |
1585 | ||
1586 | module OASISSourceRepository = struct | |
1587 | # 21 "/home/dim/sources/oasis/src/oasis/OASISSourceRepository.ml" | |
1588 | ||
1589 | end | |
1590 | ||
1591 | module OASISTest = struct | |
1592 | # 21 "/home/dim/sources/oasis/src/oasis/OASISTest.ml" | |
1593 | ||
1594 | end | |
1595 | ||
1596 | module OASISDocument = struct | |
1597 | # 21 "/home/dim/sources/oasis/src/oasis/OASISDocument.ml" | |
1598 | ||
1599 | end | |
1600 | ||
1601 | ||
2147 | ||
2148 | # 2142 "setup.ml" | |
1602 | 2149 | module BaseEnvLight = struct |
1603 | # 21 "/home/dim/sources/oasis/src/base/BaseEnvLight.ml" | |
1604 | ||
2150 | (* # 21 "/mnt/local/sda1/jdimino/dot-opam/4.01.0dev+short-paths/build/oasis.0.3.0/src/base/BaseEnvLight.ml" *) | |
2151 | ||
1605 | 2152 | module MapString = Map.Make(String) |
1606 | ||
2153 | ||
1607 | 2154 | type t = string MapString.t |
1608 | ||
2155 | ||
1609 | 2156 | let default_filename = |
1610 | 2157 | Filename.concat |
1611 | 2158 | (Sys.getcwd ()) |
1612 | 2159 | "setup.data" |
1613 | ||
2160 | ||
1614 | 2161 | let load ?(allow_empty=false) ?(filename=default_filename) () = |
1615 | 2162 | if Sys.file_exists filename then |
1616 | 2163 | begin |
1667 | 2214 | "Unable to load environment, the file '%s' doesn't exist." |
1668 | 2215 | filename) |
1669 | 2216 | end |
1670 | ||
2217 | ||
1671 | 2218 | let var_get name env = |
1672 | 2219 | let rec var_expand str = |
1673 | 2220 | let buff = |
1688 | 2235 | Buffer.contents buff |
1689 | 2236 | in |
1690 | 2237 | var_expand (MapString.find name env) |
1691 | ||
2238 | ||
1692 | 2239 | let var_choose lst env = |
1693 | 2240 | OASISExpr.choose |
1694 | 2241 | (fun nm -> var_get nm env) |
1696 | 2243 | end |
1697 | 2244 | |
1698 | 2245 | |
2246 | # 2240 "setup.ml" | |
1699 | 2247 | module BaseContext = struct |
1700 | # 21 "/home/dim/sources/oasis/src/base/BaseContext.ml" | |
1701 | ||
2248 | (* # 21 "/mnt/local/sda1/jdimino/dot-opam/4.01.0dev+short-paths/build/oasis.0.3.0/src/base/BaseContext.ml" *) | |
2249 | ||
1702 | 2250 | open OASISContext |
1703 | ||
2251 | ||
1704 | 2252 | let args = args |
1705 | ||
2253 | ||
1706 | 2254 | let default = default |
1707 | ||
2255 | ||
1708 | 2256 | end |
1709 | 2257 | |
1710 | 2258 | module BaseMessage = struct |
1711 | # 21 "/home/dim/sources/oasis/src/base/BaseMessage.ml" | |
1712 | ||
2259 | (* # 21 "/mnt/local/sda1/jdimino/dot-opam/4.01.0dev+short-paths/build/oasis.0.3.0/src/base/BaseMessage.ml" *) | |
2260 | ||
1713 | 2261 | (** Message to user, overrid for Base |
1714 | 2262 | @author Sylvain Le Gall |
1715 | 2263 | *) |
1716 | 2264 | open OASISMessage |
1717 | 2265 | open BaseContext |
1718 | ||
2266 | ||
1719 | 2267 | let debug fmt = debug ~ctxt:!default fmt |
1720 | ||
2268 | ||
1721 | 2269 | let info fmt = info ~ctxt:!default fmt |
1722 | ||
2270 | ||
1723 | 2271 | let warning fmt = warning ~ctxt:!default fmt |
1724 | ||
2272 | ||
1725 | 2273 | let error fmt = error ~ctxt:!default fmt |
1726 | ||
1727 | let string_of_exception = string_of_exception | |
1728 | ||
2274 | ||
1729 | 2275 | end |
1730 | 2276 | |
1731 | module BaseFilePath = struct | |
1732 | # 21 "/home/dim/sources/oasis/src/base/BaseFilePath.ml" | |
1733 | ||
1734 | ||
1735 | open Filename | |
1736 | ||
1737 | module Unix = OASISUnixPath | |
1738 | ||
1739 | let make = | |
1740 | function | |
1741 | | [] -> | |
1742 | invalid_arg "BaseFilename.make" | |
1743 | | hd :: tl -> | |
1744 | List.fold_left Filename.concat hd tl | |
1745 | ||
1746 | let of_unix ufn = | |
1747 | if Sys.os_type = "Unix" then | |
1748 | ufn | |
1749 | else | |
1750 | make | |
1751 | (List.map | |
1752 | (fun p -> | |
1753 | if p = Unix.current_dir_name then | |
1754 | current_dir_name | |
1755 | else if p = Unix.parent_dir_name then | |
1756 | parent_dir_name | |
1757 | else | |
1758 | p) | |
1759 | (OASISUtils.split '/' ufn)) | |
1760 | ||
1761 | end | |
1762 | ||
1763 | 2277 | module BaseEnv = struct |
1764 | # 21 "/home/dim/sources/oasis/src/base/BaseEnv.ml" | |
1765 | ||
2278 | (* # 21 "/mnt/local/sda1/jdimino/dot-opam/4.01.0dev+short-paths/build/oasis.0.3.0/src/base/BaseEnv.ml" *) | |
2279 | ||
1766 | 2280 | open OASISGettext |
1767 | 2281 | open OASISUtils |
1768 | 2282 | open PropList |
1769 | ||
2283 | ||
1770 | 2284 | module MapString = BaseEnvLight.MapString |
1771 | ||
2285 | ||
1772 | 2286 | type origin_t = |
1773 | 2287 | | ODefault |
1774 | 2288 | | OGetEnv |
1775 | 2289 | | OFileLoad |
1776 | 2290 | | OCommandLine |
1777 | ||
2291 | ||
1778 | 2292 | type cli_handle_t = |
1779 | 2293 | | CLINone |
1780 | 2294 | | CLIAuto |
1781 | 2295 | | CLIWith |
1782 | 2296 | | CLIEnable |
1783 | 2297 | | CLIUser of (Arg.key * Arg.spec * Arg.doc) list |
1784 | ||
2298 | ||
1785 | 2299 | type definition_t = |
1786 | 2300 | { |
1787 | 2301 | hide: bool; |
1790 | 2304 | arg_help: string option; |
1791 | 2305 | group: string option; |
1792 | 2306 | } |
1793 | ||
2307 | ||
1794 | 2308 | let schema = |
1795 | 2309 | Schema.create "environment" |
1796 | ||
2310 | ||
1797 | 2311 | (* Environment data *) |
1798 | 2312 | let env = |
1799 | 2313 | Data.create () |
1800 | ||
2314 | ||
1801 | 2315 | (* Environment data from file *) |
1802 | 2316 | let env_from_file = |
1803 | 2317 | ref MapString.empty |
1804 | ||
2318 | ||
1805 | 2319 | (* Lexer for var *) |
1806 | 2320 | let var_lxr = |
1807 | 2321 | Genlex.make_lexer [] |
1808 | ||
2322 | ||
1809 | 2323 | let rec var_expand str = |
1810 | 2324 | let buff = |
1811 | 2325 | Buffer.create ((String.length str) * 2) |
1826 | 2340 | in |
1827 | 2341 | match Stream.npeek 3 st with |
1828 | 2342 | | [Genlex.Ident "utoh"; Genlex.Ident nm] -> |
1829 | BaseFilePath.of_unix (var_get nm) | |
2343 | OASISHostPath.of_unix (var_get nm) | |
1830 | 2344 | | [Genlex.Ident "utoh"; Genlex.String s] -> |
1831 | BaseFilePath.of_unix s | |
2345 | OASISHostPath.of_unix s | |
1832 | 2346 | | [Genlex.Ident "ocaml_escaped"; Genlex.Ident nm] -> |
1833 | 2347 | String.escaped (var_get nm) |
1834 | 2348 | | [Genlex.Ident "ocaml_escaped"; Genlex.String s] -> |
1855 | 2369 | e) |
1856 | 2370 | str; |
1857 | 2371 | Buffer.contents buff |
1858 | ||
2372 | ||
1859 | 2373 | and var_get name = |
1860 | 2374 | let vl = |
1861 | 2375 | try |
1869 | 2383 | end |
1870 | 2384 | in |
1871 | 2385 | var_expand vl |
1872 | ||
2386 | ||
1873 | 2387 | let var_choose ?printer ?name lst = |
1874 | 2388 | OASISExpr.choose |
1875 | 2389 | ?printer |
1876 | 2390 | ?name |
1877 | 2391 | var_get |
1878 | 2392 | lst |
1879 | ||
2393 | ||
1880 | 2394 | let var_protect vl = |
1881 | 2395 | let buff = |
1882 | 2396 | Buffer.create (String.length vl) |
1887 | 2401 | | c -> Buffer.add_char buff c) |
1888 | 2402 | vl; |
1889 | 2403 | Buffer.contents buff |
1890 | ||
2404 | ||
1891 | 2405 | let var_define |
1892 | 2406 | ?(hide=false) |
1893 | 2407 | ?(dump=true) |
1898 | 2412 | name (* TODO: type constraint on the fact that name must be a valid OCaml |
1899 | 2413 | id *) |
1900 | 2414 | dflt = |
1901 | ||
2415 | ||
1902 | 2416 | let default = |
1903 | 2417 | [ |
1904 | OFileLoad, lazy (MapString.find name !env_from_file); | |
2418 | OFileLoad, (fun () -> MapString.find name !env_from_file); | |
1905 | 2419 | ODefault, dflt; |
1906 | OGetEnv, lazy (Sys.getenv name); | |
2420 | OGetEnv, (fun () -> Sys.getenv name); | |
1907 | 2421 | ] |
1908 | 2422 | in |
1909 | ||
2423 | ||
1910 | 2424 | let extra = |
1911 | 2425 | { |
1912 | 2426 | hide = hide; |
1916 | 2430 | group = group; |
1917 | 2431 | } |
1918 | 2432 | in |
1919 | ||
2433 | ||
1920 | 2434 | (* Try to find a value that can be defined |
1921 | 2435 | *) |
1922 | 2436 | let var_get_low lst = |
1923 | 2437 | let errors, res = |
1924 | 2438 | List.fold_left |
1925 | (fun (errors, res) (_, v) -> | |
2439 | (fun (errors, res) (o, v) -> | |
1926 | 2440 | if res = None then |
1927 | 2441 | begin |
1928 | 2442 | try |
1929 | errors, Some (Lazy.force v) | |
2443 | errors, Some (v ()) | |
1930 | 2444 | with |
1931 | 2445 | | Not_found -> |
1932 | 2446 | errors, res |
1940 | 2454 | ([], None) |
1941 | 2455 | (List.sort |
1942 | 2456 | (fun (o1, _) (o2, _) -> |
1943 | if o1 < o2 then | |
1944 | 1 | |
1945 | else if o1 = o2 then | |
1946 | 0 | |
1947 | else | |
1948 | -1) | |
2457 | Pervasives.compare o2 o1) | |
1949 | 2458 | lst) |
1950 | 2459 | in |
1951 | 2460 | match res, errors with |
1956 | 2465 | | None, lst -> |
1957 | 2466 | raise (Not_set (name, Some (String.concat (s_ ", ") lst))) |
1958 | 2467 | in |
1959 | ||
2468 | ||
1960 | 2469 | let help = |
1961 | 2470 | match short_desc with |
1962 | 2471 | | Some fs -> Some fs |
1963 | 2472 | | None -> None |
1964 | 2473 | in |
1965 | ||
2474 | ||
1966 | 2475 | let var_get_lst = |
1967 | 2476 | FieldRO.create |
1968 | 2477 | ~schema |
1969 | 2478 | ~name |
1970 | ~parse:(fun ?(context=ODefault) s -> [context, lazy s]) | |
2479 | ~parse:(fun ?(context=ODefault) s -> [context, fun () -> s]) | |
1971 | 2480 | ~print:var_get_low |
1972 | 2481 | ~default |
1973 | 2482 | ~update:(fun ?context x old_x -> x @ old_x) |
1974 | 2483 | ?help |
1975 | 2484 | extra |
1976 | 2485 | in |
1977 | ||
2486 | ||
1978 | 2487 | fun () -> |
1979 | 2488 | var_expand (var_get_low (var_get_lst env)) |
1980 | ||
2489 | ||
1981 | 2490 | let var_redefine |
1982 | 2491 | ?hide |
1983 | 2492 | ?dump |
1989 | 2498 | dflt = |
1990 | 2499 | if Schema.mem schema name then |
1991 | 2500 | begin |
1992 | Schema.set schema env ~context:ODefault name (Lazy.force dflt); | |
2501 | (* TODO: look suspsicious, we want to memorize dflt not dflt () *) | |
2502 | Schema.set schema env ~context:ODefault name (dflt ()); | |
1993 | 2503 | fun () -> var_get name |
1994 | 2504 | end |
1995 | 2505 | else |
2004 | 2514 | name |
2005 | 2515 | dflt |
2006 | 2516 | end |
2007 | ||
2517 | ||
2008 | 2518 | let var_ignore (e : unit -> string) = |
2009 | 2519 | () |
2010 | ||
2520 | ||
2011 | 2521 | let print_hidden = |
2012 | 2522 | var_define |
2013 | 2523 | ~hide:true |
2015 | 2525 | ~cli:CLIAuto |
2016 | 2526 | ~arg_help:"Print even non-printable variable. (debug)" |
2017 | 2527 | "print_hidden" |
2018 | (lazy "false") | |
2019 | ||
2528 | (fun () -> "false") | |
2529 | ||
2020 | 2530 | let var_all () = |
2021 | 2531 | List.rev |
2022 | 2532 | (Schema.fold |
2027 | 2537 | acc) |
2028 | 2538 | [] |
2029 | 2539 | schema) |
2030 | ||
2540 | ||
2031 | 2541 | let default_filename = |
2032 | 2542 | BaseEnvLight.default_filename |
2033 | ||
2543 | ||
2034 | 2544 | let load ?allow_empty ?filename () = |
2035 | 2545 | env_from_file := BaseEnvLight.load ?allow_empty ?filename () |
2036 | ||
2546 | ||
2037 | 2547 | let unload () = |
2038 | (* TODO: reset lazy values *) | |
2039 | 2548 | env_from_file := MapString.empty; |
2040 | 2549 | Data.clear env |
2041 | ||
2550 | ||
2042 | 2551 | let dump ?(filename=default_filename) () = |
2043 | 2552 | let chn = |
2044 | 2553 | open_out_bin filename |
2045 | 2554 | in |
2046 | Schema.iter | |
2047 | (fun nm def _ -> | |
2555 | let output nm value = | |
2556 | Printf.fprintf chn "%s=%S\n" nm value | |
2557 | in | |
2558 | let mp_todo = | |
2559 | (* Dump data from schema *) | |
2560 | Schema.fold | |
2561 | (fun mp_todo nm def _ -> | |
2048 | 2562 | if def.dump then |
2049 | 2563 | begin |
2050 | 2564 | try |
2054 | 2568 | env |
2055 | 2569 | nm |
2056 | 2570 | in |
2057 | Printf.fprintf chn "%s = %S\n" nm value | |
2571 | output nm value | |
2058 | 2572 | with Not_set _ -> |
2059 | 2573 | () |
2060 | end) | |
2061 | schema; | |
2574 | end; | |
2575 | MapString.remove nm mp_todo) | |
2576 | !env_from_file | |
2577 | schema | |
2578 | in | |
2579 | (* Dump data defined outside of schema *) | |
2580 | MapString.iter output mp_todo; | |
2581 | ||
2582 | (* End of the dump *) | |
2062 | 2583 | close_out chn |
2063 | ||
2584 | ||
2064 | 2585 | let print () = |
2065 | 2586 | let printable_vars = |
2066 | 2587 | Schema.fold |
2096 | 2617 | let dot_pad str = |
2097 | 2618 | String.make ((max_length - (String.length str)) + 3) '.' |
2098 | 2619 | in |
2099 | ||
2620 | ||
2100 | 2621 | Printf.printf "\nConfiguration: \n"; |
2101 | 2622 | List.iter |
2102 | 2623 | (fun (name,value) -> |
2103 | 2624 | Printf.printf "%s: %s %s\n" name (dot_pad name) value) |
2104 | 2625 | (List.rev printable_vars); |
2105 | 2626 | Printf.printf "\n%!" |
2106 | ||
2627 | ||
2107 | 2628 | let args () = |
2108 | 2629 | let arg_concat = |
2109 | 2630 | OASISUtils.varname_concat ~hyphen:'-' |
2130 | 2651 | ] |
2131 | 2652 | ), |
2132 | 2653 | "var+val Override any configuration variable."; |
2133 | ||
2654 | ||
2134 | 2655 | ] |
2135 | 2656 | @ |
2136 | 2657 | List.flatten |
2144 | 2665 | name |
2145 | 2666 | s |
2146 | 2667 | in |
2147 | ||
2668 | ||
2148 | 2669 | let arg_name = |
2149 | 2670 | OASISUtils.varname_of_string ~hyphen:'-' name |
2150 | 2671 | in |
2151 | ||
2672 | ||
2152 | 2673 | let hlp = |
2153 | 2674 | match short_descr_opt with |
2154 | 2675 | | Some txt -> txt () |
2155 | 2676 | | None -> "" |
2156 | 2677 | in |
2157 | ||
2678 | ||
2158 | 2679 | let arg_hlp = |
2159 | 2680 | match def.arg_help with |
2160 | 2681 | | Some s -> s |
2161 | 2682 | | None -> "str" |
2162 | 2683 | in |
2163 | ||
2684 | ||
2164 | 2685 | let default_value = |
2165 | 2686 | try |
2166 | 2687 | Printf.sprintf |
2172 | 2693 | with Not_set _ -> |
2173 | 2694 | "" |
2174 | 2695 | in |
2175 | ||
2696 | ||
2176 | 2697 | let args = |
2177 | 2698 | match def.cli with |
2178 | 2699 | | CLINone -> |
2190 | 2711 | Printf.sprintf (f_ "%s %s%s") arg_hlp hlp default_value |
2191 | 2712 | ] |
2192 | 2713 | | CLIEnable -> |
2193 | [ | |
2194 | arg_concat "--enable-" arg_name, | |
2195 | Arg.Unit (fun () -> var_set "true"), | |
2196 | Printf.sprintf (f_ " %s%s") hlp | |
2197 | (if default_value = " [true]" then | |
2198 | (s_ " [default]") | |
2199 | else | |
2200 | ""); | |
2201 | ||
2202 | arg_concat "--disable-" arg_name, | |
2203 | Arg.Unit (fun () -> var_set "false"), | |
2204 | Printf.sprintf (f_ " %s%s") hlp | |
2205 | (if default_value = " [false]" then | |
2206 | (s_ " [default]") | |
2207 | else | |
2208 | ""); | |
2209 | ] | |
2714 | let dflt = | |
2715 | if default_value = " [true]" then | |
2716 | s_ " [default: enabled]" | |
2717 | else | |
2718 | s_ " [default: disabled]" | |
2719 | in | |
2720 | [ | |
2721 | arg_concat "--enable-" arg_name, | |
2722 | Arg.Unit (fun () -> var_set "true"), | |
2723 | Printf.sprintf (f_ " %s%s") hlp dflt; | |
2724 | ||
2725 | arg_concat "--disable-" arg_name, | |
2726 | Arg.Unit (fun () -> var_set "false"), | |
2727 | Printf.sprintf (f_ " %s%s") hlp dflt | |
2728 | ] | |
2210 | 2729 | | CLIUser lst -> |
2211 | 2730 | lst |
2212 | 2731 | in |
2215 | 2734 | schema) |
2216 | 2735 | end |
2217 | 2736 | |
2218 | module BaseExec = struct | |
2219 | # 21 "/home/dim/sources/oasis/src/base/BaseExec.ml" | |
2220 | ||
2221 | open OASISGettext | |
2222 | open OASISUtils | |
2223 | open BaseMessage | |
2224 | ||
2225 | let run ?f_exit_code cmd args = | |
2226 | let cmdline = | |
2227 | String.concat " " (cmd :: args) | |
2228 | in | |
2229 | info (f_ "Running command '%s'") cmdline; | |
2230 | match f_exit_code, Sys.command cmdline with | |
2231 | | None, 0 -> () | |
2232 | | None, i -> | |
2233 | failwithf | |
2234 | (f_ "Command '%s' terminated with error code %d") | |
2235 | cmdline i | |
2236 | | Some f, i -> | |
2237 | f i | |
2238 | ||
2239 | let run_read_output ?f_exit_code cmd args = | |
2240 | let fn = | |
2241 | Filename.temp_file "oasis-" ".txt" | |
2242 | in | |
2243 | let () = | |
2244 | try | |
2245 | run ?f_exit_code cmd (args @ [">"; Filename.quote fn]) | |
2246 | with e -> | |
2247 | Sys.remove fn; | |
2248 | raise e | |
2249 | in | |
2250 | let chn = | |
2251 | open_in fn | |
2252 | in | |
2253 | let routput = | |
2254 | ref [] | |
2255 | in | |
2256 | ( | |
2257 | try | |
2258 | while true do | |
2259 | routput := (input_line chn) :: !routput | |
2260 | done | |
2261 | with End_of_file -> | |
2262 | () | |
2263 | ); | |
2264 | close_in chn; | |
2265 | Sys.remove fn; | |
2266 | List.rev !routput | |
2267 | ||
2268 | let run_read_one_line ?f_exit_code cmd args = | |
2269 | match run_read_output ?f_exit_code cmd args with | |
2270 | | [fst] -> | |
2271 | fst | |
2272 | | lst -> | |
2273 | failwithf | |
2274 | (f_ "Command return unexpected output %S") | |
2275 | (String.concat "\n" lst) | |
2276 | end | |
2277 | ||
2278 | module BaseFileUtil = struct | |
2279 | # 21 "/home/dim/sources/oasis/src/base/BaseFileUtil.ml" | |
2280 | ||
2281 | open OASISGettext | |
2282 | ||
2283 | let find_file paths exts = | |
2284 | ||
2285 | (* Cardinal product of two list *) | |
2286 | let ( * ) lst1 lst2 = | |
2287 | List.flatten | |
2288 | (List.map | |
2289 | (fun a -> | |
2290 | List.map | |
2291 | (fun b -> a,b) | |
2292 | lst2) | |
2293 | lst1) | |
2294 | in | |
2295 | ||
2296 | let rec combined_paths lst = | |
2297 | match lst with | |
2298 | | p1 :: p2 :: tl -> | |
2299 | let acc = | |
2300 | (List.map | |
2301 | (fun (a,b) -> Filename.concat a b) | |
2302 | (p1 * p2)) | |
2303 | in | |
2304 | combined_paths (acc :: tl) | |
2305 | | [e] -> | |
2306 | e | |
2307 | | [] -> | |
2308 | [] | |
2309 | in | |
2310 | ||
2311 | let alternatives = | |
2312 | List.map | |
2313 | (fun (p,e) -> | |
2314 | if String.length e > 0 && e.[0] <> '.' then | |
2315 | p ^ "." ^ e | |
2316 | else | |
2317 | p ^ e) | |
2318 | ((combined_paths paths) * exts) | |
2319 | in | |
2320 | List.find | |
2321 | Sys.file_exists | |
2322 | alternatives | |
2323 | ||
2324 | let which prg = | |
2325 | let path_sep = | |
2326 | match Sys.os_type with | |
2327 | | "Win32" -> | |
2328 | ';' | |
2329 | | _ -> | |
2330 | ':' | |
2331 | in | |
2332 | let path_lst = | |
2333 | OASISUtils.split | |
2334 | path_sep | |
2335 | (Sys.getenv "PATH") | |
2336 | in | |
2337 | let exec_ext = | |
2338 | match Sys.os_type with | |
2339 | | "Win32" -> | |
2340 | "" | |
2341 | :: | |
2342 | (OASISUtils.split | |
2343 | path_sep | |
2344 | (Sys.getenv "PATHEXT")) | |
2345 | | _ -> | |
2346 | [""] | |
2347 | in | |
2348 | find_file [path_lst; [prg]] exec_ext | |
2349 | ||
2350 | (**/**) | |
2351 | let rec fix_dir dn = | |
2352 | (* Windows hack because Sys.file_exists "src\\" = false when | |
2353 | * Sys.file_exists "src" = true | |
2354 | *) | |
2355 | let ln = | |
2356 | String.length dn | |
2357 | in | |
2358 | if Sys.os_type = "Win32" && ln > 0 && dn.[ln - 1] = '\\' then | |
2359 | fix_dir (String.sub dn 0 (ln - 1)) | |
2360 | else | |
2361 | dn | |
2362 | ||
2363 | let q = Filename.quote | |
2364 | (**/**) | |
2365 | ||
2366 | let cp src tgt = | |
2367 | BaseExec.run | |
2368 | (match Sys.os_type with | |
2369 | | "Win32" -> "copy" | |
2370 | | _ -> "cp") | |
2371 | [q src; q tgt] | |
2372 | ||
2373 | let mkdir tgt = | |
2374 | BaseExec.run | |
2375 | (match Sys.os_type with | |
2376 | | "Win32" -> "md" | |
2377 | | _ -> "mkdir") | |
2378 | [q tgt] | |
2379 | ||
2380 | let rec mkdir_parent f tgt = | |
2381 | let tgt = | |
2382 | fix_dir tgt | |
2383 | in | |
2384 | if Sys.file_exists tgt then | |
2385 | begin | |
2386 | if not (Sys.is_directory tgt) then | |
2387 | OASISUtils.failwithf | |
2388 | (f_ "Cannot create directory '%s', a file of the same name already \ | |
2389 | exists") | |
2390 | tgt | |
2391 | end | |
2392 | else | |
2393 | begin | |
2394 | mkdir_parent f (Filename.dirname tgt); | |
2395 | if not (Sys.file_exists tgt) then | |
2396 | begin | |
2397 | f tgt; | |
2398 | mkdir tgt | |
2399 | end | |
2400 | end | |
2401 | ||
2402 | let rmdir tgt = | |
2403 | if Sys.readdir tgt = [||] then | |
2404 | begin | |
2405 | match Sys.os_type with | |
2406 | | "Win32" -> | |
2407 | BaseExec.run "rd" [q tgt] | |
2408 | | _ -> | |
2409 | BaseExec.run "rm" ["-r"; q tgt] | |
2410 | end | |
2411 | ||
2412 | let glob fn = | |
2413 | let basename = | |
2414 | Filename.basename fn | |
2415 | in | |
2416 | if String.length basename >= 2 && | |
2417 | basename.[0] = '*' && | |
2418 | basename.[1] = '.' then | |
2419 | begin | |
2420 | let ext_len = | |
2421 | (String.length basename) - 2 | |
2422 | in | |
2423 | let ext = | |
2424 | String.sub basename 2 ext_len | |
2425 | in | |
2426 | let dirname = | |
2427 | Filename.dirname fn | |
2428 | in | |
2429 | Array.fold_left | |
2430 | (fun acc fn -> | |
2431 | try | |
2432 | let fn_ext = | |
2433 | String.sub | |
2434 | fn | |
2435 | ((String.length fn) - ext_len) | |
2436 | ext_len | |
2437 | in | |
2438 | if fn_ext = ext then | |
2439 | (Filename.concat dirname fn) :: acc | |
2440 | else | |
2441 | acc | |
2442 | with Invalid_argument _ -> | |
2443 | acc) | |
2444 | [] | |
2445 | (Sys.readdir dirname) | |
2446 | end | |
2447 | else | |
2448 | begin | |
2449 | if Sys.file_exists fn then | |
2450 | [fn] | |
2451 | else | |
2452 | [] | |
2453 | end | |
2454 | end | |
2455 | ||
2456 | 2737 | module BaseArgExt = struct |
2457 | # 21 "/home/dim/sources/oasis/src/base/BaseArgExt.ml" | |
2458 | ||
2738 | (* # 21 "/mnt/local/sda1/jdimino/dot-opam/4.01.0dev+short-paths/build/oasis.0.3.0/src/base/BaseArgExt.ml" *) | |
2739 | ||
2459 | 2740 | open OASISUtils |
2460 | 2741 | open OASISGettext |
2461 | ||
2742 | ||
2462 | 2743 | let parse argv args = |
2463 | 2744 | (* Simulate command line for Arg *) |
2464 | 2745 | let current = |
2465 | 2746 | ref 0 |
2466 | 2747 | in |
2467 | ||
2748 | ||
2468 | 2749 | try |
2469 | 2750 | Arg.parse_argv |
2470 | 2751 | ~current:current |
2482 | 2763 | end |
2483 | 2764 | |
2484 | 2765 | module BaseCheck = struct |
2485 | # 21 "/home/dim/sources/oasis/src/base/BaseCheck.ml" | |
2486 | ||
2766 | (* # 21 "/mnt/local/sda1/jdimino/dot-opam/4.01.0dev+short-paths/build/oasis.0.3.0/src/base/BaseCheck.ml" *) | |
2767 | ||
2487 | 2768 | open BaseEnv |
2488 | 2769 | open BaseMessage |
2489 | 2770 | open OASISUtils |
2490 | 2771 | open OASISGettext |
2491 | ||
2772 | ||
2492 | 2773 | let prog_best prg prg_lst = |
2493 | 2774 | var_redefine |
2494 | 2775 | prg |
2495 | (lazy | |
2496 | (let alternate = | |
2497 | List.fold_left | |
2498 | (fun res e -> | |
2499 | match res with | |
2500 | | Some _ -> | |
2501 | res | |
2502 | | None -> | |
2503 | try | |
2504 | Some (BaseFileUtil.which e) | |
2505 | with Not_found -> | |
2506 | None) | |
2507 | None | |
2508 | prg_lst | |
2509 | in | |
2510 | match alternate with | |
2511 | | Some prg -> prg | |
2512 | | None -> raise Not_found)) | |
2513 | ||
2776 | (fun () -> | |
2777 | let alternate = | |
2778 | List.fold_left | |
2779 | (fun res e -> | |
2780 | match res with | |
2781 | | Some _ -> | |
2782 | res | |
2783 | | None -> | |
2784 | try | |
2785 | Some (OASISFileUtil.which ~ctxt:!BaseContext.default e) | |
2786 | with Not_found -> | |
2787 | None) | |
2788 | None | |
2789 | prg_lst | |
2790 | in | |
2791 | match alternate with | |
2792 | | Some prg -> prg | |
2793 | | None -> raise Not_found) | |
2794 | ||
2514 | 2795 | let prog prg = |
2515 | 2796 | prog_best prg [prg] |
2516 | ||
2797 | ||
2517 | 2798 | let prog_opt prg = |
2518 | 2799 | prog_best prg [prg^".opt"; prg] |
2519 | ||
2800 | ||
2520 | 2801 | let ocamlfind = |
2521 | 2802 | prog "ocamlfind" |
2522 | ||
2803 | ||
2523 | 2804 | let version |
2524 | 2805 | var_prefix |
2525 | 2806 | cmp |
2532 | 2813 | var_redefine |
2533 | 2814 | ~hide:true |
2534 | 2815 | var |
2535 | (lazy | |
2536 | (let version_str = | |
2537 | match fversion () with | |
2538 | | "[Distributed with OCaml]" -> | |
2539 | begin | |
2540 | try | |
2541 | (var_get "ocaml_version") | |
2542 | with Not_found -> | |
2543 | warning | |
2544 | (f_ "Variable ocaml_version not defined, fallback \ | |
2545 | to default"); | |
2546 | Sys.ocaml_version | |
2547 | end | |
2548 | | res -> | |
2549 | res | |
2550 | in | |
2551 | let version = | |
2552 | OASISVersion.version_of_string version_str | |
2553 | in | |
2554 | if OASISVersion.comparator_apply version cmp then | |
2555 | version_str | |
2556 | else | |
2557 | failwithf | |
2558 | (f_ "Cannot satisfy version constraint on %s: %s (version: %s)") | |
2559 | var_prefix | |
2560 | (OASISVersion.string_of_comparator cmp) | |
2561 | version_str)) | |
2816 | (fun () -> | |
2817 | let version_str = | |
2818 | match fversion () with | |
2819 | | "[Distributed with OCaml]" -> | |
2820 | begin | |
2821 | try | |
2822 | (var_get "ocaml_version") | |
2823 | with Not_found -> | |
2824 | warning | |
2825 | (f_ "Variable ocaml_version not defined, fallback \ | |
2826 | to default"); | |
2827 | Sys.ocaml_version | |
2828 | end | |
2829 | | res -> | |
2830 | res | |
2831 | in | |
2832 | let version = | |
2833 | OASISVersion.version_of_string version_str | |
2834 | in | |
2835 | if OASISVersion.comparator_apply version cmp then | |
2836 | version_str | |
2837 | else | |
2838 | failwithf | |
2839 | (f_ "Cannot satisfy version constraint on %s: %s (version: %s)") | |
2840 | var_prefix | |
2841 | (OASISVersion.string_of_comparator cmp) | |
2842 | version_str) | |
2562 | 2843 | () |
2563 | ||
2844 | ||
2564 | 2845 | let package_version pkg = |
2565 | BaseExec.run_read_one_line | |
2846 | OASISExec.run_read_one_line ~ctxt:!BaseContext.default | |
2566 | 2847 | (ocamlfind ()) |
2567 | 2848 | ["query"; "-format"; "%v"; pkg] |
2568 | ||
2849 | ||
2569 | 2850 | let package ?version_comparator pkg () = |
2570 | 2851 | let var = |
2571 | 2852 | OASISUtils.varname_concat |
2574 | 2855 | in |
2575 | 2856 | let findlib_dir pkg = |
2576 | 2857 | let dir = |
2577 | BaseExec.run_read_one_line | |
2858 | OASISExec.run_read_one_line ~ctxt:!BaseContext.default | |
2578 | 2859 | (ocamlfind ()) |
2579 | 2860 | ["query"; "-format"; "%d"; pkg] |
2580 | 2861 | in |
2589 | 2870 | let vl = |
2590 | 2871 | var_redefine |
2591 | 2872 | var |
2592 | (lazy (findlib_dir pkg)) | |
2873 | (fun () -> findlib_dir pkg) | |
2593 | 2874 | () |
2594 | 2875 | in |
2595 | 2876 | ( |
2608 | 2889 | end |
2609 | 2890 | |
2610 | 2891 | module BaseOCamlcConfig = struct |
2611 | # 21 "/home/dim/sources/oasis/src/base/BaseOCamlcConfig.ml" | |
2612 | ||
2613 | ||
2892 | (* # 21 "/mnt/local/sda1/jdimino/dot-opam/4.01.0dev+short-paths/build/oasis.0.3.0/src/base/BaseOCamlcConfig.ml" *) | |
2893 | ||
2894 | ||
2614 | 2895 | open BaseEnv |
2615 | 2896 | open OASISUtils |
2616 | 2897 | open OASISGettext |
2617 | ||
2898 | ||
2618 | 2899 | module SMap = Map.Make(String) |
2619 | ||
2900 | ||
2620 | 2901 | let ocamlc = |
2621 | 2902 | BaseCheck.prog_opt "ocamlc" |
2622 | ||
2903 | ||
2623 | 2904 | let ocamlc_config_map = |
2624 | 2905 | (* Map name to value for ocamlc -config output |
2625 | 2906 | (name ^": "^value) |
2664 | 2945 | | [] -> |
2665 | 2946 | mp |
2666 | 2947 | in |
2667 | ||
2948 | ||
2949 | let cache = | |
2950 | lazy | |
2951 | (var_protect | |
2952 | (Marshal.to_string | |
2953 | (split_field | |
2954 | SMap.empty | |
2955 | (OASISExec.run_read_output | |
2956 | ~ctxt:!BaseContext.default | |
2957 | (ocamlc ()) ["-config"])) | |
2958 | [])) | |
2959 | in | |
2668 | 2960 | var_redefine |
2669 | 2961 | "ocamlc_config_map" |
2670 | 2962 | ~hide:true |
2671 | 2963 | ~dump:false |
2672 | (lazy | |
2673 | (var_protect | |
2674 | (Marshal.to_string | |
2675 | (split_field | |
2676 | SMap.empty | |
2677 | (BaseExec.run_read_output | |
2678 | (ocamlc ()) ["-config"])) | |
2679 | []))) | |
2680 | ||
2964 | (fun () -> | |
2965 | (* TODO: update if ocamlc change !!! *) | |
2966 | Lazy.force cache) | |
2967 | ||
2681 | 2968 | let var_define nm = |
2682 | 2969 | (* Extract data from ocamlc -config *) |
2683 | 2970 | let avlbl_config_get () = |
2691 | 2978 | with _ -> |
2692 | 2979 | s |
2693 | 2980 | in |
2694 | ||
2981 | ||
2695 | 2982 | let nm_config, value_config = |
2696 | 2983 | match nm with |
2697 | 2984 | | "ocaml_version" -> |
2700 | 2987 | in |
2701 | 2988 | var_redefine |
2702 | 2989 | nm |
2703 | (lazy | |
2704 | (try | |
2705 | let map = | |
2706 | avlbl_config_get () | |
2707 | in | |
2708 | let value = | |
2709 | SMap.find nm_config map | |
2710 | in | |
2711 | value_config value | |
2712 | with Not_found -> | |
2713 | failwithf | |
2714 | (f_ "Cannot find field '%s' in '%s -config' output") | |
2715 | nm | |
2716 | (ocamlc ()))) | |
2717 | ||
2990 | (fun () -> | |
2991 | try | |
2992 | let map = | |
2993 | avlbl_config_get () | |
2994 | in | |
2995 | let value = | |
2996 | SMap.find nm_config map | |
2997 | in | |
2998 | value_config value | |
2999 | with Not_found -> | |
3000 | failwithf | |
3001 | (f_ "Cannot find field '%s' in '%s -config' output") | |
3002 | nm | |
3003 | (ocamlc ())) | |
3004 | ||
2718 | 3005 | end |
2719 | 3006 | |
2720 | 3007 | module BaseStandardVar = struct |
2721 | # 21 "/home/dim/sources/oasis/src/base/BaseStandardVar.ml" | |
2722 | ||
2723 | ||
3008 | (* # 21 "/mnt/local/sda1/jdimino/dot-opam/4.01.0dev+short-paths/build/oasis.0.3.0/src/base/BaseStandardVar.ml" *) | |
3009 | ||
3010 | ||
2724 | 3011 | open OASISGettext |
2725 | 3012 | open OASISTypes |
2726 | 3013 | open OASISExpr |
2727 | 3014 | open BaseCheck |
2728 | 3015 | open BaseEnv |
2729 | ||
3016 | ||
2730 | 3017 | let ocamlfind = BaseCheck.ocamlfind |
2731 | 3018 | let ocamlc = BaseOCamlcConfig.ocamlc |
2732 | 3019 | let ocamlopt = prog_opt "ocamlopt" |
2733 | 3020 | let ocamlbuild = prog "ocamlbuild" |
2734 | ||
2735 | ||
3021 | ||
3022 | ||
2736 | 3023 | (**/**) |
2737 | 3024 | let rpkg = |
2738 | 3025 | ref None |
2739 | ||
3026 | ||
2740 | 3027 | let pkg_get () = |
2741 | 3028 | match !rpkg with |
2742 | 3029 | | Some pkg -> pkg |
2743 | 3030 | | None -> failwith (s_ "OASIS Package is not set") |
3031 | ||
3032 | let var_cond = ref [] | |
3033 | ||
3034 | let var_define_cond ~since_version f dflt = | |
3035 | let holder = ref (fun () -> dflt) in | |
3036 | let since_version = | |
3037 | OASISVersion.VGreaterEqual (OASISVersion.version_of_string since_version) | |
3038 | in | |
3039 | var_cond := | |
3040 | (fun ver -> | |
3041 | if OASISVersion.comparator_apply ver since_version then | |
3042 | holder := f ()) :: !var_cond; | |
3043 | fun () -> !holder () | |
3044 | ||
2744 | 3045 | (**/**) |
2745 | ||
3046 | ||
2746 | 3047 | let pkg_name = |
2747 | 3048 | var_define |
2748 | 3049 | ~short_desc:(fun () -> s_ "Package name") |
2749 | 3050 | "pkg_name" |
2750 | (lazy (pkg_get ()).name) | |
2751 | ||
3051 | (fun () -> (pkg_get ()).name) | |
3052 | ||
2752 | 3053 | let pkg_version = |
2753 | 3054 | var_define |
2754 | 3055 | ~short_desc:(fun () -> s_ "Package version") |
2755 | 3056 | "pkg_version" |
2756 | (lazy | |
3057 | (fun () -> | |
2757 | 3058 | (OASISVersion.string_of_version (pkg_get ()).version)) |
2758 | ||
3059 | ||
2759 | 3060 | let c = BaseOCamlcConfig.var_define |
2760 | ||
3061 | ||
2761 | 3062 | let os_type = c "os_type" |
2762 | 3063 | let system = c "system" |
2763 | 3064 | let architecture = c "architecture" |
2764 | 3065 | let ccomp_type = c "ccomp_type" |
2765 | 3066 | let ocaml_version = c "ocaml_version" |
2766 | ||
3067 | ||
2767 | 3068 | (* TODO: Check standard variable presence at runtime *) |
2768 | ||
3069 | ||
2769 | 3070 | let standard_library_default = c "standard_library_default" |
2770 | 3071 | let standard_library = c "standard_library" |
2771 | 3072 | let standard_runtime = c "standard_runtime" |
2778 | 3079 | let ext_dll = c "ext_dll" |
2779 | 3080 | let default_executable_name = c "default_executable_name" |
2780 | 3081 | let systhread_supported = c "systhread_supported" |
2781 | ||
2782 | ||
3082 | ||
3083 | let flexlink = | |
3084 | BaseCheck.prog "flexlink" | |
3085 | ||
3086 | let flexdll_version = | |
3087 | var_define | |
3088 | ~short_desc:(fun () -> "FlexDLL version (Win32)") | |
3089 | "flexdll_version" | |
3090 | (fun () -> | |
3091 | let lst = | |
3092 | OASISExec.run_read_output ~ctxt:!BaseContext.default | |
3093 | (flexlink ()) ["-help"] | |
3094 | in | |
3095 | match lst with | |
3096 | | line :: _ -> | |
3097 | Scanf.sscanf line "FlexDLL version %s" (fun ver -> ver) | |
3098 | | [] -> | |
3099 | raise Not_found) | |
3100 | ||
2783 | 3101 | (**/**) |
2784 | 3102 | let p name hlp dflt = |
2785 | 3103 | var_define |
2788 | 3106 | ~arg_help:"dir" |
2789 | 3107 | name |
2790 | 3108 | dflt |
2791 | ||
3109 | ||
2792 | 3110 | let (/) a b = |
2793 | 3111 | if os_type () = Sys.os_type then |
2794 | 3112 | Filename.concat a b |
2795 | 3113 | else if os_type () = "Unix" then |
2796 | BaseFilePath.Unix.concat a b | |
3114 | OASISUnixPath.concat a b | |
2797 | 3115 | else |
2798 | 3116 | OASISUtils.failwithf (f_ "Cannot handle os_type %s filename concat") |
2799 | 3117 | (os_type ()) |
2800 | 3118 | (**/**) |
2801 | ||
3119 | ||
2802 | 3120 | let prefix = |
2803 | 3121 | p "prefix" |
2804 | 3122 | (fun () -> s_ "Install architecture-independent files dir") |
2805 | (lazy | |
2806 | (match os_type () with | |
2807 | | "Win32" -> | |
2808 | let program_files = | |
2809 | Sys.getenv "PROGRAMFILES" | |
2810 | in | |
2811 | program_files/(pkg_name ()) | |
2812 | | _ -> | |
2813 | "/usr/local")) | |
2814 | ||
3123 | (fun () -> | |
3124 | match os_type () with | |
3125 | | "Win32" -> | |
3126 | let program_files = | |
3127 | Sys.getenv "PROGRAMFILES" | |
3128 | in | |
3129 | program_files/(pkg_name ()) | |
3130 | | _ -> | |
3131 | "/usr/local") | |
3132 | ||
2815 | 3133 | let exec_prefix = |
2816 | 3134 | p "exec_prefix" |
2817 | 3135 | (fun () -> s_ "Install architecture-dependent files in dir") |
2818 | (lazy "$prefix") | |
2819 | ||
3136 | (fun () -> "$prefix") | |
3137 | ||
2820 | 3138 | let bindir = |
2821 | 3139 | p "bindir" |
2822 | 3140 | (fun () -> s_ "User executables") |
2823 | (lazy ("$exec_prefix"/"bin")) | |
2824 | ||
3141 | (fun () -> "$exec_prefix"/"bin") | |
3142 | ||
2825 | 3143 | let sbindir = |
2826 | 3144 | p "sbindir" |
2827 | 3145 | (fun () -> s_ "System admin executables") |
2828 | (lazy ("$exec_prefix"/"sbin")) | |
2829 | ||
3146 | (fun () -> "$exec_prefix"/"sbin") | |
3147 | ||
2830 | 3148 | let libexecdir = |
2831 | 3149 | p "libexecdir" |
2832 | 3150 | (fun () -> s_ "Program executables") |
2833 | (lazy ("$exec_prefix"/"libexec")) | |
2834 | ||
3151 | (fun () -> "$exec_prefix"/"libexec") | |
3152 | ||
2835 | 3153 | let sysconfdir = |
2836 | 3154 | p "sysconfdir" |
2837 | 3155 | (fun () -> s_ "Read-only single-machine data") |
2838 | (lazy ("$prefix"/"etc")) | |
2839 | ||
3156 | (fun () -> "$prefix"/"etc") | |
3157 | ||
2840 | 3158 | let sharedstatedir = |
2841 | 3159 | p "sharedstatedir" |
2842 | 3160 | (fun () -> s_ "Modifiable architecture-independent data") |
2843 | (lazy ("$prefix"/"com")) | |
2844 | ||
3161 | (fun () -> "$prefix"/"com") | |
3162 | ||
2845 | 3163 | let localstatedir = |
2846 | 3164 | p "localstatedir" |
2847 | 3165 | (fun () -> s_ "Modifiable single-machine data") |
2848 | (lazy ("$prefix"/"var")) | |
2849 | ||
3166 | (fun () -> "$prefix"/"var") | |
3167 | ||
2850 | 3168 | let libdir = |
2851 | 3169 | p "libdir" |
2852 | 3170 | (fun () -> s_ "Object code libraries") |
2853 | (lazy ("$exec_prefix"/"lib")) | |
2854 | ||
3171 | (fun () -> "$exec_prefix"/"lib") | |
3172 | ||
2855 | 3173 | let datarootdir = |
2856 | 3174 | p "datarootdir" |
2857 | 3175 | (fun () -> s_ "Read-only arch-independent data root") |
2858 | (lazy ("$prefix"/"share")) | |
2859 | ||
3176 | (fun () -> "$prefix"/"share") | |
3177 | ||
2860 | 3178 | let datadir = |
2861 | 3179 | p "datadir" |
2862 | 3180 | (fun () -> s_ "Read-only architecture-independent data") |
2863 | (lazy ("$datarootdir")) | |
2864 | ||
3181 | (fun () -> "$datarootdir") | |
3182 | ||
2865 | 3183 | let infodir = |
2866 | 3184 | p "infodir" |
2867 | 3185 | (fun () -> s_ "Info documentation") |
2868 | (lazy ("$datarootdir"/"info")) | |
2869 | ||
3186 | (fun () -> "$datarootdir"/"info") | |
3187 | ||
2870 | 3188 | let localedir = |
2871 | 3189 | p "localedir" |
2872 | 3190 | (fun () -> s_ "Locale-dependent data") |
2873 | (lazy ("$datarootdir"/"locale")) | |
2874 | ||
3191 | (fun () -> "$datarootdir"/"locale") | |
3192 | ||
2875 | 3193 | let mandir = |
2876 | 3194 | p "mandir" |
2877 | 3195 | (fun () -> s_ "Man documentation") |
2878 | (lazy ("$datarootdir"/"man")) | |
2879 | ||
3196 | (fun () -> "$datarootdir"/"man") | |
3197 | ||
2880 | 3198 | let docdir = |
2881 | 3199 | p "docdir" |
2882 | 3200 | (fun () -> s_ "Documentation root") |
2883 | (lazy ("$datarootdir"/"doc"/"$pkg_name")) | |
2884 | ||
3201 | (fun () -> "$datarootdir"/"doc"/"$pkg_name") | |
3202 | ||
2885 | 3203 | let htmldir = |
2886 | 3204 | p "htmldir" |
2887 | 3205 | (fun () -> s_ "HTML documentation") |
2888 | (lazy ("$docdir")) | |
2889 | ||
3206 | (fun () -> "$docdir") | |
3207 | ||
2890 | 3208 | let dvidir = |
2891 | 3209 | p "dvidir" |
2892 | 3210 | (fun () -> s_ "DVI documentation") |
2893 | (lazy ("$docdir")) | |
2894 | ||
3211 | (fun () -> "$docdir") | |
3212 | ||
2895 | 3213 | let pdfdir = |
2896 | 3214 | p "pdfdir" |
2897 | 3215 | (fun () -> s_ "PDF documentation") |
2898 | (lazy ("$docdir")) | |
2899 | ||
3216 | (fun () -> "$docdir") | |
3217 | ||
2900 | 3218 | let psdir = |
2901 | 3219 | p "psdir" |
2902 | 3220 | (fun () -> s_ "PS documentation") |
2903 | (lazy ("$docdir")) | |
2904 | ||
3221 | (fun () -> "$docdir") | |
3222 | ||
2905 | 3223 | let destdir = |
2906 | 3224 | p "destdir" |
2907 | 3225 | (fun () -> s_ "Prepend a path when installing package") |
2908 | (lazy | |
2909 | (raise | |
2910 | (PropList.Not_set | |
2911 | ("destdir", | |
2912 | Some (s_ "undefined by construct"))))) | |
2913 | ||
3226 | (fun () -> | |
3227 | raise | |
3228 | (PropList.Not_set | |
3229 | ("destdir", | |
3230 | Some (s_ "undefined by construct")))) | |
3231 | ||
2914 | 3232 | let findlib_version = |
2915 | 3233 | var_define |
2916 | 3234 | "findlib_version" |
2917 | (lazy | |
2918 | (BaseCheck.package_version "findlib")) | |
2919 | ||
3235 | (fun () -> | |
3236 | BaseCheck.package_version "findlib") | |
3237 | ||
2920 | 3238 | let is_native = |
2921 | 3239 | var_define |
2922 | 3240 | "is_native" |
2923 | (lazy | |
2924 | (try | |
2925 | let _s : string = | |
2926 | ocamlopt () | |
2927 | in | |
2928 | "true" | |
2929 | with PropList.Not_set _ -> | |
2930 | let _s : string = | |
2931 | ocamlc () | |
2932 | in | |
2933 | "false")) | |
2934 | ||
3241 | (fun () -> | |
3242 | try | |
3243 | let _s : string = | |
3244 | ocamlopt () | |
3245 | in | |
3246 | "true" | |
3247 | with PropList.Not_set _ -> | |
3248 | let _s : string = | |
3249 | ocamlc () | |
3250 | in | |
3251 | "false") | |
3252 | ||
2935 | 3253 | let ext_program = |
2936 | 3254 | var_define |
2937 | 3255 | "suffix_program" |
2938 | (lazy | |
2939 | (match os_type () with | |
2940 | | "Win32" -> ".exe" | |
2941 | | _ -> "" | |
2942 | )) | |
2943 | ||
3256 | (fun () -> | |
3257 | match os_type () with | |
3258 | | "Win32" -> ".exe" | |
3259 | | _ -> "") | |
3260 | ||
2944 | 3261 | let rm = |
2945 | 3262 | var_define |
2946 | 3263 | ~short_desc:(fun () -> s_ "Remove a file.") |
2947 | 3264 | "rm" |
2948 | (lazy | |
2949 | (match os_type () with | |
2950 | | "Win32" -> "del" | |
2951 | | _ -> "rm -f")) | |
2952 | ||
3265 | (fun () -> | |
3266 | match os_type () with | |
3267 | | "Win32" -> "del" | |
3268 | | _ -> "rm -f") | |
3269 | ||
2953 | 3270 | let rmdir = |
2954 | 3271 | var_define |
2955 | 3272 | ~short_desc:(fun () -> s_ "Remove a directory.") |
2956 | 3273 | "rmdir" |
2957 | (lazy | |
2958 | (match os_type () with | |
2959 | | "Win32" -> "rd" | |
2960 | | _ -> "rm -rf")) | |
2961 | ||
3274 | (fun () -> | |
3275 | match os_type () with | |
3276 | | "Win32" -> "rd" | |
3277 | | _ -> "rm -rf") | |
3278 | ||
2962 | 3279 | let debug = |
2963 | 3280 | var_define |
2964 | ~short_desc:(fun () -> s_ "Compile with ocaml debug flag on.") | |
3281 | ~short_desc:(fun () -> s_ "Turn ocaml debug flag on") | |
3282 | ~cli:CLIEnable | |
2965 | 3283 | "debug" |
2966 | (lazy "true") | |
2967 | ||
3284 | (fun () -> "true") | |
3285 | ||
2968 | 3286 | let profile = |
2969 | 3287 | var_define |
2970 | ~short_desc:(fun () -> s_ "Compile with ocaml profile flag on.") | |
3288 | ~short_desc:(fun () -> s_ "Turn ocaml profile flag on") | |
3289 | ~cli:CLIEnable | |
2971 | 3290 | "profile" |
2972 | (lazy "false") | |
2973 | ||
3291 | (fun () -> "false") | |
3292 | ||
3293 | let tests = | |
3294 | var_define_cond ~since_version:"0.3" | |
3295 | (fun () -> | |
3296 | var_define | |
3297 | ~short_desc:(fun () -> | |
3298 | s_ "Compile tests executable and library and run them") | |
3299 | ~cli:CLIEnable | |
3300 | "tests" | |
3301 | (fun () -> "false")) | |
3302 | "true" | |
3303 | ||
3304 | let docs = | |
3305 | var_define_cond ~since_version:"0.3" | |
3306 | (fun () -> | |
3307 | var_define | |
3308 | ~short_desc:(fun () -> s_ "Create documentations") | |
3309 | ~cli:CLIEnable | |
3310 | "docs" | |
3311 | (fun () -> "true")) | |
3312 | "true" | |
3313 | ||
3314 | let native_dynlink = | |
3315 | var_define | |
3316 | ~short_desc:(fun () -> s_ "Compiler support generation of .cmxs.") | |
3317 | ~cli:CLINone | |
3318 | "native_dynlink" | |
3319 | (fun () -> | |
3320 | let res = | |
3321 | let ocaml_lt_312 () = | |
3322 | OASISVersion.comparator_apply | |
3323 | (OASISVersion.version_of_string (ocaml_version ())) | |
3324 | (OASISVersion.VLesser | |
3325 | (OASISVersion.version_of_string "3.12.0")) | |
3326 | in | |
3327 | let flexdll_lt_030 () = | |
3328 | OASISVersion.comparator_apply | |
3329 | (OASISVersion.version_of_string (flexdll_version ())) | |
3330 | (OASISVersion.VLesser | |
3331 | (OASISVersion.version_of_string "0.30")) | |
3332 | in | |
3333 | let has_native_dynlink = | |
3334 | let ocamlfind = ocamlfind () in | |
3335 | try | |
3336 | let fn = | |
3337 | OASISExec.run_read_one_line | |
3338 | ~ctxt:!BaseContext.default | |
3339 | ocamlfind | |
3340 | ["query"; "-predicates"; "native"; "dynlink"; | |
3341 | "-format"; "%d/%a"] | |
3342 | in | |
3343 | Sys.file_exists fn | |
3344 | with _ -> | |
3345 | false | |
3346 | in | |
3347 | if not has_native_dynlink then | |
3348 | false | |
3349 | else if ocaml_lt_312 () then | |
3350 | false | |
3351 | else if (os_type () = "Win32" || os_type () = "Cygwin") | |
3352 | && flexdll_lt_030 () then | |
3353 | begin | |
3354 | BaseMessage.warning | |
3355 | (f_ ".cmxs generation disabled because FlexDLL needs to be \ | |
3356 | at least 0.30. Please upgrade FlexDLL from %s to 0.30.") | |
3357 | (flexdll_version ()); | |
3358 | false | |
3359 | end | |
3360 | else | |
3361 | true | |
3362 | in | |
3363 | string_of_bool res) | |
3364 | ||
2974 | 3365 | let init pkg = |
2975 | rpkg := Some pkg | |
2976 | ||
3366 | rpkg := Some pkg; | |
3367 | List.iter (fun f -> f pkg.oasis_version) !var_cond | |
3368 | ||
2977 | 3369 | end |
2978 | 3370 | |
2979 | 3371 | module BaseFileAB = struct |
2980 | # 21 "/home/dim/sources/oasis/src/base/BaseFileAB.ml" | |
2981 | ||
3372 | (* # 21 "/mnt/local/sda1/jdimino/dot-opam/4.01.0dev+short-paths/build/oasis.0.3.0/src/base/BaseFileAB.ml" *) | |
3373 | ||
2982 | 3374 | open BaseEnv |
2983 | 3375 | open OASISGettext |
2984 | 3376 | open BaseMessage |
2985 | ||
3377 | ||
2986 | 3378 | let to_filename fn = |
2987 | 3379 | let fn = |
2988 | BaseFilePath.of_unix fn | |
3380 | OASISHostPath.of_unix fn | |
2989 | 3381 | in |
2990 | 3382 | if not (Filename.check_suffix fn ".ab") then |
2991 | 3383 | warning |
2992 | 3384 | (f_ "File '%s' doesn't have '.ab' extension") |
2993 | 3385 | fn; |
2994 | 3386 | Filename.chop_extension fn |
2995 | ||
3387 | ||
2996 | 3388 | let replace fn_lst = |
2997 | 3389 | let buff = |
2998 | 3390 | Buffer.create 13 |
3000 | 3392 | List.iter |
3001 | 3393 | (fun fn -> |
3002 | 3394 | let fn = |
3003 | BaseFilePath.of_unix fn | |
3395 | OASISHostPath.of_unix fn | |
3004 | 3396 | in |
3005 | 3397 | let chn_in = |
3006 | 3398 | open_in fn |
3025 | 3417 | end |
3026 | 3418 | |
3027 | 3419 | module BaseLog = struct |
3028 | # 21 "/home/dim/sources/oasis/src/base/BaseLog.ml" | |
3029 | ||
3420 | (* # 21 "/mnt/local/sda1/jdimino/dot-opam/4.01.0dev+short-paths/build/oasis.0.3.0/src/base/BaseLog.ml" *) | |
3421 | ||
3030 | 3422 | open OASISUtils |
3031 | ||
3423 | ||
3032 | 3424 | let default_filename = |
3033 | 3425 | Filename.concat |
3034 | 3426 | (Filename.dirname BaseEnv.default_filename) |
3035 | 3427 | "setup.log" |
3036 | ||
3428 | ||
3037 | 3429 | module SetTupleString = |
3038 | 3430 | Set.Make |
3039 | 3431 | (struct |
3043 | 3435 | | 0 -> String.compare s12 s22 |
3044 | 3436 | | n -> n |
3045 | 3437 | end) |
3046 | ||
3438 | ||
3047 | 3439 | let load () = |
3048 | 3440 | if Sys.file_exists default_filename then |
3049 | 3441 | begin |
3058 | 3450 | begin |
3059 | 3451 | let acc = |
3060 | 3452 | try |
3061 | Scanf.bscanf scbuf "%S %S@\n" | |
3453 | Scanf.bscanf scbuf "%S %S\n" | |
3062 | 3454 | (fun e d -> |
3063 | 3455 | let t = |
3064 | 3456 | e, d |
3092 | 3484 | begin |
3093 | 3485 | [] |
3094 | 3486 | end |
3095 | ||
3487 | ||
3096 | 3488 | let register event data = |
3097 | 3489 | let chn_out = |
3098 | 3490 | open_out_gen [Open_append; Open_creat; Open_text] 0o644 default_filename |
3099 | 3491 | in |
3100 | 3492 | Printf.fprintf chn_out "%S %S\n" event data; |
3101 | 3493 | close_out chn_out |
3102 | ||
3494 | ||
3103 | 3495 | let unregister event data = |
3104 | 3496 | if Sys.file_exists default_filename then |
3105 | 3497 | begin |
3124 | 3516 | if not !write_something then |
3125 | 3517 | Sys.remove default_filename |
3126 | 3518 | end |
3127 | ||
3519 | ||
3128 | 3520 | let filter events = |
3129 | 3521 | let st_events = |
3130 | 3522 | List.fold_left |
3136 | 3528 | List.filter |
3137 | 3529 | (fun (e, _) -> SetString.mem e st_events) |
3138 | 3530 | (load ()) |
3139 | ||
3531 | ||
3140 | 3532 | let exists event data = |
3141 | 3533 | List.exists |
3142 | 3534 | (fun v -> (event, data) = v) |
3144 | 3536 | end |
3145 | 3537 | |
3146 | 3538 | module BaseBuilt = struct |
3147 | # 21 "/home/dim/sources/oasis/src/base/BaseBuilt.ml" | |
3148 | ||
3539 | (* # 21 "/mnt/local/sda1/jdimino/dot-opam/4.01.0dev+short-paths/build/oasis.0.3.0/src/base/BaseBuilt.ml" *) | |
3540 | ||
3149 | 3541 | open OASISTypes |
3150 | 3542 | open OASISGettext |
3151 | 3543 | open BaseStandardVar |
3152 | 3544 | open BaseMessage |
3153 | ||
3545 | ||
3154 | 3546 | type t = |
3155 | 3547 | | BExec (* Executable *) |
3156 | 3548 | | BExecLib (* Library coming with executable *) |
3157 | 3549 | | BLib (* Library *) |
3158 | 3550 | | BDoc (* Document *) |
3159 | ||
3551 | ||
3160 | 3552 | let to_log_event_file t nm = |
3161 | 3553 | "built_"^ |
3162 | 3554 | (match t with |
3165 | 3557 | | BLib -> "lib" |
3166 | 3558 | | BDoc -> "doc")^ |
3167 | 3559 | "_"^nm |
3168 | ||
3560 | ||
3169 | 3561 | let to_log_event_done t nm = |
3170 | 3562 | "is_"^(to_log_event_file t nm) |
3171 | ||
3563 | ||
3172 | 3564 | let register t nm lst = |
3173 | 3565 | BaseLog.register |
3174 | 3566 | (to_log_event_done t nm) |
3178 | 3570 | let registered = |
3179 | 3571 | List.fold_left |
3180 | 3572 | (fun registered fn -> |
3181 | if Sys.file_exists fn then | |
3573 | if OASISFileUtil.file_exists_case fn then | |
3182 | 3574 | begin |
3183 | 3575 | BaseLog.register |
3184 | 3576 | (to_log_event_file t nm) |
3198 | 3590 | (f_ "Cannot find an existing alternative files among: %s") |
3199 | 3591 | (String.concat (s_ ", ") alt)) |
3200 | 3592 | lst |
3201 | ||
3593 | ||
3202 | 3594 | let unregister t nm = |
3203 | 3595 | List.iter |
3204 | 3596 | (fun (e, d) -> |
3206 | 3598 | (BaseLog.filter |
3207 | 3599 | [to_log_event_file t nm; |
3208 | 3600 | to_log_event_done t nm]) |
3209 | ||
3601 | ||
3210 | 3602 | let fold t nm f acc = |
3211 | 3603 | List.fold_left |
3212 | 3604 | (fun acc (_, fn) -> |
3213 | if Sys.file_exists fn then | |
3605 | if OASISFileUtil.file_exists_case fn then | |
3214 | 3606 | begin |
3215 | 3607 | f acc fn |
3216 | 3608 | end |
3234 | 3626 | acc |
3235 | 3627 | (BaseLog.filter |
3236 | 3628 | [to_log_event_file t nm]) |
3237 | ||
3629 | ||
3238 | 3630 | let is_built t nm = |
3239 | 3631 | List.fold_left |
3240 | 3632 | (fun is_built (_, d) -> |
3245 | 3637 | false |
3246 | 3638 | (BaseLog.filter |
3247 | 3639 | [to_log_event_done t nm]) |
3248 | ||
3640 | ||
3249 | 3641 | let of_executable ffn (cs, bs, exec) = |
3250 | 3642 | let unix_exec_is, unix_dll_opt = |
3251 | 3643 | OASISExecutable.unix_exec_is |
3268 | 3660 | evs, |
3269 | 3661 | unix_exec_is, |
3270 | 3662 | unix_dll_opt |
3271 | ||
3663 | ||
3272 | 3664 | let of_library ffn (cs, bs, lib) = |
3273 | 3665 | let unix_lst = |
3274 | 3666 | OASISLibrary.generated_unix_files |
3275 | 3667 | ~ctxt:!BaseContext.default |
3668 | ~source_file_exists:(fun fn -> | |
3669 | OASISFileUtil.file_exists_case (OASISHostPath.of_unix fn)) | |
3670 | ~is_native:(bool_of_string (is_native ())) | |
3671 | ~has_native_dynlink:(bool_of_string (native_dynlink ())) | |
3672 | ~ext_lib:(ext_lib ()) | |
3673 | ~ext_dll:(ext_dll ()) | |
3276 | 3674 | (cs, bs, lib) |
3277 | (fun fn -> | |
3278 | Sys.file_exists (BaseFilePath.of_unix fn)) | |
3279 | (fun () -> | |
3280 | bool_of_string (is_native ())) | |
3281 | ext_lib | |
3282 | ext_dll | |
3283 | 3675 | in |
3284 | 3676 | let evs = |
3285 | 3677 | [BLib, |
3287 | 3679 | List.map (List.map ffn) unix_lst] |
3288 | 3680 | in |
3289 | 3681 | evs, unix_lst |
3290 | ||
3682 | ||
3291 | 3683 | end |
3292 | 3684 | |
3293 | 3685 | module BaseCustom = struct |
3294 | # 21 "/home/dim/sources/oasis/src/base/BaseCustom.ml" | |
3295 | ||
3686 | (* # 21 "/mnt/local/sda1/jdimino/dot-opam/4.01.0dev+short-paths/build/oasis.0.3.0/src/base/BaseCustom.ml" *) | |
3687 | ||
3296 | 3688 | open BaseEnv |
3297 | 3689 | open BaseMessage |
3298 | 3690 | open OASISTypes |
3299 | 3691 | open OASISGettext |
3300 | ||
3692 | ||
3301 | 3693 | let run cmd args extra_args = |
3302 | BaseExec.run | |
3694 | OASISExec.run ~ctxt:!BaseContext.default ~quote:false | |
3303 | 3695 | (var_expand cmd) |
3304 | 3696 | (List.map |
3305 | 3697 | var_expand |
3306 | 3698 | (args @ (Array.to_list extra_args))) |
3307 | ||
3699 | ||
3308 | 3700 | let hook ?(failsafe=false) cstm f e = |
3309 | 3701 | let optional_command lst = |
3310 | 3702 | let printer = |
3341 | 3733 | end |
3342 | 3734 | |
3343 | 3735 | module BaseDynVar = struct |
3344 | # 21 "/home/dim/sources/oasis/src/base/BaseDynVar.ml" | |
3345 | ||
3346 | ||
3736 | (* # 21 "/mnt/local/sda1/jdimino/dot-opam/4.01.0dev+short-paths/build/oasis.0.3.0/src/base/BaseDynVar.ml" *) | |
3737 | ||
3738 | ||
3347 | 3739 | open OASISTypes |
3348 | 3740 | open OASISGettext |
3349 | 3741 | open BaseEnv |
3350 | 3742 | open BaseBuilt |
3351 | ||
3743 | ||
3352 | 3744 | let init pkg = |
3745 | (* TODO: disambiguate exec vs other variable by adding exec_VARNAME. *) | |
3746 | (* TODO: provide compile option for library libary_byte_args_VARNAME... *) | |
3353 | 3747 | List.iter |
3354 | 3748 | (function |
3355 | 3749 | | Executable (cs, bs, exec) -> |
3356 | var_ignore | |
3357 | (var_redefine | |
3358 | (* We don't save this variable *) | |
3359 | ~dump:false | |
3360 | ~short_desc:(fun () -> | |
3361 | Printf.sprintf | |
3362 | (f_ "Filename of executable '%s'") | |
3363 | cs.cs_name) | |
3364 | cs.cs_name | |
3365 | (lazy | |
3366 | (let fn_opt = | |
3367 | fold | |
3368 | BExec cs.cs_name | |
3369 | (fun _ fn -> Some fn) | |
3370 | None | |
3371 | in | |
3372 | match fn_opt with | |
3373 | | Some fn -> fn | |
3374 | | None -> | |
3375 | raise | |
3376 | (PropList.Not_set | |
3377 | (cs.cs_name, | |
3378 | Some (Printf.sprintf | |
3379 | (f_ "Executable '%s' not yet built.") | |
3380 | cs.cs_name)))))) | |
3381 | ||
3750 | if var_choose bs.bs_build then | |
3751 | var_ignore | |
3752 | (var_redefine | |
3753 | (* We don't save this variable *) | |
3754 | ~dump:false | |
3755 | ~short_desc:(fun () -> | |
3756 | Printf.sprintf | |
3757 | (f_ "Filename of executable '%s'") | |
3758 | cs.cs_name) | |
3759 | (OASISUtils.varname_of_string cs.cs_name) | |
3760 | (fun () -> | |
3761 | let fn_opt = | |
3762 | fold | |
3763 | BExec cs.cs_name | |
3764 | (fun _ fn -> Some fn) | |
3765 | None | |
3766 | in | |
3767 | match fn_opt with | |
3768 | | Some fn -> fn | |
3769 | | None -> | |
3770 | raise | |
3771 | (PropList.Not_set | |
3772 | (cs.cs_name, | |
3773 | Some (Printf.sprintf | |
3774 | (f_ "Executable '%s' not yet built.") | |
3775 | cs.cs_name))))) | |
3776 | ||
3382 | 3777 | | Library _ | Flag _ | Test _ | SrcRepo _ | Doc _ -> |
3383 | 3778 | ()) |
3384 | 3779 | pkg.sections |
3385 | 3780 | end |
3386 | 3781 | |
3387 | 3782 | module BaseTest = struct |
3388 | # 21 "/home/dim/sources/oasis/src/base/BaseTest.ml" | |
3389 | ||
3783 | (* # 21 "/mnt/local/sda1/jdimino/dot-opam/4.01.0dev+short-paths/build/oasis.0.3.0/src/base/BaseTest.ml" *) | |
3784 | ||
3390 | 3785 | open BaseEnv |
3391 | 3786 | open BaseMessage |
3392 | 3787 | open OASISTypes |
3393 | 3788 | open OASISExpr |
3394 | 3789 | open OASISGettext |
3395 | ||
3790 | ||
3396 | 3791 | let test lst pkg extra_args = |
3397 | ||
3792 | ||
3398 | 3793 | let one_test (failure, n) (test_plugin, cs, test) = |
3399 | 3794 | if var_choose |
3400 | 3795 | ~name:(Printf.sprintf |
3418 | 3813 | in |
3419 | 3814 | chdir dir; |
3420 | 3815 | fun () -> chdir cwd |
3421 | ||
3816 | ||
3422 | 3817 | | None -> |
3423 | 3818 | fun () -> () |
3424 | 3819 | in |
3463 | 3858 | if failure_percent > 0.0 then |
3464 | 3859 | failwith msg |
3465 | 3860 | else |
3466 | info "%s" msg | |
3861 | info "%s" msg; | |
3862 | ||
3863 | (* Possible explanation why the tests where not run. *) | |
3864 | if OASISVersion.version_0_3_or_after pkg.oasis_version && | |
3865 | not (bool_of_string (BaseStandardVar.tests ())) && | |
3866 | lst <> [] then | |
3867 | BaseMessage.warning | |
3868 | "Tests are turned off, consider enabling with \ | |
3869 | 'ocaml setup.ml -configure --enable-tests'" | |
3467 | 3870 | end |
3468 | 3871 | |
3469 | 3872 | module BaseDoc = struct |
3470 | # 21 "/home/dim/sources/oasis/src/base/BaseDoc.ml" | |
3471 | ||
3873 | (* # 21 "/mnt/local/sda1/jdimino/dot-opam/4.01.0dev+short-paths/build/oasis.0.3.0/src/base/BaseDoc.ml" *) | |
3874 | ||
3472 | 3875 | open BaseEnv |
3473 | 3876 | open BaseMessage |
3474 | 3877 | open OASISTypes |
3475 | 3878 | open OASISGettext |
3476 | ||
3879 | ||
3477 | 3880 | let doc lst pkg extra_args = |
3478 | ||
3881 | ||
3479 | 3882 | let one_doc (doc_plugin, cs, doc) = |
3480 | 3883 | if var_choose |
3481 | 3884 | ~name:(Printf.sprintf |
3491 | 3894 | extra_args |
3492 | 3895 | end |
3493 | 3896 | in |
3494 | List.iter | |
3495 | one_doc | |
3496 | lst | |
3897 | List.iter one_doc lst; | |
3898 | ||
3899 | if OASISVersion.version_0_3_or_after pkg.oasis_version && | |
3900 | not (bool_of_string (BaseStandardVar.docs ())) && | |
3901 | lst <> [] then | |
3902 | BaseMessage.warning | |
3903 | "Docs are turned off, consider enabling with \ | |
3904 | 'ocaml setup.ml -configure --enable-docs'" | |
3497 | 3905 | end |
3498 | 3906 | |
3499 | 3907 | module BaseSetup = struct |
3500 | # 21 "/home/dim/sources/oasis/src/base/BaseSetup.ml" | |
3501 | ||
3908 | (* # 21 "/mnt/local/sda1/jdimino/dot-opam/4.01.0dev+short-paths/build/oasis.0.3.0/src/base/BaseSetup.ml" *) | |
3909 | ||
3502 | 3910 | open BaseEnv |
3503 | 3911 | open BaseMessage |
3504 | 3912 | open OASISTypes |
3505 | 3913 | open OASISSection |
3506 | 3914 | open OASISGettext |
3507 | 3915 | open OASISUtils |
3508 | ||
3916 | ||
3509 | 3917 | type std_args_fun = |
3510 | 3918 | package -> string array -> unit |
3511 | ||
3919 | ||
3512 | 3920 | type ('a, 'b) section_args_fun = |
3513 | 3921 | name * (package -> (common_section * 'a) -> string array -> 'b) |
3514 | ||
3922 | ||
3515 | 3923 | type t = |
3516 | 3924 | { |
3517 | configure: std_args_fun; | |
3518 | build: std_args_fun; | |
3519 | doc: ((doc, unit) section_args_fun) list; | |
3520 | test: ((test, float) section_args_fun) list; | |
3521 | install: std_args_fun; | |
3522 | uninstall: std_args_fun; | |
3523 | clean: std_args_fun list; | |
3524 | clean_doc: (doc, unit) section_args_fun list; | |
3525 | clean_test: (test, unit) section_args_fun list; | |
3526 | distclean: std_args_fun list; | |
3527 | distclean_doc: (doc, unit) section_args_fun list; | |
3528 | distclean_test: (test, unit) section_args_fun list; | |
3529 | package: package; | |
3530 | version: string; | |
3925 | configure: std_args_fun; | |
3926 | build: std_args_fun; | |
3927 | doc: ((doc, unit) section_args_fun) list; | |
3928 | test: ((test, float) section_args_fun) list; | |
3929 | install: std_args_fun; | |
3930 | uninstall: std_args_fun; | |
3931 | clean: std_args_fun list; | |
3932 | clean_doc: (doc, unit) section_args_fun list; | |
3933 | clean_test: (test, unit) section_args_fun list; | |
3934 | distclean: std_args_fun list; | |
3935 | distclean_doc: (doc, unit) section_args_fun list; | |
3936 | distclean_test: (test, unit) section_args_fun list; | |
3937 | package: package; | |
3938 | oasis_fn: string option; | |
3939 | oasis_version: string; | |
3940 | oasis_digest: Digest.t option; | |
3941 | oasis_exec: string option; | |
3942 | oasis_setup_args: string list; | |
3943 | setup_update: bool; | |
3531 | 3944 | } |
3532 | ||
3945 | ||
3533 | 3946 | (* Associate a plugin function with data from package *) |
3534 | 3947 | let join_plugin_sections filter_map lst = |
3535 | 3948 | List.rev |
3542 | 3955 | acc) |
3543 | 3956 | [] |
3544 | 3957 | lst) |
3545 | ||
3958 | ||
3546 | 3959 | (* Search for plugin data associated with a section name *) |
3547 | 3960 | let lookup_plugin_section plugin action nm lst = |
3548 | 3961 | try |
3553 | 3966 | plugin |
3554 | 3967 | nm |
3555 | 3968 | action |
3556 | ||
3969 | ||
3557 | 3970 | let configure t args = |
3558 | 3971 | (* Run configure *) |
3559 | 3972 | BaseCustom.hook |
3560 | 3973 | t.package.conf_custom |
3561 | (t.configure t.package) | |
3562 | args; | |
3563 | ||
3974 | (fun () -> | |
3975 | (* Reload if preconf has changed it *) | |
3976 | begin | |
3977 | try | |
3978 | unload (); | |
3979 | load (); | |
3980 | with _ -> | |
3981 | () | |
3982 | end; | |
3983 | ||
3984 | (* Run plugin's configure *) | |
3985 | t.configure t.package args; | |
3986 | ||
3987 | (* Dump to allow postconf to change it *) | |
3988 | dump ()) | |
3989 | (); | |
3990 | ||
3564 | 3991 | (* Reload environment *) |
3565 | 3992 | unload (); |
3566 | 3993 | load (); |
3567 | ||
3994 | ||
3995 | (* Save environment *) | |
3996 | print (); | |
3997 | ||
3568 | 3998 | (* Replace data in file *) |
3569 | 3999 | BaseFileAB.replace t.package.files_ab |
3570 | ||
4000 | ||
3571 | 4001 | let build t args = |
3572 | 4002 | BaseCustom.hook |
3573 | 4003 | t.package.build_custom |
3574 | 4004 | (t.build t.package) |
3575 | 4005 | args |
3576 | ||
4006 | ||
3577 | 4007 | let doc t args = |
3578 | 4008 | BaseDoc.doc |
3579 | 4009 | (join_plugin_sections |
3592 | 4022 | t.package.sections) |
3593 | 4023 | t.package |
3594 | 4024 | args |
3595 | ||
4025 | ||
3596 | 4026 | let test t args = |
3597 | 4027 | BaseTest.test |
3598 | 4028 | (join_plugin_sections |
3611 | 4041 | t.package.sections) |
3612 | 4042 | t.package |
3613 | 4043 | args |
3614 | ||
4044 | ||
3615 | 4045 | let all t args = |
3616 | 4046 | let rno_doc = |
3617 | 4047 | ref false |
3628 | 4058 | "-no-doc", |
3629 | 4059 | Arg.Set rno_doc, |
3630 | 4060 | s_ "Don't run doc target"; |
3631 | ||
4061 | ||
3632 | 4062 | "-no-test", |
3633 | 4063 | Arg.Set rno_test, |
3634 | 4064 | s_ "Don't run test target"; |
3635 | 4065 | ] |
3636 | 4066 | (failwithf (f_ "Don't know what to do with '%s'")) |
3637 | 4067 | ""; |
3638 | ||
4068 | ||
3639 | 4069 | info "Running configure step"; |
3640 | 4070 | configure t [||]; |
3641 | ||
4071 | ||
3642 | 4072 | info "Running build step"; |
3643 | 4073 | build t [||]; |
3644 | ||
4074 | ||
3645 | 4075 | (* Load setup.log dynamic variables *) |
3646 | 4076 | BaseDynVar.init t.package; |
3647 | ||
4077 | ||
3648 | 4078 | if not !rno_doc then |
3649 | 4079 | begin |
3650 | 4080 | info "Running doc step"; |
3654 | 4084 | begin |
3655 | 4085 | info "Skipping doc step" |
3656 | 4086 | end; |
3657 | ||
4087 | ||
3658 | 4088 | if not !rno_test then |
3659 | 4089 | begin |
3660 | 4090 | info "Running test step"; |
3664 | 4094 | begin |
3665 | 4095 | info "Skipping test step" |
3666 | 4096 | end |
3667 | ||
4097 | ||
3668 | 4098 | let install t args = |
3669 | 4099 | BaseCustom.hook |
3670 | 4100 | t.package.install_custom |
3671 | 4101 | (t.install t.package) |
3672 | 4102 | args |
3673 | ||
4103 | ||
3674 | 4104 | let uninstall t args = |
3675 | 4105 | BaseCustom.hook |
3676 | 4106 | t.package.uninstall_custom |
3677 | 4107 | (t.uninstall t.package) |
3678 | 4108 | args |
3679 | ||
4109 | ||
3680 | 4110 | let reinstall t args = |
3681 | 4111 | uninstall t args; |
3682 | 4112 | install t args |
3683 | ||
4113 | ||
3684 | 4114 | let clean, distclean = |
3685 | 4115 | let failsafe f a = |
3686 | 4116 | try |
3692 | 4122 | | Failure msg -> msg |
3693 | 4123 | | e -> Printexc.to_string e) |
3694 | 4124 | in |
3695 | ||
4125 | ||
3696 | 4126 | let generic_clean t cstm mains docs tests args = |
3697 | 4127 | BaseCustom.hook |
3698 | 4128 | ~failsafe:true |
3736 | 4166 | mains) |
3737 | 4167 | () |
3738 | 4168 | in |
3739 | ||
4169 | ||
3740 | 4170 | let clean t args = |
3741 | 4171 | generic_clean |
3742 | 4172 | t |
3746 | 4176 | t.clean_test |
3747 | 4177 | args |
3748 | 4178 | in |
3749 | ||
4179 | ||
3750 | 4180 | let distclean t args = |
3751 | 4181 | (* Call clean *) |
3752 | 4182 | clean t args; |
3753 | ||
4183 | ||
4184 | (* Call distclean code *) | |
4185 | generic_clean | |
4186 | t | |
4187 | t.package.distclean_custom | |
4188 | t.distclean | |
4189 | t.distclean_doc | |
4190 | t.distclean_test | |
4191 | args; | |
4192 | ||
3754 | 4193 | (* Remove generated file *) |
3755 | 4194 | List.iter |
3756 | 4195 | (fun fn -> |
3763 | 4202 | :: |
3764 | 4203 | BaseLog.default_filename |
3765 | 4204 | :: |
3766 | (List.rev_map BaseFileAB.to_filename t.package.files_ab)); | |
3767 | ||
3768 | (* Call distclean code *) | |
3769 | generic_clean | |
3770 | t | |
3771 | t.package.distclean_custom | |
3772 | t.distclean | |
3773 | t.distclean_doc | |
3774 | t.distclean_test | |
3775 | args | |
3776 | in | |
3777 | ||
4205 | (List.rev_map BaseFileAB.to_filename t.package.files_ab)) | |
4206 | in | |
4207 | ||
3778 | 4208 | clean, distclean |
3779 | ||
4209 | ||
3780 | 4210 | let version t _ = |
3781 | print_endline t.version | |
3782 | ||
4211 | print_endline t.oasis_version | |
4212 | ||
4213 | let update_setup_ml, no_update_setup_ml_cli = | |
4214 | let b = ref true in | |
4215 | b, | |
4216 | ("-no-update-setup-ml", | |
4217 | Arg.Clear b, | |
4218 | s_ " Don't try to update setup.ml, even if _oasis has changed.") | |
4219 | ||
4220 | let update_setup_ml t = | |
4221 | let oasis_fn = | |
4222 | match t.oasis_fn with | |
4223 | | Some fn -> fn | |
4224 | | None -> "_oasis" | |
4225 | in | |
4226 | let oasis_exec = | |
4227 | match t.oasis_exec with | |
4228 | | Some fn -> fn | |
4229 | | None -> "oasis" | |
4230 | in | |
4231 | let ocaml = | |
4232 | Sys.executable_name | |
4233 | in | |
4234 | let setup_ml, args = | |
4235 | match Array.to_list Sys.argv with | |
4236 | | setup_ml :: args -> | |
4237 | setup_ml, args | |
4238 | | [] -> | |
4239 | failwith | |
4240 | (s_ "Expecting non-empty command line arguments.") | |
4241 | in | |
4242 | let ocaml, setup_ml = | |
4243 | if Sys.executable_name = Sys.argv.(0) then | |
4244 | (* We are not running in standard mode, probably the script | |
4245 | * is precompiled. | |
4246 | *) | |
4247 | "ocaml", "setup.ml" | |
4248 | else | |
4249 | ocaml, setup_ml | |
4250 | in | |
4251 | let no_update_setup_ml_cli, _, _ = no_update_setup_ml_cli in | |
4252 | let do_update () = | |
4253 | let oasis_exec_version = | |
4254 | OASISExec.run_read_one_line | |
4255 | ~ctxt:!BaseContext.default | |
4256 | ~f_exit_code: | |
4257 | (function | |
4258 | | 0 -> | |
4259 | () | |
4260 | | 1 -> | |
4261 | failwithf | |
4262 | (f_ "Executable '%s' is probably an old version \ | |
4263 | of oasis (< 0.3.0), please update to version \ | |
4264 | v%s.") | |
4265 | oasis_exec t.oasis_version | |
4266 | | 127 -> | |
4267 | failwithf | |
4268 | (f_ "Cannot find executable '%s', please install \ | |
4269 | oasis v%s.") | |
4270 | oasis_exec t.oasis_version | |
4271 | | n -> | |
4272 | failwithf | |
4273 | (f_ "Command '%s version' exited with code %d.") | |
4274 | oasis_exec n) | |
4275 | oasis_exec ["version"] | |
4276 | in | |
4277 | if OASISVersion.comparator_apply | |
4278 | (OASISVersion.version_of_string oasis_exec_version) | |
4279 | (OASISVersion.VGreaterEqual | |
4280 | (OASISVersion.version_of_string t.oasis_version)) then | |
4281 | begin | |
4282 | (* We have a version >= for the executable oasis, proceed with | |
4283 | * update. | |
4284 | *) | |
4285 | (* TODO: delegate this check to 'oasis setup'. *) | |
4286 | if Sys.os_type = "Win32" then | |
4287 | failwithf | |
4288 | (f_ "It is not possible to update the running script \ | |
4289 | setup.ml on Windows. Please update setup.ml by \ | |
4290 | running '%s'.") | |
4291 | (String.concat " " (oasis_exec :: "setup" :: t.oasis_setup_args)) | |
4292 | else | |
4293 | begin | |
4294 | OASISExec.run | |
4295 | ~ctxt:!BaseContext.default | |
4296 | ~f_exit_code: | |
4297 | (function | |
4298 | | 0 -> | |
4299 | () | |
4300 | | n -> | |
4301 | failwithf | |
4302 | (f_ "Unable to update setup.ml using '%s', \ | |
4303 | please fix the problem and retry.") | |
4304 | oasis_exec) | |
4305 | oasis_exec ("setup" :: t.oasis_setup_args); | |
4306 | OASISExec.run ~ctxt:!BaseContext.default ocaml (setup_ml :: args) | |
4307 | end | |
4308 | end | |
4309 | else | |
4310 | failwithf | |
4311 | (f_ "The version of '%s' (v%s) doesn't match the version of \ | |
4312 | oasis used to generate the %s file. Please install at \ | |
4313 | least oasis v%s.") | |
4314 | oasis_exec oasis_exec_version setup_ml t.oasis_version | |
4315 | in | |
4316 | ||
4317 | if !update_setup_ml then | |
4318 | begin | |
4319 | try | |
4320 | match t.oasis_digest with | |
4321 | | Some dgst -> | |
4322 | if Sys.file_exists oasis_fn && dgst <> Digest.file "_oasis" then | |
4323 | begin | |
4324 | do_update (); | |
4325 | true | |
4326 | end | |
4327 | else | |
4328 | false | |
4329 | | None -> | |
4330 | false | |
4331 | with e -> | |
4332 | error | |
4333 | (f_ "Error when updating setup.ml. If you want to avoid this error, \ | |
4334 | you can bypass the update of %s by running '%s %s %s %s'") | |
4335 | setup_ml ocaml setup_ml no_update_setup_ml_cli | |
4336 | (String.concat " " args); | |
4337 | raise e | |
4338 | end | |
4339 | else | |
4340 | false | |
4341 | ||
3783 | 4342 | let setup t = |
3784 | 4343 | let catch_exn = |
3785 | 4344 | ref true |
3791 | 4350 | (f_ "No action defined, run '%s %s -help'") |
3792 | 4351 | Sys.executable_name |
3793 | 4352 | Sys.argv.(0)) |
3794 | ||
4353 | ||
3795 | 4354 | in |
3796 | 4355 | let extra_args_ref = |
3797 | 4356 | ref [] |
3803 | 4362 | Arg.Tuple |
3804 | 4363 | [ |
3805 | 4364 | Arg.Rest (fun str -> extra_args_ref := str :: !extra_args_ref); |
3806 | ||
4365 | ||
3807 | 4366 | Arg.Unit |
3808 | 4367 | (fun () -> |
3809 | 4368 | allow_empty_env_ref := allow_empty_env; |
3810 | 4369 | act_ref := act); |
3811 | 4370 | ] |
3812 | 4371 | in |
3813 | ||
4372 | ||
3814 | 4373 | Arg.parse |
3815 | 4374 | (Arg.align |
3816 | [ | |
4375 | ([ | |
3817 | 4376 | "-configure", |
3818 | 4377 | arg_handle ~allow_empty_env:true configure, |
3819 | 4378 | s_ "[options*] Configure the whole build process."; |
3820 | ||
4379 | ||
3821 | 4380 | "-build", |
3822 | 4381 | arg_handle build, |
3823 | 4382 | s_ "[options*] Build executables and libraries."; |
3824 | ||
4383 | ||
3825 | 4384 | "-doc", |
3826 | 4385 | arg_handle doc, |
3827 | 4386 | s_ "[options*] Build documents."; |
3828 | ||
4387 | ||
3829 | 4388 | "-test", |
3830 | 4389 | arg_handle test, |
3831 | 4390 | s_ "[options*] Run tests."; |
3832 | ||
4391 | ||
3833 | 4392 | "-all", |
3834 | 4393 | arg_handle ~allow_empty_env:true all, |
3835 | 4394 | s_ "[options*] Run configure, build, doc and test targets."; |
3836 | ||
4395 | ||
3837 | 4396 | "-install", |
3838 | 4397 | arg_handle install, |
3839 | 4398 | s_ "[options*] Install libraries, data, executables \ |
3840 | 4399 | and documents."; |
3841 | ||
4400 | ||
3842 | 4401 | "-uninstall", |
3843 | 4402 | arg_handle uninstall, |
3844 | 4403 | s_ "[options*] Uninstall libraries, data, executables \ |
3845 | 4404 | and documents."; |
3846 | ||
4405 | ||
3847 | 4406 | "-reinstall", |
3848 | 4407 | arg_handle reinstall, |
3849 | 4408 | s_ "[options*] Uninstall and install libraries, data, \ |
3850 | 4409 | executables and documents."; |
3851 | ||
4410 | ||
3852 | 4411 | "-clean", |
3853 | 4412 | arg_handle ~allow_empty_env:true clean, |
3854 | 4413 | s_ "[options*] Clean files generated by a build."; |
3855 | ||
4414 | ||
3856 | 4415 | "-distclean", |
3857 | 4416 | arg_handle ~allow_empty_env:true distclean, |
3858 | 4417 | s_ "[options*] Clean files generated by a build and configure."; |
3859 | ||
4418 | ||
3860 | 4419 | "-version", |
3861 | 4420 | arg_handle ~allow_empty_env:true version, |
3862 | 4421 | s_ " Display version of OASIS used to generate this setup.ml."; |
3863 | ||
4422 | ||
3864 | 4423 | "-no-catch-exn", |
3865 | 4424 | Arg.Clear catch_exn, |
3866 | 4425 | s_ " Don't catch exception, useful for debugging."; |
3867 | 4426 | ] |
3868 | @ (BaseContext.args ())) | |
4427 | @ | |
4428 | (if t.setup_update then | |
4429 | [no_update_setup_ml_cli] | |
4430 | else | |
4431 | []) | |
4432 | @ (BaseContext.args ()))) | |
3869 | 4433 | (failwithf (f_ "Don't know what to do with '%s'")) |
3870 | 4434 | (s_ "Setup and run build process current package\n"); |
3871 | ||
4435 | ||
3872 | 4436 | (* Build initial environment *) |
3873 | 4437 | load ~allow_empty:!allow_empty_env_ref (); |
3874 | ||
4438 | ||
3875 | 4439 | (** Initialize flags *) |
3876 | 4440 | List.iter |
3877 | 4441 | (function |
3884 | 4448 | ~cli:CLIEnable |
3885 | 4449 | ?short_desc |
3886 | 4450 | (OASISUtils.varname_of_string cs.cs_name) |
3887 | (lazy (string_of_bool | |
3888 | (var_choose | |
3889 | ~name:(Printf.sprintf | |
3890 | (f_ "default value of flag %s") | |
3891 | cs.cs_name) | |
3892 | ~printer:string_of_bool | |
3893 | choices)))) | |
4451 | (fun () -> | |
4452 | string_of_bool | |
4453 | (var_choose | |
4454 | ~name:(Printf.sprintf | |
4455 | (f_ "default value of flag %s") | |
4456 | cs.cs_name) | |
4457 | ~printer:string_of_bool | |
4458 | choices))) | |
3894 | 4459 | in |
3895 | 4460 | match hlp with |
3896 | 4461 | | Some hlp -> |
3901 | 4466 | | _ -> |
3902 | 4467 | ()) |
3903 | 4468 | t.package.sections; |
3904 | ||
4469 | ||
3905 | 4470 | BaseStandardVar.init t.package; |
3906 | ||
4471 | ||
3907 | 4472 | BaseDynVar.init t.package; |
3908 | ||
3909 | !act_ref t (Array.of_list (List.rev !extra_args_ref)) | |
3910 | ||
4473 | ||
4474 | if t.setup_update && update_setup_ml t then | |
4475 | () | |
4476 | else | |
4477 | !act_ref t (Array.of_list (List.rev !extra_args_ref)) | |
4478 | ||
3911 | 4479 | with e when !catch_exn -> |
3912 | error "%s" (string_of_exception e); | |
4480 | error "%s" (Printexc.to_string e); | |
3913 | 4481 | exit 1 |
3914 | ||
4482 | ||
3915 | 4483 | end |
3916 | 4484 | |
3917 | module BaseDev = struct | |
3918 | # 21 "/home/dim/sources/oasis/src/base/BaseDev.ml" | |
3919 | ||
3920 | ||
3921 | ||
3922 | open OASISGettext | |
3923 | open BaseMessage | |
3924 | ||
3925 | type t = | |
3926 | { | |
3927 | oasis_cmd: string; | |
3928 | } | |
3929 | ||
3930 | let update_and_run t = | |
3931 | (* Command line to run setup-dev *) | |
3932 | let oasis_args = | |
3933 | "setup-dev" :: "-run" :: | |
3934 | Sys.executable_name :: | |
3935 | (Array.to_list Sys.argv) | |
3936 | in | |
3937 | ||
3938 | let exit_on_child_error = | |
3939 | function | |
3940 | | 0 -> () | |
3941 | | 2 -> | |
3942 | (* Bad CLI arguments *) | |
3943 | error | |
3944 | (f_ "The command '%s %s' exit with code 2. It often means that we \ | |
3945 | don't use the right command-line arguments, rerun \ | |
3946 | 'oasis setup-dev'.") | |
3947 | t.oasis_cmd | |
3948 | (String.concat " " oasis_args) | |
3949 | ||
3950 | | 127 -> | |
3951 | (* Cannot find OASIS *) | |
3952 | error | |
3953 | (f_ "Cannot find executable '%s', check where 'oasis' is located \ | |
3954 | and rerun 'oasis setup-dev'") | |
3955 | t.oasis_cmd | |
3956 | ||
3957 | | i -> | |
3958 | exit i | |
3959 | in | |
3960 | ||
3961 | let () = | |
3962 | (* Run OASIS to generate a temporary setup.ml | |
3963 | *) | |
3964 | BaseExec.run | |
3965 | ~f_exit_code:exit_on_child_error | |
3966 | t.oasis_cmd | |
3967 | oasis_args | |
3968 | in | |
3969 | ||
3970 | () | |
3971 | ||
3972 | end | |
3973 | ||
3974 | ||
4485 | ||
4486 | # 4480 "setup.ml" | |
3975 | 4487 | module InternalConfigurePlugin = struct |
3976 | # 21 "/home/dim/sources/oasis/src/plugins/internal/InternalConfigurePlugin.ml" | |
3977 | ||
4488 | (* # 21 "/mnt/local/sda1/jdimino/dot-opam/4.01.0dev+short-paths/build/oasis.0.3.0/src/plugins/internal/InternalConfigurePlugin.ml" *) | |
4489 | ||
3978 | 4490 | (** Configure using internal scheme |
3979 | 4491 | @author Sylvain Le Gall |
3980 | 4492 | *) |
3981 | ||
4493 | ||
3982 | 4494 | open BaseEnv |
3983 | 4495 | open OASISTypes |
3984 | 4496 | open OASISUtils |
3985 | 4497 | open OASISGettext |
3986 | 4498 | open BaseMessage |
3987 | ||
4499 | ||
3988 | 4500 | (** Configure build using provided series of check to be done |
3989 | 4501 | * and then output corresponding file. |
3990 | 4502 | *) |
3995 | 4507 | in |
3996 | 4508 | () |
3997 | 4509 | in |
3998 | ||
4510 | ||
3999 | 4511 | let errors = |
4000 | 4512 | ref SetString.empty |
4001 | 4513 | in |
4002 | ||
4514 | ||
4003 | 4515 | let buff = |
4004 | 4516 | Buffer.create 13 |
4005 | 4517 | in |
4006 | ||
4518 | ||
4007 | 4519 | let add_errors fmt = |
4008 | 4520 | Printf.kbprintf |
4009 | 4521 | (fun b -> |
4012 | 4524 | buff |
4013 | 4525 | fmt |
4014 | 4526 | in |
4015 | ||
4527 | ||
4016 | 4528 | let warn_exception e = |
4017 | warning "%s" (string_of_exception e) | |
4018 | in | |
4019 | ||
4529 | warning "%s" (Printexc.to_string e) | |
4530 | in | |
4531 | ||
4020 | 4532 | (* Check tools *) |
4021 | 4533 | let check_tools lst = |
4022 | 4534 | List.iter |
4046 | 4558 | pkg.sections) |
4047 | 4559 | lst |
4048 | 4560 | in |
4049 | ||
4561 | ||
4050 | 4562 | let build_checks sct bs = |
4051 | 4563 | if var_choose bs.bs_build then |
4052 | 4564 | begin |
4060 | 4572 | (f_ "Section %s requires native compilation") |
4061 | 4573 | (OASISSection.string_of_section sct) |
4062 | 4574 | end; |
4063 | ||
4575 | ||
4064 | 4576 | (* Check tools *) |
4065 | 4577 | check_tools bs.bs_build_tools; |
4066 | ||
4578 | ||
4067 | 4579 | (* Check depends *) |
4068 | 4580 | List.iter |
4069 | 4581 | (function |
4103 | 4615 | bs.bs_build_depends |
4104 | 4616 | end |
4105 | 4617 | in |
4106 | ||
4618 | ||
4107 | 4619 | (* Parse command line *) |
4108 | 4620 | BaseArgExt.parse argv (BaseEnv.args ()); |
4109 | ||
4621 | ||
4110 | 4622 | (* OCaml version *) |
4111 | 4623 | begin |
4112 | 4624 | match pkg.ocaml_version with |
4128 | 4640 | | None -> |
4129 | 4641 | () |
4130 | 4642 | end; |
4131 | ||
4643 | ||
4132 | 4644 | (* Findlib version *) |
4133 | 4645 | begin |
4134 | 4646 | match pkg.findlib_version with |
4150 | 4662 | | None -> |
4151 | 4663 | () |
4152 | 4664 | end; |
4153 | ||
4665 | ||
4666 | (* FlexDLL *) | |
4667 | if BaseStandardVar.os_type () = "Win32" || | |
4668 | BaseStandardVar.os_type () = "Cygwin" then | |
4669 | begin | |
4670 | try | |
4671 | var_ignore_eval BaseStandardVar.flexlink | |
4672 | with e -> | |
4673 | warn_exception e; | |
4674 | add_errors (f_ "Cannot find 'flexlink'") | |
4675 | end; | |
4676 | ||
4154 | 4677 | (* Check build depends *) |
4155 | 4678 | List.iter |
4156 | 4679 | (function |
4166 | 4689 | | _ -> |
4167 | 4690 | ()) |
4168 | 4691 | pkg.sections; |
4169 | ||
4170 | (* Save and print environment *) | |
4171 | if SetString.empty = !errors then | |
4172 | begin | |
4173 | dump (); | |
4174 | print () | |
4175 | end | |
4176 | else | |
4692 | ||
4693 | (* Check if we need native dynlink (presence of libraries that compile to | |
4694 | * native) | |
4695 | *) | |
4696 | begin | |
4697 | let has_cmxa = | |
4698 | List.exists | |
4699 | (function | |
4700 | | Library (_, bs, _) -> | |
4701 | var_choose bs.bs_build && | |
4702 | (bs.bs_compiled_object = Native || | |
4703 | (bs.bs_compiled_object = Best && | |
4704 | bool_of_string (BaseStandardVar.is_native ()))) | |
4705 | | _ -> | |
4706 | false) | |
4707 | pkg.sections | |
4708 | in | |
4709 | if has_cmxa then | |
4710 | var_ignore_eval BaseStandardVar.native_dynlink | |
4711 | end; | |
4712 | ||
4713 | (* Check errors *) | |
4714 | if SetString.empty != !errors then | |
4177 | 4715 | begin |
4178 | 4716 | List.iter |
4179 | 4717 | (fun e -> error "%s" e) |
4185 | 4723 | (SetString.cardinal !errors)) |
4186 | 4724 | (SetString.cardinal !errors) |
4187 | 4725 | end |
4188 | ||
4726 | ||
4189 | 4727 | end |
4190 | 4728 | |
4191 | 4729 | module InternalInstallPlugin = struct |
4192 | # 21 "/home/dim/sources/oasis/src/plugins/internal/InternalInstallPlugin.ml" | |
4193 | ||
4730 | (* # 21 "/mnt/local/sda1/jdimino/dot-opam/4.01.0dev+short-paths/build/oasis.0.3.0/src/plugins/internal/InternalInstallPlugin.ml" *) | |
4731 | ||
4194 | 4732 | (** Install using internal scheme |
4195 | 4733 | @author Sylvain Le Gall |
4196 | 4734 | *) |
4197 | ||
4735 | ||
4198 | 4736 | open BaseEnv |
4199 | 4737 | open BaseStandardVar |
4200 | 4738 | open BaseMessage |
4202 | 4740 | open OASISLibrary |
4203 | 4741 | open OASISGettext |
4204 | 4742 | open OASISUtils |
4205 | ||
4743 | ||
4206 | 4744 | let exec_hook = |
4207 | 4745 | ref (fun (cs, bs, exec) -> cs, bs, exec) |
4208 | ||
4746 | ||
4209 | 4747 | let lib_hook = |
4210 | 4748 | ref (fun (cs, bs, lib) -> cs, bs, lib, []) |
4211 | ||
4749 | ||
4212 | 4750 | let doc_hook = |
4213 | 4751 | ref (fun (cs, doc) -> cs, doc) |
4214 | ||
4752 | ||
4215 | 4753 | let install_file_ev = |
4216 | 4754 | "install-file" |
4217 | ||
4755 | ||
4218 | 4756 | let install_dir_ev = |
4219 | 4757 | "install-dir" |
4220 | ||
4758 | ||
4221 | 4759 | let install_findlib_ev = |
4222 | 4760 | "install-findlib" |
4223 | ||
4761 | ||
4762 | let win32_max_command_line_length = 8000 | |
4763 | ||
4764 | let split_install_command ocamlfind findlib_name meta files = | |
4765 | if Sys.os_type = "Win32" then | |
4766 | (* Arguments for the first command: *) | |
4767 | let first_args = ["install"; findlib_name; meta] in | |
4768 | (* Arguments for remaining commands: *) | |
4769 | let other_args = ["install"; findlib_name; "-add"] in | |
4770 | (* Extract as much files as possible from [files], [len] is | |
4771 | the current command line length: *) | |
4772 | let rec get_files len acc files = | |
4773 | match files with | |
4774 | | [] -> | |
4775 | (List.rev acc, []) | |
4776 | | file :: rest -> | |
4777 | let len = len + 1 + String.length file in | |
4778 | if len > win32_max_command_line_length then | |
4779 | (List.rev acc, files) | |
4780 | else | |
4781 | get_files len (file :: acc) rest | |
4782 | in | |
4783 | (* Split the command into several commands. *) | |
4784 | let rec split args files = | |
4785 | match files with | |
4786 | | [] -> | |
4787 | [] | |
4788 | | _ -> | |
4789 | (* Length of "ocamlfind install <lib> [META|-add]" *) | |
4790 | let len = | |
4791 | List.fold_left | |
4792 | (fun len arg -> | |
4793 | len + 1 (* for the space *) + String.length arg) | |
4794 | (String.length ocamlfind) | |
4795 | args | |
4796 | in | |
4797 | match get_files len [] files with | |
4798 | | ([], _) -> | |
4799 | failwith (s_ "Command line too long.") | |
4800 | | (firsts, others) -> | |
4801 | let cmd = args @ firsts in | |
4802 | (* Use -add for remaining commands: *) | |
4803 | let () = | |
4804 | let findlib_ge_132 = | |
4805 | OASISVersion.comparator_apply | |
4806 | (OASISVersion.version_of_string | |
4807 | (BaseStandardVar.findlib_version ())) | |
4808 | (OASISVersion.VGreaterEqual | |
4809 | (OASISVersion.version_of_string "1.3.2")) | |
4810 | in | |
4811 | if not findlib_ge_132 then | |
4812 | failwithf | |
4813 | (f_ "Installing the library %s require to use the flag \ | |
4814 | '-add' of ocamlfind because the command line is too \ | |
4815 | long. This flag is only available for findlib 1.3.2. \ | |
4816 | Please upgrade findlib from %s to 1.3.2") | |
4817 | findlib_name (BaseStandardVar.findlib_version ()) | |
4818 | in | |
4819 | let cmds = split other_args others in | |
4820 | cmd :: cmds | |
4821 | in | |
4822 | (* The first command does not use -add: *) | |
4823 | split first_args files | |
4824 | else | |
4825 | ["install" :: findlib_name :: meta :: files] | |
4826 | ||
4224 | 4827 | let install pkg argv = |
4225 | ||
4828 | ||
4226 | 4829 | let in_destdir = |
4227 | 4830 | try |
4228 | 4831 | let destdir = |
4235 | 4838 | with PropList.Not_set _ -> |
4236 | 4839 | fun fn -> fn |
4237 | 4840 | in |
4238 | ||
4841 | ||
4239 | 4842 | let install_file ?tgt_fn src_file envdir = |
4240 | 4843 | let tgt_dir = |
4241 | 4844 | in_destdir (envdir ()) |
4250 | 4853 | Filename.basename src_file) |
4251 | 4854 | in |
4252 | 4855 | (* Create target directory if needed *) |
4253 | BaseFileUtil.mkdir_parent | |
4856 | OASISFileUtil.mkdir_parent | |
4857 | ~ctxt:!BaseContext.default | |
4254 | 4858 | (fun dn -> |
4255 | 4859 | info (f_ "Creating directory '%s'") dn; |
4256 | 4860 | BaseLog.register install_dir_ev dn) |
4257 | 4861 | tgt_dir; |
4258 | ||
4862 | ||
4259 | 4863 | (* Really install files *) |
4260 | 4864 | info (f_ "Copying file '%s' to '%s'") src_file tgt_file; |
4261 | BaseFileUtil.cp src_file tgt_file; | |
4865 | OASISFileUtil.cp ~ctxt:!BaseContext.default src_file tgt_file; | |
4262 | 4866 | BaseLog.register install_file_ev tgt_file |
4263 | 4867 | in |
4264 | ||
4868 | ||
4265 | 4869 | (* Install data into defined directory *) |
4266 | 4870 | let install_data srcdir lst tgtdir = |
4267 | 4871 | let tgtdir = |
4268 | BaseFilePath.of_unix (var_expand tgtdir) | |
4872 | OASISHostPath.of_unix (var_expand tgtdir) | |
4269 | 4873 | in |
4270 | 4874 | List.iter |
4271 | 4875 | (fun (src, tgt_opt) -> |
4272 | 4876 | let real_srcs = |
4273 | BaseFileUtil.glob | |
4877 | OASISFileUtil.glob | |
4878 | ~ctxt:!BaseContext.default | |
4274 | 4879 | (Filename.concat srcdir src) |
4275 | 4880 | in |
4276 | 4881 | if real_srcs = [] then |
4284 | 4889 | (fun () -> |
4285 | 4890 | match tgt_opt with |
4286 | 4891 | | Some s -> |
4287 | BaseFilePath.of_unix (var_expand s) | |
4892 | OASISHostPath.of_unix (var_expand s) | |
4288 | 4893 | | None -> |
4289 | 4894 | tgtdir)) |
4290 | 4895 | real_srcs) |
4291 | 4896 | lst |
4292 | 4897 | in |
4293 | ||
4898 | ||
4294 | 4899 | (** Install all libraries *) |
4295 | 4900 | let install_libs pkg = |
4296 | ||
4901 | ||
4297 | 4902 | let files_of_library (f_data, acc) data_lib = |
4298 | 4903 | let cs, bs, lib, lib_extra = |
4299 | 4904 | !lib_hook data_lib |
4308 | 4913 | let acc = |
4309 | 4914 | (* Add uncompiled header from the source tree *) |
4310 | 4915 | let path = |
4311 | BaseFilePath.of_unix bs.bs_path | |
4916 | OASISHostPath.of_unix bs.bs_path | |
4312 | 4917 | in |
4313 | 4918 | List.fold_left |
4314 | 4919 | (fun acc modul -> |
4315 | 4920 | try |
4316 | 4921 | List.find |
4317 | Sys.file_exists | |
4922 | OASISFileUtil.file_exists_case | |
4318 | 4923 | (List.map |
4319 | 4924 | (Filename.concat path) |
4320 | 4925 | [modul^".mli"; |
4321 | 4926 | modul^".ml"; |
4322 | OASISUnixPath.uncapitalize_file modul^".mli"; | |
4323 | OASISUnixPath.capitalize_file modul^".mli"; | |
4324 | OASISUnixPath.uncapitalize_file modul^".ml"; | |
4325 | OASISUnixPath.capitalize_file modul^".ml"]) | |
4927 | String.uncapitalize modul^".mli"; | |
4928 | String.capitalize modul^".mli"; | |
4929 | String.uncapitalize modul^".ml"; | |
4930 | String.capitalize modul^".ml"]) | |
4326 | 4931 | :: acc |
4327 | 4932 | with Not_found -> |
4328 | 4933 | begin |
4335 | 4940 | acc |
4336 | 4941 | lib.lib_modules |
4337 | 4942 | in |
4338 | ||
4943 | ||
4339 | 4944 | let acc = |
4340 | 4945 | (* Get generated files *) |
4341 | 4946 | BaseBuilt.fold |
4344 | 4949 | (fun acc fn -> fn :: acc) |
4345 | 4950 | acc |
4346 | 4951 | in |
4347 | ||
4952 | ||
4348 | 4953 | let f_data () = |
4349 | 4954 | (* Install data associated with the library *) |
4350 | 4955 | install_data |
4355 | 4960 | pkg.name); |
4356 | 4961 | f_data () |
4357 | 4962 | in |
4358 | ||
4963 | ||
4359 | 4964 | (f_data, acc) |
4360 | 4965 | end |
4361 | 4966 | else |
4363 | 4968 | (f_data, acc) |
4364 | 4969 | end |
4365 | 4970 | in |
4366 | ||
4971 | ||
4367 | 4972 | (* Install one group of library *) |
4368 | 4973 | let install_group_lib grp = |
4369 | 4974 | (* Iterate through all group nodes *) |
4380 | 4985 | data_and_files |
4381 | 4986 | children |
4382 | 4987 | in |
4383 | ||
4988 | ||
4384 | 4989 | (* Findlib name of the root library *) |
4385 | 4990 | let findlib_name = |
4386 | 4991 | findlib_of_group grp |
4387 | 4992 | in |
4388 | ||
4993 | ||
4389 | 4994 | (* Determine root library *) |
4390 | 4995 | let root_lib = |
4391 | 4996 | root_of_group grp |
4392 | 4997 | in |
4393 | ||
4998 | ||
4394 | 4999 | (* All files to install for this library *) |
4395 | 5000 | let f_data, files = |
4396 | 5001 | install_group_lib_aux (ignore, []) grp |
4397 | 5002 | in |
4398 | ||
5003 | ||
4399 | 5004 | (* Really install, if there is something to install *) |
4400 | 5005 | if files = [] then |
4401 | 5006 | begin |
4413 | 5018 | let res = |
4414 | 5019 | Filename.concat bs.bs_path "META" |
4415 | 5020 | in |
4416 | if not (Sys.file_exists res) then | |
5021 | if not (OASISFileUtil.file_exists_case res) then | |
4417 | 5022 | failwithf |
4418 | 5023 | (f_ "Cannot find file '%s' for findlib library %s") |
4419 | 5024 | res |
4420 | 5025 | findlib_name; |
4421 | 5026 | res |
4422 | 5027 | in |
5028 | let files = | |
5029 | (* Make filename shorter to avoid hitting command max line length | |
5030 | * too early, esp. on Windows. | |
5031 | *) | |
5032 | let remove_prefix p n = | |
5033 | let plen = String.length p in | |
5034 | let nlen = String.length n in | |
5035 | if plen <= nlen && String.sub n 0 plen = p then | |
5036 | begin | |
5037 | let fn_sep = | |
5038 | if Sys.os_type = "Win32" then | |
5039 | '\\' | |
5040 | else | |
5041 | '/' | |
5042 | in | |
5043 | let cutpoint = plen + | |
5044 | (if plen < nlen && n.[plen] = fn_sep then | |
5045 | 1 | |
5046 | else | |
5047 | 0) | |
5048 | in | |
5049 | String.sub n cutpoint (nlen - cutpoint) | |
5050 | end | |
5051 | else | |
5052 | n | |
5053 | in | |
5054 | List.map (remove_prefix (Sys.getcwd ())) files | |
5055 | in | |
4423 | 5056 | info |
4424 | 5057 | (f_ "Installing findlib library '%s'") |
4425 | 5058 | findlib_name; |
4426 | BaseExec.run | |
4427 | (ocamlfind ()) | |
4428 | ("install" :: findlib_name :: meta :: files); | |
5059 | let ocamlfind = ocamlfind () in | |
5060 | let commands = | |
5061 | split_install_command | |
5062 | ocamlfind | |
5063 | findlib_name | |
5064 | meta | |
5065 | files | |
5066 | in | |
5067 | List.iter | |
5068 | (OASISExec.run ~ctxt:!BaseContext.default ocamlfind) | |
5069 | commands; | |
4429 | 5070 | BaseLog.register install_findlib_ev findlib_name |
4430 | 5071 | end; |
4431 | ||
5072 | ||
4432 | 5073 | (* Install data files *) |
4433 | 5074 | f_data (); |
4434 | ||
5075 | ||
4435 | 5076 | in |
4436 | ||
5077 | ||
5078 | let group_libs, _, _ = | |
5079 | findlib_mapping pkg | |
5080 | in | |
5081 | ||
4437 | 5082 | (* We install libraries in groups *) |
4438 | List.iter | |
4439 | install_group_lib | |
4440 | (group_libs pkg) | |
4441 | in | |
4442 | ||
5083 | List.iter install_group_lib group_libs | |
5084 | in | |
5085 | ||
4443 | 5086 | let install_execs pkg = |
4444 | 5087 | let install_exec data_exec = |
4445 | 5088 | let (cs, bs, exec) = |
4458 | 5101 | cs.cs_name |
4459 | 5102 | (fun () fn -> |
4460 | 5103 | install_file |
4461 | ~tgt_fn:cs.cs_name | |
5104 | ~tgt_fn:(cs.cs_name ^ ext_program ()) | |
4462 | 5105 | fn |
4463 | 5106 | bindir) |
4464 | 5107 | (); |
4486 | 5129 | ()) |
4487 | 5130 | pkg.sections |
4488 | 5131 | in |
4489 | ||
5132 | ||
4490 | 5133 | let install_docs pkg = |
4491 | 5134 | let install_doc data = |
4492 | 5135 | let (cs, doc) = |
4496 | 5139 | BaseBuilt.is_built BaseBuilt.BDoc cs.cs_name then |
4497 | 5140 | begin |
4498 | 5141 | let tgt_dir = |
4499 | BaseFilePath.of_unix (var_expand doc.doc_install_dir) | |
5142 | OASISHostPath.of_unix (var_expand doc.doc_install_dir) | |
4500 | 5143 | in |
4501 | 5144 | BaseBuilt.fold |
4502 | 5145 | BaseBuilt.BDoc |
4520 | 5163 | ()) |
4521 | 5164 | pkg.sections |
4522 | 5165 | in |
4523 | ||
5166 | ||
4524 | 5167 | install_libs pkg; |
4525 | 5168 | install_execs pkg; |
4526 | 5169 | install_docs pkg |
4527 | ||
5170 | ||
4528 | 5171 | (* Uninstall already installed data *) |
4529 | 5172 | let uninstall _ argv = |
4530 | 5173 | List.iter |
4531 | 5174 | (fun (ev, data) -> |
4532 | 5175 | if ev = install_file_ev then |
4533 | 5176 | begin |
4534 | if Sys.file_exists data then | |
5177 | if OASISFileUtil.file_exists_case data then | |
4535 | 5178 | begin |
4536 | 5179 | info |
4537 | 5180 | (f_ "Removing file '%s'") |
4554 | 5197 | info |
4555 | 5198 | (f_ "Removing directory '%s'") |
4556 | 5199 | data; |
4557 | BaseFileUtil.rmdir data | |
5200 | OASISFileUtil.rmdir ~ctxt:!BaseContext.default data | |
4558 | 5201 | end |
4559 | 5202 | else |
4560 | 5203 | begin |
4577 | 5220 | else if ev = install_findlib_ev then |
4578 | 5221 | begin |
4579 | 5222 | info (f_ "Removing findlib library '%s'") data; |
4580 | BaseExec.run (ocamlfind ()) ["remove"; data] | |
5223 | OASISExec.run ~ctxt:!BaseContext.default | |
5224 | (ocamlfind ()) ["remove"; data] | |
4581 | 5225 | end |
4582 | 5226 | else |
4583 | 5227 | failwithf (f_ "Unknown log event '%s'") ev; |
4588 | 5232 | [install_file_ev; |
4589 | 5233 | install_dir_ev; |
4590 | 5234 | install_findlib_ev;])) |
4591 | ||
5235 | ||
4592 | 5236 | end |
4593 | 5237 | |
4594 | 5238 | |
5239 | # 5233 "setup.ml" | |
4595 | 5240 | module OCamlbuildCommon = struct |
4596 | # 21 "/home/dim/sources/oasis/src/plugins/ocamlbuild/OCamlbuildCommon.ml" | |
4597 | ||
5241 | (* # 21 "/mnt/local/sda1/jdimino/dot-opam/4.01.0dev+short-paths/build/oasis.0.3.0/src/plugins/ocamlbuild/OCamlbuildCommon.ml" *) | |
5242 | ||
4598 | 5243 | (** Functions common to OCamlbuild build and doc plugin |
4599 | 5244 | *) |
4600 | ||
5245 | ||
4601 | 5246 | open OASISGettext |
4602 | 5247 | open BaseEnv |
4603 | 5248 | open BaseStandardVar |
4604 | ||
5249 | ||
4605 | 5250 | let ocamlbuild_clean_ev = |
4606 | 5251 | "ocamlbuild-clean" |
4607 | ||
5252 | ||
4608 | 5253 | let ocamlbuildflags = |
4609 | 5254 | var_define |
4610 | 5255 | ~short_desc:(fun () -> "OCamlbuild additional flags") |
4611 | 5256 | "ocamlbuildflags" |
4612 | (lazy "") | |
4613 | ||
5257 | (fun () -> "") | |
5258 | ||
4614 | 5259 | (** Fix special arguments depending on environment *) |
4615 | 5260 | let fix_args args extra_argv = |
4616 | 5261 | List.flatten |
4625 | 5270 | ] |
4626 | 5271 | else |
4627 | 5272 | []; |
4628 | ||
5273 | ||
4629 | 5274 | if not (bool_of_string (is_native ())) || (os_type ()) = "Win32" then |
4630 | 5275 | [ |
4631 | 5276 | "-byte-plugin" |
4633 | 5278 | else |
4634 | 5279 | []; |
4635 | 5280 | args; |
4636 | ||
5281 | ||
4637 | 5282 | if bool_of_string (debug ()) then |
4638 | 5283 | ["-tag"; "debug"] |
4639 | 5284 | else |
4640 | 5285 | []; |
4641 | ||
5286 | ||
4642 | 5287 | if bool_of_string (profile ()) then |
4643 | 5288 | ["-tag"; "profile"] |
4644 | 5289 | else |
4645 | 5290 | []; |
4646 | ||
4647 | OASISUtils.split ' ' (ocamlbuildflags ()); | |
4648 | ||
5291 | ||
5292 | OASISString.nsplit (ocamlbuildflags ()) ' '; | |
5293 | ||
4649 | 5294 | Array.to_list extra_argv; |
4650 | 5295 | ] |
4651 | ||
5296 | ||
4652 | 5297 | (** Run 'ocamlbuild -clean' if not already done *) |
4653 | 5298 | let run_clean extra_argv = |
4654 | 5299 | let extra_cli = |
4657 | 5302 | (* Run if never called with these args *) |
4658 | 5303 | if not (BaseLog.exists ocamlbuild_clean_ev extra_cli) then |
4659 | 5304 | begin |
4660 | BaseExec.run (ocamlbuild ()) (fix_args ["-clean"] extra_argv); | |
5305 | OASISExec.run ~ctxt:!BaseContext.default | |
5306 | (ocamlbuild ()) (fix_args ["-clean"] extra_argv); | |
4661 | 5307 | BaseLog.register ocamlbuild_clean_ev extra_cli; |
4662 | 5308 | at_exit |
4663 | 5309 | (fun () -> |
4666 | 5312 | with _ -> |
4667 | 5313 | ()) |
4668 | 5314 | end |
4669 | ||
5315 | ||
4670 | 5316 | (** Run ocamlbuild, unregister all clean events *) |
4671 | 5317 | let run_ocamlbuild args extra_argv = |
4672 | 5318 | (* TODO: enforce that target in args must be UNIX encoded i.e. toto/index.html |
4673 | 5319 | *) |
4674 | BaseExec.run (ocamlbuild ()) (fix_args args extra_argv); | |
5320 | OASISExec.run ~ctxt:!BaseContext.default | |
5321 | (ocamlbuild ()) (fix_args args extra_argv); | |
4675 | 5322 | (* Remove any clean event, we must run it again *) |
4676 | 5323 | List.iter |
4677 | 5324 | (fun (e, d) -> BaseLog.unregister e d) |
4678 | 5325 | (BaseLog.filter [ocamlbuild_clean_ev]) |
4679 | ||
5326 | ||
4680 | 5327 | (** Determine real build directory *) |
4681 | 5328 | let build_dir extra_argv = |
4682 | 5329 | let rec search_args dir = |
4689 | 5336 | dir |
4690 | 5337 | in |
4691 | 5338 | search_args "_build" (fix_args [] extra_argv) |
4692 | ||
5339 | ||
4693 | 5340 | end |
4694 | 5341 | |
4695 | 5342 | module OCamlbuildPlugin = struct |
4696 | # 21 "/home/dim/sources/oasis/src/plugins/ocamlbuild/OCamlbuildPlugin.ml" | |
4697 | ||
5343 | (* # 21 "/mnt/local/sda1/jdimino/dot-opam/4.01.0dev+short-paths/build/oasis.0.3.0/src/plugins/ocamlbuild/OCamlbuildPlugin.ml" *) | |
5344 | ||
4698 | 5345 | (** Build using ocamlbuild |
4699 | 5346 | @author Sylvain Le Gall |
4700 | 5347 | *) |
4701 | ||
5348 | ||
4702 | 5349 | open OASISTypes |
4703 | 5350 | open OASISGettext |
4704 | 5351 | open OASISUtils |
4706 | 5353 | open OCamlbuildCommon |
4707 | 5354 | open BaseStandardVar |
4708 | 5355 | open BaseMessage |
4709 | ||
5356 | ||
4710 | 5357 | let cond_targets_hook = |
4711 | 5358 | ref (fun lst -> lst) |
4712 | ||
5359 | ||
4713 | 5360 | let build pkg argv = |
4714 | ||
5361 | ||
4715 | 5362 | (* Return the filename in build directory *) |
4716 | 5363 | let in_build_dir fn = |
4717 | 5364 | Filename.concat |
4718 | 5365 | (build_dir argv) |
4719 | 5366 | fn |
4720 | 5367 | in |
4721 | ||
5368 | ||
4722 | 5369 | (* Return the unix filename in host build directory *) |
4723 | 5370 | let in_build_dir_of_unix fn = |
4724 | in_build_dir (BaseFilePath.of_unix fn) | |
4725 | in | |
4726 | ||
5371 | in_build_dir (OASISHostPath.of_unix fn) | |
5372 | in | |
5373 | ||
4727 | 5374 | let cond_targets = |
4728 | 5375 | List.fold_left |
4729 | 5376 | (fun acc -> |
4735 | 5382 | in_build_dir_of_unix |
4736 | 5383 | (cs, bs, lib) |
4737 | 5384 | in |
4738 | ||
5385 | ||
4739 | 5386 | let ends_with nd fn = |
4740 | 5387 | let nd_len = |
4741 | 5388 | String.length nd |
4747 | 5394 | (String.length fn - nd_len) |
4748 | 5395 | nd_len) = nd |
4749 | 5396 | in |
4750 | ||
5397 | ||
4751 | 5398 | let tgts = |
4752 | 5399 | List.flatten |
4753 | 5400 | (List.filter |
4755 | 5402 | (List.map |
4756 | 5403 | (List.filter |
4757 | 5404 | (fun fn -> |
4758 | ends_with ".cma" fn || | |
4759 | ends_with ".cmxa" fn || | |
4760 | ends_with ".cmxs" fn || | |
4761 | ends_with (ext_lib ()) fn || | |
4762 | ends_with (ext_dll ()) fn)) | |
5405 | ends_with ".cma" fn | |
5406 | || ends_with ".cmxs" fn | |
5407 | || ends_with ".cmxa" fn | |
5408 | || ends_with (ext_lib ()) fn | |
5409 | || ends_with (ext_dll ()) fn)) | |
4763 | 5410 | unix_files)) |
4764 | 5411 | in |
4765 | ||
5412 | ||
4766 | 5413 | match tgts with |
4767 | 5414 | | _ :: _ -> |
4768 | 5415 | (evs, tgts) :: acc |
4771 | 5418 | (f_ "No possible ocamlbuild targets for library %s") |
4772 | 5419 | cs.cs_name |
4773 | 5420 | end |
4774 | ||
5421 | ||
4775 | 5422 | | Executable (cs, bs, exec) when var_choose bs.bs_build -> |
4776 | 5423 | begin |
4777 | 5424 | let evs, unix_exec_is, unix_dll_opt = |
4779 | 5426 | in_build_dir_of_unix |
4780 | 5427 | (cs, bs, exec) |
4781 | 5428 | in |
4782 | ||
5429 | ||
4783 | 5430 | let target ext = |
4784 | 5431 | let unix_tgt = |
4785 | (BaseFilePath.Unix.concat | |
5432 | (OASISUnixPath.concat | |
4786 | 5433 | bs.bs_path |
4787 | (BaseFilePath.Unix.chop_extension | |
5434 | (OASISUnixPath.chop_extension | |
4788 | 5435 | exec.exec_main_is))^ext |
4789 | 5436 | in |
4790 | 5437 | let evs = |
4799 | 5446 | in |
4800 | 5447 | evs, [unix_tgt] |
4801 | 5448 | in |
4802 | ||
5449 | ||
4803 | 5450 | (* Add executable *) |
4804 | 5451 | let acc = |
4805 | 5452 | match bs.bs_compiled_object with |
4813 | 5460 | in |
4814 | 5461 | acc |
4815 | 5462 | end |
4816 | ||
5463 | ||
4817 | 5464 | | Library _ | Executable _ | Test _ |
4818 | 5465 | | SrcRepo _ | Flag _ | Doc _ -> |
4819 | 5466 | acc) |
4821 | 5468 | (* Keep the pkg.sections ordered *) |
4822 | 5469 | (List.rev pkg.sections); |
4823 | 5470 | in |
4824 | ||
5471 | ||
4825 | 5472 | (* Check and register built files *) |
4826 | 5473 | let check_and_register (bt, bnm, lst) = |
4827 | 5474 | List.iter |
4828 | 5475 | (fun fns -> |
4829 | if not (List.exists Sys.file_exists fns) then | |
5476 | if not (List.exists OASISFileUtil.file_exists_case fns) then | |
4830 | 5477 | failwithf |
4831 | 5478 | (f_ "No one of expected built files %s exists") |
4832 | 5479 | (String.concat (s_ ", ") (List.map (Printf.sprintf "'%s'") fns))) |
4833 | 5480 | lst; |
4834 | 5481 | (BaseBuilt.register bt bnm lst) |
4835 | 5482 | in |
4836 | ||
5483 | ||
4837 | 5484 | let cond_targets = |
4838 | 5485 | (* Run the hook *) |
4839 | 5486 | !cond_targets_hook cond_targets |
4840 | 5487 | in |
4841 | ||
5488 | ||
4842 | 5489 | (* Run a list of target... *) |
4843 | 5490 | run_ocamlbuild |
4844 | 5491 | (List.flatten |
4848 | 5495 | List.iter |
4849 | 5496 | check_and_register |
4850 | 5497 | (List.flatten (List.map fst cond_targets)) |
4851 | ||
4852 | ||
5498 | ||
5499 | ||
4853 | 5500 | let clean pkg extra_args = |
4854 | 5501 | run_clean extra_args; |
4855 | 5502 | List.iter |
4862 | 5509 | | _ -> |
4863 | 5510 | ()) |
4864 | 5511 | pkg.sections |
4865 | ||
5512 | ||
4866 | 5513 | end |
4867 | 5514 | |
4868 | 5515 | module OCamlbuildDocPlugin = struct |
4869 | # 21 "/home/dim/sources/oasis/src/plugins/ocamlbuild/OCamlbuildDocPlugin.ml" | |
4870 | ||
5516 | (* # 21 "/mnt/local/sda1/jdimino/dot-opam/4.01.0dev+short-paths/build/oasis.0.3.0/src/plugins/ocamlbuild/OCamlbuildDocPlugin.ml" *) | |
5517 | ||
4871 | 5518 | (* Create documentation using ocamlbuild .odocl files |
4872 | 5519 | @author Sylvain Le Gall |
4873 | 5520 | *) |
4874 | ||
5521 | ||
4875 | 5522 | open OASISTypes |
4876 | 5523 | open OASISGettext |
4877 | 5524 | open OASISMessage |
4878 | 5525 | open OCamlbuildCommon |
4879 | 5526 | open BaseStandardVar |
4880 | ||
4881 | ||
4882 | ||
5527 | ||
5528 | ||
5529 | ||
4883 | 5530 | let doc_build path pkg (cs, doc) argv = |
4884 | 5531 | let index_html = |
4885 | BaseFilePath.Unix.make | |
5532 | OASISUnixPath.make | |
4886 | 5533 | [ |
4887 | 5534 | path; |
4888 | 5535 | cs.cs_name^".docdir"; |
4890 | 5537 | ] |
4891 | 5538 | in |
4892 | 5539 | let tgt_dir = |
4893 | BaseFilePath.make | |
5540 | OASISHostPath.make | |
4894 | 5541 | [ |
4895 | 5542 | build_dir argv; |
4896 | BaseFilePath.of_unix path; | |
5543 | OASISHostPath.of_unix path; | |
4897 | 5544 | cs.cs_name^".docdir"; |
4898 | 5545 | ] |
4899 | 5546 | in |
4903 | 5550 | BaseBuilt.register |
4904 | 5551 | BaseBuilt.BDoc |
4905 | 5552 | cs.cs_name |
4906 | [BaseFileUtil.glob | |
5553 | [OASISFileUtil.glob ~ctxt:!BaseContext.default | |
4907 | 5554 | (Filename.concat tgt_dir glb)]) |
4908 | 5555 | ["*.html"; "*.css"] |
4909 | ||
5556 | ||
4910 | 5557 | let doc_clean t pkg (cs, doc) argv = |
4911 | 5558 | run_clean argv; |
4912 | 5559 | BaseBuilt.unregister BaseBuilt.BDoc cs.cs_name |
4913 | ||
5560 | ||
4914 | 5561 | end |
4915 | 5562 | |
4916 | 5563 | |
5564 | # 5558 "setup.ml" | |
4917 | 5565 | module CustomPlugin = struct |
4918 | # 21 "/home/dim/sources/oasis/src/plugins/custom/CustomPlugin.ml" | |
4919 | ||
5566 | (* # 21 "/mnt/local/sda1/jdimino/dot-opam/4.01.0dev+short-paths/build/oasis.0.3.0/src/plugins/custom/CustomPlugin.ml" *) | |
5567 | ||
4920 | 5568 | (** Generate custom configure/build/doc/test/install system |
4921 | 5569 | @author |
4922 | 5570 | *) |
4923 | ||
5571 | ||
4924 | 5572 | open BaseEnv |
4925 | 5573 | open OASISGettext |
4926 | 5574 | open OASISTypes |
4927 | ||
4928 | ||
4929 | ||
5575 | ||
5576 | ||
5577 | ||
4930 | 5578 | type t = |
4931 | 5579 | { |
4932 | 5580 | cmd_main: command_line conditional; |
4933 | 5581 | cmd_clean: (command_line option) conditional; |
4934 | 5582 | cmd_distclean: (command_line option) conditional; |
4935 | 5583 | } |
4936 | ||
5584 | ||
4937 | 5585 | let run = BaseCustom.run |
4938 | ||
5586 | ||
4939 | 5587 | let main t _ extra_args = |
4940 | 5588 | let cmd, args = |
4941 | 5589 | var_choose |
4943 | 5591 | t.cmd_main |
4944 | 5592 | in |
4945 | 5593 | run cmd args extra_args |
4946 | ||
5594 | ||
4947 | 5595 | let clean t pkg extra_args = |
4948 | 5596 | match var_choose t.cmd_clean with |
4949 | 5597 | | Some (cmd, args) -> |
4950 | 5598 | run cmd args extra_args |
4951 | 5599 | | _ -> |
4952 | 5600 | () |
4953 | ||
5601 | ||
4954 | 5602 | let distclean t pkg extra_args = |
4955 | 5603 | match var_choose t.cmd_distclean with |
4956 | 5604 | | Some (cmd, args) -> |
4957 | 5605 | run cmd args extra_args |
4958 | 5606 | | _ -> |
4959 | 5607 | () |
4960 | ||
5608 | ||
4961 | 5609 | module Build = |
4962 | 5610 | struct |
4963 | 5611 | let main t pkg extra_args = |
4970 | 5618 | begin |
4971 | 5619 | let evs, _ = |
4972 | 5620 | BaseBuilt.of_library |
4973 | BaseFilePath.of_unix | |
5621 | OASISHostPath.of_unix | |
4974 | 5622 | (cs, bs, lib) |
4975 | 5623 | in |
4976 | 5624 | evs |
4979 | 5627 | begin |
4980 | 5628 | let evs, _, _ = |
4981 | 5629 | BaseBuilt.of_executable |
4982 | BaseFilePath.of_unix | |
5630 | OASISHostPath.of_unix | |
4983 | 5631 | (cs, bs, exec) |
4984 | 5632 | in |
4985 | 5633 | evs |
4991 | 5639 | (fun (bt, bnm, lst) -> BaseBuilt.register bt bnm lst) |
4992 | 5640 | evs) |
4993 | 5641 | pkg.sections |
4994 | ||
5642 | ||
4995 | 5643 | let clean t pkg extra_args = |
4996 | 5644 | clean t pkg extra_args; |
4997 | 5645 | (* TODO: this seems to be pretty generic (at least wrt to ocamlbuild |
5007 | 5655 | | _ -> |
5008 | 5656 | ()) |
5009 | 5657 | pkg.sections |
5010 | ||
5658 | ||
5011 | 5659 | let distclean t pkg extra_args = |
5012 | 5660 | distclean t pkg extra_args |
5013 | 5661 | end |
5014 | ||
5662 | ||
5015 | 5663 | module Test = |
5016 | 5664 | struct |
5017 | 5665 | let main t pkg (cs, test) extra_args = |
5024 | 5672 | cs.cs_name |
5025 | 5673 | s; |
5026 | 5674 | 1.0 |
5027 | ||
5675 | ||
5028 | 5676 | let clean t pkg (cs, test) extra_args = |
5029 | 5677 | clean t pkg extra_args |
5030 | ||
5678 | ||
5031 | 5679 | let distclean t pkg (cs, test) extra_args = |
5032 | 5680 | distclean t pkg extra_args |
5033 | 5681 | end |
5034 | ||
5682 | ||
5035 | 5683 | module Doc = |
5036 | 5684 | struct |
5037 | 5685 | let main t pkg (cs, _) extra_args = |
5038 | 5686 | main t pkg extra_args; |
5039 | 5687 | BaseBuilt.register BaseBuilt.BDoc cs.cs_name [] |
5040 | ||
5688 | ||
5041 | 5689 | let clean t pkg (cs, _) extra_args = |
5042 | 5690 | clean t pkg extra_args; |
5043 | 5691 | BaseBuilt.unregister BaseBuilt.BDoc cs.cs_name |
5044 | ||
5692 | ||
5045 | 5693 | let distclean t pkg (cs, _) extra_args = |
5046 | 5694 | distclean t pkg extra_args |
5047 | 5695 | end |
5048 | ||
5696 | ||
5049 | 5697 | end |
5050 | 5698 | |
5051 | 5699 | |
5700 | # 5694 "setup.ml" | |
5052 | 5701 | open OASISTypes;; |
5053 | 5702 | |
5054 | 5703 | let setup_t = |
5059 | 5708 | doc = |
5060 | 5709 | [ |
5061 | 5710 | ("lambda-term-api", OCamlbuildDocPlugin.doc_build "./"); |
5062 | ("lamda-term-inputrc", | |
5711 | ("lambda-term-actions-man", | |
5063 | 5712 | CustomPlugin.Doc.main |
5064 | 5713 | { |
5065 | 5714 | CustomPlugin.cmd_main = |
5066 | [(OASISExpr.EBool true, ("true", []))]; | |
5067 | cmd_clean = [(OASISExpr.EBool true, None)]; | |
5715 | [ | |
5716 | (OASISExpr.EBool true, | |
5717 | ("$gzip", | |
5718 | [ | |
5719 | "-c"; | |
5720 | "man/lambda-term-actions.1"; | |
5721 | ">"; | |
5722 | "man/lambda-term-actions.1.gz" | |
5723 | ])) | |
5724 | ]; | |
5725 | cmd_clean = | |
5726 | [ | |
5727 | (OASISExpr.EBool true, | |
5728 | Some (("$rm", ["man/lambda-term-actions.1.gz"]))) | |
5729 | ]; | |
5068 | 5730 | cmd_distclean = [(OASISExpr.EBool true, None)]; |
5069 | 5731 | }); |
5070 | 5732 | ("lambda-term-inputrc-man", |
5088 | 5750 | ]; |
5089 | 5751 | cmd_distclean = [(OASISExpr.EBool true, None)]; |
5090 | 5752 | }); |
5753 | ("lamda-term-inputrc", | |
5754 | CustomPlugin.Doc.main | |
5755 | { | |
5756 | CustomPlugin.cmd_main = | |
5757 | [(OASISExpr.EBool true, ("true", []))]; | |
5758 | cmd_clean = [(OASISExpr.EBool true, None)]; | |
5759 | cmd_distclean = [(OASISExpr.EBool true, None)]; | |
5760 | }) | |
5761 | ]; | |
5762 | install = InternalInstallPlugin.install; | |
5763 | uninstall = InternalInstallPlugin.uninstall; | |
5764 | clean = [OCamlbuildPlugin.clean]; | |
5765 | clean_test = []; | |
5766 | clean_doc = | |
5767 | [ | |
5768 | ("lambda-term-api", OCamlbuildDocPlugin.doc_clean "./"); | |
5091 | 5769 | ("lambda-term-actions-man", |
5092 | CustomPlugin.Doc.main | |
5770 | CustomPlugin.Doc.clean | |
5093 | 5771 | { |
5094 | 5772 | CustomPlugin.cmd_main = |
5095 | 5773 | [ |
5107 | 5785 | (OASISExpr.EBool true, |
5108 | 5786 | Some (("$rm", ["man/lambda-term-actions.1.gz"]))) |
5109 | 5787 | ]; |
5110 | cmd_distclean = [(OASISExpr.EBool true, None)]; | |
5111 | }) | |
5112 | ]; | |
5113 | install = InternalInstallPlugin.install; | |
5114 | uninstall = InternalInstallPlugin.uninstall; | |
5115 | clean = [OCamlbuildPlugin.clean]; | |
5116 | clean_test = []; | |
5117 | clean_doc = | |
5118 | [ | |
5119 | ("lambda-term-api", OCamlbuildDocPlugin.doc_clean "./"); | |
5120 | ("lamda-term-inputrc", | |
5121 | CustomPlugin.Doc.clean | |
5122 | { | |
5123 | CustomPlugin.cmd_main = | |
5124 | [(OASISExpr.EBool true, ("true", []))]; | |
5125 | cmd_clean = [(OASISExpr.EBool true, None)]; | |
5126 | 5788 | cmd_distclean = [(OASISExpr.EBool true, None)]; |
5127 | 5789 | }); |
5128 | 5790 | ("lambda-term-inputrc-man", |
5146 | 5808 | ]; |
5147 | 5809 | cmd_distclean = [(OASISExpr.EBool true, None)]; |
5148 | 5810 | }); |
5811 | ("lamda-term-inputrc", | |
5812 | CustomPlugin.Doc.clean | |
5813 | { | |
5814 | CustomPlugin.cmd_main = | |
5815 | [(OASISExpr.EBool true, ("true", []))]; | |
5816 | cmd_clean = [(OASISExpr.EBool true, None)]; | |
5817 | cmd_distclean = [(OASISExpr.EBool true, None)]; | |
5818 | }) | |
5819 | ]; | |
5820 | distclean = []; | |
5821 | distclean_test = []; | |
5822 | distclean_doc = | |
5823 | [ | |
5149 | 5824 | ("lambda-term-actions-man", |
5150 | CustomPlugin.Doc.clean | |
5825 | CustomPlugin.Doc.distclean | |
5151 | 5826 | { |
5152 | 5827 | CustomPlugin.cmd_main = |
5153 | 5828 | [ |
5165 | 5840 | (OASISExpr.EBool true, |
5166 | 5841 | Some (("$rm", ["man/lambda-term-actions.1.gz"]))) |
5167 | 5842 | ]; |
5168 | cmd_distclean = [(OASISExpr.EBool true, None)]; | |
5169 | }) | |
5170 | ]; | |
5171 | distclean = []; | |
5172 | distclean_test = []; | |
5173 | distclean_doc = | |
5174 | [ | |
5175 | ("lamda-term-inputrc", | |
5176 | CustomPlugin.Doc.distclean | |
5177 | { | |
5178 | CustomPlugin.cmd_main = | |
5179 | [(OASISExpr.EBool true, ("true", []))]; | |
5180 | cmd_clean = [(OASISExpr.EBool true, None)]; | |
5181 | 5843 | cmd_distclean = [(OASISExpr.EBool true, None)]; |
5182 | 5844 | }); |
5183 | 5845 | ("lambda-term-inputrc-man", |
5201 | 5863 | ]; |
5202 | 5864 | cmd_distclean = [(OASISExpr.EBool true, None)]; |
5203 | 5865 | }); |
5204 | ("lambda-term-actions-man", | |
5866 | ("lamda-term-inputrc", | |
5205 | 5867 | CustomPlugin.Doc.distclean |
5206 | 5868 | { |
5207 | 5869 | CustomPlugin.cmd_main = |
5208 | [ | |
5209 | (OASISExpr.EBool true, | |
5210 | ("$gzip", | |
5211 | [ | |
5212 | "-c"; | |
5213 | "man/lambda-term-actions.1"; | |
5214 | ">"; | |
5215 | "man/lambda-term-actions.1.gz" | |
5216 | ])) | |
5217 | ]; | |
5218 | cmd_clean = | |
5219 | [ | |
5220 | (OASISExpr.EBool true, | |
5221 | Some (("$rm", ["man/lambda-term-actions.1.gz"]))) | |
5222 | ]; | |
5870 | [(OASISExpr.EBool true, ("true", []))]; | |
5871 | cmd_clean = [(OASISExpr.EBool true, None)]; | |
5223 | 5872 | cmd_distclean = [(OASISExpr.EBool true, None)]; |
5224 | 5873 | }) |
5225 | 5874 | ]; |
5226 | 5875 | package = |
5227 | 5876 | { |
5228 | oasis_version = "0.1"; | |
5877 | oasis_version = "0.3"; | |
5229 | 5878 | ocaml_version = Some (OASISVersion.VGreaterEqual "3.12"); |
5230 | 5879 | findlib_version = None; |
5231 | 5880 | name = "lambda-term"; |
5232 | version = "1.1"; | |
5881 | version = "1.4"; | |
5233 | 5882 | license = |
5234 | 5883 | OASISLicense.DEP5License |
5235 | { | |
5236 | OASISLicense.license = "BSD3"; | |
5237 | exceptions = []; | |
5238 | version = OASISLicense.NoVersion; | |
5239 | }; | |
5884 | (OASISLicense.DEP5Unit | |
5885 | { | |
5886 | OASISLicense.license = "BSD3"; | |
5887 | excption = None; | |
5888 | version = OASISLicense.NoVersion; | |
5889 | }); | |
5240 | 5890 | license_file = Some "LICENSE"; |
5241 | 5891 | copyrights = []; |
5242 | 5892 | maintainers = []; |
5243 | 5893 | authors = ["J\195\169r\195\169mie Dimino"]; |
5244 | 5894 | homepage = Some "http://lambda-term.forge.ocamlcore.org/"; |
5245 | synopsis = "Lambda-Term"; | |
5895 | synopsis = "Terminal manipulation library for OCaml"; | |
5246 | 5896 | description = |
5247 | Some "Corss-platform library for terminal manipulation"; | |
5897 | Some | |
5898 | "Lambda-term is a cross-platform library for manipulating the\nterminal. It provides an abstraction for keys, mouse events, colors,\nas well as a set of widgets to write curses-like applications.\n\nThe main objective of lambda-term is to provide a higher level\nfunctional interface to terminal manipulation than, for example,\nncurses, by providing a native OCaml interface instead of bindings to\na C library.\n\nLambda-term integrates with zed to provide text edition facilities in\nconsole applications."; | |
5248 | 5899 | categories = []; |
5249 | conf_type = (`Configure, "internal", Some "0.2"); | |
5900 | conf_type = (`Configure, "internal", Some "0.3"); | |
5250 | 5901 | conf_custom = |
5251 | 5902 | { |
5252 | 5903 | pre_command = [(OASISExpr.EBool true, None)]; |
5253 | 5904 | post_command = [(OASISExpr.EBool true, None)]; |
5254 | 5905 | }; |
5255 | build_type = (`Build, "ocamlbuild", Some "0.2"); | |
5906 | build_type = (`Build, "ocamlbuild", Some "0.3"); | |
5256 | 5907 | build_custom = |
5257 | 5908 | { |
5258 | 5909 | pre_command = [(OASISExpr.EBool true, None)]; |
5259 | 5910 | post_command = [(OASISExpr.EBool true, None)]; |
5260 | 5911 | }; |
5261 | install_type = (`Install, "internal", Some "0.2"); | |
5912 | install_type = (`Install, "internal", Some "0.3"); | |
5262 | 5913 | install_custom = |
5263 | 5914 | { |
5264 | 5915 | pre_command = [(OASISExpr.EBool true, None)]; |
5297 | 5948 | [ |
5298 | 5949 | FindlibPackage |
5299 | 5950 | ("lwt", |
5300 | Some (OASISVersion.VGreaterEqual "2.3.0")); | |
5951 | Some (OASISVersion.VGreaterEqual "2.4.0")); | |
5301 | 5952 | FindlibPackage ("lwt.unix", None); |
5302 | 5953 | FindlibPackage ("lwt.syntax", None); |
5303 | 5954 | FindlibPackage ("lwt.react", None); |
5304 | 5955 | FindlibPackage |
5305 | ("zed", Some (OASISVersion.VGreaterEqual "1.1")) | |
5956 | ("zed", Some (OASISVersion.VGreaterEqual "1.2")) | |
5306 | 5957 | ]; |
5307 | 5958 | bs_build_tools = [ExternalTool "ocamlbuild"]; |
5308 | 5959 | bs_c_sources = |
5309 | 5960 | [ |
5310 | 5961 | "lTerm_term_stubs.c"; |
5311 | 5962 | "lTerm_unix_stubs.c"; |
5312 | "lTerm_windows_stubs.c"; | |
5313 | "lTerm_iconv_stubs.c" | |
5963 | "lTerm_windows_stubs.c" | |
5314 | 5964 | ]; |
5315 | 5965 | bs_data_files = []; |
5316 | 5966 | bs_ccopt = [(OASISExpr.EBool true, [])]; |
5328 | 5978 | "LTerm_event"; |
5329 | 5979 | "LTerm_unix"; |
5330 | 5980 | "LTerm_windows"; |
5331 | "LTerm_iconv"; | |
5332 | 5981 | "LTerm_style"; |
5333 | 5982 | "LTerm_geom"; |
5334 | 5983 | "LTerm_draw"; |
5335 | 5984 | "LTerm_mouse"; |
5336 | "LTerm_color_mappings"; | |
5337 | 5985 | "LTerm_widget"; |
5338 | 5986 | "LTerm_edit"; |
5339 | 5987 | "LTerm_read_line"; |
5340 | 5988 | "LTerm_text"; |
5341 | 5989 | "LTerm_ui"; |
5342 | 5990 | "LTerm_resources"; |
5343 | "LTerm_inputrc" | |
5991 | "LTerm_inputrc"; | |
5992 | "LTerm_history" | |
5344 | 5993 | ]; |
5345 | lib_internal_modules = ["LTerm_resource_lexer"]; | |
5994 | lib_pack = false; | |
5995 | lib_internal_modules = | |
5996 | ["LTerm_color_mappings"; "LTerm_resource_lexer"]; | |
5346 | 5997 | lib_findlib_parent = None; |
5347 | 5998 | lib_findlib_name = Some "lambda-term"; |
5348 | 5999 | lib_findlib_containers = []; |
5349 | 6000 | }); |
6001 | Executable | |
6002 | ({ | |
6003 | cs_name = "events"; | |
6004 | cs_data = PropList.Data.create (); | |
6005 | cs_plugin_data = []; | |
6006 | }, | |
6007 | { | |
6008 | bs_build = [(OASISExpr.EBool true, true)]; | |
6009 | bs_install = [(OASISExpr.EBool true, false)]; | |
6010 | bs_path = "examples"; | |
6011 | bs_compiled_object = Best; | |
6012 | bs_build_depends = [InternalLibrary "lambda-term"]; | |
6013 | bs_build_tools = [ExternalTool "ocamlbuild"]; | |
6014 | bs_c_sources = []; | |
6015 | bs_data_files = []; | |
6016 | bs_ccopt = [(OASISExpr.EBool true, [])]; | |
6017 | bs_cclib = [(OASISExpr.EBool true, [])]; | |
6018 | bs_dlllib = [(OASISExpr.EBool true, [])]; | |
6019 | bs_dllpath = [(OASISExpr.EBool true, [])]; | |
6020 | bs_byteopt = [(OASISExpr.EBool true, [])]; | |
6021 | bs_nativeopt = [(OASISExpr.EBool true, [])]; | |
6022 | }, | |
6023 | {exec_custom = false; exec_main_is = "events.ml"; }); | |
6024 | Executable | |
6025 | ({ | |
6026 | cs_name = "colors"; | |
6027 | cs_data = PropList.Data.create (); | |
6028 | cs_plugin_data = []; | |
6029 | }, | |
6030 | { | |
6031 | bs_build = [(OASISExpr.EBool true, true)]; | |
6032 | bs_install = [(OASISExpr.EBool true, false)]; | |
6033 | bs_path = "examples"; | |
6034 | bs_compiled_object = Best; | |
6035 | bs_build_depends = [InternalLibrary "lambda-term"]; | |
6036 | bs_build_tools = [ExternalTool "ocamlbuild"]; | |
6037 | bs_c_sources = []; | |
6038 | bs_data_files = []; | |
6039 | bs_ccopt = [(OASISExpr.EBool true, [])]; | |
6040 | bs_cclib = [(OASISExpr.EBool true, [])]; | |
6041 | bs_dlllib = [(OASISExpr.EBool true, [])]; | |
6042 | bs_dllpath = [(OASISExpr.EBool true, [])]; | |
6043 | bs_byteopt = [(OASISExpr.EBool true, [])]; | |
6044 | bs_nativeopt = [(OASISExpr.EBool true, [])]; | |
6045 | }, | |
6046 | {exec_custom = false; exec_main_is = "colors.ml"; }); | |
6047 | Executable | |
6048 | ({ | |
6049 | cs_name = "colors_256"; | |
6050 | cs_data = PropList.Data.create (); | |
6051 | cs_plugin_data = []; | |
6052 | }, | |
6053 | { | |
6054 | bs_build = [(OASISExpr.EBool true, true)]; | |
6055 | bs_install = [(OASISExpr.EBool true, false)]; | |
6056 | bs_path = "examples"; | |
6057 | bs_compiled_object = Best; | |
6058 | bs_build_depends = [InternalLibrary "lambda-term"]; | |
6059 | bs_build_tools = [ExternalTool "ocamlbuild"]; | |
6060 | bs_c_sources = []; | |
6061 | bs_data_files = []; | |
6062 | bs_ccopt = [(OASISExpr.EBool true, [])]; | |
6063 | bs_cclib = [(OASISExpr.EBool true, [])]; | |
6064 | bs_dlllib = [(OASISExpr.EBool true, [])]; | |
6065 | bs_dllpath = [(OASISExpr.EBool true, [])]; | |
6066 | bs_byteopt = [(OASISExpr.EBool true, [])]; | |
6067 | bs_nativeopt = [(OASISExpr.EBool true, [])]; | |
6068 | }, | |
6069 | {exec_custom = false; exec_main_is = "colors_256.ml"; }); | |
6070 | Executable | |
6071 | ({ | |
6072 | cs_name = "rgb"; | |
6073 | cs_data = PropList.Data.create (); | |
6074 | cs_plugin_data = []; | |
6075 | }, | |
6076 | { | |
6077 | bs_build = [(OASISExpr.EBool true, true)]; | |
6078 | bs_install = [(OASISExpr.EBool true, false)]; | |
6079 | bs_path = "examples"; | |
6080 | bs_compiled_object = Best; | |
6081 | bs_build_depends = [InternalLibrary "lambda-term"]; | |
6082 | bs_build_tools = [ExternalTool "ocamlbuild"]; | |
6083 | bs_c_sources = []; | |
6084 | bs_data_files = []; | |
6085 | bs_ccopt = [(OASISExpr.EBool true, [])]; | |
6086 | bs_cclib = [(OASISExpr.EBool true, [])]; | |
6087 | bs_dlllib = [(OASISExpr.EBool true, [])]; | |
6088 | bs_dllpath = [(OASISExpr.EBool true, [])]; | |
6089 | bs_byteopt = [(OASISExpr.EBool true, [])]; | |
6090 | bs_nativeopt = [(OASISExpr.EBool true, [])]; | |
6091 | }, | |
6092 | {exec_custom = false; exec_main_is = "rgb.ml"; }); | |
6093 | Executable | |
6094 | ({ | |
6095 | cs_name = "move"; | |
6096 | cs_data = PropList.Data.create (); | |
6097 | cs_plugin_data = []; | |
6098 | }, | |
6099 | { | |
6100 | bs_build = [(OASISExpr.EBool true, true)]; | |
6101 | bs_install = [(OASISExpr.EBool true, false)]; | |
6102 | bs_path = "examples"; | |
6103 | bs_compiled_object = Best; | |
6104 | bs_build_depends = [InternalLibrary "lambda-term"]; | |
6105 | bs_build_tools = [ExternalTool "ocamlbuild"]; | |
6106 | bs_c_sources = []; | |
6107 | bs_data_files = []; | |
6108 | bs_ccopt = [(OASISExpr.EBool true, [])]; | |
6109 | bs_cclib = [(OASISExpr.EBool true, [])]; | |
6110 | bs_dlllib = [(OASISExpr.EBool true, [])]; | |
6111 | bs_dllpath = [(OASISExpr.EBool true, [])]; | |
6112 | bs_byteopt = [(OASISExpr.EBool true, [])]; | |
6113 | bs_nativeopt = [(OASISExpr.EBool true, [])]; | |
6114 | }, | |
6115 | {exec_custom = false; exec_main_is = "move.ml"; }); | |
6116 | Executable | |
6117 | ({ | |
6118 | cs_name = "hello"; | |
6119 | cs_data = PropList.Data.create (); | |
6120 | cs_plugin_data = []; | |
6121 | }, | |
6122 | { | |
6123 | bs_build = [(OASISExpr.EBool true, true)]; | |
6124 | bs_install = [(OASISExpr.EBool true, false)]; | |
6125 | bs_path = "examples"; | |
6126 | bs_compiled_object = Best; | |
6127 | bs_build_depends = [InternalLibrary "lambda-term"]; | |
6128 | bs_build_tools = [ExternalTool "ocamlbuild"]; | |
6129 | bs_c_sources = []; | |
6130 | bs_data_files = []; | |
6131 | bs_ccopt = [(OASISExpr.EBool true, [])]; | |
6132 | bs_cclib = [(OASISExpr.EBool true, [])]; | |
6133 | bs_dlllib = [(OASISExpr.EBool true, [])]; | |
6134 | bs_dllpath = [(OASISExpr.EBool true, [])]; | |
6135 | bs_byteopt = [(OASISExpr.EBool true, [])]; | |
6136 | bs_nativeopt = [(OASISExpr.EBool true, [])]; | |
6137 | }, | |
6138 | {exec_custom = false; exec_main_is = "hello.ml"; }); | |
6139 | Executable | |
6140 | ({ | |
6141 | cs_name = "clock"; | |
6142 | cs_data = PropList.Data.create (); | |
6143 | cs_plugin_data = []; | |
6144 | }, | |
6145 | { | |
6146 | bs_build = [(OASISExpr.EBool true, true)]; | |
6147 | bs_install = [(OASISExpr.EBool true, false)]; | |
6148 | bs_path = "examples"; | |
6149 | bs_compiled_object = Best; | |
6150 | bs_build_depends = [InternalLibrary "lambda-term"]; | |
6151 | bs_build_tools = [ExternalTool "ocamlbuild"]; | |
6152 | bs_c_sources = []; | |
6153 | bs_data_files = []; | |
6154 | bs_ccopt = [(OASISExpr.EBool true, [])]; | |
6155 | bs_cclib = [(OASISExpr.EBool true, [])]; | |
6156 | bs_dlllib = [(OASISExpr.EBool true, [])]; | |
6157 | bs_dllpath = [(OASISExpr.EBool true, [])]; | |
6158 | bs_byteopt = [(OASISExpr.EBool true, [])]; | |
6159 | bs_nativeopt = [(OASISExpr.EBool true, [])]; | |
6160 | }, | |
6161 | {exec_custom = false; exec_main_is = "clock.ml"; }); | |
6162 | Executable | |
6163 | ({ | |
6164 | cs_name = "buttons"; | |
6165 | cs_data = PropList.Data.create (); | |
6166 | cs_plugin_data = []; | |
6167 | }, | |
6168 | { | |
6169 | bs_build = [(OASISExpr.EBool true, true)]; | |
6170 | bs_install = [(OASISExpr.EBool true, false)]; | |
6171 | bs_path = "examples"; | |
6172 | bs_compiled_object = Best; | |
6173 | bs_build_depends = [InternalLibrary "lambda-term"]; | |
6174 | bs_build_tools = [ExternalTool "ocamlbuild"]; | |
6175 | bs_c_sources = []; | |
6176 | bs_data_files = []; | |
6177 | bs_ccopt = [(OASISExpr.EBool true, [])]; | |
6178 | bs_cclib = [(OASISExpr.EBool true, [])]; | |
6179 | bs_dlllib = [(OASISExpr.EBool true, [])]; | |
6180 | bs_dllpath = [(OASISExpr.EBool true, [])]; | |
6181 | bs_byteopt = [(OASISExpr.EBool true, [])]; | |
6182 | bs_nativeopt = [(OASISExpr.EBool true, [])]; | |
6183 | }, | |
6184 | {exec_custom = false; exec_main_is = "buttons.ml"; }); | |
5350 | 6185 | Executable |
5351 | 6186 | ({ |
5352 | 6187 | cs_name = "shell"; |
5376 | 6211 | {exec_custom = false; exec_main_is = "shell.ml"; }); |
5377 | 6212 | Executable |
5378 | 6213 | ({ |
5379 | cs_name = "events"; | |
5380 | cs_data = PropList.Data.create (); | |
5381 | cs_plugin_data = []; | |
5382 | }, | |
5383 | { | |
5384 | bs_build = [(OASISExpr.EBool true, true)]; | |
5385 | bs_install = [(OASISExpr.EBool true, false)]; | |
5386 | bs_path = "examples"; | |
5387 | bs_compiled_object = Best; | |
5388 | bs_build_depends = [InternalLibrary "lambda-term"]; | |
5389 | bs_build_tools = [ExternalTool "ocamlbuild"]; | |
5390 | bs_c_sources = []; | |
5391 | bs_data_files = []; | |
5392 | bs_ccopt = [(OASISExpr.EBool true, [])]; | |
5393 | bs_cclib = [(OASISExpr.EBool true, [])]; | |
5394 | bs_dlllib = [(OASISExpr.EBool true, [])]; | |
5395 | bs_dllpath = [(OASISExpr.EBool true, [])]; | |
5396 | bs_byteopt = [(OASISExpr.EBool true, [])]; | |
5397 | bs_nativeopt = [(OASISExpr.EBool true, [])]; | |
5398 | }, | |
5399 | {exec_custom = false; exec_main_is = "events.ml"; }); | |
5400 | Doc | |
5401 | ({ | |
5402 | cs_name = "lambda-term-api"; | |
5403 | cs_data = PropList.Data.create (); | |
5404 | cs_plugin_data = []; | |
5405 | }, | |
5406 | { | |
5407 | doc_type = (`Doc, "ocamlbuild", Some "0.2"); | |
5408 | doc_custom = | |
5409 | { | |
5410 | pre_command = [(OASISExpr.EBool true, None)]; | |
5411 | post_command = [(OASISExpr.EBool true, None)]; | |
5412 | }; | |
5413 | doc_build = [(OASISExpr.EBool true, true)]; | |
5414 | doc_install = [(OASISExpr.EBool true, true)]; | |
5415 | doc_install_dir = "$htmldir/api"; | |
5416 | doc_title = "API reference for Lambda-Term"; | |
5417 | doc_authors = []; | |
5418 | doc_abstract = None; | |
5419 | doc_format = OtherDoc; | |
5420 | doc_data_files = [("style.css", None)]; | |
5421 | doc_build_tools = | |
5422 | [ExternalTool "ocamlbuild"; ExternalTool "ocamldoc"]; | |
5423 | }); | |
5424 | Executable | |
5425 | ({ | |
5426 | cs_name = "clock"; | |
5427 | cs_data = PropList.Data.create (); | |
5428 | cs_plugin_data = []; | |
5429 | }, | |
5430 | { | |
5431 | bs_build = [(OASISExpr.EBool true, true)]; | |
5432 | bs_install = [(OASISExpr.EBool true, false)]; | |
5433 | bs_path = "examples"; | |
5434 | bs_compiled_object = Best; | |
5435 | bs_build_depends = [InternalLibrary "lambda-term"]; | |
5436 | bs_build_tools = [ExternalTool "ocamlbuild"]; | |
5437 | bs_c_sources = []; | |
5438 | bs_data_files = []; | |
5439 | bs_ccopt = [(OASISExpr.EBool true, [])]; | |
5440 | bs_cclib = [(OASISExpr.EBool true, [])]; | |
5441 | bs_dlllib = [(OASISExpr.EBool true, [])]; | |
5442 | bs_dllpath = [(OASISExpr.EBool true, [])]; | |
5443 | bs_byteopt = [(OASISExpr.EBool true, [])]; | |
5444 | bs_nativeopt = [(OASISExpr.EBool true, [])]; | |
5445 | }, | |
5446 | {exec_custom = false; exec_main_is = "clock.ml"; }); | |
5447 | SrcRepo | |
5448 | ({ | |
5449 | cs_name = "head"; | |
5450 | cs_data = PropList.Data.create (); | |
5451 | cs_plugin_data = []; | |
5452 | }, | |
5453 | { | |
5454 | src_repo_type = Darcs; | |
5455 | src_repo_location = | |
5456 | "http://darcs.ocamlcore.org/repos/lambda-term"; | |
5457 | src_repo_browser = | |
5458 | Some | |
5459 | "http://darcs.ocamlcore.org/cgi-bin/darcsweb.cgi?r=lambda-term;a=summary"; | |
5460 | src_repo_module = None; | |
5461 | src_repo_branch = None; | |
5462 | src_repo_tag = None; | |
5463 | src_repo_subdir = None; | |
5464 | }); | |
5465 | Doc | |
5466 | ({ | |
5467 | cs_name = "lamda-term-inputrc"; | |
5468 | cs_data = PropList.Data.create (); | |
5469 | cs_plugin_data = []; | |
5470 | }, | |
5471 | { | |
5472 | doc_type = (`Doc, "custom", Some "0.2"); | |
5473 | doc_custom = | |
5474 | { | |
5475 | pre_command = [(OASISExpr.EBool true, None)]; | |
5476 | post_command = [(OASISExpr.EBool true, None)]; | |
5477 | }; | |
5478 | doc_build = [(OASISExpr.EBool true, true)]; | |
5479 | doc_install = [(OASISExpr.EBool true, true)]; | |
5480 | doc_install_dir = "$docdir"; | |
5481 | doc_title = "lambda-term-inputrc example"; | |
5482 | doc_authors = []; | |
5483 | doc_abstract = None; | |
5484 | doc_format = OtherDoc; | |
5485 | doc_data_files = [("lambda-term-inputrc", None)]; | |
5486 | doc_build_tools = [ExternalTool "ocamlbuild"]; | |
5487 | }); | |
5488 | Executable | |
5489 | ({ | |
5490 | cs_name = "colors"; | |
5491 | cs_data = PropList.Data.create (); | |
5492 | cs_plugin_data = []; | |
5493 | }, | |
5494 | { | |
5495 | bs_build = [(OASISExpr.EBool true, true)]; | |
5496 | bs_install = [(OASISExpr.EBool true, false)]; | |
5497 | bs_path = "examples"; | |
5498 | bs_compiled_object = Best; | |
5499 | bs_build_depends = [InternalLibrary "lambda-term"]; | |
5500 | bs_build_tools = [ExternalTool "ocamlbuild"]; | |
5501 | bs_c_sources = []; | |
5502 | bs_data_files = []; | |
5503 | bs_ccopt = [(OASISExpr.EBool true, [])]; | |
5504 | bs_cclib = [(OASISExpr.EBool true, [])]; | |
5505 | bs_dlllib = [(OASISExpr.EBool true, [])]; | |
5506 | bs_dllpath = [(OASISExpr.EBool true, [])]; | |
5507 | bs_byteopt = [(OASISExpr.EBool true, [])]; | |
5508 | bs_nativeopt = [(OASISExpr.EBool true, [])]; | |
5509 | }, | |
5510 | {exec_custom = false; exec_main_is = "colors.ml"; }); | |
5511 | Executable | |
5512 | ({ | |
5513 | 6214 | cs_name = "read-password"; |
5514 | 6215 | cs_data = PropList.Data.create (); |
5515 | 6216 | cs_plugin_data = []; |
5531 | 6232 | bs_nativeopt = [(OASISExpr.EBool true, [])]; |
5532 | 6233 | }, |
5533 | 6234 | {exec_custom = false; exec_main_is = "read_password.ml"; }); |
5534 | Executable | |
5535 | ({ | |
5536 | cs_name = "hello"; | |
5537 | cs_data = PropList.Data.create (); | |
5538 | cs_plugin_data = []; | |
5539 | }, | |
5540 | { | |
5541 | bs_build = [(OASISExpr.EBool true, true)]; | |
5542 | bs_install = [(OASISExpr.EBool true, false)]; | |
5543 | bs_path = "examples"; | |
5544 | bs_compiled_object = Best; | |
5545 | bs_build_depends = [InternalLibrary "lambda-term"]; | |
5546 | bs_build_tools = [ExternalTool "ocamlbuild"]; | |
5547 | bs_c_sources = []; | |
5548 | bs_data_files = []; | |
5549 | bs_ccopt = [(OASISExpr.EBool true, [])]; | |
5550 | bs_cclib = [(OASISExpr.EBool true, [])]; | |
5551 | bs_dlllib = [(OASISExpr.EBool true, [])]; | |
5552 | bs_dllpath = [(OASISExpr.EBool true, [])]; | |
5553 | bs_byteopt = [(OASISExpr.EBool true, [])]; | |
5554 | bs_nativeopt = [(OASISExpr.EBool true, [])]; | |
5555 | }, | |
5556 | {exec_custom = false; exec_main_is = "hello.ml"; }); | |
5557 | Doc | |
5558 | ({ | |
5559 | cs_name = "lambda-term-inputrc-man"; | |
5560 | cs_data = PropList.Data.create (); | |
5561 | cs_plugin_data = []; | |
5562 | }, | |
5563 | { | |
5564 | doc_type = (`Doc, "custom", Some "0.2"); | |
5565 | doc_custom = | |
5566 | { | |
5567 | pre_command = [(OASISExpr.EBool true, None)]; | |
5568 | post_command = [(OASISExpr.EBool true, None)]; | |
5569 | }; | |
5570 | doc_build = [(OASISExpr.EBool true, true)]; | |
5571 | doc_install = [(OASISExpr.EBool true, true)]; | |
5572 | doc_install_dir = "$mandir/man5"; | |
5573 | doc_title = "Man page for ~/.lambda-term-inputrc"; | |
5574 | doc_authors = []; | |
5575 | doc_abstract = None; | |
5576 | doc_format = OtherDoc; | |
5577 | doc_data_files = | |
5578 | [("man/lambda-term-inputrc.5.gz", None)]; | |
5579 | doc_build_tools = | |
5580 | [ExternalTool "ocamlbuild"; ExternalTool "gzip"]; | |
5581 | }); | |
5582 | Executable | |
5583 | ({ | |
5584 | cs_name = "lambda-term-actions"; | |
5585 | cs_data = PropList.Data.create (); | |
5586 | cs_plugin_data = []; | |
5587 | }, | |
5588 | { | |
5589 | bs_build = [(OASISExpr.EBool true, true)]; | |
5590 | bs_install = [(OASISExpr.EBool true, true)]; | |
5591 | bs_path = "tools"; | |
5592 | bs_compiled_object = Best; | |
5593 | bs_build_depends = [InternalLibrary "lambda-term"]; | |
5594 | bs_build_tools = [ExternalTool "ocamlbuild"]; | |
5595 | bs_c_sources = []; | |
5596 | bs_data_files = []; | |
5597 | bs_ccopt = [(OASISExpr.EBool true, [])]; | |
5598 | bs_cclib = [(OASISExpr.EBool true, [])]; | |
5599 | bs_dlllib = [(OASISExpr.EBool true, [])]; | |
5600 | bs_dllpath = [(OASISExpr.EBool true, [])]; | |
5601 | bs_byteopt = [(OASISExpr.EBool true, [])]; | |
5602 | bs_nativeopt = [(OASISExpr.EBool true, [])]; | |
5603 | }, | |
5604 | { | |
5605 | exec_custom = false; | |
5606 | exec_main_is = "lambda_term_actions.ml"; | |
5607 | }); | |
5608 | 6235 | Executable |
5609 | 6236 | ({ |
5610 | 6237 | cs_name = "read-yes-no"; |
5651 | 6278 | bs_nativeopt = [(OASISExpr.EBool true, [])]; |
5652 | 6279 | }, |
5653 | 6280 | {exec_custom = false; exec_main_is = "editor.ml"; }); |
5654 | Doc | |
5655 | ({ | |
5656 | cs_name = "lambda-term-actions-man"; | |
5657 | cs_data = PropList.Data.create (); | |
5658 | cs_plugin_data = []; | |
5659 | }, | |
5660 | { | |
5661 | doc_type = (`Doc, "custom", Some "0.2"); | |
5662 | doc_custom = | |
5663 | { | |
5664 | pre_command = [(OASISExpr.EBool true, None)]; | |
5665 | post_command = [(OASISExpr.EBool true, None)]; | |
5666 | }; | |
5667 | doc_build = [(OASISExpr.EBool true, true)]; | |
5668 | doc_install = [(OASISExpr.EBool true, true)]; | |
5669 | doc_install_dir = "$mandir/man1"; | |
5670 | doc_title = "Man page for lambda-term-actions"; | |
5671 | doc_authors = []; | |
5672 | doc_abstract = None; | |
5673 | doc_format = OtherDoc; | |
5674 | doc_data_files = | |
5675 | [("man/lambda-term-actions.1.gz", None)]; | |
5676 | doc_build_tools = | |
5677 | [ExternalTool "ocamlbuild"; ExternalTool "gzip"]; | |
5678 | }); | |
5679 | 6281 | Executable |
5680 | 6282 | ({ |
5681 | cs_name = "rgb"; | |
6283 | cs_name = "lambda-term-actions"; | |
5682 | 6284 | cs_data = PropList.Data.create (); |
5683 | 6285 | cs_plugin_data = []; |
5684 | 6286 | }, |
5685 | 6287 | { |
5686 | 6288 | bs_build = [(OASISExpr.EBool true, true)]; |
5687 | bs_install = [(OASISExpr.EBool true, false)]; | |
5688 | bs_path = "examples"; | |
6289 | bs_install = [(OASISExpr.EBool true, true)]; | |
6290 | bs_path = "tools"; | |
5689 | 6291 | bs_compiled_object = Best; |
5690 | 6292 | bs_build_depends = [InternalLibrary "lambda-term"]; |
5691 | 6293 | bs_build_tools = [ExternalTool "ocamlbuild"]; |
5698 | 6300 | bs_byteopt = [(OASISExpr.EBool true, [])]; |
5699 | 6301 | bs_nativeopt = [(OASISExpr.EBool true, [])]; |
5700 | 6302 | }, |
5701 | {exec_custom = false; exec_main_is = "rgb.ml"; }); | |
6303 | { | |
6304 | exec_custom = false; | |
6305 | exec_main_is = "lambda_term_actions.ml"; | |
6306 | }); | |
5702 | 6307 | Executable |
5703 | 6308 | ({ |
5704 | cs_name = "colors_256"; | |
6309 | cs_name = "history-stress-test"; | |
5705 | 6310 | cs_data = PropList.Data.create (); |
5706 | 6311 | cs_plugin_data = []; |
5707 | 6312 | }, |
5708 | 6313 | { |
5709 | 6314 | bs_build = [(OASISExpr.EBool true, true)]; |
5710 | 6315 | bs_install = [(OASISExpr.EBool true, false)]; |
5711 | bs_path = "examples"; | |
6316 | bs_path = "tests"; | |
5712 | 6317 | bs_compiled_object = Best; |
5713 | 6318 | bs_build_depends = [InternalLibrary "lambda-term"]; |
5714 | 6319 | bs_build_tools = [ExternalTool "ocamlbuild"]; |
5721 | 6326 | bs_byteopt = [(OASISExpr.EBool true, [])]; |
5722 | 6327 | bs_nativeopt = [(OASISExpr.EBool true, [])]; |
5723 | 6328 | }, |
5724 | {exec_custom = false; exec_main_is = "colors_256.ml"; }); | |
5725 | Executable | |
6329 | { | |
6330 | exec_custom = false; | |
6331 | exec_main_is = "history_stress_test.ml"; | |
6332 | }); | |
6333 | Doc | |
5726 | 6334 | ({ |
5727 | cs_name = "move"; | |
6335 | cs_name = "lambda-term-api"; | |
5728 | 6336 | cs_data = PropList.Data.create (); |
5729 | 6337 | cs_plugin_data = []; |
5730 | 6338 | }, |
5731 | 6339 | { |
5732 | bs_build = [(OASISExpr.EBool true, true)]; | |
5733 | bs_install = [(OASISExpr.EBool true, false)]; | |
5734 | bs_path = "examples"; | |
5735 | bs_compiled_object = Best; | |
5736 | bs_build_depends = [InternalLibrary "lambda-term"]; | |
5737 | bs_build_tools = [ExternalTool "ocamlbuild"]; | |
5738 | bs_c_sources = []; | |
5739 | bs_data_files = []; | |
5740 | bs_ccopt = [(OASISExpr.EBool true, [])]; | |
5741 | bs_cclib = [(OASISExpr.EBool true, [])]; | |
5742 | bs_dlllib = [(OASISExpr.EBool true, [])]; | |
5743 | bs_dllpath = [(OASISExpr.EBool true, [])]; | |
5744 | bs_byteopt = [(OASISExpr.EBool true, [])]; | |
5745 | bs_nativeopt = [(OASISExpr.EBool true, [])]; | |
5746 | }, | |
5747 | {exec_custom = false; exec_main_is = "move.ml"; }); | |
5748 | Executable | |
6340 | doc_type = (`Doc, "ocamlbuild", Some "0.3"); | |
6341 | doc_custom = | |
6342 | { | |
6343 | pre_command = [(OASISExpr.EBool true, None)]; | |
6344 | post_command = [(OASISExpr.EBool true, None)]; | |
6345 | }; | |
6346 | doc_build = | |
6347 | [ | |
6348 | (OASISExpr.ENot (OASISExpr.EFlag "docs"), false); | |
6349 | (OASISExpr.EFlag "docs", true) | |
6350 | ]; | |
6351 | doc_install = [(OASISExpr.EBool true, true)]; | |
6352 | doc_install_dir = "$htmldir/api"; | |
6353 | doc_title = "API reference for Lambda-Term"; | |
6354 | doc_authors = []; | |
6355 | doc_abstract = None; | |
6356 | doc_format = OtherDoc; | |
6357 | doc_data_files = [("style.css", None)]; | |
6358 | doc_build_tools = | |
6359 | [ExternalTool "ocamlbuild"; ExternalTool "ocamldoc"]; | |
6360 | }); | |
6361 | Doc | |
5749 | 6362 | ({ |
5750 | cs_name = "buttons"; | |
6363 | cs_name = "lambda-term-actions-man"; | |
5751 | 6364 | cs_data = PropList.Data.create (); |
5752 | 6365 | cs_plugin_data = []; |
5753 | 6366 | }, |
5754 | 6367 | { |
5755 | bs_build = [(OASISExpr.EBool true, true)]; | |
5756 | bs_install = [(OASISExpr.EBool true, false)]; | |
5757 | bs_path = "examples"; | |
5758 | bs_compiled_object = Best; | |
5759 | bs_build_depends = [InternalLibrary "lambda-term"]; | |
5760 | bs_build_tools = [ExternalTool "ocamlbuild"]; | |
5761 | bs_c_sources = []; | |
5762 | bs_data_files = []; | |
5763 | bs_ccopt = [(OASISExpr.EBool true, [])]; | |
5764 | bs_cclib = [(OASISExpr.EBool true, [])]; | |
5765 | bs_dlllib = [(OASISExpr.EBool true, [])]; | |
5766 | bs_dllpath = [(OASISExpr.EBool true, [])]; | |
5767 | bs_byteopt = [(OASISExpr.EBool true, [])]; | |
5768 | bs_nativeopt = [(OASISExpr.EBool true, [])]; | |
5769 | }, | |
5770 | {exec_custom = false; exec_main_is = "buttons.ml"; }) | |
6368 | doc_type = (`Doc, "custom", Some "0.3"); | |
6369 | doc_custom = | |
6370 | { | |
6371 | pre_command = [(OASISExpr.EBool true, None)]; | |
6372 | post_command = [(OASISExpr.EBool true, None)]; | |
6373 | }; | |
6374 | doc_build = | |
6375 | [ | |
6376 | (OASISExpr.ENot (OASISExpr.EFlag "docs"), false); | |
6377 | (OASISExpr.EFlag "docs", true) | |
6378 | ]; | |
6379 | doc_install = [(OASISExpr.EBool true, true)]; | |
6380 | doc_install_dir = "$mandir/man1"; | |
6381 | doc_title = "Man page for lambda-term-actions"; | |
6382 | doc_authors = []; | |
6383 | doc_abstract = None; | |
6384 | doc_format = OtherDoc; | |
6385 | doc_data_files = | |
6386 | [("man/lambda-term-actions.1.gz", None)]; | |
6387 | doc_build_tools = | |
6388 | [ExternalTool "ocamlbuild"; ExternalTool "gzip"]; | |
6389 | }); | |
6390 | Doc | |
6391 | ({ | |
6392 | cs_name = "lambda-term-inputrc-man"; | |
6393 | cs_data = PropList.Data.create (); | |
6394 | cs_plugin_data = []; | |
6395 | }, | |
6396 | { | |
6397 | doc_type = (`Doc, "custom", Some "0.3"); | |
6398 | doc_custom = | |
6399 | { | |
6400 | pre_command = [(OASISExpr.EBool true, None)]; | |
6401 | post_command = [(OASISExpr.EBool true, None)]; | |
6402 | }; | |
6403 | doc_build = | |
6404 | [ | |
6405 | (OASISExpr.ENot (OASISExpr.EFlag "docs"), false); | |
6406 | (OASISExpr.EFlag "docs", true) | |
6407 | ]; | |
6408 | doc_install = [(OASISExpr.EBool true, true)]; | |
6409 | doc_install_dir = "$mandir/man5"; | |
6410 | doc_title = "Man page for ~/.lambda-term-inputrc"; | |
6411 | doc_authors = []; | |
6412 | doc_abstract = None; | |
6413 | doc_format = OtherDoc; | |
6414 | doc_data_files = | |
6415 | [("man/lambda-term-inputrc.5.gz", None)]; | |
6416 | doc_build_tools = | |
6417 | [ExternalTool "ocamlbuild"; ExternalTool "gzip"]; | |
6418 | }); | |
6419 | Doc | |
6420 | ({ | |
6421 | cs_name = "lamda-term-inputrc"; | |
6422 | cs_data = PropList.Data.create (); | |
6423 | cs_plugin_data = []; | |
6424 | }, | |
6425 | { | |
6426 | doc_type = (`Doc, "custom", Some "0.3"); | |
6427 | doc_custom = | |
6428 | { | |
6429 | pre_command = [(OASISExpr.EBool true, None)]; | |
6430 | post_command = [(OASISExpr.EBool true, None)]; | |
6431 | }; | |
6432 | doc_build = | |
6433 | [ | |
6434 | (OASISExpr.ENot (OASISExpr.EFlag "docs"), false); | |
6435 | (OASISExpr.EFlag "docs", true) | |
6436 | ]; | |
6437 | doc_install = [(OASISExpr.EBool true, true)]; | |
6438 | doc_install_dir = "$docdir"; | |
6439 | doc_title = "lambda-term-inputrc example"; | |
6440 | doc_authors = []; | |
6441 | doc_abstract = None; | |
6442 | doc_format = OtherDoc; | |
6443 | doc_data_files = [("lambda-term-inputrc", None)]; | |
6444 | doc_build_tools = [ExternalTool "ocamlbuild"]; | |
6445 | }); | |
6446 | SrcRepo | |
6447 | ({ | |
6448 | cs_name = "head"; | |
6449 | cs_data = PropList.Data.create (); | |
6450 | cs_plugin_data = []; | |
6451 | }, | |
6452 | { | |
6453 | src_repo_type = Git; | |
6454 | src_repo_location = | |
6455 | "https://github.com/diml/lambda-term.git"; | |
6456 | src_repo_browser = | |
6457 | Some "https://github.com/diml/lambda-term"; | |
6458 | src_repo_module = None; | |
6459 | src_repo_branch = None; | |
6460 | src_repo_tag = None; | |
6461 | src_repo_subdir = None; | |
6462 | }) | |
5771 | 6463 | ]; |
5772 | 6464 | plugins = |
5773 | [(`Extra, "DevFiles", Some "0.2"); (`Extra, "META", Some "0.2")]; | |
6465 | [(`Extra, "DevFiles", Some "0.3"); (`Extra, "META", Some "0.3")]; | |
5774 | 6466 | schema_data = PropList.Data.create (); |
5775 | 6467 | plugin_data = []; |
5776 | 6468 | }; |
5777 | version = "0.2.1~alpha1"; | |
6469 | oasis_fn = Some "_oasis"; | |
6470 | oasis_version = "0.3.0"; | |
6471 | oasis_digest = Some "Wb\152cy\200vH_/Q2\205\211S\002"; | |
6472 | oasis_exec = None; | |
6473 | oasis_setup_args = []; | |
6474 | setup_update = false; | |
5778 | 6475 | };; |
5779 | 6476 | |
5780 | 6477 | let setup () = BaseSetup.setup setup_t;; |
5781 | 6478 | |
6479 | # 6474 "setup.ml" | |
5782 | 6480 | (* OASIS_STOP *) |
5783 | 6481 | |
5784 | (* +-----------------------------------------------------------------+ | |
5785 | | Search for iconv.h | | |
5786 | +-----------------------------------------------------------------+ *) | |
5787 | ||
5788 | let search_iconv () = | |
5789 | let rec loop = function | |
5790 | | [] -> | |
5791 | "" | |
5792 | | dir :: dirs -> | |
5793 | if Sys.file_exists (dir ^ "/include/iconv.h") then | |
5794 | dir | |
5795 | else | |
5796 | loop dirs | |
5797 | in | |
5798 | loop search_paths | |
5799 | ||
5800 | let iconv_prefix = | |
5801 | BaseEnv.var_define | |
5802 | ~short_desc:(fun () -> "iconv installation prefix") | |
5803 | "iconv_prefix" | |
5804 | (Lazy.lazy_from_fun search_iconv) | |
5805 | ||
5806 | (* +-----------------------------------------------------------------+ | |
5807 | | Test whether -liconv is needed or not | | |
5808 | +-----------------------------------------------------------------+ *) | |
5809 | ||
5810 | let stub_code = " | |
5811 | #include <iconv.h> | |
5812 | #include <caml/mlvalues.h> | |
5813 | ||
5814 | CAMLprim value ocaml_text_test() | |
5815 | { | |
5816 | iconv_open(0, 0); | |
5817 | return Val_unit; | |
5818 | } | |
5819 | " | |
5820 | ||
5821 | let caml_code = " | |
5822 | external test : unit -> unit = \"ocaml_text_test\" | |
5823 | let () = test () | |
5824 | " | |
5825 | ||
5826 | let compile ocamlc log_file stub_file caml_file args = | |
5827 | let result = ref false and dir = iconv_prefix () in | |
5828 | BaseExec.run | |
5829 | ~f_exit_code:(fun x -> result := x = 0) | |
5830 | ocamlc | |
5831 | (List.flatten [ | |
5832 | ["-custom"]; | |
5833 | (if dir = "" then | |
5834 | [] | |
5835 | else | |
5836 | ["-ccopt"; "-I" ^ dir ^ "/include"; | |
5837 | "-cclib"; "-L" ^ dir ^ "/lib"]); | |
5838 | args; | |
5839 | [Filename.quote stub_file; Filename.quote caml_file; "2>"; Filename.quote log_file]; | |
5840 | ]); | |
5841 | !result | |
5842 | ||
5843 | let safe_remove file_name = | |
5844 | try | |
5845 | Sys.remove file_name | |
5846 | with exn -> | |
5847 | () | |
5848 | ||
5849 | let check_iconv () = | |
5850 | OASISContext.printf `Info "Testing whether -liconv is needed"; | |
5851 | ||
5852 | let ocamlc = BaseEnv.var_get "ocamlc" | |
5853 | and ext_obj = BaseEnv.var_get "ext_obj" | |
5854 | and exec_name = BaseEnv.var_get "default_executable_name" in | |
5855 | ||
5856 | (* Put the code into a temporary file. *) | |
5857 | let stub_file, oc = Filename.open_temp_file "ocaml_text_stub" ".c" in | |
5858 | output_string oc stub_code; | |
5859 | close_out oc; | |
5860 | ||
5861 | let caml_file, oc = Filename.open_temp_file "ocaml_text_caml" ".ml" in | |
5862 | output_string oc caml_code; | |
5863 | close_out oc; | |
5864 | ||
5865 | let log_file = Filename.temp_file "ocaml_text" ".log" in | |
5866 | ||
5867 | (* Cleanup things on exit. *) | |
5868 | at_exit (fun () -> | |
5869 | safe_remove log_file; | |
5870 | safe_remove stub_file; | |
5871 | safe_remove (Filename.chop_extension (Filename.basename stub_file) ^ ext_obj); | |
5872 | safe_remove exec_name; | |
5873 | safe_remove caml_file; | |
5874 | safe_remove (Filename.chop_extension caml_file ^ ".cmi"); | |
5875 | safe_remove (Filename.chop_extension caml_file ^ ".cmo")); | |
5876 | ||
5877 | (* Compile it without -liconv. *) | |
5878 | if compile ocamlc log_file stub_file caml_file [] then | |
5879 | "false" | |
5880 | else if compile ocamlc log_file stub_file caml_file ["-cclib"; "-liconv"] then | |
5881 | "true" | |
5882 | else begin | |
5883 | OASISContext.printf `Error "libiconv seems to be missing!"; | |
5884 | exit 1 | |
5885 | end | |
5886 | ||
5887 | (* Define the need_liconv variable *) | |
5888 | let need_liconv = | |
5889 | BaseEnv.var_define | |
5890 | ~short_desc:(fun () -> "-liconv is needed") | |
5891 | "need_liconv" | |
5892 | (Lazy.lazy_from_fun check_iconv) | |
5893 | ||
5894 | let () = setup () | |
6482 | let () = setup ();; |
0 | 0 | # OASIS_START |
1 | # DO NOT EDIT (digest: e280b39969d915e6cc70294d855915c0) | |
2 | version = "1.1" | |
1 | # DO NOT EDIT (digest: 03861a8c15f4c45e208920d5dc7dec7d) | |
2 | version = "1.4" | |
3 | 3 | description = "Corss-platform library for terminal manipulation" |
4 | 4 | requires = "lwt.unix lwt.react zed" |
5 | 5 | archive(byte) = "lambda-term.cma" |
6 | archive(byte, plugin) = "lambda-term.cma" | |
6 | 7 | archive(native) = "lambda-term.cmxa" |
8 | archive(native, plugin) = "lambda-term.cmxs" | |
7 | 9 | exists_if = "lambda-term.cma" |
8 | 10 | # OASIS_STOP |
9 | 11 |
6 | 6 | * This file is a part of Lambda-Term. |
7 | 7 | *) |
8 | 8 | |
9 | (* Static generation of RGB-->index color mappings *) | |
9 | (* This program generates the contents of the file | |
10 | lTerm_color_mappings.ml which contains tables used to convert RGB | |
11 | colors to indexes. *) | |
10 | 12 | |
11 | 13 | (* +-----------------------------------------------------------------+ |
12 | 14 | | Mapping generation | |
16 | 18 | count_r : int; |
17 | 19 | count_g : int; |
18 | 20 | count_b : int; |
19 | index_r : int array; | |
20 | index_g : int array; | |
21 | index_b : int array; | |
21 | index_r : string; | |
22 | index_g : string; | |
23 | index_b : string; | |
22 | 24 | map : string; |
23 | 25 | } |
24 | 26 | |
25 | 27 | module Int_set = Set.Make(struct type t = int let compare x y = x - y end) |
26 | 28 | |
27 | 29 | let reindex set = |
28 | let indexes = Array.make 256 0 in | |
30 | let indexes = String.make 256 '\x00' in | |
29 | 31 | let rec loop idx prev = function |
30 | 32 | | [] -> |
31 | 33 | for i = prev to 255 do |
32 | indexes.(i) <- idx | |
34 | indexes.[i] <- char_of_int idx | |
33 | 35 | done; |
34 | 36 | indexes |
35 | 37 | | next :: rest -> |
36 | 38 | let middle = (prev + next) / 2 in |
37 | 39 | for i = prev to middle do |
38 | indexes.(i) <- idx | |
40 | indexes.[i] <- char_of_int idx | |
39 | 41 | done; |
40 | 42 | let idx = idx + 1 in |
41 | 43 | for i = middle + 1 to next - 1 do |
42 | indexes.(i) <- idx | |
44 | indexes.[i] <- char_of_int idx | |
43 | 45 | done; |
44 | 46 | loop idx next rest |
45 | 47 | in |
188 | 190 | | Color generation | |
189 | 191 | +-----------------------------------------------------------------+ *) |
190 | 192 | |
191 | let code_of_map map = | |
192 | Printf.sprintf "{ | |
193 | let add_string str strings = | |
194 | let rec aux n strings = | |
195 | match strings with | |
196 | | [] -> | |
197 | let id = "data" ^ string_of_int n in | |
198 | (id, [(id, str)]) | |
199 | | (id, str') :: _ when str = str' -> | |
200 | (id, strings) | |
201 | | x :: strings -> | |
202 | let id, strings = aux (n + 1) strings in | |
203 | (id, x :: strings) | |
204 | in | |
205 | aux 0 strings | |
206 | ||
207 | let code_of_map map strings = | |
208 | let index_r, strings = add_string map.index_r strings in | |
209 | let index_g, strings = add_string map.index_g strings in | |
210 | let index_b, strings = add_string map.index_b strings in | |
211 | let mapping, strings = add_string map.map strings in | |
212 | let code = | |
213 | Printf.sprintf "{ | |
193 | 214 | count_r = %d; |
194 | 215 | count_g = %d; |
195 | 216 | count_b = %d; |
196 | index_r = [|%s|]; | |
197 | index_g = [|%s|]; | |
198 | index_b = [|%s|]; | |
199 | map = %S; | |
217 | index_r = %s; | |
218 | index_g = %s; | |
219 | index_b = %s; | |
220 | map = %s; | |
200 | 221 | }" |
201 | map.count_r | |
202 | map.count_g | |
203 | map.count_b | |
204 | (String.concat "; " (List.map string_of_int (Array.to_list map.index_r))) | |
205 | (String.concat "; " (List.map string_of_int (Array.to_list map.index_g))) | |
206 | (String.concat "; " (List.map string_of_int (Array.to_list map.index_b))) | |
207 | map.map | |
222 | map.count_r | |
223 | map.count_g | |
224 | map.count_b | |
225 | index_r | |
226 | index_g | |
227 | index_b | |
228 | mapping | |
229 | in | |
230 | (code, strings) | |
231 | ||
232 | let print_string oc str = | |
233 | let rec aux i = | |
234 | if i = String.length str then | |
235 | () | |
236 | else begin | |
237 | if i > 0 then output_string oc "\\\n "; | |
238 | let len = min 16 (String.length str - i) in | |
239 | for i = i to i + len - 1 do | |
240 | Printf.fprintf oc "\\%03u" (Char.code str.[i]) | |
241 | done; | |
242 | aux (i + len) | |
243 | end | |
244 | in | |
245 | aux 0 | |
208 | 246 | |
209 | 247 | let () = |
210 | 248 | let oc = |
213 | 251 | else |
214 | 252 | open_out Sys.argv.(1) |
215 | 253 | in |
254 | let strings = [] in | |
255 | let code16, strings = code_of_map colors_16 strings in | |
256 | let code88, strings = code_of_map colors_88 strings in | |
257 | let code256, strings = code_of_map colors_256 strings in | |
258 | output_string oc "(* | |
259 | * lTerm_color_mappings.ml | |
260 | * ----------------------- | |
261 | * Copyright : (c) 2012, Jeremie Dimino <jeremie@dimino.org> | |
262 | * Licence : BSD3 | |
263 | * | |
264 | * This file is a part of Lambda-Term. | |
265 | *) | |
266 | ||
267 | (* This file was generated by gen_color_mappings.ml. *) | |
268 | ||
269 | "; | |
270 | List.iter (fun (id, str) -> Printf.fprintf oc "let %s = \"%a\"\n" id print_string str) strings; | |
216 | 271 | Printf.fprintf oc " |
217 | 272 | type map = { |
218 | 273 | count_r : int; |
219 | 274 | count_g : int; |
220 | 275 | count_b : int; |
221 | index_r : int array; | |
222 | index_g : int array; | |
223 | index_b : int array; | |
276 | index_r : string; | |
277 | index_g : string; | |
278 | index_b : string; | |
224 | 279 | map : string; |
225 | 280 | } |
226 | 281 | |
230 | 285 | |
231 | 286 | let colors_256 = %s |
232 | 287 | " |
233 | (code_of_map colors_16) | |
234 | (code_of_map colors_88) | |
235 | (code_of_map colors_256) | |
288 | code16 | |
289 | code88 | |
290 | code256 |
7 | 7 | *) |
8 | 8 | |
9 | 9 | open CamomileLibraryDyn.Camomile |
10 | open Lwt_react | |
10 | 11 | open Lwt |
11 | 12 | open LTerm_geom |
13 | ||
14 | let uspace = UChar.of_char ' ' | |
15 | ||
16 | (* +-----------------------------------------------------------------+ | |
17 | | TTYs sizes | | |
18 | +-----------------------------------------------------------------+ *) | |
19 | ||
20 | external get_size_from_fd : Unix.file_descr -> size = "lt_term_get_size_from_fd" | |
21 | external set_size_from_fd : Unix.file_descr -> size -> unit = "lt_term_set_size_from_fd" | |
22 | ||
23 | let get_size_from_fd fd = | |
24 | Lwt_unix.check_descriptor fd; | |
25 | get_size_from_fd (Lwt_unix.unix_file_descr fd) | |
26 | ||
27 | let set_size_from_fd fd size = | |
28 | Lwt_unix.check_descriptor fd; | |
29 | set_size_from_fd (Lwt_unix.unix_file_descr fd) size | |
12 | 30 | |
13 | 31 | (* +-----------------------------------------------------------------+ |
14 | 32 | | The terminal type | |
21 | 39 | (function |
22 | 40 | | Not_a_tty -> Some "terminal is not a tty" |
23 | 41 | | _ -> None) |
42 | ||
43 | module Int_map = Map.Make(struct type t = int let compare a b = a - b end) | |
24 | 44 | |
25 | 45 | type t = { |
26 | 46 | model : string; |
33 | 53 | mutable raw_mode : bool; |
34 | 54 | (* Whether the terminal is currently in raw mode. *) |
35 | 55 | |
36 | incoming_fd : Lwt_unix.file_descr; | |
37 | outgoing_fd : Lwt_unix.file_descr; | |
56 | mutable incoming_fd : Lwt_unix.file_descr; | |
57 | mutable outgoing_fd : Lwt_unix.file_descr; | |
38 | 58 | (* File descriptors. *) |
39 | 59 | |
40 | ic : Lwt_io.input_channel; | |
41 | oc : Lwt_io.output_channel; | |
60 | mutable ic : Lwt_io.input_channel; | |
61 | mutable oc : Lwt_io.output_channel; | |
42 | 62 | (* Channels. *) |
43 | 63 | |
44 | incoming_cd : LTerm_iconv.t; | |
45 | outgoing_cd : LTerm_iconv.t; | |
46 | (* Conversion descriptors. *) | |
47 | ||
48 | input_stream : char Lwt_stream.t; | |
49 | (* Stream of character input from the terminal. *) | |
50 | ||
51 | mutable size_changed : bool; | |
52 | (* Whether the size have changed and the corresponding event have | |
53 | not yet been reported. *) | |
54 | ||
55 | size_changed_cond : [ `Resize | `Event of LTerm_event.t ] Lwt_condition.t; | |
56 | (* Condition used to wakeup the read_event thread on unix. *) | |
57 | ||
58 | incoming_is_a_tty : bool; | |
59 | outgoing_is_a_tty : bool; | |
64 | mutable input_stream : char Lwt_stream.t; | |
65 | (* Stream of characters read from the terminal. *) | |
66 | ||
67 | mutable next_event : LTerm_event.t Lwt.t option; | |
68 | (* Thread reading the next event from the terminal. We cannot cancel | |
69 | the reading of an event, so we keep the last thread to reuse it | |
70 | in case the user cancels [read_event]. *) | |
71 | ||
72 | mutable read_event : bool; | |
73 | (* Whether a thread is currently reading an event. *) | |
74 | ||
75 | mutable last_reported_size : size; | |
76 | (* The last size reported by [read_event]. *) | |
77 | ||
78 | mutable size : size; | |
79 | (* The current size of the terminal. *) | |
80 | ||
81 | incoming_encoding : CharEncoding.t; | |
82 | outgoing_encoding : CharEncoding.t; | |
83 | (* Characters encodings. *) | |
84 | ||
85 | outgoing_is_utf8 : bool; | |
86 | (* Whether the outgoing encoding is UTF-8. *) | |
87 | ||
88 | notify : LTerm_event.t Lwt_condition.t; | |
89 | (* Condition used to send a spontaneous event. *) | |
90 | ||
91 | mutable event : unit event; | |
92 | (* Event which handles SIGWINCH. *) | |
93 | ||
94 | mutable incoming_is_a_tty : bool; | |
95 | mutable outgoing_is_a_tty : bool; | |
60 | 96 | (* Whether input/output are tty devices. *) |
61 | 97 | |
62 | 98 | mutable escape_time : float; |
64 | 100 | } |
65 | 101 | |
66 | 102 | (* +-----------------------------------------------------------------+ |
103 | | Signals | | |
104 | +-----------------------------------------------------------------+ *) | |
105 | ||
106 | let resize_event, send_resize = E.create () | |
107 | ||
108 | let () = | |
109 | match LTerm_unix.sigwinch with | |
110 | | None -> | |
111 | (* Check for size when something happen. *) | |
112 | ignore (Lwt_sequence.add_r send_resize Lwt_main.enter_iter_hooks) | |
113 | | Some signum -> | |
114 | try | |
115 | ignore (Lwt_unix.on_signal signum (fun _ -> send_resize ())) | |
116 | with Not_found -> | |
117 | ignore (Lwt_sequence.add_r send_resize Lwt_main.enter_iter_hooks) | |
118 | ||
119 | (* +-----------------------------------------------------------------+ | |
67 | 120 | | Creation | |
68 | 121 | +-----------------------------------------------------------------+ *) |
69 | 122 | |
70 | let default_model = | |
123 | let default_model, term_defined = | |
71 | 124 | try |
72 | Sys.getenv "TERM" | |
125 | (Sys.getenv "TERM", true) | |
73 | 126 | with Not_found -> |
74 | "dumb" | |
127 | ("dumb", false) | |
75 | 128 | |
76 | 129 | let colors_of_term = function |
77 | 130 | | "Eterm-256color" -> 256 |
98 | 151 | | "xterm+88color" -> 88 |
99 | 152 | | _ -> 16 |
100 | 153 | |
101 | let create ?(windows=Lwt_sys.windows) ?(model=default_model) ?incoming_encoding ?outgoing_encoding incoming_fd ic outgoing_fd oc = | |
102 | let incoming_encoding, outgoing_encoding = | |
103 | match windows with | |
104 | | true -> | |
105 | (Printf.sprintf "cp%d" (LTerm_windows.get_console_cp ()), | |
106 | Printf.sprintf "cp%d" (LTerm_windows.get_console_output_cp ())) | |
107 | | false -> | |
108 | (LTerm_unix.system_encoding, | |
109 | LTerm_unix.system_encoding) | |
154 | exception No_such_encoding of string | |
155 | ||
156 | let char_encoding_of_name name = | |
157 | try | |
158 | CharEncoding.of_name name | |
159 | with Not_found -> | |
160 | raise (No_such_encoding name) | |
161 | ||
162 | (* UTF-8 on windows. *) | |
163 | let () = CharEncoding.alias "CP65001" "UTF-8" | |
164 | ||
165 | let empty_stream = Lwt_stream.from (fun () -> return None) | |
166 | ||
167 | let create ?(windows=Lwt_sys.windows) ?(model=default_model) ?incoming_encoding ?outgoing_encoding incoming_fd incoming_channel outgoing_fd outgoing_channel = | |
168 | try_lwt | |
169 | (* Colors stuff. *) | |
170 | let colors = if windows then 16 else colors_of_term model in | |
171 | let bold_is_bright = | |
172 | match model with | |
173 | | "linux" (* The linux frame buffer *) | |
174 | | "xterm-color" (* The MacOS-X terminal *) -> | |
175 | true | |
176 | | _ -> | |
177 | false | |
178 | in | |
179 | let color_map = | |
180 | match colors with | |
181 | | 16 -> LTerm_color_mappings.colors_16 | |
182 | | 88 -> LTerm_color_mappings.colors_88 | |
183 | | 256 -> LTerm_color_mappings.colors_256 | |
184 | | n -> Printf.ksprintf failwith "LTerm.create: unknown number of colors (%d)" n | |
185 | in | |
186 | (* Encodings. *) | |
187 | let incoming_encoding = | |
188 | char_encoding_of_name | |
189 | (match incoming_encoding with | |
190 | | Some name -> | |
191 | name | |
192 | | None -> | |
193 | if windows then | |
194 | Printf.sprintf "CP%d" (LTerm_windows.get_console_cp ()) | |
195 | else | |
196 | LTerm_unix.system_encoding) | |
197 | and outgoing_encoding = | |
198 | char_encoding_of_name | |
199 | (match outgoing_encoding with | |
200 | | Some name -> | |
201 | name | |
202 | | None -> | |
203 | if windows then | |
204 | Printf.sprintf "CP%d" (LTerm_windows.get_console_output_cp ()) | |
205 | else | |
206 | LTerm_unix.system_encoding) in | |
207 | (* Check if fds are ttys. *) | |
208 | lwt incoming_is_a_tty = Lwt_unix.isatty incoming_fd | |
209 | and outgoing_is_a_tty = Lwt_unix.isatty outgoing_fd in | |
210 | (* Create the terminal. *) | |
211 | let term = { | |
212 | model; | |
213 | colors; | |
214 | windows; | |
215 | bold_is_bright; | |
216 | color_map; | |
217 | raw_mode = false; | |
218 | incoming_fd; | |
219 | outgoing_fd; | |
220 | ic = incoming_channel; | |
221 | oc = outgoing_channel; | |
222 | input_stream = empty_stream; | |
223 | next_event = None; | |
224 | read_event = false; | |
225 | incoming_encoding; | |
226 | outgoing_encoding; | |
227 | outgoing_is_utf8 = CharEncoding.name_of outgoing_encoding = "UTF-8"; | |
228 | notify = Lwt_condition.create (); | |
229 | event = E.never; | |
230 | incoming_is_a_tty; | |
231 | outgoing_is_a_tty; | |
232 | escape_time = 0.1; | |
233 | size = { rows = 0; cols = 0 }; | |
234 | last_reported_size = { rows = 0; cols = 0 }; | |
235 | } in | |
236 | term.input_stream <- Lwt_stream.from (fun () -> Lwt_io.read_char_opt term.ic); | |
237 | (* Setup initial size and size updater. *) | |
238 | if term.outgoing_is_a_tty then begin | |
239 | let check_size () = | |
240 | let size = get_size_from_fd term.outgoing_fd in | |
241 | if size <> term.size then begin | |
242 | term.size <- size; | |
243 | Lwt_condition.signal term.notify (LTerm_event.Resize size) | |
244 | end | |
245 | in | |
246 | term.size <- get_size_from_fd term.outgoing_fd; | |
247 | term.last_reported_size <- term.size; | |
248 | term.event <- E.map check_size resize_event | |
249 | end; | |
250 | return term | |
251 | with exn -> | |
252 | raise_lwt exn | |
253 | ||
254 | let set_io ?incoming_fd ?incoming_channel ?outgoing_fd ?outgoing_channel term = | |
255 | let get opt x = | |
256 | match opt with | |
257 | | Some x -> x | |
258 | | None -> x | |
110 | 259 | in |
111 | let colors = colors_of_term model in | |
260 | let incoming_fd = get incoming_fd term.incoming_fd | |
261 | and outgoing_fd = get outgoing_fd term.outgoing_fd | |
262 | and incoming_channel = get incoming_channel term.ic | |
263 | and outgoing_channel = get outgoing_channel term.oc in | |
264 | (* Check if fds are ttys. *) | |
112 | 265 | lwt incoming_is_a_tty = Lwt_unix.isatty incoming_fd |
113 | 266 | and outgoing_is_a_tty = Lwt_unix.isatty outgoing_fd in |
114 | let term = { | |
115 | model; | |
116 | colors; | |
117 | windows; | |
118 | bold_is_bright = | |
119 | (match model with | |
120 | | "linux" (* The linux frame buffer *) | |
121 | | "xterm-color" (* The MacOS-X terminal *) -> | |
122 | true | |
123 | | _ -> | |
124 | false); | |
125 | color_map = | |
126 | (match colors with | |
127 | | 16 -> LTerm_color_mappings.colors_16 | |
128 | | 88 -> LTerm_color_mappings.colors_88 | |
129 | | 256 -> LTerm_color_mappings.colors_256 | |
130 | | n -> Printf.ksprintf failwith "LTerm.create: unknown number of colors (%d)" n); | |
131 | raw_mode = false; | |
132 | incoming_fd; | |
133 | outgoing_fd; | |
134 | ic; | |
135 | oc; | |
136 | incoming_cd = LTerm_iconv.iconv_open ~to_code:"UCS-4BE" ~of_code:incoming_encoding; | |
137 | outgoing_cd = LTerm_iconv.iconv_open ~to_code:(outgoing_encoding ^ "//TRANSLIT") ~of_code:"UTF-8"; | |
138 | input_stream = Lwt_stream.from (fun () -> Lwt_io.read_char_opt ic); | |
139 | size_changed = false; | |
140 | size_changed_cond = Lwt_condition.create (); | |
141 | incoming_is_a_tty; | |
142 | outgoing_is_a_tty; | |
143 | escape_time = 0.1; | |
144 | } in | |
145 | if not windows then begin | |
146 | match LTerm_unix.sigwinch with | |
147 | | Some signum -> | |
148 | ignore | |
149 | (Lwt_unix.on_signal signum | |
150 | (fun _ -> | |
151 | term.size_changed <- true; | |
152 | Lwt_condition.signal term.size_changed_cond `Resize)) | |
153 | | None -> | |
154 | () | |
155 | end; | |
156 | return term | |
267 | (* Apply changes. *) | |
268 | term.incoming_fd <- incoming_fd; | |
269 | term.outgoing_fd <- outgoing_fd; | |
270 | term.ic <- incoming_channel; | |
271 | term.oc <- outgoing_channel; | |
272 | term.incoming_is_a_tty <- incoming_is_a_tty; | |
273 | term.outgoing_is_a_tty <- outgoing_is_a_tty; | |
274 | return () | |
157 | 275 | |
158 | 276 | let model t = t.model |
159 | 277 | let colors t = t.colors |
164 | 282 | let escape_time t = t.escape_time |
165 | 283 | let set_escape_time t time = t.escape_time <- time |
166 | 284 | |
167 | (* +-----------------------------------------------------------------+ | |
168 | | Sizes | | |
169 | +-----------------------------------------------------------------+ *) | |
170 | ||
171 | external get_size_from_fd : Unix.file_descr -> size = "lt_term_get_size_from_fd" | |
172 | external set_size_from_fd : Unix.file_descr -> size -> unit = "lt_term_set_size_from_fd" | |
173 | ||
174 | let get_size_from_fd fd = | |
175 | Lwt_unix.check_descriptor fd; | |
176 | return (get_size_from_fd (Lwt_unix.unix_file_descr fd)) | |
177 | ||
178 | let set_size_from_fd fd size = | |
179 | Lwt_unix.check_descriptor fd; | |
180 | return (set_size_from_fd (Lwt_unix.unix_file_descr fd) size) | |
285 | let size term = | |
286 | if term.outgoing_is_a_tty then begin | |
287 | let size = get_size_from_fd term.outgoing_fd in | |
288 | if size <> term.size then begin | |
289 | term.size <- size; | |
290 | Lwt_condition.signal term.notify (LTerm_event.Resize size) | |
291 | end; | |
292 | size | |
293 | end else | |
294 | raise Not_a_tty | |
181 | 295 | |
182 | 296 | let get_size term = |
183 | if term.outgoing_is_a_tty then | |
184 | get_size_from_fd term.outgoing_fd | |
185 | else | |
186 | raise_lwt Not_a_tty | |
187 | ||
188 | let set_size term size = | |
189 | if term.outgoing_is_a_tty then | |
190 | set_size_from_fd term.outgoing_fd size | |
191 | else | |
192 | raise_lwt Not_a_tty | |
297 | try | |
298 | return (size term) | |
299 | with exn -> | |
300 | raise_lwt exn | |
301 | ||
302 | let set_size term size = raise_lwt (Failure "LTerm.set_size is deprecated") | |
303 | ||
304 | (* +-----------------------------------------------------------------+ | |
305 | | Events | | |
306 | +-----------------------------------------------------------------+ *) | |
307 | ||
308 | class output_single (cell : UChar.t option ref) = object | |
309 | method put char = cell := Some char | |
310 | method flush () = () | |
311 | method close_out () = () | |
312 | end | |
313 | ||
314 | let read_char term = | |
315 | lwt first_byte = | |
316 | match_lwt Lwt_stream.get term.input_stream with | |
317 | | Some byte -> return byte | |
318 | | None -> raise_lwt End_of_file | |
319 | in | |
320 | let cell = ref None in | |
321 | let output = new CharEncoding.convert_uchar_output term.incoming_encoding (new output_single cell) in | |
322 | let rec loop st = | |
323 | match !cell with | |
324 | | Some char -> | |
325 | return char | |
326 | | None -> | |
327 | lwt byte = Lwt_stream.next st in | |
328 | assert (output#output (String.make 1 byte) 0 1 = 1); | |
329 | output#flush (); | |
330 | loop st | |
331 | in | |
332 | lwt char = | |
333 | try_lwt | |
334 | assert (output#output (String.make 1 first_byte) 0 1 = 1); | |
335 | Lwt_stream.parse term.input_stream loop | |
336 | with CharEncoding.Malformed_code | Lwt_stream.Empty -> | |
337 | return (UChar.of_char first_byte) | |
338 | in | |
339 | return (LTerm_event.Key { | |
340 | LTerm_key.control = false; | |
341 | LTerm_key.meta = false; | |
342 | LTerm_key.shift = false; | |
343 | LTerm_key.code = LTerm_key.Char char; | |
344 | }) | |
345 | ||
346 | let rec next_event term = | |
347 | if term.windows then | |
348 | match_lwt LTerm_windows.read_console_input term.incoming_fd with | |
349 | | LTerm_windows.Resize -> | |
350 | if term.outgoing_is_a_tty then | |
351 | let size = get_size_from_fd term.outgoing_fd in | |
352 | if size <> term.size then begin | |
353 | term.size <- size; | |
354 | return (LTerm_event.Resize size) | |
355 | end else | |
356 | next_event term | |
357 | else | |
358 | next_event term | |
359 | | LTerm_windows.Key key -> | |
360 | return (LTerm_event.Key key) | |
361 | | LTerm_windows.Mouse mouse -> | |
362 | let window = (LTerm_windows.get_console_screen_buffer_info term.outgoing_fd).LTerm_windows.window in | |
363 | return (LTerm_event.Mouse { | |
364 | mouse with | |
365 | LTerm_mouse.row = mouse.LTerm_mouse.row - window.row1; | |
366 | LTerm_mouse.col = mouse.LTerm_mouse.col - window.col1; | |
367 | }) | |
368 | else | |
369 | LTerm_unix.parse_event ~escape_time:term.escape_time term.incoming_encoding term.input_stream | |
370 | ||
371 | let wrap_next_event next_event term = | |
372 | match term.next_event with | |
373 | | Some thread -> | |
374 | thread | |
375 | | None -> | |
376 | (* Create a non-cancelable thread. *) | |
377 | let waiter, wakener = wait () in | |
378 | term.next_event <- Some waiter; | |
379 | (* Connect the [next_event term] thread to [waiter]. *) | |
380 | ignore | |
381 | (try_bind | |
382 | (fun () -> next_event term) | |
383 | (fun v -> | |
384 | term.next_event <- None; | |
385 | wakeup wakener v; | |
386 | return ()) | |
387 | (fun e -> | |
388 | term.next_event <- None; | |
389 | wakeup_exn wakener e; | |
390 | return ())); | |
391 | waiter | |
392 | ||
393 | let read_event term = | |
394 | if term.read_event then | |
395 | raise_lwt (Failure "LTerm.read_event: cannot read events from two thread at the same time") | |
396 | else if term.size <> term.last_reported_size then begin | |
397 | term.last_reported_size <- term.size; | |
398 | return (LTerm_event.Resize term.last_reported_size) | |
399 | end else begin | |
400 | term.read_event <- true; | |
401 | try_lwt | |
402 | if term.incoming_is_a_tty then | |
403 | match_lwt pick [wrap_next_event next_event term; Lwt_condition.wait term.notify] with | |
404 | | LTerm_event.Resize size -> | |
405 | term.last_reported_size <- size; | |
406 | return (LTerm_event.Resize size) | |
407 | | ev -> | |
408 | return ev | |
409 | else | |
410 | wrap_next_event read_char term | |
411 | finally | |
412 | term.read_event <- false; | |
413 | return () | |
414 | end | |
193 | 415 | |
194 | 416 | (* +-----------------------------------------------------------------+ |
195 | 417 | | Modes | |
229 | 451 | Unix.c_parenb = false; |
230 | 452 | Unix.c_echo = false; |
231 | 453 | Unix.c_icanon = false; |
232 | Unix.c_isig = false; | |
233 | 454 | Unix.c_vmin = 1; |
234 | 455 | Unix.c_vtime = 0; |
456 | Unix.c_isig = false; | |
235 | 457 | } in |
236 | 458 | term.raw_mode <- true; |
237 | 459 | return (Mode_unix attr) |
360 | 582 | let _ = |
361 | 583 | LTerm_windows.fill_console_output_character |
362 | 584 | term.outgoing_fd |
363 | (UChar.of_char ' ') | |
585 | uspace | |
364 | 586 | (info.LTerm_windows.size.cols * info.LTerm_windows.size.rows) |
365 | 587 | { row = 0; col = 0 } |
366 | 588 | in |
377 | 599 | let _ = |
378 | 600 | LTerm_windows.fill_console_output_character |
379 | 601 | term.outgoing_fd |
380 | (UChar.of_char ' ') | |
602 | uspace | |
381 | 603 | (info.LTerm_windows.size.cols * (info.LTerm_windows.size.rows - info.LTerm_windows.cursor_position.row) |
382 | 604 | + info.LTerm_windows.size.cols - info.LTerm_windows.cursor_position.col) |
383 | 605 | info.LTerm_windows.cursor_position |
395 | 617 | let _ = |
396 | 618 | LTerm_windows.fill_console_output_character |
397 | 619 | term.outgoing_fd |
398 | (UChar.of_char ' ') | |
620 | uspace | |
399 | 621 | (info.LTerm_windows.size.cols * info.LTerm_windows.cursor_position.row |
400 | 622 | + info.LTerm_windows.cursor_position.col) |
401 | 623 | { row = 0; col = 0 } |
413 | 635 | let _ = |
414 | 636 | LTerm_windows.fill_console_output_character |
415 | 637 | term.outgoing_fd |
416 | (UChar.of_char ' ') | |
638 | uspace | |
417 | 639 | info.LTerm_windows.size.cols |
418 | 640 | { row = info.LTerm_windows.cursor_position.row; col = 0 } |
419 | 641 | in |
430 | 652 | let _ = |
431 | 653 | LTerm_windows.fill_console_output_character |
432 | 654 | term.outgoing_fd |
433 | (UChar.of_char ' ') | |
655 | uspace | |
434 | 656 | (info.LTerm_windows.size.cols - info.LTerm_windows.cursor_position.col) |
435 | 657 | info.LTerm_windows.cursor_position |
436 | 658 | in |
447 | 669 | let _ = |
448 | 670 | LTerm_windows.fill_console_output_character |
449 | 671 | term.outgoing_fd |
450 | (UChar.of_char ' ') | |
672 | uspace | |
451 | 673 | info.LTerm_windows.cursor_position.col |
452 | 674 | { row = info.LTerm_windows.cursor_position.row; col = 0 } |
453 | 675 | in |
480 | 702 | raise_lwt Not_a_tty |
481 | 703 | |
482 | 704 | (* +-----------------------------------------------------------------+ |
483 | | Events | | |
484 | +-----------------------------------------------------------------+ *) | |
485 | ||
486 | let read_event term = | |
487 | if term.windows then | |
488 | LTerm_windows.read_console_input term.incoming_fd >>= function | |
489 | | LTerm_windows.Resize -> | |
490 | lwt size = get_size term in | |
491 | return (LTerm_event.Resize size) | |
492 | | LTerm_windows.Key key -> | |
493 | return (LTerm_event.Key key) | |
494 | | LTerm_windows.Mouse mouse -> | |
495 | let window = (LTerm_windows.get_console_screen_buffer_info term.outgoing_fd).LTerm_windows.window in | |
496 | return (LTerm_event.Mouse { | |
497 | mouse with | |
498 | LTerm_mouse.row = mouse.LTerm_mouse.row - window.row1; | |
499 | LTerm_mouse.col = mouse.LTerm_mouse.col - window.col1; | |
500 | }) | |
501 | else if term.size_changed then begin | |
502 | term.size_changed <- false; | |
503 | lwt size = get_size term in | |
504 | return (LTerm_event.Resize size) | |
505 | end else | |
506 | pick [LTerm_unix.parse_event ~escape_time:term.escape_time term.incoming_cd term.input_stream >|= (fun ev -> `Event ev); | |
507 | Lwt_condition.wait term.size_changed_cond] >>= function | |
508 | | `Event ev -> | |
509 | return ev | |
510 | | `Resize -> | |
511 | term.size_changed <- false; | |
512 | lwt size = get_size term in | |
513 | return (LTerm_event.Resize size) | |
514 | ||
515 | (* +-----------------------------------------------------------------+ | |
516 | | Styled printing | | |
517 | +-----------------------------------------------------------------+ *) | |
518 | ||
519 | module Codes = struct | |
520 | let bold = ";1" | |
521 | let underline = ";4" | |
522 | let blink = ";5" | |
523 | let reverse = ";7" | |
524 | let foreground = 30 | |
525 | let background = 40 | |
526 | end | |
527 | ||
528 | let vline = UChar.of_char '\xb3' | |
529 | let vlline = UChar.of_char '\xb4' | |
530 | let dlcorner = UChar.of_char '\xbf' | |
531 | let urcorner = UChar.of_char '\xc0' | |
532 | let huline = UChar.of_char '\xc1' | |
533 | let hdline = UChar.of_char '\xc2' | |
534 | let vrline = UChar.of_char '\xc3' | |
535 | let hline = UChar.of_char '\xc4' | |
536 | let cross = UChar.of_char '\xc5' | |
537 | let ulcorner = UChar.of_char '\xd9' | |
538 | let drcorner = UChar.of_char '\xda' | |
539 | ||
540 | (* Maps unicode characters used for drawing on windows. *) | |
541 | let windows_map_char char = | |
705 | | String recoding | | |
706 | +-----------------------------------------------------------------+ *) | |
707 | ||
708 | let vline = UChar.of_char '|' | |
709 | let vlline = UChar.of_char '+' | |
710 | let dlcorner = UChar.of_char '+' | |
711 | let urcorner = UChar.of_char '+' | |
712 | let huline = UChar.of_char '+' | |
713 | let hdline = UChar.of_char '+' | |
714 | let vrline = UChar.of_char '+' | |
715 | let hline = UChar.of_char '-' | |
716 | let cross = UChar.of_char '+' | |
717 | let ulcorner = UChar.of_char '+' | |
718 | let drcorner = UChar.of_char '+' | |
719 | let question = UChar.of_char '?' | |
720 | ||
721 | module UNF = UNF.Make (UText) | |
722 | ||
723 | (* Map characters that cannot be encoded to ASCII ones. *) | |
724 | let map_char char = | |
542 | 725 | match UChar.code char with |
543 | 726 | | 0x2500 -> hline |
544 | 727 | | 0x2501 -> hline |
622 | 805 | | 0x254f -> vline |
623 | 806 | | 0x2550 -> hline |
624 | 807 | | 0x2551 -> vline |
625 | | _ -> char | |
808 | | _ -> | |
809 | match UNF.nfd_decompose char with | |
810 | | char :: _ -> | |
811 | if UChar.code char <= 127 then | |
812 | char | |
813 | else | |
814 | question | |
815 | | [] -> | |
816 | question | |
817 | ||
818 | class output_to_buffer buf res = object | |
819 | method output str ofs len = | |
820 | Buffer.add_substring buf str ofs len; | |
821 | len | |
822 | method flush () = () | |
823 | method close_out () = | |
824 | res := Buffer.contents buf | |
825 | end | |
826 | ||
827 | let encode_string term str = | |
828 | if term.outgoing_is_utf8 then | |
829 | (* Do not recode [str] if the output is UTF-8. *) | |
830 | str | |
831 | else | |
832 | let buf = Buffer.create (String.length str) in | |
833 | let res = ref "" in | |
834 | let output = new CharEncoding.uchar_output_channel_of term.outgoing_encoding (new output_to_buffer buf res) in | |
835 | let rec loop ofs = | |
836 | if ofs = String.length str then begin | |
837 | output#close_out (); | |
838 | !res | |
839 | end else begin | |
840 | let ch, ofs = Zed_utf8.unsafe_extract_next str ofs in | |
841 | (try | |
842 | output#put ch | |
843 | with CharEncoding.Out_of_range -> | |
844 | output#put (map_char ch)); | |
845 | loop ofs | |
846 | end | |
847 | in | |
848 | loop 0 | |
849 | ||
850 | let encode_char term ch = | |
851 | if term.outgoing_is_utf8 then | |
852 | Zed_utf8.singleton ch | |
853 | else begin | |
854 | let res = ref "" in | |
855 | let output = new CharEncoding.uchar_output_channel_of term.outgoing_encoding (new output_to_buffer (Buffer.create 8) res) in | |
856 | (try | |
857 | output#put ch | |
858 | with CharEncoding.Out_of_range -> | |
859 | output#put (map_char ch)); | |
860 | output#close_out (); | |
861 | !res | |
862 | end | |
863 | ||
864 | (* +-----------------------------------------------------------------+ | |
865 | | Styled printing | | |
866 | +-----------------------------------------------------------------+ *) | |
867 | ||
868 | module Codes = struct | |
869 | let bold = ";1" | |
870 | let underline = ";4" | |
871 | let blink = ";5" | |
872 | let reverse = ";7" | |
873 | let foreground = 30 | |
874 | let background = 40 | |
875 | end | |
626 | 876 | |
627 | 877 | let fprint term str = |
628 | Lwt_io.fprint term.oc (LTerm_iconv.recode_with term.outgoing_cd str) | |
878 | Lwt_io.fprint term.oc (encode_string term str) | |
629 | 879 | |
630 | 880 | let fprintl term str = |
631 | 881 | fprint term (str ^ "\n") |
652 | 902 | let map_color term r g b = |
653 | 903 | let open LTerm_color_mappings in |
654 | 904 | let map = term.color_map in |
655 | (* The [String.unsafe_get] is safe because the private type | |
905 | (* The [String.unsafe_get]s are safe because the private type | |
656 | 906 | [LTerm_style.color] ensure that all components are in the range |
657 | 907 | [0..255]. *) |
658 | Char.code (String.unsafe_get map.map (map.index_r.(r) + map.count_r * (map.index_g.(g) + map.count_g * map.index_b.(b)))) | |
908 | Char.code | |
909 | (String.unsafe_get map.map | |
910 | (Char.code (String.unsafe_get map.index_r r) | |
911 | + map.count_r * (Char.code (String.unsafe_get map.index_g g) | |
912 | + map.count_g * Char.code (String.unsafe_get map.index_b b)))) | |
659 | 913 | |
660 | 914 | let add_index term buf base n = |
661 | 915 | if n < 8 then begin |
684 | 938 | | LTerm_style.RGB(r, g, b) -> |
685 | 939 | add_index term buf base (map_color term r g b) |
686 | 940 | |
941 | let add_style term buf style = | |
942 | let open LTerm_style in | |
943 | Buffer.add_string buf "\027[0"; | |
944 | (match style.bold with Some true -> Buffer.add_string buf Codes.bold | _ -> ()); | |
945 | (match style.underline with Some true -> Buffer.add_string buf Codes.underline | _ -> ()); | |
946 | (match style.blink with Some true -> Buffer.add_string buf Codes.blink | _ -> ()); | |
947 | (match style.reverse with Some true -> Buffer.add_string buf Codes.reverse | _ -> ()); | |
948 | (match style.foreground with Some color -> add_color term buf Codes.foreground color | None -> ()); | |
949 | (match style.background with Some color -> add_color term buf Codes.background color | None -> ()); | |
950 | Buffer.add_char buf 'm' | |
951 | ||
687 | 952 | let expand term text = |
688 | 953 | if Array.length text = 0 then |
689 | 954 | "" |
690 | 955 | else begin |
691 | let open LTerm_style in | |
692 | 956 | let buf = Buffer.create 256 in |
693 | 957 | Buffer.add_string buf "\027[0m"; |
694 | 958 | let rec loop idx prev_style = |
697 | 961 | Buffer.contents buf |
698 | 962 | end else begin |
699 | 963 | let ch, style = Array.unsafe_get text idx in |
700 | if not (LTerm_style.equal style prev_style) then begin | |
701 | Buffer.add_string buf "\027[0"; | |
702 | (match style.bold with Some true -> Buffer.add_string buf Codes.bold | _ -> ()); | |
703 | (match style.underline with Some true -> Buffer.add_string buf Codes.underline | _ -> ()); | |
704 | (match style.blink with Some true -> Buffer.add_string buf Codes.blink | _ -> ()); | |
705 | (match style.reverse with Some true -> Buffer.add_string buf Codes.reverse | _ -> ()); | |
706 | (match style.foreground with Some color -> add_color term buf Codes.foreground color | None -> ()); | |
707 | (match style.background with Some color -> add_color term buf Codes.background color | None -> ()); | |
708 | Buffer.add_char buf 'm'; | |
709 | end; | |
964 | if not (LTerm_style.equal style prev_style) then add_style term buf style; | |
710 | 965 | Buffer.add_string buf (Zed_utf8.singleton ch); |
711 | 966 | loop (idx + 1) style |
712 | 967 | end |
713 | 968 | in |
714 | loop 0 none | |
969 | loop 0 LTerm_style.none | |
715 | 970 | end |
716 | 971 | |
717 | 972 | let windows_fg_color term = function |
726 | 981 | |
727 | 982 | let windows_default_attributes = { LTerm_windows.foreground = 7; LTerm_windows.background = 0 } |
728 | 983 | |
984 | let windows_attributes_of_style term style = | |
985 | let open LTerm_style in | |
986 | if style.reverse = Some true then { | |
987 | LTerm_windows.foreground = (match style.background with Some color -> windows_bg_color term color | None -> 0); | |
988 | LTerm_windows.background = (match style.foreground with Some color -> windows_fg_color term color | None -> 7); | |
989 | } else { | |
990 | LTerm_windows.foreground = (match style.foreground with Some color -> windows_fg_color term color | None -> 7); | |
991 | LTerm_windows.background = (match style.background with Some color -> windows_bg_color term color | None -> 0); | |
992 | } | |
993 | ||
729 | 994 | let fprints_windows term oc text = |
730 | let open LTerm_style in | |
731 | 995 | let rec loop idx prev_attr = |
732 | 996 | if idx = Array.length text then begin |
733 | 997 | lwt () = Lwt_io.flush oc in |
735 | 999 | return () |
736 | 1000 | end else begin |
737 | 1001 | let ch, style = Array.unsafe_get text idx in |
738 | let attr = | |
739 | if style.reverse = Some true then { | |
740 | LTerm_windows.foreground = (match style.background with Some color -> windows_bg_color term color | None -> 0); | |
741 | LTerm_windows.background = (match style.foreground with Some color -> windows_fg_color term color | None -> 7); | |
742 | } else { | |
743 | LTerm_windows.foreground = (match style.foreground with Some color -> windows_fg_color term color | None -> 7); | |
744 | LTerm_windows.background = (match style.background with Some color -> windows_bg_color term color | None -> 0); | |
745 | } | |
746 | in | |
1002 | let attr = windows_attributes_of_style term style in | |
747 | 1003 | lwt () = |
748 | 1004 | if attr <> prev_attr then |
749 | 1005 | lwt () = Lwt_io.flush oc in |
752 | 1008 | else |
753 | 1009 | return () |
754 | 1010 | in |
755 | lwt () = Lwt_io.write oc (LTerm_iconv.recode_with term.outgoing_cd (Zed_utf8.singleton ch)) in | |
1011 | lwt () = Lwt_io.write oc (encode_char term ch) in | |
756 | 1012 | loop (idx + 1) attr |
757 | 1013 | end |
758 | 1014 | in |
771 | 1027 | |
772 | 1028 | let fprintls term text = |
773 | 1029 | fprints term (Array.append text (LTerm_text.of_string "\n")) |
1030 | ||
1031 | (* +-----------------------------------------------------------------+ | |
1032 | | Printing with contexts | | |
1033 | +-----------------------------------------------------------------+ *) | |
1034 | ||
1035 | type context = { | |
1036 | ctx_term : t; | |
1037 | ctx_oc : Lwt_io.output_channel; | |
1038 | mutable ctx_style : LTerm_style.t; | |
1039 | mutable ctx_attr : LTerm_windows.text_attributes; | |
1040 | } | |
1041 | ||
1042 | let clear_styles term oc = | |
1043 | if term.outgoing_is_a_tty then | |
1044 | if term.windows then | |
1045 | lwt () = Lwt_io.flush oc in | |
1046 | LTerm_windows.set_console_text_attribute term.outgoing_fd windows_default_attributes; | |
1047 | return () | |
1048 | else | |
1049 | Lwt_io.write oc "\027[0m" | |
1050 | else | |
1051 | return () | |
1052 | ||
1053 | let with_context term f = | |
1054 | Lwt_io.atomic | |
1055 | (fun oc -> | |
1056 | let ctx = { | |
1057 | ctx_term = term; | |
1058 | ctx_oc = oc; | |
1059 | ctx_style = LTerm_style.none; | |
1060 | ctx_attr = windows_default_attributes; | |
1061 | } in | |
1062 | lwt () = clear_styles term oc in | |
1063 | try_lwt | |
1064 | f ctx | |
1065 | finally | |
1066 | clear_styles term oc) | |
1067 | term.oc | |
1068 | ||
1069 | let update_style ctx style = | |
1070 | if ctx.ctx_term.outgoing_is_a_tty then begin | |
1071 | if ctx.ctx_term.windows then begin | |
1072 | let attr = windows_attributes_of_style ctx.ctx_term style in | |
1073 | if attr <> ctx.ctx_attr then | |
1074 | lwt () = Lwt_io.flush ctx.ctx_oc in | |
1075 | LTerm_windows.set_console_text_attribute ctx.ctx_term.outgoing_fd attr; | |
1076 | ctx.ctx_attr <- attr; | |
1077 | return () | |
1078 | else | |
1079 | return () | |
1080 | end else begin | |
1081 | if not (LTerm_style.equal style ctx.ctx_style) then begin | |
1082 | let buf = Buffer.create 16 in | |
1083 | add_style ctx.ctx_term buf style; | |
1084 | lwt () = Lwt_io.write ctx.ctx_oc (Buffer.contents buf) in | |
1085 | ctx.ctx_style <- style; | |
1086 | return () | |
1087 | end else | |
1088 | return () | |
1089 | end | |
1090 | end else | |
1091 | return () | |
1092 | ||
1093 | let context_term ctx = ctx.ctx_term | |
1094 | let context_oc ctx = ctx.ctx_oc | |
1095 | ||
1096 | (* +-----------------------------------------------------------------+ | |
1097 | | Styles setting | | |
1098 | +-----------------------------------------------------------------+ *) | |
1099 | ||
1100 | let set_style term style = | |
1101 | if term.outgoing_is_a_tty then | |
1102 | if term.windows then begin | |
1103 | let attr = windows_attributes_of_style term style in | |
1104 | Lwt_io.atomic | |
1105 | (fun oc -> | |
1106 | lwt () = Lwt_io.flush oc in | |
1107 | LTerm_windows.set_console_text_attribute term.outgoing_fd attr; | |
1108 | return ()) | |
1109 | term.oc | |
1110 | end else begin | |
1111 | let buf = Buffer.create 16 in | |
1112 | add_style term buf style; | |
1113 | Lwt_io.fprint term.oc (Buffer.contents buf) | |
1114 | end | |
1115 | else | |
1116 | return () | |
774 | 1117 | |
775 | 1118 | (* +-----------------------------------------------------------------+ |
776 | 1119 | | Rendering | |
785 | 1128 | p1.foreground = p2.foreground && |
786 | 1129 | p1.background = p2.background |
787 | 1130 | |
788 | let render_point term buf old_point new_point = | |
1131 | let unknown_char = UChar.of_int 0xfffd | |
1132 | let unknown_utf8 = Zed_utf8.singleton unknown_char | |
1133 | ||
1134 | let render_style term buf old_point new_point = | |
789 | 1135 | let open LTerm_draw in |
790 | 1136 | if not (same_style new_point old_point) then begin |
791 | 1137 | (* Reset styles if they are different from the previous point. *) |
797 | 1143 | add_color term buf Codes.foreground new_point.foreground; |
798 | 1144 | add_color term buf Codes.background new_point.background; |
799 | 1145 | Buffer.add_char buf 'm'; |
800 | end; | |
801 | Buffer.add_string buf (Zed_utf8.singleton new_point.char) | |
1146 | end | |
1147 | ||
1148 | let render_point term buf old_point new_point = | |
1149 | render_style term buf old_point new_point; | |
1150 | (* Skip control characters, otherwise output will be messy. *) | |
1151 | if UChar.code new_point.LTerm_draw.char < 32 then | |
1152 | Buffer.add_string buf unknown_utf8 | |
1153 | else | |
1154 | Buffer.add_string buf (Zed_utf8.singleton new_point.LTerm_draw.char) | |
802 | 1155 | |
803 | 1156 | type render_kind = Render_screen | Render_box |
804 | 1157 | |
815 | 1168 | "\r\027[0m"); |
816 | 1169 | (* The last displayed point. *) |
817 | 1170 | let last_point = ref { |
818 | char = UChar.of_char ' '; | |
1171 | char = uspace; | |
819 | 1172 | bold = false; |
820 | 1173 | underline = false; |
821 | 1174 | blink = false; |
823 | 1176 | foreground = LTerm_style.default; |
824 | 1177 | background = LTerm_style.default; |
825 | 1178 | } in |
826 | for y = 0 to Array.length matrix - 1 do | |
1179 | let rows = Array.length matrix and old_rows = Array.length old_matrix in | |
1180 | for y = 0 to rows - 1 do | |
827 | 1181 | let line = Array.unsafe_get matrix y in |
828 | 1182 | (* If the current line is equal to the displayed one, skip it *) |
829 | if y >= Array.length old_matrix || line <> Array.unsafe_get old_matrix y then begin | |
1183 | if y >= old_rows || line <> Array.unsafe_get old_matrix y then begin | |
830 | 1184 | for x = 0 to Array.length line - 1 do |
831 | 1185 | let point = Array.unsafe_get line x in |
832 | 1186 | render_point term buf !last_point point; |
833 | 1187 | last_point := point |
834 | 1188 | done |
835 | 1189 | end; |
836 | if y < Array.length matrix - 1 then Buffer.add_char buf '\n' | |
1190 | if y < rows - 1 then Buffer.add_char buf '\n' | |
837 | 1191 | done; |
838 | 1192 | Buffer.add_string buf "\027[0m"; |
1193 | (* Go to the beginning of the line if rendering a box. *) | |
1194 | if kind = Render_box then Buffer.add_char buf '\r'; | |
839 | 1195 | fprint term (Buffer.contents buf) |
840 | 1196 | |
841 | let render_windows term kind matrix = | |
842 | let open LTerm_draw in | |
1197 | let blank_windows = { | |
1198 | LTerm_windows.ci_char = uspace; | |
1199 | LTerm_windows.ci_foreground = 7; | |
1200 | LTerm_windows.ci_background = 0; | |
1201 | } | |
1202 | ||
1203 | let windows_char_info term point char = | |
1204 | if point.LTerm_draw.reverse then { | |
1205 | LTerm_windows.ci_char = char; | |
1206 | LTerm_windows.ci_foreground = windows_bg_color term point.LTerm_draw.background; | |
1207 | LTerm_windows.ci_background = windows_fg_color term point.LTerm_draw.foreground; | |
1208 | } else { | |
1209 | LTerm_windows.ci_char = char; | |
1210 | LTerm_windows.ci_foreground = windows_fg_color term point.LTerm_draw.foreground; | |
1211 | LTerm_windows.ci_background = windows_bg_color term point.LTerm_draw.background; | |
1212 | } | |
1213 | ||
1214 | let render_windows term kind handle_newlines matrix = | |
843 | 1215 | (* Build the matrix of char infos *) |
844 | 1216 | let matrix = |
845 | 1217 | Array.map |
846 | 1218 | (fun line -> |
847 | Array.map | |
848 | (fun point -> | |
849 | if point.reverse then { | |
850 | LTerm_windows.ci_char = windows_map_char point.char; | |
851 | LTerm_windows.ci_foreground = windows_bg_color term point.background; | |
852 | LTerm_windows.ci_background = windows_fg_color term point.foreground; | |
853 | } else { | |
854 | LTerm_windows.ci_char = windows_map_char point.char; | |
855 | LTerm_windows.ci_foreground = windows_fg_color term point.foreground; | |
856 | LTerm_windows.ci_background = windows_bg_color term point.background; | |
857 | }) | |
858 | line) | |
1219 | let len = Array.length line - (if handle_newlines then 1 else 0) in | |
1220 | if len < 0 then invalid_arg "LTerm.print_box_with_newlines"; | |
1221 | let res = Array.make len blank_windows in | |
1222 | let rec loop i = | |
1223 | if i = len then | |
1224 | res | |
1225 | else begin | |
1226 | let point = Array.unsafe_get line i in | |
1227 | let code = UChar.code point.LTerm_draw.char in | |
1228 | if handle_newlines && code = 10 then begin | |
1229 | (* Copy styles. *) | |
1230 | Array.unsafe_set res i (windows_char_info term point uspace); | |
1231 | for i = i + 1 to len - 1 do | |
1232 | let point = Array.unsafe_get line i in | |
1233 | Array.unsafe_set res i (windows_char_info term point uspace) | |
1234 | done; | |
1235 | res | |
1236 | end else begin | |
1237 | let char = if code < 32 then unknown_char else point.LTerm_draw.char in | |
1238 | Array.unsafe_set res i (windows_char_info term point char); | |
1239 | loop (i + 1) | |
1240 | end | |
1241 | end | |
1242 | in | |
1243 | loop 0) | |
859 | 1244 | matrix |
1245 | in | |
1246 | let rows = Array.length matrix in | |
1247 | lwt () = | |
1248 | match kind with | |
1249 | | Render_screen -> | |
1250 | return () | |
1251 | | Render_box -> | |
1252 | (* Ensure that there is enough place to display the box. *) | |
1253 | lwt () = fprint term "\r" in | |
1254 | lwt () = fprint term (String.make (rows - 1) '\n') in | |
1255 | Lwt_io.flush term.oc | |
860 | 1256 | in |
861 | 1257 | let info = LTerm_windows.get_console_screen_buffer_info term.outgoing_fd in |
862 | 1258 | let window_rect = info.LTerm_windows.window in |
866 | 1262 | window_rect |
867 | 1263 | | Render_box -> |
868 | 1264 | { window_rect with |
869 | row1 = info.LTerm_windows.cursor_position.row; | |
870 | row2 = info.LTerm_windows.cursor_position.row + Array.length matrix } | |
1265 | row1 = info.LTerm_windows.cursor_position.row - (rows - 1); | |
1266 | row2 = info.LTerm_windows.cursor_position.row + 1 } | |
871 | 1267 | in |
872 | 1268 | ignore ( |
873 | 1269 | LTerm_windows.write_console_output |
882 | 1278 | let render_update term old_matrix matrix = |
883 | 1279 | if term.outgoing_is_a_tty then |
884 | 1280 | if term.windows then |
885 | render_windows term Render_screen matrix | |
1281 | render_windows term Render_screen false matrix | |
886 | 1282 | else |
887 | 1283 | render_update_unix term Render_screen old_matrix matrix |
888 | 1284 | else |
891 | 1287 | let render term m = render_update term [||] m |
892 | 1288 | |
893 | 1289 | let print_box term matrix = |
894 | if term.outgoing_is_a_tty then | |
895 | if term.windows then | |
896 | render_windows term Render_box matrix | |
897 | else | |
898 | render_update_unix term Render_box [||] matrix | |
899 | else | |
1290 | if term.outgoing_is_a_tty then begin | |
1291 | if Array.length matrix > 0 then begin | |
1292 | if term.windows then | |
1293 | render_windows term Render_box false matrix | |
1294 | else | |
1295 | render_update_unix term Render_box [||] matrix | |
1296 | end else | |
1297 | fprint term "\r" | |
1298 | end else | |
1299 | raise_lwt Not_a_tty | |
1300 | ||
1301 | let print_box_with_newlines_unix term matrix = | |
1302 | let open LTerm_draw in | |
1303 | let buf = Buffer.create 16 in | |
1304 | (* Go the the beginnig of line and reset attributes *) | |
1305 | Buffer.add_string buf "\r\027[0m"; | |
1306 | (* The last displayed point. *) | |
1307 | let last_point = ref { | |
1308 | char = uspace; | |
1309 | bold = false; | |
1310 | underline = false; | |
1311 | blink = false; | |
1312 | reverse = false; | |
1313 | foreground = LTerm_style.default; | |
1314 | background = LTerm_style.default; | |
1315 | } in | |
1316 | let rows = Array.length matrix in | |
1317 | for y = 0 to rows - 1 do | |
1318 | let line = Array.unsafe_get matrix y in | |
1319 | let cols = Array.length line - 1 in | |
1320 | if cols < 0 then invalid_arg "LTerm.print_box_with_newlines"; | |
1321 | let rec loop x = | |
1322 | let point = Array.unsafe_get line x in | |
1323 | let code = UChar.code point.char in | |
1324 | if x = cols then begin | |
1325 | if code = 10 && y < rows - 1 then | |
1326 | Buffer.add_char buf '\n' | |
1327 | end else if code = 10 then begin | |
1328 | (* Use the style of the newline for the rest of the line. *) | |
1329 | render_style term buf !last_point point; | |
1330 | last_point := point; | |
1331 | (* Erase everything until the end of line. *) | |
1332 | Buffer.add_string buf "\027[K"; | |
1333 | if y < rows - 1 then Buffer.add_char buf '\n' | |
1334 | end else begin | |
1335 | render_point term buf !last_point point; | |
1336 | last_point := point; | |
1337 | loop (x + 1) | |
1338 | end | |
1339 | in | |
1340 | loop 0 | |
1341 | done; | |
1342 | Buffer.add_string buf "\027[0m\r"; | |
1343 | fprint term (Buffer.contents buf) | |
1344 | ||
1345 | let print_box_with_newlines term matrix = | |
1346 | if term.outgoing_is_a_tty then begin | |
1347 | if Array.length matrix > 0 then begin | |
1348 | if term.windows then | |
1349 | render_windows term Render_box true matrix | |
1350 | else | |
1351 | print_box_with_newlines_unix term matrix | |
1352 | end else | |
1353 | fprint term "\r" | |
1354 | end else | |
900 | 1355 | raise_lwt Not_a_tty |
901 | 1356 | |
902 | 1357 | (* +-----------------------------------------------------------------+ |
904 | 1359 | +-----------------------------------------------------------------+ *) |
905 | 1360 | |
906 | 1361 | let flush term = Lwt_io.flush term.oc |
1362 | ||
1363 | let get_size_from_fd fd = return (get_size_from_fd fd) | |
1364 | let set_size_from_fd fd size = return (set_size_from_fd fd size) | |
907 | 1365 | |
908 | 1366 | (* +-----------------------------------------------------------------+ |
909 | 1367 | | Standard terminals | |
8 | 8 | |
9 | 9 | (** Terminal definitions *) |
10 | 10 | |
11 | open CamomileLibrary | |
12 | ||
11 | 13 | type t |
12 | 14 | (** Type of terminals. *) |
13 | 15 | |
14 | 16 | (** {6 Creation} *) |
17 | ||
18 | exception No_such_encoding of string | |
19 | (** Exception raised when an encoding does not exist. *) | |
15 | 20 | |
16 | 21 | val create : |
17 | 22 | ?windows : bool -> |
25 | 30 | terminal using [input_fd] and [input_channel] for inputs and |
26 | 31 | [output_fd] and [output_channel] for outputs. |
27 | 32 | |
28 | - [windows] is a flag telling whether windows hack should be | |
29 | used. It defaults to [Lwt_sys.windows]. | |
33 | - [windows] indicates whether the terminal is a windows console | |
34 | (not mintty, rxvt, ...). It defaults to [Lwt_sys.windows]. | |
30 | 35 | |
31 | 36 | - [model] is the type of the terminal, such as "rxvt" or |
32 | 37 | "xterm". It defaults to the contents of the "TERM" environment |
42 | 47 | defaults to [LTerm_windows.get_console_output_cp] if [windows] is |
43 | 48 | [true] and [LTerm_unix.system_encoding] otherwise. Note that |
44 | 49 | transliteration is used so printing unicode character on the |
45 | terminal will never fail. *) | |
50 | terminal will never fail. | |
51 | ||
52 | If one of the two given encodings does not exist, it raises | |
53 | [No_such_encoding]. | |
54 | ||
55 | Note about terminal resize: in the windows console resizes are | |
56 | not automatically detected. Lambda-term will only check for | |
57 | resize only when something happens. If you want it to poll just | |
58 | write somewhere in your program: | |
59 | ||
60 | {[ | |
61 | Lwt_engine.on_timer 1.0 true ignore | |
62 | ]} | |
63 | *) | |
46 | 64 | |
47 | 65 | (** {6 Informations} *) |
48 | 66 | |
53 | 71 | (** Number of colors of the terminal. *) |
54 | 72 | |
55 | 73 | val windows : t -> bool |
56 | (** Whether the terminal is in windows mode or not. *) | |
74 | (** Whether the terminal is a windows console or not. *) | |
57 | 75 | |
58 | 76 | val is_a_tty : t -> bool |
59 | 77 | (** [is_a_tty term] whether the intput and output of the given |
78 | 96 | (** Exception raised when trying to use a function that can only be |
79 | 97 | used on terminals. *) |
80 | 98 | |
81 | (** {6 Sizes} *) | |
82 | ||
83 | val get_size : t -> LTerm_geom.size Lwt.t | |
84 | (** Returns the current size of the terminal. | |
85 | ||
86 | It raises {!Not_a_tty} if the output of the given terminal is | |
87 | not a tty. *) | |
88 | ||
89 | val set_size : t -> LTerm_geom.size -> unit Lwt.t | |
90 | (** Sets the current size of the terminal. | |
99 | val size : t -> LTerm_geom.size | |
100 | (** Returns the curent size of the terminal. | |
91 | 101 | |
92 | 102 | It raises {!Not_a_tty} if the output of the given terminal is |
93 | 103 | not a tty. *) |
197 | 207 | (** Reads and returns one event. The terminal should be in raw mode |
198 | 208 | before calling this function, otherwise event will not be |
199 | 209 | reported as they happen. It does not fail if the terminal is not |
200 | a tty. *) | |
210 | a tty. | |
211 | ||
212 | Note: you must not call {!read_event} from multiple thread at | |
213 | the same time, it will raise {!Failure} if you try to do so. *) | |
201 | 214 | |
202 | 215 | (** {6 Printing} *) |
203 | 216 | |
204 | (** The general name of a printing function is [<prefix>print<suffixes>]. | |
217 | (** All these functions accept only valid UTF-8 strings (or unicode | |
218 | styled text). Strings are recoded on the fly using the terminal | |
219 | output encoding (except if the terminal output encoding is already | |
220 | UTF-8, in which case the string is just printed as-it). | |
221 | ||
222 | The general name of a printing function is [<prefix>print<suffixes>]. | |
205 | 223 | |
206 | 224 | Where [<prefix>] is one of: |
207 | 225 | - ['f'], which means that the function takes as argument a terminal |
211 | 229 | and [<suffixes>] is a combination of: |
212 | 230 | - ['l'] which means that a new-line character is printed after the message |
213 | 231 | - ['f'] which means that the function takes as argument a {b format} instead |
214 | of a string | |
232 | of a string | |
215 | 233 | - ['s'] which means that the function takes as argument a styled |
216 | string instead of a string | |
217 | ||
218 | Notes: | |
219 | - if the terminal is not a tty, styles are stripped. | |
220 | - non-ascii characters are recoded on the fly using the terminal | |
221 | encoding | |
234 | string instead of a string | |
235 | ||
236 | Note that if the terminal is not a tty, styles are stripped. | |
222 | 237 | *) |
223 | 238 | |
224 | val fprint : t -> string -> unit Lwt.t | |
225 | val fprintl : t -> string -> unit Lwt.t | |
226 | val fprintf : t -> ('a, unit, string, unit Lwt.t) format4 -> 'a | |
239 | val fprint : t -> Zed_utf8.t -> unit Lwt.t | |
240 | val fprintl : t -> Zed_utf8.t -> unit Lwt.t | |
241 | val fprintf : t -> ('a, unit, Zed_utf8.t, unit Lwt.t) format4 -> 'a | |
227 | 242 | val fprints : t -> LTerm_text.t -> unit Lwt.t |
228 | val fprintlf : t -> ('a, unit, string, unit Lwt.t) format4 -> 'a | |
243 | val fprintlf : t -> ('a, unit, Zed_utf8.t, unit Lwt.t) format4 -> 'a | |
229 | 244 | val fprintls : t -> LTerm_text.t -> unit Lwt.t |
230 | val print : string -> unit Lwt.t | |
231 | val printl : string -> unit Lwt.t | |
232 | val printf : ('a, unit, string, unit Lwt.t) format4 -> 'a | |
245 | val print : Zed_utf8.t -> unit Lwt.t | |
246 | val printl : Zed_utf8.t -> unit Lwt.t | |
247 | val printf : ('a, unit, Zed_utf8.t, unit Lwt.t) format4 -> 'a | |
233 | 248 | val prints : LTerm_text.t -> unit Lwt.t |
234 | val printlf : ('a, unit, string, unit Lwt.t) format4 -> 'a | |
249 | val printlf : ('a, unit, Zed_utf8.t, unit Lwt.t) format4 -> 'a | |
235 | 250 | val printls : LTerm_text.t -> unit Lwt.t |
236 | val eprint : string -> unit Lwt.t | |
237 | val eprintl : string -> unit Lwt.t | |
238 | val eprintf : ('a, unit, string, unit Lwt.t) format4 -> 'a | |
251 | val eprint : Zed_utf8.t -> unit Lwt.t | |
252 | val eprintl : Zed_utf8.t -> unit Lwt.t | |
253 | val eprintf : ('a, unit, Zed_utf8.t, unit Lwt.t) format4 -> 'a | |
239 | 254 | val eprints : LTerm_text.t -> unit Lwt.t |
240 | val eprintlf : ('a, unit, string, unit Lwt.t) format4 -> 'a | |
255 | val eprintlf : ('a, unit, Zed_utf8.t, unit Lwt.t) format4 -> 'a | |
241 | 256 | val eprintls : LTerm_text.t -> unit Lwt.t |
257 | ||
258 | (** {8 Printing contexts} *) | |
259 | ||
260 | (** You shoud use these functions when you to print a lot of styled | |
261 | text that does not entirely fit in a single {!LTerm_text.t} | |
262 | value. | |
263 | ||
264 | This is more efficient than calling manually {!set_style} since | |
265 | styles will be modified only when needed. *) | |
266 | ||
267 | type context | |
268 | (** A context for styled printing. *) | |
269 | ||
270 | val with_context : t -> (context -> 'a Lwt.t) -> 'a Lwt.t | |
271 | (** [with_context term f] creates a new printing context and pass it | |
272 | to [f]. Note that calls to [with_context] are serialized. *) | |
273 | ||
274 | val update_style : context -> LTerm_style.t -> unit Lwt.t | |
275 | (** [update_style ctx style] updates the style of the context with | |
276 | [style]. If needed styles of the terminal are modified. *) | |
277 | ||
278 | val context_term : context -> t | |
279 | (** Returns the terminal used by the given context. *) | |
280 | ||
281 | val context_oc : context -> Lwt_io.output_channel | |
282 | (** Returns the output channel used by the given context. Note that | |
283 | this channel cannot be used after {!with_context} has | |
284 | terminated. *) | |
285 | ||
286 | val encode_string : t -> Zed_utf8.t -> string | |
287 | (** [encode_string term str] encodes an UTF-8 string using the | |
288 | terminal encoding. *) | |
289 | ||
290 | val encode_char : t -> UChar.t -> string | |
291 | (** [encode_char term ch] encodes an unicode character using the | |
292 | terminal encoding. *) | |
293 | ||
294 | (** {6 Styles} *) | |
295 | ||
296 | val set_style : t -> LTerm_style.t -> unit Lwt.t | |
297 | (** Change the style of the termina for subsequent unstyled | |
298 | output. It does nothing if the output is not a tty. *) | |
242 | 299 | |
243 | 300 | (** {6 Rendering} *) |
244 | 301 | |
264 | 321 | {!print_box} because it works better under windows and is more |
265 | 322 | efficient. |
266 | 323 | |
267 | Note: on windows this does not move the cursor. | |
268 | *) | |
324 | The cursor is moved to the beginning of the last displayed | |
325 | line. *) | |
326 | ||
327 | val print_box_with_newlines : t -> LTerm_draw.matrix -> unit Lwt.t | |
328 | (** [print_box term matrix] Same as {!print_box} but [matrix] | |
329 | may contains newline characters. It must contain one more column | |
330 | that the terminal (in case a line of the length of the terminal | |
331 | ends with a newline). | |
332 | ||
333 | The difference between {!print_box} and | |
334 | {!print_box_with_newlines} is that when the text is selected in | |
335 | the terminal, with {!print_box} it will always be a box with the | |
336 | dimensions of [matrix]. With {!print_box_with_newlines} it may | |
337 | contains lines longer than the width of the terminal. | |
338 | ||
339 | The contents of a line after the first newline character (if | |
340 | any) in a row of [matrix] is ignored. The rest of the line get | |
341 | the style of the newline character. *) | |
269 | 342 | |
270 | 343 | (** {6 Misc} *) |
271 | 344 | |
291 | 364 | val set_size_from_fd : Lwt_unix.file_descr -> LTerm_geom.size -> unit Lwt.t |
292 | 365 | (** [set_size_from_fd fd size] tries to set the size of the terminal |
293 | 366 | accessible via the given file descriptor. *) |
367 | ||
368 | (** {6 Modification} *) | |
369 | ||
370 | val set_io : | |
371 | ?incoming_fd : Lwt_unix.file_descr -> ?incoming_channel : Lwt_io.input_channel -> | |
372 | ?outgoing_fd : Lwt_unix.file_descr -> ?outgoing_channel : Lwt_io.output_channel -> t -> unit Lwt.t | |
373 | (** Modifies file descriptors/channels of a terminal. Unspecified | |
374 | arguments are kept unchanged. | |
375 | ||
376 | Note: before modifying a terminal you should ensure that no | |
377 | operation is pending on it. *) | |
378 | ||
379 | (**/**) | |
380 | val get_size : t -> LTerm_geom.size Lwt.t | |
381 | val set_size : t -> LTerm_geom.size -> unit Lwt.t |
0 | (* | |
1 | * lTerm_color_mappings.ml | |
2 | * ----------------------- | |
3 | * Copyright : (c) 2012, Jeremie Dimino <jeremie@dimino.org> | |
4 | * Licence : BSD3 | |
5 | * | |
6 | * This file is a part of Lambda-Term. | |
7 | *) | |
8 | ||
9 | (* This file was generated by gen_color_mappings.ml. *) | |
10 | ||
11 | let data0 = "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ | |
12 | \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ | |
13 | \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001\ | |
14 | \001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\ | |
15 | \001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\ | |
16 | \001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\ | |
17 | \001\001\001\001\001\001\001\001\001\001\001\001\001\001\002\002\ | |
18 | \002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\ | |
19 | \002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\ | |
20 | \002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\ | |
21 | \002\002\002\002\002\002\002\003\003\003\003\003\003\003\003\003\ | |
22 | \003\003\003\003\003\003\003\003\003\003\003\003\003\003\003\003\ | |
23 | \003\003\003\003\003\003\003\003\003\003\003\003\003\003\003\003\ | |
24 | \003\003\003\003\003\003\003\003\003\003\004\004\004\004\004\004\ | |
25 | \004\004\004\004\004\004\004\004\004\004\004\004\004\004\004\004\ | |
26 | \004\004\004\005\005\005\005\005\005\005\005\005\005\005\005\005" | |
27 | let data1 = "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ | |
28 | \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ | |
29 | \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ | |
30 | \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ | |
31 | \001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\ | |
32 | \001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\ | |
33 | \001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\ | |
34 | \001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\ | |
35 | \001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\ | |
36 | \001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\ | |
37 | \001\001\001\001\001\001\001\002\002\002\002\002\002\002\002\002\ | |
38 | \002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\ | |
39 | \002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\ | |
40 | \002\002\002\002\002\002\002\002\002\002\003\003\003\003\003\003\ | |
41 | \003\003\003\003\003\003\003\003\003\003\004\004\004\004\004\004\ | |
42 | \004\004\004\004\004\004\004\005\005\005\005\005\005\005\005\005" | |
43 | let data2 = "\000\001\001\001\001\009\002\003\003\001\001\009\002\003\003\003\ | |
44 | \003\009\002\002\003\003\003\011\002\002\003\003\003\011\010\010\ | |
45 | \010\011\011\011\004\005\005\005\005\009\006\008\008\001\001\009\ | |
46 | \006\008\008\007\007\009\006\002\007\007\007\015\006\002\007\007\ | |
47 | \007\015\010\010\010\015\015\011\004\004\005\005\005\013\004\012\ | |
48 | \012\005\005\013\006\012\012\007\007\015\006\006\007\007\007\015\ | |
49 | \006\006\007\007\007\015\014\014\015\015\015\015\004\004\005\005\ | |
50 | \005\013\004\012\012\005\005\013\006\012\012\007\007\015\006\006\ | |
51 | \007\007\007\015\006\006\007\007\007\015\014\014\015\015\015\015\ | |
52 | \004\004\013\013\013\013\004\012\012\013\013\013\014\012\012\012\ | |
53 | \007\015\014\014\012\007\007\015\014\014\007\007\007\015\014\014\ | |
54 | \015\015\015\015\004\004\013\013\013\013\004\012\012\013\013\013\ | |
55 | \014\012\012\012\012\013\014\014\012\015\015\015\014\014\012\015\ | |
56 | \015\015\014\014\014\015\015\015" | |
57 | let data3 = "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ | |
58 | \000\000\000\000\000\000\000\000\001\001\001\001\001\001\001\001\ | |
59 | \001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\ | |
60 | \001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\ | |
61 | \001\001\001\001\001\001\002\002\002\002\002\002\002\002\002\002\ | |
62 | \002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\002\ | |
63 | \002\002\002\002\002\002\002\002\003\003\003\003\003\003\003\003\ | |
64 | \003\003\003\003\003\003\003\003\003\003\003\003\003\003\003\003\ | |
65 | \004\004\004\004\004\004\004\004\004\004\004\004\004\004\004\004\ | |
66 | \004\004\004\004\004\004\004\005\005\005\005\005\005\005\005\005\ | |
67 | \005\005\005\005\005\005\005\005\005\005\005\005\005\005\006\006\ | |
68 | \006\006\006\006\006\006\006\006\006\006\006\006\006\006\006\006\ | |
69 | \006\006\006\006\007\007\007\007\007\007\007\007\007\007\007\008\ | |
70 | \008\008\008\008\008\008\008\008\008\008\008\008\009\009\009\009\ | |
71 | \009\009\009\009\009\009\009\009\009\009\009\009\009\009\009\009\ | |
72 | \009\009\009\009\010\010\010\010\010\010\010\010\010\010\010\010" | |
73 | let data4 = "\016\032\032\032\032\032\048\048\048\064\064\020\036\052\032\032\ | |
74 | \032\048\048\048\064\064\020\040\036\036\052\052\052\068\068\068\ | |
75 | \068\020\020\036\036\036\052\052\052\052\068\068\020\020\040\036\ | |
76 | \036\036\052\052\052\068\068\020\020\040\040\036\036\056\052\052\ | |
77 | \052\068\024\024\040\040\040\056\056\056\056\072\072\024\024\044\ | |
78 | \040\040\040\056\056\056\072\072\024\024\044\040\040\040\056\056\ | |
79 | \056\072\072\028\028\044\044\044\040\060\060\060\076\076\028\028\ | |
80 | \044\044\044\044\060\060\060\076\076\017\033\049\032\032\032\048\ | |
81 | \048\048\064\064\021\080\053\032\032\032\048\048\048\064\064\025\ | |
82 | \041\057\057\052\052\048\048\048\064\064\020\020\057\036\036\052\ | |
83 | \052\068\068\068\068\020\020\040\036\036\036\052\052\052\068\068\ | |
84 | \020\020\040\040\036\036\052\052\052\052\068\024\024\024\040\040\ | |
85 | \040\056\056\056\072\068\024\024\024\044\040\040\056\056\056\072\ | |
86 | \072\024\024\024\044\040\040\056\056\056\072\072\028\028\028\044\ | |
87 | \044\040\060\060\060\076\072\028\028\028\044\044\044\044\060\060\ | |
88 | \060\076\017\034\033\033\049\049\049\065\065\065\065\022\038\054\ | |
89 | \054\049\049\048\048\048\064\064\021\042\081\082\053\053\053\069\ | |
90 | \069\069\069\021\042\082\082\053\053\053\069\069\069\069\025\025\ | |
91 | \041\041\057\057\073\073\073\073\073\025\025\041\041\057\057\057\ | |
92 | \073\073\073\073\025\024\041\041\061\057\057\077\077\073\073\029\ | |
93 | \024\045\045\061\061\077\077\077\077\073\029\024\045\045\061\061\ | |
94 | \077\077\077\077\073\029\028\045\045\061\061\061\077\077\077\077\ | |
95 | \029\028\045\045\061\061\061\061\061\077\077\017\017\033\033\033\ | |
96 | \049\049\049\049\065\065\017\017\054\033\033\049\049\065\065\065\ | |
97 | \065\021\042\082\082\053\053\053\069\069\069\069\021\021\082\082\ | |
98 | \083\053\053\053\053\069\069\021\021\041\083\083\057\053\053\053\ | |
99 | \069\069\025\025\041\041\057\057\057\073\073\073\073\025\025\041\ | |
100 | \041\041\057\057\057\057\073\073\025\029\045\041\041\061\057\057\ | |
101 | \057\073\073\025\029\045\041\041\061\057\057\057\077\073\029\029\ | |
102 | \045\045\045\061\061\061\077\077\077\029\029\045\045\045\061\061\ | |
103 | \061\061\077\077\017\017\034\033\033\033\049\049\049\065\065\017\ | |
104 | \017\034\033\033\033\049\049\049\065\065\022\022\038\038\054\054\ | |
105 | \070\070\070\070\070\021\021\038\083\083\054\053\053\053\069\069\ | |
106 | \021\021\042\083\083\084\053\053\053\069\069\021\021\042\042\084\ | |
107 | \084\053\053\053\069\069\025\025\046\041\041\041\057\057\057\073\ | |
108 | \073\025\025\046\041\041\041\057\057\057\073\073\025\025\046\041\ | |
109 | \041\041\057\057\057\073\073\029\029\046\045\045\045\061\061\061\ | |
110 | \077\077\029\029\046\045\045\045\061\061\061\077\077\017\017\034\ | |
111 | \034\033\033\050\049\049\049\065\017\017\034\034\033\033\049\049\ | |
112 | \049\049\065\022\022\038\038\054\054\054\070\070\070\070\022\022\ | |
113 | \038\038\054\054\054\070\070\070\070\021\021\042\042\084\084\054\ | |
114 | \053\053\069\069\021\021\042\042\084\084\085\053\053\053\069\026\ | |
115 | \025\042\042\042\085\085\057\053\053\069\025\025\046\046\041\041\ | |
116 | \057\057\057\057\073\025\025\046\046\041\041\041\057\057\057\073\ | |
117 | \025\025\046\046\045\041\041\057\057\057\073\029\029\046\046\045\ | |
118 | \045\045\061\061\061\077\018\018\034\034\034\050\050\050\050\066\ | |
119 | \066\018\018\018\034\034\034\050\050\050\066\065\022\018\038\038\ | |
120 | \055\054\054\071\071\070\070\022\022\038\038\038\054\054\054\054\ | |
121 | \070\070\022\022\043\038\038\038\054\054\054\070\070\026\022\042\ | |
122 | \042\038\085\085\054\054\053\069\026\026\042\042\042\085\085\058\ | |
123 | \086\074\074\026\026\047\042\042\042\058\058\086\074\074\026\026\ | |
124 | \047\042\042\042\086\086\086\074\074\030\030\046\046\046\041\062\ | |
125 | \062\062\078\078\030\029\046\046\046\045\062\062\062\078\078\018\ | |
126 | \018\035\034\034\034\050\050\050\066\066\018\018\018\035\034\034\ | |
127 | \050\050\050\066\066\023\018\039\039\055\055\071\071\071\071\070\ | |
128 | \022\023\039\038\038\055\054\054\054\070\070\022\022\043\038\038\ | |
129 | \038\054\054\054\070\070\022\022\043\043\038\038\054\054\054\054\ | |
130 | \070\026\026\047\042\042\042\058\058\086\074\074\026\026\047\042\ | |
131 | \042\042\058\058\086\087\074\026\026\047\042\042\042\086\086\086\ | |
132 | \087\074\030\030\047\046\046\042\062\087\087\087\078\030\030\046\ | |
133 | \046\046\046\062\062\062\078\078\018\018\035\034\034\034\050\050\ | |
134 | \050\066\066\018\018\018\035\034\034\050\050\050\066\066\023\018\ | |
135 | \039\039\055\055\071\071\071\071\070\022\023\039\038\038\055\054\ | |
136 | \054\054\071\070\022\022\043\038\038\038\054\054\054\070\070\022\ | |
137 | \022\043\043\038\038\054\054\054\054\070\026\026\047\042\042\038\ | |
138 | \086\086\086\075\074\026\026\047\042\042\042\086\086\086\087\074\ | |
139 | \026\026\047\042\042\042\086\086\086\087\074\030\030\047\047\046\ | |
140 | \042\063\087\087\087\074\030\030\046\046\046\046\062\062\062\062\ | |
141 | \078\019\019\035\035\035\034\051\051\051\067\067\019\019\019\035\ | |
142 | \035\034\051\051\051\067\066\023\019\039\039\055\055\055\071\071\ | |
143 | \071\071\023\023\039\039\039\055\055\055\071\071\071\023\023\043\ | |
144 | \039\039\039\055\055\055\071\071\022\022\043\043\039\038\038\054\ | |
145 | \054\054\070\027\027\043\043\043\038\059\059\059\075\075\027\027\ | |
146 | \047\043\043\042\059\087\087\087\075\027\027\047\047\043\042\059\ | |
147 | \087\087\087\074\031\031\047\047\047\042\063\087\087\087\079\031\ | |
148 | \030\047\047\047\046\063\063\062\079\079\019\019\035\035\035\035\ | |
149 | \051\051\051\067\067\019\019\019\035\035\035\035\051\051\051\067\ | |
150 | \023\019\039\039\055\055\055\055\055\071\071\023\023\039\039\039\ | |
151 | \055\055\055\055\071\071\023\023\043\039\039\039\055\055\055\071\ | |
152 | \071\023\023\043\043\039\039\039\055\055\055\071\027\023\043\043\ | |
153 | \043\039\059\059\059\075\075\027\027\043\043\043\043\059\059\059\ | |
154 | \075\075\027\027\043\043\043\043\059\059\059\059\075\031\027\047\ | |
155 | \047\047\043\063\063\059\079\079\031\031\047\047\047\047\063\063\ | |
156 | \063\079\079" | |
157 | let data5 = "\000\000\000\000\000\001\001\001\001\001\001\001\001\001\002\002\ | |
158 | \002\002\002\002\002\002\002\002\003\003\003\003\003\003\003\003\ | |
159 | \003\003\004\004\004\004\004\004\004\004\004\004\005\005\005\005\ | |
160 | \005\005\005\005\005\005\006\006\006\006\006\006\006\006\006\006\ | |
161 | \007\007\007\007\007\007\007\007\007\007\008\008\008\008\008\008\ | |
162 | \008\008\008\008\009\009\009\009\009\009\009\009\010\010\010\010\ | |
163 | \010\011\011\011\011\011\011\011\012\012\012\012\012\012\012\012\ | |
164 | \012\012\013\013\013\013\013\013\013\013\013\013\014\014\014\014\ | |
165 | \014\014\014\014\015\015\015\015\015\016\016\016\016\016\016\016\ | |
166 | \017\017\017\017\017\017\017\017\017\017\018\018\018\018\018\018\ | |
167 | \018\018\018\018\019\019\019\019\019\019\019\019\020\020\020\020\ | |
168 | \020\021\021\021\021\021\021\021\022\022\022\022\022\022\022\022\ | |
169 | \022\022\023\023\023\023\023\023\023\023\023\023\024\024\024\024\ | |
170 | \024\024\024\024\025\025\025\025\025\026\026\026\026\026\026\026\ | |
171 | \027\027\027\027\027\027\027\027\027\027\028\028\028\028\028\028\ | |
172 | \028\028\028\028\028\028\028\029\029\029\029\029\029\029\029\029" | |
173 | let data6 = "\016\052\052\052\052\052\052\052\052\052\052\052\052\088\088\088\ | |
174 | \088\088\124\124\124\124\124\160\160\160\160\160\196\196\022\058\ | |
175 | \094\052\052\052\052\052\052\052\052\052\052\088\088\088\088\088\ | |
176 | \124\124\124\124\124\160\160\160\160\160\196\196\022\064\058\094\ | |
177 | \094\052\052\052\052\052\052\052\052\088\088\088\088\088\124\124\ | |
178 | \124\124\124\160\160\160\160\160\196\196\022\022\064\058\058\094\ | |
179 | \094\094\052\052\052\052\052\088\088\088\088\088\124\124\124\124\ | |
180 | \124\160\160\160\160\160\196\196\022\022\064\058\058\058\094\094\ | |
181 | \094\094\130\130\130\130\088\088\088\088\124\124\124\124\124\160\ | |
182 | \160\160\160\160\196\196\022\022\022\064\058\058\058\094\094\094\ | |
183 | \094\094\130\130\130\130\130\130\130\166\166\166\166\166\166\202\ | |
184 | \202\202\202\202\022\022\022\064\064\058\058\058\094\094\094\094\ | |
185 | \094\130\130\130\130\130\130\130\166\166\166\166\166\166\202\202\ | |
186 | \202\202\022\022\022\064\064\064\058\058\058\094\094\094\094\094\ | |
187 | \094\130\130\130\130\130\130\166\166\166\166\166\166\202\202\202\ | |
188 | \022\022\022\022\064\064\064\058\058\058\058\094\094\094\094\094\ | |
189 | \094\130\130\130\130\130\166\166\166\166\166\202\202\202\022\022\ | |
190 | \022\022\064\064\064\064\058\058\058\058\094\094\094\094\094\130\ | |
191 | \130\130\130\130\130\166\166\166\166\166\202\202\022\022\022\022\ | |
192 | \070\064\064\064\058\058\058\058\058\094\094\094\094\094\130\130\ | |
193 | \130\130\130\166\166\166\166\166\202\202\022\022\022\022\070\064\ | |
194 | \064\064\064\058\058\058\058\094\094\094\094\094\130\130\130\130\ | |
195 | \130\166\166\166\166\166\202\202\022\022\022\022\070\070\064\064\ | |
196 | \064\064\058\058\058\100\094\094\094\094\094\130\130\130\130\130\ | |
197 | \166\166\166\166\166\202\028\028\028\028\070\070\070\064\064\064\ | |
198 | \064\064\100\100\100\100\100\136\136\136\136\136\130\172\172\172\ | |
199 | \172\166\208\208\028\028\028\028\028\070\070\064\064\064\064\064\ | |
200 | \064\100\100\100\100\136\136\136\136\136\136\172\172\172\172\172\ | |
201 | \208\208\028\028\028\028\028\070\070\070\064\064\064\064\064\100\ | |
202 | \100\100\100\100\136\136\136\136\136\172\172\172\172\172\208\208\ | |
203 | \028\028\028\028\028\070\070\070\064\064\064\064\064\100\100\100\ | |
204 | \100\100\136\136\136\136\136\172\172\172\172\172\208\208\028\028\ | |
205 | \028\028\028\070\070\070\070\070\064\064\064\106\106\100\100\100\ | |
206 | \142\136\136\136\136\136\172\172\172\172\172\208\034\034\034\034\ | |
207 | \034\070\070\070\070\070\070\070\064\106\106\106\106\142\142\142\ | |
208 | \142\142\136\178\178\178\178\172\214\214\034\034\034\034\034\076\ | |
209 | \070\070\070\070\070\070\070\106\106\106\106\106\142\142\142\142\ | |
210 | \142\178\178\178\178\178\214\214\034\034\034\034\034\076\076\070\ | |
211 | \070\070\070\070\070\106\106\106\106\106\142\142\142\142\142\178\ | |
212 | \178\178\178\178\214\214\034\034\034\034\034\076\076\076\070\070\ | |
213 | \070\070\070\106\106\106\106\106\142\142\142\142\142\178\178\178\ | |
214 | \178\178\214\214\034\034\034\034\034\076\076\076\076\070\070\070\ | |
215 | \070\070\106\106\106\106\106\142\142\142\142\184\178\178\178\178\ | |
216 | \220\214\040\040\040\040\040\076\076\076\076\076\076\076\070\112\ | |
217 | \112\112\112\106\148\148\148\148\184\184\184\184\184\178\220\220\ | |
218 | \040\040\040\040\040\076\076\076\076\076\076\076\076\112\112\112\ | |
219 | \112\112\148\148\148\148\148\184\184\184\184\184\220\220\040\040\ | |
220 | \040\040\040\082\076\076\076\076\076\076\076\112\112\112\112\112\ | |
221 | \148\148\148\148\148\184\184\184\184\184\220\220\040\040\040\040\ | |
222 | \040\082\082\076\076\076\076\076\076\112\112\112\112\112\148\148\ | |
223 | \148\148\148\184\184\184\184\184\220\220\040\040\040\040\040\082\ | |
224 | \082\082\082\076\076\076\076\076\112\112\112\112\112\148\148\148\ | |
225 | \148\148\184\184\184\184\226\220\046\046\046\046\046\082\082\082\ | |
226 | \082\082\082\082\076\118\118\118\118\112\154\154\154\154\190\190\ | |
227 | \190\190\190\226\226\226\046\046\046\046\046\082\082\082\082\082\ | |
228 | \082\082\082\118\118\118\118\118\154\154\154\154\154\190\190\190\ | |
229 | \190\190\226\226\017\053\089\052\052\052\052\052\052\052\052\052\ | |
230 | \052\088\088\088\088\088\124\124\124\124\124\160\160\160\160\160\ | |
231 | \196\196\023\232\095\052\052\052\052\052\052\052\052\052\052\088\ | |
232 | \088\088\088\088\124\124\124\124\124\160\160\160\160\160\196\196\ | |
233 | \029\065\101\094\052\052\052\052\052\052\052\052\052\088\088\088\ | |
234 | \088\088\124\124\124\124\124\160\160\160\160\160\196\196\022\022\ | |
235 | \064\058\058\094\052\052\052\052\052\052\052\088\088\088\088\088\ | |
236 | \124\124\124\124\124\160\160\160\160\160\196\196\022\022\022\058\ | |
237 | \058\058\094\094\094\052\052\052\052\088\088\088\088\088\124\124\ | |
238 | \124\124\124\160\160\160\160\160\196\196\022\022\022\064\058\058\ | |
239 | \058\094\094\094\094\094\130\130\130\130\130\130\124\124\124\124\ | |
240 | \124\160\160\160\160\160\196\196\022\022\022\022\064\058\058\058\ | |
241 | \094\094\094\094\094\130\130\130\130\130\130\166\166\166\166\166\ | |
242 | \166\166\202\202\202\202\022\022\022\022\064\064\058\058\058\094\ | |
243 | \094\094\094\094\130\130\130\130\130\130\166\166\166\166\166\166\ | |
244 | \166\202\202\202\022\022\022\022\064\064\064\058\058\058\094\094\ | |
245 | \094\094\094\094\130\130\130\130\130\130\166\166\166\166\166\202\ | |
246 | \202\202\022\022\022\022\022\064\064\064\058\058\058\058\094\094\ | |
247 | \094\094\094\130\130\130\130\130\166\166\166\166\166\166\202\202\ | |
248 | \022\022\022\022\022\064\064\064\064\058\058\058\058\094\094\094\ | |
249 | \094\094\130\130\130\130\130\166\166\166\166\166\202\202\022\022\ | |
250 | \022\022\022\064\064\064\064\058\058\058\058\094\094\094\094\094\ | |
251 | \130\130\130\130\130\166\166\166\166\166\202\202\022\022\022\022\ | |
252 | \022\070\064\064\064\064\058\058\058\100\094\094\094\094\094\130\ | |
253 | \130\130\130\130\166\166\166\166\166\202\028\028\028\028\028\070\ | |
254 | \070\064\064\064\064\064\100\100\100\100\094\094\136\136\136\130\ | |
255 | \130\172\172\166\166\166\208\202\028\028\028\028\028\070\070\070\ | |
256 | \064\064\064\064\064\100\100\100\100\136\136\136\136\136\172\172\ | |
257 | \172\172\172\172\208\208\028\028\028\028\028\070\070\070\064\064\ | |
258 | \064\064\064\100\100\100\100\100\136\136\136\136\136\172\172\172\ | |
259 | \172\172\208\208\028\028\028\028\028\070\070\070\070\064\064\064\ | |
260 | \064\064\100\100\100\100\136\136\136\136\136\172\172\172\172\172\ | |
261 | \208\208\028\028\028\028\028\070\070\070\070\070\064\064\064\064\ | |
262 | \106\100\100\100\142\136\136\136\136\136\172\172\172\172\172\208\ | |
263 | \034\034\034\034\034\034\070\070\070\070\070\070\064\106\106\106\ | |
264 | \106\142\142\142\142\136\136\178\178\178\172\172\214\208\034\034\ | |
265 | \034\034\034\034\076\070\070\070\070\070\070\106\106\106\106\106\ | |
266 | \142\142\142\142\142\178\178\178\178\178\214\214\034\034\034\034\ | |
267 | \034\034\076\076\070\070\070\070\070\106\106\106\106\106\142\142\ | |
268 | \142\142\142\178\178\178\178\178\214\214\034\034\034\034\034\034\ | |
269 | \076\076\070\070\070\070\070\070\106\106\106\106\106\142\142\142\ | |
270 | \142\178\178\178\178\178\214\214\034\034\034\034\034\034\076\076\ | |
271 | \076\076\070\070\070\070\112\106\106\106\106\142\142\142\142\184\ | |
272 | \178\178\178\178\220\214\040\040\040\040\040\040\076\076\076\076\ | |
273 | \076\076\070\112\112\112\112\106\148\148\148\148\184\184\184\184\ | |
274 | \178\178\220\220\040\040\040\040\040\040\076\076\076\076\076\076\ | |
275 | \076\112\112\112\112\112\148\148\148\148\148\184\184\184\184\184\ | |
276 | \220\220\040\040\040\040\040\040\076\076\076\076\076\076\076\076\ | |
277 | \112\112\112\112\148\148\148\148\148\184\184\184\184\184\220\220\ | |
278 | \040\040\040\040\040\040\082\076\076\076\076\076\076\076\112\112\ | |
279 | \112\112\112\148\148\148\148\148\184\184\184\184\220\220\040\040\ | |
280 | \040\040\040\040\082\082\082\076\076\076\076\076\112\112\112\112\ | |
281 | \112\148\148\148\148\148\184\184\184\184\226\220\046\046\046\046\ | |
282 | \046\046\082\082\082\082\082\082\076\118\118\118\118\112\154\154\ | |
283 | \154\154\190\190\190\190\190\226\226\226\046\046\046\046\046\046\ | |
284 | \082\082\082\082\082\082\082\082\118\118\118\118\118\154\154\154\ | |
285 | \154\190\190\190\190\190\226\226\017\054\053\089\089\052\052\052\ | |
286 | \052\052\052\052\052\088\088\088\088\088\124\124\124\124\124\160\ | |
287 | \160\160\160\160\196\196\024\060\096\089\052\052\052\052\052\052\ | |
288 | \052\052\052\088\088\088\088\088\124\124\124\124\124\160\160\160\ | |
289 | \160\160\196\196\023\066\233\234\095\052\052\052\052\052\052\052\ | |
290 | \052\088\088\088\088\088\124\124\124\124\124\160\160\160\160\160\ | |
291 | \196\196\029\029\234\234\095\095\052\052\052\052\052\052\052\088\ | |
292 | \088\088\088\088\124\124\124\124\124\160\160\160\160\160\196\196\ | |
293 | \029\022\065\065\101\101\094\052\052\052\052\052\052\088\088\088\ | |
294 | \088\088\124\124\124\124\124\160\160\160\160\160\196\196\022\022\ | |
295 | \022\065\101\058\058\094\094\094\094\130\052\088\088\088\088\088\ | |
296 | \124\124\124\124\124\160\160\160\160\160\196\196\022\022\022\022\ | |
297 | \064\058\058\058\094\094\094\094\094\130\130\130\130\130\130\166\ | |
298 | \166\166\166\166\160\160\160\160\196\196\022\022\022\022\022\064\ | |
299 | \058\058\058\094\094\094\094\094\130\130\130\130\130\130\166\166\ | |
300 | \166\166\166\166\202\202\202\202\022\022\022\022\022\064\064\058\ | |
301 | \058\058\094\094\094\094\094\130\130\130\130\130\130\166\166\166\ | |
302 | \166\166\166\202\202\202\022\022\022\022\022\064\064\064\058\058\ | |
303 | \058\058\094\094\094\094\094\130\130\130\130\130\166\166\166\166\ | |
304 | \166\202\202\202\022\022\022\022\022\064\064\064\064\058\058\058\ | |
305 | \058\094\094\094\094\130\130\130\130\130\130\166\166\166\166\166\ | |
306 | \202\202\022\022\022\022\022\070\064\064\064\058\058\058\058\094\ | |
307 | \094\094\094\094\130\130\130\130\130\166\166\166\166\166\202\202\ | |
308 | \022\022\022\022\022\022\064\064\064\064\058\058\058\100\094\094\ | |
309 | \094\094\094\130\130\130\130\166\166\166\166\166\202\202\028\028\ | |
310 | \028\028\028\028\070\064\064\064\064\064\100\100\100\100\094\094\ | |
311 | \136\136\130\130\130\130\166\166\166\166\166\202\028\028\028\028\ | |
312 | \028\028\070\070\064\064\064\064\064\100\100\100\100\136\136\136\ | |
313 | \136\136\172\172\172\172\172\166\208\208\028\028\028\028\028\028\ | |
314 | \070\070\070\064\064\064\064\100\100\100\100\100\136\136\136\136\ | |
315 | \136\172\172\172\172\172\208\208\028\028\028\028\028\028\070\070\ | |
316 | \070\064\064\064\064\064\100\100\100\100\136\136\136\136\136\172\ | |
317 | \172\172\172\172\208\208\028\028\028\028\028\028\070\070\070\070\ | |
318 | \070\064\064\064\106\100\100\100\142\136\136\136\136\136\172\172\ | |
319 | \172\172\208\208\034\034\034\034\034\034\070\070\070\070\070\070\ | |
320 | \064\106\106\106\106\142\142\142\142\136\136\178\178\172\172\172\ | |
321 | \214\208\034\034\034\034\034\034\076\070\070\070\070\070\070\106\ | |
322 | \106\106\106\106\142\142\142\142\136\178\178\178\178\172\214\214\ | |
323 | \034\034\034\034\034\034\076\076\070\070\070\070\070\070\106\106\ | |
324 | \106\106\142\142\142\142\142\178\178\178\178\178\214\214\034\034\ | |
325 | \034\034\034\034\076\076\076\070\070\070\070\070\106\106\106\106\ | |
326 | \106\142\142\142\142\178\178\178\178\178\214\214\034\034\034\034\ | |
327 | \034\034\076\076\076\076\070\070\070\070\112\106\106\106\106\106\ | |
328 | \142\142\142\184\178\178\178\178\220\214\040\040\040\040\040\040\ | |
329 | \076\076\076\076\076\076\076\070\112\112\112\106\148\148\148\148\ | |
330 | \184\184\184\184\178\178\220\214\040\040\040\040\040\040\040\076\ | |
331 | \076\076\076\076\076\076\112\112\112\112\148\148\148\148\148\184\ | |
332 | \184\184\184\178\220\220\040\040\040\040\040\040\040\076\076\076\ | |
333 | \076\076\076\076\112\112\112\112\112\148\148\148\148\184\184\184\ | |
334 | \184\184\220\220\040\040\040\040\040\040\040\082\076\076\076\076\ | |
335 | \076\076\112\112\112\112\112\148\148\148\148\148\184\184\184\184\ | |
336 | \220\220\040\040\040\040\040\040\040\082\082\082\076\076\076\076\ | |
337 | \076\112\112\112\112\112\148\148\148\148\148\184\184\184\226\220\ | |
338 | \046\046\046\046\046\046\046\082\082\082\082\082\082\076\118\118\ | |
339 | \118\118\154\154\154\154\190\190\190\190\190\226\226\226\046\046\ | |
340 | \046\046\046\046\046\082\082\082\082\082\082\082\118\118\118\118\ | |
341 | \118\154\154\154\154\154\190\190\190\190\226\226\017\017\054\053\ | |
342 | \053\089\089\089\052\052\052\052\052\088\088\088\088\088\124\124\ | |
343 | \124\124\124\160\160\160\160\160\196\196\017\017\054\053\053\089\ | |
344 | \052\052\052\052\052\052\052\088\088\088\088\088\124\124\124\124\ | |
345 | \124\160\160\160\160\160\196\196\024\024\234\234\096\095\052\052\ | |
346 | \052\052\052\052\052\088\088\088\088\088\124\124\124\124\124\160\ | |
347 | \160\160\160\160\196\196\023\023\234\234\235\095\095\095\052\052\ | |
348 | \052\052\052\088\088\088\088\088\124\124\124\124\124\160\160\160\ | |
349 | \160\160\196\196\023\023\066\235\235\101\095\095\052\052\052\052\ | |
350 | \052\088\088\088\088\088\124\124\124\124\124\160\160\160\160\160\ | |
351 | \196\196\029\029\065\065\065\101\101\137\137\137\052\052\052\088\ | |
352 | \088\088\088\088\124\124\124\124\124\160\160\160\160\160\196\196\ | |
353 | \029\022\022\065\065\101\101\101\137\094\137\137\137\130\088\088\ | |
354 | \088\088\124\124\124\124\124\160\160\160\160\160\196\196\029\022\ | |
355 | \022\065\065\107\101\101\058\094\094\094\094\130\130\130\130\130\ | |
356 | \130\166\166\166\166\166\166\160\160\202\202\196\022\022\022\022\ | |
357 | \022\107\107\058\058\058\094\094\094\094\130\130\130\130\130\130\ | |
358 | \166\166\166\166\166\166\166\202\202\202\022\022\022\022\022\107\ | |
359 | \064\064\058\058\058\058\094\094\094\094\130\130\130\130\130\130\ | |
360 | \166\166\166\166\166\202\202\202\022\022\022\022\022\022\107\064\ | |
361 | \064\058\058\058\058\094\094\094\094\130\130\130\130\130\166\166\ | |
362 | \166\166\166\202\202\202\022\022\022\022\022\022\107\064\064\058\ | |
363 | \058\058\058\094\094\094\094\130\130\130\130\130\166\166\166\166\ | |
364 | \166\166\202\202\022\022\022\022\022\022\107\064\064\064\058\058\ | |
365 | \058\100\094\094\094\094\130\130\130\130\130\166\166\166\166\166\ | |
366 | \202\202\028\028\028\028\028\028\070\070\064\064\064\064\100\100\ | |
367 | \100\094\094\094\094\130\130\130\130\130\166\166\166\166\202\202\ | |
368 | \028\028\028\028\028\028\028\070\070\064\064\064\064\100\100\100\ | |
369 | \100\136\136\136\136\136\130\172\172\166\166\166\208\202\028\028\ | |
370 | \028\028\028\028\028\070\070\064\064\064\064\064\100\100\100\100\ | |
371 | \136\136\136\136\136\172\172\172\172\172\208\208\028\028\028\028\ | |
372 | \028\028\028\070\070\070\064\064\064\064\100\100\100\100\136\136\ | |
373 | \136\136\136\172\172\172\172\172\208\208\028\028\028\028\028\028\ | |
374 | \028\070\070\070\070\070\064\064\106\100\100\100\142\136\136\136\ | |
375 | \136\172\172\172\172\172\208\208\034\034\034\034\034\034\034\070\ | |
376 | \070\070\070\070\070\064\106\106\106\142\142\142\136\136\136\178\ | |
377 | \178\172\172\172\172\208\034\034\034\034\034\034\034\076\070\070\ | |
378 | \070\070\070\070\106\106\106\106\142\142\142\142\136\178\178\178\ | |
379 | \178\172\214\214\034\034\034\034\034\034\034\076\076\070\070\070\ | |
380 | \070\070\106\106\106\106\106\142\142\142\142\178\178\178\178\178\ | |
381 | \214\214\034\034\034\034\034\034\034\076\076\070\070\070\070\070\ | |
382 | \106\106\106\106\106\142\142\142\142\178\178\178\178\178\214\214\ | |
383 | \034\034\034\034\034\034\034\076\076\076\076\076\070\070\070\106\ | |
384 | \106\106\106\106\142\142\142\184\178\178\178\178\214\214\040\040\ | |
385 | \040\040\040\040\040\076\076\076\076\076\076\070\112\112\112\112\ | |
386 | \148\148\148\148\184\184\184\184\178\178\220\214\040\040\040\040\ | |
387 | \040\040\040\076\076\076\076\076\076\076\112\112\112\112\148\148\ | |
388 | \148\148\148\184\184\184\184\178\220\220\040\040\040\040\040\040\ | |
389 | \040\040\076\076\076\076\076\076\076\112\112\112\112\148\148\148\ | |
390 | \148\184\184\184\184\184\220\220\040\040\040\040\040\040\040\040\ | |
391 | \076\076\076\076\076\076\076\112\112\112\112\148\148\148\148\148\ | |
392 | \184\184\184\184\220\220\040\040\040\040\040\040\040\082\082\082\ | |
393 | \082\076\076\076\076\112\112\112\112\112\148\148\148\148\148\184\ | |
394 | \184\184\226\220\046\046\046\046\046\046\046\082\082\082\082\082\ | |
395 | \082\082\118\118\118\118\112\154\154\154\154\190\190\190\190\226\ | |
396 | \226\226\046\046\046\046\046\046\046\046\082\082\082\082\082\082\ | |
397 | \082\118\118\118\118\154\154\154\154\154\190\190\190\190\226\226\ | |
398 | \017\017\054\053\053\053\089\089\089\089\125\125\125\125\088\088\ | |
399 | \088\088\124\124\124\124\124\160\160\160\160\160\196\196\017\017\ | |
400 | \017\053\053\053\089\089\089\052\052\052\052\088\088\088\088\088\ | |
401 | \124\124\124\124\124\160\160\160\160\160\196\196\024\017\060\096\ | |
402 | \096\096\089\052\052\052\052\052\052\088\088\088\088\088\124\124\ | |
403 | \124\124\124\160\160\160\160\160\196\196\023\023\060\235\235\096\ | |
404 | \095\095\052\052\052\052\052\088\088\088\088\088\124\124\124\124\ | |
405 | \124\160\160\160\160\160\196\196\023\023\066\235\235\236\095\095\ | |
406 | \095\095\095\131\131\131\088\088\088\088\124\124\124\124\124\160\ | |
407 | \160\160\160\160\196\196\023\023\066\066\236\236\237\095\095\095\ | |
408 | \095\131\131\131\088\088\088\088\124\124\124\124\124\160\160\160\ | |
409 | \160\160\196\196\029\029\029\065\065\237\101\101\095\137\137\137\ | |
410 | \137\137\131\131\131\088\124\124\124\124\124\160\160\160\160\160\ | |
411 | \196\196\029\029\022\065\065\065\101\101\101\137\137\137\137\137\ | |
412 | \137\137\137\173\173\173\173\173\173\160\160\160\160\160\196\196\ | |
413 | \029\029\022\022\065\065\065\101\101\101\137\137\137\137\137\137\ | |
414 | \137\137\173\173\173\173\173\173\209\209\209\209\209\209\029\022\ | |
415 | \022\022\065\065\107\107\101\101\101\143\137\137\137\137\137\130\ | |
416 | \130\130\130\166\166\166\166\166\166\202\202\202\035\022\022\022\ | |
417 | \065\065\107\107\107\101\101\143\143\094\094\094\094\130\130\130\ | |
418 | \130\130\166\166\166\166\166\202\202\202\035\022\022\022\071\071\ | |
419 | \107\107\107\143\143\143\143\094\094\094\094\130\130\130\130\130\ | |
420 | \166\166\166\166\166\202\202\202\035\022\022\022\071\071\107\107\ | |
421 | \107\107\143\143\143\143\094\094\094\094\130\130\130\130\130\166\ | |
422 | \166\166\166\166\202\202\035\028\028\028\071\071\071\107\107\107\ | |
423 | \064\064\143\143\100\094\094\094\094\130\130\130\130\166\166\166\ | |
424 | \166\166\202\202\028\028\028\028\028\028\071\107\107\107\064\064\ | |
425 | \064\100\100\100\100\136\136\136\130\130\130\172\166\166\166\166\ | |
426 | \166\202\028\028\028\028\028\028\071\107\107\107\064\064\064\064\ | |
427 | \100\100\100\100\136\136\136\136\172\172\172\172\172\166\208\202\ | |
428 | \028\028\028\028\028\028\071\107\107\107\064\064\064\064\100\100\ | |
429 | \100\100\136\136\136\136\136\172\172\172\172\166\208\208\028\028\ | |
430 | \028\028\028\028\028\113\107\070\070\070\064\064\106\100\100\100\ | |
431 | \142\136\136\136\136\172\172\172\172\172\208\208\034\034\034\034\ | |
432 | \034\034\034\113\113\070\070\070\070\064\106\106\106\142\142\142\ | |
433 | \136\136\136\178\172\172\172\172\172\208\034\034\034\034\034\034\ | |
434 | \034\113\113\070\070\070\070\070\106\106\106\106\142\142\142\142\ | |
435 | \136\178\178\178\178\172\214\208\034\034\034\034\034\034\034\113\ | |
436 | \113\070\070\070\070\070\070\106\106\106\106\142\142\142\142\178\ | |
437 | \178\178\178\178\214\214\034\034\034\034\034\034\034\113\113\076\ | |
438 | \070\070\070\070\070\106\106\106\106\142\142\142\142\178\178\178\ | |
439 | \178\178\214\214\034\034\034\034\034\034\034\113\113\076\076\076\ | |
440 | \070\070\070\112\106\106\106\106\142\142\142\184\178\178\178\178\ | |
441 | \214\214\040\040\040\040\040\040\040\040\113\076\076\076\076\076\ | |
442 | \112\112\112\112\148\148\148\148\184\184\184\178\178\178\220\214\ | |
443 | \040\040\040\040\040\040\040\040\119\076\076\076\076\076\076\112\ | |
444 | \112\112\112\148\148\148\148\184\184\184\184\178\220\220\040\040\ | |
445 | \040\040\040\040\040\040\119\076\076\076\076\076\076\112\112\112\ | |
446 | \112\148\148\148\148\148\184\184\184\184\220\220\040\040\040\040\ | |
447 | \040\040\040\040\119\076\076\076\076\076\076\112\112\112\112\148\ | |
448 | \148\148\148\148\184\184\184\184\220\220\040\040\040\040\040\040\ | |
449 | \040\040\119\082\082\082\076\076\076\076\076\112\112\112\148\148\ | |
450 | \148\148\148\184\184\184\226\220\046\046\046\046\046\046\046\046\ | |
451 | \119\082\082\082\082\082\076\118\118\118\112\154\154\154\154\190\ | |
452 | \190\190\190\226\226\226\046\046\046\046\046\046\046\046\119\082\ | |
453 | \082\082\082\082\082\082\118\118\118\118\154\154\154\154\190\190\ | |
454 | \190\190\226\226\017\017\017\054\053\053\053\089\089\089\089\089\ | |
455 | \125\125\125\125\125\125\125\161\161\161\161\161\161\197\197\197\ | |
456 | \197\197\017\017\017\054\053\053\053\089\089\089\089\089\125\125\ | |
457 | \125\125\125\125\124\124\124\124\124\160\160\160\160\160\196\196\ | |
458 | \017\017\017\060\096\053\053\089\089\089\089\125\052\088\088\088\ | |
459 | \088\088\124\124\124\124\124\160\160\160\160\160\196\196\024\024\ | |
460 | \060\060\096\096\096\132\132\132\052\052\052\088\088\088\088\088\ | |
461 | \124\124\124\124\124\160\160\160\160\160\196\196\023\023\066\060\ | |
462 | \236\236\237\095\095\095\095\131\131\131\088\088\088\088\124\124\ | |
463 | \124\124\124\160\160\160\160\160\196\196\023\023\023\066\236\236\ | |
464 | \237\095\095\095\095\095\095\131\131\131\131\131\131\167\167\167\ | |
465 | \167\167\167\203\203\203\203\203\023\023\023\066\237\237\237\238\ | |
466 | \095\095\095\095\095\131\131\131\131\131\131\167\167\167\167\167\ | |
467 | \167\203\203\203\203\203\029\029\029\072\065\065\238\101\101\095\ | |
468 | \095\095\137\137\137\131\131\131\131\173\167\167\167\167\167\203\ | |
469 | \203\203\203\203\029\029\029\072\065\065\065\101\101\101\101\101\ | |
470 | \137\137\137\137\137\137\173\173\173\173\173\173\173\209\209\209\ | |
471 | \209\209\029\029\029\072\065\065\065\065\101\101\101\101\137\137\ | |
472 | \137\137\137\137\137\173\173\173\173\173\173\209\209\209\209\209\ | |
473 | \029\029\029\022\065\065\065\065\101\101\101\101\101\137\137\137\ | |
474 | \137\137\137\173\173\173\173\173\173\209\209\209\209\209\029\029\ | |
475 | \035\022\071\065\065\065\101\101\101\101\101\137\137\137\137\137\ | |
476 | \137\173\173\173\173\173\173\209\209\209\209\209\035\035\022\022\ | |
477 | \071\065\065\107\107\107\101\101\101\143\143\137\137\137\137\137\ | |
478 | \173\173\173\173\173\173\173\209\209\209\035\035\028\028\071\071\ | |
479 | \071\107\107\107\107\107\143\143\143\143\143\137\137\179\179\179\ | |
480 | \173\173\173\166\215\215\209\202\035\035\028\028\028\071\071\071\ | |
481 | \107\107\107\107\107\143\143\143\143\143\179\179\179\179\179\179\ | |
482 | \215\215\215\215\215\202\035\035\028\028\028\071\071\071\107\107\ | |
483 | \107\107\107\143\143\143\143\143\179\179\179\179\179\179\179\215\ | |
484 | \215\215\215\202\035\035\028\028\028\071\071\071\107\107\107\107\ | |
485 | \107\143\143\143\143\143\143\179\179\179\179\179\179\215\215\215\ | |
486 | \215\215\035\035\028\028\028\071\071\071\107\107\107\107\107\107\ | |
487 | \143\143\143\143\143\185\179\179\179\179\179\179\215\215\215\215\ | |
488 | \035\034\034\034\034\071\071\071\113\107\107\107\107\107\149\149\ | |
489 | \143\143\143\185\185\185\179\179\179\179\172\215\215\215\041\034\ | |
490 | \034\034\034\077\077\077\113\113\113\113\107\149\149\149\149\185\ | |
491 | \185\185\185\185\185\179\179\221\221\221\221\215\041\034\034\034\ | |
492 | \034\077\077\077\113\113\113\113\113\149\149\149\149\149\185\185\ | |
493 | \185\185\185\185\179\221\221\221\221\214\041\034\034\034\034\077\ | |
494 | \077\077\113\113\113\113\113\149\149\149\149\149\185\185\185\185\ | |
495 | \185\185\178\221\221\221\221\214\041\034\034\034\034\077\077\077\ | |
496 | \113\113\113\113\113\149\149\149\149\149\149\185\185\185\185\185\ | |
497 | \185\178\221\221\221\214\041\040\040\040\040\077\077\077\113\113\ | |
498 | \113\113\113\113\149\149\149\149\149\149\185\185\185\185\185\227\ | |
499 | \227\221\221\221\041\040\040\040\040\077\077\077\113\113\113\113\ | |
500 | \113\113\155\149\149\149\149\149\149\148\185\185\185\227\227\227\ | |
501 | \221\221\047\040\040\040\040\083\083\083\119\119\119\119\113\076\ | |
502 | \155\155\155\149\149\191\191\191\148\227\227\227\227\227\227\221\ | |
503 | \047\040\040\040\040\083\083\083\119\119\119\119\113\155\155\155\ | |
504 | \155\155\112\191\191\191\191\227\227\227\227\227\227\220\047\040\ | |
505 | \040\040\040\083\083\083\119\119\119\119\119\155\155\155\155\155\ | |
506 | \155\191\191\191\191\191\227\227\227\227\227\220\047\046\046\046\ | |
507 | \046\083\083\083\119\119\119\119\119\119\155\155\155\155\155\191\ | |
508 | \191\191\191\191\191\227\227\227\227\227\047\046\046\046\046\083\ | |
509 | \083\083\119\119\119\119\119\082\082\082\155\155\155\155\154\154\ | |
510 | \154\191\191\191\190\190\227\227\017\017\017\054\054\053\053\053\ | |
511 | \089\089\089\089\089\125\125\125\125\125\125\125\161\161\161\161\ | |
512 | \161\161\197\197\197\197\017\017\017\017\054\053\053\053\089\089\ | |
513 | \089\089\089\125\125\125\125\125\125\161\161\161\161\161\161\161\ | |
514 | \197\197\197\197\017\017\017\017\054\053\053\053\089\089\089\089\ | |
515 | \089\125\125\125\125\125\125\161\161\161\161\161\160\160\160\160\ | |
516 | \196\196\024\017\017\060\060\096\096\096\132\089\132\132\132\125\ | |
517 | \088\088\088\088\124\124\124\124\124\160\160\160\160\160\196\196\ | |
518 | \024\024\024\060\060\237\096\096\096\132\132\132\132\131\131\131\ | |
519 | \131\088\124\124\124\124\124\160\160\160\160\160\196\196\023\023\ | |
520 | \023\066\237\237\237\238\095\095\095\095\095\131\131\131\131\131\ | |
521 | \131\167\167\167\167\167\167\203\203\203\203\203\023\023\023\066\ | |
522 | \066\237\237\238\095\095\095\095\095\095\131\131\131\131\131\131\ | |
523 | \167\167\167\167\167\167\167\203\203\203\023\023\023\066\066\238\ | |
524 | \238\238\239\095\095\095\095\095\131\131\131\131\131\131\167\167\ | |
525 | \167\167\167\167\167\203\203\203\029\029\029\072\066\065\065\239\ | |
526 | \101\101\101\101\095\137\137\137\137\131\131\131\173\173\167\167\ | |
527 | \167\167\167\203\203\203\029\029\029\029\072\065\065\065\101\101\ | |
528 | \101\101\101\137\137\137\137\137\137\173\173\173\173\173\173\209\ | |
529 | \209\209\209\209\029\029\029\072\072\065\065\065\101\101\101\101\ | |
530 | \101\137\137\137\137\137\137\173\173\173\173\173\173\173\209\209\ | |
531 | \209\209\029\029\029\072\072\065\065\065\065\101\101\101\101\137\ | |
532 | \137\137\137\137\137\173\173\173\173\173\173\173\209\209\209\209\ | |
533 | \029\029\029\072\072\065\065\065\065\101\101\101\101\101\137\137\ | |
534 | \137\137\137\137\173\173\173\173\173\173\173\209\209\209\035\035\ | |
535 | \035\035\072\071\065\065\107\107\107\107\101\101\143\143\137\137\ | |
536 | \137\137\137\173\173\173\173\173\173\209\209\209\035\035\035\028\ | |
537 | \071\071\071\071\107\107\107\107\107\143\143\143\143\143\137\179\ | |
538 | \179\179\179\173\173\173\215\215\215\209\035\035\035\028\071\071\ | |
539 | \071\071\107\107\107\107\107\143\143\143\143\143\143\179\179\179\ | |
540 | \179\179\179\215\215\215\215\215\035\035\035\028\071\071\071\071\ | |
541 | \071\107\107\107\107\107\143\143\143\143\143\179\179\179\179\179\ | |
542 | \179\215\215\215\215\215\035\035\035\028\028\071\071\071\071\107\ | |
543 | \107\107\107\107\143\143\143\143\143\143\179\179\179\179\179\179\ | |
544 | \215\215\215\215\035\035\035\034\034\071\071\071\071\107\107\107\ | |
545 | \107\107\107\143\143\143\143\143\185\185\179\179\179\179\179\215\ | |
546 | \215\215\035\041\041\034\034\077\071\071\071\113\113\113\107\107\ | |
547 | \149\149\149\143\143\143\185\185\185\179\179\179\179\221\215\215\ | |
548 | \041\041\041\034\034\077\077\077\113\113\113\113\113\107\149\149\ | |
549 | \149\149\185\185\185\185\185\185\179\179\221\221\221\215\041\041\ | |
550 | \041\034\034\077\077\077\077\113\113\113\113\149\149\149\149\149\ | |
551 | \185\185\185\185\185\185\179\179\221\221\221\215\041\041\041\034\ | |
552 | \034\077\077\077\077\113\113\113\113\113\149\149\149\149\149\185\ | |
553 | \185\185\185\185\185\221\221\221\221\221\041\041\041\040\040\077\ | |
554 | \077\077\077\113\113\113\113\113\149\149\149\149\149\149\185\185\ | |
555 | \185\185\185\185\185\221\221\221\041\041\040\040\040\077\077\077\ | |
556 | \077\113\113\113\113\113\113\149\149\149\149\149\149\149\185\185\ | |
557 | \185\185\185\227\221\221\041\041\040\040\040\083\077\077\077\119\ | |
558 | \113\113\113\113\113\155\155\149\149\149\149\149\191\185\185\185\ | |
559 | \185\227\221\221\047\047\040\040\040\083\077\077\077\119\119\119\ | |
560 | \113\113\155\155\155\155\149\149\191\191\191\185\185\185\185\227\ | |
561 | \227\221\047\047\040\040\040\083\083\083\083\119\119\119\119\119\ | |
562 | \155\155\155\155\155\191\191\191\191\191\227\227\227\227\227\221\ | |
563 | \047\047\046\046\046\083\083\083\083\119\119\119\119\119\155\155\ | |
564 | \155\155\155\155\191\191\191\191\191\191\227\227\227\227\047\047\ | |
565 | \046\046\046\083\083\083\083\119\119\119\119\119\119\155\155\155\ | |
566 | \155\155\155\155\191\191\191\191\191\191\227\227\017\017\017\054\ | |
567 | \054\054\053\053\053\089\089\089\089\089\089\125\125\125\125\125\ | |
568 | \125\161\161\161\161\161\161\197\197\197\017\017\017\017\054\054\ | |
569 | \053\053\053\089\089\089\089\089\125\125\125\125\125\125\161\161\ | |
570 | \161\161\161\161\161\197\197\197\017\017\017\017\017\054\053\053\ | |
571 | \053\089\089\089\089\089\125\125\125\125\125\125\161\161\161\161\ | |
572 | \161\161\197\197\197\197\024\017\017\060\060\097\096\096\053\089\ | |
573 | \089\089\089\125\125\125\125\125\125\161\161\161\161\161\161\160\ | |
574 | \160\197\197\196\024\024\017\060\060\060\096\096\096\132\132\132\ | |
575 | \132\132\132\132\132\168\168\168\168\168\168\160\160\160\160\160\ | |
576 | \196\196\024\024\024\067\060\060\238\096\096\096\095\095\132\132\ | |
577 | \131\131\131\131\131\168\167\167\167\167\167\203\203\203\203\203\ | |
578 | \023\023\023\066\066\238\238\238\239\095\095\095\095\095\131\131\ | |
579 | \131\131\131\131\167\167\167\167\167\167\167\203\203\203\023\023\ | |
580 | \023\066\066\066\238\238\239\095\095\095\095\095\095\131\131\131\ | |
581 | \131\131\131\167\167\167\167\167\167\203\203\203\023\023\023\023\ | |
582 | \066\066\239\239\239\240\095\095\095\095\095\131\131\131\131\131\ | |
583 | \131\167\167\167\167\167\167\203\203\203\029\029\029\029\072\066\ | |
584 | \065\065\240\101\101\101\101\095\137\137\137\137\131\131\131\173\ | |
585 | \173\167\167\167\167\209\203\203\029\029\029\029\072\065\065\065\ | |
586 | \065\101\101\101\101\101\137\137\137\137\137\137\173\173\173\173\ | |
587 | \173\173\173\209\209\209\029\029\029\029\072\065\065\065\065\101\ | |
588 | \101\101\101\101\137\137\137\137\137\137\173\173\173\173\173\173\ | |
589 | \173\209\209\209\029\029\029\029\072\072\065\065\065\065\101\101\ | |
590 | \101\101\137\137\137\137\137\137\173\173\173\173\173\173\173\209\ | |
591 | \209\209\029\029\029\035\072\072\065\065\065\065\101\101\101\101\ | |
592 | \101\137\137\137\137\137\137\137\173\173\173\173\173\209\209\209\ | |
593 | \029\035\035\035\072\072\071\065\065\107\107\107\107\101\101\143\ | |
594 | \143\143\137\137\137\137\173\173\173\173\173\173\209\209\035\035\ | |
595 | \035\035\072\071\071\071\071\107\107\107\107\107\143\143\143\143\ | |
596 | \137\137\179\179\179\179\173\173\173\215\215\209\035\035\035\035\ | |
597 | \072\071\071\071\071\107\107\107\107\107\143\143\143\143\143\137\ | |
598 | \179\179\179\179\173\173\173\215\215\209\035\035\035\035\078\071\ | |
599 | \071\071\071\071\107\107\107\107\107\143\143\143\143\143\179\179\ | |
600 | \179\179\179\179\179\215\215\215\035\035\035\035\078\071\071\071\ | |
601 | \071\071\107\107\107\107\107\107\143\143\143\143\143\179\179\179\ | |
602 | \179\179\179\215\215\215\035\035\035\041\078\078\071\071\071\071\ | |
603 | \107\107\107\107\107\107\107\143\143\143\143\185\185\179\179\179\ | |
604 | \179\179\215\215\035\041\041\041\078\077\077\071\071\071\113\113\ | |
605 | \113\107\107\149\149\149\143\143\143\185\185\179\179\179\179\221\ | |
606 | \221\215\041\041\041\041\078\077\077\077\077\113\113\113\113\107\ | |
607 | \107\149\149\149\149\185\185\185\185\185\179\179\179\221\221\215\ | |
608 | \041\041\041\041\078\077\077\077\077\077\113\113\113\113\149\149\ | |
609 | \149\149\149\185\185\185\185\185\185\179\179\221\221\221\041\041\ | |
610 | \041\041\040\077\077\077\077\077\113\113\113\113\113\149\149\149\ | |
611 | \149\149\149\185\185\185\185\185\185\221\221\221\041\041\041\041\ | |
612 | \040\077\077\077\077\077\113\113\113\113\113\113\149\149\149\149\ | |
613 | \149\149\185\185\185\185\185\227\221\221\041\041\041\040\040\083\ | |
614 | \077\077\077\077\113\113\113\113\113\113\113\149\149\149\149\149\ | |
615 | \149\185\185\185\185\227\221\221\041\041\047\040\040\083\077\077\ | |
616 | \077\077\113\113\113\113\113\113\113\149\149\149\149\149\149\185\ | |
617 | \185\185\185\227\227\221\047\047\047\047\040\083\083\083\083\119\ | |
618 | \119\119\119\119\113\155\155\155\155\149\191\191\191\191\227\227\ | |
619 | \227\227\227\221\047\047\047\047\046\083\083\083\083\083\119\119\ | |
620 | \119\119\119\155\155\155\155\155\191\191\191\191\191\191\227\227\ | |
621 | \227\227\047\047\047\046\046\083\083\083\083\083\119\119\119\119\ | |
622 | \119\119\119\155\155\155\155\155\191\191\191\191\191\191\227\227\ | |
623 | \017\017\017\017\054\054\054\053\053\053\053\089\089\089\089\089\ | |
624 | \089\125\125\125\125\125\161\161\161\161\161\197\197\197\017\017\ | |
625 | \017\017\054\054\054\053\053\053\089\089\089\089\089\089\125\125\ | |
626 | \125\125\125\125\161\161\161\161\161\197\197\197\017\017\017\017\ | |
627 | \017\054\054\053\053\053\089\089\089\089\089\125\125\125\125\125\ | |
628 | \125\161\161\161\161\161\161\197\197\197\017\017\017\017\017\097\ | |
629 | \097\053\053\053\089\089\089\089\125\125\125\125\125\125\161\161\ | |
630 | \161\161\161\161\161\197\197\197\024\024\017\017\060\060\096\096\ | |
631 | \096\096\132\132\132\132\132\132\132\132\168\168\168\168\168\168\ | |
632 | \204\204\204\204\204\204\024\024\024\067\060\060\060\096\096\096\ | |
633 | \096\096\132\132\132\132\132\132\168\168\168\168\168\168\168\204\ | |
634 | \204\204\204\204\024\024\024\067\060\060\060\239\096\096\096\096\ | |
635 | \095\132\132\132\131\131\131\131\168\168\167\167\167\167\167\203\ | |
636 | \203\203\023\023\023\023\066\066\239\239\239\240\095\095\095\095\ | |
637 | \095\131\131\131\131\131\131\167\167\167\167\167\167\203\203\203\ | |
638 | \023\023\023\023\066\066\066\239\239\240\059\095\095\095\095\095\ | |
639 | \095\131\131\131\131\131\167\167\167\167\167\203\203\203\023\023\ | |
640 | \023\023\066\066\066\240\240\240\059\241\095\095\095\095\095\131\ | |
641 | \131\131\131\131\167\167\167\167\167\203\203\203\023\029\029\029\ | |
642 | \072\066\066\065\059\059\059\101\101\095\095\095\095\131\131\131\ | |
643 | \131\131\167\167\167\167\167\167\203\203\029\029\029\029\072\066\ | |
644 | \066\065\065\241\101\101\101\095\095\137\137\137\137\131\131\131\ | |
645 | \173\173\167\167\167\209\209\203\029\029\029\029\072\072\065\065\ | |
646 | \065\065\101\101\101\101\101\137\137\137\137\137\137\173\173\173\ | |
647 | \173\173\173\209\209\209\029\029\029\029\072\072\072\065\065\065\ | |
648 | \065\065\101\101\101\101\137\137\137\137\137\137\173\173\173\173\ | |
649 | \173\209\209\209\029\029\029\035\072\072\072\065\065\065\065\065\ | |
650 | \101\101\101\101\101\137\137\137\137\137\173\173\173\173\173\173\ | |
651 | \209\209\029\029\035\035\072\072\072\071\065\065\065\107\107\101\ | |
652 | \101\101\101\143\137\137\137\137\137\173\173\173\173\173\209\209\ | |
653 | \029\035\035\035\072\072\071\071\065\065\065\107\107\107\101\101\ | |
654 | \101\143\143\137\137\137\179\173\173\173\173\173\215\209\035\035\ | |
655 | \035\035\072\072\071\071\071\071\071\107\107\107\107\143\143\143\ | |
656 | \143\143\137\179\179\179\179\179\173\215\215\215\035\035\035\035\ | |
657 | \078\078\071\071\071\071\071\071\107\107\107\107\107\143\143\143\ | |
658 | \143\143\179\179\179\179\179\215\215\215\035\035\035\035\078\078\ | |
659 | \071\071\071\071\071\071\107\107\107\107\107\143\143\143\143\143\ | |
660 | \179\179\179\179\179\179\215\215\035\035\035\041\078\078\078\071\ | |
661 | \071\071\071\071\107\107\107\107\107\107\143\143\143\143\185\179\ | |
662 | \179\179\179\179\215\215\035\035\041\041\078\078\078\077\071\071\ | |
663 | \071\071\113\107\107\107\107\149\143\143\143\143\185\185\179\179\ | |
664 | \179\179\221\215\041\041\041\041\078\078\077\077\077\077\077\113\ | |
665 | \113\113\113\107\149\149\149\149\185\185\185\185\185\179\179\221\ | |
666 | \221\215\041\041\041\041\078\078\077\077\077\077\077\077\113\113\ | |
667 | \113\113\149\149\149\149\149\149\185\185\185\185\185\221\221\221\ | |
668 | \041\041\041\041\084\078\077\077\077\077\077\077\113\113\113\113\ | |
669 | \113\149\149\149\149\149\185\185\185\185\185\221\221\221\041\041\ | |
670 | \041\041\084\084\077\077\077\077\077\077\113\113\113\113\113\149\ | |
671 | \149\149\149\149\149\185\185\185\185\227\221\221\041\041\041\041\ | |
672 | \084\084\077\077\077\077\077\077\113\113\113\113\113\149\149\149\ | |
673 | \149\149\149\185\185\185\185\227\227\221\047\047\047\047\084\084\ | |
674 | \083\083\083\083\077\119\119\119\113\113\113\155\155\149\149\149\ | |
675 | \191\191\191\227\227\227\227\221\047\047\047\047\084\084\083\083\ | |
676 | \083\083\083\083\119\119\119\119\155\155\155\155\155\191\191\191\ | |
677 | \191\191\227\227\227\227\047\047\047\047\084\084\083\083\083\083\ | |
678 | \083\083\119\119\119\119\119\155\155\155\155\155\155\191\191\191\ | |
679 | \191\191\227\227\017\017\017\017\054\054\054\054\053\053\053\053\ | |
680 | \089\089\089\089\089\125\125\125\125\125\125\161\161\161\161\161\ | |
681 | \197\197\017\017\017\017\017\054\054\054\053\053\053\053\089\089\ | |
682 | \089\089\089\125\125\125\125\125\161\161\161\161\161\161\197\197\ | |
683 | \017\017\017\017\017\054\054\054\053\053\053\053\089\089\089\089\ | |
684 | \089\125\125\125\125\125\161\161\161\161\161\197\197\197\017\017\ | |
685 | \017\017\017\097\054\054\053\053\053\053\089\089\089\089\125\125\ | |
686 | \125\125\125\125\161\161\161\161\161\197\197\197\024\017\017\017\ | |
687 | \060\060\097\097\096\096\096\133\132\132\132\132\132\125\125\125\ | |
688 | \125\161\161\161\161\161\161\197\197\197\024\024\024\067\060\060\ | |
689 | \060\096\096\096\096\096\132\132\132\132\132\132\132\168\168\168\ | |
690 | \168\168\168\204\204\204\204\204\024\024\024\024\067\060\060\060\ | |
691 | \096\096\096\096\096\132\132\132\132\132\132\168\168\168\168\168\ | |
692 | \168\204\204\204\204\204\024\024\024\024\067\060\060\060\240\096\ | |
693 | \096\096\096\095\132\132\132\131\131\131\131\168\168\167\167\167\ | |
694 | \167\204\203\203\023\023\023\023\066\066\066\240\240\240\059\241\ | |
695 | \095\095\095\095\095\131\131\131\131\131\167\167\167\167\167\203\ | |
696 | \203\203\023\023\023\023\066\066\066\066\240\240\059\241\095\095\ | |
697 | \095\095\095\131\131\131\131\131\131\167\167\167\167\167\203\203\ | |
698 | \023\023\023\023\066\066\066\066\059\059\059\241\095\095\095\095\ | |
699 | \095\095\131\131\131\131\131\167\167\167\167\167\203\203\023\023\ | |
700 | \023\023\073\066\066\066\241\241\241\241\242\095\095\095\095\095\ | |
701 | \131\131\131\131\131\167\167\167\167\167\203\203\029\029\029\029\ | |
702 | \072\072\066\066\065\065\065\242\101\101\095\095\095\137\137\137\ | |
703 | \131\131\173\173\173\167\167\167\209\203\029\029\029\029\072\072\ | |
704 | \072\065\065\065\065\065\101\101\101\101\101\137\137\137\137\137\ | |
705 | \173\173\173\173\173\173\209\209\029\029\029\029\072\072\072\072\ | |
706 | \065\065\065\065\065\101\101\101\101\137\137\137\137\137\137\173\ | |
707 | \173\173\173\173\209\209\029\029\029\029\072\072\072\072\065\065\ | |
708 | \065\065\065\101\101\101\101\101\137\137\137\137\137\173\173\173\ | |
709 | \173\173\209\209\029\029\029\035\072\072\072\072\065\065\065\065\ | |
710 | \065\101\101\101\101\101\137\137\137\137\137\173\173\173\173\173\ | |
711 | \209\209\035\035\035\035\035\072\072\072\071\071\065\065\107\107\ | |
712 | \107\101\101\143\143\143\137\137\137\179\173\173\173\173\215\209\ | |
713 | \035\035\035\035\035\072\072\071\071\071\071\071\107\107\107\107\ | |
714 | \107\143\143\143\143\143\179\179\179\179\179\215\215\215\035\035\ | |
715 | \035\035\035\078\078\071\071\071\071\071\071\107\107\107\107\107\ | |
716 | \143\143\143\143\179\179\179\179\179\179\215\215\035\035\035\035\ | |
717 | \035\078\078\071\071\071\071\071\071\107\107\107\107\107\143\143\ | |
718 | \143\143\143\179\179\179\179\179\215\215\035\035\035\035\041\078\ | |
719 | \078\078\071\071\071\071\071\107\107\107\107\107\143\143\143\143\ | |
720 | \143\179\179\179\179\179\215\215\035\041\041\041\041\078\078\078\ | |
721 | \077\071\071\071\113\113\107\107\107\107\149\149\143\143\143\185\ | |
722 | \185\179\179\179\221\215\041\041\041\041\041\078\078\077\077\077\ | |
723 | \077\077\113\113\113\113\113\149\149\149\149\149\185\185\185\185\ | |
724 | \185\179\221\221\041\041\041\041\041\078\078\077\077\077\077\077\ | |
725 | \077\113\113\113\113\149\149\149\149\149\185\185\185\185\185\185\ | |
726 | \221\221\041\041\041\041\041\084\084\077\077\077\077\077\077\113\ | |
727 | \113\113\113\113\149\149\149\149\149\185\185\185\185\185\221\221\ | |
728 | \041\041\041\041\041\084\084\077\077\077\077\077\077\113\113\113\ | |
729 | \113\113\149\149\149\149\149\185\185\185\185\185\221\221\041\041\ | |
730 | \047\047\047\084\084\084\083\077\077\077\077\113\113\113\113\113\ | |
731 | \155\149\149\149\149\149\185\185\185\185\227\221\047\047\047\047\ | |
732 | \047\084\084\083\083\083\083\083\119\119\119\119\119\155\155\155\ | |
733 | \155\155\191\191\191\191\191\227\227\227\047\047\047\047\047\084\ | |
734 | \084\083\083\083\083\083\083\119\119\119\119\119\155\155\155\155\ | |
735 | \155\191\191\191\191\191\227\227\017\017\017\017\055\054\054\054\ | |
736 | \053\053\053\053\053\089\089\089\089\089\125\125\125\125\125\161\ | |
737 | \161\161\161\161\197\197\017\017\017\017\017\054\054\054\054\053\ | |
738 | \053\053\053\089\089\089\089\089\125\125\125\125\125\161\161\161\ | |
739 | \161\161\197\197\017\017\017\017\017\054\054\054\054\053\053\053\ | |
740 | \053\089\089\089\089\125\125\125\125\125\125\161\161\161\161\161\ | |
741 | \197\197\017\017\017\017\017\017\097\054\054\053\053\053\053\089\ | |
742 | \089\089\089\125\125\125\125\125\161\161\161\161\161\197\197\197\ | |
743 | \025\017\017\017\060\060\097\097\097\096\096\133\133\089\089\089\ | |
744 | \089\125\125\125\125\125\161\161\161\161\161\197\197\197\024\024\ | |
745 | \024\017\060\060\060\060\096\096\096\096\096\132\132\132\132\132\ | |
746 | \132\168\168\168\168\168\168\204\204\204\204\204\024\024\024\067\ | |
747 | \067\060\060\060\096\096\096\096\096\132\132\132\132\132\132\168\ | |
748 | \168\168\168\168\168\168\204\204\204\204\024\024\024\024\067\060\ | |
749 | \060\060\060\096\096\096\096\096\132\132\132\132\132\132\168\168\ | |
750 | \168\168\168\168\168\204\204\204\023\024\024\024\067\066\066\060\ | |
751 | \059\059\059\096\096\095\095\095\095\131\131\131\131\131\167\167\ | |
752 | \167\167\167\167\203\203\023\023\023\023\066\066\066\066\059\059\ | |
753 | \059\241\095\095\095\095\095\095\131\131\131\131\131\167\167\167\ | |
754 | \167\167\203\203\023\023\023\023\066\066\066\066\059\059\059\241\ | |
755 | \242\095\095\095\095\095\131\131\131\131\131\167\167\167\167\167\ | |
756 | \203\203\023\023\023\023\073\066\066\066\066\241\241\241\242\095\ | |
757 | \095\095\095\095\131\131\131\131\131\167\167\167\167\167\203\203\ | |
758 | \023\023\023\023\073\066\066\066\066\065\242\242\242\101\095\095\ | |
759 | \095\095\131\131\131\131\131\167\167\167\167\167\203\203\029\029\ | |
760 | \029\029\029\072\072\066\065\065\065\065\101\101\101\101\101\137\ | |
761 | \137\137\137\137\173\173\173\173\173\173\209\209\029\029\029\029\ | |
762 | \029\072\072\072\065\065\065\065\065\101\101\101\101\101\137\137\ | |
763 | \137\137\137\173\173\173\173\173\209\209\029\029\029\029\029\072\ | |
764 | \072\072\065\065\065\065\065\101\101\101\101\101\137\137\137\137\ | |
765 | \137\173\173\173\173\173\209\209\029\029\029\029\029\072\072\072\ | |
766 | \065\065\065\065\065\101\101\101\101\101\137\137\137\137\137\173\ | |
767 | \173\173\173\173\209\209\029\029\035\035\035\072\072\072\071\065\ | |
768 | \065\065\065\107\101\101\101\101\143\137\137\137\137\137\173\173\ | |
769 | \173\173\173\209\035\035\035\035\035\072\072\072\071\071\071\071\ | |
770 | \071\107\107\107\107\143\143\143\143\143\137\179\179\179\179\173\ | |
771 | \215\215\035\035\035\035\035\078\078\072\071\071\071\071\071\107\ | |
772 | \107\107\107\107\143\143\143\143\143\179\179\179\179\179\215\215\ | |
773 | \035\035\035\035\035\078\078\078\071\071\071\071\071\107\107\107\ | |
774 | \107\107\143\143\143\143\143\179\179\179\179\179\215\215\035\035\ | |
775 | \035\035\035\078\078\078\071\071\071\071\071\107\107\107\107\107\ | |
776 | \143\143\143\143\143\179\179\179\179\179\215\215\035\035\035\041\ | |
777 | \041\078\078\078\077\071\071\071\071\113\107\107\107\107\107\143\ | |
778 | \143\143\143\185\179\179\179\179\221\215\041\041\041\041\041\078\ | |
779 | \078\078\077\077\077\077\077\113\113\113\113\107\149\149\149\149\ | |
780 | \185\185\185\185\185\179\221\221\041\041\041\041\041\078\078\078\ | |
781 | \077\077\077\077\077\113\113\113\113\113\149\149\149\149\149\185\ | |
782 | \185\185\185\185\221\221\041\041\041\041\041\084\078\078\077\077\ | |
783 | \077\077\077\113\113\113\113\113\149\149\149\149\149\185\185\185\ | |
784 | \185\185\221\221\041\041\041\041\041\084\084\078\077\077\077\077\ | |
785 | \077\113\113\113\113\113\149\149\149\149\149\185\185\185\185\185\ | |
786 | \221\221\041\041\041\047\047\084\084\084\077\077\077\077\077\113\ | |
787 | \113\113\113\113\113\149\149\149\149\149\185\185\185\185\227\221\ | |
788 | \047\047\047\047\047\084\084\084\083\083\083\083\083\119\119\119\ | |
789 | \119\113\155\155\155\155\191\191\191\191\191\227\227\227\047\047\ | |
790 | \047\047\047\084\084\084\083\083\083\083\083\119\119\119\119\119\ | |
791 | \155\155\155\155\155\191\191\191\191\191\227\227\017\017\017\017\ | |
792 | \055\054\054\054\054\053\053\053\053\089\089\089\089\089\125\125\ | |
793 | \125\125\125\161\161\161\161\161\197\197\017\017\017\017\017\054\ | |
794 | \054\054\054\053\053\053\053\089\089\089\089\089\125\125\125\125\ | |
795 | \125\161\161\161\161\161\197\197\017\017\017\017\017\055\054\054\ | |
796 | \054\053\053\053\053\089\089\089\089\089\125\125\125\125\125\161\ | |
797 | \161\161\161\161\197\197\017\017\017\017\017\017\097\054\054\053\ | |
798 | \053\053\053\089\089\089\089\125\125\125\125\125\161\161\161\161\ | |
799 | \161\161\197\197\025\017\017\017\061\061\097\097\097\133\133\133\ | |
800 | \133\089\089\089\089\125\125\125\125\125\161\161\161\161\161\197\ | |
801 | \197\197\024\024\025\017\061\060\060\060\096\096\096\096\096\132\ | |
802 | \132\132\132\132\132\168\168\168\168\168\168\204\204\204\204\204\ | |
803 | \024\024\024\067\067\060\060\060\096\096\096\096\096\132\132\132\ | |
804 | \132\132\132\168\168\168\168\168\168\168\204\204\204\204\024\024\ | |
805 | \024\024\067\060\060\060\060\096\096\096\096\096\132\132\132\132\ | |
806 | \132\132\168\168\168\168\168\168\168\204\204\204\024\024\024\024\ | |
807 | \067\066\060\060\060\241\096\096\096\096\095\132\132\132\131\131\ | |
808 | \131\131\168\168\167\167\167\204\204\203\023\023\023\023\073\066\ | |
809 | \066\066\241\241\241\241\242\095\095\095\095\095\131\131\131\131\ | |
810 | \131\167\167\167\167\167\203\203\023\023\023\023\073\066\066\066\ | |
811 | \066\241\241\241\242\095\095\095\095\095\131\131\131\131\131\167\ | |
812 | \167\167\167\167\203\203\023\023\023\023\073\066\066\066\066\241\ | |
813 | \241\241\242\095\095\095\095\095\131\131\131\131\131\167\167\167\ | |
814 | \167\167\203\203\023\023\023\023\073\066\066\066\066\242\242\242\ | |
815 | \242\243\095\095\095\095\131\131\131\131\131\167\167\167\167\167\ | |
816 | \203\203\029\029\029\029\029\072\072\066\066\065\065\065\243\101\ | |
817 | \101\101\095\095\137\137\137\137\131\173\173\173\173\167\209\209\ | |
818 | \029\029\029\029\029\072\072\072\065\065\065\065\065\101\101\101\ | |
819 | \101\101\137\137\137\137\137\173\173\173\173\173\209\209\029\029\ | |
820 | \029\029\029\072\072\072\072\065\065\065\065\101\101\101\101\101\ | |
821 | \137\137\137\137\137\173\173\173\173\173\209\209\029\029\029\029\ | |
822 | \029\072\072\072\072\065\065\065\065\101\101\101\101\101\137\137\ | |
823 | \137\137\137\173\173\173\173\173\209\209\029\029\029\035\035\072\ | |
824 | \072\072\072\065\065\065\065\065\101\101\101\101\143\137\137\137\ | |
825 | \137\137\173\173\173\173\173\209\035\035\035\035\035\072\072\072\ | |
826 | \072\071\071\071\071\107\107\107\107\143\143\143\143\143\137\179\ | |
827 | \179\179\173\173\215\215\035\035\035\035\035\078\078\072\071\071\ | |
828 | \071\071\071\107\107\107\107\107\143\143\143\143\143\179\179\179\ | |
829 | \179\179\215\215\035\035\035\035\035\078\078\078\071\071\071\071\ | |
830 | \071\107\107\107\107\107\143\143\143\143\143\179\179\179\179\179\ | |
831 | \215\215\035\035\035\035\035\078\078\078\071\071\071\071\071\071\ | |
832 | \107\107\107\107\107\143\143\143\143\179\179\179\179\179\215\215\ | |
833 | \035\035\035\041\041\078\078\078\078\071\071\071\071\071\107\107\ | |
834 | \107\107\107\143\143\143\143\185\179\179\179\179\179\215\041\041\ | |
835 | \041\041\041\078\078\078\078\077\077\077\077\113\113\113\113\107\ | |
836 | \149\149\149\149\185\185\185\185\185\179\221\221\041\041\041\041\ | |
837 | \041\078\078\078\077\077\077\077\077\113\113\113\113\113\149\149\ | |
838 | \149\149\149\185\185\185\185\185\221\221\041\041\041\041\041\084\ | |
839 | \078\078\077\077\077\077\077\113\113\113\113\113\149\149\149\149\ | |
840 | \149\185\185\185\185\185\221\221\041\041\041\041\041\084\084\078\ | |
841 | \077\077\077\077\077\077\113\113\113\113\113\149\149\149\149\185\ | |
842 | \185\185\185\185\221\221\041\041\041\041\047\084\084\084\084\077\ | |
843 | \077\077\077\077\113\113\113\113\113\149\149\149\149\149\185\185\ | |
844 | \185\185\227\221\047\047\047\047\047\084\084\084\084\083\083\083\ | |
845 | \083\119\119\119\119\113\155\155\155\155\149\191\191\191\191\227\ | |
846 | \227\227\047\047\047\047\047\084\084\084\083\083\083\083\083\119\ | |
847 | \119\119\119\119\155\155\155\155\155\191\191\191\191\191\227\227\ | |
848 | \017\017\017\017\055\055\054\054\054\054\053\053\053\090\089\089\ | |
849 | \089\089\089\125\125\125\125\125\161\161\161\161\161\197\017\017\ | |
850 | \017\017\017\055\054\054\054\054\053\053\053\090\089\089\089\089\ | |
851 | \089\125\125\125\125\125\161\161\161\161\161\197\017\017\017\017\ | |
852 | \017\017\054\054\054\054\053\053\053\090\089\089\089\089\089\125\ | |
853 | \125\125\125\161\161\161\161\161\197\197\017\017\017\017\017\017\ | |
854 | \097\054\054\054\053\053\053\090\089\089\089\089\125\125\125\125\ | |
855 | \125\161\161\161\161\161\197\197\025\017\017\017\061\061\097\097\ | |
856 | \097\097\133\133\133\133\089\089\089\089\125\125\125\125\125\161\ | |
857 | \161\161\161\161\197\197\025\025\017\017\061\060\060\097\097\097\ | |
858 | \096\096\096\133\133\132\132\132\132\132\168\168\168\168\168\168\ | |
859 | \168\204\204\204\024\024\024\067\067\060\060\060\060\096\096\096\ | |
860 | \096\096\132\132\132\132\132\132\168\168\168\168\168\168\168\204\ | |
861 | \204\204\024\024\024\024\067\067\060\060\060\096\096\096\096\096\ | |
862 | \132\132\132\132\132\132\168\168\168\168\168\168\168\204\204\204\ | |
863 | \024\024\024\024\067\067\060\060\060\060\096\096\096\096\096\132\ | |
864 | \132\132\132\132\132\168\168\168\168\168\168\204\204\204\024\024\ | |
865 | \024\024\067\067\066\060\060\060\060\242\096\096\096\095\095\132\ | |
866 | \132\131\131\131\168\168\168\167\167\167\204\203\023\023\023\023\ | |
867 | \073\066\066\066\066\060\242\242\242\096\095\095\095\095\131\131\ | |
868 | \131\131\131\167\167\167\167\167\203\203\023\023\023\023\073\066\ | |
869 | \066\066\066\242\242\242\242\243\095\095\095\095\131\131\131\131\ | |
870 | \131\167\167\167\167\167\203\203\023\023\023\023\073\066\066\066\ | |
871 | \066\066\242\242\242\243\095\095\095\095\095\131\131\131\131\131\ | |
872 | \167\167\167\167\167\203\030\030\030\030\073\073\066\066\066\066\ | |
873 | \066\243\243\243\244\095\095\095\095\131\131\131\131\131\167\167\ | |
874 | \167\167\167\203\029\029\029\029\029\072\072\072\066\066\065\065\ | |
875 | \065\244\101\101\101\095\138\137\137\137\137\173\173\173\173\173\ | |
876 | \209\209\029\029\029\029\029\072\072\072\072\065\065\065\065\065\ | |
877 | \101\101\101\101\137\137\137\137\137\173\173\173\173\173\209\209\ | |
878 | \029\029\029\029\029\072\072\072\072\065\065\065\065\065\101\101\ | |
879 | \101\101\144\137\137\137\137\137\173\173\173\173\209\209\029\029\ | |
880 | \029\029\029\072\072\072\072\072\065\065\065\065\065\101\101\101\ | |
881 | \101\137\137\137\137\137\173\173\173\173\173\209\029\029\029\035\ | |
882 | \035\072\072\072\072\072\071\071\065\065\108\107\144\101\101\143\ | |
883 | \137\137\137\137\180\173\173\173\173\209\035\035\035\035\035\072\ | |
884 | \072\072\072\072\071\071\071\071\107\107\107\107\143\143\143\143\ | |
885 | \143\137\179\179\179\179\215\215\035\035\035\035\035\078\078\078\ | |
886 | \072\071\071\071\071\071\107\107\107\107\107\143\143\143\143\179\ | |
887 | \179\179\179\179\215\215\035\035\035\035\035\078\078\078\078\071\ | |
888 | \071\071\071\071\107\107\107\107\107\143\143\143\143\179\179\179\ | |
889 | \179\179\215\215\035\035\035\035\035\078\078\078\078\078\071\071\ | |
890 | \071\071\071\107\107\107\107\107\143\143\143\143\179\179\179\179\ | |
891 | \179\215\035\035\041\041\041\078\078\078\078\078\077\077\071\071\ | |
892 | \113\113\107\107\107\107\149\149\143\143\185\185\179\179\179\215\ | |
893 | \041\041\041\041\041\078\078\078\078\078\077\077\077\077\113\113\ | |
894 | \113\113\150\149\149\149\149\185\185\185\185\185\221\221\041\041\ | |
895 | \041\041\041\078\078\078\078\077\077\077\077\077\113\113\113\113\ | |
896 | \113\149\149\149\149\185\185\185\185\185\221\221\041\041\041\041\ | |
897 | \041\078\078\078\078\077\077\077\077\077\113\113\113\113\113\149\ | |
898 | \149\149\149\149\185\185\185\185\221\221\041\041\041\041\041\084\ | |
899 | \084\084\084\077\077\077\077\077\077\113\113\113\113\113\149\149\ | |
900 | \149\149\185\185\185\185\185\221\041\041\047\047\047\084\084\084\ | |
901 | \084\084\083\083\077\077\119\119\119\113\113\155\155\155\149\149\ | |
902 | \191\191\191\185\185\227\047\047\047\047\047\084\084\084\084\083\ | |
903 | \083\083\083\083\119\119\119\119\119\155\155\155\155\155\191\191\ | |
904 | \191\191\227\227\018\018\018\018\055\055\055\054\054\054\054\054\ | |
905 | \090\090\090\090\090\126\126\126\126\126\125\162\162\162\162\161\ | |
906 | \198\198\018\018\018\018\018\055\055\054\054\054\054\054\090\090\ | |
907 | \090\090\089\089\126\126\126\125\125\162\162\161\161\161\198\197\ | |
908 | \018\018\018\018\018\018\055\054\054\054\054\054\090\090\090\090\ | |
909 | \089\089\126\126\125\125\125\125\161\161\161\161\161\197\018\018\ | |
910 | \018\018\018\018\055\055\054\054\054\054\090\090\090\089\089\089\ | |
911 | \089\125\125\125\125\125\161\161\161\161\197\197\025\018\018\018\ | |
912 | \061\061\097\097\097\097\054\054\133\133\090\089\089\089\089\125\ | |
913 | \125\125\125\161\161\161\161\161\197\197\025\025\018\018\061\061\ | |
914 | \061\097\097\097\097\097\133\133\133\133\133\132\132\169\169\169\ | |
915 | \169\168\168\161\205\205\204\197\025\025\025\025\067\061\060\060\ | |
916 | \097\097\097\097\096\096\133\133\133\132\132\132\132\169\168\168\ | |
917 | \168\168\168\204\204\204\024\024\024\025\067\067\060\060\060\060\ | |
918 | \096\096\096\096\096\132\132\132\132\132\132\132\168\168\168\168\ | |
919 | \168\204\204\204\024\024\024\024\067\067\067\060\060\060\060\096\ | |
920 | \096\096\096\096\132\132\132\132\132\132\168\168\168\168\168\204\ | |
921 | \204\204\024\024\024\024\067\067\067\060\060\060\060\060\096\096\ | |
922 | \096\096\096\132\132\132\132\132\168\168\168\168\168\168\204\204\ | |
923 | \024\024\024\024\024\067\067\066\060\060\060\060\096\096\096\096\ | |
924 | \096\132\132\132\132\132\168\168\168\168\168\168\204\204\024\024\ | |
925 | \024\024\024\067\067\066\060\060\060\060\243\096\096\096\096\095\ | |
926 | \132\132\132\131\131\168\168\168\168\167\204\204\030\030\030\030\ | |
927 | \073\073\066\066\066\066\066\243\243\243\244\095\095\095\095\131\ | |
928 | \131\131\131\131\167\167\167\167\167\203\030\030\030\030\073\073\ | |
929 | \066\066\066\066\066\066\243\243\244\102\245\095\138\138\138\138\ | |
930 | \131\174\174\174\174\167\210\210\030\030\030\030\030\073\073\066\ | |
931 | \066\066\066\066\244\244\244\102\245\138\138\138\138\138\131\174\ | |
932 | \174\174\174\167\210\210\030\030\030\029\029\073\073\072\066\066\ | |
933 | \066\066\065\102\102\102\245\144\138\138\138\138\174\174\174\174\ | |
934 | \174\167\210\210\030\029\029\029\029\073\072\072\072\066\066\066\ | |
935 | \065\245\245\245\245\144\138\138\138\137\180\174\174\174\173\173\ | |
936 | \216\210\036\029\029\029\029\072\072\072\072\072\072\065\065\065\ | |
937 | \108\144\144\101\144\144\137\137\137\180\180\173\173\173\216\216\ | |
938 | \036\036\036\029\029\072\072\072\072\072\072\072\065\108\108\108\ | |
939 | \108\144\144\144\144\137\137\180\180\180\180\173\216\216\036\036\ | |
940 | \036\035\035\079\072\072\072\072\072\072\071\108\108\108\108\144\ | |
941 | \144\144\144\144\180\180\180\180\180\173\216\216\036\036\035\035\ | |
942 | \035\079\072\072\072\072\072\072\071\108\108\108\108\107\144\144\ | |
943 | \144\144\143\180\180\180\180\179\216\216\036\035\035\035\035\079\ | |
944 | \079\072\072\072\072\071\071\108\108\108\107\107\107\144\144\144\ | |
945 | \143\180\180\180\180\179\216\216\035\035\035\035\035\079\078\078\ | |
946 | \078\078\078\071\071\071\071\114\150\107\107\150\143\143\143\186\ | |
947 | \186\179\179\179\222\215\042\042\035\035\041\078\078\078\078\078\ | |
948 | \078\078\071\114\114\114\114\150\150\150\150\150\186\186\186\186\ | |
949 | \179\179\222\222\042\042\041\041\041\078\078\078\078\078\078\078\ | |
950 | \077\114\114\114\114\150\150\150\150\150\186\186\186\186\186\179\ | |
951 | \222\222\042\041\041\041\041\041\078\078\078\078\078\078\077\114\ | |
952 | \114\114\114\113\150\150\150\150\149\186\186\186\186\185\222\222\ | |
953 | \042\041\041\041\041\085\078\078\078\078\078\078\077\114\114\114\ | |
954 | \113\113\150\150\150\150\149\149\186\186\186\185\228\222\041\041\ | |
955 | \041\041\041\085\084\084\084\078\078\077\077\077\077\077\113\113\ | |
956 | \113\113\149\149\149\149\149\185\185\185\228\221\048\048\041\047\ | |
957 | \047\084\084\084\084\084\084\084\077\120\120\120\120\156\156\156\ | |
958 | \156\192\192\192\192\192\192\228\228\228\048\047\047\047\047\047\ | |
959 | \084\084\084\084\084\084\083\120\120\120\120\156\156\156\156\156\ | |
960 | \155\192\192\192\192\191\228\228\018\018\018\018\018\055\055\054\ | |
961 | \054\054\054\054\054\090\090\090\090\126\126\126\126\126\126\162\ | |
962 | \162\162\162\162\198\198\018\018\018\018\018\055\055\055\054\054\ | |
963 | \054\054\054\090\090\090\090\126\126\126\126\126\162\162\162\162\ | |
964 | \162\162\198\198\018\018\018\018\018\018\055\055\054\054\054\054\ | |
965 | \054\090\090\090\090\126\126\126\126\126\162\162\162\162\162\161\ | |
966 | \198\198\018\018\018\018\018\018\018\055\055\054\054\054\054\090\ | |
967 | \090\090\090\126\126\126\126\126\125\162\162\161\161\161\198\197\ | |
968 | \018\018\018\018\018\018\061\097\097\097\054\054\054\090\090\090\ | |
969 | \090\126\126\126\125\125\125\162\161\161\161\161\161\197\025\025\ | |
970 | \018\018\018\061\061\097\097\097\097\097\133\133\133\133\133\133\ | |
971 | \169\169\169\169\169\169\205\205\205\205\205\197\025\025\025\018\ | |
972 | \061\061\061\061\097\097\097\097\097\133\133\133\133\133\132\169\ | |
973 | \169\169\169\169\168\168\205\205\205\204\024\025\025\025\067\067\ | |
974 | \061\060\060\097\097\097\097\096\096\133\133\133\132\132\132\132\ | |
975 | \169\168\168\168\168\168\204\204\024\024\024\025\067\067\067\060\ | |
976 | \060\060\060\060\096\096\096\096\096\132\132\132\132\132\168\168\ | |
977 | \168\168\168\168\204\204\024\024\024\024\067\067\067\067\060\060\ | |
978 | \060\060\096\096\096\096\096\132\132\132\132\132\132\168\168\168\ | |
979 | \168\168\204\204\024\024\024\024\024\067\067\067\060\060\060\060\ | |
980 | \060\096\096\096\096\096\132\132\132\132\132\168\168\168\168\168\ | |
981 | \204\204\024\024\024\024\024\067\067\067\060\060\060\060\060\096\ | |
982 | \096\096\096\096\132\132\132\132\132\168\168\168\168\168\204\204\ | |
983 | \024\024\024\024\024\073\067\067\066\060\060\060\060\244\096\096\ | |
984 | \096\096\138\132\132\132\131\168\168\168\168\168\204\204\030\030\ | |
985 | \030\030\030\073\073\066\066\066\066\066\244\244\244\102\245\138\ | |
986 | \138\138\138\138\131\174\174\174\174\167\210\210\030\030\030\030\ | |
987 | \030\073\073\066\066\066\066\066\066\244\244\102\245\246\138\138\ | |
988 | \138\138\138\174\174\174\174\174\210\210\030\030\030\030\030\073\ | |
989 | \073\073\066\066\066\066\066\102\102\102\245\246\138\138\138\138\ | |
990 | \138\174\174\174\174\174\210\210\030\030\030\030\030\073\073\073\ | |
991 | \066\066\066\066\066\245\245\245\245\246\138\138\138\138\138\174\ | |
992 | \174\174\174\174\210\210\036\036\036\036\036\073\073\072\072\072\ | |
993 | \066\066\066\108\246\246\246\246\144\144\138\138\180\180\174\174\ | |
994 | \174\174\216\210\036\036\036\036\036\079\072\072\072\072\072\072\ | |
995 | \108\108\108\108\108\144\144\144\144\144\180\180\180\180\180\216\ | |
996 | \216\216\036\036\036\036\036\079\079\072\072\072\072\072\072\108\ | |
997 | \108\108\108\144\144\144\144\144\180\180\180\180\180\180\216\216\ | |
998 | \036\036\036\036\035\079\079\072\072\072\072\072\072\108\108\108\ | |
999 | \108\108\144\144\144\144\144\180\180\180\180\180\216\216\036\036\ | |
1000 | \036\036\035\079\079\072\072\072\072\072\072\108\108\108\108\108\ | |
1001 | \144\144\144\144\144\180\180\180\180\180\216\216\036\042\042\035\ | |
1002 | \035\079\079\079\078\072\072\072\071\071\108\108\108\150\150\150\ | |
1003 | \144\144\144\186\180\180\180\180\222\216\042\042\042\042\042\079\ | |
1004 | \079\078\078\078\078\078\078\114\114\114\114\150\150\150\150\150\ | |
1005 | \186\186\186\186\186\222\222\222\042\042\042\042\041\085\078\078\ | |
1006 | \078\078\078\078\078\114\114\114\114\150\150\150\150\150\150\186\ | |
1007 | \186\186\186\186\222\222\042\042\042\041\041\085\078\078\078\078\ | |
1008 | \078\078\078\114\114\114\114\114\150\150\150\150\150\186\186\186\ | |
1009 | \186\186\222\222\042\042\042\041\041\085\085\078\078\078\078\078\ | |
1010 | \078\114\114\114\114\114\150\150\150\150\150\186\186\186\186\186\ | |
1011 | \222\222\042\042\041\041\041\085\085\078\078\078\078\078\078\077\ | |
1012 | \114\114\114\114\156\150\150\150\150\192\186\186\186\186\228\222\ | |
1013 | \048\048\048\048\041\085\085\084\084\084\084\084\084\120\120\120\ | |
1014 | \120\156\156\156\156\156\192\192\192\192\192\228\228\228\048\048\ | |
1015 | \048\047\047\047\084\084\084\084\084\084\084\120\120\120\120\120\ | |
1016 | \156\156\156\156\156\192\192\192\192\192\228\228\018\018\018\018\ | |
1017 | \018\055\055\055\054\054\054\054\054\090\090\090\090\090\126\126\ | |
1018 | \126\126\126\162\162\162\162\162\198\198\018\018\018\018\018\055\ | |
1019 | \055\055\054\054\054\054\054\090\090\090\090\090\126\126\126\126\ | |
1020 | \126\162\162\162\162\162\198\198\018\018\018\018\018\018\055\055\ | |
1021 | \055\054\054\054\054\090\090\090\090\090\126\126\126\126\126\162\ | |
1022 | \162\162\162\162\198\198\018\018\018\018\018\018\018\055\055\054\ | |
1023 | \054\054\054\054\090\090\090\090\126\126\126\126\126\162\162\162\ | |
1024 | \162\162\198\198\018\018\018\018\018\018\061\097\097\097\054\054\ | |
1025 | \054\054\090\090\090\090\126\126\126\126\162\162\162\162\162\161\ | |
1026 | \198\197\025\025\018\018\018\061\061\061\097\097\097\097\097\133\ | |
1027 | \133\133\133\133\169\169\169\169\169\169\169\205\205\205\205\197\ | |
1028 | \025\025\025\018\061\061\061\061\097\097\097\097\097\133\133\133\ | |
1029 | \133\133\133\169\169\169\169\169\169\205\205\205\205\205\025\025\ | |
1030 | \025\025\067\061\061\061\061\097\097\097\097\097\133\133\133\133\ | |
1031 | \132\132\169\169\169\169\168\168\168\205\205\204\024\024\025\025\ | |
1032 | \067\067\067\061\060\060\060\097\097\096\096\096\096\133\132\132\ | |
1033 | \132\132\132\168\168\168\168\168\204\204\024\024\024\024\067\067\ | |
1034 | \067\067\060\060\060\060\060\096\096\096\096\096\132\132\132\132\ | |
1035 | \132\168\168\168\168\168\204\204\024\024\024\024\024\067\067\067\ | |
1036 | \060\060\060\060\060\096\096\096\096\096\132\132\132\132\132\168\ | |
1037 | \168\168\168\168\204\204\024\024\024\024\024\067\067\067\067\060\ | |
1038 | \060\060\060\096\096\096\096\096\132\132\132\132\132\168\168\168\ | |
1039 | \168\168\204\204\024\024\024\024\024\067\067\067\067\060\060\060\ | |
1040 | \060\060\096\096\096\096\132\132\132\132\132\168\168\168\168\168\ | |
1041 | \204\204\030\030\030\024\024\073\073\067\066\066\066\066\060\102\ | |
1042 | \102\102\245\139\138\138\138\138\174\174\174\174\174\167\210\210\ | |
1043 | \030\030\030\030\030\073\073\073\066\066\066\066\066\102\102\102\ | |
1044 | \245\246\138\138\138\138\138\174\174\174\174\174\210\210\030\030\ | |
1045 | \030\030\030\073\073\073\066\066\066\066\066\102\102\102\245\246\ | |
1046 | \138\138\138\138\138\174\174\174\174\174\210\210\030\030\030\030\ | |
1047 | \030\073\073\073\066\066\066\066\066\245\245\245\245\246\138\138\ | |
1048 | \138\138\138\174\174\174\174\174\210\210\030\030\030\030\030\073\ | |
1049 | \073\073\073\066\066\066\066\109\246\246\246\246\144\138\138\138\ | |
1050 | \138\174\174\174\174\174\210\210\036\036\036\036\036\079\073\072\ | |
1051 | \072\072\072\072\072\108\108\108\108\144\144\144\144\144\138\180\ | |
1052 | \180\180\180\174\216\216\036\036\036\036\036\079\079\072\072\072\ | |
1053 | \072\072\072\108\108\108\108\108\144\144\144\144\144\180\180\180\ | |
1054 | \180\180\216\216\036\036\036\036\036\079\079\079\072\072\072\072\ | |
1055 | \072\108\108\108\108\108\144\144\144\144\144\180\180\180\180\180\ | |
1056 | \216\216\036\036\036\036\036\079\079\079\072\072\072\072\072\108\ | |
1057 | \108\108\108\108\144\144\144\144\144\180\180\180\180\180\216\216\ | |
1058 | \036\036\036\036\042\079\079\079\072\072\072\072\072\114\108\108\ | |
1059 | \108\108\108\144\144\144\144\186\180\180\180\180\222\216\042\042\ | |
1060 | \042\042\042\079\079\079\078\078\078\078\078\114\114\114\114\114\ | |
1061 | \150\150\150\150\186\186\186\186\186\180\222\222\042\042\042\042\ | |
1062 | \042\079\079\078\078\078\078\078\078\114\114\114\114\114\150\150\ | |
1063 | \150\150\150\186\186\186\186\186\222\222\042\042\042\042\042\085\ | |
1064 | \085\078\078\078\078\078\078\114\114\114\114\114\150\150\150\150\ | |
1065 | \150\186\186\186\186\186\222\222\042\042\042\042\042\085\085\078\ | |
1066 | \078\078\078\078\078\114\114\114\114\114\150\150\150\150\150\186\ | |
1067 | \186\186\186\186\222\222\042\042\042\042\041\085\085\085\078\078\ | |
1068 | \078\078\078\077\114\114\114\114\114\150\150\150\150\150\186\186\ | |
1069 | \186\186\228\222\048\048\048\048\048\085\085\085\084\084\084\084\ | |
1070 | \084\120\120\120\120\120\156\156\156\156\192\192\192\192\192\228\ | |
1071 | \228\228\048\048\048\048\047\047\085\084\084\084\084\084\084\120\ | |
1072 | \120\120\120\120\156\156\156\156\156\192\192\192\192\192\228\228\ | |
1073 | \018\018\018\018\018\055\055\055\054\054\054\054\054\090\090\090\ | |
1074 | \090\090\126\126\126\126\126\162\162\162\162\162\198\198\018\018\ | |
1075 | \018\018\018\055\055\055\055\054\054\054\054\054\090\090\090\090\ | |
1076 | \126\126\126\126\126\162\162\162\162\162\198\198\018\018\018\018\ | |
1077 | \018\018\055\055\055\054\054\054\054\054\090\090\090\090\126\126\ | |
1078 | \126\126\126\162\162\162\162\162\198\198\018\018\018\018\018\018\ | |
1079 | \018\055\055\055\054\054\054\054\090\090\090\090\126\126\126\126\ | |
1080 | \126\162\162\162\162\162\198\198\018\018\018\018\018\018\061\097\ | |
1081 | \097\097\054\054\054\054\090\090\090\090\126\126\126\126\126\162\ | |
1082 | \162\162\162\161\198\198\025\025\018\018\018\061\061\061\097\097\ | |
1083 | \097\097\097\133\133\133\133\133\133\169\169\169\169\169\169\205\ | |
1084 | \205\205\205\205\025\025\025\018\061\061\061\061\097\097\097\097\ | |
1085 | \097\133\133\133\133\133\133\169\169\169\169\169\169\205\205\205\ | |
1086 | \205\205\025\025\025\025\067\061\061\061\061\097\097\097\097\097\ | |
1087 | \133\133\133\133\133\132\169\169\169\169\169\168\168\205\205\204\ | |
1088 | \024\025\025\025\067\067\067\061\060\060\060\097\097\097\096\096\ | |
1089 | \096\133\133\132\132\132\169\169\168\168\168\168\204\204\024\024\ | |
1090 | \024\025\067\067\067\067\060\060\060\060\060\096\096\096\096\096\ | |
1091 | \132\132\132\132\132\168\168\168\168\168\204\204\024\024\024\024\ | |
1092 | \024\067\067\067\060\060\060\060\060\096\096\096\096\096\132\132\ | |
1093 | \132\132\132\168\168\168\168\168\204\204\024\024\024\024\024\067\ | |
1094 | \067\067\067\060\060\060\060\096\096\096\096\096\132\132\132\132\ | |
1095 | \132\168\168\168\168\168\204\204\024\024\024\024\024\067\067\067\ | |
1096 | \067\060\060\060\060\060\096\096\096\096\139\132\132\132\132\132\ | |
1097 | \168\168\168\168\204\204\030\024\024\024\024\073\073\067\067\066\ | |
1098 | \066\060\060\245\245\245\245\139\139\138\138\132\175\174\174\174\ | |
1099 | \168\168\211\210\030\030\030\030\030\073\073\073\066\066\066\066\ | |
1100 | \066\245\245\245\245\246\138\138\138\138\138\174\174\174\174\174\ | |
1101 | \210\210\030\030\030\030\030\073\073\073\066\066\066\066\066\245\ | |
1102 | \245\245\245\246\138\138\138\138\138\174\174\174\174\174\210\210\ | |
1103 | \030\030\030\030\030\073\073\073\066\066\066\066\066\245\245\245\ | |
1104 | \245\246\138\138\138\138\138\174\174\174\174\174\210\210\030\030\ | |
1105 | \030\030\030\073\073\073\073\066\066\066\066\109\246\246\246\246\ | |
1106 | \247\138\138\138\138\174\174\174\174\174\210\210\036\036\036\036\ | |
1107 | \036\073\073\073\072\072\072\072\109\108\108\108\108\247\144\144\ | |
1108 | \144\138\138\180\180\180\180\174\216\216\036\036\036\036\036\079\ | |
1109 | \079\072\072\072\072\072\072\108\108\108\108\108\144\144\144\144\ | |
1110 | \144\180\180\180\180\180\216\216\036\036\036\036\036\079\079\079\ | |
1111 | \072\072\072\072\072\108\108\108\108\108\144\144\144\144\144\180\ | |
1112 | \180\180\180\180\216\216\036\036\036\036\036\079\079\079\072\072\ | |
1113 | \072\072\072\072\108\108\108\108\144\144\144\144\144\180\180\180\ | |
1114 | \180\180\216\216\036\036\036\036\036\079\079\079\079\072\072\072\ | |
1115 | \072\115\108\108\108\108\108\144\144\144\144\186\180\180\180\180\ | |
1116 | \180\216\042\042\042\042\042\079\079\079\079\078\078\078\072\114\ | |
1117 | \114\114\114\114\150\150\150\150\186\186\186\186\180\180\222\222\ | |
1118 | \042\042\042\042\042\079\079\079\078\078\078\078\078\114\114\114\ | |
1119 | \114\114\150\150\150\150\150\186\186\186\186\186\222\222\042\042\ | |
1120 | \042\042\042\085\085\078\078\078\078\078\078\114\114\114\114\114\ | |
1121 | \150\150\150\150\150\186\186\186\186\186\222\222\042\042\042\042\ | |
1122 | \042\085\085\078\078\078\078\078\078\078\114\114\114\114\150\150\ | |
1123 | \150\150\150\150\186\186\186\186\222\222\042\042\042\042\041\085\ | |
1124 | \085\085\078\078\078\078\078\078\114\114\114\114\114\150\150\150\ | |
1125 | \150\150\186\186\186\186\228\222\048\048\048\048\048\085\085\085\ | |
1126 | \085\084\084\084\084\121\120\120\120\120\156\156\156\156\150\192\ | |
1127 | \192\192\192\228\228\228\048\048\048\048\048\085\085\084\084\084\ | |
1128 | \084\084\084\120\120\120\120\120\156\156\156\156\156\192\192\192\ | |
1129 | \192\192\228\228\018\018\018\018\018\055\055\055\055\055\054\054\ | |
1130 | \054\091\091\090\090\090\127\126\126\126\126\126\162\162\162\162\ | |
1131 | \162\198\018\018\018\018\018\055\055\055\055\055\054\054\054\054\ | |
1132 | \091\090\090\090\127\126\126\126\126\126\162\162\162\162\162\198\ | |
1133 | \018\018\018\018\018\018\055\055\055\055\055\054\054\054\091\090\ | |
1134 | \090\090\127\126\126\126\126\126\162\162\162\162\198\198\018\018\ | |
1135 | \018\018\018\018\018\055\055\055\055\055\054\054\091\090\090\090\ | |
1136 | \127\126\126\126\126\162\162\162\162\162\198\198\018\018\018\018\ | |
1137 | \018\018\018\098\097\055\055\055\054\054\091\090\090\090\127\126\ | |
1138 | \126\126\126\162\162\162\162\162\198\198\025\025\018\018\018\061\ | |
1139 | \061\061\097\097\097\097\097\097\133\133\133\133\133\170\169\169\ | |
1140 | \169\169\169\169\205\205\205\205\025\025\025\018\018\061\061\061\ | |
1141 | \061\097\097\097\097\097\133\133\133\133\133\133\169\169\169\169\ | |
1142 | \169\169\205\205\205\205\025\025\025\025\068\061\061\061\061\097\ | |
1143 | \097\097\097\097\133\133\133\133\133\133\169\169\169\169\169\169\ | |
1144 | \169\205\205\205\025\025\025\025\067\067\061\061\061\061\061\097\ | |
1145 | \097\097\097\133\133\133\133\133\132\169\169\169\169\169\169\205\ | |
1146 | \205\205\025\025\025\025\025\067\067\061\061\061\060\060\097\097\ | |
1147 | \097\096\096\133\133\133\132\132\132\169\169\168\168\168\205\204\ | |
1148 | \024\024\025\025\025\067\067\067\061\060\060\060\060\097\096\096\ | |
1149 | \096\096\133\132\132\132\132\132\168\168\168\168\168\204\024\024\ | |
1150 | \024\025\025\067\067\067\067\060\060\060\060\060\096\096\096\096\ | |
1151 | \133\132\132\132\132\132\168\168\168\168\168\204\024\024\024\024\ | |
1152 | \024\067\067\067\067\067\060\060\060\060\096\096\096\096\096\132\ | |
1153 | \132\132\132\132\168\168\168\168\168\204\031\024\024\024\024\067\ | |
1154 | \067\067\067\067\067\060\060\060\103\139\139\096\139\139\132\132\ | |
1155 | \132\175\175\168\168\168\211\211\031\031\031\031\031\073\073\073\ | |
1156 | \067\067\066\066\060\103\246\246\246\246\139\139\138\138\175\175\ | |
1157 | \174\174\174\174\211\210\030\030\030\030\030\073\073\073\073\066\ | |
1158 | \066\066\066\109\246\246\246\246\139\138\138\138\138\174\174\174\ | |
1159 | \174\174\210\210\030\030\030\030\030\073\073\073\073\066\066\066\ | |
1160 | \066\109\246\246\246\246\247\138\138\138\138\174\174\174\174\174\ | |
1161 | \210\210\030\030\030\030\030\073\073\073\073\073\066\066\066\066\ | |
1162 | \246\246\246\246\247\138\138\138\138\138\174\174\174\174\174\210\ | |
1163 | \037\037\037\037\037\073\073\073\073\073\073\073\066\109\109\109\ | |
1164 | \247\247\247\248\138\138\138\181\174\174\174\174\174\210\036\036\ | |
1165 | \036\036\036\080\073\073\073\072\072\072\072\109\109\108\108\108\ | |
1166 | \248\144\144\144\138\181\180\180\180\180\217\216\036\036\036\036\ | |
1167 | \036\079\079\079\072\072\072\072\072\072\108\108\108\108\108\144\ | |
1168 | \144\144\144\180\180\180\180\180\216\216\036\036\036\036\036\079\ | |
1169 | \079\079\079\072\072\072\072\072\108\108\108\108\108\144\144\144\ | |
1170 | \144\187\180\180\180\180\223\216\036\036\036\036\036\079\079\079\ | |
1171 | \079\072\072\072\072\072\115\108\108\108\108\108\144\144\144\187\ | |
1172 | \180\180\180\180\180\216\036\036\036\042\042\079\079\079\079\079\ | |
1173 | \072\072\072\115\115\114\114\108\151\151\150\187\187\144\186\180\ | |
1174 | \180\180\180\216\042\042\042\042\042\079\079\079\079\079\078\078\ | |
1175 | \078\115\114\114\114\114\114\150\150\150\150\186\186\186\186\186\ | |
1176 | \223\222\042\042\042\042\042\079\079\079\079\078\078\078\078\078\ | |
1177 | \114\114\114\114\114\150\150\150\150\150\186\186\186\186\222\222\ | |
1178 | \042\042\042\042\042\085\085\079\079\078\078\078\078\078\114\114\ | |
1179 | \114\114\114\150\150\150\150\150\186\186\186\186\229\222\042\042\ | |
1180 | \042\042\042\085\085\085\085\078\078\078\078\078\114\114\114\114\ | |
1181 | \114\114\150\150\150\150\150\186\186\186\186\222\042\042\048\048\ | |
1182 | \048\085\085\085\085\085\078\078\078\121\121\120\120\114\114\157\ | |
1183 | \156\193\150\150\193\192\229\186\186\228\048\048\048\048\048\085\ | |
1184 | \085\085\085\084\084\084\084\121\120\120\120\120\120\156\156\156\ | |
1185 | \156\156\192\192\192\192\228\228\019\019\019\019\019\055\055\055\ | |
1186 | \055\055\055\055\054\091\091\091\091\127\127\127\127\127\126\163\ | |
1187 | \163\163\163\162\199\199\019\019\019\019\019\019\055\055\055\055\ | |
1188 | \055\055\054\091\091\091\091\127\127\127\127\126\126\163\163\163\ | |
1189 | \162\162\199\198\019\019\019\019\019\019\055\055\055\055\055\055\ | |
1190 | \054\091\091\091\091\127\127\127\127\126\126\163\163\162\162\162\ | |
1191 | \199\198\019\019\019\019\019\019\019\055\055\055\055\055\055\054\ | |
1192 | \091\091\091\127\127\127\126\126\126\163\163\162\162\162\162\198\ | |
1193 | \019\019\019\019\019\019\019\098\098\055\055\055\055\054\091\091\ | |
1194 | \091\127\127\127\126\126\126\163\162\162\162\162\162\198\025\019\ | |
1195 | \019\019\019\061\061\061\098\097\097\097\097\097\134\134\133\133\ | |
1196 | \133\170\170\170\169\169\169\169\162\205\205\205\025\025\025\019\ | |
1197 | \019\061\061\061\061\097\097\097\097\097\097\133\133\133\133\133\ | |
1198 | \170\170\169\169\169\169\169\205\205\205\025\025\025\025\068\061\ | |
1199 | \061\061\061\061\097\097\097\097\097\097\133\133\133\133\133\169\ | |
1200 | \169\169\169\169\169\205\205\205\025\025\025\025\068\068\061\061\ | |
1201 | \061\061\061\097\097\097\097\097\133\133\133\133\133\133\169\169\ | |
1202 | \169\169\169\205\205\205\025\025\025\025\025\067\067\061\061\061\ | |
1203 | \061\061\097\097\097\097\097\133\133\133\133\133\169\169\169\169\ | |
1204 | \169\205\205\205\025\025\025\025\025\067\067\067\061\061\061\061\ | |
1205 | \061\097\097\097\097\133\133\133\133\133\132\169\169\169\169\168\ | |
1206 | \205\205\025\025\025\025\025\067\067\067\061\061\061\061\061\097\ | |
1207 | \097\097\097\133\133\133\133\133\132\169\169\169\169\168\205\205\ | |
1208 | \024\024\024\025\025\067\067\067\067\067\061\061\060\060\103\097\ | |
1209 | \139\096\096\133\132\132\132\132\175\168\168\168\168\204\031\031\ | |
1210 | \031\024\024\067\067\067\067\067\067\067\060\103\103\103\139\139\ | |
1211 | \139\139\139\132\132\175\175\175\175\168\211\211\031\031\031\031\ | |
1212 | \031\074\067\067\067\067\067\067\103\103\103\103\103\139\139\139\ | |
1213 | \139\139\175\175\175\175\175\211\211\211\031\031\031\031\031\074\ | |
1214 | \073\067\067\067\067\067\067\103\103\103\103\139\139\139\139\139\ | |
1215 | \138\175\175\175\175\174\211\211\031\031\031\031\031\073\073\073\ | |
1216 | \073\067\067\067\109\103\103\103\103\247\139\139\139\139\138\175\ | |
1217 | \175\175\174\174\211\211\037\037\037\037\037\073\073\073\073\073\ | |
1218 | \073\073\066\109\109\109\247\247\247\248\138\138\138\181\174\174\ | |
1219 | \174\174\174\210\037\037\037\037\037\073\073\073\073\073\073\073\ | |
1220 | \066\109\109\109\109\247\247\248\145\249\138\181\181\181\181\174\ | |
1221 | \217\217\037\037\037\037\037\080\073\073\073\073\073\073\073\109\ | |
1222 | \109\109\109\248\248\248\145\249\138\181\181\181\181\174\217\217\ | |
1223 | \037\037\037\036\036\080\080\073\073\073\073\073\072\109\109\109\ | |
1224 | \109\108\145\145\145\249\144\181\181\181\181\174\217\217\037\036\ | |
1225 | \036\036\036\080\080\079\073\073\073\072\072\072\109\109\109\108\ | |
1226 | \249\249\249\249\144\181\181\181\180\180\223\217\036\036\036\036\ | |
1227 | \036\079\079\079\079\079\072\072\072\072\115\108\108\108\108\108\ | |
1228 | \144\144\144\187\187\180\180\180\223\216\043\043\043\043\043\079\ | |
1229 | \079\079\079\079\079\079\072\115\115\115\115\151\151\151\151\151\ | |
1230 | \187\187\187\187\180\180\223\223\043\043\043\043\042\079\079\079\ | |
1231 | \079\079\079\079\115\115\115\115\115\114\151\151\151\151\187\187\ | |
1232 | \187\187\187\180\223\223\043\043\042\042\042\079\079\079\079\079\ | |
1233 | \079\079\078\115\115\115\115\114\151\151\151\151\150\187\187\187\ | |
1234 | \187\186\223\223\043\042\042\042\042\042\079\079\079\079\079\079\ | |
1235 | \078\115\115\115\114\114\151\151\151\150\150\150\187\187\187\186\ | |
1236 | \223\223\042\042\042\042\042\085\085\085\085\085\078\078\078\078\ | |
1237 | \121\114\114\114\114\114\114\150\150\150\150\186\186\186\229\222\ | |
1238 | \049\049\049\042\042\085\085\085\085\085\085\085\078\121\121\121\ | |
1239 | \121\114\157\157\157\157\193\193\193\193\193\229\229\229\049\048\ | |
1240 | \048\048\048\085\085\085\085\085\085\085\084\121\121\121\121\120\ | |
1241 | \157\157\157\157\156\193\193\193\193\192\229\229\019\019\019\019\ | |
1242 | \019\056\055\055\055\055\055\055\055\091\091\091\091\091\127\127\ | |
1243 | \127\127\127\163\163\163\163\163\199\199\019\019\019\019\019\019\ | |
1244 | \056\055\055\055\055\055\055\091\091\091\091\091\127\127\127\127\ | |
1245 | \127\163\163\163\163\163\199\199\019\019\019\019\019\019\056\055\ | |
1246 | \055\055\055\055\055\091\091\091\091\091\127\127\127\127\126\163\ | |
1247 | \163\163\163\162\199\199\019\019\019\019\019\019\019\056\055\055\ | |
1248 | \055\055\055\055\091\091\091\091\127\127\127\127\126\163\163\163\ | |
1249 | \163\162\199\199\019\019\019\019\019\019\019\098\098\055\055\055\ | |
1250 | \055\055\091\091\091\091\127\127\127\127\126\163\163\163\163\162\ | |
1251 | \199\198\026\019\019\019\019\062\062\062\098\098\098\098\097\134\ | |
1252 | \134\134\134\134\170\170\170\170\170\169\169\206\206\206\206\205\ | |
1253 | \025\026\026\019\019\062\061\061\061\098\098\098\097\097\134\134\ | |
1254 | \134\133\133\133\170\170\170\169\169\169\169\206\205\205\025\025\ | |
1255 | \025\026\068\062\061\061\061\061\097\097\097\097\097\097\097\133\ | |
1256 | \133\133\133\170\169\169\169\169\169\169\205\205\025\025\025\025\ | |
1257 | \068\068\061\061\061\061\061\061\097\097\097\097\097\133\133\133\ | |
1258 | \133\133\169\169\169\169\169\169\205\205\025\025\025\025\025\068\ | |
1259 | \068\061\061\061\061\061\097\097\097\097\097\133\133\133\133\133\ | |
1260 | \169\169\169\169\169\169\205\205\025\025\025\025\025\068\068\067\ | |
1261 | \061\061\061\061\061\097\097\097\097\097\133\133\133\133\133\169\ | |
1262 | \169\169\169\169\205\205\025\025\025\025\025\068\068\067\061\061\ | |
1263 | \061\061\061\097\097\097\097\097\133\133\133\133\133\169\169\169\ | |
1264 | \169\169\205\205\025\025\025\025\025\067\067\067\067\061\061\061\ | |
1265 | \061\061\097\097\097\097\133\133\133\133\132\132\169\169\169\169\ | |
1266 | \205\205\031\031\031\025\025\074\067\067\067\067\067\067\061\103\ | |
1267 | \103\103\103\139\139\139\139\139\175\175\175\175\175\168\211\211\ | |
1268 | \031\031\031\031\031\074\074\067\067\067\067\067\067\103\103\103\ | |
1269 | \103\139\139\139\139\139\175\175\175\175\175\175\211\211\031\031\ | |
1270 | \031\031\031\074\074\067\067\067\067\067\067\103\103\103\103\103\ | |
1271 | \139\139\139\139\139\175\175\175\175\175\211\211\031\031\031\031\ | |
1272 | \031\074\074\067\067\067\067\067\067\103\103\103\103\103\139\139\ | |
1273 | \139\139\139\175\175\175\175\175\211\211\031\031\031\031\031\074\ | |
1274 | \073\073\073\073\067\067\067\109\109\103\103\103\248\139\139\139\ | |
1275 | \139\181\175\175\175\174\217\211\037\037\037\037\037\080\073\073\ | |
1276 | \073\073\073\073\073\109\109\109\109\248\248\248\145\249\138\181\ | |
1277 | \181\181\181\174\217\217\037\037\037\037\037\080\073\073\073\073\ | |
1278 | \073\073\073\109\109\109\109\109\248\248\145\249\250\181\181\181\ | |
1279 | \181\181\217\217\037\037\037\037\037\080\080\073\073\073\073\073\ | |
1280 | \073\109\109\109\109\109\145\145\145\249\250\181\181\181\181\181\ | |
1281 | \217\217\037\037\037\037\037\080\080\080\073\073\073\073\073\109\ | |
1282 | \109\109\109\109\249\249\249\249\250\181\181\181\181\181\217\217\ | |
1283 | \037\037\036\036\036\080\080\080\079\079\073\073\072\115\115\109\ | |
1284 | \109\108\108\250\250\250\250\187\181\181\181\181\223\217\043\043\ | |
1285 | \043\043\043\079\079\079\079\079\079\079\072\115\115\115\115\151\ | |
1286 | \151\151\151\151\187\187\187\187\187\223\223\223\043\043\043\043\ | |
1287 | \043\079\079\079\079\079\079\079\079\115\115\115\115\115\151\151\ | |
1288 | \151\151\187\187\187\187\187\187\223\223\043\043\043\043\043\086\ | |
1289 | \079\079\079\079\079\079\079\115\115\115\115\115\151\151\151\151\ | |
1290 | \151\187\187\187\187\187\223\223\043\043\043\043\043\086\079\079\ | |
1291 | \079\079\079\079\079\115\115\115\115\115\151\151\151\151\151\187\ | |
1292 | \187\187\187\187\223\223\043\043\042\042\042\086\086\079\079\079\ | |
1293 | \079\079\079\078\115\115\115\115\114\151\151\151\151\193\187\187\ | |
1294 | \187\187\229\223\049\049\049\049\049\086\085\085\085\085\085\085\ | |
1295 | \085\121\121\121\121\157\157\157\157\157\193\193\193\193\193\229\ | |
1296 | \229\229\049\049\049\049\048\085\085\085\085\085\085\085\085\121\ | |
1297 | \121\121\121\121\157\157\157\157\157\193\193\193\193\193\229\229\ | |
1298 | \019\019\019\019\019\056\056\055\055\055\055\055\055\091\091\091\ | |
1299 | \091\091\127\127\127\127\127\163\163\163\163\163\199\199\019\019\ | |
1300 | \019\019\019\019\056\056\055\055\055\055\055\091\091\091\091\091\ | |
1301 | \127\127\127\127\127\163\163\163\163\163\199\199\019\019\019\019\ | |
1302 | \019\019\056\056\055\055\055\055\055\055\091\091\091\091\127\127\ | |
1303 | \127\127\127\163\163\163\163\163\199\199\019\019\019\019\019\019\ | |
1304 | \019\056\056\055\055\055\055\055\091\091\091\091\091\127\127\127\ | |
1305 | \127\163\163\163\163\163\199\199\019\019\019\019\019\019\019\098\ | |
1306 | \098\055\055\055\055\055\055\091\091\091\091\127\127\127\127\163\ | |
1307 | \163\163\163\163\199\199\026\019\019\019\019\062\062\062\098\098\ | |
1308 | \098\098\098\134\134\134\134\134\170\170\170\170\170\170\169\206\ | |
1309 | \206\206\206\199\026\026\026\019\019\062\062\062\098\098\098\098\ | |
1310 | \098\097\134\134\134\134\170\170\170\170\170\170\169\169\206\206\ | |
1311 | \206\205\025\026\026\026\068\062\062\061\061\061\098\098\098\097\ | |
1312 | \097\134\134\134\133\133\133\170\170\169\169\169\169\206\206\205\ | |
1313 | \025\025\025\026\068\068\068\061\061\061\061\061\097\097\097\097\ | |
1314 | \097\097\133\133\133\133\170\169\169\169\169\169\205\205\025\025\ | |
1315 | \025\025\025\068\068\061\061\061\061\061\061\097\097\097\097\097\ | |
1316 | \133\133\133\133\133\169\169\169\169\169\205\205\025\025\025\025\ | |
1317 | \025\068\068\068\061\061\061\061\061\097\097\097\097\097\133\133\ | |
1318 | \133\133\133\169\169\169\169\169\205\205\025\025\025\025\025\068\ | |
1319 | \068\068\061\061\061\061\061\097\097\097\097\097\133\133\133\133\ | |
1320 | \133\169\169\169\169\169\205\205\025\025\025\025\025\068\068\068\ | |
1321 | \067\061\061\061\061\061\097\097\097\097\097\133\133\133\133\169\ | |
1322 | \169\169\169\169\205\205\031\031\025\025\025\074\067\067\067\067\ | |
1323 | \067\067\061\103\103\103\103\097\139\139\139\139\133\175\175\175\ | |
1324 | \175\169\211\211\031\031\031\031\025\074\074\067\067\067\067\067\ | |
1325 | \067\103\103\103\103\103\139\139\139\139\139\175\175\175\175\175\ | |
1326 | \211\211\031\031\031\031\031\074\074\074\067\067\067\067\067\103\ | |
1327 | \103\103\103\103\139\139\139\139\139\175\175\175\175\175\211\211\ | |
1328 | \031\031\031\031\031\074\074\074\067\067\067\067\067\103\103\103\ | |
1329 | \103\103\139\139\139\139\139\175\175\175\175\175\211\211\031\031\ | |
1330 | \031\031\031\074\074\074\067\067\067\067\067\067\103\103\103\103\ | |
1331 | \103\139\139\139\139\175\175\175\175\175\211\211\037\037\037\031\ | |
1332 | \031\080\080\073\073\073\073\073\067\109\109\109\109\103\145\145\ | |
1333 | \145\249\139\181\181\181\181\174\217\217\037\037\037\037\037\080\ | |
1334 | \080\073\073\073\073\073\073\109\109\109\109\109\145\145\145\249\ | |
1335 | \250\181\181\181\181\181\217\217\037\037\037\037\037\080\080\073\ | |
1336 | \073\073\073\073\073\109\109\109\109\109\145\145\145\249\250\181\ | |
1337 | \181\181\181\181\217\217\037\037\037\037\037\080\080\080\073\073\ | |
1338 | \073\073\073\109\109\109\109\109\249\249\249\249\250\181\181\181\ | |
1339 | \181\181\217\217\037\037\037\037\037\080\080\080\080\073\073\073\ | |
1340 | \073\073\109\109\109\109\109\250\250\250\250\251\181\181\181\181\ | |
1341 | \217\217\043\043\043\043\043\080\080\079\079\079\079\079\079\115\ | |
1342 | \115\115\115\115\151\151\151\151\251\187\187\187\187\181\223\223\ | |
1343 | \043\043\043\043\043\079\079\079\079\079\079\079\079\115\115\115\ | |
1344 | \115\115\151\151\151\151\151\187\187\187\187\187\223\223\043\043\ | |
1345 | \043\043\043\086\079\079\079\079\079\079\079\115\115\115\115\115\ | |
1346 | \151\151\151\151\151\187\187\187\187\187\223\223\043\043\043\043\ | |
1347 | \043\086\086\079\079\079\079\079\079\115\115\115\115\115\151\151\ | |
1348 | \151\151\151\187\187\187\187\187\223\223\043\043\043\043\043\086\ | |
1349 | \086\086\079\079\079\079\079\079\115\115\115\115\114\151\151\151\ | |
1350 | \151\151\187\187\187\187\229\223\049\049\049\049\049\086\086\086\ | |
1351 | \085\085\085\085\085\121\121\121\121\121\157\157\157\157\157\193\ | |
1352 | \193\193\193\229\229\229\049\049\049\049\049\049\085\085\085\085\ | |
1353 | \085\085\085\121\121\121\121\121\157\157\157\157\157\193\193\193\ | |
1354 | \193\193\229\229\019\019\019\019\019\056\056\056\055\055\055\055\ | |
1355 | \055\091\091\091\091\091\127\127\127\127\127\163\163\163\163\163\ | |
1356 | \199\199\019\019\019\019\019\019\056\056\055\055\055\055\055\055\ | |
1357 | \091\091\091\091\091\127\127\127\127\163\163\163\163\163\199\199\ | |
1358 | \019\019\019\019\019\019\056\056\056\055\055\055\055\055\091\091\ | |
1359 | \091\091\091\127\127\127\127\163\163\163\163\163\199\199\019\019\ | |
1360 | \019\019\019\019\019\056\056\055\055\055\055\055\091\091\091\091\ | |
1361 | \091\127\127\127\127\163\163\163\163\163\199\199\019\019\019\019\ | |
1362 | \019\019\019\098\098\056\055\055\055\055\055\091\091\091\091\127\ | |
1363 | \127\127\127\163\163\163\163\163\199\199\026\019\019\019\019\062\ | |
1364 | \062\062\098\098\098\098\098\134\134\134\134\134\170\170\170\170\ | |
1365 | \170\170\163\206\206\206\206\199\026\026\026\019\019\062\062\062\ | |
1366 | \062\098\098\098\098\134\134\134\134\134\134\170\170\170\170\170\ | |
1367 | \169\169\206\206\206\205\026\026\026\026\068\062\062\062\062\098\ | |
1368 | \098\098\098\097\097\134\134\134\134\170\170\170\170\170\169\169\ | |
1369 | \169\206\206\205\025\025\026\026\068\068\062\062\061\061\061\061\ | |
1370 | \098\097\097\097\097\134\133\133\133\133\170\170\169\169\169\169\ | |
1371 | \205\205\025\025\025\025\026\068\068\068\061\061\061\061\061\097\ | |
1372 | \097\097\097\097\133\133\133\133\133\169\169\169\169\169\205\205\ | |
1373 | \025\025\025\025\025\068\068\068\061\061\061\061\061\097\097\097\ | |
1374 | \097\097\133\133\133\133\133\169\169\169\169\169\205\205\025\025\ | |
1375 | \025\025\025\068\068\068\061\061\061\061\061\097\097\097\097\097\ | |
1376 | \133\133\133\133\133\169\169\169\169\169\205\205\025\025\025\025\ | |
1377 | \025\068\068\068\068\061\061\061\061\061\097\097\097\097\097\133\ | |
1378 | \133\133\133\169\169\169\169\169\205\205\031\025\025\025\025\074\ | |
1379 | \068\067\067\067\067\061\061\103\103\103\097\097\097\139\139\139\ | |
1380 | \133\176\175\175\175\169\212\211\031\031\031\031\025\074\074\067\ | |
1381 | \067\067\067\067\067\103\103\103\103\103\139\139\139\139\139\175\ | |
1382 | \175\175\175\175\211\211\031\031\031\031\031\074\074\074\067\067\ | |
1383 | \067\067\067\103\103\103\103\103\139\139\139\139\139\175\175\175\ | |
1384 | \175\175\211\211\031\031\031\031\031\074\074\074\067\067\067\067\ | |
1385 | \067\067\103\103\103\103\139\139\139\139\139\175\175\175\175\175\ | |
1386 | \211\211\031\031\031\031\031\074\074\074\074\067\067\067\067\067\ | |
1387 | \103\103\103\103\103\139\139\139\139\182\175\175\175\175\218\211\ | |
1388 | \037\031\031\031\031\080\074\074\073\073\073\073\067\067\109\109\ | |
1389 | \109\103\249\249\249\249\139\182\181\181\175\175\217\217\037\037\ | |
1390 | \037\037\037\080\080\080\073\073\073\073\073\109\109\109\109\109\ | |
1391 | \249\249\249\249\250\181\181\181\181\181\217\217\037\037\037\037\ | |
1392 | \037\080\080\080\073\073\073\073\073\109\109\109\109\109\249\249\ | |
1393 | \249\249\250\181\181\181\181\181\217\217\037\037\037\037\037\080\ | |
1394 | \080\080\073\073\073\073\073\109\109\109\109\109\249\249\249\249\ | |
1395 | \250\251\181\181\181\181\217\217\037\037\037\037\037\080\080\080\ | |
1396 | \080\073\073\073\073\073\109\109\109\109\109\250\250\250\250\251\ | |
1397 | \181\181\181\181\217\217\043\043\043\043\043\080\080\080\080\079\ | |
1398 | \079\079\079\115\115\115\115\152\151\151\151\251\251\251\187\187\ | |
1399 | \181\181\223\223\043\043\043\043\043\043\079\079\079\079\079\079\ | |
1400 | \079\115\115\115\115\115\151\151\151\151\151\187\187\187\187\187\ | |
1401 | \223\223\043\043\043\043\043\086\079\079\079\079\079\079\079\115\ | |
1402 | \115\115\115\115\151\151\151\151\151\187\187\187\187\187\223\223\ | |
1403 | \043\043\043\043\043\086\086\079\079\079\079\079\079\115\115\115\ | |
1404 | \115\115\115\151\151\151\151\187\187\187\187\187\223\223\043\043\ | |
1405 | \043\043\043\086\086\086\079\079\079\079\079\079\115\115\115\115\ | |
1406 | \115\151\151\151\151\151\187\187\187\187\229\223\049\049\049\049\ | |
1407 | \049\086\086\086\085\085\085\085\085\122\121\121\121\158\157\157\ | |
1408 | \157\157\157\193\193\193\193\229\229\229\049\049\049\049\049\049\ | |
1409 | \085\085\085\085\085\085\085\121\121\121\121\121\157\157\157\157\ | |
1410 | \157\193\193\193\193\193\229\229\019\019\019\019\019\056\056\056\ | |
1411 | \056\055\055\055\055\055\091\091\091\091\091\127\127\127\127\164\ | |
1412 | \163\163\163\163\200\199\019\019\019\019\019\019\056\056\056\056\ | |
1413 | \055\055\055\055\092\091\091\091\091\127\127\127\127\164\163\163\ | |
1414 | \163\163\200\199\019\019\019\019\019\019\056\056\056\056\055\055\ | |
1415 | \055\055\092\091\091\091\091\091\127\127\127\164\163\163\163\163\ | |
1416 | \200\199\019\019\019\019\019\019\019\056\056\056\056\056\055\055\ | |
1417 | \055\091\091\091\091\091\127\127\127\164\163\163\163\163\199\199\ | |
1418 | \019\019\019\019\019\019\019\098\098\056\056\056\055\055\055\092\ | |
1419 | \091\091\091\091\127\127\127\164\163\163\163\163\199\199\026\019\ | |
1420 | \019\019\019\062\062\062\098\098\098\098\098\134\134\134\134\134\ | |
1421 | \134\170\170\170\170\170\170\163\206\206\206\199\026\026\026\019\ | |
1422 | \019\062\062\062\062\098\098\098\098\098\134\134\134\134\134\170\ | |
1423 | \170\170\170\170\170\206\206\206\206\206\026\026\026\026\068\062\ | |
1424 | \062\062\062\062\098\098\098\098\134\134\134\134\134\134\170\170\ | |
1425 | \170\170\170\169\169\206\206\206\026\026\026\026\068\068\062\062\ | |
1426 | \062\062\062\098\098\098\098\097\134\134\134\134\170\170\170\170\ | |
1427 | \170\169\169\206\206\205\025\026\026\026\026\068\068\062\062\061\ | |
1428 | \061\061\098\098\097\097\097\097\134\134\133\133\133\170\169\169\ | |
1429 | \169\169\206\205\025\025\025\026\026\068\068\068\062\061\061\061\ | |
1430 | \061\098\097\097\097\097\097\133\133\133\133\170\169\169\169\169\ | |
1431 | \206\205\025\025\025\026\026\068\068\068\068\061\061\061\061\061\ | |
1432 | \097\097\097\097\097\133\133\133\133\170\169\169\169\169\169\205\ | |
1433 | \025\025\025\025\025\068\068\068\068\068\061\061\061\061\097\097\ | |
1434 | \097\097\097\133\133\133\133\133\169\169\169\169\169\205\025\025\ | |
1435 | \025\025\025\068\068\068\068\068\068\061\061\061\061\104\140\097\ | |
1436 | \097\140\133\133\133\176\176\169\169\169\212\205\031\032\032\025\ | |
1437 | \025\074\074\068\068\067\067\067\061\061\103\103\103\140\140\140\ | |
1438 | \139\139\139\176\175\175\175\175\212\211\031\031\031\031\032\074\ | |
1439 | \074\074\067\067\067\067\067\104\103\103\103\103\103\139\139\139\ | |
1440 | \139\176\175\175\175\175\212\211\031\031\031\031\031\074\074\074\ | |
1441 | \074\067\067\067\067\110\103\103\103\103\103\139\139\139\139\176\ | |
1442 | \175\175\175\175\175\211\031\031\031\031\031\074\074\074\074\067\ | |
1443 | \067\067\067\067\110\103\103\103\103\139\139\139\139\182\175\175\ | |
1444 | \175\175\175\211\031\031\031\031\031\074\074\074\074\074\067\067\ | |
1445 | \067\067\110\103\103\103\103\103\139\139\139\182\182\175\175\175\ | |
1446 | \218\211\037\037\031\031\031\080\080\074\074\074\073\073\073\110\ | |
1447 | \110\109\109\103\103\250\250\250\250\182\182\181\181\181\218\217\ | |
1448 | \037\037\037\037\037\080\080\080\080\073\073\073\073\073\109\109\ | |
1449 | \109\109\109\250\250\250\250\251\181\181\181\181\217\217\037\037\ | |
1450 | \037\037\037\080\080\080\080\073\073\073\073\073\109\109\109\109\ | |
1451 | \109\250\250\250\250\251\181\181\181\181\217\217\037\037\037\037\ | |
1452 | \037\080\080\080\080\073\073\073\073\073\109\109\109\109\109\250\ | |
1453 | \250\250\250\251\181\181\181\181\224\217\044\044\044\044\044\080\ | |
1454 | \080\080\080\080\080\080\073\116\116\116\116\152\152\152\251\251\ | |
1455 | \251\251\252\181\181\181\224\217\043\043\043\043\043\080\080\080\ | |
1456 | \080\080\079\079\079\116\115\115\115\115\152\152\151\151\151\252\ | |
1457 | \187\187\187\181\224\223\043\043\043\043\043\043\086\079\079\079\ | |
1458 | \079\079\079\079\115\115\115\115\115\151\151\151\151\151\187\187\ | |
1459 | \187\187\230\223\043\043\043\043\043\086\086\079\079\079\079\079\ | |
1460 | \079\079\115\115\115\115\115\151\151\151\151\151\187\187\187\187\ | |
1461 | \230\223\043\043\043\043\043\086\086\086\086\079\079\079\079\079\ | |
1462 | \115\115\115\115\115\151\151\151\151\151\151\187\187\187\230\223\ | |
1463 | \050\050\050\049\049\086\086\086\086\086\086\079\079\122\122\122\ | |
1464 | \115\115\158\158\157\157\194\194\194\230\230\230\230\223\049\049\ | |
1465 | \049\049\049\049\086\086\085\085\085\085\085\085\121\121\121\121\ | |
1466 | \121\157\157\157\157\157\193\193\193\193\193\229\020\020\020\020\ | |
1467 | \020\056\056\056\056\056\056\056\055\092\092\092\092\091\128\128\ | |
1468 | \128\128\164\164\164\164\164\163\200\200\020\020\020\020\020\020\ | |
1469 | \056\056\056\056\056\056\055\092\092\092\092\091\128\128\128\128\ | |
1470 | \164\164\164\164\163\163\200\200\020\020\020\020\020\020\056\056\ | |
1471 | \056\056\056\056\056\055\092\092\092\091\128\128\128\128\164\164\ | |
1472 | \164\164\163\163\200\199\020\020\020\020\020\020\020\056\056\056\ | |
1473 | \056\056\056\055\092\092\092\092\128\128\128\128\164\164\164\164\ | |
1474 | \163\163\200\199\020\020\020\020\020\020\020\020\098\056\056\056\ | |
1475 | \056\056\092\092\092\092\128\128\128\128\164\164\164\163\163\163\ | |
1476 | \200\199\026\020\020\020\020\062\062\062\098\098\098\098\098\098\ | |
1477 | \134\134\134\134\134\134\170\170\170\170\170\207\207\206\206\206\ | |
1478 | \026\026\026\020\020\062\062\062\062\098\098\098\098\098\134\134\ | |
1479 | \134\134\134\134\170\170\170\170\170\170\170\206\206\206\026\026\ | |
1480 | \026\026\020\062\062\062\062\062\098\098\098\098\098\134\134\134\ | |
1481 | \134\134\134\170\170\170\170\170\170\206\206\206\026\026\026\026\ | |
1482 | \068\068\062\062\062\062\062\062\098\098\098\098\134\134\134\134\ | |
1483 | \134\134\170\170\170\170\170\206\206\206\026\026\026\026\026\068\ | |
1484 | \068\062\062\062\062\062\098\098\098\098\098\134\134\134\134\134\ | |
1485 | \170\170\170\170\170\169\206\206\026\026\026\026\026\068\068\068\ | |
1486 | \062\062\062\062\062\098\098\098\098\097\134\134\134\134\170\170\ | |
1487 | \170\170\170\169\206\206\026\026\026\026\026\068\068\068\062\062\ | |
1488 | \062\062\062\098\098\098\098\097\134\134\134\134\170\170\170\170\ | |
1489 | \169\169\206\206\025\025\026\026\026\068\068\068\068\068\062\062\ | |
1490 | \061\061\098\098\097\097\097\097\134\134\133\133\170\170\169\169\ | |
1491 | \169\205\032\032\025\025\026\068\068\068\068\068\068\068\061\104\ | |
1492 | \104\104\140\140\140\140\140\176\176\176\176\176\169\169\212\212\ | |
1493 | \032\032\032\032\032\074\068\068\068\068\068\068\068\104\104\104\ | |
1494 | \104\140\140\140\140\140\176\176\176\176\176\212\212\212\032\032\ | |
1495 | \032\032\032\074\074\074\068\068\068\068\068\104\104\104\104\104\ | |
1496 | \140\140\140\140\176\176\176\176\176\175\212\212\032\032\032\032\ | |
1497 | \032\074\074\074\068\068\068\068\067\104\104\104\104\104\140\140\ | |
1498 | \140\140\176\176\176\176\175\175\212\212\031\031\031\032\032\074\ | |
1499 | \074\074\074\074\067\067\067\110\110\104\104\103\146\146\140\182\ | |
1500 | \182\139\176\175\175\175\175\211\038\038\038\038\038\074\074\074\ | |
1501 | \074\074\074\074\067\110\110\110\110\146\146\146\146\182\182\182\ | |
1502 | \182\182\175\175\218\218\038\038\038\038\038\074\074\074\074\074\ | |
1503 | \074\074\067\110\110\110\110\146\146\146\146\146\182\182\182\182\ | |
1504 | \182\218\218\218\038\038\038\038\038\080\080\074\074\074\074\074\ | |
1505 | \074\110\110\110\110\110\146\146\146\146\251\182\182\182\182\181\ | |
1506 | \218\218\038\038\038\038\038\080\080\080\074\074\074\074\074\116\ | |
1507 | \110\110\110\152\146\146\146\251\251\251\182\182\182\181\218\218\ | |
1508 | \044\044\044\044\044\080\080\080\080\080\080\080\073\116\116\116\ | |
1509 | \116\152\152\152\251\251\251\251\252\181\181\181\224\217\044\044\ | |
1510 | \044\044\044\080\080\080\080\080\080\080\073\116\116\116\116\109\ | |
1511 | \152\152\152\251\251\251\252\188\253\181\224\224\044\044\044\044\ | |
1512 | \044\080\080\080\080\080\080\080\080\116\116\116\116\116\152\152\ | |
1513 | \152\152\252\252\252\188\253\181\224\224\044\044\044\044\043\087\ | |
1514 | \080\080\080\080\080\080\080\116\116\116\116\115\152\152\152\152\ | |
1515 | \151\188\188\188\253\187\224\224\044\043\043\043\043\087\080\080\ | |
1516 | \080\080\080\080\079\079\116\116\115\115\115\152\152\152\151\253\ | |
1517 | \253\253\253\187\224\224\043\043\043\043\043\086\086\086\086\079\ | |
1518 | \079\079\079\079\122\115\115\115\115\158\151\151\151\151\151\187\ | |
1519 | \187\187\230\223\050\050\050\050\050\086\086\086\086\086\086\086\ | |
1520 | \079\122\122\122\122\115\158\158\158\158\194\194\194\194\194\230\ | |
1521 | \230\230\050\050\049\049\049\086\086\086\086\086\086\086\085\122\ | |
1522 | \122\122\122\121\158\158\158\158\157\194\194\194\194\193\230\230\ | |
1523 | \020\020\020\020\020\056\056\056\056\056\056\056\056\092\092\092\ | |
1524 | \092\092\128\128\128\128\128\164\164\164\164\164\200\200\020\020\ | |
1525 | \020\020\020\020\056\056\056\056\056\056\056\092\092\092\092\092\ | |
1526 | \128\128\128\128\128\164\164\164\164\164\200\200\020\020\020\020\ | |
1527 | \020\020\020\056\056\056\056\056\056\056\092\092\092\092\128\128\ | |
1528 | \128\128\128\164\164\164\164\163\200\200\020\020\020\020\020\020\ | |
1529 | \020\056\056\056\056\056\056\056\092\092\092\092\128\128\128\128\ | |
1530 | \128\164\164\164\164\163\200\200\020\020\020\020\020\020\020\020\ | |
1531 | \099\056\056\056\056\056\056\092\092\092\092\128\128\128\128\164\ | |
1532 | \164\164\164\163\200\200\026\020\020\020\020\062\062\062\098\098\ | |
1533 | \098\098\098\098\135\134\134\134\134\134\134\128\170\170\170\207\ | |
1534 | \207\207\206\206\026\026\020\020\020\062\062\062\062\098\098\098\ | |
1535 | \098\098\098\134\134\134\134\134\134\134\170\170\170\170\170\207\ | |
1536 | \206\206\026\026\026\026\020\062\062\062\062\062\098\098\098\098\ | |
1537 | \098\098\134\134\134\134\134\134\170\170\170\170\170\207\206\206\ | |
1538 | \026\026\026\026\069\068\062\062\062\062\062\062\098\098\098\098\ | |
1539 | \098\134\134\134\134\134\170\170\170\170\170\206\206\206\026\026\ | |
1540 | \026\026\026\068\068\062\062\062\062\062\062\098\098\098\098\134\ | |
1541 | \134\134\134\134\134\170\170\170\170\170\206\206\026\026\026\026\ | |
1542 | \026\068\068\068\062\062\062\062\062\098\098\098\098\098\134\134\ | |
1543 | \134\134\134\170\170\170\170\170\206\206\026\026\026\026\026\068\ | |
1544 | \068\068\062\062\062\062\062\098\098\098\098\098\134\134\134\134\ | |
1545 | \134\170\170\170\170\170\206\206\026\026\026\026\026\068\068\068\ | |
1546 | \068\062\062\062\062\062\098\098\098\098\140\134\134\134\134\170\ | |
1547 | \170\170\170\169\206\206\032\032\026\026\026\068\068\068\068\068\ | |
1548 | \068\068\062\104\104\104\104\140\140\140\140\140\176\176\176\176\ | |
1549 | \176\169\212\212\032\032\032\032\026\075\068\068\068\068\068\068\ | |
1550 | \068\104\104\104\104\140\140\140\140\140\176\176\176\176\176\176\ | |
1551 | \212\212\032\032\032\032\032\074\074\068\068\068\068\068\068\104\ | |
1552 | \104\104\104\104\140\140\140\140\140\176\176\176\176\176\212\212\ | |
1553 | \032\032\032\032\032\074\074\068\068\068\068\068\068\104\104\104\ | |
1554 | \104\104\140\140\140\140\140\176\176\176\176\176\212\212\032\032\ | |
1555 | \032\032\032\074\074\074\074\068\068\068\068\110\104\104\104\104\ | |
1556 | \104\140\140\140\140\176\176\176\176\175\218\212\038\038\038\038\ | |
1557 | \032\074\074\074\074\074\074\074\110\110\110\110\110\104\146\146\ | |
1558 | \146\146\182\182\182\182\182\175\218\218\038\038\038\038\038\074\ | |
1559 | \074\074\074\074\074\074\074\110\110\110\110\110\146\146\146\146\ | |
1560 | \182\182\182\182\182\182\218\218\038\038\038\038\038\074\074\074\ | |
1561 | \074\074\074\074\074\110\110\110\110\110\146\146\146\146\146\182\ | |
1562 | \182\182\182\182\218\218\038\038\038\038\038\038\074\074\074\074\ | |
1563 | \074\074\074\110\110\110\110\110\146\146\146\146\146\182\182\182\ | |
1564 | \182\182\218\218\038\038\038\038\038\080\080\080\080\074\074\074\ | |
1565 | \074\116\116\110\110\110\152\152\146\146\146\252\182\182\182\182\ | |
1566 | \224\218\044\044\044\044\044\080\080\080\080\080\080\080\080\116\ | |
1567 | \116\116\116\116\152\152\152\152\252\252\252\188\253\181\224\224\ | |
1568 | \044\044\044\044\044\080\080\080\080\080\080\080\080\116\116\116\ | |
1569 | \116\116\152\152\152\152\152\252\252\188\253\254\224\224\044\044\ | |
1570 | \044\044\044\087\080\080\080\080\080\080\080\116\116\116\116\116\ | |
1571 | \152\152\152\152\152\188\188\188\253\254\224\224\044\044\044\044\ | |
1572 | \044\087\080\080\080\080\080\080\080\116\116\116\116\116\152\152\ | |
1573 | \152\152\152\253\253\253\253\254\224\224\044\044\043\043\043\087\ | |
1574 | \087\087\086\080\080\080\080\079\116\116\116\115\115\152\152\152\ | |
1575 | \151\151\254\254\254\254\230\224\050\050\050\050\050\086\086\086\ | |
1576 | \086\086\086\086\086\122\122\122\122\158\158\158\158\158\194\194\ | |
1577 | \194\194\194\230\230\230\050\050\050\050\050\086\086\086\086\086\ | |
1578 | \086\086\086\122\122\122\122\122\158\158\158\158\158\194\194\194\ | |
1579 | \194\194\230\230\020\020\020\020\020\057\056\056\056\056\056\056\ | |
1580 | \056\092\092\092\092\092\128\128\128\128\128\164\164\164\164\164\ | |
1581 | \200\200\020\020\020\020\020\020\056\056\056\056\056\056\056\056\ | |
1582 | \092\092\092\092\128\128\128\128\128\164\164\164\164\164\200\200\ | |
1583 | \020\020\020\020\020\020\020\056\056\056\056\056\056\056\092\092\ | |
1584 | \092\092\092\128\128\128\128\164\164\164\164\164\200\200\020\020\ | |
1585 | \020\020\020\020\020\020\056\056\056\056\056\056\056\092\092\092\ | |
1586 | \092\128\128\128\128\164\164\164\164\164\200\200\020\020\020\020\ | |
1587 | \020\020\020\020\099\056\056\056\056\056\056\092\092\092\092\128\ | |
1588 | \128\128\128\128\164\164\164\164\200\200\027\020\020\020\020\063\ | |
1589 | \063\063\099\099\099\099\098\056\135\135\135\134\134\171\171\171\ | |
1590 | \128\207\207\207\207\207\207\206\026\026\020\020\020\063\062\062\ | |
1591 | \062\099\098\098\098\098\098\135\135\134\134\134\134\134\171\170\ | |
1592 | \170\170\170\207\206\206\026\026\026\020\020\063\062\062\062\062\ | |
1593 | \098\098\098\098\098\098\098\134\134\134\134\134\134\170\170\170\ | |
1594 | \170\207\206\206\026\026\026\026\069\069\062\062\062\062\062\062\ | |
1595 | \098\098\098\098\098\134\134\134\134\134\134\170\170\170\170\207\ | |
1596 | \206\206\026\026\026\026\026\069\069\062\062\062\062\062\062\098\ | |
1597 | \098\098\098\098\134\134\134\134\134\170\170\170\170\170\206\206\ | |
1598 | \026\026\026\026\026\069\068\068\062\062\062\062\062\098\098\098\ | |
1599 | \098\098\134\134\134\134\134\170\170\170\170\170\206\206\026\026\ | |
1600 | \026\026\026\069\068\068\062\062\062\062\062\098\098\098\098\098\ | |
1601 | \134\134\134\134\134\170\170\170\170\170\206\206\026\026\026\026\ | |
1602 | \026\068\068\068\068\062\062\062\062\062\098\098\098\098\098\134\ | |
1603 | \134\134\134\170\170\170\170\170\206\206\032\026\026\026\026\026\ | |
1604 | \068\068\068\068\068\068\062\104\104\104\104\098\140\140\140\140\ | |
1605 | \134\176\176\176\176\170\212\212\032\032\032\026\026\075\068\068\ | |
1606 | \068\068\068\068\068\104\104\104\104\104\140\140\140\140\140\176\ | |
1607 | \176\176\176\176\212\212\032\032\032\032\032\075\075\068\068\068\ | |
1608 | \068\068\068\104\104\104\104\104\140\140\140\140\140\176\176\176\ | |
1609 | \176\176\212\212\032\032\032\032\032\075\075\068\068\068\068\068\ | |
1610 | \068\104\104\104\104\104\140\140\140\140\140\176\176\176\176\176\ | |
1611 | \212\212\032\032\032\032\032\074\074\074\074\068\068\068\068\068\ | |
1612 | \104\104\104\104\104\140\140\140\140\140\176\176\176\176\212\212\ | |
1613 | \038\038\032\032\032\074\074\074\074\074\074\074\068\110\110\110\ | |
1614 | \110\104\146\146\146\146\140\182\182\182\182\176\218\218\038\038\ | |
1615 | \038\038\038\081\074\074\074\074\074\074\074\110\110\110\110\110\ | |
1616 | \146\146\146\146\146\182\182\182\182\182\218\218\038\038\038\038\ | |
1617 | \038\081\074\074\074\074\074\074\074\110\110\110\110\110\146\146\ | |
1618 | \146\146\146\182\182\182\182\182\218\218\038\038\038\038\038\081\ | |
1619 | \074\074\074\074\074\074\074\110\110\110\110\110\146\146\146\146\ | |
1620 | \146\182\182\182\182\182\218\218\038\038\038\038\038\038\081\074\ | |
1621 | \074\074\074\074\074\074\110\110\110\110\110\146\146\146\146\146\ | |
1622 | \182\182\182\182\225\218\044\044\044\044\038\087\080\080\080\080\ | |
1623 | \080\080\080\116\116\116\116\110\152\152\152\152\146\188\188\188\ | |
1624 | \253\182\224\224\044\044\044\044\044\087\080\080\080\080\080\080\ | |
1625 | \080\116\116\116\116\116\152\152\152\152\152\188\188\188\253\254\ | |
1626 | \224\224\044\044\044\044\044\087\080\080\080\080\080\080\080\116\ | |
1627 | \116\116\116\116\152\152\152\152\152\188\188\188\253\254\224\224\ | |
1628 | \044\044\044\044\044\087\080\080\080\080\080\080\080\116\116\116\ | |
1629 | \116\116\152\152\152\152\152\253\253\253\253\254\224\224\044\044\ | |
1630 | \044\044\044\087\087\087\087\080\080\080\080\080\116\116\116\116\ | |
1631 | \116\152\152\152\152\152\254\254\254\254\255\224\050\050\050\050\ | |
1632 | \050\087\086\086\086\086\086\086\086\122\122\122\122\122\158\158\ | |
1633 | \158\158\195\194\194\194\194\255\230\230\050\050\050\050\050\086\ | |
1634 | \086\086\086\086\086\086\086\122\122\122\122\122\158\158\158\158\ | |
1635 | \158\194\194\194\194\194\230\230\020\020\020\020\020\057\057\056\ | |
1636 | \056\056\056\056\056\092\092\092\092\092\128\128\128\128\128\164\ | |
1637 | \164\164\164\164\200\200\020\020\020\020\020\020\057\056\056\056\ | |
1638 | \056\056\056\056\092\092\092\092\092\128\128\128\128\128\164\164\ | |
1639 | \164\164\200\200\020\020\020\020\020\020\020\057\056\056\056\056\ | |
1640 | \056\056\092\092\092\092\092\128\128\128\128\128\164\164\164\164\ | |
1641 | \200\200\020\020\020\020\020\020\020\020\056\056\056\056\056\056\ | |
1642 | \056\092\092\092\092\128\128\128\128\128\164\164\164\164\200\200\ | |
1643 | \020\020\020\020\020\020\020\020\099\056\056\056\056\056\056\092\ | |
1644 | \092\092\092\128\128\128\128\128\164\164\164\164\200\200\027\020\ | |
1645 | \020\020\020\063\063\063\099\099\099\099\098\135\135\135\135\135\ | |
1646 | \092\171\171\171\171\207\207\207\207\207\207\200\027\027\020\020\ | |
1647 | \020\063\062\062\062\099\099\099\098\098\135\135\135\135\134\134\ | |
1648 | \171\171\171\170\170\170\170\207\207\206\026\026\027\020\020\063\ | |
1649 | \062\062\062\062\098\098\098\098\098\098\098\134\134\134\134\134\ | |
1650 | \134\170\170\170\170\207\207\206\026\026\026\026\069\069\062\062\ | |
1651 | \062\062\062\062\098\098\098\098\098\134\134\134\134\134\134\170\ | |
1652 | \170\170\170\207\207\206\026\026\026\026\026\069\069\062\062\062\ | |
1653 | \062\062\062\098\098\098\098\098\134\134\134\134\134\170\170\170\ | |
1654 | \170\170\206\206\026\026\026\026\026\069\069\068\062\062\062\062\ | |
1655 | \062\098\098\098\098\098\134\134\134\134\134\170\170\170\170\170\ | |
1656 | \206\206\026\026\026\026\026\069\069\068\062\062\062\062\062\062\ | |
1657 | \098\098\098\098\134\134\134\134\134\134\170\170\170\170\206\206\ | |
1658 | \026\026\026\026\026\068\068\068\068\062\062\062\062\062\098\098\ | |
1659 | \098\098\098\134\134\134\134\134\170\170\170\170\206\206\032\026\ | |
1660 | \026\026\026\075\068\068\068\068\068\062\062\104\104\104\098\098\ | |
1661 | \140\140\140\140\134\134\176\176\176\170\213\212\032\032\032\026\ | |
1662 | \026\075\075\068\068\068\068\068\068\104\104\104\104\104\140\140\ | |
1663 | \140\140\140\176\176\176\176\176\212\212\032\032\032\032\032\075\ | |
1664 | \075\068\068\068\068\068\068\104\104\104\104\104\140\140\140\140\ | |
1665 | \140\176\176\176\176\176\212\212\032\032\032\032\032\075\075\068\ | |
1666 | \068\068\068\068\068\068\104\104\104\104\140\140\140\140\140\176\ | |
1667 | \176\176\176\176\212\212\032\032\032\032\032\075\075\074\068\068\ | |
1668 | \068\068\068\068\104\104\104\104\104\140\140\140\140\140\176\176\ | |
1669 | \176\176\219\212\038\032\032\032\032\032\074\074\074\074\074\068\ | |
1670 | \068\110\110\110\104\104\146\146\146\140\140\140\182\182\182\176\ | |
1671 | \219\218\038\038\038\038\038\081\074\074\074\074\074\074\074\110\ | |
1672 | \110\110\110\110\146\146\146\146\146\182\182\182\182\182\218\218\ | |
1673 | \038\038\038\038\038\081\081\074\074\074\074\074\074\110\110\110\ | |
1674 | \110\110\146\146\146\146\146\182\182\182\182\182\218\218\038\038\ | |
1675 | \038\038\038\081\081\074\074\074\074\074\074\110\110\110\110\110\ | |
1676 | \110\146\146\146\146\182\182\182\182\182\218\218\038\038\038\038\ | |
1677 | \038\081\081\074\074\074\074\074\074\074\110\110\110\110\110\146\ | |
1678 | \146\146\146\146\182\182\182\182\225\218\044\038\038\038\038\087\ | |
1679 | \080\080\080\080\080\074\074\074\116\116\116\110\110\152\152\152\ | |
1680 | \146\253\253\253\253\182\225\224\044\044\044\044\044\087\080\080\ | |
1681 | \080\080\080\080\080\116\116\116\116\116\152\152\152\152\152\253\ | |
1682 | \253\253\253\254\224\224\044\044\044\044\044\087\080\080\080\080\ | |
1683 | \080\080\080\116\116\116\116\116\152\152\152\152\152\253\253\253\ | |
1684 | \253\254\224\224\044\044\044\044\044\087\080\080\080\080\080\080\ | |
1685 | \080\116\116\116\116\116\152\152\152\152\152\253\253\253\253\254\ | |
1686 | \255\224\044\044\044\044\044\087\087\087\087\080\080\080\080\080\ | |
1687 | \116\116\116\116\116\152\152\152\152\152\254\254\254\254\255\224\ | |
1688 | \050\050\050\050\050\087\087\087\087\086\086\086\086\123\122\122\ | |
1689 | \122\159\158\158\158\158\195\194\194\194\255\255\255\230\050\050\ | |
1690 | \050\050\050\050\086\086\086\086\086\086\086\122\122\122\122\122\ | |
1691 | \158\158\158\158\158\194\194\194\194\194\230\230\020\020\020\020\ | |
1692 | \020\057\057\057\057\056\056\056\056\056\092\092\092\092\092\128\ | |
1693 | \128\128\128\128\164\164\164\164\201\200\020\020\020\020\020\020\ | |
1694 | \057\057\057\056\056\056\056\056\092\092\092\092\092\128\128\128\ | |
1695 | \128\128\164\164\164\164\201\200\020\020\020\020\020\020\020\057\ | |
1696 | \057\057\056\056\056\056\056\092\092\092\092\092\128\128\128\128\ | |
1697 | \128\164\164\164\201\200\020\020\020\020\020\020\020\057\057\057\ | |
1698 | \057\056\056\056\056\092\092\092\092\092\128\128\128\128\128\164\ | |
1699 | \164\164\201\200\020\020\020\020\020\020\020\020\099\057\057\057\ | |
1700 | \056\056\056\056\056\092\092\092\128\128\128\128\128\164\164\164\ | |
1701 | \201\200\027\020\020\020\020\063\063\063\099\099\099\099\099\135\ | |
1702 | \135\135\135\135\135\171\171\171\171\171\207\207\207\207\207\200\ | |
1703 | \027\027\020\020\020\063\063\063\063\099\099\099\099\099\135\135\ | |
1704 | \135\135\135\171\171\171\171\171\207\207\207\207\207\206\027\027\ | |
1705 | \027\027\020\063\063\063\063\099\099\099\099\099\098\135\135\135\ | |
1706 | \135\134\171\171\171\171\207\207\207\207\207\206\027\027\027\027\ | |
1707 | \069\069\063\063\063\063\062\099\099\099\098\098\098\135\135\134\ | |
1708 | \134\134\171\171\171\207\207\207\207\206\026\026\027\027\027\069\ | |
1709 | \069\069\063\062\062\062\062\098\098\098\098\098\135\134\134\134\ | |
1710 | \134\134\170\170\170\170\207\206\026\026\026\027\027\069\069\069\ | |
1711 | \062\062\062\062\062\098\098\098\098\098\098\134\134\134\134\134\ | |
1712 | \170\170\170\170\207\206\026\026\026\026\027\069\069\069\069\062\ | |
1713 | \062\062\062\062\098\098\098\098\098\134\134\134\134\134\170\170\ | |
1714 | \170\170\207\206\026\026\026\026\026\069\069\069\069\062\062\062\ | |
1715 | \062\062\062\098\098\098\098\098\134\134\134\134\134\170\170\170\ | |
1716 | \170\206\026\026\026\026\026\075\069\069\069\068\068\062\062\062\ | |
1717 | \062\062\098\098\098\098\134\134\134\134\134\170\170\170\213\206\ | |
1718 | \032\032\026\026\026\075\075\068\068\068\068\068\062\062\104\104\ | |
1719 | \104\104\141\140\140\140\140\177\176\176\176\176\213\212\032\032\ | |
1720 | \032\032\026\075\075\075\068\068\068\068\068\062\104\104\104\104\ | |
1721 | \104\140\140\140\140\140\176\176\176\176\213\212\032\032\032\032\ | |
1722 | \026\075\075\075\068\068\068\068\068\068\104\104\104\104\104\140\ | |
1723 | \140\140\140\140\176\176\176\176\213\212\032\032\032\032\032\075\ | |
1724 | \075\075\075\068\068\068\068\068\104\104\104\104\104\140\140\140\ | |
1725 | \140\140\176\176\176\176\176\212\032\032\032\032\032\075\075\075\ | |
1726 | \075\075\068\068\068\068\111\104\104\104\104\104\104\140\140\140\ | |
1727 | \140\176\176\176\219\212\038\038\032\032\032\081\081\074\074\074\ | |
1728 | \074\074\068\068\110\110\110\104\104\146\146\146\146\183\182\182\ | |
1729 | \182\182\219\218\038\038\038\038\038\081\081\081\074\074\074\074\ | |
1730 | \074\074\110\110\110\110\104\146\146\146\146\146\182\182\182\182\ | |
1731 | \219\218\038\038\038\038\038\081\081\081\074\074\074\074\074\074\ | |
1732 | \110\110\110\110\110\146\146\146\146\146\182\182\182\182\219\218\ | |
1733 | \038\038\038\038\038\081\081\081\081\074\074\074\074\074\110\110\ | |
1734 | \110\110\110\146\146\146\146\146\182\182\182\182\225\218\038\038\ | |
1735 | \038\038\038\081\081\081\081\074\074\074\074\074\117\110\110\110\ | |
1736 | \110\153\146\146\146\146\146\182\182\182\225\218\044\044\038\038\ | |
1737 | \038\087\087\087\081\080\080\080\074\074\116\116\116\116\110\152\ | |
1738 | \152\152\146\146\254\254\254\254\225\224\044\044\044\044\044\087\ | |
1739 | \087\087\087\080\080\080\080\080\116\116\116\116\116\152\152\152\ | |
1740 | \152\152\254\254\254\254\255\224\044\044\044\044\044\087\087\087\ | |
1741 | \087\080\080\080\080\080\116\116\116\116\116\152\152\152\152\152\ | |
1742 | \254\254\254\254\255\224\044\044\044\044\044\087\087\087\087\080\ | |
1743 | \080\080\080\080\116\116\116\116\116\152\152\152\152\152\254\254\ | |
1744 | \254\254\255\224\051\051\051\051\051\087\087\087\087\087\087\087\ | |
1745 | \080\123\123\123\123\116\159\159\159\159\195\195\195\255\255\255\ | |
1746 | \255\224\050\050\050\050\050\050\086\086\086\086\086\086\086\086\ | |
1747 | \122\122\122\122\122\158\158\158\158\158\194\194\194\194\194\230\ | |
1748 | \021\021\021\021\021\057\057\057\057\057\057\057\056\093\093\093\ | |
1749 | \093\092\129\129\129\129\165\165\165\165\165\201\201\201\021\021\ | |
1750 | \021\021\021\021\057\057\057\057\057\057\056\093\093\093\093\092\ | |
1751 | \129\129\129\129\165\165\165\165\165\201\201\201\021\021\021\021\ | |
1752 | \021\021\021\057\057\057\057\057\057\056\093\093\093\093\129\129\ | |
1753 | \129\129\165\165\165\165\165\201\201\201\021\021\021\021\021\021\ | |
1754 | \021\057\057\057\057\057\057\057\093\093\093\093\092\129\129\129\ | |
1755 | \129\165\165\165\165\201\201\201\021\021\021\021\021\021\021\021\ | |
1756 | \099\057\057\057\057\057\056\093\093\093\092\129\129\129\129\165\ | |
1757 | \165\165\165\201\201\201\027\021\021\021\021\063\063\063\099\099\ | |
1758 | \099\099\099\099\135\135\135\135\135\171\171\171\171\171\171\207\ | |
1759 | \207\207\207\207\027\027\021\021\021\063\063\063\063\099\099\099\ | |
1760 | \099\099\135\135\135\135\135\135\171\171\171\171\171\171\207\207\ | |
1761 | \207\207\027\027\027\027\021\063\063\063\063\063\099\099\099\099\ | |
1762 | \099\135\135\135\135\135\171\171\171\171\171\171\207\207\207\207\ | |
1763 | \027\027\027\027\069\069\063\063\063\063\063\099\099\099\099\099\ | |
1764 | \099\135\135\135\135\171\171\171\171\171\207\207\207\207\027\027\ | |
1765 | \027\027\027\069\069\063\063\063\063\063\099\099\099\099\099\135\ | |
1766 | \135\135\135\135\171\171\171\171\171\207\207\207\027\027\027\027\ | |
1767 | \027\069\069\069\063\063\063\063\063\099\099\099\099\098\135\135\ | |
1768 | \135\135\171\171\171\171\171\207\207\207\027\027\027\027\027\069\ | |
1769 | \069\069\063\063\063\063\063\099\099\099\099\098\135\135\135\135\ | |
1770 | \134\171\171\171\171\207\207\207\026\026\027\027\027\069\069\069\ | |
1771 | \069\069\063\063\062\062\099\099\099\098\098\135\135\135\134\134\ | |
1772 | \171\171\171\170\170\207\033\033\026\027\027\069\069\069\069\069\ | |
1773 | \069\069\062\105\105\105\105\141\141\141\141\141\177\177\177\177\ | |
1774 | \177\213\213\213\033\033\033\033\026\075\075\069\069\069\069\069\ | |
1775 | \069\105\105\105\105\141\141\141\141\141\177\177\177\177\177\213\ | |
1776 | \213\213\033\033\033\033\033\075\075\075\069\069\069\069\069\105\ | |
1777 | \105\105\105\105\141\141\141\141\177\177\177\177\177\213\213\213\ | |
1778 | \033\033\033\033\033\075\075\075\069\069\069\069\069\105\105\105\ | |
1779 | \105\105\141\141\141\141\140\177\177\177\177\213\213\213\032\032\ | |
1780 | \033\033\033\075\075\075\075\075\068\068\068\111\111\105\105\104\ | |
1781 | \104\147\141\183\140\140\183\177\219\176\176\213\039\039\039\032\ | |
1782 | \032\075\075\075\075\075\075\075\068\111\111\111\111\104\147\147\ | |
1783 | \147\183\183\183\183\183\219\219\219\219\039\039\039\039\039\081\ | |
1784 | \075\075\075\075\075\075\075\111\111\111\111\147\147\147\147\147\ | |
1785 | \183\183\183\183\183\219\219\219\039\039\039\039\039\081\081\081\ | |
1786 | \075\075\075\075\075\111\111\111\111\111\147\147\147\147\147\183\ | |
1787 | \183\183\183\219\219\219\039\039\039\039\039\081\081\081\081\075\ | |
1788 | \075\075\075\111\111\111\111\153\147\147\147\147\147\183\183\183\ | |
1789 | \183\219\219\219\045\045\045\039\039\081\081\081\081\081\081\074\ | |
1790 | \074\117\117\117\110\110\153\153\147\147\189\189\189\225\225\225\ | |
1791 | \225\218\045\045\045\045\045\081\081\081\081\081\081\081\074\117\ | |
1792 | \117\117\117\110\153\153\153\153\189\189\189\189\225\225\225\225\ | |
1793 | \045\045\045\045\045\081\081\081\081\081\081\081\081\117\117\117\ | |
1794 | \117\153\153\153\153\153\189\189\189\189\189\225\225\225\045\045\ | |
1795 | \045\045\045\087\081\081\081\081\081\081\081\117\117\117\117\117\ | |
1796 | \153\153\153\153\195\189\189\189\189\255\225\225\045\045\045\045\ | |
1797 | \045\087\087\087\087\081\081\081\081\117\117\117\117\159\159\153\ | |
1798 | \153\153\195\189\189\189\255\255\255\225\051\051\051\051\051\087\ | |
1799 | \087\087\087\087\087\087\080\123\123\123\123\116\159\159\159\159\ | |
1800 | \195\195\195\255\255\255\255\224\051\051\051\051\051\087\087\087\ | |
1801 | \087\087\087\087\080\123\123\123\123\116\159\159\159\159\195\195\ | |
1802 | \195\195\255\255\255\231\051\051\051\051\051\087\087\087\087\087\ | |
1803 | \087\087\087\123\123\123\123\123\159\159\159\159\158\195\195\195\ | |
1804 | \195\194\231\231\021\021\021\021\021\057\057\057\057\057\057\057\ | |
1805 | \057\093\093\093\093\093\129\129\129\129\129\165\165\165\165\165\ | |
1806 | \201\201\021\021\021\021\021\021\057\057\057\057\057\057\057\057\ | |
1807 | \093\093\093\093\093\129\129\129\129\165\165\165\165\165\201\201\ | |
1808 | \021\021\021\021\021\021\021\057\057\057\057\057\057\057\093\093\ | |
1809 | \093\093\093\129\129\129\129\129\165\165\165\165\201\201\021\021\ | |
1810 | \021\021\021\021\021\021\057\057\057\057\057\057\057\093\093\093\ | |
1811 | \093\129\129\129\129\129\165\165\165\165\201\201\021\021\021\021\ | |
1812 | \021\021\021\021\099\057\057\057\057\057\057\057\093\093\093\093\ | |
1813 | \129\129\129\129\165\165\165\165\201\201\027\021\021\021\021\063\ | |
1814 | \063\063\099\099\099\099\099\057\057\057\135\135\135\135\129\129\ | |
1815 | \129\171\171\171\165\165\207\207\027\027\021\021\021\063\063\063\ | |
1816 | \063\099\099\099\099\099\099\135\135\135\135\135\135\135\171\171\ | |
1817 | \171\171\171\171\207\207\027\027\027\021\021\063\063\063\063\063\ | |
1818 | \099\099\099\099\099\099\099\135\135\135\135\135\171\171\171\171\ | |
1819 | \171\171\207\207\027\027\027\027\069\069\063\063\063\063\063\063\ | |
1820 | \099\099\099\099\099\135\135\135\135\135\135\171\171\171\171\171\ | |
1821 | \207\207\027\027\027\027\027\069\069\063\063\063\063\063\063\099\ | |
1822 | \099\099\099\099\135\135\135\135\135\171\171\171\171\171\207\207\ | |
1823 | \027\027\027\027\027\069\069\069\063\063\063\063\063\099\099\099\ | |
1824 | \099\099\135\135\135\135\135\171\171\171\171\171\207\207\027\027\ | |
1825 | \027\027\027\069\069\069\063\063\063\063\063\099\099\099\099\099\ | |
1826 | \135\135\135\135\135\171\171\171\171\171\207\207\027\027\027\027\ | |
1827 | \027\069\069\069\069\063\063\063\063\063\099\099\099\099\099\135\ | |
1828 | \135\135\135\135\171\171\171\171\207\207\033\027\027\027\027\027\ | |
1829 | \069\069\069\069\069\069\063\105\105\105\105\141\141\141\141\141\ | |
1830 | \135\177\177\177\177\171\213\213\033\033\033\027\027\027\069\069\ | |
1831 | \069\069\069\069\069\105\105\105\105\105\141\141\141\141\141\177\ | |
1832 | \177\177\177\177\213\213\033\033\033\033\027\027\075\069\069\069\ | |
1833 | \069\069\069\105\105\105\105\105\141\141\141\141\141\177\177\177\ | |
1834 | \177\177\213\213\033\033\033\033\033\075\075\069\069\069\069\069\ | |
1835 | \069\105\105\105\105\105\141\141\141\141\141\177\177\177\177\177\ | |
1836 | \213\213\033\033\033\033\033\075\075\075\075\069\069\069\069\111\ | |
1837 | \105\105\105\105\105\141\141\141\141\141\177\177\177\177\213\213\ | |
1838 | \039\033\033\033\033\075\075\075\075\075\075\075\069\111\111\111\ | |
1839 | \111\105\147\147\147\147\141\183\183\183\183\177\219\219\039\039\ | |
1840 | \039\039\033\075\075\075\075\075\075\075\075\111\111\111\111\111\ | |
1841 | \147\147\147\147\147\183\183\183\183\183\219\219\039\039\039\039\ | |
1842 | \039\039\075\075\075\075\075\075\075\111\111\111\111\111\147\147\ | |
1843 | \147\147\147\183\183\183\183\183\219\219\039\039\039\039\039\039\ | |
1844 | \075\075\075\075\075\075\075\111\111\111\111\111\147\147\147\147\ | |
1845 | \147\183\183\183\183\183\219\219\039\039\039\039\039\039\081\081\ | |
1846 | \075\075\075\075\075\075\111\111\111\111\111\147\147\147\147\147\ | |
1847 | \183\183\183\183\183\219\045\045\039\039\039\081\081\081\081\081\ | |
1848 | \081\081\075\117\117\117\117\111\153\153\153\153\147\189\189\189\ | |
1849 | \189\183\225\225\045\045\045\045\045\081\081\081\081\081\081\081\ | |
1850 | \081\117\117\117\117\117\153\153\153\153\153\189\189\189\189\189\ | |
1851 | \225\225\045\045\045\045\045\081\081\081\081\081\081\081\081\117\ | |
1852 | \117\117\117\117\153\153\153\153\153\189\189\189\189\189\225\225\ | |
1853 | \045\045\045\045\045\045\081\081\081\081\081\081\081\117\117\117\ | |
1854 | \117\117\153\153\153\153\153\189\189\189\189\189\225\225\045\045\ | |
1855 | \045\045\045\045\081\081\081\081\081\081\081\081\117\117\117\117\ | |
1856 | \117\153\153\153\153\153\189\189\189\189\189\225\051\051\051\051\ | |
1857 | \051\087\087\087\087\087\087\087\087\123\123\123\123\123\159\159\ | |
1858 | \159\159\153\195\195\195\195\189\231\231\051\051\051\051\051\087\ | |
1859 | \087\087\087\087\087\087\087\123\123\123\123\123\159\159\159\159\ | |
1860 | \159\195\195\195\195\195\231\231" | |
1861 | ||
1862 | type map = { | |
1863 | count_r : int; | |
1864 | count_g : int; | |
1865 | count_b : int; | |
1866 | index_r : string; | |
1867 | index_g : string; | |
1868 | index_b : string; | |
1869 | map : string; | |
1870 | } | |
1871 | ||
1872 | let colors_16 = { | |
1873 | count_r = 6; | |
1874 | count_g = 6; | |
1875 | count_b = 6; | |
1876 | index_r = data0; | |
1877 | index_g = data0; | |
1878 | index_b = data1; | |
1879 | map = data2; | |
1880 | } | |
1881 | ||
1882 | let colors_88 = { | |
1883 | count_r = 11; | |
1884 | count_g = 11; | |
1885 | count_b = 11; | |
1886 | index_r = data3; | |
1887 | index_g = data3; | |
1888 | index_b = data3; | |
1889 | map = data4; | |
1890 | } | |
1891 | ||
1892 | let colors_256 = { | |
1893 | count_r = 30; | |
1894 | count_g = 30; | |
1895 | count_b = 30; | |
1896 | index_r = data5; | |
1897 | index_g = data5; | |
1898 | index_b = data5; | |
1899 | map = data6; | |
1900 | } |
106 | 106 | bind [{ control = true; meta = false; shift = false; code = Char(UChar.of_char 'a') }] [Zed Goto_bol]; |
107 | 107 | bind [{ control = true; meta = false; shift = false; code = Char(UChar.of_char 'e') }] [Zed Goto_eol]; |
108 | 108 | bind [{ control = true; meta = false; shift = false; code = Char(UChar.of_char 'd') }] [Zed Delete_next_char]; |
109 | bind [{ control = true; meta = false; shift = false; code = Char(UChar.of_char 'h') }] [Zed Delete_prev_char]; | |
109 | 110 | bind [{ control = true; meta = false; shift = false; code = Char(UChar.of_char 'k') }] [Zed Kill_next_line]; |
110 | 111 | bind [{ control = true; meta = false; shift = false; code = Char(UChar.of_char 'u') }] [Zed Kill_prev_line]; |
111 | bind [{ control = true; meta = false; shift = false; code = Char(UChar.of_char 'n') }] [Zed Prev_char]; | |
112 | bind [{ control = true; meta = false; shift = false; code = Char(UChar.of_char 'p') }] [Zed Next_char]; | |
112 | bind [{ control = true; meta = false; shift = false; code = Char(UChar.of_char 'n') }] [Zed Next_char]; | |
113 | bind [{ control = true; meta = false; shift = false; code = Char(UChar.of_char 'p') }] [Zed Prev_char]; | |
113 | 114 | bind [{ control = true; meta = false; shift = false; code = Char(UChar.of_char 'w') }] [Zed Kill]; |
114 | 115 | bind [{ control = true; meta = false; shift = false; code = Char(UChar.of_char 'y') }] [Zed Yank]; |
115 | 116 | bind [{ control = false; meta = false; shift = false; code = Backspace }] [Zed Delete_prev_char]; |
0 | (* | |
1 | * lTerm_history.ml | |
2 | * ---------------- | |
3 | * Copyright : (c) 2012, Jeremie Dimino <jeremie@dimino.org> | |
4 | * Licence : BSD3 | |
5 | * | |
6 | * This file is a part of Lambda-Term. | |
7 | *) | |
8 | ||
9 | open CamomileLibraryDyn.Camomile | |
10 | open Lwt | |
11 | ||
12 | let section = Lwt_log.Section.make "lambda-term(history)" | |
13 | ||
14 | (* A node contains an entry of the history. *) | |
15 | type node = { | |
16 | mutable data : Zed_utf8.t; | |
17 | mutable size : int; | |
18 | mutable prev : node; | |
19 | } | |
20 | ||
21 | type t = { | |
22 | mutable entries : node; | |
23 | (* Points to the first entry (the most recent). Its [prev] is a fake | |
24 | node used as marker, is after the oldest entry. *) | |
25 | mutable full_size : int; | |
26 | mutable length : int; | |
27 | mutable max_size : int; | |
28 | mutable max_entries : int; | |
29 | mutable old_count : int; | |
30 | mutable cache : Zed_utf8.t list option; | |
31 | (* When set, the cache is equal to the list of entries, from the | |
32 | most recent to the oldest. *) | |
33 | } | |
34 | ||
35 | let entry_size str = | |
36 | let size = ref 0 in | |
37 | for i = 0 to String.length str - 1 do | |
38 | match String.unsafe_get str i with | |
39 | | '\n' | '\\' -> | |
40 | size := !size + 2 | |
41 | | _ -> | |
42 | size := !size + 1 | |
43 | done; | |
44 | !size + 1 | |
45 | ||
46 | (* Check that [size1 + size2 < limit], handling overflow. *) | |
47 | let size_ok size1 size2 limit = | |
48 | let sum = size1 + size2 in | |
49 | sum >= 0 && sum <= limit | |
50 | ||
51 | let create ?(max_size=max_int) ?(max_entries=max_int) init = | |
52 | if max_size < 0 then | |
53 | invalid_arg "LTerm_history.create: negative maximum size"; | |
54 | if max_entries < 0 then | |
55 | invalid_arg "LTerm_history.create: negative maximum number of entries"; | |
56 | let rec aux size count node entries = | |
57 | match entries with | |
58 | | [] -> | |
59 | (size, count, node) | |
60 | | entry :: entries -> | |
61 | let entry_size = entry_size entry in | |
62 | if size_ok size entry_size max_size && count + 1 < max_entries then begin | |
63 | let next = { data = ""; prev = node; size = 0 } in | |
64 | node.data <- entry; | |
65 | node.size <- entry_size; | |
66 | aux (size + entry_size) (count + 1) next entries | |
67 | end else | |
68 | (size, count, node) | |
69 | in | |
70 | let rec node = { data = ""; size = 0; prev = node } in | |
71 | let size, count, marker = aux 0 0 node init in | |
72 | node.prev <- marker; | |
73 | { | |
74 | entries = node; | |
75 | full_size = size; | |
76 | length = count; | |
77 | max_size = max_size; | |
78 | max_entries = max_entries; | |
79 | old_count = count; | |
80 | cache = None; | |
81 | } | |
82 | ||
83 | let spaces = UCharInfo.load_property_tbl `White_Space | |
84 | ||
85 | let is_space ch = UCharTbl.Bool.get spaces ch | |
86 | let is_empty str = Zed_utf8.for_all is_space str | |
87 | ||
88 | let is_dup history entry = | |
89 | history.length > 0 && history.entries.data = entry | |
90 | ||
91 | (* Remove the oldest entry of history, precondition: the history | |
92 | contains at least one entry. *) | |
93 | let drop_oldest history = | |
94 | let last = history.entries.prev.prev in | |
95 | (* Make [last] become the end of entries marker. *) | |
96 | history.entries.prev <- last; | |
97 | (* Update counters. *) | |
98 | history.length <- history.length - 1; | |
99 | history.full_size <- history.full_size - last.size; | |
100 | if history.old_count > 0 then history.old_count <- history.old_count - 1; | |
101 | (* Clear the marker so its contents can be garbage collected. *) | |
102 | last.data <- ""; | |
103 | last.size <- 0 | |
104 | ||
105 | let add_aux history data size = | |
106 | if size <= history.max_size then begin | |
107 | (* Check length. *) | |
108 | if history.length = history.max_entries then begin | |
109 | history.cache <- None; | |
110 | (* We know that [max_entries > 0], so the precondition is | |
111 | verified. *) | |
112 | drop_oldest history | |
113 | end; | |
114 | (* Check size. *) | |
115 | if not (size_ok history.full_size size history.max_size) then begin | |
116 | history.cache <- None; | |
117 | (* We know that size <= max_size, so we are here only if there | |
118 | is at least one other entry in the history, so the | |
119 | precondition is verified. *) | |
120 | drop_oldest history; | |
121 | while not (size_ok history.full_size size history.max_size) do | |
122 | (* Same here. *) | |
123 | drop_oldest history | |
124 | done | |
125 | end; | |
126 | (* Add the entry. *) | |
127 | let node = { data = data; size = size; prev = history.entries.prev } in | |
128 | history.entries.prev <- node; | |
129 | history.entries <- node; | |
130 | history.length <- history.length + 1; | |
131 | history.full_size <- history.full_size + size; | |
132 | match history.cache with | |
133 | | None -> | |
134 | () | |
135 | | Some l -> | |
136 | history.cache <- Some (data :: l) | |
137 | end | |
138 | ||
139 | let add history ?(skip_empty=true) ?(skip_dup=true) entry = | |
140 | if history.max_entries > 0 && history.max_size > 0 && not (skip_empty && is_empty entry) && not (skip_dup && is_dup history entry) then | |
141 | add_aux history entry (entry_size entry) | |
142 | ||
143 | let rec list_of_nodes marker acc node = | |
144 | if node == marker then | |
145 | acc | |
146 | else | |
147 | list_of_nodes marker (node.data :: acc) node.prev | |
148 | ||
149 | let contents history = | |
150 | match history.cache with | |
151 | | Some l -> | |
152 | l | |
153 | | None -> | |
154 | let marker = history.entries.prev in | |
155 | let l = list_of_nodes marker [] marker.prev in | |
156 | history.cache <- Some l; | |
157 | l | |
158 | ||
159 | let size history = history.full_size | |
160 | let length history = history.length | |
161 | let old_count history = history.old_count | |
162 | let max_size history = history.max_size | |
163 | let max_entries history = history.max_entries | |
164 | ||
165 | let set_old_count history n = | |
166 | if n < 0 then | |
167 | invalid_arg "LTerm_history.set_old_count: negative old count"; | |
168 | if n > history.length then | |
169 | invalid_arg "LTerm_history.set_old_count: old count greater than the length of the history"; | |
170 | history.old_count <- n | |
171 | ||
172 | let set_max_size history size = | |
173 | if size < 0 then | |
174 | invalid_arg "LTerm_history.set_max_size: negative maximum size"; | |
175 | if size < history.full_size then begin | |
176 | history.cache <- None; | |
177 | (* 0 <= size < full_size so there is at least one element. *) | |
178 | drop_oldest history; | |
179 | while size < history.full_size do | |
180 | (* Same here. *) | |
181 | drop_oldest history | |
182 | done | |
183 | end; | |
184 | history.max_size <- size | |
185 | ||
186 | let set_max_entries history n = | |
187 | if n < 0 then | |
188 | invalid_arg "LTerm_history.set_max_entries: negative maximum number of entries"; | |
189 | if n < history.length then begin | |
190 | history.cache <- None; | |
191 | (* 0 <= n < length so there is at least one element. *) | |
192 | drop_oldest history; | |
193 | while n < history.length do | |
194 | (* Same here. *) | |
195 | drop_oldest history | |
196 | done | |
197 | end; | |
198 | history.max_entries <- n | |
199 | ||
200 | let escape entry = | |
201 | let len = String.length entry in | |
202 | let buf = Buffer.create len in | |
203 | let rec loop ofs = | |
204 | if ofs = len then | |
205 | Buffer.contents buf | |
206 | else | |
207 | match String.unsafe_get entry ofs with | |
208 | | '\n' -> | |
209 | Buffer.add_string buf "\\n"; | |
210 | loop (ofs + 1) | |
211 | | '\\' -> | |
212 | Buffer.add_string buf "\\\\"; | |
213 | loop (ofs + 1) | |
214 | | ch when Char.code ch <= 127 -> | |
215 | Buffer.add_char buf ch; | |
216 | loop (ofs + 1) | |
217 | | _ -> | |
218 | let ofs' = Zed_utf8.unsafe_next entry ofs in | |
219 | Buffer.add_substring buf entry ofs (ofs' - ofs); | |
220 | loop ofs' | |
221 | in | |
222 | loop 0 | |
223 | ||
224 | let unescape line = | |
225 | let len = String.length line in | |
226 | let buf = Buffer.create len in | |
227 | let rec loop ofs size = | |
228 | if ofs = len then | |
229 | (Buffer.contents buf, size + 1) | |
230 | else | |
231 | match String.unsafe_get line ofs with | |
232 | | '\\' -> | |
233 | if ofs = len then begin | |
234 | Buffer.add_char buf '\\'; | |
235 | (Buffer.contents buf, size + 3) | |
236 | end else begin | |
237 | match String.unsafe_get line (ofs + 1) with | |
238 | | 'n' -> | |
239 | Buffer.add_char buf '\n'; | |
240 | loop (ofs + 2) (size + 2) | |
241 | | '\\' -> | |
242 | Buffer.add_char buf '\\'; | |
243 | loop (ofs + 2) (size + 2) | |
244 | | _ -> | |
245 | Buffer.add_char buf '\\'; | |
246 | loop (ofs + 1) (size + 2) | |
247 | end | |
248 | | ch when Char.code ch <= 127 -> | |
249 | Buffer.add_char buf ch; | |
250 | loop (ofs + 1) (size + 1) | |
251 | | _ -> | |
252 | let ofs' = Zed_utf8.unsafe_next line ofs in | |
253 | Buffer.add_substring buf line ofs (ofs' - ofs); | |
254 | loop ofs' (size + ofs' - ofs) | |
255 | in | |
256 | loop 0 0 | |
257 | ||
258 | let section = Lwt_log.Section.make "lambda-term(history)" | |
259 | ||
260 | let rec safe_lockf fn fd cmd ofs = | |
261 | try_lwt | |
262 | lwt () = Lwt_unix.lockf fd cmd ofs in | |
263 | return true | |
264 | with | |
265 | | Unix.Unix_error (Unix.EINTR, _, _) -> | |
266 | safe_lockf fn fd cmd ofs | |
267 | | Unix.Unix_error (error, _, _) -> | |
268 | Lwt_log.ign_warning_f ~section "failed to lock file '%s': %s" fn (Unix.error_message error); | |
269 | return false | |
270 | ||
271 | let open_history fn = | |
272 | try_lwt | |
273 | lwt fd = Lwt_unix.openfile fn [Unix.O_RDWR] 0 in | |
274 | lwt locked = safe_lockf fn fd Lwt_unix.F_LOCK 0 in | |
275 | return (Some (fd, locked)) | |
276 | with | |
277 | | Unix.Unix_error (Unix.ENOENT, _, _) -> | |
278 | return None | |
279 | | Unix.Unix_error (Unix.EACCES, _, _) -> | |
280 | Lwt_log.ign_info_f "cannot open file '%s' in read and write mode: %s" fn (Unix.error_message Unix.EACCES); | |
281 | (* If the file cannot be openned in read & write mode, | |
282 | open it in read only mode but do not lock it. *) | |
283 | try_lwt | |
284 | lwt fd = Lwt_unix.openfile fn [Unix.O_RDONLY] 0 in | |
285 | return (Some (fd, false)) | |
286 | with Unix.Unix_error (Unix.ENOENT, _, _) -> | |
287 | return None | |
288 | ||
289 | let load history ?log ?(skip_empty=true) ?(skip_dup=true) fn = | |
290 | (* In case we do not load anything. *) | |
291 | history.old_count <- history.length; | |
292 | if history.max_entries = 0 || history.max_size = 0 then | |
293 | (* Do not bother loading the file for nothing... *) | |
294 | return () | |
295 | else begin | |
296 | let log = | |
297 | match log with | |
298 | | Some func -> | |
299 | func | |
300 | | None -> | |
301 | fun line msg -> | |
302 | Lwt_log.ign_error_f ~section "File %S, at line %d: %s" fn line msg | |
303 | in | |
304 | (* File opening. *) | |
305 | match_lwt open_history fn with | |
306 | | None -> | |
307 | return () | |
308 | | Some (fd, locked) -> | |
309 | (* File loading. *) | |
310 | let ic = Lwt_io.of_fd ~mode:Lwt_io.input fd in | |
311 | try_lwt | |
312 | let rec aux num = | |
313 | match_lwt Lwt_io.read_line_opt ic with | |
314 | | None -> | |
315 | return () | |
316 | | Some line -> | |
317 | (try | |
318 | let entry, size = unescape line in | |
319 | if not (skip_empty && is_empty entry) && not (skip_dup && is_dup history entry) then begin | |
320 | add_aux history entry size; | |
321 | history.old_count <- history.length | |
322 | end | |
323 | with Zed_utf8.Invalid (msg, _) -> | |
324 | log num msg); | |
325 | aux (num + 1) | |
326 | in | |
327 | aux 1 | |
328 | finally | |
329 | (* Cleanup. *) | |
330 | lwt _ = if locked then safe_lockf fn fd Lwt_unix.F_ULOCK 0 else return true in | |
331 | Lwt_unix.close fd | |
332 | end | |
333 | ||
334 | let rec skip_nodes node count = | |
335 | if count = 0 then | |
336 | node | |
337 | else | |
338 | skip_nodes node.prev (count - 1) | |
339 | ||
340 | let rec copy history marker node skip_empty skip_dup = | |
341 | if node != marker then begin | |
342 | let line = escape node.data in | |
343 | if not (skip_empty && is_empty line) && not (skip_dup && is_dup history line) then | |
344 | add_aux history line node.size; | |
345 | copy history marker node.prev skip_empty skip_dup | |
346 | end | |
347 | ||
348 | let rec dump_entries oc marker node = | |
349 | if node == marker then | |
350 | return () | |
351 | else begin | |
352 | lwt () = Lwt_io.write_line oc node.data in | |
353 | dump_entries oc marker node.prev | |
354 | end | |
355 | ||
356 | let save history ?max_size ?max_entries ?(skip_empty=true) ?(skip_dup=true) ?(append=true) ?(perm=0o666) fn = | |
357 | let max_size = | |
358 | match max_size with | |
359 | | Some m -> m | |
360 | | None -> history.max_size | |
361 | and max_entries = | |
362 | match max_entries with | |
363 | | Some m -> m | |
364 | | None -> history.max_entries | |
365 | in | |
366 | let history_save = create ~max_size ~max_entries [] in | |
367 | if history_save.max_size = 0 || history_save.max_entries = 0 || (not append && history.old_count = history.length) then | |
368 | (* Just empty the history. *) | |
369 | Lwt_unix.openfile fn [Unix.O_CREAT; Unix.O_TRUNC] perm >>= Lwt_unix.close | |
370 | else if append && history.old_count = history.length then | |
371 | (* Do not touch the file. *) | |
372 | return () | |
373 | else begin | |
374 | lwt fd = Lwt_unix.openfile fn [Unix.O_CREAT; Unix.O_RDWR] perm in | |
375 | (* Lock the entire file. *) | |
376 | lwt locked = safe_lockf fn fd Unix.F_LOCK 0 in | |
377 | try_lwt | |
378 | lwt count = | |
379 | if append then begin | |
380 | (* Load existing entries into [history_save]. | |
381 | ||
382 | We return the number of entries read. This may be greater | |
383 | than the number of entries stored in [history_save]: | |
384 | - because of limits | |
385 | - because the history files contains duplicated lines | |
386 | and/or empty lines and [skip_dup] and/or [skip_empty] | |
387 | have been specified. *) | |
388 | let ic = Lwt_io.of_fd ~mode:Lwt_io.input ~close:return fd in | |
389 | let rec aux count = | |
390 | match_lwt Lwt_io.read_line_opt ic with | |
391 | | None -> | |
392 | history_save.old_count <- history_save.length; | |
393 | lwt () = Lwt_io.close ic in | |
394 | return count | |
395 | | Some line -> | |
396 | (* Do not bother unescaping. Tests remain the same | |
397 | on the unescaped version. *) | |
398 | if not (skip_empty && is_empty line) && not (skip_dup && is_dup history_save line) then | |
399 | add_aux history_save line (String.length line + 1); | |
400 | aux (count + 1) | |
401 | in | |
402 | aux 0 | |
403 | end else | |
404 | return 0 | |
405 | in | |
406 | let marker = history.entries.prev in | |
407 | (* Copy new entries into the saving history. *) | |
408 | copy history_save marker (skip_nodes marker.prev history.old_count) skip_empty skip_dup; | |
409 | lwt to_skip = | |
410 | if append && history_save.old_count = count then | |
411 | (* We are in append mode and no old entries were removed: do | |
412 | not modify the file and append new entries at the end of | |
413 | the file. *) | |
414 | return count | |
415 | else | |
416 | (* Otherwise truncate the file and save everything. *) | |
417 | lwt _ = Lwt_unix.lseek fd 0 Unix.SEEK_SET in | |
418 | lwt () = Lwt_unix.ftruncate fd 0 in | |
419 | return 0 | |
420 | in | |
421 | (* Save entries to the temporary file. *) | |
422 | let oc = Lwt_io.of_fd ~mode:Lwt_io.output ~close:return fd in | |
423 | let marker = history_save.entries.prev in | |
424 | lwt () = dump_entries oc marker (skip_nodes marker.prev to_skip) in | |
425 | lwt () = Lwt_io.close oc in | |
426 | (* Done! *) | |
427 | history.old_count <- history.length; | |
428 | return () | |
429 | finally | |
430 | lwt _ = if locked then safe_lockf fn fd Lwt_unix.F_ULOCK 0 else return true in | |
431 | Lwt_unix.close fd | |
432 | end |
0 | (* | |
1 | * lTerm_history.mli | |
2 | * ----------------- | |
3 | * Copyright : (c) 2012, Jeremie Dimino <jeremie@dimino.org> | |
4 | * Licence : BSD3 | |
5 | * | |
6 | * This file is a part of Lambda-Term. | |
7 | *) | |
8 | ||
9 | (** History management *) | |
10 | ||
11 | type t | |
12 | (** Type of a history. *) | |
13 | ||
14 | val create : ?max_size : int -> ?max_entries : int -> Zed_utf8.t list -> t | |
15 | (** [create ?max_size ?max_lines init] creates a new history. | |
16 | ||
17 | [max_size] is the maximum size in bytes of the history. Oldest | |
18 | entries are dropped if this limit is reached. The default is | |
19 | [max_int]. | |
20 | ||
21 | [max_entries] is the maximum number of entries of the | |
22 | history. Oldest entries are dropped if this limit is | |
23 | reached. The default is no [max_int]. | |
24 | ||
25 | [init] is the initial contents of the history. All entries of | |
26 | [init] are considered "old". Old entries are not saved by | |
27 | {!save} when [append] is set to [true]. | |
28 | ||
29 | Note: the first element of [init] must be the most recent | |
30 | entry. *) | |
31 | ||
32 | val add : t -> ?skip_empty : bool -> ?skip_dup : bool -> Zed_utf8.t -> unit | |
33 | (** [add history ?skip_empty ?skip_dup entry] adds [entry] to the | |
34 | top of the history. If [skip_empty] is [true] (the default) and | |
35 | [entry] contains only spaces, it is not added. If [skip_dup] is | |
36 | [true] (the default) and [entry] is equal to the top of the | |
37 | history, it is not added. | |
38 | ||
39 | If [entry] is bigger than the maximum size of the history, the | |
40 | history is not modified. *) | |
41 | ||
42 | val contents : t -> Zed_utf8.t list | |
43 | (** Returns all the entries of the history. The first element of the | |
44 | list is the most recent entry. *) | |
45 | ||
46 | val size : t -> int | |
47 | (** Returns the size (in bytes) of the history. *) | |
48 | ||
49 | val length : t -> int | |
50 | (** Returns the number of entries in the history. *) | |
51 | ||
52 | val old_count : t -> int | |
53 | (** Returns the number of old entries in the history. *) | |
54 | ||
55 | val set_old_count : t -> int -> unit | |
56 | (** [set_old_count history count] sets the number of old entries in | |
57 | the history. *) | |
58 | ||
59 | val max_size : t -> int | |
60 | (** Returns the maximum size of the history. *) | |
61 | ||
62 | val set_max_size : t -> int -> unit | |
63 | (** Sets the maximum size of the history. It may drop oldest entries | |
64 | to honor the new limit. *) | |
65 | ||
66 | val max_entries : t -> int | |
67 | (** Returns the maximum number of entries of the history. *) | |
68 | ||
69 | val set_max_entries : t -> int -> unit | |
70 | (** Sets the maximum number of entries of the history. It may drop | |
71 | oldest entries to honor the new limit. *) | |
72 | ||
73 | val load : t -> | |
74 | ?log : (int -> string -> unit) -> | |
75 | ?skip_empty : bool -> | |
76 | ?skip_dup : bool -> | |
77 | string -> unit Lwt.t | |
78 | (** [load history ?log ?skip_empty ?skip_dup filename] loads entries | |
79 | from [filename] to [history]. If [filename] does not exists | |
80 | [history] is not modified. | |
81 | ||
82 | [log] is the function used to log errors contained in the | |
83 | history file (errors are because of non-UTF8 data). Arguments | |
84 | are a line number and an error message. The default is to use | |
85 | the default logger (of [Lwt_log]). Entries containing errors are | |
86 | skipped. | |
87 | ||
88 | Note: all entries are marked as old, i.e. [old_count history = | |
89 | length history]. *) | |
90 | ||
91 | val save : t -> | |
92 | ?max_size : int -> | |
93 | ?max_entries : int -> | |
94 | ?skip_empty : bool -> | |
95 | ?skip_dup : bool -> | |
96 | ?append : bool -> | |
97 | ?perm : int -> | |
98 | string -> unit Lwt.t | |
99 | (** [save history ?max_size ?max_entries ?skip_empty ?sjip_dup ?perm | |
100 | filename] saves [history] to [filename]. | |
101 | ||
102 | If [append] is [false] then the file is truncated and new | |
103 | entries are saved. If it is [true] (the default) then new | |
104 | entries are added at the end. [perm] are the file permissions in | |
105 | case it is created. | |
106 | ||
107 | If [append] is [true] and there is no new entries, the file is | |
108 | not touched. In any other case, limits are honored and the | |
109 | resulting file will never contains more bytes than [max_size] or | |
110 | more entries than [max_entries]. If [max_size] and/or | |
111 | [max_entries] are not specified, the ones of [history] are used. | |
112 | ||
113 | After the history is successfully saved, all entries of | |
114 | [history] are marked as old, i.e. [old_count history = length | |
115 | history]. *) | |
116 | ||
117 | val entry_size : Zed_utf8.t -> int | |
118 | (** [entry_size entry] returns the size taken by an entry in the | |
119 | history file in bytes. This is not exactly [String.length entry] | |
120 | since some characters are escaped and the entry is terminated by | |
121 | a newline character. *) |
0 | (* | |
1 | * lTerm_iconv.ml | |
2 | * -------------- | |
3 | * Copyright : (c) 2011, Jeremie Dimino <jeremie@dimino.org> | |
4 | * Licence : BSD3 | |
5 | * | |
6 | * This file is a part of Lambda-Term. | |
7 | *) | |
8 | ||
9 | type t | |
10 | ||
11 | exception Closed | |
12 | exception Unsupported of string * string | |
13 | exception Invalid_sequence | |
14 | exception Unterminated_sequence | |
15 | exception Insufficient_space | |
16 | ||
17 | let () = | |
18 | Printexc.register_printer | |
19 | (function | |
20 | | Closed -> | |
21 | Some("iconv: closed conversions descriptor") | |
22 | | Unsupported(enc_of, enc_to) -> | |
23 | Some(Printf.sprintf "iconv: conversion from %S to %S not supported" enc_of enc_to) | |
24 | | Invalid_sequence -> | |
25 | Some("iconv: invalid sequence found") | |
26 | | Unterminated_sequence -> | |
27 | Some("iconv: sequence not terminated found at the end of input") | |
28 | | Insufficient_space -> | |
29 | Some("iconv: insufficient space in output") | |
30 | | _ -> | |
31 | None) | |
32 | ||
33 | let () = | |
34 | Callback.register_exception "lambda-term:iconv:closed" Closed; | |
35 | Callback.register_exception "lambda-term:iconv:unsupported" (Unsupported("", "")); | |
36 | Callback.register_exception "lambda-term:iconv:invalid-sequence" Invalid_sequence; | |
37 | Callback.register_exception "lambda-term:iconv:unterminated-sequence" Unterminated_sequence; | |
38 | Callback.register_exception "lambda-term:iconv:insufficient-space" Insufficient_space | |
39 | ||
40 | type data = { | |
41 | mutable bytes : string; | |
42 | mutable index : int; | |
43 | mutable limit : int; | |
44 | } | |
45 | ||
46 | external iconv_open : to_code : string -> of_code : string -> t = "lt_iconv_iconv_open" | |
47 | external iconv_close : t -> unit = "lt_iconv_iconv_close" | |
48 | external iconv : t -> src : data -> dst : data -> unit = "lt_iconv_iconv" | |
49 | external reset : t -> unit = "lt_iconv_reset" | |
50 | ||
51 | let iconv cd ~src ~dst = | |
52 | if src.index < 0 || src.index > src.limit || src.limit > String.length src.bytes then invalid_arg "LTerm_iconv.iconv"; | |
53 | if dst.index < 0 || dst.index > dst.limit || dst.limit > String.length dst.bytes then invalid_arg "LTerm_iconv.iconv"; | |
54 | iconv cd ~src ~dst | |
55 | ||
56 | let equal enc1 enc2 = | |
57 | let rec loop i1 i2 = | |
58 | if i1 = String.length enc1 || String.unsafe_get enc1 i1 = '/' then | |
59 | i2 = String.length enc2 || String.unsafe_get enc2 i2 = '/' | |
60 | else if i2 = String.length enc2 || String.unsafe_get enc2 i2 = '/' then | |
61 | false | |
62 | else | |
63 | let ch1 = Char.lowercase (String.unsafe_get enc1 i1) | |
64 | and ch2 = Char.lowercase (String.unsafe_get enc2 i2) in | |
65 | match ch1, ch2 with | |
66 | | ('a' .. 'z' | '0' .. '9' | '_' | '-' | '.' | ':'), ('a' .. 'z' | '0' .. '9' | '_' | '-' | '.' | ':') -> | |
67 | ch1 = ch2 && loop (i1 + 1) (i2 + 1) | |
68 | | ('a' .. 'z' | '0' .. '9' | '_' | '-' | '.' | ':'), _ -> | |
69 | loop i1 (i2 + 1) | |
70 | | _, ('a' .. 'z' | '0' .. '9' | '_' | '-' | '.' | ':') -> | |
71 | loop (i1 + 1) i2 | |
72 | | _ -> | |
73 | loop (i1 + 1) (i2 + 1) | |
74 | in | |
75 | loop 0 0 | |
76 | ||
77 | let recode_with cd str = | |
78 | reset cd; | |
79 | let src = { | |
80 | bytes = str; | |
81 | index = 0; | |
82 | limit = String.length str; | |
83 | } | |
84 | and dst = { | |
85 | bytes = String.create (String.length str); | |
86 | index = 0; | |
87 | limit = String.length str; | |
88 | } in | |
89 | while src.index < src.limit do | |
90 | try | |
91 | iconv cd ~src ~dst | |
92 | with | |
93 | | Insufficient_space -> | |
94 | let buf = String.create (String.length dst.bytes * 2) in | |
95 | String.unsafe_blit dst.bytes 0 buf 0 (String.length dst.bytes); | |
96 | dst.bytes <- buf; | |
97 | dst.limit <- String.length buf | |
98 | done; | |
99 | String.sub dst.bytes 0 dst.index | |
100 | ||
101 | let recode ~to_code ~of_code str = | |
102 | if equal to_code of_code then | |
103 | str | |
104 | else begin | |
105 | let cd = iconv_open ~to_code ~of_code in | |
106 | let str = try recode_with cd str with exn -> iconv_close cd; raise exn in | |
107 | iconv_close cd; | |
108 | str | |
109 | end |
0 | (* | |
1 | * lTerm_iconv.mli | |
2 | * --------------- | |
3 | * Copyright : (c) 2011, Jeremie Dimino <jeremie@dimino.org> | |
4 | * Licence : BSD3 | |
5 | * | |
6 | * This file is a part of Lambda-Term. | |
7 | *) | |
8 | ||
9 | (** Iconv bindings. *) | |
10 | ||
11 | type t | |
12 | (** Type of an iconv conversion descriptor. *) | |
13 | ||
14 | val equal : string -> string -> bool | |
15 | (** [equal encoding1 encoding2] returns [true] iff the two given | |
16 | encodings denote the same one. *) | |
17 | ||
18 | exception Closed | |
19 | (** Exception raised when trying to use a closed iconv | |
20 | descriptor. *) | |
21 | ||
22 | exception Unsupported of string * string | |
23 | (** [Unsupported(src, dst)] is the exception raised when the | |
24 | conversion from [src] to [dst] is not supported. *) | |
25 | ||
26 | val iconv_open : to_code : string -> of_code : string -> t | |
27 | (** [iconv_open ~to_code ~of_code] creates a iconv descriptor which | |
28 | converts from strings encoded in [of_code] to string encoded in | |
29 | [to_code]. *) | |
30 | ||
31 | val iconv_close : t -> unit | |
32 | (** [iconv_close cd] closes the given conversion descriptor. It does | |
33 | nothing if it is already closed. *) | |
34 | ||
35 | (** Type of a chunk of data. *) | |
36 | type data = { | |
37 | mutable bytes : string; | |
38 | (** The string containing the data. *) | |
39 | mutable index : int; | |
40 | (** The start of data in [bytes]. *) | |
41 | mutable limit : int; | |
42 | (** The end of data in [bytes]. *) | |
43 | } | |
44 | ||
45 | exception Invalid_sequence | |
46 | (** Exception raised when an invalid encoded sequence is encountered | |
47 | in the input, or when a character cannot be encoded in the | |
48 | destination encoding. *) | |
49 | ||
50 | exception Unterminated_sequence | |
51 | (** Exception raised when a unterminated sequence is encountered at | |
52 | the end of the input. *) | |
53 | ||
54 | exception Insufficient_space | |
55 | (** Excpetion raised when there is no more room in the output. *) | |
56 | ||
57 | val iconv : t -> src : data -> dst : data -> unit | |
58 | (** [iconv cd ~src ~dst] converts bytes from [src] to [dst] using | |
59 | the given conversion descriptor and updates [src.index] and | |
60 | [dst.index]. *) | |
61 | ||
62 | val reset : t -> unit | |
63 | (** [reset cd] resets [cd] to its initial state. *) | |
64 | ||
65 | val recode : to_code : string -> of_code : string -> string -> string | |
66 | (** [recode ~to_code ~of_code str] recodes [str] from [of_code] to | |
67 | [to_code]. *) | |
68 | ||
69 | val recode_with : t -> string -> string | |
70 | (** [recode_with cd str] recodes [str] with the given conversion | |
71 | descriptor. *) |
0 | /* | |
1 | * lTerm_iconv_stubs.c | |
2 | * ------------------- | |
3 | * Copyright : (c) 2011, Jeremie Dimino <jeremie@dimino.org> | |
4 | * Licence : BSD3 | |
5 | * | |
6 | * This file is a part of Lambda-Term. | |
7 | */ | |
8 | ||
9 | #include <caml/mlvalues.h> | |
10 | #include <caml/alloc.h> | |
11 | #include <caml/custom.h> | |
12 | #include <caml/memory.h> | |
13 | #include <caml/fail.h> | |
14 | #include <caml/callback.h> | |
15 | #include <caml/unixsupport.h> | |
16 | ||
17 | #include <iconv.h> | |
18 | #include <errno.h> | |
19 | ||
20 | /* +-----------------------------------------------------------------+ | |
21 | | Conversion descriptors | | |
22 | +-----------------------------------------------------------------+ */ | |
23 | ||
24 | #define Iconv_val(v) *(iconv_t*)Data_custom_val(v) | |
25 | ||
26 | static void lt_iconv_finalize(value val_cd) | |
27 | { | |
28 | iconv_t cd = Iconv_val(val_cd); | |
29 | if (cd) iconv_close(cd); | |
30 | } | |
31 | ||
32 | static int lt_iconv_compare(value v1, value v2) | |
33 | { | |
34 | long d = (long)Iconv_val(v1) - (long)Iconv_val(v2); | |
35 | if (d < 0) return -1; | |
36 | if (d > 0) return +1; | |
37 | return 0; | |
38 | } | |
39 | ||
40 | static long lt_iconv_hash(value v) | |
41 | { | |
42 | return (long)Iconv_val(v); | |
43 | } | |
44 | ||
45 | static struct custom_operations iconv_ops = { | |
46 | "lambda-term:iconv", | |
47 | lt_iconv_finalize, | |
48 | lt_iconv_compare, | |
49 | lt_iconv_hash, | |
50 | custom_serialize_default, | |
51 | custom_deserialize_default | |
52 | }; | |
53 | ||
54 | ||
55 | static value alloc_iconv(iconv_t cd) | |
56 | { | |
57 | value result = caml_alloc_custom(&iconv_ops, sizeof(iconv_t), 0, 1); | |
58 | Iconv_val(result) = cd; | |
59 | return result; | |
60 | } | |
61 | ||
62 | /* +-----------------------------------------------------------------+ | |
63 | | Opening/closing | | |
64 | +-----------------------------------------------------------------+ */ | |
65 | ||
66 | CAMLprim value lt_iconv_iconv_open(value to_code, value of_code) | |
67 | { | |
68 | iconv_t cd = iconv_open(String_val(to_code), String_val(of_code)); | |
69 | if (cd == (iconv_t)-1) { | |
70 | value args[2]; | |
71 | args[0] = of_code; | |
72 | args[1] = to_code; | |
73 | caml_raise_with_args(*caml_named_value("lambda-term:iconv:unsupported"), 2, args); | |
74 | } | |
75 | return alloc_iconv(cd); | |
76 | } | |
77 | ||
78 | CAMLprim value lt_iconv_iconv_close(value val_cd) | |
79 | { | |
80 | iconv_t cd = Iconv_val(val_cd); | |
81 | if (cd) { | |
82 | Iconv_val(val_cd) = NULL; | |
83 | iconv_close(cd); | |
84 | } | |
85 | return Val_unit; | |
86 | } | |
87 | ||
88 | CAMLprim value lt_iconv_iconv(value val_cd, value val_src, value val_dst) | |
89 | { | |
90 | iconv_t cd = Iconv_val(val_cd); | |
91 | if (cd == NULL) caml_raise_constant(*caml_named_value("lambda-term:iconv:closed")); | |
92 | ||
93 | char *src = String_val(Field(val_src, 0)) + Long_val(Field(val_src, 1)); | |
94 | size_t src_len = Long_val(Field(val_src, 2)) - Long_val(Field(val_src, 1)); | |
95 | ||
96 | char *dst = String_val(Field(val_dst, 0)) + Long_val(Field(val_dst, 1)); | |
97 | size_t dst_len = Long_val(Field(val_dst, 2)) - Long_val(Field(val_dst, 1)); | |
98 | ||
99 | size_t result = iconv(cd, &src, &src_len, &dst, &dst_len); | |
100 | ||
101 | Field(val_src, 1) = Val_long(Long_val(Field(val_src, 2)) - src_len); | |
102 | Field(val_dst, 1) = Val_long(Long_val(Field(val_dst, 2)) - dst_len); | |
103 | ||
104 | if (result == (size_t)-1) { | |
105 | switch (errno) { | |
106 | case EILSEQ: | |
107 | caml_raise_constant(*caml_named_value("lambda-term:iconv:invalid-sequence")); | |
108 | case EINVAL: | |
109 | caml_raise_constant(*caml_named_value("lambda-term:iconv:unterminated-sequence")); | |
110 | case E2BIG: | |
111 | caml_raise_constant(*caml_named_value("lambda-term:iconv:insufficient-space")); | |
112 | } | |
113 | } | |
114 | ||
115 | return Val_unit; | |
116 | } | |
117 | ||
118 | CAMLprim value lt_iconv_reset(value val_cd) | |
119 | { | |
120 | iconv_t cd = Iconv_val(val_cd); | |
121 | if (cd == NULL) caml_raise_constant(*caml_named_value("lambda-term:iconv:closed")); | |
122 | iconv(cd, NULL, 0, NULL, 0); | |
123 | return Val_unit; | |
124 | } |
15 | 15 | val load : ?file : string -> unit -> unit Lwt.t |
16 | 16 | (** [load ?file ()] loads key bindings from [file], which defaults |
17 | 17 | to ~/.lambda-term-inputrc, if it exists. *) |
18 | ||
19 | val default : string | |
20 | (** The name of the default key bindings file, | |
21 | i.e. ~/.lambda-term-inputrc. *) |
331 | 331 | { Error "parsing error in actions" } |
332 | 332 | |
333 | 333 | { |
334 | let lambda_term_inputrc = | |
335 | Filename.concat (try Sys.getenv "HOME" with Not_found -> "") ".lambda-term-inputrc" | |
336 | ||
337 | let load ?(file = lambda_term_inputrc) () = | |
334 | let default = | |
335 | Filename.concat LTerm_resources.home ".lambda-term-inputrc" | |
336 | ||
337 | let load ?(file = default) () = | |
338 | 338 | try_lwt |
339 | 339 | lwt ic = Lwt_io.open_file ~mode:Lwt_io.input file in |
340 | 340 | let rec loop num handler = |
357 | 357 | | Error msg -> |
358 | 358 | raise (Parse_error (file, num, msg)) |
359 | 359 | in |
360 | loop 1 handle_edit_action | |
360 | try_lwt | |
361 | loop 1 handle_edit_action | |
362 | finally | |
363 | Lwt_io.close ic | |
361 | 364 | with Unix.Unix_error(Unix.ENOENT, _, _) -> |
362 | 365 | return () |
363 | 366 | } |
16 | 16 | |
17 | 17 | exception Interrupt |
18 | 18 | type prompt = LTerm_text.t |
19 | type history = Zed_utf8.t list | |
19 | 20 | |
20 | 21 | (* +-----------------------------------------------------------------+ |
21 | 22 | | Completion | |
41 | 42 | |
42 | 43 | let lookup word words = List.filter (fun word' -> Zed_utf8.starts_with word' word) words |
43 | 44 | let lookup_assoc word words = List.filter (fun (word', x) -> Zed_utf8.starts_with word' word) words |
44 | ||
45 | (* +-----------------------------------------------------------------+ | |
46 | | History | | |
47 | +-----------------------------------------------------------------+ *) | |
48 | ||
49 | type history = string list | |
50 | ||
51 | let add_entry line history = | |
52 | if Zed_utf8.strip line = "" then | |
53 | history | |
54 | else | |
55 | if (match history with [] -> false | x :: _ -> x = line) then | |
56 | history | |
57 | else | |
58 | line :: history | |
59 | ||
60 | let newline = UChar.of_char '\n' | |
61 | let backslash = UChar.of_char '\\' | |
62 | let letter_n = UChar.of_char 'n' | |
63 | ||
64 | let escape line = | |
65 | let buf = Buffer.create (String.length line) in | |
66 | Zed_utf8.iter | |
67 | (fun ch -> | |
68 | if ch = newline then | |
69 | Buffer.add_string buf "\\n" | |
70 | else if ch = backslash then | |
71 | Buffer.add_string buf "\\\\" | |
72 | else | |
73 | Buffer.add_string buf (Zed_utf8.singleton ch)) | |
74 | line; | |
75 | Buffer.contents buf | |
76 | ||
77 | let unescape line = | |
78 | let buf = Buffer.create (String.length line) in | |
79 | let rec loop ofs = | |
80 | if ofs = String.length line then | |
81 | Buffer.contents buf | |
82 | else begin | |
83 | let ch, ofs = Zed_utf8.unsafe_extract_next line ofs in | |
84 | if ch = backslash then begin | |
85 | if ofs = String.length line then begin | |
86 | Buffer.add_char buf '\\'; | |
87 | Buffer.contents buf | |
88 | end else begin | |
89 | let ch, ofs = Zed_utf8.unsafe_extract_next line ofs in | |
90 | if ch = backslash then | |
91 | Buffer.add_char buf '\\' | |
92 | else if ch = letter_n then | |
93 | Buffer.add_char buf '\n' | |
94 | else begin | |
95 | Buffer.add_char buf '\\'; | |
96 | Buffer.add_string buf (Zed_utf8.singleton ch) | |
97 | end; | |
98 | loop ofs | |
99 | end | |
100 | end else begin | |
101 | Buffer.add_string buf (Zed_utf8.singleton ch); | |
102 | loop ofs | |
103 | end | |
104 | end | |
105 | in | |
106 | loop 0 | |
107 | ||
108 | let rec load_lines ic acc = | |
109 | Lwt_io.read_line_opt ic >>= function | |
110 | | Some l -> | |
111 | ignore (Zed_utf8.validate l); | |
112 | load_lines ic (unescape l :: acc) | |
113 | | None -> | |
114 | return acc | |
115 | ||
116 | let load_history name = | |
117 | if Sys.file_exists name then | |
118 | Lwt_io.with_file ~mode:Lwt_io.input name (fun ic -> load_lines ic []) | |
119 | else | |
120 | return [] | |
121 | ||
122 | let rec merge h1 h2 = | |
123 | match h1, h2 with | |
124 | | l1 :: h1, l2 :: h2 when l1 = l2 -> | |
125 | l1 :: merge h1 h2 | |
126 | | _ -> | |
127 | h1 @ h2 | |
128 | ||
129 | let save_history name history = | |
130 | lwt on_disk_history = load_history name in | |
131 | Lwt_io.lines_to_file name (Lwt_stream.map escape (Lwt_stream.of_list (merge (List.rev on_disk_history) (List.rev history)))) | |
132 | 45 | |
133 | 46 | (* +-----------------------------------------------------------------+ |
134 | 47 | | Actions | |
150 | 63 | | Prev_search |
151 | 64 | | Cancel_search |
152 | 65 | | Break |
66 | | Suspend | |
153 | 67 | |
154 | 68 | let doc_of_action = function |
155 | 69 | | Edit action -> LTerm_edit.doc_of_action action |
167 | 81 | | Prev_search -> "search backward in the history." |
168 | 82 | | Cancel_search -> "cancel search mode." |
169 | 83 | | Break -> "cancel edition." |
84 | | Suspend -> "suspend edition." | |
170 | 85 | |
171 | 86 | let actions = [ |
172 | 87 | Interrupt_or_delete_next_char, "interrupt-or-delete-next-char"; |
183 | 98 | Prev_search, "prev-search"; |
184 | 99 | Cancel_search, "cancel-search"; |
185 | 100 | Break, "break"; |
101 | Suspend, "suspend"; | |
186 | 102 | ] |
187 | 103 | |
188 | 104 | let actions_to_names = Array.of_list (List.sort (fun (a1, n1) (a2, n2) -> Pervasives.compare a1 a2) actions) |
238 | 154 | bind [{ control = false; meta = false; shift = false; code = Down }] [History_next]; |
239 | 155 | bind [{ control = false; meta = false; shift = false; code = Tab }] [Complete]; |
240 | 156 | bind [{ control = false; meta = false; shift = false; code = Enter }] [Accept]; |
157 | bind [{ control = true; meta = false; shift = false; code = Char(UChar.of_char 'b') }] [Edit (LTerm_edit.Zed Zed_edit.Prev_char)]; | |
158 | bind [{ control = true; meta = false; shift = false; code = Char(UChar.of_char 'f') }] [Edit (LTerm_edit.Zed Zed_edit.Next_char)]; | |
159 | bind [{ control = true; meta = false; shift = false; code = Char(UChar.of_char 'h') }] [Edit (LTerm_edit.Zed Zed_edit.Delete_prev_char)]; | |
241 | 160 | bind [{ control = true; meta = false; shift = false; code = Char(UChar.of_char 'c') }] [Break]; |
161 | bind [{ control = true; meta = false; shift = false; code = Char(UChar.of_char 'z') }] [Suspend]; | |
242 | 162 | bind [{ control = true; meta = false; shift = false; code = Char(UChar.of_char 'm') }] [Accept]; |
243 | 163 | bind [{ control = true; meta = false; shift = false; code = Char(UChar.of_char 'l') }] [Clear_screen]; |
244 | 164 | bind [{ control = true; meta = false; shift = false; code = Char(UChar.of_char 'r') }] [Prev_search]; |
245 | 165 | bind [{ control = true; meta = false; shift = false; code = Char(UChar.of_char 'd') }] [Interrupt_or_delete_next_char]; |
166 | bind [{ control = false; meta = true; shift = false; code = Char(UChar.of_char 'p') }] [History_prev]; | |
167 | bind [{ control = false; meta = true; shift = false; code = Char(UChar.of_char 'n') }] [History_next]; | |
246 | 168 | bind [{ control = false; meta = true; shift = false; code = Left }] [Complete_bar_prev]; |
247 | 169 | bind [{ control = false; meta = true; shift = false; code = Right }] [Complete_bar_next]; |
248 | 170 | bind [{ control = false; meta = true; shift = false; code = Home }] [Complete_bar_first]; |
563 | 485 | end |
564 | 486 | |
565 | 487 | | Break -> |
566 | Zed_edit.insert context (Zed_rope.of_string "^C"); | |
567 | 488 | raise Sys.Break |
568 | 489 | |
569 | 490 | | _ -> |
657 | 578 | | Running in a terminal | |
658 | 579 | +-----------------------------------------------------------------+ *) |
659 | 580 | |
581 | let newline = UChar.of_char '\n' | |
660 | 582 | let vline = LTerm_draw.({ top = Light; bottom = Light; left = Blank; right = Blank }) |
661 | 583 | let reverse_style = { LTerm_style.none with LTerm_style.reverse = Some true } |
662 | 584 | let default_prompt = LTerm_text.of_string "# " |
669 | 591 | | e :: l -> drop (count - 1) l |
670 | 592 | |
671 | 593 | (* Computes the position of the cursor after printing the given styled |
672 | string. *) | |
594 | string: | |
595 | - [pos] is the current cursor position | |
596 | (it may be at column [max-column + 1]) | |
597 | - [text] is the text to display | |
598 | - [start] is the start of the chunk to display in [text] | |
599 | - [stop] is the end of the chunk to display in [text] | |
600 | *) | |
673 | 601 | let rec compute_position cols pos text start stop = |
674 | 602 | if start = stop then |
675 | 603 | pos |
677 | 605 | let ch, style = text.(start) in |
678 | 606 | if ch = newline then |
679 | 607 | compute_position cols { row = pos.row + 1; col = 0 } text (start + 1) stop |
680 | else if pos.col + 1 = cols then | |
681 | compute_position cols { row = pos.row + 1; col = 0 } text (start + 1) stop | |
608 | else if pos.col = cols then | |
609 | compute_position cols { row = pos.row + 1; col = 1 } text (start + 1) stop | |
682 | 610 | else |
683 | 611 | compute_position cols { pos with col = pos.col + 1 } text (start + 1) stop |
612 | ||
613 | (* Return the "real" position of the cursor, i.e. on the screen. *) | |
614 | let real_pos cols pos = | |
615 | if pos.col = cols then | |
616 | { row = pos.row + 1; col = 0 } | |
617 | else | |
618 | pos | |
684 | 619 | |
685 | 620 | let rec get_index_of_last_displayed_word column columns index words = |
686 | 621 | match words with |
714 | 649 | in |
715 | 650 | loop row col 0 |
716 | 651 | |
652 | let unsafe_get matrix row col = | |
653 | Array.unsafe_get (Array.unsafe_get matrix row) col | |
654 | ||
655 | let draw_styled_with_newlines matrix cols row col str = | |
656 | let rec loop row col idx = | |
657 | if idx < Array.length str then begin | |
658 | let ch, style = Array.unsafe_get str idx in | |
659 | if ch = newline then begin | |
660 | (unsafe_get matrix row col).LTerm_draw.char <- newline; | |
661 | loop (row + 1) 0 (idx + 1) | |
662 | end else begin | |
663 | let row, col = | |
664 | if col = cols then | |
665 | (row + 1, 0) | |
666 | else | |
667 | (row, col) | |
668 | in | |
669 | let point = unsafe_get matrix row col in | |
670 | point.LTerm_draw.char <- ch; | |
671 | LTerm_draw.set_style point style; | |
672 | loop row (col + 1) (idx + 1) | |
673 | end | |
674 | end | |
675 | in | |
676 | loop row col 0 | |
677 | ||
678 | let styled_newline = [|(newline, LTerm_style.none)|] | |
679 | ||
717 | 680 | class virtual ['a] term term = |
718 | let size, set_size = S.create { cols = 80; rows = 25 } in | |
681 | let size, set_size = S.create (LTerm.size term) in | |
719 | 682 | let event, set_prompt = E.create () in |
720 | 683 | let prompt = S.switch (S.const default_prompt) event in |
721 | 684 | let key_sequence, set_key_sequence = S.create [] in |
790 | 753 | |
791 | 754 | method draw_update = |
792 | 755 | let size = S.value size in |
793 | if visible && size.cols > 0 then begin | |
756 | if visible && size.rows > 0 && size.cols > 0 then begin | |
794 | 757 | let styled, position = self#stylise false in |
795 | 758 | let prompt = S.value prompt in |
796 | 759 | (* Compute the position of the cursor after displaying the |
802 | 765 | (* Compute the position of the cursor after displaying the |
803 | 766 | input. *) |
804 | 767 | let pos_after_styled = compute_position size.cols pos_after_before styled position (Array.length styled) in |
768 | (* Compute the position of the cursor after displaying the | |
769 | newline used to end the input. *) | |
770 | let pos_after_newline = compute_position size.cols pos_after_styled styled_newline 0 1 in | |
771 | (* The real position of the cursor on the screen. *) | |
772 | let pos_cursor = real_pos size.cols pos_after_before in | |
773 | (* Height of prompt+input. *) | |
774 | let prompt_input_height = max (pos_cursor.row + 1) pos_after_newline.row in | |
805 | 775 | let matrix = |
806 | 776 | if self#show_box && size.cols > 2 then |
807 | (* Compute the position of the cursor after displaying the | |
808 | newline to separate the input and the box. *) | |
809 | let pos_after_newline = compute_position size.cols pos_after_styled [|(newline, LTerm_style.none)|] 0 1 in | |
810 | 777 | match S.value self#message with |
811 | 778 | | Some msg -> |
812 | 779 | (* Compute the height of the message. *) |
813 | 780 | let message_height = (compute_position (size.cols - 2) { row = 0; col = 0 } msg 0 (Array.length msg)).row + 1 in |
814 | 781 | (* The total height of the displayed text. *) |
815 | let total_height = pos_after_newline.row + message_height + 2 in | |
782 | let total_height = prompt_input_height + message_height + 2 in | |
816 | 783 | |
817 | 784 | (* Create the matrix for the rendering. *) |
818 | let matrix_size = { size with rows = if displayed then max total_height height else total_height } in | |
785 | let matrix_size = { cols = size.cols + 1; rows = if displayed then max total_height height else total_height } in | |
819 | 786 | let matrix = LTerm_draw.make_matrix matrix_size in |
820 | let ctx = LTerm_draw.context matrix matrix_size in | |
821 | 787 | |
822 | 788 | (* Update the height parameter. *) |
823 | 789 | height <- total_height; |
824 | 790 | |
825 | 791 | (* Draw the prompt and the input. *) |
826 | draw_styled ctx 0 0 prompt; | |
827 | draw_styled ctx pos_after_prompt.row pos_after_prompt.col styled; | |
792 | draw_styled_with_newlines matrix size.cols 0 0 prompt; | |
793 | draw_styled_with_newlines matrix size.cols pos_after_prompt.row pos_after_prompt.col styled; | |
794 | draw_styled_with_newlines matrix size.cols pos_after_styled.row pos_after_styled.col styled_newline; | |
795 | ||
796 | let ctx = LTerm_draw.sub (LTerm_draw.context matrix matrix_size) { | |
797 | row1 = 0; | |
798 | col1 = 0; | |
799 | row2 = matrix_size.rows; | |
800 | col2 = size.cols; | |
801 | } in | |
828 | 802 | |
829 | 803 | (* Draw a frame for the message. *) |
830 | 804 | LTerm_draw.draw_frame ctx { |
831 | row1 = pos_after_newline.row; | |
805 | row1 = prompt_input_height; | |
832 | 806 | col1 = 0; |
833 | 807 | row2 = total_height; |
834 | 808 | col2 = size.cols; |
835 | 809 | } LTerm_draw.Light; |
810 | for row = prompt_input_height to total_height - 1 do | |
811 | (unsafe_get matrix row size.cols).LTerm_draw.char <- newline | |
812 | done; | |
836 | 813 | |
837 | 814 | (* Draw the message. *) |
838 | 815 | let ctx = LTerm_draw.sub ctx { |
839 | row1 = pos_after_newline.row + 1; | |
816 | row1 = prompt_input_height + 1; | |
840 | 817 | col1 = 1; |
841 | 818 | row2 = total_height - 1; |
842 | 819 | col2 = size.cols - 1; |
851 | 828 | let comp_words = drop comp_start (S.value self#completion_words) in |
852 | 829 | |
853 | 830 | (* The total height of the displayed text. *) |
854 | let total_height = pos_after_newline.row + 3 in | |
831 | let total_height = prompt_input_height + 3 in | |
855 | 832 | |
856 | 833 | (* Create the matrix for the rendering. *) |
857 | let matrix_size = { size with rows = if displayed then max total_height height else total_height } in | |
834 | let matrix_size = { cols = size.cols + 1; rows = if displayed then max total_height height else total_height } in | |
858 | 835 | let matrix = LTerm_draw.make_matrix matrix_size in |
859 | let ctx = LTerm_draw.context matrix matrix_size in | |
860 | 836 | |
861 | 837 | (* Update the height parameter. *) |
862 | 838 | height <- total_height; |
863 | 839 | |
864 | 840 | (* Draw the prompt and the input. *) |
865 | draw_styled ctx 0 0 prompt; | |
866 | draw_styled ctx pos_after_prompt.row pos_after_prompt.col styled; | |
841 | draw_styled_with_newlines matrix size.cols 0 0 prompt; | |
842 | draw_styled_with_newlines matrix size.cols pos_after_prompt.row pos_after_prompt.col styled; | |
843 | draw_styled_with_newlines matrix size.cols pos_after_styled.row pos_after_styled.col styled_newline; | |
844 | ||
845 | let ctx = LTerm_draw.sub (LTerm_draw.context matrix matrix_size) { | |
846 | row1 = 0; | |
847 | col1 = 0; | |
848 | row2 = matrix_size.rows; | |
849 | col2 = size.cols; | |
850 | } in | |
867 | 851 | |
868 | 852 | (* Draw a frame for the completion. *) |
869 | 853 | LTerm_draw.draw_frame ctx { |
870 | row1 = pos_after_newline.row; | |
854 | row1 = prompt_input_height; | |
871 | 855 | col1 = 0; |
872 | 856 | row2 = total_height; |
873 | 857 | col2 = size.cols; |
874 | 858 | } LTerm_draw.Light; |
859 | for row = prompt_input_height to total_height - 1 do | |
860 | (unsafe_get matrix row size.cols).LTerm_draw.char <- newline | |
861 | done; | |
875 | 862 | |
876 | 863 | (* Draw the completion. *) |
877 | 864 | let ctx = LTerm_draw.sub ctx { |
878 | row1 = pos_after_newline.row + 1; | |
865 | row1 = prompt_input_height + 1; | |
879 | 866 | col1 = 1; |
880 | 867 | row2 = total_height - 1; |
881 | 868 | col2 = size.cols - 1; |
902 | 889 | matrix |
903 | 890 | |
904 | 891 | else begin |
905 | let total_height = pos_after_styled.row + 1 in | |
906 | let matrix_size = { size with rows = if displayed then max total_height height else total_height } in | |
892 | let total_height = prompt_input_height in | |
893 | let matrix_size = { cols = size.cols + 1; rows = if displayed then max total_height height else total_height } in | |
907 | 894 | let matrix = LTerm_draw.make_matrix matrix_size in |
908 | let ctx = LTerm_draw.context matrix matrix_size in | |
909 | 895 | height <- total_height; |
910 | draw_styled ctx 0 0 prompt; | |
911 | draw_styled ctx pos_after_prompt.row pos_after_prompt.col styled; | |
896 | draw_styled_with_newlines matrix size.cols 0 0 prompt; | |
897 | draw_styled_with_newlines matrix size.cols pos_after_prompt.row pos_after_prompt.col styled; | |
912 | 898 | matrix |
913 | 899 | end |
914 | 900 | in |
901 | lwt () = LTerm.hide_cursor term in | |
915 | 902 | lwt () = |
916 | 903 | if displayed then |
917 | 904 | (* Go back to the beginning of displayed text. *) |
920 | 907 | return () |
921 | 908 | in |
922 | 909 | (* Display everything. *) |
923 | lwt () = LTerm.print_box term matrix in | |
910 | lwt () = LTerm.print_box_with_newlines term matrix in | |
924 | 911 | (* Update the cursor. *) |
925 | cursor <- pos_after_before; | |
912 | cursor <- pos_cursor; | |
926 | 913 | (* Move the cursor to the right position. *) |
927 | lwt () = | |
928 | if LTerm.windows term then | |
929 | (* On windows the cursor is not moved. *) | |
930 | LTerm.move term cursor.row cursor.col | |
931 | else | |
932 | (* On Unix the cursor stay at the end of line. We put it | |
933 | back to the beginning of the line immediatly because all | |
934 | terminals do not respond the same way when the cursor is | |
935 | at the end of line. *) | |
936 | lwt () = LTerm.fprint term "\r" in | |
937 | LTerm.move term (cursor.row - Array.length matrix + 1) cursor.col | |
938 | in | |
914 | lwt () = LTerm.move term (cursor.row - Array.length matrix + 1) cursor.col in | |
915 | lwt () = LTerm.show_cursor term in | |
939 | 916 | lwt () = LTerm.flush term in |
940 | 917 | displayed <- true; |
941 | 918 | return () |
944 | 921 | |
945 | 922 | method draw_success = |
946 | 923 | let size = S.value size in |
947 | let styled, position = self#stylise true in | |
948 | let prompt = S.value prompt in | |
949 | let pos_after_prompt = compute_position size.cols { row = 0; col = 0 } prompt 0 (Array.length prompt) in | |
950 | let pos_after_before = compute_position size.cols pos_after_prompt styled 0 position in | |
951 | let pos_after_styled = compute_position size.cols pos_after_before styled position (Array.length styled) in | |
952 | let total_height = pos_after_styled.row + 1 in | |
953 | let matrix_size = { size with rows = if displayed then max total_height height else total_height } in | |
954 | let matrix = LTerm_draw.make_matrix matrix_size in | |
955 | let ctx = LTerm_draw.context matrix matrix_size in | |
956 | draw_styled ctx 0 0 prompt; | |
957 | draw_styled ctx pos_after_prompt.row pos_after_prompt.col styled; | |
958 | lwt () = if displayed then LTerm.move term (-cursor.row) (-cursor.col) else return () in | |
959 | lwt () = LTerm.print_box term matrix in | |
960 | if LTerm.windows term then | |
961 | LTerm.move term total_height 0 | |
962 | else | |
963 | lwt () = LTerm.fprint term "\r" in | |
964 | LTerm.move term (total_height - Array.length matrix + 1) 0 | |
924 | if size.rows > 0 && size.cols > 0 then begin | |
925 | let styled, position = self#stylise true in | |
926 | let prompt = S.value prompt in | |
927 | let pos_after_prompt = compute_position size.cols { row = 0; col = 0 } prompt 0 (Array.length prompt) in | |
928 | let pos_after_before = compute_position size.cols pos_after_prompt styled 0 position in | |
929 | let pos_after_styled = compute_position size.cols pos_after_before styled position (Array.length styled) in | |
930 | let total_height = pos_after_styled.row + 1 in | |
931 | let matrix_size = { cols = size.cols + 1; rows = if displayed then max total_height height else total_height } in | |
932 | let matrix = LTerm_draw.make_matrix matrix_size in | |
933 | draw_styled_with_newlines matrix size.cols 0 0 prompt; | |
934 | draw_styled_with_newlines matrix size.cols pos_after_prompt.row pos_after_prompt.col styled; | |
935 | draw_styled_with_newlines matrix size.cols pos_after_styled.row pos_after_styled.col styled_newline; | |
936 | lwt () = if displayed then LTerm.move term (-cursor.row) (-cursor.col) else return () in | |
937 | lwt () = LTerm.print_box_with_newlines term matrix in | |
938 | lwt () = LTerm.move term (total_height - Array.length matrix) 0 in | |
939 | (* Print a newline instead of a movement to ensure scrolling when | |
940 | at the end of screen. *) | |
941 | LTerm.fprint term "\n" | |
942 | end else | |
943 | return () | |
965 | 944 | |
966 | 945 | method draw_failure = |
967 | 946 | self#draw_success |
969 | 948 | method hide = |
970 | 949 | if visible then begin |
971 | 950 | visible <- false; |
972 | Lwt_mutex.with_lock draw_mutex (fun () -> | |
973 | if displayed then | |
974 | let matrix_size = { S.value size with rows = height } in | |
975 | let matrix = LTerm_draw.make_matrix matrix_size in | |
976 | lwt () = LTerm.move term (-cursor.row) (-cursor.col) in | |
977 | lwt () = LTerm.print_box term matrix in | |
978 | lwt () = | |
979 | if LTerm.windows term then | |
980 | return () | |
981 | else | |
982 | lwt () = LTerm.fprint term "\r" in | |
983 | LTerm.move term (1 - Array.length matrix) 0 | |
984 | in | |
985 | cursor <- { row = 0; col = 0 }; | |
986 | height <- 0; | |
987 | displayed <- false; | |
988 | return () | |
989 | else | |
990 | return ()) | |
951 | lwt () = Lwt_mutex.lock draw_mutex in | |
952 | try_lwt | |
953 | let size = S.value size in | |
954 | if displayed && size.rows > 0 && size.cols > 0 then | |
955 | let matrix_size = { cols = size.cols + 1; rows = height } in | |
956 | let matrix = LTerm_draw.make_matrix matrix_size in | |
957 | for row = 0 to height - 1 do | |
958 | (unsafe_get matrix row 0).LTerm_draw.char <- newline | |
959 | done; | |
960 | lwt () = LTerm.move term (-cursor.row) (-cursor.col) in | |
961 | lwt () = LTerm.print_box_with_newlines term matrix in | |
962 | lwt () = LTerm.move term (1 - Array.length matrix) 0 in | |
963 | cursor <- { row = 0; col = 0 }; | |
964 | height <- 0; | |
965 | displayed <- false; | |
966 | return () | |
967 | else | |
968 | return () | |
969 | finally | |
970 | Lwt_mutex.unlock draw_mutex; | |
971 | return () | |
991 | 972 | end else |
992 | 973 | return () |
993 | 974 | |
997 | 978 | self#queue_draw_update |
998 | 979 | end else |
999 | 980 | return () |
981 | ||
982 | val mutable mode = None | |
1000 | 983 | |
1001 | 984 | (* The main loop. *) |
1002 | 985 | method private loop = |
1027 | 1010 | | { control = false; meta = false; shift = false; code = Char ch } -> |
1028 | 1011 | Zed_macro.add self#macro (Edit (LTerm_edit.Zed (Zed_edit.Insert ch))); |
1029 | 1012 | self#insert ch |
1013 | | { code = Char ch } when LTerm.windows term && UChar.code ch >= 32 -> | |
1014 | (* Windows reports Shift+A for A, ... *) | |
1015 | Zed_macro.add self#macro (Edit (LTerm_edit.Zed (Zed_edit.Insert ch))); | |
1016 | self#insert ch | |
1030 | 1017 | | _ -> |
1031 | 1018 | () |
1032 | 1019 | else |
1050 | 1037 | | Edit LTerm_edit.Play_macro :: actions -> |
1051 | 1038 | Zed_macro.cancel self#macro; |
1052 | 1039 | self#exec (Zed_macro.contents macro @ actions) |
1040 | | Suspend :: actions -> | |
1041 | if Lwt_sys.windows then | |
1042 | self#exec actions | |
1043 | else begin | |
1044 | let is_visible = visible in | |
1045 | lwt () = self#hide in | |
1046 | lwt () = LTerm.flush term in | |
1047 | lwt () = | |
1048 | match mode with | |
1049 | | Some mode -> | |
1050 | LTerm.leave_raw_mode term mode | |
1051 | | None -> | |
1052 | return () | |
1053 | in | |
1054 | Unix.kill (Unix.getpid ()) Sys.sigtstp; | |
1055 | lwt () = | |
1056 | match LTerm.is_a_tty term with | |
1057 | | true -> | |
1058 | lwt m = LTerm.enter_raw_mode term in | |
1059 | mode <- Some m; | |
1060 | return () | |
1061 | | false -> | |
1062 | return () | |
1063 | in | |
1064 | lwt () = if is_visible then self#show else return () in | |
1065 | self#exec actions | |
1066 | end | |
1053 | 1067 | | action :: actions -> |
1054 | 1068 | self#send_action action; |
1055 | 1069 | self#exec actions |
1057 | 1071 | self#loop |
1058 | 1072 | |
1059 | 1073 | method run = |
1060 | (* Get the initial size of the terminal. *) | |
1061 | lwt initial_size = LTerm.get_size term in | |
1062 | set_size initial_size; | |
1074 | (* Update the size with the current size. *) | |
1075 | set_size (LTerm.size term); | |
1063 | 1076 | |
1064 | 1077 | let running = ref true in |
1065 | 1078 | |
1078 | 1091 | ]) |
1079 | 1092 | in |
1080 | 1093 | |
1081 | lwt mode = | |
1094 | lwt () = | |
1082 | 1095 | match LTerm.is_a_tty term with |
1083 | 1096 | | true -> |
1084 | lwt mode = LTerm.enter_raw_mode term in | |
1085 | return (Some mode) | |
1097 | lwt m = LTerm.enter_raw_mode term in | |
1098 | mode <- Some m; | |
1099 | return () | |
1086 | 1100 | | false -> |
1087 | return None | |
1101 | return () | |
1088 | 1102 | in |
1089 | 1103 | |
1090 | 1104 | lwt result = |
21 | 21 | type prompt = LTerm_text.t |
22 | 22 | (** Type of prompts. *) |
23 | 23 | |
24 | type history = Zed_utf8.t list | |
25 | (** Type of histories. It is a list of entries from the most | |
26 | recent to the oldest. *) | |
27 | ||
24 | 28 | (** {6 Completion} *) |
25 | 29 | |
26 | 30 | val common_prefix : string list -> string |
33 | 37 | val lookup_assoc : Zed_utf8.t -> (Zed_utf8.t * 'a) list -> (Zed_utf8.t * 'a) list |
34 | 38 | (** [lookup_assoc word words] does the same as {!lookup} but works |
35 | 39 | on associative list. *) |
36 | ||
37 | (** {8 History} *) | |
38 | ||
39 | type history = string list | |
40 | (** Type of an history *) | |
41 | ||
42 | val add_entry : string -> history -> history | |
43 | (** [add_entry line history] returns the history [history] plus | |
44 | [line] at the beginning. If [line] already appears at the | |
45 | beginning or contains only spaces, it is discarded. *) | |
46 | ||
47 | val save_history : string -> history -> unit Lwt.t | |
48 | (** [save_history filename history] saves [history] to | |
49 | [filename]. The contents of [filename] is merged with [history] | |
50 | before saving. *) | |
51 | ||
52 | val load_history : string -> history Lwt.t | |
53 | (** [load_history filename] loads history from [filename]. Returns | |
54 | the empty history if the the file does not exit. It fails with | |
55 | [Zed_utf8.Invalid] if one of the line of the history is not | |
56 | correctly UTF-8 encoded. *) | |
57 | 40 | |
58 | 41 | (** {6 Actions} *) |
59 | 42 | |
91 | 74 | (** Cancel search mode. *) |
92 | 75 | | Break |
93 | 76 | (** Raise [Sys.Break]. *) |
77 | | Suspend | |
78 | (** Suspend the program. *) | |
94 | 79 | |
95 | 80 | val bindings : action list Zed_input.Make(LTerm_key).t ref |
96 | 81 | (** Bindings. *) |
5 | 5 | * |
6 | 6 | * This file is a part of Lambda-Term. |
7 | 7 | *) |
8 | ||
9 | let home = | |
10 | try | |
11 | Sys.getenv "HOME" | |
12 | with Not_found -> | |
13 | try | |
14 | (Unix.getpwuid (Unix.getuid ())).Unix.pw_dir | |
15 | with Unix.Unix_error _ | Not_found -> | |
16 | if Lwt_sys.windows then | |
17 | try | |
18 | Sys.getenv "AppData" | |
19 | with Not_found -> | |
20 | "" | |
21 | else | |
22 | "" | |
8 | 23 | |
9 | 24 | (* +-----------------------------------------------------------------+ |
10 | 25 | | Types | |
60 | 60 | |
61 | 61 | val load : string -> t Lwt.t |
62 | 62 | (** Same as {!parse} but parses the contents of a file. *) |
63 | ||
64 | val home : string | |
65 | (** The home directory. *) |
6 | 6 | * This file is a part of Lambda-Term. |
7 | 7 | */ |
8 | 8 | |
9 | #include <caml/mlvalues.h> | |
10 | #include <caml/unixsupport.h> | |
9 | #include <lwt_unix.h> | |
11 | 10 | #include <caml/alloc.h> |
12 | 11 | #include <caml/fail.h> |
12 | #include <caml/memory.h> | |
13 | 13 | |
14 | 14 | #if defined(_WIN32) || defined(_WIN64) |
15 | 15 | |
23 | 23 | CAMLprim value lt_term_get_size_from_fd(value fd) |
24 | 24 | { |
25 | 25 | CONSOLE_SCREEN_BUFFER_INFO info; |
26 | value result; | |
26 | 27 | |
27 | 28 | if (!GetConsoleScreenBufferInfo(Handle_val(fd), &info)) { |
28 | 29 | win32_maperr(GetLastError()); |
29 | 30 | uerror("GetConsoleScreenBufferInfo", Nothing); |
30 | 31 | } |
31 | 32 | |
32 | value result = caml_alloc_tuple(2); | |
33 | result = caml_alloc_tuple(2); | |
33 | 34 | Field(result, 0) = Val_int(info.srWindow.Bottom - info.srWindow.Top + 1); |
34 | 35 | Field(result, 1) = Val_int(info.srWindow.Right - info.srWindow.Left + 1); |
35 | 36 | return result; |
38 | 39 | CAMLprim value lt_term_set_size_from_fd(value fd, value val_size) |
39 | 40 | { |
40 | 41 | CONSOLE_SCREEN_BUFFER_INFO info; |
42 | SMALL_RECT rect; | |
41 | 43 | |
42 | 44 | if (!GetConsoleScreenBufferInfo(Handle_val(fd), &info)) { |
43 | 45 | win32_maperr(GetLastError()); |
44 | 46 | uerror("GetConsoleScreenBufferInfo", Nothing); |
45 | 47 | } |
46 | 48 | |
47 | SMALL_RECT rect; | |
49 | rect; | |
48 | 50 | rect.Top = info.srWindow.Top; |
49 | 51 | rect.Left = info.srWindow.Left; |
50 | 52 | rect.Bottom = rect.Top + Int_val(Field(val_size, 0)) - 1; |
64 | 66 | | Terminal sizes on Unix | |
65 | 67 | +-----------------------------------------------------------------+ */ |
66 | 68 | |
69 | #include <unistd.h> | |
67 | 70 | #include <sys/ioctl.h> |
68 | 71 | #include <termios.h> |
69 | 72 | #include <errno.h> |
31 | 31 | in |
32 | 32 | loop 0 0 |
33 | 33 | |
34 | let rec invalid_length str ofs acc = | |
35 | let ofs, len, _ = Zed_utf8.next_error str ofs in | |
36 | if ofs = String.length str then | |
37 | acc + len | |
38 | else | |
39 | invalid_length str (ofs + 1) (acc + len + 4) | |
40 | ||
41 | let uchar_of_hex x = | |
42 | if x < 10 then | |
43 | UChar.of_int (Char.code '0' + x) | |
44 | else | |
45 | UChar.of_int (Char.code 'a' + x - 10) | |
46 | ||
47 | let of_string_maybe_invalid str = | |
48 | let len = invalid_length str 0 0 in | |
49 | let arr = Array.create len dummy in | |
50 | let rec loop ofs idx = | |
51 | if idx = len then | |
52 | arr | |
53 | else begin | |
54 | let ofs, idx = | |
55 | try | |
56 | let chr, ofs = Zed_utf8.unsafe_extract_next str ofs in | |
57 | Array.unsafe_set arr idx (chr, LTerm_style.none); | |
58 | (ofs, idx + 1) | |
59 | with Zed_utf8.Invalid _ -> | |
60 | let code = Char.code (String.unsafe_get str ofs) in | |
61 | Array.unsafe_set arr (idx + 0) (UChar.of_char '\\', LTerm_style.none); | |
62 | Array.unsafe_set arr (idx + 1) (UChar.of_char 'y', LTerm_style.none); | |
63 | Array.unsafe_set arr (idx + 2) (uchar_of_hex (code lsr 4), LTerm_style.none); | |
64 | Array.unsafe_set arr (idx + 3) (uchar_of_hex (code land 15), LTerm_style.none); | |
65 | (ofs + 1, idx + 4) | |
66 | in | |
67 | loop ofs idx | |
68 | end | |
69 | in | |
70 | loop 0 0 | |
71 | ||
34 | 72 | let to_string txt = |
35 | 73 | let buf = Buffer.create (Array.length txt) in |
36 | 74 | Array.iter (fun (ch, style) -> Buffer.add_string buf (Zed_utf8.singleton ch)) txt; |
67 | 105 | end |
68 | 106 | in |
69 | 107 | loop 0 0 |
108 | ||
109 | (* +-----------------------------------------------------------------+ | |
110 | | Parenthesis matching | | |
111 | +-----------------------------------------------------------------+ *) | |
112 | ||
113 | let lparen = UChar.of_char '(' | |
114 | let rparen = UChar.of_char ')' | |
115 | let lbrace = UChar.of_char '{' | |
116 | let rbrace = UChar.of_char '}' | |
117 | let lbracket = UChar.of_char '[' | |
118 | let rbracket = UChar.of_char ']' | |
119 | ||
120 | type search_result = | |
121 | | No_match_found | |
122 | | No_paren_found | |
123 | | Match_found of int | |
124 | ||
125 | let stylise_parenthesis text ?(paren = [(lparen, rparen); (lbrace, rbrace); (lbracket, rbracket)]) pos style_paren = | |
126 | if Array.length text > 0 then begin | |
127 | let rec rsearch idx left right depth = | |
128 | if idx >= Array.length text then | |
129 | No_match_found | |
130 | else | |
131 | let ch, _ = text.(idx) in | |
132 | if ch = right then | |
133 | if depth = 0 then | |
134 | Match_found idx | |
135 | else | |
136 | rsearch (idx + 1) left right (depth - 1) | |
137 | else if ch = left then | |
138 | rsearch (idx + 1) left right (depth + 1) | |
139 | else | |
140 | rsearch (idx + 1) left right depth | |
141 | in | |
142 | let rec lsearch idx left right depth = | |
143 | if idx < 0 then | |
144 | No_match_found | |
145 | else | |
146 | let ch, _ = text.(idx) in | |
147 | if ch = left then | |
148 | if depth = 0 then | |
149 | Match_found idx | |
150 | else | |
151 | lsearch (idx - 1) left right (depth - 1) | |
152 | else if ch = right then | |
153 | lsearch (idx - 1) left right (depth + 1) | |
154 | else | |
155 | lsearch (idx - 1) left right depth | |
156 | in | |
157 | let found = | |
158 | if pos = Array.length text then | |
159 | false | |
160 | else | |
161 | let ch, _ = text.(pos) in | |
162 | let rec loop = function | |
163 | | [] -> | |
164 | No_paren_found | |
165 | | (lparen, rparen) :: rest -> | |
166 | if ch = lparen then | |
167 | rsearch (pos + 1) lparen rparen 0 | |
168 | else if ch = rparen then | |
169 | lsearch (pos - 1) lparen rparen 0 | |
170 | else | |
171 | loop rest | |
172 | in | |
173 | match loop paren with | |
174 | | Match_found idx -> | |
175 | let ch, style = text.(idx) in | |
176 | text.(idx) <- (ch, LTerm_style.merge style_paren style); | |
177 | true | |
178 | | No_match_found -> | |
179 | true | |
180 | | No_paren_found -> | |
181 | false | |
182 | in | |
183 | if not found && pos > 0 then | |
184 | let ch, style = text.(pos - 1) in | |
185 | let rec loop = function | |
186 | | [] -> | |
187 | No_paren_found | |
188 | | (lparen, rparen) :: rest -> | |
189 | if ch = lparen then | |
190 | rsearch (pos + 1) lparen rparen 0 | |
191 | else if ch = rparen then | |
192 | lsearch (pos - 2) lparen rparen 0 | |
193 | else | |
194 | loop rest | |
195 | in | |
196 | match loop paren with | |
197 | | Match_found idx -> | |
198 | text.(pos - 1) <- (ch, LTerm_style.merge style_paren style); | |
199 | let ch, style = text.(idx) in | |
200 | text.(idx) <- (ch, LTerm_style.merge style_paren style) | |
201 | | No_match_found | No_paren_found -> | |
202 | () | |
203 | end | |
70 | 204 | |
71 | 205 | (* +-----------------------------------------------------------------+ |
72 | 206 | | Markup strings | |
22 | 22 | val to_string : t -> Zed_utf8.t |
23 | 23 | (** Returns the string part of a styled string. *) |
24 | 24 | |
25 | val of_string_maybe_invalid : string -> t | |
26 | (** Creates a styled string from a string. All characters of the | |
27 | string have no style. The string may contain invalid UTF-8 | |
28 | sequences, in which case invalid bytes are escaped with the | |
29 | syntax [\yXX]. *) | |
30 | ||
25 | 31 | val of_rope : Zed_rope.t -> t |
26 | 32 | (** Creates a styled string from a rope. *) |
27 | 33 | |
31 | 37 | val stylise : string -> LTerm_style.t -> t |
32 | 38 | (** [stylise string style] creates a styled string with all styles |
33 | 39 | set to [style]. *) |
40 | ||
41 | (** {6 Parenthesis matching} *) | |
42 | ||
43 | val stylise_parenthesis : t -> ?paren : (UChar.t * UChar.t) list -> int -> LTerm_style.t -> unit | |
44 | (** [stylise_parenthesis text ?paren pos style] searchs for | |
45 | parenthesis group starting or ending at [pos] and apply them the | |
46 | style [style]. [paren] is the list of parenthesis recognized. *) | |
34 | 47 | |
35 | 48 | (** {6 Markup strings} *) |
36 | 49 |
73 | 73 | +-----------------------------------------------------------------+ *) |
74 | 74 | |
75 | 75 | let create term ?(save_state = true) draw = |
76 | lwt size = LTerm.get_size term in | |
77 | 76 | lwt mode = LTerm.enter_raw_mode term in |
78 | 77 | lwt () = if save_state then LTerm.save_state term else return () in |
79 | 78 | let stream, push = Lwt_stream.create () in |
83 | 82 | mode = mode; |
84 | 83 | state = Init; |
85 | 84 | restore_state = save_state; |
86 | size = size; | |
85 | size = LTerm.size term; | |
87 | 86 | matrix_a = [||]; |
88 | 87 | matrix_b = [||]; |
89 | 88 | cursor_visible = false; |
101 | 100 | lwt () = ui.drawer in |
102 | 101 | lwt () = LTerm.leave_raw_mode ui.term ui.mode in |
103 | 102 | if ui.restore_state then |
103 | lwt () = LTerm.show_cursor ui.term in | |
104 | 104 | LTerm.load_state ui.term |
105 | 105 | else |
106 | 106 | return () |
191 | 191 | | Loop | |
192 | 192 | +-----------------------------------------------------------------+ *) |
193 | 193 | |
194 | let wait ui = | |
194 | let rec wait ui = | |
195 | 195 | check ui; |
196 | 196 | if ui.state = Init then draw ui; |
197 | 197 | lwt ev = pick [LTerm.read_event ui.term; Lwt_stream.next ui.draw_error_stream >>= fail] in |
14 | 14 | external get_system_encoding : unit -> string = "lt_unix_get_system_encoding" |
15 | 15 | |
16 | 16 | let sigwinch = get_sigwinch () |
17 | let system_encoding = get_system_encoding () | |
17 | ||
18 | (* Obtained by running the folliwing makefile in the "localedata" | |
19 | directory of the glibc: | |
20 | ||
21 | {[ | |
22 | include SUPPORTED | |
23 | all: | |
24 | @echo $(SUPPORTED-LOCALES) | sed 's/ /\n/g' | awk -F/ '$$1 ~ /[.]/ { next; }; { print " | \""$$1"\" -> \""$$2"\"" }' | |
25 | ]} | |
26 | *) | |
27 | let encoding_of_lang = function | |
28 | | "aa_DJ" -> "ISO-8859-1" | |
29 | | "aa_ER" -> "UTF-8" | |
30 | | "aa_ER@saaho" -> "UTF-8" | |
31 | | "aa_ET" -> "UTF-8" | |
32 | | "af_ZA" -> "ISO-8859-1" | |
33 | | "am_ET" -> "UTF-8" | |
34 | | "an_ES" -> "ISO-8859-15" | |
35 | | "ar_AE" -> "ISO-8859-6" | |
36 | | "ar_BH" -> "ISO-8859-6" | |
37 | | "ar_DZ" -> "ISO-8859-6" | |
38 | | "ar_EG" -> "ISO-8859-6" | |
39 | | "ar_IN" -> "UTF-8" | |
40 | | "ar_IQ" -> "ISO-8859-6" | |
41 | | "ar_JO" -> "ISO-8859-6" | |
42 | | "ar_KW" -> "ISO-8859-6" | |
43 | | "ar_LB" -> "ISO-8859-6" | |
44 | | "ar_LY" -> "ISO-8859-6" | |
45 | | "ar_MA" -> "ISO-8859-6" | |
46 | | "ar_OM" -> "ISO-8859-6" | |
47 | | "ar_QA" -> "ISO-8859-6" | |
48 | | "ar_SA" -> "ISO-8859-6" | |
49 | | "ar_SD" -> "ISO-8859-6" | |
50 | | "ar_SY" -> "ISO-8859-6" | |
51 | | "ar_TN" -> "ISO-8859-6" | |
52 | | "ar_YE" -> "ISO-8859-6" | |
53 | | "az_AZ" -> "UTF-8" | |
54 | | "as_IN" -> "UTF-8" | |
55 | | "ast_ES" -> "ISO-8859-15" | |
56 | | "be_BY" -> "CP1251" | |
57 | | "be_BY@latin" -> "UTF-8" | |
58 | | "bem_ZM" -> "UTF-8" | |
59 | | "ber_DZ" -> "UTF-8" | |
60 | | "ber_MA" -> "UTF-8" | |
61 | | "bg_BG" -> "CP1251" | |
62 | | "bn_BD" -> "UTF-8" | |
63 | | "bn_IN" -> "UTF-8" | |
64 | | "bo_CN" -> "UTF-8" | |
65 | | "bo_IN" -> "UTF-8" | |
66 | | "br_FR" -> "ISO-8859-1" | |
67 | | "br_FR@euro" -> "ISO-8859-15" | |
68 | | "bs_BA" -> "ISO-8859-2" | |
69 | | "byn_ER" -> "UTF-8" | |
70 | | "ca_AD" -> "ISO-8859-15" | |
71 | | "ca_ES" -> "ISO-8859-1" | |
72 | | "ca_ES@euro" -> "ISO-8859-15" | |
73 | | "ca_FR" -> "ISO-8859-15" | |
74 | | "ca_IT" -> "ISO-8859-15" | |
75 | | "crh_UA" -> "UTF-8" | |
76 | | "cs_CZ" -> "ISO-8859-2" | |
77 | | "csb_PL" -> "UTF-8" | |
78 | | "cv_RU" -> "UTF-8" | |
79 | | "cy_GB" -> "ISO-8859-14" | |
80 | | "da_DK" -> "ISO-8859-1" | |
81 | | "de_AT" -> "ISO-8859-1" | |
82 | | "de_AT@euro" -> "ISO-8859-15" | |
83 | | "de_BE" -> "ISO-8859-1" | |
84 | | "de_BE@euro" -> "ISO-8859-15" | |
85 | | "de_CH" -> "ISO-8859-1" | |
86 | | "de_DE" -> "ISO-8859-1" | |
87 | | "de_DE@euro" -> "ISO-8859-15" | |
88 | | "de_LU" -> "ISO-8859-1" | |
89 | | "de_LU@euro" -> "ISO-8859-15" | |
90 | | "dv_MV" -> "UTF-8" | |
91 | | "dz_BT" -> "UTF-8" | |
92 | | "el_GR" -> "ISO-8859-7" | |
93 | | "el_CY" -> "ISO-8859-7" | |
94 | | "en_AG" -> "UTF-8" | |
95 | | "en_AU" -> "ISO-8859-1" | |
96 | | "en_BW" -> "ISO-8859-1" | |
97 | | "en_CA" -> "ISO-8859-1" | |
98 | | "en_DK" -> "ISO-8859-1" | |
99 | | "en_GB" -> "ISO-8859-1" | |
100 | | "en_HK" -> "ISO-8859-1" | |
101 | | "en_IE" -> "ISO-8859-1" | |
102 | | "en_IE@euro" -> "ISO-8859-15" | |
103 | | "en_IN" -> "UTF-8" | |
104 | | "en_NG" -> "UTF-8" | |
105 | | "en_NZ" -> "ISO-8859-1" | |
106 | | "en_PH" -> "ISO-8859-1" | |
107 | | "en_SG" -> "ISO-8859-1" | |
108 | | "en_US" -> "ISO-8859-1" | |
109 | | "en_ZA" -> "ISO-8859-1" | |
110 | | "en_ZM" -> "UTF-8" | |
111 | | "en_ZW" -> "ISO-8859-1" | |
112 | | "es_AR" -> "ISO-8859-1" | |
113 | | "es_BO" -> "ISO-8859-1" | |
114 | | "es_CL" -> "ISO-8859-1" | |
115 | | "es_CO" -> "ISO-8859-1" | |
116 | | "es_CR" -> "ISO-8859-1" | |
117 | | "es_DO" -> "ISO-8859-1" | |
118 | | "es_EC" -> "ISO-8859-1" | |
119 | | "es_ES" -> "ISO-8859-1" | |
120 | | "es_ES@euro" -> "ISO-8859-15" | |
121 | | "es_GT" -> "ISO-8859-1" | |
122 | | "es_HN" -> "ISO-8859-1" | |
123 | | "es_MX" -> "ISO-8859-1" | |
124 | | "es_NI" -> "ISO-8859-1" | |
125 | | "es_PA" -> "ISO-8859-1" | |
126 | | "es_PE" -> "ISO-8859-1" | |
127 | | "es_PR" -> "ISO-8859-1" | |
128 | | "es_PY" -> "ISO-8859-1" | |
129 | | "es_SV" -> "ISO-8859-1" | |
130 | | "es_US" -> "ISO-8859-1" | |
131 | | "es_UY" -> "ISO-8859-1" | |
132 | | "es_VE" -> "ISO-8859-1" | |
133 | | "et_EE" -> "ISO-8859-1" | |
134 | | "eu_ES" -> "ISO-8859-1" | |
135 | | "eu_ES@euro" -> "ISO-8859-15" | |
136 | | "fa_IR" -> "UTF-8" | |
137 | | "ff_SN" -> "UTF-8" | |
138 | | "fi_FI" -> "ISO-8859-1" | |
139 | | "fi_FI@euro" -> "ISO-8859-15" | |
140 | | "fil_PH" -> "UTF-8" | |
141 | | "fo_FO" -> "ISO-8859-1" | |
142 | | "fr_BE" -> "ISO-8859-1" | |
143 | | "fr_BE@euro" -> "ISO-8859-15" | |
144 | | "fr_CA" -> "ISO-8859-1" | |
145 | | "fr_CH" -> "ISO-8859-1" | |
146 | | "fr_FR" -> "ISO-8859-1" | |
147 | | "fr_FR@euro" -> "ISO-8859-15" | |
148 | | "fr_LU" -> "ISO-8859-1" | |
149 | | "fr_LU@euro" -> "ISO-8859-15" | |
150 | | "fur_IT" -> "UTF-8" | |
151 | | "fy_NL" -> "UTF-8" | |
152 | | "fy_DE" -> "UTF-8" | |
153 | | "ga_IE" -> "ISO-8859-1" | |
154 | | "ga_IE@euro" -> "ISO-8859-15" | |
155 | | "gd_GB" -> "ISO-8859-15" | |
156 | | "gez_ER" -> "UTF-8" | |
157 | | "gez_ER@abegede" -> "UTF-8" | |
158 | | "gez_ET" -> "UTF-8" | |
159 | | "gez_ET@abegede" -> "UTF-8" | |
160 | | "gl_ES" -> "ISO-8859-1" | |
161 | | "gl_ES@euro" -> "ISO-8859-15" | |
162 | | "gu_IN" -> "UTF-8" | |
163 | | "gv_GB" -> "ISO-8859-1" | |
164 | | "ha_NG" -> "UTF-8" | |
165 | | "he_IL" -> "ISO-8859-8" | |
166 | | "hi_IN" -> "UTF-8" | |
167 | | "hne_IN" -> "UTF-8" | |
168 | | "hr_HR" -> "ISO-8859-2" | |
169 | | "hsb_DE" -> "ISO-8859-2" | |
170 | | "ht_HT" -> "UTF-8" | |
171 | | "hu_HU" -> "ISO-8859-2" | |
172 | | "hy_AM" -> "UTF-8" | |
173 | | "id_ID" -> "ISO-8859-1" | |
174 | | "ig_NG" -> "UTF-8" | |
175 | | "ik_CA" -> "UTF-8" | |
176 | | "is_IS" -> "ISO-8859-1" | |
177 | | "it_CH" -> "ISO-8859-1" | |
178 | | "it_IT" -> "ISO-8859-1" | |
179 | | "it_IT@euro" -> "ISO-8859-15" | |
180 | | "iu_CA" -> "UTF-8" | |
181 | | "iw_IL" -> "ISO-8859-8" | |
182 | | "ka_GE" -> "GEORGIAN-PS" | |
183 | | "kk_KZ" -> "PT154" | |
184 | | "kl_GL" -> "ISO-8859-1" | |
185 | | "km_KH" -> "UTF-8" | |
186 | | "kn_IN" -> "UTF-8" | |
187 | | "kok_IN" -> "UTF-8" | |
188 | | "ks_IN" -> "UTF-8" | |
189 | | "ks_IN@devanagari" -> "UTF-8" | |
190 | | "ku_TR" -> "ISO-8859-9" | |
191 | | "kw_GB" -> "ISO-8859-1" | |
192 | | "ky_KG" -> "UTF-8" | |
193 | | "lb_LU" -> "UTF-8" | |
194 | | "lg_UG" -> "ISO-8859-10" | |
195 | | "li_BE" -> "UTF-8" | |
196 | | "li_NL" -> "UTF-8" | |
197 | | "lij_IT" -> "UTF-8" | |
198 | | "lo_LA" -> "UTF-8" | |
199 | | "lt_LT" -> "ISO-8859-13" | |
200 | | "lv_LV" -> "ISO-8859-13" | |
201 | | "mai_IN" -> "UTF-8" | |
202 | | "mg_MG" -> "ISO-8859-15" | |
203 | | "mhr_RU" -> "UTF-8" | |
204 | | "mi_NZ" -> "ISO-8859-13" | |
205 | | "mk_MK" -> "ISO-8859-5" | |
206 | | "ml_IN" -> "UTF-8" | |
207 | | "mn_MN" -> "UTF-8" | |
208 | | "mr_IN" -> "UTF-8" | |
209 | | "ms_MY" -> "ISO-8859-1" | |
210 | | "mt_MT" -> "ISO-8859-3" | |
211 | | "my_MM" -> "UTF-8" | |
212 | | "nan_TW@latin" -> "UTF-8" | |
213 | | "nb_NO" -> "ISO-8859-1" | |
214 | | "nds_DE" -> "UTF-8" | |
215 | | "nds_NL" -> "UTF-8" | |
216 | | "ne_NP" -> "UTF-8" | |
217 | | "nl_AW" -> "UTF-8" | |
218 | | "nl_BE" -> "ISO-8859-1" | |
219 | | "nl_BE@euro" -> "ISO-8859-15" | |
220 | | "nl_NL" -> "ISO-8859-1" | |
221 | | "nl_NL@euro" -> "ISO-8859-15" | |
222 | | "nn_NO" -> "ISO-8859-1" | |
223 | | "nr_ZA" -> "UTF-8" | |
224 | | "nso_ZA" -> "UTF-8" | |
225 | | "oc_FR" -> "ISO-8859-1" | |
226 | | "om_ET" -> "UTF-8" | |
227 | | "om_KE" -> "ISO-8859-1" | |
228 | | "or_IN" -> "UTF-8" | |
229 | | "os_RU" -> "UTF-8" | |
230 | | "pa_IN" -> "UTF-8" | |
231 | | "pa_PK" -> "UTF-8" | |
232 | | "pap_AN" -> "UTF-8" | |
233 | | "pl_PL" -> "ISO-8859-2" | |
234 | | "ps_AF" -> "UTF-8" | |
235 | | "pt_BR" -> "ISO-8859-1" | |
236 | | "pt_PT" -> "ISO-8859-1" | |
237 | | "pt_PT@euro" -> "ISO-8859-15" | |
238 | | "ro_RO" -> "ISO-8859-2" | |
239 | | "ru_RU" -> "ISO-8859-5" | |
240 | | "ru_UA" -> "KOI8-U" | |
241 | | "rw_RW" -> "UTF-8" | |
242 | | "sa_IN" -> "UTF-8" | |
243 | | "sc_IT" -> "UTF-8" | |
244 | | "sd_IN" -> "UTF-8" | |
245 | | "sd_IN@devanagari" -> "UTF-8" | |
246 | | "se_NO" -> "UTF-8" | |
247 | | "shs_CA" -> "UTF-8" | |
248 | | "si_LK" -> "UTF-8" | |
249 | | "sid_ET" -> "UTF-8" | |
250 | | "sk_SK" -> "ISO-8859-2" | |
251 | | "sl_SI" -> "ISO-8859-2" | |
252 | | "so_DJ" -> "ISO-8859-1" | |
253 | | "so_ET" -> "UTF-8" | |
254 | | "so_KE" -> "ISO-8859-1" | |
255 | | "so_SO" -> "ISO-8859-1" | |
256 | | "sq_AL" -> "ISO-8859-1" | |
257 | | "sq_MK" -> "UTF-8" | |
258 | | "sr_ME" -> "UTF-8" | |
259 | | "sr_RS" -> "UTF-8" | |
260 | | "sr_RS@latin" -> "UTF-8" | |
261 | | "ss_ZA" -> "UTF-8" | |
262 | | "st_ZA" -> "ISO-8859-1" | |
263 | | "sv_FI" -> "ISO-8859-1" | |
264 | | "sv_FI@euro" -> "ISO-8859-15" | |
265 | | "sv_SE" -> "ISO-8859-1" | |
266 | | "sw_KE" -> "UTF-8" | |
267 | | "sw_TZ" -> "UTF-8" | |
268 | | "ta_IN" -> "UTF-8" | |
269 | | "te_IN" -> "UTF-8" | |
270 | | "tg_TJ" -> "KOI8-T" | |
271 | | "th_TH" -> "TIS-620" | |
272 | | "ti_ER" -> "UTF-8" | |
273 | | "ti_ET" -> "UTF-8" | |
274 | | "tig_ER" -> "UTF-8" | |
275 | | "tk_TM" -> "UTF-8" | |
276 | | "tl_PH" -> "ISO-8859-1" | |
277 | | "tn_ZA" -> "UTF-8" | |
278 | | "tr_CY" -> "ISO-8859-9" | |
279 | | "tr_TR" -> "ISO-8859-9" | |
280 | | "ts_ZA" -> "UTF-8" | |
281 | | "tt_RU" -> "UTF-8" | |
282 | | "tt_RU@iqtelif" -> "UTF-8" | |
283 | | "ug_CN" -> "UTF-8" | |
284 | | "uk_UA" -> "KOI8-U" | |
285 | | "ur_PK" -> "UTF-8" | |
286 | | "uz_UZ" -> "ISO-8859-1" | |
287 | | "uz_UZ@cyrillic" -> "UTF-8" | |
288 | | "ve_ZA" -> "UTF-8" | |
289 | | "vi_VN" -> "UTF-8" | |
290 | | "wa_BE" -> "ISO-8859-1" | |
291 | | "wa_BE@euro" -> "ISO-8859-15" | |
292 | | "wae_CH" -> "UTF-8" | |
293 | | "wo_SN" -> "UTF-8" | |
294 | | "xh_ZA" -> "ISO-8859-1" | |
295 | | "yi_US" -> "CP1255" | |
296 | | "yo_NG" -> "UTF-8" | |
297 | | "yue_HK" -> "UTF-8" | |
298 | | "zh_CN" -> "GB2312" | |
299 | | "zh_HK" -> "BIG5-HKSCS" | |
300 | | "zh_SG" -> "GB2312" | |
301 | | "zh_TW" -> "BIG5" | |
302 | | "zu_ZA" -> "ISO-8859-1" | |
303 | | _ -> "ASCII" | |
304 | ||
305 | let system_encoding = | |
306 | match get_system_encoding () with | |
307 | | "" -> begin | |
308 | match try Some (Sys.getenv "LANG") with Not_found -> None with | |
309 | | None -> | |
310 | "ASCII" | |
311 | | Some lang -> | |
312 | match try Some (String.index lang '.') with Not_found -> None with | |
313 | | None -> | |
314 | encoding_of_lang lang | |
315 | | Some idx -> | |
316 | String.sub lang (idx + 1) (String.length lang - idx - 1) | |
317 | end | |
318 | | enc -> | |
319 | enc | |
18 | 320 | |
19 | 321 | (* +-----------------------------------------------------------------+ |
20 | 322 | | Parsing of encoded characters | |
21 | 323 | +-----------------------------------------------------------------+ *) |
22 | 324 | |
23 | exception Fallback | |
24 | ||
25 | let parse_char cd st first_byte = | |
26 | let open LTerm_iconv in | |
27 | let src = { | |
28 | bytes = String.create 128; | |
29 | index = 0; | |
30 | limit = 1; | |
31 | } | |
32 | and dst = { | |
33 | bytes = String.create 4; | |
34 | index = 0; | |
35 | limit = 4; | |
36 | } in | |
325 | class output_single (cell : UChar.t option ref) = object | |
326 | method put char = cell := Some char | |
327 | method flush () = () | |
328 | method close_out () = () | |
329 | end | |
330 | ||
331 | let parse_char encoding st first_byte = | |
332 | let cell = ref None in | |
333 | let output = new CharEncoding.convert_uchar_output encoding (new output_single cell) in | |
37 | 334 | let rec loop st = |
38 | try | |
39 | iconv cd ~src ~dst; | |
40 | return | |
41 | (UChar.of_int | |
42 | ((Char.code dst.bytes.[0] lsl 24) | |
43 | lor (Char.code dst.bytes.[1] lsl 16) | |
44 | lor (Char.code dst.bytes.[2] lsl 8) | |
45 | lor (Char.code dst.bytes.[3]))) | |
46 | with | |
47 | | Invalid_sequence -> | |
48 | raise_lwt Fallback | |
49 | | Unterminated_sequence -> | |
50 | Lwt_stream.get st >>= function | |
51 | | Some ch -> | |
52 | src.bytes.[src.limit] <- ch; | |
53 | src.limit <- src.limit + 1; | |
54 | loop st | |
55 | | None -> | |
56 | raise_lwt Fallback | |
335 | match !cell with | |
336 | | Some char -> | |
337 | return char | |
338 | | None -> | |
339 | lwt byte = Lwt_stream.next st in | |
340 | assert (output#output (String.make 1 byte) 0 1 = 1); | |
341 | output#flush (); | |
342 | loop st | |
57 | 343 | in |
58 | 344 | try_lwt |
59 | src.bytes.[0] <- first_byte; | |
60 | reset cd; | |
345 | assert (output#output (String.make 1 first_byte) 0 1 = 1); | |
61 | 346 | Lwt_stream.parse st loop |
62 | with | |
63 | | Fallback -> | |
64 | return (UChar.of_char first_byte) | |
347 | with CharEncoding.Malformed_code | Lwt_stream.Empty -> | |
348 | return (UChar.of_char first_byte) | |
65 | 349 | |
66 | 350 | (* +-----------------------------------------------------------------+ |
67 | 351 | | Input of escape sequence | |
550 | 834 | in |
551 | 835 | loop 0 (Array.length sequences) |
552 | 836 | |
553 | let rec parse_event ?(escape_time = 0.1) cd stream = | |
837 | let rec parse_event ?(escape_time = 0.1) encoding stream = | |
554 | 838 | lwt byte = Lwt_stream.next stream in |
555 | 839 | match byte with |
556 | 840 | | '\x1b' -> begin |
586 | 870 | | _ -> raise Exit); |
587 | 871 | }) |
588 | 872 | with Exit -> |
589 | parse_event cd stream | |
873 | parse_event encoding stream | |
590 | 874 | end |
591 | 875 | | seq -> |
592 | 876 | match find_sequence seq with |
637 | 921 | return(LTerm_event.Key { control = false; meta = true; shift = false; code = Char(UChar.of_char byte) }) |
638 | 922 | | byte' -> |
639 | 923 | lwt () = Lwt_stream.junk stream in |
640 | lwt code = parse_char cd stream byte' in | |
924 | lwt code = parse_char encoding stream byte' in | |
641 | 925 | return (LTerm_event.Key { control = false; meta = true; shift = false; code = Char code }) |
642 | 926 | end |
643 | 927 | | '\x00' .. '\x1f' -> |
652 | 936 | return (LTerm_event.Key { control = false; meta = false; shift = false; code = Char(UChar.of_char byte) }) |
653 | 937 | | _ -> |
654 | 938 | (* Encoded characters *) |
655 | lwt code = parse_char cd stream byte in | |
939 | lwt code = parse_char encoding stream byte in | |
656 | 940 | return (LTerm_event.Key { control = false; meta = false; shift = false; code = Char code }) |
8 | 8 | |
9 | 9 | (** Unix specific functions *) |
10 | 10 | |
11 | open CamomileLibraryDyn.Camomile | |
12 | ||
11 | 13 | val sigwinch : int option |
12 | 14 | (** The number of the signal used to indicate that the terminal size |
13 | 15 | have changed. It is [None] on windows. *) |
15 | 17 | val system_encoding : string |
16 | 18 | (** The encoding used by the system. *) |
17 | 19 | |
18 | val parse_event : ?escape_time : float -> LTerm_iconv.t -> char Lwt_stream.t -> LTerm_event.t Lwt.t | |
19 | (** [parse_event cd stream] parses one event from the given input | |
20 | stream. [cd] is the conversion descriptor used to decode | |
21 | non-ascii characters. It must be a converter from the stream | |
22 | encoding to "UCS-4BE". If an invalid sequence is encountered in | |
23 | the input, it fallbacks to Latin-1. [escape_time] is the time | |
24 | waited before returning the escape key. It defaults to [0.1]. *) | |
20 | val parse_event : ?escape_time : float -> CharEncoding.t -> char Lwt_stream.t -> LTerm_event.t Lwt.t | |
21 | (** [parse_event encoding stream] parses one event from the given | |
22 | input stream. [encoding] is the character encoding used to | |
23 | decode non-ascii characters. It must be a converter from the | |
24 | stream encoding to "UCS-4BE". If an invalid sequence is | |
25 | encountered in the input, it fallbacks to Latin-1. [escape_time] | |
26 | is the time waited before returning the escape key. It defaults | |
27 | to [0.1]. *) |
21 | 21 | |
22 | 22 | CAMLprim value lt_unix_get_system_encoding() |
23 | 23 | { |
24 | char codeset[128]; | |
25 | sprintf(codeset, "CP%d", GetACP()); | |
26 | return caml_copy_string(codeset); | |
24 | return caml_copy_string(""); | |
27 | 25 | } |
28 | 26 | |
29 | 27 | #else |
815 | 815 | (* A event from the terminal. *) |
816 | 816 | |
817 | 817 | let lambda_termrc = |
818 | Filename.concat (try Sys.getenv "HOME" with Not_found -> "") ".lambda-termrc" | |
818 | Filename.concat LTerm_resources.home ".lambda-termrc" | |
819 | 819 | |
820 | 820 | let file_exists file = |
821 | 821 | try_lwt |
101 | 101 | { |
102 | 102 | DWORD event_count; |
103 | 103 | INPUT_RECORD *input = &(job->input); |
104 | WORD code; | |
105 | int i; | |
106 | DWORD bs; | |
104 | 107 | |
105 | 108 | for (;;) { |
106 | if (!ReadConsoleInput(job->handle, input, 1, &event_count)) { | |
109 | if (!ReadConsoleInputW(job->handle, input, 1, &event_count)) { | |
107 | 110 | job->error_code = GetLastError(); |
108 | 111 | return; |
109 | 112 | } |
113 | 116 | if (input->Event.KeyEvent.bKeyDown) { |
114 | 117 | if (input->Event.KeyEvent.uChar.UnicodeChar) |
115 | 118 | return; |
116 | WORD code = input->Event.KeyEvent.wVirtualKeyCode; | |
117 | int i; | |
119 | code = input->Event.KeyEvent.wVirtualKeyCode; | |
118 | 120 | for (i = 0; i < sizeof(code_table)/sizeof(code_table[0]); i++) |
119 | 121 | if (code == code_table[i]) |
120 | 122 | return; |
121 | 123 | } |
122 | 124 | break; |
123 | 125 | case MOUSE_EVENT: { |
124 | DWORD bs = input->Event.MouseEvent.dwButtonState; | |
126 | bs = input->Event.MouseEvent.dwButtonState; | |
125 | 127 | if (!(input->Event.MouseEvent.dwEventFlags & MOUSE_MOVED) && |
126 | 128 | bs & (FROM_LEFT_1ST_BUTTON_PRESSED | |
127 | 129 | FROM_LEFT_2ND_BUTTON_PRESSED | |
148 | 150 | |
149 | 151 | CAMLprim value lt_windows_read_console_input_result(value val_job) |
150 | 152 | { |
153 | INPUT_RECORD *input; | |
154 | DWORD cks, bs; | |
155 | WORD code; | |
156 | int i; | |
151 | 157 | CAMLparam1(val_job); |
152 | 158 | CAMLlocal3(result, x, y); |
153 | 159 | struct job_read_console_input *job = Job_read_console_input_val(val_job); |
155 | 161 | win32_maperr(job->error_code); |
156 | 162 | uerror("ReadConsoleInput", Nothing); |
157 | 163 | } |
158 | INPUT_RECORD *input = &(job->input); | |
164 | input = &(job->input); | |
159 | 165 | switch (input->EventType) { |
160 | 166 | case KEY_EVENT: { |
161 | 167 | result = caml_alloc(1, 0); |
162 | 168 | x = caml_alloc_tuple(4); |
163 | 169 | Field(result, 0) = x; |
164 | DWORD cks = input->Event.KeyEvent.dwControlKeyState; | |
170 | cks = input->Event.KeyEvent.dwControlKeyState; | |
165 | 171 | Field(x, 0) = Val_bool((cks & LEFT_CTRL_PRESSED) | (cks & RIGHT_CTRL_PRESSED)); |
166 | 172 | Field(x, 1) = Val_bool((cks & LEFT_ALT_PRESSED) | (cks & RIGHT_ALT_PRESSED)); |
167 | 173 | Field(x, 2) = Val_bool(cks & SHIFT_PRESSED); |
168 | WORD code = input->Event.KeyEvent.wVirtualKeyCode; | |
169 | int i; | |
174 | code = input->Event.KeyEvent.wVirtualKeyCode; | |
170 | 175 | for (i = 0; i < sizeof(code_table)/sizeof(code_table[0]); i++) |
171 | 176 | if (code == code_table[i]) { |
172 | 177 | Field(x, 3) = Val_int(i); |
181 | 186 | result = caml_alloc(1, 1); |
182 | 187 | x = caml_alloc_tuple(6); |
183 | 188 | Field(result, 0) = x; |
184 | DWORD cks = input->Event.MouseEvent.dwControlKeyState; | |
189 | cks = input->Event.MouseEvent.dwControlKeyState; | |
185 | 190 | Field(x, 0) = Val_bool((cks & LEFT_CTRL_PRESSED) | (cks & RIGHT_CTRL_PRESSED)); |
186 | 191 | Field(x, 1) = Val_bool((cks & LEFT_ALT_PRESSED) | (cks & RIGHT_ALT_PRESSED)); |
187 | 192 | Field(x, 2) = Val_bool(cks & SHIFT_PRESSED); |
188 | 193 | Field(x, 4) = Val_int(input->Event.MouseEvent.dwMousePosition.Y); |
189 | 194 | Field(x, 5) = Val_int(input->Event.MouseEvent.dwMousePosition.X); |
190 | DWORD bs = input->Event.MouseEvent.dwButtonState; | |
195 | bs = input->Event.MouseEvent.dwButtonState; | |
191 | 196 | if (bs & FROM_LEFT_1ST_BUTTON_PRESSED) |
192 | 197 | Field(x, 3) = Val_int(0); |
193 | 198 | else if (bs & FROM_LEFT_2ND_BUTTON_PRESSED) |
222 | 227 | CAMLlocal2(result, x); |
223 | 228 | |
224 | 229 | CONSOLE_SCREEN_BUFFER_INFO info; |
230 | int color; | |
225 | 231 | |
226 | 232 | if (!GetConsoleScreenBufferInfo(Handle_val(val_fd), &info)) { |
227 | 233 | win32_maperr(GetLastError()); |
241 | 247 | Field(result, 1) = x; |
242 | 248 | |
243 | 249 | x = caml_alloc_tuple(2); |
244 | int color = 0; | |
250 | color = 0; | |
245 | 251 | if (info.wAttributes & FOREGROUND_RED) color |= 1; |
246 | 252 | if (info.wAttributes & FOREGROUND_GREEN) color |= 2; |
247 | 253 | if (info.wAttributes & FOREGROUND_BLUE) color |= 4; |
277 | 283 | CAMLprim value lt_windows_get_console_mode(value val_fd) |
278 | 284 | { |
279 | 285 | DWORD mode; |
286 | value result; | |
280 | 287 | |
281 | 288 | if (!GetConsoleMode(Handle_val(val_fd), &mode)) { |
282 | 289 | win32_maperr(GetLastError()); |
283 | 290 | uerror("GetConsoleMode", Nothing); |
284 | 291 | } |
285 | 292 | |
286 | value result = caml_alloc_tuple(7); | |
293 | result = caml_alloc_tuple(7); | |
287 | 294 | Field(result, 0) = Val_bool(mode & ENABLE_ECHO_INPUT); |
288 | 295 | Field(result, 1) = Val_bool(mode & ENABLE_INSERT_MODE); |
289 | 296 | Field(result, 2) = Val_bool(mode & ENABLE_LINE_INPUT); |
320 | 327 | CAMLprim value lt_windows_get_console_cursor_info(value val_fd) |
321 | 328 | { |
322 | 329 | CONSOLE_CURSOR_INFO info; |
330 | value result; | |
323 | 331 | if (!GetConsoleCursorInfo(Handle_val(val_fd), &info)) { |
324 | 332 | win32_maperr(GetLastError()); |
325 | 333 | uerror("GetConsoleCursorInfo", Nothing); |
326 | 334 | } |
327 | value result = caml_alloc_tuple(2); | |
335 | result = caml_alloc_tuple(2); | |
328 | 336 | Field(result, 0) = Val_int(info.dwSize); |
329 | 337 | Field(result, 1) = Val_bool(info.bVisible); |
330 | 338 | return result; |
390 | 398 | CAMLparam5(val_fd, val_chars, val_size, val_coord, val_rect); |
391 | 399 | CAMLlocal1(result); |
392 | 400 | |
401 | value line, src; | |
402 | int fg, bg; | |
403 | WORD attrs; | |
393 | 404 | int lines = Int_val(Field(val_size, 0)); |
394 | 405 | int columns = Int_val(Field(val_size, 1)); |
406 | COORD size; | |
407 | COORD coord; | |
408 | SMALL_RECT rect; | |
395 | 409 | |
396 | 410 | /* Convert characters */ |
397 | CHAR_INFO buffer[lines * columns]; | |
411 | CHAR_INFO *buffer = (CHAR_INFO*)lwt_unix_malloc(lines * columns * sizeof (CHAR_INFO)); | |
398 | 412 | int l, c; |
399 | 413 | CHAR_INFO *dst = buffer; |
400 | 414 | for (l = 0; l < lines; l++) { |
401 | value line = Field(val_chars, l); | |
415 | line = Field(val_chars, l); | |
402 | 416 | for (c = 0; c < columns; c++) { |
403 | value src = Field(line, c); | |
417 | src = Field(line, c); | |
404 | 418 | dst->Char.UnicodeChar = Int_val(Field(src, 0)); |
405 | int fg = Int_val(Field(src, 1)); | |
406 | int bg = Int_val(Field(src, 2)); | |
407 | WORD attrs = 0; | |
419 | fg = Int_val(Field(src, 1)); | |
420 | bg = Int_val(Field(src, 2)); | |
421 | attrs = 0; | |
408 | 422 | if (fg & 1) attrs |= FOREGROUND_RED; |
409 | 423 | if (fg & 2) attrs |= FOREGROUND_GREEN; |
410 | 424 | if (fg & 4) attrs |= FOREGROUND_BLUE; |
418 | 432 | } |
419 | 433 | } |
420 | 434 | |
421 | COORD size; | |
422 | COORD coord; | |
423 | SMALL_RECT rect; | |
424 | 435 | size.X = Int_val(Field(val_size, 1)); |
425 | 436 | size.Y = Int_val(Field(val_size, 0)); |
426 | 437 | coord.X = Int_val(Field(val_coord, 1)); |
430 | 441 | rect.Bottom = Int_val(Field(val_rect, 2)) - 1; |
431 | 442 | rect.Right = Int_val(Field(val_rect, 3)) - 1; |
432 | 443 | |
433 | if (!WriteConsoleOutput(Handle_val(val_fd), buffer, size, coord, &rect)) { | |
444 | if (!WriteConsoleOutputW(Handle_val(val_fd), buffer, size, coord, &rect)) { | |
445 | free(buffer); | |
434 | 446 | win32_maperr(GetLastError()); |
435 | 447 | uerror("WriteConsoleOutput", Nothing); |
436 | 448 | } |
449 | free(buffer); | |
437 | 450 | |
438 | 451 | result = caml_alloc_tuple(4); |
439 | 452 | Field(result, 0) = Val_int(rect.Top); |
0 | 0 | # OASIS_START |
1 | # DO NOT EDIT (digest: 3e2cc76824806ede32cd9445818f443f) | |
1 | # DO NOT EDIT (digest: ba3c322b421c5f64349e83e10a4f7083) | |
2 | 2 | LTerm |
3 | 3 | LTerm_key |
4 | 4 | LTerm_event |
5 | 5 | LTerm_unix |
6 | 6 | LTerm_windows |
7 | LTerm_iconv | |
8 | 7 | LTerm_style |
9 | 8 | LTerm_geom |
10 | 9 | LTerm_draw |
11 | 10 | LTerm_mouse |
12 | LTerm_color_mappings | |
13 | 11 | LTerm_widget |
14 | 12 | LTerm_edit |
15 | 13 | LTerm_read_line |
17 | 15 | LTerm_ui |
18 | 16 | LTerm_resources |
19 | 17 | LTerm_inputrc |
18 | LTerm_history | |
19 | LTerm_color_mappings | |
20 | 20 | LTerm_resource_lexer |
21 | 21 | # OASIS_STOP |
0 | # OASIS_START | |
1 | # DO NOT EDIT (digest: c959c1b9ca2c18f5e593c40365cee41b) | |
2 | lTerm_term_stubs.o | |
3 | lTerm_unix_stubs.o | |
4 | lTerm_windows_stubs.o | |
5 | lTerm_iconv_stubs.o | |
6 | # OASIS_STOP |
0 | # OASIS_START | |
1 | # DO NOT EDIT (digest: dff6f3d31800f198b7eea874f030ab42) | |
2 | lTerm_term_stubs.o | |
3 | lTerm_unix_stubs.o | |
4 | lTerm_windows_stubs.o | |
5 | # OASIS_STOP |
0 | (* | |
1 | * history_stress_test.ml | |
2 | * ---------------------- | |
3 | * Copyright : (c) 2012, Jeremie Dimino <jeremie@dimino.org> | |
4 | * Licence : BSD3 | |
5 | * | |
6 | * This file is a part of Lambda-Term. | |
7 | *) | |
8 | ||
9 | (* Start n processes, adding entries [k, k + n, k + n * 2, ... k + n * | |
10 | count] to their history. Between each addition, they save their | |
11 | history to the same file. | |
12 | ||
13 | At the end the parent check that the history contains all numbers | |
14 | from [0] to [n - 1 + n * count]. *) | |
15 | ||
16 | open Lwt | |
17 | ||
18 | let rec check nproc count n l = | |
19 | match l with | |
20 | | [] -> | |
21 | n = nproc * (count + 1) | |
22 | | p :: l -> | |
23 | n = p && check nproc count (n + 1) l | |
24 | ||
25 | let rec start_procs name fn nproc count k = | |
26 | if k = nproc then | |
27 | [] | |
28 | else | |
29 | let t = | |
30 | lwt status = Lwt_process.exec (name, [|name; fn; string_of_int nproc; string_of_int count; string_of_int k|]) in | |
31 | assert (status = Unix.WEXITED 0); | |
32 | return () | |
33 | in | |
34 | t :: start_procs name fn nproc count (k + 1) | |
35 | ||
36 | let () = | |
37 | match Sys.argv with | |
38 | | [|name; fn; s1; s2|] -> | |
39 | Lwt_main.run ( | |
40 | if Sys.file_exists fn then Sys.remove fn; | |
41 | let nproc = int_of_string s1 | |
42 | and count = int_of_string s2 in | |
43 | lwt () = join (start_procs name fn nproc count 0) in | |
44 | let history = LTerm_history.create [] in | |
45 | lwt () = LTerm_history.load history fn in | |
46 | Sys.remove fn; | |
47 | if check nproc count 0 (List.sort compare (List.map int_of_string (LTerm_history.contents history))) then begin | |
48 | prerr_endline "success"; | |
49 | exit 0 | |
50 | end else begin | |
51 | prerr_endline "failure"; | |
52 | exit 1 | |
53 | end | |
54 | ) | |
55 | | [|name; fn; s1; s2; s3|] -> | |
56 | Lwt_main.run ( | |
57 | let nproc = int_of_string s1 | |
58 | and count = int_of_string s2 | |
59 | and start = int_of_string s3 in | |
60 | let history = LTerm_history.create [] in | |
61 | for_lwt i = 0 to count do | |
62 | LTerm_history.add history (string_of_int (start + i * nproc)); | |
63 | assert (LTerm_history.length history = i + 1 && LTerm_history.old_count history = i); | |
64 | LTerm_history.save history fn | |
65 | done | |
66 | ) | |
67 | | _ -> | |
68 | Printf.eprintf "usage: %s <file> <nproc> <count>\n" Sys.argv.(0); | |
69 | exit 2 |