Codebase list lambda-term / 9c0e4c5
Imported Upstream version 1.4 Lifeng Sun 10 years ago
45 changed file(s) with 7323 addition(s) and 3650 deletion(s). Raw diff Collapse all Expand all
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
.project less more
0 Lambda-Term
+0
-13
CHANGES less more
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
-455
CHANGES.darcs less more
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>
11 All rights reserved.
22 Redistribution and use in source and binary forms, with or without
33 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
26
3 SETUP = ocaml setup.ml
7 # Set to setup.exe for the release
8 SETUP := setup.exe
49
5 build: setup.data
6 $(SETUP) -build $(BUILDFLAGS)
10 # Default rule
11 default: build
712
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.*
1019
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
1324
14 all:
15 $(SETUP) -all $(ALLFLAGS)
25 build: $(SETUP) setup.data
26 ./$(SETUP) -build $(BUILDFLAGS)
1627
17 install: setup.data
18 $(SETUP) -install $(INSTALLFLAGS)
28 doc: $(SETUP) setup.data build
29 ./$(SETUP) -doc $(DOCFLAGS)
1930
20 uninstall: setup.data
21 $(SETUP) -uninstall $(UNINSTALLFLAGS)
31 test: $(SETUP) setup.data build
32 ./$(SETUP) -test $(TESTFLAGS)
2233
23 reinstall: setup.data
24 $(SETUP) -reinstall $(REINSTALLFLAGS)
34 all: $(SETUP)
35 ./$(SETUP) -all $(ALLFLAGS)
2536
26 clean:
27 $(SETUP) -clean $(CLEANFLAGS)
37 install: $(SETUP) setup.data
38 ./$(SETUP) -install $(INSTALLFLAGS)
2839
29 distclean:
30 $(SETUP) -distclean $(DISTCLEANFLAGS)
40 uninstall: $(SETUP) setup.data
41 ./$(SETUP) -uninstall $(UNINSTALLFLAGS)
3142
32 setup.data:
33 $(SETUP) -configure $(CONFIGUREFLAGS)
43 reinstall: $(SETUP) setup.data
44 ./$(SETUP) -reinstall $(REINSTALLFLAGS)
3445
35 .PHONY: build doc test all install uninstall reinstall clean distclean configure
46 clean: $(SETUP)
47 ./$(SETUP) -clean $(CLEANFLAGS)
3648
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.
11 # | Package parameters |
22 # +-------------------------------------------------------------------+
33
4 OASISFormat: 0.1
4 OASISFormat: 0.3
55 OCamlVersion: >= 3.12
66 Name: lambda-term
7 Version: 1.1
7 Version: 1.4
88 LicenseFile: LICENSE
99 License: BSD3
1010 Authors: Jérémie Dimino
1111 Homepage: http://lambda-term.forge.ocamlcore.org/
1212 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.
1628
1729 # +-------------------------------------------------------------------+
1830 # | The library |
2032
2133 Library "lambda-term"
2234 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)
2436 XMETADescription: Corss-platform library for terminal manipulation
2537 XMETARequires: lwt.unix, lwt.react, zed
2638 Path: src
3143 LTerm_event,
3244 LTerm_unix,
3345 LTerm_windows,
34 LTerm_iconv,
3546 LTerm_style,
3647 LTerm_geom,
3748 LTerm_draw,
3849 LTerm_mouse,
39 LTerm_color_mappings,
4050 LTerm_widget,
4151 LTerm_edit,
4252 LTerm_read_line,
4353 LTerm_text,
4454 LTerm_ui,
4555 LTerm_resources,
46 LTerm_inputrc
56 LTerm_inputrc,
57 LTerm_history
4758 InternalModules:
59 LTerm_color_mappings,
4860 LTerm_resource_lexer
4961 CSources:
5062 lTerm_term_stubs.c,
5163 lTerm_unix_stubs.c,
52 lTerm_windows_stubs.c,
53 lTerm_iconv_stubs.c
64 lTerm_windows_stubs.c
5465
5566 # +-------------------------------------------------------------------+
5667 # | Examples |
152163 BuildDepends: lambda-term
153164
154165 # +-------------------------------------------------------------------+
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 # +-------------------------------------------------------------------+
155177 # | Doc |
156178 # +-------------------------------------------------------------------+
157179
158180 Document "lambda-term-api"
159181 Title: API reference for Lambda-Term
160 Type: ocamlbuild (0.2)
182 Type: ocamlbuild (0.3)
161183 Install: true
162184 InstallDir: $htmldir/api
163185 DataFiles: style.css
170192 # +-------------------------------------------------------------------+
171193
172194 Document "lambda-term-actions-man"
173 Type: custom (0.2)
195 Type: custom (0.3)
174196 Title: Man page for lambda-term-actions
175197 Install: true
176198 BuildTools: gzip
180202 InstallDir: $mandir/man1
181203
182204 Document "lambda-term-inputrc-man"
183 Type: custom (0.2)
205 Type: custom (0.3)
184206 Title: Man page for ~/.lambda-term-inputrc
185207 Install: true
186208 BuildTools: gzip
194216 # +-------------------------------------------------------------------+
195217
196218 Document "lamda-term-inputrc"
197 Type: custom (0.2)
219 Type: custom (0.3)
198220 Title: lambda-term-inputrc example
199221 XCustom: true
200222 Install: true
205227 # +-------------------------------------------------------------------+
206228
207229 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
+107
-100
_tags less more
22 <src/*>: use_iconv
33
44 # OASIS_START
5 # DO NOT EDIT (digest: df02cf32ec7f7460394286f1bdb3ea6d)
5 # DO NOT EDIT (digest: e78fd8b9674dd1ec0d4b08a2700288d0)
66 # Ignore VCS directories, you can use the same kind of rule outside
77 # OASIS_START/STOP if you want to exclude directories that contains
88 # useless stuff for the build process
1717 "_darcs": -traverse
1818 "_darcs": not_hygienic
1919 # Library lambda-term
20 "src": include
2120 "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
2423 <src/*.ml{,i}>: pkg_lwt.unix
2524 <src/*.ml{,i}>: pkg_lwt.syntax
2625 <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
2928 "src/lTerm_term_stubs.c": pkg_lwt.unix
3029 "src/lTerm_term_stubs.c": pkg_lwt.syntax
3130 "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
3433 "src/lTerm_unix_stubs.c": pkg_lwt.unix
3534 "src/lTerm_unix_stubs.c": pkg_lwt.syntax
3635 "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
3938 "src/lTerm_windows_stubs.c": pkg_lwt.unix
4039 "src/lTerm_windows_stubs.c": pkg_lwt.syntax
4140 "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
4898 # Executable shell
4999 <examples/shell.{native,byte}>: use_lambda-term
50 <examples/shell.{native,byte}>: pkg_zed
51100 <examples/shell.{native,byte}>: pkg_str
101 <examples/shell.{native,byte}>: pkg_lwt
52102 <examples/shell.{native,byte}>: pkg_lwt.unix
53103 <examples/shell.{native,byte}>: pkg_lwt.syntax
54104 <examples/shell.{native,byte}>: pkg_lwt.react
55 <examples/shell.{native,byte}>: pkg_lwt
105 <examples/shell.{native,byte}>: pkg_zed
56106 <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
78107 # Executable read-password
79108 <examples/read_password.{native,byte}>: use_lambda-term
80 <examples/read_password.{native,byte}>: pkg_zed
109 <examples/read_password.{native,byte}>: pkg_lwt
81110 <examples/read_password.{native,byte}>: pkg_lwt.unix
82111 <examples/read_password.{native,byte}>: pkg_lwt.syntax
83112 <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
92134 # Executable lambda-term-actions
93135 <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
95137 <tools/lambda_term_actions.{native,byte}>: pkg_lwt.unix
96138 <tools/lambda_term_actions.{native,byte}>: pkg_lwt.syntax
97139 <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
99141 <tools/*.ml{,i}>: use_lambda-term
100 <tools/*.ml{,i}>: pkg_zed
142 <tools/*.ml{,i}>: pkg_lwt
101143 <tools/*.ml{,i}>: pkg_lwt.unix
102144 <tools/*.ml{,i}>: pkg_lwt.syntax
103145 <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
153160 # OASIS_STOP
7171 B_fg(if exit_code = 0 then lwhite else lred); S code; E_fg;
7272 S" ]─";
7373 E_fg;
74 S"\n";
7475
7576 B_fg lred; S(try Sys.getenv "USER" with Not_found -> ""); E_fg;
7677 B_fg lgreen; S"@"; E_fg;
144145 lwt binaries = get_binaries () in
145146 match_lwt
146147 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
148149 return (Some command)
149150 with Sys.Break ->
150151 return None
151152 with
152153 | 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;
154162 loop
155163 term
156 (LTerm_read_line.add_entry command history)
164 history
157165 (match status with
158166 | Unix.WEXITED code -> code
159167 | Unix.WSIGNALED code -> code
169177 lwt () = LTerm_inputrc.load () in
170178 try_lwt
171179 lwt term = Lazy.force LTerm.stdout in
172 loop term [] 0
180 loop term (LTerm_history.create []) 0
173181 with LTerm_read_line.Interrupt ->
174182 return ()
00 # OASIS_START
1 # DO NOT EDIT (digest: 15b3d54b2e5297018fc18ed5e78346ec)
1 # DO NOT EDIT (digest: 018d09151b8f722e940e6273f7eea50b)
22 src/LTerm
33 src/LTerm_key
44 src/LTerm_event
55 src/LTerm_unix
66 src/LTerm_windows
7 src/LTerm_iconv
87 src/LTerm_style
98 src/LTerm_geom
109 src/LTerm_draw
1110 src/LTerm_mouse
12 src/LTerm_color_mappings
1311 src/LTerm_widget
1412 src/LTerm_edit
1513 src/LTerm_read_line
1715 src/LTerm_ui
1816 src/LTerm_resources
1917 src/LTerm_inputrc
18 src/LTerm_history
2019 # OASIS_STOP
77 *)
88
99 (* OASIS_START *)
10 (* DO NOT EDIT (digest: 58cb0bb2797c6f9456b5d520b2a6eb4d) *)
10 (* DO NOT EDIT (digest: c2536d5c3dfc79582a4d8fb624ea092b) *)
1111 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
1414 let ns_ str =
1515 str
16
16
1717 let s_ str =
1818 str
19
19
2020 let f_ (str : ('a, 'b, 'c, 'd) format4) =
2121 str
22
22
2323 let fn_ fmt1 fmt2 n =
2424 if n = 1 then
2525 fmt1^^""
2626 else
2727 fmt2^^""
28
28
2929 let init =
3030 []
31
31
3232 end
3333
3434 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
3939 open OASISGettext
40
40
4141 type test = string
42
42
4343 type flag = string
44
44
4545 type t =
4646 | EBool of bool
4747 | ENot of t
5050 | EFlag of flag
5151 | ETest of test * string
5252
53
53
5454 type 'a choices = (t * 'a) list
55
55
5656 let eval var_get t =
5757 let rec eval' =
5858 function
5959 | EBool b ->
6060 b
61
61
6262 | ENot e ->
6363 not (eval' e)
64
64
6565 | EAnd (e1, e2) ->
6666 (eval' e1) && (eval' e2)
67
67
6868 | EOr (e1, e2) ->
6969 (eval' e1) || (eval' e2)
70
70
7171 | EFlag nm ->
7272 let v =
7373 var_get nm
7474 in
7575 assert(v = "true" || v = "false");
7676 (v = "true")
77
77
7878 | ETest (nm, vl) ->
7979 let v =
8080 var_get nm
8282 (v = vl)
8383 in
8484 eval' t
85
85
8686 let choose ?printer ?name var_get lst =
8787 let rec choose_aux =
8888 function
118118 str_lst)
119119 in
120120 choose_aux (List.rev lst)
121
121
122122 end
123123
124124
125 # 117 "myocamlbuild.ml"
125126 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
128129 module MapString = Map.Make(String)
129
130
130131 type t = string MapString.t
131
132
132133 let default_filename =
133134 Filename.concat
134135 (Sys.getcwd ())
135136 "setup.data"
136
137
137138 let load ?(allow_empty=false) ?(filename=default_filename) () =
138139 if Sys.file_exists filename then
139140 begin
190191 "Unable to load environment, the file '%s' doesn't exist."
191192 filename)
192193 end
193
194
194195 let var_get name env =
195196 let rec var_expand str =
196197 let buff =
211212 Buffer.contents buff
212213 in
213214 var_expand (MapString.find name env)
214
215
215216 let var_choose lst env =
216217 OASISExpr.choose
217218 (fun nm -> var_get nm env)
219220 end
220221
221222
223 # 215 "myocamlbuild.ml"
222224 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
225227 (** OCamlbuild extension, copied from
226228 * http://brion.inria.fr/gallium/index.php/Using_ocamlfind_with_ocamlbuild
227229 * by N. Pouillard and others
231233 * Modified by Sylvain Le Gall
232234 *)
233235 open Ocamlbuild_plugin
234
236
235237 (* these functions are not really officially exported *)
236238 let run_and_read =
237239 Ocamlbuild_pack.My_unix.run_and_read
238
240
239241 let blank_sep_strings =
240242 Ocamlbuild_pack.Lexers.blank_sep_strings
241
243
242244 let split s ch =
243245 let x =
244246 ref []
253255 try
254256 go s
255257 with Not_found -> !x
256
258
257259 let split_nl s = split s '\n'
258
260
259261 let before_space s =
260262 try
261263 String.before s (String.index s ' ')
262264 with Not_found -> s
263
265
264266 (* this lists all supported packages *)
265267 let find_packages () =
266268 List.map before_space (split_nl & run_and_read "ocamlfind list")
267
269
268270 (* this is supposed to list available syntaxes, but I don't know how to do it. *)
269271 let find_syntaxes () = ["camlp4o"; "camlp4r"]
270
272
271273 (* ocamlfind command *)
272274 let ocamlfind x = S[A"ocamlfind"; x]
273
275
274276 let dispatch =
275277 function
276278 | Before_options ->
300302 flag ["ocaml"; "infer_interface"; "pkg_"^pkg] & S[A"-package"; A pkg];
301303 end
302304 (find_packages ());
303
305
304306 (* Like -package but for extensions syntax. Morover -syntax is useless
305307 * when linking. *)
306308 List.iter begin fun syntax ->
309311 flag ["ocaml"; "doc"; "syntax_"^syntax] & S[A"-syntax"; A syntax];
310312 flag ["ocaml"; "infer_interface"; "syntax_"^syntax] & S[A"-syntax"; A syntax];
311313 end (find_syntaxes ());
312
314
313315 (* The default "thread" tag is not compatible with ocamlfind.
314316 * Indeed, the default rules add the "threads.cma" or "threads.cmxa"
315317 * options when using this tag. When using the "-linkpkg" option with
322324 flag ["ocaml"; "pkg_threads"; "doc"] (S[A "-I"; A "+threads"]);
323325 flag ["ocaml"; "pkg_threads"; "link"] (S[A "-thread"]);
324326 flag ["ocaml"; "pkg_threads"; "infer_interface"] (S[A "-thread"])
325
327
326328 | _ ->
327329 ()
328
330
329331 end
330332
331333 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
334336 (** Base functions for writing myocamlbuild.ml
335337 @author Sylvain Le Gall
336338 *)
337
338
339
339
340
341
340342 open Ocamlbuild_plugin
341
343 module OC = Ocamlbuild_pack.Ocaml_compiler
344
342345 type dir = string
343346 type file = string
344347 type name = string
345348 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
349352 type t =
350353 {
351354 lib_ocaml: (name * dir list) list;
352355 lib_c: (name * dir * file list) list;
353356 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;
354361 }
355
362
356363 let env_filename =
357364 Pathname.basename
358365 BaseEnvLight.default_filename
359
366
360367 let dispatch_combine lst =
361368 fun e ->
362369 List.iter
363370 (fun dispatch -> dispatch e)
364371 lst
365
372
373 let tag_libstubs nm =
374 "use_lib"^nm^"_stubs"
375
376 let nm_libstubs nm =
377 nm^"_stubs"
378
366379 let dispatch t e =
367380 let env =
368381 BaseEnvLight.load
389402 Options.ext_lib, "ext_lib";
390403 Options.ext_dll, "ext_dll";
391404 ]
392
405
393406 | After_rules ->
394407 (* Declare OCaml libraries *)
395408 List.iter
396409 (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);
401414 List.iter
402415 (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"])
406420 tl)
407421 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
409429 (* Declare C libraries *)
410430 List.iter
411431 (fun (lib, dir, headers) ->
412432 (* 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))]);
418439
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
422443 (* When ocaml link something that use the C library, then one
423444 need that file to be up to date.
424445 *)
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
428452 (* TODO: be more specific about what depends on headers *)
429453 (* Depends on .h files *)
430454 dep ["compile"; "c"]
431455 headers;
432
456
433457 (* Setup search path for lib *)
434458 flag ["link"; "ocaml"; "use_"^lib]
435459 (S[A"-I"; P(dir)]);
436460 )
437461 t.lib_c;
438
462
439463 (* Add flags *)
440464 List.iter
441465 (fun (tags, cond_specs) ->
446470 t.flags
447471 | _ ->
448472 ()
449
473
450474 let dispatch_default t =
451475 dispatch_combine
452476 [
453477 dispatch t;
454478 MyOCamlbuildFindlib.dispatch;
455479 ]
456
480
457481 end
458482
459483
484 # 476 "myocamlbuild.ml"
460485 open Ocamlbuild_plugin;;
461486 let package_default =
462487 {
463 MyOCamlbuildBase.lib_ocaml = [("src/lambda-term", ["src"])];
488 MyOCamlbuildBase.lib_ocaml = [("lambda-term", ["src"])];
464489 lib_c = [("lambda-term", "src", [])];
465490 flags = [];
491 includes =
492 [("tools", ["src"]); ("tests", ["src"]); ("examples", ["src"])];
466493 }
467494 ;;
468495
469496 let dispatch_default = MyOCamlbuildBase.dispatch_default package_default;;
470497
498 # 491 "myocamlbuild.ml"
471499 (* OASIS_STOP *)
472500
473501 open Ocamlbuild_plugin
481509 Options.make_links := false
482510
483511 | 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"]
505513
506514 | _ ->
507515 ())
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
+2622
-2034
setup.ml less more
33 * Copyright : (c) 2011, Jeremie Dimino <jeremie@dimino.org>
44 * Licence : BSD3
55 *
6 * This file is a part of Lambda-Term.
6 * This file is a part of Zed, an editor engine.
77 *)
88
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
209 (* OASIS_START *)
21 (* DO NOT EDIT (digest: fc0fbe126ea51baf078319ddeeedf51e) *)
10 (* DO NOT EDIT (digest: 196e721eb8f28d35d292d1cde7b5ccd3) *)
2211 (*
23 Regenerated by OASIS v0.2.1~alpha1
12 Regenerated by OASIS v0.3.0
2413 Visit http://oasis.forge.ocamlcore.org for more information and
2514 documentation about functions used in this file.
2615 *)
2716 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
3019 let ns_ str =
3120 str
32
21
3322 let s_ str =
3423 str
35
24
3625 let f_ (str : ('a, 'b, 'c, 'd) format4) =
3726 str
38
27
3928 let fn_ fmt1 fmt2 n =
4029 if n = 1 then
4130 fmt1^^""
4231 else
4332 fmt2^^""
44
33
4534 let init =
4635 []
47
36
4837 end
4938
5039 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
5342 open OASISGettext
54
43
5544 type level =
5645 [ `Debug
5746 | `Info
5847 | `Warning
5948 | `Error]
60
49
6150 type t =
6251 {
63 verbose: bool;
52 quiet: bool;
53 info: bool;
6454 debug: bool;
6555 ignore_plugins: bool;
6656 ignore_unknown_fields: bool;
6757 printf: level -> string -> unit;
6858 }
69
59
7060 let printf lvl str =
7161 let beg =
7262 match lvl with
7666 | `Debug -> s_ "D: "
7767 in
7868 prerr_endline (beg^str)
79
69
8070 let default =
8171 ref
8272 {
83 verbose = true;
73 quiet = false;
74 info = false;
8475 debug = false;
8576 ignore_plugins = false;
8677 ignore_unknown_fields = false;
8778 printf = printf;
8879 }
89
80
9081 let quiet =
91 {!default with
92 verbose = false;
93 debug = false;
94 }
95
96
82 {!default with quiet = true}
83
84
9785 let args () =
9886 ["-quiet",
99 Arg.Unit (fun () -> default := {!default with verbose = false}),
87 Arg.Unit (fun () -> default := {!default with quiet = true}),
10088 (s_ " Run quietly");
101
89
90 "-info",
91 Arg.Unit (fun () -> default := {!default with info = true}),
92 (s_ " Display information message");
93
94
10295 "-debug",
10396 Arg.Unit (fun () -> default := {!default with debug = true}),
10497 (s_ " Output debug message")]
10598 end
10699
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
107225 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
110230 module MapString = Map.Make(String)
111
231
112232 let map_string_of_assoc assoc =
113233 List.fold_left
114234 (fun acc (k, v) -> MapString.add k v acc)
115235 MapString.empty
116236 assoc
117
237
118238 module SetString = Set.Make(String)
119
239
120240 let set_string_add_list st lst =
121241 List.fold_left
122242 (fun acc e -> SetString.add e acc)
123243 st
124244 lst
125
245
126246 let set_string_of_list =
127247 set_string_add_list
128248 SetString.empty
129
130
249
250
131251 let compare_csl s1 s2 =
132252 String.compare (String.lowercase s1) (String.lowercase s2)
133
253
134254 module HashStringCsl =
135255 Hashtbl.Make
136256 (struct
137257 type t = string
138
258
139259 let equal s1 s2 =
140260 (String.lowercase s1) = (String.lowercase s2)
141
261
142262 let hash s =
143263 Hashtbl.hash (String.lowercase s)
144264 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
188266 let varname_of_string ?(hyphen='_') s =
189267 if String.length s = 0 then
190268 begin
192270 end
193271 else
194272 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
203275 (fun c ->
204276 if ('a' <= c && c <= 'z')
205277 ||
206278 ('A' <= c && c <= 'Z')
207279 ||
208280 ('0' <= c && c <= '9') then
209 Buffer.add_char buff c
281 c
210282 else
211 Buffer.add_char buff hyphen)
283 hyphen)
212284 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
215294 end
216
295
217296 let varname_concat ?(hyphen='_') p s =
297 let what = String.make 1 hyphen in
218298 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
226303 in
227304 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
239313 let is_varname str =
240314 str = varname_of_string str
241
315
242316 let failwithf fmt = Printf.ksprintf failwith fmt
243
317
244318 end
245319
246320 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
249323 open OASISGettext
250
324
251325 type name = string
252
326
253327 exception Not_set of name * string option
254328 exception No_printer of name
255329 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
270349 module Data =
271350 struct
272
351
273352 type t =
274353 (name, unit -> unit) Hashtbl.t
275
354
276355 let create () =
277356 Hashtbl.create 13
278
357
279358 let clear t =
280359 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" *)
283362 end
284
363
285364 module Schema =
286365 struct
287
366
288367 type ('ctxt, 'extra) value =
289368 {
290369 get: Data.t -> string;
292371 help: (unit -> string) option;
293372 extra: 'extra;
294373 }
295
374
296375 type ('ctxt, 'extra) t =
297376 {
298377 name: name;
300379 order: name Queue.t;
301380 name_norm: string -> string;
302381 }
303
382
304383 let create ?(case_insensitive=false) nm =
305384 {
306385 name = nm;
312391 else
313392 fun s -> s);
314393 }
315
394
316395 let add t nm set get extra help =
317396 let key =
318397 t.name_norm nm
319398 in
320
399
321400 if Hashtbl.mem t.fields key then
322401 failwith
323402 (Printf.sprintf
333412 extra = extra;
334413 };
335414 Queue.add nm t.order
336
415
337416 let mem t nm =
338417 Hashtbl.mem t.fields nm
339
418
340419 let find t nm =
341420 try
342421 Hashtbl.find t.fields (t.name_norm nm)
343422 with Not_found ->
344423 raise (Unknown_field (nm, t.name))
345
424
346425 let get t data nm =
347426 (find t nm).get data
348
427
349428 let set t data nm ?context x =
350429 (find t nm).set
351430 data
352431 ?context
353432 x
354
433
355434 let fold f acc t =
356435 Queue.fold
357436 (fun acc k ->
361440 f acc k v.extra v.help)
362441 acc
363442 t.order
364
443
365444 let iter f t =
366445 fold
367446 (fun () -> f)
368447 ()
369448 t
370
449
371450 let name t =
372451 t.name
373452 end
374
453
375454 module Field =
376455 struct
377
456
378457 type ('ctxt, 'value, 'extra) t =
379458 {
380459 set: Data.t -> ?context:'ctxt -> 'value -> unit;
384463 help: (unit -> string) option;
385464 extra: 'extra;
386465 }
387
466
388467 let new_id =
389468 let last_id =
390469 ref 0
391470 in
392471 fun () -> incr last_id; !last_id
393
472
394473 let create ?schema ?name ?parse ?print ?default ?update ?help extra =
395474 (* Default value container *)
396475 let v =
397476 ref None
398477 in
399
478
400479 (* If name is not given, create unique one *)
401480 let nm =
402481 match name with
403482 | Some s -> s
404483 | None -> Printf.sprintf "_anon_%d" (new_id ())
405484 in
406
485
407486 (* Last chance to get a value: the default *)
408487 let default () =
409488 match default with
410489 | Some d -> d
411490 | None -> raise (Not_set (nm, Some (s_ "no default value")))
412491 in
413
492
414493 (* Get data *)
415494 let get data =
416495 (* Get value *)
422501 with Not_found ->
423502 default ()
424503 in
425
504
426505 (* Set data *)
427506 let set data ?context x =
428507 let x =
442521 nm
443522 (fun () -> v := Some x)
444523 in
445
524
446525 (* Parse string value, if possible *)
447526 let parse =
448527 match parse with
456535 nm
457536 s)
458537 in
459
538
460539 (* Set data, from string *)
461540 let sets data ?context s =
462541 set ?context data (parse ?context s)
463542 in
464
543
465544 (* Output value as string, if possible *)
466545 let print =
467546 match print with
470549 | None ->
471550 fun _ -> raise (No_printer nm)
472551 in
473
552
474553 (* Get data, as a string *)
475554 let gets data =
476555 print (get data)
477556 in
478
557
479558 begin
480559 match schema with
481560 | Some t ->
483562 | None ->
484563 ()
485564 end;
486
565
487566 {
488567 set = set;
489568 get = get;
492571 help = help;
493572 extra = extra;
494573 }
495
574
496575 let fset data t ?context x =
497576 t.set data ?context x
498
577
499578 let fget data t =
500579 t.get data
501
580
502581 let fsets data t ?context s =
503582 t.sets data ?context s
504
583
505584 let fgets data t =
506585 t.gets data
507
586
508587 end
509
588
510589 module FieldRO =
511590 struct
512
591
513592 let create ?schema ?name ?parse ?print ?default ?update ?help extra =
514593 let fld =
515594 Field.create ?schema ?name ?parse ?print ?default ?update ?help extra
516595 in
517596 fun data -> Field.fget data fld
518
597
519598 end
520599 end
521600
522601 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
526605 open OASISGettext
527606 open OASISContext
528
607
529608 let generic_message ~ctxt lvl fmt =
530609 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
534617 in
535618 Printf.ksprintf
536619 (fun str ->
539622 ctxt.printf lvl str
540623 end)
541624 fmt
542
625
543626 let debug ~ctxt fmt =
544627 generic_message ~ctxt `Debug fmt
545
628
546629 let info ~ctxt fmt =
547630 generic_message ~ctxt `Info fmt
548
631
549632 let warning ~ctxt fmt =
550633 generic_message ~ctxt `Warning fmt
551
634
552635 let error ~ctxt fmt =
553636 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
569638 end
570639
571640 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
574643 open OASISGettext
575
576
577
644
645
646
578647 type s = string
579
648
580649 type t = string
581
650
582651 type comparator =
583652 | VGreater of t
584653 | VGreaterEqual of t
588657 | VOr of comparator * comparator
589658 | VAnd of comparator * comparator
590659
591
660
592661 (* Range of allowed characters *)
593662 let is_digit c =
594663 '0' <= c && c <= '9'
595
664
596665 let is_alpha c =
597666 ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z')
598
667
599668 let is_special =
600669 function
601670 | '.' | '+' | '-' | '~' -> true
602671 | _ -> false
603
672
604673 let rec version_compare v1 v2 =
605674 if v1 <> "" || v2 <> "" then
606675 begin
614683 else if is_alpha c then Char.code c
615684 else (Char.code c) + 256
616685 in
617
686
618687 let len1 = String.length v1 in
619688 let len2 = String.length v2 in
620
689
621690 let p = ref 0 in
622
691
623692 (** Compare ascii part *)
624693 let compare_vascii () =
625694 let cmp = ref 0 in
636705 else
637706 !cmp
638707 in
639
708
640709 (** Compare digit part *)
641710 let compare_digit () =
642711 let extract_int v p =
658727 let i2, tl2 = extract_int v2 (ref !p) in
659728 i1 - i2, tl1, tl2
660729 in
661
730
662731 match compare_vascii () with
663732 | 0 ->
664733 begin
680749 begin
681750 0
682751 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
701758 let chop t =
702759 try
703760 let pos =
706763 String.sub t 0 pos
707764 with Not_found ->
708765 t
709
766
710767 let rec comparator_apply v op =
711768 match op with
712769 | VGreater cv ->
723780 (comparator_apply v op1) || (comparator_apply v op2)
724781 | VAnd (op1, op2) ->
725782 (comparator_apply v op1) && (comparator_apply v op2)
726
783
727784 let rec string_of_comparator =
728785 function
729786 | VGreater v -> "> "^(string_of_version v)
735792 (string_of_comparator c1)^" || "^(string_of_comparator c2)
736793 | VAnd (c1, c2) ->
737794 (string_of_comparator c1)^" && "^(string_of_comparator c2)
738
795
739796 let rec varname_of_comparator =
740797 let concat p v =
741798 OASISUtils.varname_concat
753810 (varname_of_comparator c1)^"_or_"^(varname_of_comparator c2)
754811 | VAnd (c1, c2) ->
755812 (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
757817 end
758818
759819 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
762822 (** License for _oasis fields
763823 @author Sylvain Le Gall
764824 *)
765
766
767
825
826
827
768828 type license = string
769
829
770830 type license_exception = string
771
831
772832 type license_version =
773833 | Version of OASISVersion.t
774834 | VersionOrLater of OASISVersion.t
775835 | NoVersion
776836
777
837
838 type license_dep_5_unit =
839 {
840 license: license;
841 excption: license_exception option;
842 version: license_version;
843 }
844
845
778846 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
785852 type t =
786853 | DEP5License of license_dep_5
787854 | OtherLicense of string (* URL *)
788855
789
856
790857 end
791858
792859 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
797864 open OASISGettext
798
865
799866 type test = string
800
867
801868 type flag = string
802
869
803870 type t =
804871 | EBool of bool
805872 | ENot of t
808875 | EFlag of flag
809876 | ETest of test * string
810877
811
878
812879 type 'a choices = (t * 'a) list
813
880
814881 let eval var_get t =
815882 let rec eval' =
816883 function
817884 | EBool b ->
818885 b
819
886
820887 | ENot e ->
821888 not (eval' e)
822
889
823890 | EAnd (e1, e2) ->
824891 (eval' e1) && (eval' e2)
825
892
826893 | EOr (e1, e2) ->
827894 (eval' e1) || (eval' e2)
828
895
829896 | EFlag nm ->
830897 let v =
831898 var_get nm
832899 in
833900 assert(v = "true" || v = "false");
834901 (v = "true")
835
902
836903 | ETest (nm, vl) ->
837904 let v =
838905 var_get nm
840907 (v = vl)
841908 in
842909 eval' t
843
910
844911 let choose ?printer ?name var_get lst =
845912 let rec choose_aux =
846913 function
876943 str_lst)
877944 in
878945 choose_aux (List.rev lst)
879
946
880947 end
881948
882949 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
888955 type name = string
889956 type package_name = string
890957 type url = string
896963 type arg = string
897964 type args = string list
898965 type command_line = (prog * arg list)
899
966
900967 type findlib_name = string
901968 type findlib_full = string
902
969
903970 type compiled_object =
904971 | Byte
905972 | Native
906973 | Best
907974
908
975
909976 type dependency =
910977 | FindlibPackage of findlib_full * OASISVersion.comparator option
911978 | InternalLibrary of name
912979
913
980
914981 type tool =
915982 | ExternalTool of name
916983 | InternalExecutable of name
917984
918
985
919986 type vcs =
920987 | Darcs
921988 | Git
927994 | Monotone
928995 | OtherVCS of url
929996
930
997
931998 type plugin_kind =
932999 [ `Configure
9331000 | `Build
9361003 | `Install
9371004 | `Extra
9381005 ]
939
1006
9401007 type plugin_data_purpose =
9411008 [ `Configure
9421009 | `Build
9501017 | `Extra
9511018 | `Other of string
9521019 ]
953
1020
9541021 type 'a plugin = 'a * name * OASISVersion.t option
955
1022
9561023 type all_plugin = plugin_kind plugin
957
1024
9581025 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
9621029 type 'a conditional = 'a OASISExpr.choices
963
1030
9641031 type custom =
9651032 {
9661033 pre_command: (command_line option) conditional;
9671034 post_command: (command_line option) conditional;
9681035 }
9691036
970
1037
9711038 type common_section =
9721039 {
9731040 cs_name: name;
9751042 cs_plugin_data: plugin_data;
9761043 }
9771044
978
1045
9791046 type build_section =
9801047 {
9811048 bs_build: bool conditional;
9941061 bs_nativeopt: args conditional;
9951062 }
9961063
997
1064
9981065 type library =
9991066 {
10001067 lib_modules: string list;
1068 lib_pack: bool;
10011069 lib_internal_modules: string list;
10021070 lib_findlib_parent: findlib_name option;
10031071 lib_findlib_name: findlib_name option;
10041072 lib_findlib_containers: findlib_name list;
10051073 }
1006
1074
10071075 type executable =
10081076 {
10091077 exec_custom: bool;
10101078 exec_main_is: unix_filename;
10111079 }
1012
1080
10131081 type flag =
10141082 {
10151083 flag_description: string option;
10161084 flag_default: bool conditional;
10171085 }
1018
1086
10191087 type source_repository =
10201088 {
10211089 src_repo_type: vcs;
10261094 src_repo_tag: string option;
10271095 src_repo_subdir: unix_filename option;
10281096 }
1029
1097
10301098 type test =
10311099 {
10321100 test_type: [`Test] plugin;
10361104 test_run: bool conditional;
10371105 test_tools: tool list;
10381106 }
1039
1107
10401108 type doc_format =
10411109 | HTML of unix_filename
10421110 | DocText
10461114 | DVI
10471115 | OtherDoc
10481116
1049
1117
10501118 type doc =
10511119 {
10521120 doc_type: [`Doc] plugin;
10611129 doc_data_files: (unix_filename * unix_filename option) list;
10621130 doc_build_tools: tool list;
10631131 }
1064
1132
10651133 type section =
10661134 | Library of common_section * build_section * library
10671135 | Executable of common_section * build_section * executable
10701138 | Test of common_section * test
10711139 | Doc of common_section * doc
10721140
1073
1141
10741142 type section_kind =
10751143 [ `Library | `Executable | `Flag | `SrcRepo | `Test | `Doc ]
1076
1144
10771145 type package =
10781146 {
10791147 oasis_version: OASISVersion.t;
10901158 synopsis: string;
10911159 description: string option;
10921160 categories: url list;
1093
1161
10941162 conf_type: [`Configure] plugin;
10951163 conf_custom: custom;
1096
1164
10971165 build_type: [`Build] plugin;
10981166 build_custom: custom;
1099
1167
11001168 install_type: [`Install] plugin;
11011169 install_custom: custom;
11021170 uninstall_custom: custom;
1103
1171
11041172 clean_custom: custom;
11051173 distclean_custom: custom;
1106
1174
11071175 files_ab: unix_filename list;
11081176 sections: section list;
11091177 plugins: [`Extra] plugin list;
11101178 schema_data: PropList.Data.t;
11111179 plugin_data: plugin_data;
11121180 }
1113
1181
11141182 end
11151183
11161184 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
11191187 type unix_filename = string
11201188 type unix_dirname = string
1121
1189
11221190 type host_filename = string
11231191 type host_dirname = string
1124
1192
11251193 let current_dir_name = "."
1126
1194
11271195 let parent_dir_name = ".."
1128
1196
1197 let is_current_dir fn =
1198 fn = current_dir_name || fn = ""
1199
11291200 let concat f1 f2 =
1130 if f1 = current_dir_name then
1201 if is_current_dir f1 then
11311202 f2
1132 else if f2 = current_dir_name then
1133 f1
11341203 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
11371209 let make =
11381210 function
11391211 | hd :: tl ->
11431215 tl
11441216 | [] ->
11451217 invalid_arg "OASISUnixPath.make"
1146
1218
11471219 let dirname f =
11481220 try
11491221 String.sub f 0 (String.rindex f '/')
11501222 with Not_found ->
11511223 current_dir_name
1152
1224
11531225 let basename f =
11541226 try
11551227 let pos_start =
11581230 String.sub f pos_start ((String.length f) - pos_start)
11591231 with Not_found ->
11601232 f
1161
1233
11621234 let chop_extension f =
11631235 try
11641236 let last_dot =
11771249 f
11781250 with Not_found ->
11791251 sub
1180
1252
11811253 with Not_found ->
11821254 f
1183
1255
11841256 let capitalize_file f =
11851257 let dir = dirname f in
11861258 let base = basename f in
11871259 concat dir (String.capitalize base)
1188
1260
11891261 let uncapitalize_file f =
11901262 let dir = dirname f in
11911263 let base = basename f in
11921264 concat dir (String.uncapitalize base)
1265
11931266 end
11941267
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
11951301 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
11971304 open OASISTypes
1198
1305
11991306 let section_kind_common =
12001307 function
12011308 | Library (cs, _, _) ->
12101317 `Test, cs
12111318 | Doc (cs, _) ->
12121319 `Doc, cs
1213
1320
12141321 let section_common sct =
12151322 snd (section_kind_common sct)
1216
1323
12171324 let section_common_set cs =
12181325 function
12191326 | Library (_, bs, lib) -> Library (cs, bs, lib)
12221329 | SrcRepo (_, src_repo) -> SrcRepo (cs, src_repo)
12231330 | Test (_, tst) -> Test (cs, tst)
12241331 | Doc (_, doc) -> Doc (cs, doc)
1225
1332
12261333 (** Key used to identify section
12271334 *)
12281335 let section_id sct =
12301337 section_kind_common sct
12311338 in
12321339 k, cs.cs_name
1233
1340
12341341 let string_of_section sct =
12351342 let k, nm =
12361343 section_id sct
12431350 | `Test -> "test"
12441351 | `Doc -> "doc")
12451352 ^" "^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
12471378 end
12481379
12491380 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
12521383 end
12531384
12541385 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
12571388 open OASISTypes
1258
1389
12591390 let unix_exec_is (cs, bs, exec) is_native ext_dll suffix_program =
12601391 let dir =
12611392 OASISUnixPath.concat
12681399 | Best -> is_native ()
12691400 | Byte -> false
12701401 in
1271
1402
12721403 OASISUnixPath.concat
12731404 dir
12741405 (cs.cs_name^(suffix_program ())),
1275
1406
12761407 if not is_native_exec &&
12771408 not exec.exec_custom &&
12781409 bs.bs_c_sources <> [] then
1279 Some (dir^"/dll"^cs.cs_name^(ext_dll ()))
1410 Some (dir^"/dll"^cs.cs_name^"_stubs"^(ext_dll ()))
12801411 else
12811412 None
1282
1413
12831414 end
12841415
12851416 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
12881419 open OASISTypes
12891420 open OASISUtils
12901421 open OASISGettext
1291
1422 open OASISSection
1423
12921424 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
12961524 (* The headers that should be compiled along *)
12971525 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
13261527 []
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
13301551 let acc_nopath =
13311552 []
13321553 in
1333
1554
13341555 (* Compute what libraries should be built *)
13351556 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
13361564 let byte acc =
1337 [cs.cs_name^".cma"] :: acc
1565 add_pack_header ([cs.cs_name^".cma"] :: acc)
13381566 in
13391567 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
13411575 in
13421576 match bs.bs_compiled_object with
13431577 | Native ->
13441578 byte (native acc_nopath)
1345 | Best when is_native () ->
1579 | Best when is_native ->
13461580 byte (native acc_nopath)
13471581 | Byte | Best ->
13481582 byte acc_nopath
13491583 in
1350
1584
13511585 (* Add C library to be built *)
13521586 let acc_nopath =
13531587 if bs.bs_c_sources <> [] then
13541588 begin
1355 ["lib"^cs.cs_name^(ext_lib ())]
1589 ["lib"^cs.cs_name^"_stubs"^ext_lib]
13561590 ::
1357 ["dll"^cs.cs_name^(ext_dll ())]
1591 ["dll"^cs.cs_name^"_stubs"^ext_dll]
13581592 ::
13591593 acc_nopath
13601594 end
13611595 else
13621596 acc_nopath
13631597 in
1364
1598
13651599 (* All the files generated *)
13661600 List.rev_append
13671601 (List.rev_map
13681602 (List.rev_map
13691603 (OASISUnixPath.concat bs.bs_path))
13701604 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 =
13851783 List.fold_left
13861784 (fun mp ->
13871785 function
13881786 | 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
14041788 | _ ->
14051789 mp)
14061790 MapString.empty
14071791 pkg.sections
14081792 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
15411818 let findlib_of_group =
15421819 function
15431820 | Container (fndlb_nm, _)
15441821 | Package (fndlb_nm, _, _, _, _) -> fndlb_nm
1545
1822
15461823 let root_of_group grp =
15471824 let rec root_lib_aux =
1825 (* We do a DFS in the group. *)
15481826 function
15491827 | 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
15581994 | [] ->
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
15742145 end
15752146
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"
16022149 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
16052152 module MapString = Map.Make(String)
1606
2153
16072154 type t = string MapString.t
1608
2155
16092156 let default_filename =
16102157 Filename.concat
16112158 (Sys.getcwd ())
16122159 "setup.data"
1613
2160
16142161 let load ?(allow_empty=false) ?(filename=default_filename) () =
16152162 if Sys.file_exists filename then
16162163 begin
16672214 "Unable to load environment, the file '%s' doesn't exist."
16682215 filename)
16692216 end
1670
2217
16712218 let var_get name env =
16722219 let rec var_expand str =
16732220 let buff =
16882235 Buffer.contents buff
16892236 in
16902237 var_expand (MapString.find name env)
1691
2238
16922239 let var_choose lst env =
16932240 OASISExpr.choose
16942241 (fun nm -> var_get nm env)
16962243 end
16972244
16982245
2246 # 2240 "setup.ml"
16992247 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
17022250 open OASISContext
1703
2251
17042252 let args = args
1705
2253
17062254 let default = default
1707
2255
17082256 end
17092257
17102258 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
17132261 (** Message to user, overrid for Base
17142262 @author Sylvain Le Gall
17152263 *)
17162264 open OASISMessage
17172265 open BaseContext
1718
2266
17192267 let debug fmt = debug ~ctxt:!default fmt
1720
2268
17212269 let info fmt = info ~ctxt:!default fmt
1722
2270
17232271 let warning fmt = warning ~ctxt:!default fmt
1724
2272
17252273 let error fmt = error ~ctxt:!default fmt
1726
1727 let string_of_exception = string_of_exception
1728
2274
17292275 end
17302276
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
17632277 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
17662280 open OASISGettext
17672281 open OASISUtils
17682282 open PropList
1769
2283
17702284 module MapString = BaseEnvLight.MapString
1771
2285
17722286 type origin_t =
17732287 | ODefault
17742288 | OGetEnv
17752289 | OFileLoad
17762290 | OCommandLine
1777
2291
17782292 type cli_handle_t =
17792293 | CLINone
17802294 | CLIAuto
17812295 | CLIWith
17822296 | CLIEnable
17832297 | CLIUser of (Arg.key * Arg.spec * Arg.doc) list
1784
2298
17852299 type definition_t =
17862300 {
17872301 hide: bool;
17902304 arg_help: string option;
17912305 group: string option;
17922306 }
1793
2307
17942308 let schema =
17952309 Schema.create "environment"
1796
2310
17972311 (* Environment data *)
17982312 let env =
17992313 Data.create ()
1800
2314
18012315 (* Environment data from file *)
18022316 let env_from_file =
18032317 ref MapString.empty
1804
2318
18052319 (* Lexer for var *)
18062320 let var_lxr =
18072321 Genlex.make_lexer []
1808
2322
18092323 let rec var_expand str =
18102324 let buff =
18112325 Buffer.create ((String.length str) * 2)
18262340 in
18272341 match Stream.npeek 3 st with
18282342 | [Genlex.Ident "utoh"; Genlex.Ident nm] ->
1829 BaseFilePath.of_unix (var_get nm)
2343 OASISHostPath.of_unix (var_get nm)
18302344 | [Genlex.Ident "utoh"; Genlex.String s] ->
1831 BaseFilePath.of_unix s
2345 OASISHostPath.of_unix s
18322346 | [Genlex.Ident "ocaml_escaped"; Genlex.Ident nm] ->
18332347 String.escaped (var_get nm)
18342348 | [Genlex.Ident "ocaml_escaped"; Genlex.String s] ->
18552369 e)
18562370 str;
18572371 Buffer.contents buff
1858
2372
18592373 and var_get name =
18602374 let vl =
18612375 try
18692383 end
18702384 in
18712385 var_expand vl
1872
2386
18732387 let var_choose ?printer ?name lst =
18742388 OASISExpr.choose
18752389 ?printer
18762390 ?name
18772391 var_get
18782392 lst
1879
2393
18802394 let var_protect vl =
18812395 let buff =
18822396 Buffer.create (String.length vl)
18872401 | c -> Buffer.add_char buff c)
18882402 vl;
18892403 Buffer.contents buff
1890
2404
18912405 let var_define
18922406 ?(hide=false)
18932407 ?(dump=true)
18982412 name (* TODO: type constraint on the fact that name must be a valid OCaml
18992413 id *)
19002414 dflt =
1901
2415
19022416 let default =
19032417 [
1904 OFileLoad, lazy (MapString.find name !env_from_file);
2418 OFileLoad, (fun () -> MapString.find name !env_from_file);
19052419 ODefault, dflt;
1906 OGetEnv, lazy (Sys.getenv name);
2420 OGetEnv, (fun () -> Sys.getenv name);
19072421 ]
19082422 in
1909
2423
19102424 let extra =
19112425 {
19122426 hide = hide;
19162430 group = group;
19172431 }
19182432 in
1919
2433
19202434 (* Try to find a value that can be defined
19212435 *)
19222436 let var_get_low lst =
19232437 let errors, res =
19242438 List.fold_left
1925 (fun (errors, res) (_, v) ->
2439 (fun (errors, res) (o, v) ->
19262440 if res = None then
19272441 begin
19282442 try
1929 errors, Some (Lazy.force v)
2443 errors, Some (v ())
19302444 with
19312445 | Not_found ->
19322446 errors, res
19402454 ([], None)
19412455 (List.sort
19422456 (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)
19492458 lst)
19502459 in
19512460 match res, errors with
19562465 | None, lst ->
19572466 raise (Not_set (name, Some (String.concat (s_ ", ") lst)))
19582467 in
1959
2468
19602469 let help =
19612470 match short_desc with
19622471 | Some fs -> Some fs
19632472 | None -> None
19642473 in
1965
2474
19662475 let var_get_lst =
19672476 FieldRO.create
19682477 ~schema
19692478 ~name
1970 ~parse:(fun ?(context=ODefault) s -> [context, lazy s])
2479 ~parse:(fun ?(context=ODefault) s -> [context, fun () -> s])
19712480 ~print:var_get_low
19722481 ~default
19732482 ~update:(fun ?context x old_x -> x @ old_x)
19742483 ?help
19752484 extra
19762485 in
1977
2486
19782487 fun () ->
19792488 var_expand (var_get_low (var_get_lst env))
1980
2489
19812490 let var_redefine
19822491 ?hide
19832492 ?dump
19892498 dflt =
19902499 if Schema.mem schema name then
19912500 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 ());
19932503 fun () -> var_get name
19942504 end
19952505 else
20042514 name
20052515 dflt
20062516 end
2007
2517
20082518 let var_ignore (e : unit -> string) =
20092519 ()
2010
2520
20112521 let print_hidden =
20122522 var_define
20132523 ~hide:true
20152525 ~cli:CLIAuto
20162526 ~arg_help:"Print even non-printable variable. (debug)"
20172527 "print_hidden"
2018 (lazy "false")
2019
2528 (fun () -> "false")
2529
20202530 let var_all () =
20212531 List.rev
20222532 (Schema.fold
20272537 acc)
20282538 []
20292539 schema)
2030
2540
20312541 let default_filename =
20322542 BaseEnvLight.default_filename
2033
2543
20342544 let load ?allow_empty ?filename () =
20352545 env_from_file := BaseEnvLight.load ?allow_empty ?filename ()
2036
2546
20372547 let unload () =
2038 (* TODO: reset lazy values *)
20392548 env_from_file := MapString.empty;
20402549 Data.clear env
2041
2550
20422551 let dump ?(filename=default_filename) () =
20432552 let chn =
20442553 open_out_bin filename
20452554 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 _ ->
20482562 if def.dump then
20492563 begin
20502564 try
20542568 env
20552569 nm
20562570 in
2057 Printf.fprintf chn "%s = %S\n" nm value
2571 output nm value
20582572 with Not_set _ ->
20592573 ()
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 *)
20622583 close_out chn
2063
2584
20642585 let print () =
20652586 let printable_vars =
20662587 Schema.fold
20962617 let dot_pad str =
20972618 String.make ((max_length - (String.length str)) + 3) '.'
20982619 in
2099
2620
21002621 Printf.printf "\nConfiguration: \n";
21012622 List.iter
21022623 (fun (name,value) ->
21032624 Printf.printf "%s: %s %s\n" name (dot_pad name) value)
21042625 (List.rev printable_vars);
21052626 Printf.printf "\n%!"
2106
2627
21072628 let args () =
21082629 let arg_concat =
21092630 OASISUtils.varname_concat ~hyphen:'-'
21302651 ]
21312652 ),
21322653 "var+val Override any configuration variable.";
2133
2654
21342655 ]
21352656 @
21362657 List.flatten
21442665 name
21452666 s
21462667 in
2147
2668
21482669 let arg_name =
21492670 OASISUtils.varname_of_string ~hyphen:'-' name
21502671 in
2151
2672
21522673 let hlp =
21532674 match short_descr_opt with
21542675 | Some txt -> txt ()
21552676 | None -> ""
21562677 in
2157
2678
21582679 let arg_hlp =
21592680 match def.arg_help with
21602681 | Some s -> s
21612682 | None -> "str"
21622683 in
2163
2684
21642685 let default_value =
21652686 try
21662687 Printf.sprintf
21722693 with Not_set _ ->
21732694 ""
21742695 in
2175
2696
21762697 let args =
21772698 match def.cli with
21782699 | CLINone ->
21902711 Printf.sprintf (f_ "%s %s%s") arg_hlp hlp default_value
21912712 ]
21922713 | 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 ]
22102729 | CLIUser lst ->
22112730 lst
22122731 in
22152734 schema)
22162735 end
22172736
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
24562737 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
24592740 open OASISUtils
24602741 open OASISGettext
2461
2742
24622743 let parse argv args =
24632744 (* Simulate command line for Arg *)
24642745 let current =
24652746 ref 0
24662747 in
2467
2748
24682749 try
24692750 Arg.parse_argv
24702751 ~current:current
24822763 end
24832764
24842765 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
24872768 open BaseEnv
24882769 open BaseMessage
24892770 open OASISUtils
24902771 open OASISGettext
2491
2772
24922773 let prog_best prg prg_lst =
24932774 var_redefine
24942775 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
25142795 let prog prg =
25152796 prog_best prg [prg]
2516
2797
25172798 let prog_opt prg =
25182799 prog_best prg [prg^".opt"; prg]
2519
2800
25202801 let ocamlfind =
25212802 prog "ocamlfind"
2522
2803
25232804 let version
25242805 var_prefix
25252806 cmp
25322813 var_redefine
25332814 ~hide:true
25342815 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)
25622843 ()
2563
2844
25642845 let package_version pkg =
2565 BaseExec.run_read_one_line
2846 OASISExec.run_read_one_line ~ctxt:!BaseContext.default
25662847 (ocamlfind ())
25672848 ["query"; "-format"; "%v"; pkg]
2568
2849
25692850 let package ?version_comparator pkg () =
25702851 let var =
25712852 OASISUtils.varname_concat
25742855 in
25752856 let findlib_dir pkg =
25762857 let dir =
2577 BaseExec.run_read_one_line
2858 OASISExec.run_read_one_line ~ctxt:!BaseContext.default
25782859 (ocamlfind ())
25792860 ["query"; "-format"; "%d"; pkg]
25802861 in
25892870 let vl =
25902871 var_redefine
25912872 var
2592 (lazy (findlib_dir pkg))
2873 (fun () -> findlib_dir pkg)
25932874 ()
25942875 in
25952876 (
26082889 end
26092890
26102891 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
26142895 open BaseEnv
26152896 open OASISUtils
26162897 open OASISGettext
2617
2898
26182899 module SMap = Map.Make(String)
2619
2900
26202901 let ocamlc =
26212902 BaseCheck.prog_opt "ocamlc"
2622
2903
26232904 let ocamlc_config_map =
26242905 (* Map name to value for ocamlc -config output
26252906 (name ^": "^value)
26642945 | [] ->
26652946 mp
26662947 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
26682960 var_redefine
26692961 "ocamlc_config_map"
26702962 ~hide:true
26712963 ~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
26812968 let var_define nm =
26822969 (* Extract data from ocamlc -config *)
26832970 let avlbl_config_get () =
26912978 with _ ->
26922979 s
26932980 in
2694
2981
26952982 let nm_config, value_config =
26962983 match nm with
26972984 | "ocaml_version" ->
27002987 in
27012988 var_redefine
27022989 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
27183005 end
27193006
27203007 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
27243011 open OASISGettext
27253012 open OASISTypes
27263013 open OASISExpr
27273014 open BaseCheck
27283015 open BaseEnv
2729
3016
27303017 let ocamlfind = BaseCheck.ocamlfind
27313018 let ocamlc = BaseOCamlcConfig.ocamlc
27323019 let ocamlopt = prog_opt "ocamlopt"
27333020 let ocamlbuild = prog "ocamlbuild"
2734
2735
3021
3022
27363023 (**/**)
27373024 let rpkg =
27383025 ref None
2739
3026
27403027 let pkg_get () =
27413028 match !rpkg with
27423029 | Some pkg -> pkg
27433030 | 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
27443045 (**/**)
2745
3046
27463047 let pkg_name =
27473048 var_define
27483049 ~short_desc:(fun () -> s_ "Package name")
27493050 "pkg_name"
2750 (lazy (pkg_get ()).name)
2751
3051 (fun () -> (pkg_get ()).name)
3052
27523053 let pkg_version =
27533054 var_define
27543055 ~short_desc:(fun () -> s_ "Package version")
27553056 "pkg_version"
2756 (lazy
3057 (fun () ->
27573058 (OASISVersion.string_of_version (pkg_get ()).version))
2758
3059
27593060 let c = BaseOCamlcConfig.var_define
2760
3061
27613062 let os_type = c "os_type"
27623063 let system = c "system"
27633064 let architecture = c "architecture"
27643065 let ccomp_type = c "ccomp_type"
27653066 let ocaml_version = c "ocaml_version"
2766
3067
27673068 (* TODO: Check standard variable presence at runtime *)
2768
3069
27693070 let standard_library_default = c "standard_library_default"
27703071 let standard_library = c "standard_library"
27713072 let standard_runtime = c "standard_runtime"
27783079 let ext_dll = c "ext_dll"
27793080 let default_executable_name = c "default_executable_name"
27803081 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
27833101 (**/**)
27843102 let p name hlp dflt =
27853103 var_define
27883106 ~arg_help:"dir"
27893107 name
27903108 dflt
2791
3109
27923110 let (/) a b =
27933111 if os_type () = Sys.os_type then
27943112 Filename.concat a b
27953113 else if os_type () = "Unix" then
2796 BaseFilePath.Unix.concat a b
3114 OASISUnixPath.concat a b
27973115 else
27983116 OASISUtils.failwithf (f_ "Cannot handle os_type %s filename concat")
27993117 (os_type ())
28003118 (**/**)
2801
3119
28023120 let prefix =
28033121 p "prefix"
28043122 (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
28153133 let exec_prefix =
28163134 p "exec_prefix"
28173135 (fun () -> s_ "Install architecture-dependent files in dir")
2818 (lazy "$prefix")
2819
3136 (fun () -> "$prefix")
3137
28203138 let bindir =
28213139 p "bindir"
28223140 (fun () -> s_ "User executables")
2823 (lazy ("$exec_prefix"/"bin"))
2824
3141 (fun () -> "$exec_prefix"/"bin")
3142
28253143 let sbindir =
28263144 p "sbindir"
28273145 (fun () -> s_ "System admin executables")
2828 (lazy ("$exec_prefix"/"sbin"))
2829
3146 (fun () -> "$exec_prefix"/"sbin")
3147
28303148 let libexecdir =
28313149 p "libexecdir"
28323150 (fun () -> s_ "Program executables")
2833 (lazy ("$exec_prefix"/"libexec"))
2834
3151 (fun () -> "$exec_prefix"/"libexec")
3152
28353153 let sysconfdir =
28363154 p "sysconfdir"
28373155 (fun () -> s_ "Read-only single-machine data")
2838 (lazy ("$prefix"/"etc"))
2839
3156 (fun () -> "$prefix"/"etc")
3157
28403158 let sharedstatedir =
28413159 p "sharedstatedir"
28423160 (fun () -> s_ "Modifiable architecture-independent data")
2843 (lazy ("$prefix"/"com"))
2844
3161 (fun () -> "$prefix"/"com")
3162
28453163 let localstatedir =
28463164 p "localstatedir"
28473165 (fun () -> s_ "Modifiable single-machine data")
2848 (lazy ("$prefix"/"var"))
2849
3166 (fun () -> "$prefix"/"var")
3167
28503168 let libdir =
28513169 p "libdir"
28523170 (fun () -> s_ "Object code libraries")
2853 (lazy ("$exec_prefix"/"lib"))
2854
3171 (fun () -> "$exec_prefix"/"lib")
3172
28553173 let datarootdir =
28563174 p "datarootdir"
28573175 (fun () -> s_ "Read-only arch-independent data root")
2858 (lazy ("$prefix"/"share"))
2859
3176 (fun () -> "$prefix"/"share")
3177
28603178 let datadir =
28613179 p "datadir"
28623180 (fun () -> s_ "Read-only architecture-independent data")
2863 (lazy ("$datarootdir"))
2864
3181 (fun () -> "$datarootdir")
3182
28653183 let infodir =
28663184 p "infodir"
28673185 (fun () -> s_ "Info documentation")
2868 (lazy ("$datarootdir"/"info"))
2869
3186 (fun () -> "$datarootdir"/"info")
3187
28703188 let localedir =
28713189 p "localedir"
28723190 (fun () -> s_ "Locale-dependent data")
2873 (lazy ("$datarootdir"/"locale"))
2874
3191 (fun () -> "$datarootdir"/"locale")
3192
28753193 let mandir =
28763194 p "mandir"
28773195 (fun () -> s_ "Man documentation")
2878 (lazy ("$datarootdir"/"man"))
2879
3196 (fun () -> "$datarootdir"/"man")
3197
28803198 let docdir =
28813199 p "docdir"
28823200 (fun () -> s_ "Documentation root")
2883 (lazy ("$datarootdir"/"doc"/"$pkg_name"))
2884
3201 (fun () -> "$datarootdir"/"doc"/"$pkg_name")
3202
28853203 let htmldir =
28863204 p "htmldir"
28873205 (fun () -> s_ "HTML documentation")
2888 (lazy ("$docdir"))
2889
3206 (fun () -> "$docdir")
3207
28903208 let dvidir =
28913209 p "dvidir"
28923210 (fun () -> s_ "DVI documentation")
2893 (lazy ("$docdir"))
2894
3211 (fun () -> "$docdir")
3212
28953213 let pdfdir =
28963214 p "pdfdir"
28973215 (fun () -> s_ "PDF documentation")
2898 (lazy ("$docdir"))
2899
3216 (fun () -> "$docdir")
3217
29003218 let psdir =
29013219 p "psdir"
29023220 (fun () -> s_ "PS documentation")
2903 (lazy ("$docdir"))
2904
3221 (fun () -> "$docdir")
3222
29053223 let destdir =
29063224 p "destdir"
29073225 (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
29143232 let findlib_version =
29153233 var_define
29163234 "findlib_version"
2917 (lazy
2918 (BaseCheck.package_version "findlib"))
2919
3235 (fun () ->
3236 BaseCheck.package_version "findlib")
3237
29203238 let is_native =
29213239 var_define
29223240 "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
29353253 let ext_program =
29363254 var_define
29373255 "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
29443261 let rm =
29453262 var_define
29463263 ~short_desc:(fun () -> s_ "Remove a file.")
29473264 "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
29533270 let rmdir =
29543271 var_define
29553272 ~short_desc:(fun () -> s_ "Remove a directory.")
29563273 "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
29623279 let debug =
29633280 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
29653283 "debug"
2966 (lazy "true")
2967
3284 (fun () -> "true")
3285
29683286 let profile =
29693287 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
29713290 "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
29743365 let init pkg =
2975 rpkg := Some pkg
2976
3366 rpkg := Some pkg;
3367 List.iter (fun f -> f pkg.oasis_version) !var_cond
3368
29773369 end
29783370
29793371 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
29823374 open BaseEnv
29833375 open OASISGettext
29843376 open BaseMessage
2985
3377
29863378 let to_filename fn =
29873379 let fn =
2988 BaseFilePath.of_unix fn
3380 OASISHostPath.of_unix fn
29893381 in
29903382 if not (Filename.check_suffix fn ".ab") then
29913383 warning
29923384 (f_ "File '%s' doesn't have '.ab' extension")
29933385 fn;
29943386 Filename.chop_extension fn
2995
3387
29963388 let replace fn_lst =
29973389 let buff =
29983390 Buffer.create 13
30003392 List.iter
30013393 (fun fn ->
30023394 let fn =
3003 BaseFilePath.of_unix fn
3395 OASISHostPath.of_unix fn
30043396 in
30053397 let chn_in =
30063398 open_in fn
30253417 end
30263418
30273419 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
30303422 open OASISUtils
3031
3423
30323424 let default_filename =
30333425 Filename.concat
30343426 (Filename.dirname BaseEnv.default_filename)
30353427 "setup.log"
3036
3428
30373429 module SetTupleString =
30383430 Set.Make
30393431 (struct
30433435 | 0 -> String.compare s12 s22
30443436 | n -> n
30453437 end)
3046
3438
30473439 let load () =
30483440 if Sys.file_exists default_filename then
30493441 begin
30583450 begin
30593451 let acc =
30603452 try
3061 Scanf.bscanf scbuf "%S %S@\n"
3453 Scanf.bscanf scbuf "%S %S\n"
30623454 (fun e d ->
30633455 let t =
30643456 e, d
30923484 begin
30933485 []
30943486 end
3095
3487
30963488 let register event data =
30973489 let chn_out =
30983490 open_out_gen [Open_append; Open_creat; Open_text] 0o644 default_filename
30993491 in
31003492 Printf.fprintf chn_out "%S %S\n" event data;
31013493 close_out chn_out
3102
3494
31033495 let unregister event data =
31043496 if Sys.file_exists default_filename then
31053497 begin
31243516 if not !write_something then
31253517 Sys.remove default_filename
31263518 end
3127
3519
31283520 let filter events =
31293521 let st_events =
31303522 List.fold_left
31363528 List.filter
31373529 (fun (e, _) -> SetString.mem e st_events)
31383530 (load ())
3139
3531
31403532 let exists event data =
31413533 List.exists
31423534 (fun v -> (event, data) = v)
31443536 end
31453537
31463538 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
31493541 open OASISTypes
31503542 open OASISGettext
31513543 open BaseStandardVar
31523544 open BaseMessage
3153
3545
31543546 type t =
31553547 | BExec (* Executable *)
31563548 | BExecLib (* Library coming with executable *)
31573549 | BLib (* Library *)
31583550 | BDoc (* Document *)
3159
3551
31603552 let to_log_event_file t nm =
31613553 "built_"^
31623554 (match t with
31653557 | BLib -> "lib"
31663558 | BDoc -> "doc")^
31673559 "_"^nm
3168
3560
31693561 let to_log_event_done t nm =
31703562 "is_"^(to_log_event_file t nm)
3171
3563
31723564 let register t nm lst =
31733565 BaseLog.register
31743566 (to_log_event_done t nm)
31783570 let registered =
31793571 List.fold_left
31803572 (fun registered fn ->
3181 if Sys.file_exists fn then
3573 if OASISFileUtil.file_exists_case fn then
31823574 begin
31833575 BaseLog.register
31843576 (to_log_event_file t nm)
31983590 (f_ "Cannot find an existing alternative files among: %s")
31993591 (String.concat (s_ ", ") alt))
32003592 lst
3201
3593
32023594 let unregister t nm =
32033595 List.iter
32043596 (fun (e, d) ->
32063598 (BaseLog.filter
32073599 [to_log_event_file t nm;
32083600 to_log_event_done t nm])
3209
3601
32103602 let fold t nm f acc =
32113603 List.fold_left
32123604 (fun acc (_, fn) ->
3213 if Sys.file_exists fn then
3605 if OASISFileUtil.file_exists_case fn then
32143606 begin
32153607 f acc fn
32163608 end
32343626 acc
32353627 (BaseLog.filter
32363628 [to_log_event_file t nm])
3237
3629
32383630 let is_built t nm =
32393631 List.fold_left
32403632 (fun is_built (_, d) ->
32453637 false
32463638 (BaseLog.filter
32473639 [to_log_event_done t nm])
3248
3640
32493641 let of_executable ffn (cs, bs, exec) =
32503642 let unix_exec_is, unix_dll_opt =
32513643 OASISExecutable.unix_exec_is
32683660 evs,
32693661 unix_exec_is,
32703662 unix_dll_opt
3271
3663
32723664 let of_library ffn (cs, bs, lib) =
32733665 let unix_lst =
32743666 OASISLibrary.generated_unix_files
32753667 ~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 ())
32763674 (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
32833675 in
32843676 let evs =
32853677 [BLib,
32873679 List.map (List.map ffn) unix_lst]
32883680 in
32893681 evs, unix_lst
3290
3682
32913683 end
32923684
32933685 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
32963688 open BaseEnv
32973689 open BaseMessage
32983690 open OASISTypes
32993691 open OASISGettext
3300
3692
33013693 let run cmd args extra_args =
3302 BaseExec.run
3694 OASISExec.run ~ctxt:!BaseContext.default ~quote:false
33033695 (var_expand cmd)
33043696 (List.map
33053697 var_expand
33063698 (args @ (Array.to_list extra_args)))
3307
3699
33083700 let hook ?(failsafe=false) cstm f e =
33093701 let optional_command lst =
33103702 let printer =
33413733 end
33423734
33433735 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
33473739 open OASISTypes
33483740 open OASISGettext
33493741 open BaseEnv
33503742 open BaseBuilt
3351
3743
33523744 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... *)
33533747 List.iter
33543748 (function
33553749 | 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
33823777 | Library _ | Flag _ | Test _ | SrcRepo _ | Doc _ ->
33833778 ())
33843779 pkg.sections
33853780 end
33863781
33873782 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
33903785 open BaseEnv
33913786 open BaseMessage
33923787 open OASISTypes
33933788 open OASISExpr
33943789 open OASISGettext
3395
3790
33963791 let test lst pkg extra_args =
3397
3792
33983793 let one_test (failure, n) (test_plugin, cs, test) =
33993794 if var_choose
34003795 ~name:(Printf.sprintf
34183813 in
34193814 chdir dir;
34203815 fun () -> chdir cwd
3421
3816
34223817 | None ->
34233818 fun () -> ()
34243819 in
34633858 if failure_percent > 0.0 then
34643859 failwith msg
34653860 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'"
34673870 end
34683871
34693872 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
34723875 open BaseEnv
34733876 open BaseMessage
34743877 open OASISTypes
34753878 open OASISGettext
3476
3879
34773880 let doc lst pkg extra_args =
3478
3881
34793882 let one_doc (doc_plugin, cs, doc) =
34803883 if var_choose
34813884 ~name:(Printf.sprintf
34913894 extra_args
34923895 end
34933896 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'"
34973905 end
34983906
34993907 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
35023910 open BaseEnv
35033911 open BaseMessage
35043912 open OASISTypes
35053913 open OASISSection
35063914 open OASISGettext
35073915 open OASISUtils
3508
3916
35093917 type std_args_fun =
35103918 package -> string array -> unit
3511
3919
35123920 type ('a, 'b) section_args_fun =
35133921 name * (package -> (common_section * 'a) -> string array -> 'b)
3514
3922
35153923 type t =
35163924 {
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;
35313944 }
3532
3945
35333946 (* Associate a plugin function with data from package *)
35343947 let join_plugin_sections filter_map lst =
35353948 List.rev
35423955 acc)
35433956 []
35443957 lst)
3545
3958
35463959 (* Search for plugin data associated with a section name *)
35473960 let lookup_plugin_section plugin action nm lst =
35483961 try
35533966 plugin
35543967 nm
35553968 action
3556
3969
35573970 let configure t args =
35583971 (* Run configure *)
35593972 BaseCustom.hook
35603973 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
35643991 (* Reload environment *)
35653992 unload ();
35663993 load ();
3567
3994
3995 (* Save environment *)
3996 print ();
3997
35683998 (* Replace data in file *)
35693999 BaseFileAB.replace t.package.files_ab
3570
4000
35714001 let build t args =
35724002 BaseCustom.hook
35734003 t.package.build_custom
35744004 (t.build t.package)
35754005 args
3576
4006
35774007 let doc t args =
35784008 BaseDoc.doc
35794009 (join_plugin_sections
35924022 t.package.sections)
35934023 t.package
35944024 args
3595
4025
35964026 let test t args =
35974027 BaseTest.test
35984028 (join_plugin_sections
36114041 t.package.sections)
36124042 t.package
36134043 args
3614
4044
36154045 let all t args =
36164046 let rno_doc =
36174047 ref false
36284058 "-no-doc",
36294059 Arg.Set rno_doc,
36304060 s_ "Don't run doc target";
3631
4061
36324062 "-no-test",
36334063 Arg.Set rno_test,
36344064 s_ "Don't run test target";
36354065 ]
36364066 (failwithf (f_ "Don't know what to do with '%s'"))
36374067 "";
3638
4068
36394069 info "Running configure step";
36404070 configure t [||];
3641
4071
36424072 info "Running build step";
36434073 build t [||];
3644
4074
36454075 (* Load setup.log dynamic variables *)
36464076 BaseDynVar.init t.package;
3647
4077
36484078 if not !rno_doc then
36494079 begin
36504080 info "Running doc step";
36544084 begin
36554085 info "Skipping doc step"
36564086 end;
3657
4087
36584088 if not !rno_test then
36594089 begin
36604090 info "Running test step";
36644094 begin
36654095 info "Skipping test step"
36664096 end
3667
4097
36684098 let install t args =
36694099 BaseCustom.hook
36704100 t.package.install_custom
36714101 (t.install t.package)
36724102 args
3673
4103
36744104 let uninstall t args =
36754105 BaseCustom.hook
36764106 t.package.uninstall_custom
36774107 (t.uninstall t.package)
36784108 args
3679
4109
36804110 let reinstall t args =
36814111 uninstall t args;
36824112 install t args
3683
4113
36844114 let clean, distclean =
36854115 let failsafe f a =
36864116 try
36924122 | Failure msg -> msg
36934123 | e -> Printexc.to_string e)
36944124 in
3695
4125
36964126 let generic_clean t cstm mains docs tests args =
36974127 BaseCustom.hook
36984128 ~failsafe:true
37364166 mains)
37374167 ()
37384168 in
3739
4169
37404170 let clean t args =
37414171 generic_clean
37424172 t
37464176 t.clean_test
37474177 args
37484178 in
3749
4179
37504180 let distclean t args =
37514181 (* Call clean *)
37524182 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
37544193 (* Remove generated file *)
37554194 List.iter
37564195 (fun fn ->
37634202 ::
37644203 BaseLog.default_filename
37654204 ::
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
37784208 clean, distclean
3779
4209
37804210 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
37834342 let setup t =
37844343 let catch_exn =
37854344 ref true
37914350 (f_ "No action defined, run '%s %s -help'")
37924351 Sys.executable_name
37934352 Sys.argv.(0))
3794
4353
37954354 in
37964355 let extra_args_ref =
37974356 ref []
38034362 Arg.Tuple
38044363 [
38054364 Arg.Rest (fun str -> extra_args_ref := str :: !extra_args_ref);
3806
4365
38074366 Arg.Unit
38084367 (fun () ->
38094368 allow_empty_env_ref := allow_empty_env;
38104369 act_ref := act);
38114370 ]
38124371 in
3813
4372
38144373 Arg.parse
38154374 (Arg.align
3816 [
4375 ([
38174376 "-configure",
38184377 arg_handle ~allow_empty_env:true configure,
38194378 s_ "[options*] Configure the whole build process.";
3820
4379
38214380 "-build",
38224381 arg_handle build,
38234382 s_ "[options*] Build executables and libraries.";
3824
4383
38254384 "-doc",
38264385 arg_handle doc,
38274386 s_ "[options*] Build documents.";
3828
4387
38294388 "-test",
38304389 arg_handle test,
38314390 s_ "[options*] Run tests.";
3832
4391
38334392 "-all",
38344393 arg_handle ~allow_empty_env:true all,
38354394 s_ "[options*] Run configure, build, doc and test targets.";
3836
4395
38374396 "-install",
38384397 arg_handle install,
38394398 s_ "[options*] Install libraries, data, executables \
38404399 and documents.";
3841
4400
38424401 "-uninstall",
38434402 arg_handle uninstall,
38444403 s_ "[options*] Uninstall libraries, data, executables \
38454404 and documents.";
3846
4405
38474406 "-reinstall",
38484407 arg_handle reinstall,
38494408 s_ "[options*] Uninstall and install libraries, data, \
38504409 executables and documents.";
3851
4410
38524411 "-clean",
38534412 arg_handle ~allow_empty_env:true clean,
38544413 s_ "[options*] Clean files generated by a build.";
3855
4414
38564415 "-distclean",
38574416 arg_handle ~allow_empty_env:true distclean,
38584417 s_ "[options*] Clean files generated by a build and configure.";
3859
4418
38604419 "-version",
38614420 arg_handle ~allow_empty_env:true version,
38624421 s_ " Display version of OASIS used to generate this setup.ml.";
3863
4422
38644423 "-no-catch-exn",
38654424 Arg.Clear catch_exn,
38664425 s_ " Don't catch exception, useful for debugging.";
38674426 ]
3868 @ (BaseContext.args ()))
4427 @
4428 (if t.setup_update then
4429 [no_update_setup_ml_cli]
4430 else
4431 [])
4432 @ (BaseContext.args ())))
38694433 (failwithf (f_ "Don't know what to do with '%s'"))
38704434 (s_ "Setup and run build process current package\n");
3871
4435
38724436 (* Build initial environment *)
38734437 load ~allow_empty:!allow_empty_env_ref ();
3874
4438
38754439 (** Initialize flags *)
38764440 List.iter
38774441 (function
38844448 ~cli:CLIEnable
38854449 ?short_desc
38864450 (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)))
38944459 in
38954460 match hlp with
38964461 | Some hlp ->
39014466 | _ ->
39024467 ())
39034468 t.package.sections;
3904
4469
39054470 BaseStandardVar.init t.package;
3906
4471
39074472 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
39114479 with e when !catch_exn ->
3912 error "%s" (string_of_exception e);
4480 error "%s" (Printexc.to_string e);
39134481 exit 1
3914
4482
39154483 end
39164484
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"
39754487 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
39784490 (** Configure using internal scheme
39794491 @author Sylvain Le Gall
39804492 *)
3981
4493
39824494 open BaseEnv
39834495 open OASISTypes
39844496 open OASISUtils
39854497 open OASISGettext
39864498 open BaseMessage
3987
4499
39884500 (** Configure build using provided series of check to be done
39894501 * and then output corresponding file.
39904502 *)
39954507 in
39964508 ()
39974509 in
3998
4510
39994511 let errors =
40004512 ref SetString.empty
40014513 in
4002
4514
40034515 let buff =
40044516 Buffer.create 13
40054517 in
4006
4518
40074519 let add_errors fmt =
40084520 Printf.kbprintf
40094521 (fun b ->
40124524 buff
40134525 fmt
40144526 in
4015
4527
40164528 let warn_exception e =
4017 warning "%s" (string_of_exception e)
4018 in
4019
4529 warning "%s" (Printexc.to_string e)
4530 in
4531
40204532 (* Check tools *)
40214533 let check_tools lst =
40224534 List.iter
40464558 pkg.sections)
40474559 lst
40484560 in
4049
4561
40504562 let build_checks sct bs =
40514563 if var_choose bs.bs_build then
40524564 begin
40604572 (f_ "Section %s requires native compilation")
40614573 (OASISSection.string_of_section sct)
40624574 end;
4063
4575
40644576 (* Check tools *)
40654577 check_tools bs.bs_build_tools;
4066
4578
40674579 (* Check depends *)
40684580 List.iter
40694581 (function
41034615 bs.bs_build_depends
41044616 end
41054617 in
4106
4618
41074619 (* Parse command line *)
41084620 BaseArgExt.parse argv (BaseEnv.args ());
4109
4621
41104622 (* OCaml version *)
41114623 begin
41124624 match pkg.ocaml_version with
41284640 | None ->
41294641 ()
41304642 end;
4131
4643
41324644 (* Findlib version *)
41334645 begin
41344646 match pkg.findlib_version with
41504662 | None ->
41514663 ()
41524664 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
41544677 (* Check build depends *)
41554678 List.iter
41564679 (function
41664689 | _ ->
41674690 ())
41684691 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
41774715 begin
41784716 List.iter
41794717 (fun e -> error "%s" e)
41854723 (SetString.cardinal !errors))
41864724 (SetString.cardinal !errors)
41874725 end
4188
4726
41894727 end
41904728
41914729 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
41944732 (** Install using internal scheme
41954733 @author Sylvain Le Gall
41964734 *)
4197
4735
41984736 open BaseEnv
41994737 open BaseStandardVar
42004738 open BaseMessage
42024740 open OASISLibrary
42034741 open OASISGettext
42044742 open OASISUtils
4205
4743
42064744 let exec_hook =
42074745 ref (fun (cs, bs, exec) -> cs, bs, exec)
4208
4746
42094747 let lib_hook =
42104748 ref (fun (cs, bs, lib) -> cs, bs, lib, [])
4211
4749
42124750 let doc_hook =
42134751 ref (fun (cs, doc) -> cs, doc)
4214
4752
42154753 let install_file_ev =
42164754 "install-file"
4217
4755
42184756 let install_dir_ev =
42194757 "install-dir"
4220
4758
42214759 let install_findlib_ev =
42224760 "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
42244827 let install pkg argv =
4225
4828
42264829 let in_destdir =
42274830 try
42284831 let destdir =
42354838 with PropList.Not_set _ ->
42364839 fun fn -> fn
42374840 in
4238
4841
42394842 let install_file ?tgt_fn src_file envdir =
42404843 let tgt_dir =
42414844 in_destdir (envdir ())
42504853 Filename.basename src_file)
42514854 in
42524855 (* Create target directory if needed *)
4253 BaseFileUtil.mkdir_parent
4856 OASISFileUtil.mkdir_parent
4857 ~ctxt:!BaseContext.default
42544858 (fun dn ->
42554859 info (f_ "Creating directory '%s'") dn;
42564860 BaseLog.register install_dir_ev dn)
42574861 tgt_dir;
4258
4862
42594863 (* Really install files *)
42604864 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;
42624866 BaseLog.register install_file_ev tgt_file
42634867 in
4264
4868
42654869 (* Install data into defined directory *)
42664870 let install_data srcdir lst tgtdir =
42674871 let tgtdir =
4268 BaseFilePath.of_unix (var_expand tgtdir)
4872 OASISHostPath.of_unix (var_expand tgtdir)
42694873 in
42704874 List.iter
42714875 (fun (src, tgt_opt) ->
42724876 let real_srcs =
4273 BaseFileUtil.glob
4877 OASISFileUtil.glob
4878 ~ctxt:!BaseContext.default
42744879 (Filename.concat srcdir src)
42754880 in
42764881 if real_srcs = [] then
42844889 (fun () ->
42854890 match tgt_opt with
42864891 | Some s ->
4287 BaseFilePath.of_unix (var_expand s)
4892 OASISHostPath.of_unix (var_expand s)
42884893 | None ->
42894894 tgtdir))
42904895 real_srcs)
42914896 lst
42924897 in
4293
4898
42944899 (** Install all libraries *)
42954900 let install_libs pkg =
4296
4901
42974902 let files_of_library (f_data, acc) data_lib =
42984903 let cs, bs, lib, lib_extra =
42994904 !lib_hook data_lib
43084913 let acc =
43094914 (* Add uncompiled header from the source tree *)
43104915 let path =
4311 BaseFilePath.of_unix bs.bs_path
4916 OASISHostPath.of_unix bs.bs_path
43124917 in
43134918 List.fold_left
43144919 (fun acc modul ->
43154920 try
43164921 List.find
4317 Sys.file_exists
4922 OASISFileUtil.file_exists_case
43184923 (List.map
43194924 (Filename.concat path)
43204925 [modul^".mli";
43214926 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"])
43264931 :: acc
43274932 with Not_found ->
43284933 begin
43354940 acc
43364941 lib.lib_modules
43374942 in
4338
4943
43394944 let acc =
43404945 (* Get generated files *)
43414946 BaseBuilt.fold
43444949 (fun acc fn -> fn :: acc)
43454950 acc
43464951 in
4347
4952
43484953 let f_data () =
43494954 (* Install data associated with the library *)
43504955 install_data
43554960 pkg.name);
43564961 f_data ()
43574962 in
4358
4963
43594964 (f_data, acc)
43604965 end
43614966 else
43634968 (f_data, acc)
43644969 end
43654970 in
4366
4971
43674972 (* Install one group of library *)
43684973 let install_group_lib grp =
43694974 (* Iterate through all group nodes *)
43804985 data_and_files
43814986 children
43824987 in
4383
4988
43844989 (* Findlib name of the root library *)
43854990 let findlib_name =
43864991 findlib_of_group grp
43874992 in
4388
4993
43894994 (* Determine root library *)
43904995 let root_lib =
43914996 root_of_group grp
43924997 in
4393
4998
43944999 (* All files to install for this library *)
43955000 let f_data, files =
43965001 install_group_lib_aux (ignore, []) grp
43975002 in
4398
5003
43995004 (* Really install, if there is something to install *)
44005005 if files = [] then
44015006 begin
44135018 let res =
44145019 Filename.concat bs.bs_path "META"
44155020 in
4416 if not (Sys.file_exists res) then
5021 if not (OASISFileUtil.file_exists_case res) then
44175022 failwithf
44185023 (f_ "Cannot find file '%s' for findlib library %s")
44195024 res
44205025 findlib_name;
44215026 res
44225027 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
44235056 info
44245057 (f_ "Installing findlib library '%s'")
44255058 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;
44295070 BaseLog.register install_findlib_ev findlib_name
44305071 end;
4431
5072
44325073 (* Install data files *)
44335074 f_data ();
4434
5075
44355076 in
4436
5077
5078 let group_libs, _, _ =
5079 findlib_mapping pkg
5080 in
5081
44375082 (* 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
44435086 let install_execs pkg =
44445087 let install_exec data_exec =
44455088 let (cs, bs, exec) =
44585101 cs.cs_name
44595102 (fun () fn ->
44605103 install_file
4461 ~tgt_fn:cs.cs_name
5104 ~tgt_fn:(cs.cs_name ^ ext_program ())
44625105 fn
44635106 bindir)
44645107 ();
44865129 ())
44875130 pkg.sections
44885131 in
4489
5132
44905133 let install_docs pkg =
44915134 let install_doc data =
44925135 let (cs, doc) =
44965139 BaseBuilt.is_built BaseBuilt.BDoc cs.cs_name then
44975140 begin
44985141 let tgt_dir =
4499 BaseFilePath.of_unix (var_expand doc.doc_install_dir)
5142 OASISHostPath.of_unix (var_expand doc.doc_install_dir)
45005143 in
45015144 BaseBuilt.fold
45025145 BaseBuilt.BDoc
45205163 ())
45215164 pkg.sections
45225165 in
4523
5166
45245167 install_libs pkg;
45255168 install_execs pkg;
45265169 install_docs pkg
4527
5170
45285171 (* Uninstall already installed data *)
45295172 let uninstall _ argv =
45305173 List.iter
45315174 (fun (ev, data) ->
45325175 if ev = install_file_ev then
45335176 begin
4534 if Sys.file_exists data then
5177 if OASISFileUtil.file_exists_case data then
45355178 begin
45365179 info
45375180 (f_ "Removing file '%s'")
45545197 info
45555198 (f_ "Removing directory '%s'")
45565199 data;
4557 BaseFileUtil.rmdir data
5200 OASISFileUtil.rmdir ~ctxt:!BaseContext.default data
45585201 end
45595202 else
45605203 begin
45775220 else if ev = install_findlib_ev then
45785221 begin
45795222 info (f_ "Removing findlib library '%s'") data;
4580 BaseExec.run (ocamlfind ()) ["remove"; data]
5223 OASISExec.run ~ctxt:!BaseContext.default
5224 (ocamlfind ()) ["remove"; data]
45815225 end
45825226 else
45835227 failwithf (f_ "Unknown log event '%s'") ev;
45885232 [install_file_ev;
45895233 install_dir_ev;
45905234 install_findlib_ev;]))
4591
5235
45925236 end
45935237
45945238
5239 # 5233 "setup.ml"
45955240 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
45985243 (** Functions common to OCamlbuild build and doc plugin
45995244 *)
4600
5245
46015246 open OASISGettext
46025247 open BaseEnv
46035248 open BaseStandardVar
4604
5249
46055250 let ocamlbuild_clean_ev =
46065251 "ocamlbuild-clean"
4607
5252
46085253 let ocamlbuildflags =
46095254 var_define
46105255 ~short_desc:(fun () -> "OCamlbuild additional flags")
46115256 "ocamlbuildflags"
4612 (lazy "")
4613
5257 (fun () -> "")
5258
46145259 (** Fix special arguments depending on environment *)
46155260 let fix_args args extra_argv =
46165261 List.flatten
46255270 ]
46265271 else
46275272 [];
4628
5273
46295274 if not (bool_of_string (is_native ())) || (os_type ()) = "Win32" then
46305275 [
46315276 "-byte-plugin"
46335278 else
46345279 [];
46355280 args;
4636
5281
46375282 if bool_of_string (debug ()) then
46385283 ["-tag"; "debug"]
46395284 else
46405285 [];
4641
5286
46425287 if bool_of_string (profile ()) then
46435288 ["-tag"; "profile"]
46445289 else
46455290 [];
4646
4647 OASISUtils.split ' ' (ocamlbuildflags ());
4648
5291
5292 OASISString.nsplit (ocamlbuildflags ()) ' ';
5293
46495294 Array.to_list extra_argv;
46505295 ]
4651
5296
46525297 (** Run 'ocamlbuild -clean' if not already done *)
46535298 let run_clean extra_argv =
46545299 let extra_cli =
46575302 (* Run if never called with these args *)
46585303 if not (BaseLog.exists ocamlbuild_clean_ev extra_cli) then
46595304 begin
4660 BaseExec.run (ocamlbuild ()) (fix_args ["-clean"] extra_argv);
5305 OASISExec.run ~ctxt:!BaseContext.default
5306 (ocamlbuild ()) (fix_args ["-clean"] extra_argv);
46615307 BaseLog.register ocamlbuild_clean_ev extra_cli;
46625308 at_exit
46635309 (fun () ->
46665312 with _ ->
46675313 ())
46685314 end
4669
5315
46705316 (** Run ocamlbuild, unregister all clean events *)
46715317 let run_ocamlbuild args extra_argv =
46725318 (* TODO: enforce that target in args must be UNIX encoded i.e. toto/index.html
46735319 *)
4674 BaseExec.run (ocamlbuild ()) (fix_args args extra_argv);
5320 OASISExec.run ~ctxt:!BaseContext.default
5321 (ocamlbuild ()) (fix_args args extra_argv);
46755322 (* Remove any clean event, we must run it again *)
46765323 List.iter
46775324 (fun (e, d) -> BaseLog.unregister e d)
46785325 (BaseLog.filter [ocamlbuild_clean_ev])
4679
5326
46805327 (** Determine real build directory *)
46815328 let build_dir extra_argv =
46825329 let rec search_args dir =
46895336 dir
46905337 in
46915338 search_args "_build" (fix_args [] extra_argv)
4692
5339
46935340 end
46945341
46955342 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
46985345 (** Build using ocamlbuild
46995346 @author Sylvain Le Gall
47005347 *)
4701
5348
47025349 open OASISTypes
47035350 open OASISGettext
47045351 open OASISUtils
47065353 open OCamlbuildCommon
47075354 open BaseStandardVar
47085355 open BaseMessage
4709
5356
47105357 let cond_targets_hook =
47115358 ref (fun lst -> lst)
4712
5359
47135360 let build pkg argv =
4714
5361
47155362 (* Return the filename in build directory *)
47165363 let in_build_dir fn =
47175364 Filename.concat
47185365 (build_dir argv)
47195366 fn
47205367 in
4721
5368
47225369 (* Return the unix filename in host build directory *)
47235370 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
47275374 let cond_targets =
47285375 List.fold_left
47295376 (fun acc ->
47355382 in_build_dir_of_unix
47365383 (cs, bs, lib)
47375384 in
4738
5385
47395386 let ends_with nd fn =
47405387 let nd_len =
47415388 String.length nd
47475394 (String.length fn - nd_len)
47485395 nd_len) = nd
47495396 in
4750
5397
47515398 let tgts =
47525399 List.flatten
47535400 (List.filter
47555402 (List.map
47565403 (List.filter
47575404 (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))
47635410 unix_files))
47645411 in
4765
5412
47665413 match tgts with
47675414 | _ :: _ ->
47685415 (evs, tgts) :: acc
47715418 (f_ "No possible ocamlbuild targets for library %s")
47725419 cs.cs_name
47735420 end
4774
5421
47755422 | Executable (cs, bs, exec) when var_choose bs.bs_build ->
47765423 begin
47775424 let evs, unix_exec_is, unix_dll_opt =
47795426 in_build_dir_of_unix
47805427 (cs, bs, exec)
47815428 in
4782
5429
47835430 let target ext =
47845431 let unix_tgt =
4785 (BaseFilePath.Unix.concat
5432 (OASISUnixPath.concat
47865433 bs.bs_path
4787 (BaseFilePath.Unix.chop_extension
5434 (OASISUnixPath.chop_extension
47885435 exec.exec_main_is))^ext
47895436 in
47905437 let evs =
47995446 in
48005447 evs, [unix_tgt]
48015448 in
4802
5449
48035450 (* Add executable *)
48045451 let acc =
48055452 match bs.bs_compiled_object with
48135460 in
48145461 acc
48155462 end
4816
5463
48175464 | Library _ | Executable _ | Test _
48185465 | SrcRepo _ | Flag _ | Doc _ ->
48195466 acc)
48215468 (* Keep the pkg.sections ordered *)
48225469 (List.rev pkg.sections);
48235470 in
4824
5471
48255472 (* Check and register built files *)
48265473 let check_and_register (bt, bnm, lst) =
48275474 List.iter
48285475 (fun fns ->
4829 if not (List.exists Sys.file_exists fns) then
5476 if not (List.exists OASISFileUtil.file_exists_case fns) then
48305477 failwithf
48315478 (f_ "No one of expected built files %s exists")
48325479 (String.concat (s_ ", ") (List.map (Printf.sprintf "'%s'") fns)))
48335480 lst;
48345481 (BaseBuilt.register bt bnm lst)
48355482 in
4836
5483
48375484 let cond_targets =
48385485 (* Run the hook *)
48395486 !cond_targets_hook cond_targets
48405487 in
4841
5488
48425489 (* Run a list of target... *)
48435490 run_ocamlbuild
48445491 (List.flatten
48485495 List.iter
48495496 check_and_register
48505497 (List.flatten (List.map fst cond_targets))
4851
4852
5498
5499
48535500 let clean pkg extra_args =
48545501 run_clean extra_args;
48555502 List.iter
48625509 | _ ->
48635510 ())
48645511 pkg.sections
4865
5512
48665513 end
48675514
48685515 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
48715518 (* Create documentation using ocamlbuild .odocl files
48725519 @author Sylvain Le Gall
48735520 *)
4874
5521
48755522 open OASISTypes
48765523 open OASISGettext
48775524 open OASISMessage
48785525 open OCamlbuildCommon
48795526 open BaseStandardVar
4880
4881
4882
5527
5528
5529
48835530 let doc_build path pkg (cs, doc) argv =
48845531 let index_html =
4885 BaseFilePath.Unix.make
5532 OASISUnixPath.make
48865533 [
48875534 path;
48885535 cs.cs_name^".docdir";
48905537 ]
48915538 in
48925539 let tgt_dir =
4893 BaseFilePath.make
5540 OASISHostPath.make
48945541 [
48955542 build_dir argv;
4896 BaseFilePath.of_unix path;
5543 OASISHostPath.of_unix path;
48975544 cs.cs_name^".docdir";
48985545 ]
48995546 in
49035550 BaseBuilt.register
49045551 BaseBuilt.BDoc
49055552 cs.cs_name
4906 [BaseFileUtil.glob
5553 [OASISFileUtil.glob ~ctxt:!BaseContext.default
49075554 (Filename.concat tgt_dir glb)])
49085555 ["*.html"; "*.css"]
4909
5556
49105557 let doc_clean t pkg (cs, doc) argv =
49115558 run_clean argv;
49125559 BaseBuilt.unregister BaseBuilt.BDoc cs.cs_name
4913
5560
49145561 end
49155562
49165563
5564 # 5558 "setup.ml"
49175565 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
49205568 (** Generate custom configure/build/doc/test/install system
49215569 @author
49225570 *)
4923
5571
49245572 open BaseEnv
49255573 open OASISGettext
49265574 open OASISTypes
4927
4928
4929
5575
5576
5577
49305578 type t =
49315579 {
49325580 cmd_main: command_line conditional;
49335581 cmd_clean: (command_line option) conditional;
49345582 cmd_distclean: (command_line option) conditional;
49355583 }
4936
5584
49375585 let run = BaseCustom.run
4938
5586
49395587 let main t _ extra_args =
49405588 let cmd, args =
49415589 var_choose
49435591 t.cmd_main
49445592 in
49455593 run cmd args extra_args
4946
5594
49475595 let clean t pkg extra_args =
49485596 match var_choose t.cmd_clean with
49495597 | Some (cmd, args) ->
49505598 run cmd args extra_args
49515599 | _ ->
49525600 ()
4953
5601
49545602 let distclean t pkg extra_args =
49555603 match var_choose t.cmd_distclean with
49565604 | Some (cmd, args) ->
49575605 run cmd args extra_args
49585606 | _ ->
49595607 ()
4960
5608
49615609 module Build =
49625610 struct
49635611 let main t pkg extra_args =
49705618 begin
49715619 let evs, _ =
49725620 BaseBuilt.of_library
4973 BaseFilePath.of_unix
5621 OASISHostPath.of_unix
49745622 (cs, bs, lib)
49755623 in
49765624 evs
49795627 begin
49805628 let evs, _, _ =
49815629 BaseBuilt.of_executable
4982 BaseFilePath.of_unix
5630 OASISHostPath.of_unix
49835631 (cs, bs, exec)
49845632 in
49855633 evs
49915639 (fun (bt, bnm, lst) -> BaseBuilt.register bt bnm lst)
49925640 evs)
49935641 pkg.sections
4994
5642
49955643 let clean t pkg extra_args =
49965644 clean t pkg extra_args;
49975645 (* TODO: this seems to be pretty generic (at least wrt to ocamlbuild
50075655 | _ ->
50085656 ())
50095657 pkg.sections
5010
5658
50115659 let distclean t pkg extra_args =
50125660 distclean t pkg extra_args
50135661 end
5014
5662
50155663 module Test =
50165664 struct
50175665 let main t pkg (cs, test) extra_args =
50245672 cs.cs_name
50255673 s;
50265674 1.0
5027
5675
50285676 let clean t pkg (cs, test) extra_args =
50295677 clean t pkg extra_args
5030
5678
50315679 let distclean t pkg (cs, test) extra_args =
50325680 distclean t pkg extra_args
50335681 end
5034
5682
50355683 module Doc =
50365684 struct
50375685 let main t pkg (cs, _) extra_args =
50385686 main t pkg extra_args;
50395687 BaseBuilt.register BaseBuilt.BDoc cs.cs_name []
5040
5688
50415689 let clean t pkg (cs, _) extra_args =
50425690 clean t pkg extra_args;
50435691 BaseBuilt.unregister BaseBuilt.BDoc cs.cs_name
5044
5692
50455693 let distclean t pkg (cs, _) extra_args =
50465694 distclean t pkg extra_args
50475695 end
5048
5696
50495697 end
50505698
50515699
5700 # 5694 "setup.ml"
50525701 open OASISTypes;;
50535702
50545703 let setup_t =
50595708 doc =
50605709 [
50615710 ("lambda-term-api", OCamlbuildDocPlugin.doc_build "./");
5062 ("lamda-term-inputrc",
5711 ("lambda-term-actions-man",
50635712 CustomPlugin.Doc.main
50645713 {
50655714 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 ];
50685730 cmd_distclean = [(OASISExpr.EBool true, None)];
50695731 });
50705732 ("lambda-term-inputrc-man",
50885750 ];
50895751 cmd_distclean = [(OASISExpr.EBool true, None)];
50905752 });
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 "./");
50915769 ("lambda-term-actions-man",
5092 CustomPlugin.Doc.main
5770 CustomPlugin.Doc.clean
50935771 {
50945772 CustomPlugin.cmd_main =
50955773 [
51075785 (OASISExpr.EBool true,
51085786 Some (("$rm", ["man/lambda-term-actions.1.gz"])))
51095787 ];
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)];
51265788 cmd_distclean = [(OASISExpr.EBool true, None)];
51275789 });
51285790 ("lambda-term-inputrc-man",
51465808 ];
51475809 cmd_distclean = [(OASISExpr.EBool true, None)];
51485810 });
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 [
51495824 ("lambda-term-actions-man",
5150 CustomPlugin.Doc.clean
5825 CustomPlugin.Doc.distclean
51515826 {
51525827 CustomPlugin.cmd_main =
51535828 [
51655840 (OASISExpr.EBool true,
51665841 Some (("$rm", ["man/lambda-term-actions.1.gz"])))
51675842 ];
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)];
51815843 cmd_distclean = [(OASISExpr.EBool true, None)];
51825844 });
51835845 ("lambda-term-inputrc-man",
52015863 ];
52025864 cmd_distclean = [(OASISExpr.EBool true, None)];
52035865 });
5204 ("lambda-term-actions-man",
5866 ("lamda-term-inputrc",
52055867 CustomPlugin.Doc.distclean
52065868 {
52075869 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)];
52235872 cmd_distclean = [(OASISExpr.EBool true, None)];
52245873 })
52255874 ];
52265875 package =
52275876 {
5228 oasis_version = "0.1";
5877 oasis_version = "0.3";
52295878 ocaml_version = Some (OASISVersion.VGreaterEqual "3.12");
52305879 findlib_version = None;
52315880 name = "lambda-term";
5232 version = "1.1";
5881 version = "1.4";
52335882 license =
52345883 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 });
52405890 license_file = Some "LICENSE";
52415891 copyrights = [];
52425892 maintainers = [];
52435893 authors = ["J\195\169r\195\169mie Dimino"];
52445894 homepage = Some "http://lambda-term.forge.ocamlcore.org/";
5245 synopsis = "Lambda-Term";
5895 synopsis = "Terminal manipulation library for OCaml";
52465896 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.";
52485899 categories = [];
5249 conf_type = (`Configure, "internal", Some "0.2");
5900 conf_type = (`Configure, "internal", Some "0.3");
52505901 conf_custom =
52515902 {
52525903 pre_command = [(OASISExpr.EBool true, None)];
52535904 post_command = [(OASISExpr.EBool true, None)];
52545905 };
5255 build_type = (`Build, "ocamlbuild", Some "0.2");
5906 build_type = (`Build, "ocamlbuild", Some "0.3");
52565907 build_custom =
52575908 {
52585909 pre_command = [(OASISExpr.EBool true, None)];
52595910 post_command = [(OASISExpr.EBool true, None)];
52605911 };
5261 install_type = (`Install, "internal", Some "0.2");
5912 install_type = (`Install, "internal", Some "0.3");
52625913 install_custom =
52635914 {
52645915 pre_command = [(OASISExpr.EBool true, None)];
52975948 [
52985949 FindlibPackage
52995950 ("lwt",
5300 Some (OASISVersion.VGreaterEqual "2.3.0"));
5951 Some (OASISVersion.VGreaterEqual "2.4.0"));
53015952 FindlibPackage ("lwt.unix", None);
53025953 FindlibPackage ("lwt.syntax", None);
53035954 FindlibPackage ("lwt.react", None);
53045955 FindlibPackage
5305 ("zed", Some (OASISVersion.VGreaterEqual "1.1"))
5956 ("zed", Some (OASISVersion.VGreaterEqual "1.2"))
53065957 ];
53075958 bs_build_tools = [ExternalTool "ocamlbuild"];
53085959 bs_c_sources =
53095960 [
53105961 "lTerm_term_stubs.c";
53115962 "lTerm_unix_stubs.c";
5312 "lTerm_windows_stubs.c";
5313 "lTerm_iconv_stubs.c"
5963 "lTerm_windows_stubs.c"
53145964 ];
53155965 bs_data_files = [];
53165966 bs_ccopt = [(OASISExpr.EBool true, [])];
53285978 "LTerm_event";
53295979 "LTerm_unix";
53305980 "LTerm_windows";
5331 "LTerm_iconv";
53325981 "LTerm_style";
53335982 "LTerm_geom";
53345983 "LTerm_draw";
53355984 "LTerm_mouse";
5336 "LTerm_color_mappings";
53375985 "LTerm_widget";
53385986 "LTerm_edit";
53395987 "LTerm_read_line";
53405988 "LTerm_text";
53415989 "LTerm_ui";
53425990 "LTerm_resources";
5343 "LTerm_inputrc"
5991 "LTerm_inputrc";
5992 "LTerm_history"
53445993 ];
5345 lib_internal_modules = ["LTerm_resource_lexer"];
5994 lib_pack = false;
5995 lib_internal_modules =
5996 ["LTerm_color_mappings"; "LTerm_resource_lexer"];
53465997 lib_findlib_parent = None;
53475998 lib_findlib_name = Some "lambda-term";
53485999 lib_findlib_containers = [];
53496000 });
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"; });
53506185 Executable
53516186 ({
53526187 cs_name = "shell";
53766211 {exec_custom = false; exec_main_is = "shell.ml"; });
53776212 Executable
53786213 ({
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 ({
55136214 cs_name = "read-password";
55146215 cs_data = PropList.Data.create ();
55156216 cs_plugin_data = [];
55316232 bs_nativeopt = [(OASISExpr.EBool true, [])];
55326233 },
55336234 {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 });
56086235 Executable
56096236 ({
56106237 cs_name = "read-yes-no";
56516278 bs_nativeopt = [(OASISExpr.EBool true, [])];
56526279 },
56536280 {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 });
56796281 Executable
56806282 ({
5681 cs_name = "rgb";
6283 cs_name = "lambda-term-actions";
56826284 cs_data = PropList.Data.create ();
56836285 cs_plugin_data = [];
56846286 },
56856287 {
56866288 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";
56896291 bs_compiled_object = Best;
56906292 bs_build_depends = [InternalLibrary "lambda-term"];
56916293 bs_build_tools = [ExternalTool "ocamlbuild"];
56986300 bs_byteopt = [(OASISExpr.EBool true, [])];
56996301 bs_nativeopt = [(OASISExpr.EBool true, [])];
57006302 },
5701 {exec_custom = false; exec_main_is = "rgb.ml"; });
6303 {
6304 exec_custom = false;
6305 exec_main_is = "lambda_term_actions.ml";
6306 });
57026307 Executable
57036308 ({
5704 cs_name = "colors_256";
6309 cs_name = "history-stress-test";
57056310 cs_data = PropList.Data.create ();
57066311 cs_plugin_data = [];
57076312 },
57086313 {
57096314 bs_build = [(OASISExpr.EBool true, true)];
57106315 bs_install = [(OASISExpr.EBool true, false)];
5711 bs_path = "examples";
6316 bs_path = "tests";
57126317 bs_compiled_object = Best;
57136318 bs_build_depends = [InternalLibrary "lambda-term"];
57146319 bs_build_tools = [ExternalTool "ocamlbuild"];
57216326 bs_byteopt = [(OASISExpr.EBool true, [])];
57226327 bs_nativeopt = [(OASISExpr.EBool true, [])];
57236328 },
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
57266334 ({
5727 cs_name = "move";
6335 cs_name = "lambda-term-api";
57286336 cs_data = PropList.Data.create ();
57296337 cs_plugin_data = [];
57306338 },
57316339 {
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
57496362 ({
5750 cs_name = "buttons";
6363 cs_name = "lambda-term-actions-man";
57516364 cs_data = PropList.Data.create ();
57526365 cs_plugin_data = [];
57536366 },
57546367 {
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 })
57716463 ];
57726464 plugins =
5773 [(`Extra, "DevFiles", Some "0.2"); (`Extra, "META", Some "0.2")];
6465 [(`Extra, "DevFiles", Some "0.3"); (`Extra, "META", Some "0.3")];
57746466 schema_data = PropList.Data.create ();
57756467 plugin_data = [];
57766468 };
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;
57786475 };;
57796476
57806477 let setup () = BaseSetup.setup setup_t;;
57816478
6479 # 6474 "setup.ml"
57826480 (* OASIS_STOP *)
57836481
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 ();;
00 # OASIS_START
1 # DO NOT EDIT (digest: e280b39969d915e6cc70294d855915c0)
2 version = "1.1"
1 # DO NOT EDIT (digest: 03861a8c15f4c45e208920d5dc7dec7d)
2 version = "1.4"
33 description = "Corss-platform library for terminal manipulation"
44 requires = "lwt.unix lwt.react zed"
55 archive(byte) = "lambda-term.cma"
6 archive(byte, plugin) = "lambda-term.cma"
67 archive(native) = "lambda-term.cmxa"
8 archive(native, plugin) = "lambda-term.cmxs"
79 exists_if = "lambda-term.cma"
810 # OASIS_STOP
911
66 * This file is a part of Lambda-Term.
77 *)
88
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. *)
1012
1113 (* +-----------------------------------------------------------------+
1214 | Mapping generation |
1618 count_r : int;
1719 count_g : int;
1820 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;
2224 map : string;
2325 }
2426
2527 module Int_set = Set.Make(struct type t = int let compare x y = x - y end)
2628
2729 let reindex set =
28 let indexes = Array.make 256 0 in
30 let indexes = String.make 256 '\x00' in
2931 let rec loop idx prev = function
3032 | [] ->
3133 for i = prev to 255 do
32 indexes.(i) <- idx
34 indexes.[i] <- char_of_int idx
3335 done;
3436 indexes
3537 | next :: rest ->
3638 let middle = (prev + next) / 2 in
3739 for i = prev to middle do
38 indexes.(i) <- idx
40 indexes.[i] <- char_of_int idx
3941 done;
4042 let idx = idx + 1 in
4143 for i = middle + 1 to next - 1 do
42 indexes.(i) <- idx
44 indexes.[i] <- char_of_int idx
4345 done;
4446 loop idx next rest
4547 in
188190 | Color generation |
189191 +-----------------------------------------------------------------+ *)
190192
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 "{
193214 count_r = %d;
194215 count_g = %d;
195216 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;
200221 }"
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
208246
209247 let () =
210248 let oc =
213251 else
214252 open_out Sys.argv.(1)
215253 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;
216271 Printf.fprintf oc "
217272 type map = {
218273 count_r : int;
219274 count_g : int;
220275 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;
224279 map : string;
225280 }
226281
230285
231286 let colors_256 = %s
232287 "
233 (code_of_map colors_16)
234 (code_of_map colors_88)
235 (code_of_map colors_256)
288 code16
289 code88
290 code256
77 *)
88
99 open CamomileLibraryDyn.Camomile
10 open Lwt_react
1011 open Lwt
1112 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
1230
1331 (* +-----------------------------------------------------------------+
1432 | The terminal type |
2139 (function
2240 | Not_a_tty -> Some "terminal is not a tty"
2341 | _ -> None)
42
43 module Int_map = Map.Make(struct type t = int let compare a b = a - b end)
2444
2545 type t = {
2646 model : string;
3353 mutable raw_mode : bool;
3454 (* Whether the terminal is currently in raw mode. *)
3555
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;
3858 (* File descriptors. *)
3959
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;
4262 (* Channels. *)
4363
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;
6096 (* Whether input/output are tty devices. *)
6197
6298 mutable escape_time : float;
64100 }
65101
66102 (* +-----------------------------------------------------------------+
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 (* +-----------------------------------------------------------------+
67120 | Creation |
68121 +-----------------------------------------------------------------+ *)
69122
70 let default_model =
123 let default_model, term_defined =
71124 try
72 Sys.getenv "TERM"
125 (Sys.getenv "TERM", true)
73126 with Not_found ->
74 "dumb"
127 ("dumb", false)
75128
76129 let colors_of_term = function
77130 | "Eterm-256color" -> 256
98151 | "xterm+88color" -> 88
99152 | _ -> 16
100153
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
110259 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. *)
112265 lwt incoming_is_a_tty = Lwt_unix.isatty incoming_fd
113266 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 ()
157275
158276 let model t = t.model
159277 let colors t = t.colors
164282 let escape_time t = t.escape_time
165283 let set_escape_time t time = t.escape_time <- time
166284
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
181295
182296 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
193415
194416 (* +-----------------------------------------------------------------+
195417 | Modes |
229451 Unix.c_parenb = false;
230452 Unix.c_echo = false;
231453 Unix.c_icanon = false;
232 Unix.c_isig = false;
233454 Unix.c_vmin = 1;
234455 Unix.c_vtime = 0;
456 Unix.c_isig = false;
235457 } in
236458 term.raw_mode <- true;
237459 return (Mode_unix attr)
360582 let _ =
361583 LTerm_windows.fill_console_output_character
362584 term.outgoing_fd
363 (UChar.of_char ' ')
585 uspace
364586 (info.LTerm_windows.size.cols * info.LTerm_windows.size.rows)
365587 { row = 0; col = 0 }
366588 in
377599 let _ =
378600 LTerm_windows.fill_console_output_character
379601 term.outgoing_fd
380 (UChar.of_char ' ')
602 uspace
381603 (info.LTerm_windows.size.cols * (info.LTerm_windows.size.rows - info.LTerm_windows.cursor_position.row)
382604 + info.LTerm_windows.size.cols - info.LTerm_windows.cursor_position.col)
383605 info.LTerm_windows.cursor_position
395617 let _ =
396618 LTerm_windows.fill_console_output_character
397619 term.outgoing_fd
398 (UChar.of_char ' ')
620 uspace
399621 (info.LTerm_windows.size.cols * info.LTerm_windows.cursor_position.row
400622 + info.LTerm_windows.cursor_position.col)
401623 { row = 0; col = 0 }
413635 let _ =
414636 LTerm_windows.fill_console_output_character
415637 term.outgoing_fd
416 (UChar.of_char ' ')
638 uspace
417639 info.LTerm_windows.size.cols
418640 { row = info.LTerm_windows.cursor_position.row; col = 0 }
419641 in
430652 let _ =
431653 LTerm_windows.fill_console_output_character
432654 term.outgoing_fd
433 (UChar.of_char ' ')
655 uspace
434656 (info.LTerm_windows.size.cols - info.LTerm_windows.cursor_position.col)
435657 info.LTerm_windows.cursor_position
436658 in
447669 let _ =
448670 LTerm_windows.fill_console_output_character
449671 term.outgoing_fd
450 (UChar.of_char ' ')
672 uspace
451673 info.LTerm_windows.cursor_position.col
452674 { row = info.LTerm_windows.cursor_position.row; col = 0 }
453675 in
480702 raise_lwt Not_a_tty
481703
482704 (* +-----------------------------------------------------------------+
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 =
542725 match UChar.code char with
543726 | 0x2500 -> hline
544727 | 0x2501 -> hline
622805 | 0x254f -> vline
623806 | 0x2550 -> hline
624807 | 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
626876
627877 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)
629879
630880 let fprintl term str =
631881 fprint term (str ^ "\n")
652902 let map_color term r g b =
653903 let open LTerm_color_mappings in
654904 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
656906 [LTerm_style.color] ensure that all components are in the range
657907 [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))))
659913
660914 let add_index term buf base n =
661915 if n < 8 then begin
684938 | LTerm_style.RGB(r, g, b) ->
685939 add_index term buf base (map_color term r g b)
686940
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
687952 let expand term text =
688953 if Array.length text = 0 then
689954 ""
690955 else begin
691 let open LTerm_style in
692956 let buf = Buffer.create 256 in
693957 Buffer.add_string buf "\027[0m";
694958 let rec loop idx prev_style =
697961 Buffer.contents buf
698962 end else begin
699963 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;
710965 Buffer.add_string buf (Zed_utf8.singleton ch);
711966 loop (idx + 1) style
712967 end
713968 in
714 loop 0 none
969 loop 0 LTerm_style.none
715970 end
716971
717972 let windows_fg_color term = function
726981
727982 let windows_default_attributes = { LTerm_windows.foreground = 7; LTerm_windows.background = 0 }
728983
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
729994 let fprints_windows term oc text =
730 let open LTerm_style in
731995 let rec loop idx prev_attr =
732996 if idx = Array.length text then begin
733997 lwt () = Lwt_io.flush oc in
735999 return ()
7361000 end else begin
7371001 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
7471003 lwt () =
7481004 if attr <> prev_attr then
7491005 lwt () = Lwt_io.flush oc in
7521008 else
7531009 return ()
7541010 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
7561012 loop (idx + 1) attr
7571013 end
7581014 in
7711027
7721028 let fprintls term text =
7731029 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 ()
7741117
7751118 (* +-----------------------------------------------------------------+
7761119 | Rendering |
7851128 p1.foreground = p2.foreground &&
7861129 p1.background = p2.background
7871130
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 =
7891135 let open LTerm_draw in
7901136 if not (same_style new_point old_point) then begin
7911137 (* Reset styles if they are different from the previous point. *)
7971143 add_color term buf Codes.foreground new_point.foreground;
7981144 add_color term buf Codes.background new_point.background;
7991145 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)
8021155
8031156 type render_kind = Render_screen | Render_box
8041157
8151168 "\r\027[0m");
8161169 (* The last displayed point. *)
8171170 let last_point = ref {
818 char = UChar.of_char ' ';
1171 char = uspace;
8191172 bold = false;
8201173 underline = false;
8211174 blink = false;
8231176 foreground = LTerm_style.default;
8241177 background = LTerm_style.default;
8251178 } 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
8271181 let line = Array.unsafe_get matrix y in
8281182 (* 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
8301184 for x = 0 to Array.length line - 1 do
8311185 let point = Array.unsafe_get line x in
8321186 render_point term buf !last_point point;
8331187 last_point := point
8341188 done
8351189 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'
8371191 done;
8381192 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';
8391195 fprint term (Buffer.contents buf)
8401196
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 =
8431215 (* Build the matrix of char infos *)
8441216 let matrix =
8451217 Array.map
8461218 (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)
8591244 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
8601256 in
8611257 let info = LTerm_windows.get_console_screen_buffer_info term.outgoing_fd in
8621258 let window_rect = info.LTerm_windows.window in
8661262 window_rect
8671263 | Render_box ->
8681264 { 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 }
8711267 in
8721268 ignore (
8731269 LTerm_windows.write_console_output
8821278 let render_update term old_matrix matrix =
8831279 if term.outgoing_is_a_tty then
8841280 if term.windows then
885 render_windows term Render_screen matrix
1281 render_windows term Render_screen false matrix
8861282 else
8871283 render_update_unix term Render_screen old_matrix matrix
8881284 else
8911287 let render term m = render_update term [||] m
8921288
8931289 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
9001355 raise_lwt Not_a_tty
9011356
9021357 (* +-----------------------------------------------------------------+
9041359 +-----------------------------------------------------------------+ *)
9051360
9061361 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)
9071365
9081366 (* +-----------------------------------------------------------------+
9091367 | Standard terminals |
88
99 (** Terminal definitions *)
1010
11 open CamomileLibrary
12
1113 type t
1214 (** Type of terminals. *)
1315
1416 (** {6 Creation} *)
17
18 exception No_such_encoding of string
19 (** Exception raised when an encoding does not exist. *)
1520
1621 val create :
1722 ?windows : bool ->
2530 terminal using [input_fd] and [input_channel] for inputs and
2631 [output_fd] and [output_channel] for outputs.
2732
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].
3035
3136 - [model] is the type of the terminal, such as "rxvt" or
3237 "xterm". It defaults to the contents of the "TERM" environment
4247 defaults to [LTerm_windows.get_console_output_cp] if [windows] is
4348 [true] and [LTerm_unix.system_encoding] otherwise. Note that
4449 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 *)
4664
4765 (** {6 Informations} *)
4866
5371 (** Number of colors of the terminal. *)
5472
5573 val windows : t -> bool
56 (** Whether the terminal is in windows mode or not. *)
74 (** Whether the terminal is a windows console or not. *)
5775
5876 val is_a_tty : t -> bool
5977 (** [is_a_tty term] whether the intput and output of the given
7896 (** Exception raised when trying to use a function that can only be
7997 used on terminals. *)
8098
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.
91101
92102 It raises {!Not_a_tty} if the output of the given terminal is
93103 not a tty. *)
197207 (** Reads and returns one event. The terminal should be in raw mode
198208 before calling this function, otherwise event will not be
199209 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. *)
201214
202215 (** {6 Printing} *)
203216
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>].
205223
206224 Where [<prefix>] is one of:
207225 - ['f'], which means that the function takes as argument a terminal
211229 and [<suffixes>] is a combination of:
212230 - ['l'] which means that a new-line character is printed after the message
213231 - ['f'] which means that the function takes as argument a {b format} instead
214 of a string
232 of a string
215233 - ['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.
222237 *)
223238
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
227242 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
229244 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
233248 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
235250 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
239254 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
241256 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. *)
242299
243300 (** {6 Rendering} *)
244301
264321 {!print_box} because it works better under windows and is more
265322 efficient.
266323
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. *)
269342
270343 (** {6 Misc} *)
271344
291364 val set_size_from_fd : Lwt_unix.file_descr -> LTerm_geom.size -> unit Lwt.t
292365 (** [set_size_from_fd fd size] tries to set the size of the terminal
293366 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 }
106106 bind [{ control = true; meta = false; shift = false; code = Char(UChar.of_char 'a') }] [Zed Goto_bol];
107107 bind [{ control = true; meta = false; shift = false; code = Char(UChar.of_char 'e') }] [Zed Goto_eol];
108108 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];
109110 bind [{ control = true; meta = false; shift = false; code = Char(UChar.of_char 'k') }] [Zed Kill_next_line];
110111 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];
113114 bind [{ control = true; meta = false; shift = false; code = Char(UChar.of_char 'w') }] [Zed Kill];
114115 bind [{ control = true; meta = false; shift = false; code = Char(UChar.of_char 'y') }] [Zed Yank];
115116 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
-110
src/lTerm_iconv.ml less more
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
-72
src/lTerm_iconv.mli less more
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
-125
src/lTerm_iconv_stubs.c less more
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 }
1515 val load : ?file : string -> unit -> unit Lwt.t
1616 (** [load ?file ()] loads key bindings from [file], which defaults
1717 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. *)
331331 { Error "parsing error in actions" }
332332
333333 {
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) () =
338338 try_lwt
339339 lwt ic = Lwt_io.open_file ~mode:Lwt_io.input file in
340340 let rec loop num handler =
357357 | Error msg ->
358358 raise (Parse_error (file, num, msg))
359359 in
360 loop 1 handle_edit_action
360 try_lwt
361 loop 1 handle_edit_action
362 finally
363 Lwt_io.close ic
361364 with Unix.Unix_error(Unix.ENOENT, _, _) ->
362365 return ()
363366 }
1616
1717 exception Interrupt
1818 type prompt = LTerm_text.t
19 type history = Zed_utf8.t list
1920
2021 (* +-----------------------------------------------------------------+
2122 | Completion |
4142
4243 let lookup word words = List.filter (fun word' -> Zed_utf8.starts_with word' word) words
4344 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))))
13245
13346 (* +-----------------------------------------------------------------+
13447 | Actions |
15063 | Prev_search
15164 | Cancel_search
15265 | Break
66 | Suspend
15367
15468 let doc_of_action = function
15569 | Edit action -> LTerm_edit.doc_of_action action
16781 | Prev_search -> "search backward in the history."
16882 | Cancel_search -> "cancel search mode."
16983 | Break -> "cancel edition."
84 | Suspend -> "suspend edition."
17085
17186 let actions = [
17287 Interrupt_or_delete_next_char, "interrupt-or-delete-next-char";
18398 Prev_search, "prev-search";
18499 Cancel_search, "cancel-search";
185100 Break, "break";
101 Suspend, "suspend";
186102 ]
187103
188104 let actions_to_names = Array.of_list (List.sort (fun (a1, n1) (a2, n2) -> Pervasives.compare a1 a2) actions)
238154 bind [{ control = false; meta = false; shift = false; code = Down }] [History_next];
239155 bind [{ control = false; meta = false; shift = false; code = Tab }] [Complete];
240156 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)];
241160 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];
242162 bind [{ control = true; meta = false; shift = false; code = Char(UChar.of_char 'm') }] [Accept];
243163 bind [{ control = true; meta = false; shift = false; code = Char(UChar.of_char 'l') }] [Clear_screen];
244164 bind [{ control = true; meta = false; shift = false; code = Char(UChar.of_char 'r') }] [Prev_search];
245165 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];
246168 bind [{ control = false; meta = true; shift = false; code = Left }] [Complete_bar_prev];
247169 bind [{ control = false; meta = true; shift = false; code = Right }] [Complete_bar_next];
248170 bind [{ control = false; meta = true; shift = false; code = Home }] [Complete_bar_first];
563485 end
564486
565487 | Break ->
566 Zed_edit.insert context (Zed_rope.of_string "^C");
567488 raise Sys.Break
568489
569490 | _ ->
657578 | Running in a terminal |
658579 +-----------------------------------------------------------------+ *)
659580
581 let newline = UChar.of_char '\n'
660582 let vline = LTerm_draw.({ top = Light; bottom = Light; left = Blank; right = Blank })
661583 let reverse_style = { LTerm_style.none with LTerm_style.reverse = Some true }
662584 let default_prompt = LTerm_text.of_string "# "
669591 | e :: l -> drop (count - 1) l
670592
671593 (* 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 *)
673601 let rec compute_position cols pos text start stop =
674602 if start = stop then
675603 pos
677605 let ch, style = text.(start) in
678606 if ch = newline then
679607 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
682610 else
683611 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
684619
685620 let rec get_index_of_last_displayed_word column columns index words =
686621 match words with
714649 in
715650 loop row col 0
716651
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
717680 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
719682 let event, set_prompt = E.create () in
720683 let prompt = S.switch (S.const default_prompt) event in
721684 let key_sequence, set_key_sequence = S.create [] in
790753
791754 method draw_update =
792755 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
794757 let styled, position = self#stylise false in
795758 let prompt = S.value prompt in
796759 (* Compute the position of the cursor after displaying the
802765 (* Compute the position of the cursor after displaying the
803766 input. *)
804767 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
805775 let matrix =
806776 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
810777 match S.value self#message with
811778 | Some msg ->
812779 (* Compute the height of the message. *)
813780 let message_height = (compute_position (size.cols - 2) { row = 0; col = 0 } msg 0 (Array.length msg)).row + 1 in
814781 (* 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
816783
817784 (* 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
819786 let matrix = LTerm_draw.make_matrix matrix_size in
820 let ctx = LTerm_draw.context matrix matrix_size in
821787
822788 (* Update the height parameter. *)
823789 height <- total_height;
824790
825791 (* 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
828802
829803 (* Draw a frame for the message. *)
830804 LTerm_draw.draw_frame ctx {
831 row1 = pos_after_newline.row;
805 row1 = prompt_input_height;
832806 col1 = 0;
833807 row2 = total_height;
834808 col2 = size.cols;
835809 } 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;
836813
837814 (* Draw the message. *)
838815 let ctx = LTerm_draw.sub ctx {
839 row1 = pos_after_newline.row + 1;
816 row1 = prompt_input_height + 1;
840817 col1 = 1;
841818 row2 = total_height - 1;
842819 col2 = size.cols - 1;
851828 let comp_words = drop comp_start (S.value self#completion_words) in
852829
853830 (* 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
855832
856833 (* 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
858835 let matrix = LTerm_draw.make_matrix matrix_size in
859 let ctx = LTerm_draw.context matrix matrix_size in
860836
861837 (* Update the height parameter. *)
862838 height <- total_height;
863839
864840 (* 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
867851
868852 (* Draw a frame for the completion. *)
869853 LTerm_draw.draw_frame ctx {
870 row1 = pos_after_newline.row;
854 row1 = prompt_input_height;
871855 col1 = 0;
872856 row2 = total_height;
873857 col2 = size.cols;
874858 } 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;
875862
876863 (* Draw the completion. *)
877864 let ctx = LTerm_draw.sub ctx {
878 row1 = pos_after_newline.row + 1;
865 row1 = prompt_input_height + 1;
879866 col1 = 1;
880867 row2 = total_height - 1;
881868 col2 = size.cols - 1;
902889 matrix
903890
904891 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
907894 let matrix = LTerm_draw.make_matrix matrix_size in
908 let ctx = LTerm_draw.context matrix matrix_size in
909895 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;
912898 matrix
913899 end
914900 in
901 lwt () = LTerm.hide_cursor term in
915902 lwt () =
916903 if displayed then
917904 (* Go back to the beginning of displayed text. *)
920907 return ()
921908 in
922909 (* Display everything. *)
923 lwt () = LTerm.print_box term matrix in
910 lwt () = LTerm.print_box_with_newlines term matrix in
924911 (* Update the cursor. *)
925 cursor <- pos_after_before;
912 cursor <- pos_cursor;
926913 (* 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
939916 lwt () = LTerm.flush term in
940917 displayed <- true;
941918 return ()
944921
945922 method draw_success =
946923 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 ()
965944
966945 method draw_failure =
967946 self#draw_success
969948 method hide =
970949 if visible then begin
971950 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 ()
991972 end else
992973 return ()
993974
997978 self#queue_draw_update
998979 end else
999980 return ()
981
982 val mutable mode = None
1000983
1001984 (* The main loop. *)
1002985 method private loop =
10271010 | { control = false; meta = false; shift = false; code = Char ch } ->
10281011 Zed_macro.add self#macro (Edit (LTerm_edit.Zed (Zed_edit.Insert ch)));
10291012 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
10301017 | _ ->
10311018 ()
10321019 else
10501037 | Edit LTerm_edit.Play_macro :: actions ->
10511038 Zed_macro.cancel self#macro;
10521039 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
10531067 | action :: actions ->
10541068 self#send_action action;
10551069 self#exec actions
10571071 self#loop
10581072
10591073 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);
10631076
10641077 let running = ref true in
10651078
10781091 ])
10791092 in
10801093
1081 lwt mode =
1094 lwt () =
10821095 match LTerm.is_a_tty term with
10831096 | 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 ()
10861100 | false ->
1087 return None
1101 return ()
10881102 in
10891103
10901104 lwt result =
2121 type prompt = LTerm_text.t
2222 (** Type of prompts. *)
2323
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
2428 (** {6 Completion} *)
2529
2630 val common_prefix : string list -> string
3337 val lookup_assoc : Zed_utf8.t -> (Zed_utf8.t * 'a) list -> (Zed_utf8.t * 'a) list
3438 (** [lookup_assoc word words] does the same as {!lookup} but works
3539 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. *)
5740
5841 (** {6 Actions} *)
5942
9174 (** Cancel search mode. *)
9275 | Break
9376 (** Raise [Sys.Break]. *)
77 | Suspend
78 (** Suspend the program. *)
9479
9580 val bindings : action list Zed_input.Make(LTerm_key).t ref
9681 (** Bindings. *)
55 *
66 * This file is a part of Lambda-Term.
77 *)
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 ""
823
924 (* +-----------------------------------------------------------------+
1025 | Types |
6060
6161 val load : string -> t Lwt.t
6262 (** Same as {!parse} but parses the contents of a file. *)
63
64 val home : string
65 (** The home directory. *)
66 * This file is a part of Lambda-Term.
77 */
88
9 #include <caml/mlvalues.h>
10 #include <caml/unixsupport.h>
9 #include <lwt_unix.h>
1110 #include <caml/alloc.h>
1211 #include <caml/fail.h>
12 #include <caml/memory.h>
1313
1414 #if defined(_WIN32) || defined(_WIN64)
1515
2323 CAMLprim value lt_term_get_size_from_fd(value fd)
2424 {
2525 CONSOLE_SCREEN_BUFFER_INFO info;
26 value result;
2627
2728 if (!GetConsoleScreenBufferInfo(Handle_val(fd), &info)) {
2829 win32_maperr(GetLastError());
2930 uerror("GetConsoleScreenBufferInfo", Nothing);
3031 }
3132
32 value result = caml_alloc_tuple(2);
33 result = caml_alloc_tuple(2);
3334 Field(result, 0) = Val_int(info.srWindow.Bottom - info.srWindow.Top + 1);
3435 Field(result, 1) = Val_int(info.srWindow.Right - info.srWindow.Left + 1);
3536 return result;
3839 CAMLprim value lt_term_set_size_from_fd(value fd, value val_size)
3940 {
4041 CONSOLE_SCREEN_BUFFER_INFO info;
42 SMALL_RECT rect;
4143
4244 if (!GetConsoleScreenBufferInfo(Handle_val(fd), &info)) {
4345 win32_maperr(GetLastError());
4446 uerror("GetConsoleScreenBufferInfo", Nothing);
4547 }
4648
47 SMALL_RECT rect;
49 rect;
4850 rect.Top = info.srWindow.Top;
4951 rect.Left = info.srWindow.Left;
5052 rect.Bottom = rect.Top + Int_val(Field(val_size, 0)) - 1;
6466 | Terminal sizes on Unix |
6567 +-----------------------------------------------------------------+ */
6668
69 #include <unistd.h>
6770 #include <sys/ioctl.h>
6871 #include <termios.h>
6972 #include <errno.h>
3131 in
3232 loop 0 0
3333
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
3472 let to_string txt =
3573 let buf = Buffer.create (Array.length txt) in
3674 Array.iter (fun (ch, style) -> Buffer.add_string buf (Zed_utf8.singleton ch)) txt;
67105 end
68106 in
69107 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
70204
71205 (* +-----------------------------------------------------------------+
72206 | Markup strings |
2222 val to_string : t -> Zed_utf8.t
2323 (** Returns the string part of a styled string. *)
2424
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
2531 val of_rope : Zed_rope.t -> t
2632 (** Creates a styled string from a rope. *)
2733
3137 val stylise : string -> LTerm_style.t -> t
3238 (** [stylise string style] creates a styled string with all styles
3339 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. *)
3447
3548 (** {6 Markup strings} *)
3649
7373 +-----------------------------------------------------------------+ *)
7474
7575 let create term ?(save_state = true) draw =
76 lwt size = LTerm.get_size term in
7776 lwt mode = LTerm.enter_raw_mode term in
7877 lwt () = if save_state then LTerm.save_state term else return () in
7978 let stream, push = Lwt_stream.create () in
8382 mode = mode;
8483 state = Init;
8584 restore_state = save_state;
86 size = size;
85 size = LTerm.size term;
8786 matrix_a = [||];
8887 matrix_b = [||];
8988 cursor_visible = false;
101100 lwt () = ui.drawer in
102101 lwt () = LTerm.leave_raw_mode ui.term ui.mode in
103102 if ui.restore_state then
103 lwt () = LTerm.show_cursor ui.term in
104104 LTerm.load_state ui.term
105105 else
106106 return ()
191191 | Loop |
192192 +-----------------------------------------------------------------+ *)
193193
194 let wait ui =
194 let rec wait ui =
195195 check ui;
196196 if ui.state = Init then draw ui;
197197 lwt ev = pick [LTerm.read_event ui.term; Lwt_stream.next ui.draw_error_stream >>= fail] in
1414 external get_system_encoding : unit -> string = "lt_unix_get_system_encoding"
1515
1616 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
18320
19321 (* +-----------------------------------------------------------------+
20322 | Parsing of encoded characters |
21323 +-----------------------------------------------------------------+ *)
22324
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
37334 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
57343 in
58344 try_lwt
59 src.bytes.[0] <- first_byte;
60 reset cd;
345 assert (output#output (String.make 1 first_byte) 0 1 = 1);
61346 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)
65349
66350 (* +-----------------------------------------------------------------+
67351 | Input of escape sequence |
550834 in
551835 loop 0 (Array.length sequences)
552836
553 let rec parse_event ?(escape_time = 0.1) cd stream =
837 let rec parse_event ?(escape_time = 0.1) encoding stream =
554838 lwt byte = Lwt_stream.next stream in
555839 match byte with
556840 | '\x1b' -> begin
586870 | _ -> raise Exit);
587871 })
588872 with Exit ->
589 parse_event cd stream
873 parse_event encoding stream
590874 end
591875 | seq ->
592876 match find_sequence seq with
637921 return(LTerm_event.Key { control = false; meta = true; shift = false; code = Char(UChar.of_char byte) })
638922 | byte' ->
639923 lwt () = Lwt_stream.junk stream in
640 lwt code = parse_char cd stream byte' in
924 lwt code = parse_char encoding stream byte' in
641925 return (LTerm_event.Key { control = false; meta = true; shift = false; code = Char code })
642926 end
643927 | '\x00' .. '\x1f' ->
652936 return (LTerm_event.Key { control = false; meta = false; shift = false; code = Char(UChar.of_char byte) })
653937 | _ ->
654938 (* Encoded characters *)
655 lwt code = parse_char cd stream byte in
939 lwt code = parse_char encoding stream byte in
656940 return (LTerm_event.Key { control = false; meta = false; shift = false; code = Char code })
88
99 (** Unix specific functions *)
1010
11 open CamomileLibraryDyn.Camomile
12
1113 val sigwinch : int option
1214 (** The number of the signal used to indicate that the terminal size
1315 have changed. It is [None] on windows. *)
1517 val system_encoding : string
1618 (** The encoding used by the system. *)
1719
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]. *)
2121
2222 CAMLprim value lt_unix_get_system_encoding()
2323 {
24 char codeset[128];
25 sprintf(codeset, "CP%d", GetACP());
26 return caml_copy_string(codeset);
24 return caml_copy_string("");
2725 }
2826
2927 #else
815815 (* A event from the terminal. *)
816816
817817 let lambda_termrc =
818 Filename.concat (try Sys.getenv "HOME" with Not_found -> "") ".lambda-termrc"
818 Filename.concat LTerm_resources.home ".lambda-termrc"
819819
820820 let file_exists file =
821821 try_lwt
101101 {
102102 DWORD event_count;
103103 INPUT_RECORD *input = &(job->input);
104 WORD code;
105 int i;
106 DWORD bs;
104107
105108 for (;;) {
106 if (!ReadConsoleInput(job->handle, input, 1, &event_count)) {
109 if (!ReadConsoleInputW(job->handle, input, 1, &event_count)) {
107110 job->error_code = GetLastError();
108111 return;
109112 }
113116 if (input->Event.KeyEvent.bKeyDown) {
114117 if (input->Event.KeyEvent.uChar.UnicodeChar)
115118 return;
116 WORD code = input->Event.KeyEvent.wVirtualKeyCode;
117 int i;
119 code = input->Event.KeyEvent.wVirtualKeyCode;
118120 for (i = 0; i < sizeof(code_table)/sizeof(code_table[0]); i++)
119121 if (code == code_table[i])
120122 return;
121123 }
122124 break;
123125 case MOUSE_EVENT: {
124 DWORD bs = input->Event.MouseEvent.dwButtonState;
126 bs = input->Event.MouseEvent.dwButtonState;
125127 if (!(input->Event.MouseEvent.dwEventFlags & MOUSE_MOVED) &&
126128 bs & (FROM_LEFT_1ST_BUTTON_PRESSED |
127129 FROM_LEFT_2ND_BUTTON_PRESSED |
148150
149151 CAMLprim value lt_windows_read_console_input_result(value val_job)
150152 {
153 INPUT_RECORD *input;
154 DWORD cks, bs;
155 WORD code;
156 int i;
151157 CAMLparam1(val_job);
152158 CAMLlocal3(result, x, y);
153159 struct job_read_console_input *job = Job_read_console_input_val(val_job);
155161 win32_maperr(job->error_code);
156162 uerror("ReadConsoleInput", Nothing);
157163 }
158 INPUT_RECORD *input = &(job->input);
164 input = &(job->input);
159165 switch (input->EventType) {
160166 case KEY_EVENT: {
161167 result = caml_alloc(1, 0);
162168 x = caml_alloc_tuple(4);
163169 Field(result, 0) = x;
164 DWORD cks = input->Event.KeyEvent.dwControlKeyState;
170 cks = input->Event.KeyEvent.dwControlKeyState;
165171 Field(x, 0) = Val_bool((cks & LEFT_CTRL_PRESSED) | (cks & RIGHT_CTRL_PRESSED));
166172 Field(x, 1) = Val_bool((cks & LEFT_ALT_PRESSED) | (cks & RIGHT_ALT_PRESSED));
167173 Field(x, 2) = Val_bool(cks & SHIFT_PRESSED);
168 WORD code = input->Event.KeyEvent.wVirtualKeyCode;
169 int i;
174 code = input->Event.KeyEvent.wVirtualKeyCode;
170175 for (i = 0; i < sizeof(code_table)/sizeof(code_table[0]); i++)
171176 if (code == code_table[i]) {
172177 Field(x, 3) = Val_int(i);
181186 result = caml_alloc(1, 1);
182187 x = caml_alloc_tuple(6);
183188 Field(result, 0) = x;
184 DWORD cks = input->Event.MouseEvent.dwControlKeyState;
189 cks = input->Event.MouseEvent.dwControlKeyState;
185190 Field(x, 0) = Val_bool((cks & LEFT_CTRL_PRESSED) | (cks & RIGHT_CTRL_PRESSED));
186191 Field(x, 1) = Val_bool((cks & LEFT_ALT_PRESSED) | (cks & RIGHT_ALT_PRESSED));
187192 Field(x, 2) = Val_bool(cks & SHIFT_PRESSED);
188193 Field(x, 4) = Val_int(input->Event.MouseEvent.dwMousePosition.Y);
189194 Field(x, 5) = Val_int(input->Event.MouseEvent.dwMousePosition.X);
190 DWORD bs = input->Event.MouseEvent.dwButtonState;
195 bs = input->Event.MouseEvent.dwButtonState;
191196 if (bs & FROM_LEFT_1ST_BUTTON_PRESSED)
192197 Field(x, 3) = Val_int(0);
193198 else if (bs & FROM_LEFT_2ND_BUTTON_PRESSED)
222227 CAMLlocal2(result, x);
223228
224229 CONSOLE_SCREEN_BUFFER_INFO info;
230 int color;
225231
226232 if (!GetConsoleScreenBufferInfo(Handle_val(val_fd), &info)) {
227233 win32_maperr(GetLastError());
241247 Field(result, 1) = x;
242248
243249 x = caml_alloc_tuple(2);
244 int color = 0;
250 color = 0;
245251 if (info.wAttributes & FOREGROUND_RED) color |= 1;
246252 if (info.wAttributes & FOREGROUND_GREEN) color |= 2;
247253 if (info.wAttributes & FOREGROUND_BLUE) color |= 4;
277283 CAMLprim value lt_windows_get_console_mode(value val_fd)
278284 {
279285 DWORD mode;
286 value result;
280287
281288 if (!GetConsoleMode(Handle_val(val_fd), &mode)) {
282289 win32_maperr(GetLastError());
283290 uerror("GetConsoleMode", Nothing);
284291 }
285292
286 value result = caml_alloc_tuple(7);
293 result = caml_alloc_tuple(7);
287294 Field(result, 0) = Val_bool(mode & ENABLE_ECHO_INPUT);
288295 Field(result, 1) = Val_bool(mode & ENABLE_INSERT_MODE);
289296 Field(result, 2) = Val_bool(mode & ENABLE_LINE_INPUT);
320327 CAMLprim value lt_windows_get_console_cursor_info(value val_fd)
321328 {
322329 CONSOLE_CURSOR_INFO info;
330 value result;
323331 if (!GetConsoleCursorInfo(Handle_val(val_fd), &info)) {
324332 win32_maperr(GetLastError());
325333 uerror("GetConsoleCursorInfo", Nothing);
326334 }
327 value result = caml_alloc_tuple(2);
335 result = caml_alloc_tuple(2);
328336 Field(result, 0) = Val_int(info.dwSize);
329337 Field(result, 1) = Val_bool(info.bVisible);
330338 return result;
390398 CAMLparam5(val_fd, val_chars, val_size, val_coord, val_rect);
391399 CAMLlocal1(result);
392400
401 value line, src;
402 int fg, bg;
403 WORD attrs;
393404 int lines = Int_val(Field(val_size, 0));
394405 int columns = Int_val(Field(val_size, 1));
406 COORD size;
407 COORD coord;
408 SMALL_RECT rect;
395409
396410 /* Convert characters */
397 CHAR_INFO buffer[lines * columns];
411 CHAR_INFO *buffer = (CHAR_INFO*)lwt_unix_malloc(lines * columns * sizeof (CHAR_INFO));
398412 int l, c;
399413 CHAR_INFO *dst = buffer;
400414 for (l = 0; l < lines; l++) {
401 value line = Field(val_chars, l);
415 line = Field(val_chars, l);
402416 for (c = 0; c < columns; c++) {
403 value src = Field(line, c);
417 src = Field(line, c);
404418 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;
408422 if (fg & 1) attrs |= FOREGROUND_RED;
409423 if (fg & 2) attrs |= FOREGROUND_GREEN;
410424 if (fg & 4) attrs |= FOREGROUND_BLUE;
418432 }
419433 }
420434
421 COORD size;
422 COORD coord;
423 SMALL_RECT rect;
424435 size.X = Int_val(Field(val_size, 1));
425436 size.Y = Int_val(Field(val_size, 0));
426437 coord.X = Int_val(Field(val_coord, 1));
430441 rect.Bottom = Int_val(Field(val_rect, 2)) - 1;
431442 rect.Right = Int_val(Field(val_rect, 3)) - 1;
432443
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);
434446 win32_maperr(GetLastError());
435447 uerror("WriteConsoleOutput", Nothing);
436448 }
449 free(buffer);
437450
438451 result = caml_alloc_tuple(4);
439452 Field(result, 0) = Val_int(rect.Top);
00 # OASIS_START
1 # DO NOT EDIT (digest: 3e2cc76824806ede32cd9445818f443f)
1 # DO NOT EDIT (digest: ba3c322b421c5f64349e83e10a4f7083)
22 LTerm
33 LTerm_key
44 LTerm_event
55 LTerm_unix
66 LTerm_windows
7 LTerm_iconv
87 LTerm_style
98 LTerm_geom
109 LTerm_draw
1110 LTerm_mouse
12 LTerm_color_mappings
1311 LTerm_widget
1412 LTerm_edit
1513 LTerm_read_line
1715 LTerm_ui
1816 LTerm_resources
1917 LTerm_inputrc
18 LTerm_history
19 LTerm_color_mappings
2020 LTerm_resource_lexer
2121 # OASIS_STOP
+0
-7
src/liblambda-term.clib less more
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