about summary refs log tree commit diff stats
path: root/js/magic-bird/imgs/extracted-1688-map/MapPartsWhite/hills_white/29.png
blob: dc950b1897a0d0b87c728c184b664a273e855cf3 (plain)
ofshex dumpascii
0000 89 50 4e 47 0d 0a 1a 0a 00 00 00 0d 49 48 44 52 00 00 00 50 00 00 00 1a 08 06 00 00 00 20 d2 db .PNG........IHDR...P............
0020 a7 00 00 04 ff 49 44 41 54 78 da ed 98 0f 48 94 67 1c c7 d5 92 d4 49 2e 11 63 45 c6 8c 1a 16 c5 .....IDATx....H.g.....I..cE.....
0040 16 46 51 51 2c 8a c6 a4 51 24 b1 d8 68 24 85 14 c9 c9 91 2c 22 31 8a 48 0a f1 48 44 29 2e 44 51 .FQQ,...Q$..h$.....,"1.H..HD).DQ
0060 1c 1e 91 24 8b 49 62 18 82 23 31 4a 8a a2 8d 8c 45 8e 0c 8d b4 3f b4 ca 7d 7f f0 79 e1 2d 4c 6f ...$.Ib..#1J....E....?..}..y.-Lo
0080 a1 78 37 3d f8 70 f7 de bd cf 73 ef fb 7d be bf 3f cf 1b 11 31 f9 9a 7c 4d be 86 78 0d 0e 0e ae .x7=.p....s..}..?...1..|M..x....
00a0 10 eb 44 ea 28 cd f7 a9 f1 7f 17 cd 2b ba c4 03 f1 04 1e 89 87 e2 be 38 f3 31 22 68 cc 76 f1 87 ..D.(.......+..........8.1"h.v..
00c0 e8 16 e9 e1 2a ce 14 91 25 e6 0e f1 db 1a 71 42 d4 89 6a f1 b3 c8 e3 f3 1d 71 53 f4 8b 1e 71 4e ....*...%.....qB..j......qS...qN
00e0 94 8a 5d 62 7e 10 ff fb bd f0 8b 72 f1 58 ec 0d 57 01 b7 89 df 45 b1 f8 9c ef a2 c4 26 51 29 ea ..]b~......r.X..W....E......&Q).
0100 c5 1e 31 c7 35 e6 4b 51 26 2e 21 62 37 42 be 11 7d e2 3c e3 17 d8 02 b9 16 2a d2 35 c7 71 9c bb ..1.5.KQ&.!b7B..}.<......*.5.q..
0120 56 5c 11 45 22 e5 3f 5e 7b bc 88 1b 4f f1 66 e3 1c 73 55 9b e8 14 d3 c4 65 c2 f5 e8 30 63 7f 14 V\.E".?^{...O.f..sU.....e...0c..
0140 4f 39 b7 1c 97 3e 17 6f 11 f2 35 98 38 19 b8 f7 a4 2d 18 e3 57 e3 c2 74 9c 68 ae de c4 6f 49 62 O9...>.o..5.8....-..W..t.h...oIb
0160 6a a8 3b 6f 91 38 20 0e 8a cf 44 09 79 6d b7 d8 6c bf 0f 33 76 0d f9 cf 84 ba 2d 02 88 58 8d a0 j.;o.8....D.ym..l..3v.....-..X..
0180 37 71 f5 0b f1 8a 3c 69 e7 f7 8a 76 f1 1d 0e 2e c2 dd b6 58 d9 ae f9 4d e8 8c 50 14 2d 4d e4 88 7q....<i...v.......X...M..P.-M..
01a0 2d 38 a6 15 e1 d6 72 7c 97 b0 5b 8f 33 a6 7e 60 9e e5 b8 f5 1f f1 a7 68 c4 c9 67 11 f1 02 df 5d -8....r|..[.3.~`.......h..g....]
01c0 e7 f7 7b e4 b9 1e 04 b7 73 9a c4 45 c4 7f 49 14 c4 13 15 1d 88 1b 69 61 4d e5 b7 94 b0 83 6b 5f ..{.....s..E..I.......iaM.....k_
01e0 30 1e 85 62 3e 39 ed 35 2b de cd cd 34 88 d3 a2 c5 5c c4 f9 1e 0a c2 8a 11 8a 40 1b 21 da 2c ae 0..b>9.5+...4....\........@.!.,.
0200 89 df 44 8d a8 62 be 6a e6 f1 73 dc c4 ff 35 31 ae 9d 2a dc 4f ae 2d e0 fc 87 cc 99 c7 62 74 21 ..D..b.j..s...51..*.O.-......bt!
0220 f2 1b 52 c4 0d 8c 60 f7 14 33 56 a2 7d 82 30 bd 5c 40 21 c9 bd 89 3c 97 81 50 3f 70 e1 b6 c2 d1 ..R...`..3V.}.0.\@!...<..P?p....
0240 8c ad c4 4d 09 e4 ba 99 23 e4 c2 00 21 5b 85 68 0d 38 d0 c4 ac 10 b5 fc 77 03 ae 6b e6 3a 1a 29 ...M....#...![.h.8......w..k.:.)
0260 44 9d 14 9f 57 d0 8b b0 6d 44 46 23 f3 5f c3 00 6f 39 cf 72 ee 33 18 a0 bd 6a 18 ea 22 63 ac 0a D...W...mDF#._..o9.r.3...j.."c..
0280 72 e3 33 68 3e a3 f9 3e 15 31 f2 85 8f 1b 77 5c 50 88 ed bf 60 ec 74 c3 35 6f 24 73 98 78 49 ae r.3h>..>.1....w\P...`.t.5o$s.xI.
02a0 ef 33 2d 54 f8 3c 7d 84 85 3a 84 23 02 08 5f 8b 50 96 0b 7f e5 b8 02 01 3b 10 cb ae ef 08 98 e3 .3-T.<}..:.#.._.P.......;.......
02c0 4e 71 4e 80 f3 6a 58 fc 93 dc c3 7e fe a7 06 97 b7 e0 cc 3c 72 a8 87 b9 4a de 71 90 eb 73 2a 79 NqN..jX....~.......<r...J.q..s*y
02e0 20 85 16 c2 72 59 b2 39 43 ac 12 fb 10 ee 2c ad 41 29 6d 42 5a 90 6e 8d 7d ef 38 ca 69 3f 82 18 ....rY.9C.....,.A)mBZ.n.}.8.i?..
0300 7b 9a fc 56 cd ff 57 70 a3 f5 b8 ad 91 9b 0e 20 6a 0b d7 66 c5 2a 17 91 72 28 2c eb 69 ae f7 72 {..V..Wp........j..f.*..r(,.i..r
0320 6c f7 ba 95 f7 c5 b4 5c df 88 6f ed be 87 b8 96 04 f7 c1 91 30 e9 23 cd f5 7f 23 56 19 82 38 fc l......\..o.........0.#...#V..8.
0340 42 21 e9 21 22 8e 51 f9 f7 f0 5e 8c e8 1e 8a 57 1c 42 59 17 30 9b f9 93 3f 7a 8f 38 46 37 6c 61 B!.!".Q...^....W.BY.0...?z.8F7la
0360 3b 6d 94 7b c9 5c 9c e8 45 a4 2a 9c 58 c9 bb 1f 57 5a ab 73 18 87 f9 09 5d cb c1 5f b1 bf de 48 ;m.{.\..E.*.X...WZ.s....].._...H
0380 61 58 ed ec b5 dd 91 18 4a ae 89 1e e5 0a 6f db b7 ab e4 ab 62 57 2e 0b e0 b0 13 a4 96 0a d2 8b aX......J.....o.....bW..........
03a0 17 31 7d 88 b9 83 45 30 67 2e 13 f3 6c 57 84 2b 97 84 a4 88 a3 28 60 3c ae ea 27 64 9d 82 71 c1 .1}...E0g...lW.+.....(`<..'d..q.
03c0 55 58 9c 9c 5c 47 d5 2d a4 00 ec 23 7c 8b 28 02 b6 27 5f 49 91 9c 35 51 1e 6f a5 20 e0 55 c2 f4 UX..\G.-...#|.(..'_I..5Q.o...U..
03e0 1c 85 c3 4f e5 2c c0 6d 1e 7a bf 97 b4 31 d6 bc c7 92 f7 d6 51 40 16 d2 5d 24 4c a4 e7 83 f9 f4 ...O.,.m.z...1......Q@..]$L.....
0400 6b 4e bf 57 ce f6 30 93 1c 67 c2 fe 85 98 39 84 fb 42 84 9f c3 7b 5c c4 44 7c d1 72 9c a7 3d f1 kN.W..0..g....9..B...{\.D|.r..=.
0420 b9 0a c6 31 da 10 2f 22 9a a8 1b 10 2e 69 2c 72 71 38 89 96 48 d5 cc e6 61 41 1d 8e f3 53 40 ea ...1../".....i,rq8..H...aA...S@.
0440 09 d5 03 9c 17 e3 16 2c 6c dc 46 7e 89 0f 76 95 69 9e ad 02 ee fc c0 6f 33 09 cb cb ec 55 2d 2c .......,l.F~..v.i......o3....U-,
0460 6f 51 38 ca c8 7f 3e 42 35 8b 9c 76 88 ef 3c c1 36 e6 e3 25 56 14 d5 2b 85 5d ca 56 2e dc 9e 5c oQ8...>B5..v..<.6..%V..+.].V...\
0480 cc 08 62 7c 32 89 3c 9f ed 96 8f ed dd 5c 9e ca 78 29 0e 1d ec 3f 07 78 72 d3 8e e3 ea d9 a7 de ..b|2.<......\..x)...?.xr.......
04a0 a2 80 1c 47 c0 25 34 c6 8b c2 e1 b1 fc 16 1a d0 4c 72 50 2d 4f 4c 12 83 18 bf 19 97 94 b0 91 1f ...G.%4.........LrP-OL..........
04c0 60 67 b1 8d a4 df 4c 9b f2 80 4d fe 75 0a 47 2b a1 5b 8a 70 9d b4 29 47 87 7b 92 13 6e 39 cb 7a `g....L...M.u.G+.[.p..)G.{..n9.z
04e0 aa af e9 f2 97 39 8e c4 19 1b 70 ad 09 f5 13 cd ec 45 f2 5a 01 85 20 07 61 4f b1 38 59 14 8e 3e .....9....p......E.Z....aO.8Y..>
0500 5c 99 41 35 9d 47 91 48 70 a2 62 a2 56 d6 28 42 3a d9 d9 f2 d9 83 55 1e b3 27 3a 4f 68 c4 52 08 \.A5.G.Hp.b.V.(B:.....U..':Oh.R.
0520 c9 4a fa 2f a2 f7 90 54 a7 d9 99 2c 00 00 00 00 49 45 4e 44 ae 42 60 82 .J./...T...,....IEND.B`.
='n295' href='#n295'>295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626
 `when` for macosx. Refs #461.' href='/ahoang/Nim/commit/lib/wrappers/readline/readline.nim?h=devel&id=07d19df80f36f3c0639172385b89b1854c8ebcee'>07d19df80 ^


55c407464 ^
07d19df80 ^
55c407464 ^





























b2bc5440a ^
55c407464 ^
b2bc5440a ^
55c407464 ^



b2bc5440a ^

55c407464 ^


b2bc5440a ^

55c407464 ^



07d19df80 ^
b2bc5440a ^
55c407464 ^



b2bc5440a ^
55c407464 ^
2e25574ff ^
b2bc5440a ^
55c407464 ^

07d19df80 ^
b2bc5440a ^
55c407464 ^








































































































































































































































































































































































2e25574ff ^
55c407464 ^
2e25574ff ^
55c407464 ^
2e25574ff ^
55c407464 ^




2e25574ff ^
55c407464 ^
2e25574ff ^
55c407464 ^
2e25574ff ^
55c407464 ^


2e25574ff ^
55c407464 ^
2e25574ff ^
55c407464 ^
2e25574ff ^
55c407464 ^
2e25574ff ^
55c407464 ^









2e25574ff ^
55c407464 ^










2e25574ff ^
55c407464 ^
2e25574ff ^
55c407464 ^


2e25574ff ^
55c407464 ^
2e25574ff ^
55c407464 ^





















2e25574ff ^
55c407464 ^













b2bc5440a ^
55c407464 ^













































































d4bc11b65 ^
55c407464 ^






































b2bc5440a ^
55c407464 ^




2e25574ff ^
55c407464 ^





















































2e25574ff ^
55c407464 ^


d4bc11b65 ^

55c407464 ^





























































































































































































































































































b2bc5440a ^
55c407464 ^




b2bc5440a ^
55c407464 ^



2e25574ff ^
55c407464 ^


d4bc11b65 ^

55c407464 ^







b2bc5440a ^
55c407464 ^

b2bc5440a ^
55c407464 ^
b2bc5440a ^
55c407464 ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209






















                                                                               
                                 
                      
                                 
        
                                          

        
                                          
                                     
                           














































                                                                            
                                        
              
                          
                                             















                                                                               


                                                               










                                                              


                                                                                               
      

                                                                                                   





































                                                                           

                                                   
 




                                                                             
 
                                                                                  
                                                                 
 



                                                                               
 
                                                                        
                                                            
 


                                                                   
 
                                                                                                  
 


                                                                         
 
                                                                                                  





























                                                                              
                    
                                                  
                                       



                                               

                                     


                                                                         

                                                            



                                            
                         
                                                                               



                                                                  
                                  
                  
                          
                                 

 
                         
                                                                       








































































































































































































































































































































































                                                                                 
                                                                      
                                                  
                                                        
                                                 
                                                                            




                                                                   
                                                                   
                                                            
                                                                                
                                                                          
                                                                         


                                                                    
                                                              
                                                    
                                                                           
                                                                  
                                                                         
                                                               
                                                                  









                                                                                 
                                                                       










                                                                             
                                                       
                                                       
                                                                               


                                                                   
                                                                           
                                                                       
                                                              





















                                                                                
                                                                   













                                                                            
                                                                       













































































                                                                                  
                                                                            






































                                                                                  
                                                                         




                                                                           
                                                     





















































                                                                                     
                                                                             


                                                                                 

                                                                      





























































































































































































































































































                                                                                            
                                          




                                           
                      



                                             
                          


                  

               







                                                                                                 
                                                 

 
                                                       
                                                   
                                                          
                                                      
# Readline.h -- the names of functions callable from within readline. 
# Copyright (C) 1987-2009 Free Software Foundation, Inc.
#
#   This file is part of the GNU Readline Library (Readline), a library
#   for reading lines of text with interactive input and history editing.      
#
#   Readline is free software: you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation, either version 3 of the License, or
#   (at your option) any later version.
#
#   Readline is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
#
#   You should have received a copy of the GNU General Public License
#   along with Readline.  If not, see <http://www.gnu.org/licenses/>.
#

{.deadCodeElim: on.}
when defined(windows): 
  const 
    readlineDll* = "readline.dll"
elif defined(macosx): 
  # Mac OS X ships with 'libedit'
  const 
    readlineDll* = "libedit(.2|.1|).dylib"
else: 
  const 
    readlineDll* = "libreadline.so.6(|.0)"
#  mangle "'CommandFunc'" CommandFunc
#  mangle TvcpFunc TvcpFunc

import rltypedefs

# Some character stuff. 

const 
  control_character_threshold* = 0x00000020 # Smaller than this is control. 
  control_character_mask* = 0x0000001F # 0x20 - 1 
  meta_character_threshold* = 0x0000007F # Larger than this is Meta. 
  control_character_bit* = 0x00000040 # 0x000000, must be off. 
  meta_character_bit* = 0x00000080 # x0000000, must be on. 
  largest_char* = 255         # Largest character value. 

template CTRL_CHAR*(c: expr): expr = 
  (c < control_character_threshold and ((c and 0x00000080) == 0))

template META_CHAR*(c: expr): expr = 
  (c > meta_character_threshold and c <= largest_char)

template CTRL*(c: expr): expr = 
  (c and control_character_mask)

template META*(c: expr): expr = 
  (c or meta_character_bit)

template UNMETA*(c: expr): expr = 
  (c and not meta_character_bit)

template UNCTRL*(c: expr): expr = 
  (c or 32 or control_character_bit)

# Beware:  these only work with single-byte ASCII characters. 

const 
  RETURN_CHAR* = CTRL('M'.ord)
  RUBOUT_CHAR* = 0x0000007F
  ABORT_CHAR* = CTRL('G'.ord)
  PAGE_CHAR* = CTRL('L'.ord)
  ESC_CHAR* = CTRL('['.ord)

# A keymap contains one entry for each key in the ASCII set.
#   Each entry consists of a type and a pointer.
#   FUNCTION is the address of a function to run, or the
#   address of a keymap to indirect through.
#   TYPE says which kind of thing FUNCTION is. 

type 
  KEYMAP_ENTRY*{.pure, final.} = object 
    typ*: char
    function*: CommandFunc
{.deprecated: [TKEYMAP_ENTRY: KEYMAP_ENTRY].}


# This must be large enough to hold bindings for all of the characters
#   in a desired character set (e.g, 128 for ASCII, 256 for ISO Latin-x,
#   and so on) plus one for subsequence matching. 

const 
  KEYMAP_SIZE* = 257
  ANYOTHERKEY* = KEYMAP_SIZE - 1

# I wanted to make the above structure contain a union of:
#   union { rl_TCommandFunc_t *function; struct _keymap_entry *keymap; } value;
#   but this made it impossible for me to create a static array.
#   Maybe I need C lessons. 

type 
  KEYMAP_ENTRY_ARRAY* = array[0..KEYMAP_SIZE - 1, KEYMAP_ENTRY]
  PKeymap* = ptr KEYMAP_ENTRY
{.deprecated: [TKEYMAP_ENTRY_ARRAY: KEYMAP_ENTRY_ARRAY].}

# The values that TYPE can have in a keymap entry. 

const 
  ISFUNC* = 0
  ISKMAP* = 1
  ISMACR* = 2

when false: 
  var 
    emacs_standard_keymap*{.importc: "emacs_standard_keymap", 
                            dynlib: readlineDll.}: KEYMAP_ENTRY_ARRAY
    emacs_meta_keymap*{.importc: "emacs_meta_keymap", dynlib: readlineDll.}: KEYMAP_ENTRY_ARRAY
    emacs_ctlx_keymap*{.importc: "emacs_ctlx_keymap", dynlib: readlineDll.}: KEYMAP_ENTRY_ARRAY
  var 
    vi_insertion_keymap*{.importc: "vi_insertion_keymap", dynlib: readlineDll.}: KEYMAP_ENTRY_ARRAY
    vi_movement_keymap*{.importc: "vi_movement_keymap", dynlib: readlineDll.}: KEYMAP_ENTRY_ARRAY
# Return a new, empty keymap.
#   Free it with free() when you are done. 

proc make_bare_keymap*(): PKeymap{.cdecl, importc: "rl_make_bare_keymap", 
                                   dynlib: readlineDll.}
# Return a new keymap which is a copy of MAP. 

proc copy_keymap*(a2: PKeymap): PKeymap{.cdecl, importc: "rl_copy_keymap", 
    dynlib: readlineDll.}
# Return a new keymap with the printing characters bound to rl_insert,
#   the lowercase Meta characters bound to run their equivalents, and
#   the Meta digits bound to produce numeric arguments. 

proc make_keymap*(): PKeymap{.cdecl, importc: "rl_make_keymap", 
                              dynlib: readlineDll.}
# Free the storage associated with a keymap. 

proc discard_keymap*(a2: PKeymap){.cdecl, importc: "rl_discard_keymap", 
                                   dynlib: readlineDll.}
# These functions actually appear in bind.c 
# Return the keymap corresponding to a given name.  Names look like
#   `emacs' or `emacs-meta' or `vi-insert'.  

proc get_keymap_by_name*(a2: cstring): PKeymap{.cdecl, 
    importc: "rl_get_keymap_by_name", dynlib: readlineDll.}
# Return the current keymap. 

proc get_keymap*(): PKeymap{.cdecl, importc: "rl_get_keymap", 
                             dynlib: readlineDll.}
# Set the current keymap to MAP. 

proc set_keymap*(a2: PKeymap){.cdecl, importc: "rl_set_keymap", 
                               dynlib: readlineDll.}

const 
  tildeDll = readlineDll

type 
  Hook_func* = proc (a2: cstring): cstring{.cdecl.}
{.deprecated: [Thook_func: Hook_func].}

when not defined(macosx):
  # If non-null, this contains the address of a function that the application
  #   wants called before trying the standard tilde expansions.  The function
  #   is called with the text sans tilde, and returns a malloc()'ed string
  #   which is the expansion, or a NULL pointer if the expansion fails. 

  var expansion_preexpansion_hook*{.importc: "tilde_expansion_preexpansion_hook", 
                                    dynlib: tildeDll.}: Hook_func

  # If non-null, this contains the address of a function to call if the
  #   standard meaning for expanding a tilde fails.  The function is called
  #   with the text (sans tilde, as in "foo"), and returns a malloc()'ed string
  #   which is the expansion, or a NULL pointer if there is no expansion. 

  var expansion_failure_hook*{.importc: "tilde_expansion_failure_hook", 
                               dynlib: tildeDll.}: Hook_func

  # When non-null, this is a NULL terminated array of strings which
  #   are duplicates for a tilde prefix.  Bash uses this to expand
  #   `=~' and `:~'. 

  var additional_prefixes*{.importc: "tilde_additional_prefixes", dynlib: tildeDll.}: cstringArray

  # When non-null, this is a NULL terminated array of strings which match
  #   the end of a username, instead of just "/".  Bash sets this to
  #   `:' and `=~'. 

  var additional_suffixes*{.importc: "tilde_additional_suffixes", dynlib: tildeDll.}: cstringArray

# Return a new string which is the result of tilde expanding STRING. 

proc expand*(a2: cstring): cstring{.cdecl, importc: "tilde_expand", 
                                    dynlib: tildeDll.}
# Do the work of tilde expansion on FILENAME.  FILENAME starts with a
#   tilde.  If there is no expansion, call tilde_expansion_failure_hook. 

proc expand_word*(a2: cstring): cstring{.cdecl, importc: "tilde_expand_word", 
    dynlib: tildeDll.}
# Find the portion of the string beginning with ~ that should be expanded. 

proc find_word*(a2: cstring, a3: cint, a4: ptr cint): cstring{.cdecl, 
    importc: "tilde_find_word", dynlib: tildeDll.}

# Hex-encoded Readline version number. 

const 
  READLINE_VERSION* = 0x00000600 # Readline 6.0 
  VERSION_MAJOR* = 6
  VERSION_MINOR* = 0

# Readline data structures. 
# Maintaining the state of undo.  We remember individual deletes and inserts
#   on a chain of things to do. 
# The actions that undo knows how to undo.  Notice that UNDO_DELETE means
#   to insert some text, and UNDO_INSERT means to delete some text.   I.e.,
#   the code tells undo what to undo, not how to undo it. 

type 
  Undo_code* = enum 
    UNDO_DELETE, UNDO_INSERT, UNDO_BEGIN, UNDO_END
{.deprecated: [Tundo_code: Undo_code].}

# What an element of THE_UNDO_LIST looks like. 

type 
  UNDO_LIST*{.pure, final.} = object 
    next*: ptr UNDO_LIST
    start*: cint
    theEnd*: cint             # Where the change took place. 
    text*: cstring            # The text to insert, if undoing a delete. 
    what*: Undo_code          # Delete, Insert, Begin, End. 
{.deprecated: [TUNDO_LIST: UNDO_LIST].}
  

# The current undo list for RL_LINE_BUFFER. 

when not defined(macosx):
  var undo_list*{.importc: "rl_undo_list", dynlib: readlineDll.}: ptr UNDO_LIST

# The data structure for mapping textual names to code addresses. 

type 
  FUNMAP*{.pure, final.} = object 
    name*: cstring
    function*: CommandFunc
{.deprecated: [TFUNMAP: FUNMAP].}


when not defined(macosx):
  var funmap*{.importc: "funmap", dynlib: readlineDll.}: ptr ptr FUNMAP

# **************************************************************** 
#								    
#	     Functions available to bind to key sequences	    
#								    
# **************************************************************** 
# Bindable commands for numeric arguments. 

proc digit_argument*(a2: cint, a3: cint): cint{.cdecl, 
    importc: "rl_digit_argument", dynlib: readlineDll.}
proc universal_argument*(a2: cint, a3: cint): cint{.cdecl, 
    importc: "rl_universal_argument", dynlib: readlineDll.}
# Bindable commands for moving the cursor. 

proc forward_byte*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_forward_byte", 
    dynlib: readlineDll.}
proc forward_char*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_forward_char", 
    dynlib: readlineDll.}
proc forward*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_forward", 
    dynlib: readlineDll.}
proc backward_byte*(a2: cint, a3: cint): cint{.cdecl, 
    importc: "rl_backward_byte", dynlib: readlineDll.}
proc backward_char*(a2: cint, a3: cint): cint{.cdecl, 
    importc: "rl_backward_char", dynlib: readlineDll.}
proc backward*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_backward", 
    dynlib: readlineDll.}
proc beg_of_line*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_beg_of_line", 
    dynlib: readlineDll.}
proc end_of_line*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_end_of_line", 
    dynlib: readlineDll.}
proc forward_word*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_forward_word", 
    dynlib: readlineDll.}
proc backward_word*(a2: cint, a3: cint): cint{.cdecl, 
    importc: "rl_backward_word", dynlib: readlineDll.}
proc refresh_line*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_refresh_line", 
    dynlib: readlineDll.}
proc clear_screen*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_clear_screen", 
    dynlib: readlineDll.}
proc skip_csi_sequence*(a2: cint, a3: cint): cint{.cdecl, 
    importc: "rl_skip_csi_sequence", dynlib: readlineDll.}
proc arrow_keys*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_arrow_keys", 
    dynlib: readlineDll.}
# Bindable commands for inserting and deleting text. 

proc insert*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_insert", 
                                        dynlib: readlineDll.}
proc quoted_insert*(a2: cint, a3: cint): cint{.cdecl, 
    importc: "rl_quoted_insert", dynlib: readlineDll.}
proc tab_insert*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_tab_insert", 
    dynlib: readlineDll.}
proc newline*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_newline", 
    dynlib: readlineDll.}
proc do_lowercase_version*(a2: cint, a3: cint): cint{.cdecl, 
    importc: "rl_do_lowercase_version", dynlib: readlineDll.}
proc rubout*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_rubout", 
                                        dynlib: readlineDll.}
proc delete*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_delete", 
                                        dynlib: readlineDll.}
proc rubout_or_delete*(a2: cint, a3: cint): cint{.cdecl, 
    importc: "rl_rubout_or_delete", dynlib: readlineDll.}
proc delete_horizontal_space*(a2: cint, a3: cint): cint{.cdecl, 
    importc: "rl_delete_horizontal_space", dynlib: readlineDll.}
proc delete_or_show_completions*(a2: cint, a3: cint): cint{.cdecl, 
    importc: "rl_delete_or_show_completions", dynlib: readlineDll.}
proc insert_comment*(a2: cint, a3: cint): cint{.cdecl, 
    importc: "rl_insert_comment", dynlib: readlineDll.}
# Bindable commands for changing case. 

proc upcase_word*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_upcase_word", 
    dynlib: readlineDll.}
proc downcase_word*(a2: cint, a3: cint): cint{.cdecl, 
    importc: "rl_downcase_word", dynlib: readlineDll.}
proc capitalize_word*(a2: cint, a3: cint): cint{.cdecl, 
    importc: "rl_capitalize_word", dynlib: readlineDll.}
# Bindable commands for transposing characters and words. 

proc transpose_words*(a2: cint, a3: cint): cint{.cdecl, 
    importc: "rl_transpose_words", dynlib: readlineDll.}
proc transpose_chars*(a2: cint, a3: cint): cint{.cdecl, 
    importc: "rl_transpose_chars", dynlib: readlineDll.}
# Bindable commands for searching within a line. 

proc char_search*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_char_search", 
    dynlib: readlineDll.}
proc backward_char_search*(a2: cint, a3: cint): cint{.cdecl, 
    importc: "rl_backward_char_search", dynlib: readlineDll.}
# Bindable commands for readline's interface to the command history. 

proc beginning_of_history*(a2: cint, a3: cint): cint{.cdecl, 
    importc: "rl_beginning_of_history", dynlib: readlineDll.}
proc end_of_history*(a2: cint, a3: cint): cint{.cdecl, 
    importc: "rl_end_of_history", dynlib: readlineDll.}
proc get_next_history*(a2: cint, a3: cint): cint{.cdecl, 
    importc: "rl_get_next_history", dynlib: readlineDll.}
proc get_previous_history*(a2: cint, a3: cint): cint{.cdecl, 
    importc: "rl_get_previous_history", dynlib: readlineDll.}
# Bindable commands for managing the mark and region. 

proc set_mark*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_set_mark", 
    dynlib: readlineDll.}
proc exchange_point_and_mark*(a2: cint, a3: cint): cint{.cdecl, 
    importc: "rl_exchange_point_and_mark", dynlib: readlineDll.}
# Bindable commands to set the editing mode (emacs or vi). 

proc vi_editing_mode*(a2: cint, a3: cint): cint{.cdecl, 
    importc: "rl_vi_editing_mode", dynlib: readlineDll.}
proc emacs_editing_mode*(a2: cint, a3: cint): cint{.cdecl, 
    importc: "rl_emacs_editing_mode", dynlib: readlineDll.}
# Bindable commands to change the insert mode (insert or overwrite) 

proc overwrite_mode*(a2: cint, a3: cint): cint{.cdecl, 
    importc: "rl_overwrite_mode", dynlib: readlineDll.}
# Bindable commands for managing key bindings. 

proc re_read_init_file*(a2: cint, a3: cint): cint{.cdecl, 
    importc: "rl_re_read_init_file", dynlib: readlineDll.}
proc dump_functions*(a2: cint, a3: cint): cint{.cdecl, 
    importc: "rl_dump_functions", dynlib: readlineDll.}
proc dump_macros*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_dump_macros", 
    dynlib: readlineDll.}
proc dump_variables*(a2: cint, a3: cint): cint{.cdecl, 
    importc: "rl_dump_variables", dynlib: readlineDll.}
# Bindable commands for word completion. 

proc complete*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_complete", 
    dynlib: readlineDll.}
proc possible_completions*(a2: cint, a3: cint): cint{.cdecl, 
    importc: "rl_possible_completions", dynlib: readlineDll.}
proc insert_completions*(a2: cint, a3: cint): cint{.cdecl, 
    importc: "rl_insert_completions", dynlib: readlineDll.}
proc old_menu_complete*(a2: cint, a3: cint): cint{.cdecl, 
    importc: "rl_old_menu_complete", dynlib: readlineDll.}
proc menu_complete*(a2: cint, a3: cint): cint{.cdecl, 
    importc: "rl_menu_complete", dynlib: readlineDll.}
proc backward_menu_complete*(a2: cint, a3: cint): cint{.cdecl, 
    importc: "rl_backward_menu_complete", dynlib: readlineDll.}
# Bindable commands for killing and yanking text, and managing the kill ring. 

proc kill_word*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_kill_word", 
    dynlib: readlineDll.}
proc backward_kill_word*(a2: cint, a3: cint): cint{.cdecl, 
    importc: "rl_backward_kill_word", dynlib: readlineDll.}
proc kill_line*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_kill_line", 
    dynlib: readlineDll.}
proc backward_kill_line*(a2: cint, a3: cint): cint{.cdecl, 
    importc: "rl_backward_kill_line", dynlib: readlineDll.}
proc kill_full_line*(a2: cint, a3: cint): cint{.cdecl, 
    importc: "rl_kill_full_line", dynlib: readlineDll.}
proc unix_word_rubout*(a2: cint, a3: cint): cint{.cdecl, 
    importc: "rl_unix_word_rubout", dynlib: readlineDll.}
proc unix_filename_rubout*(a2: cint, a3: cint): cint{.cdecl, 
    importc: "rl_unix_filename_rubout", dynlib: readlineDll.}
proc unix_line_discard*(a2: cint, a3: cint): cint{.cdecl, 
    importc: "rl_unix_line_discard", dynlib: readlineDll.}
proc copy_region_to_kill*(a2: cint, a3: cint): cint{.cdecl, 
    importc: "rl_copy_region_to_kill", dynlib: readlineDll.}
proc kill_region*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_kill_region", 
    dynlib: readlineDll.}
proc copy_forward_word*(a2: cint, a3: cint): cint{.cdecl, 
    importc: "rl_copy_forward_word", dynlib: readlineDll.}
proc copy_backward_word*(a2: cint, a3: cint): cint{.cdecl, 
    importc: "rl_copy_backward_word", dynlib: readlineDll.}
proc yank*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_yank", 
                                      dynlib: readlineDll.}
proc yank_pop*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_yank_pop", 
    dynlib: readlineDll.}
proc yank_nth_arg*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_yank_nth_arg", 
    dynlib: readlineDll.}
proc yank_last_arg*(a2: cint, a3: cint): cint{.cdecl, 
    importc: "rl_yank_last_arg", dynlib: readlineDll.}
when defined(Windows): 
  proc paste_from_clipboard*(a2: cint, a3: cint): cint{.cdecl, 
      importc: "rl_paste_from_clipboard", dynlib: readlineDll.}
# Bindable commands for incremental searching. 

proc reverse_search_history*(a2: cint, a3: cint): cint{.cdecl, 
    importc: "rl_reverse_search_history", dynlib: readlineDll.}
proc forward_search_history*(a2: cint, a3: cint): cint{.cdecl, 
    importc: "rl_forward_search_history", dynlib: readlineDll.}
# Bindable keyboard macro commands. 

proc start_kbd_macro*(a2: cint, a3: cint): cint{.cdecl, 
    importc: "rl_start_kbd_macro", dynlib: readlineDll.}
proc end_kbd_macro*(a2: cint, a3: cint): cint{.cdecl, 
    importc: "rl_end_kbd_macro", dynlib: readlineDll.}
proc call_last_kbd_macro*(a2: cint, a3: cint): cint{.cdecl, 
    importc: "rl_call_last_kbd_macro", dynlib: readlineDll.}
# Bindable undo commands. 

proc revert_line*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_revert_line", 
    dynlib: readlineDll.}
proc undo_command*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_undo_command", 
    dynlib: readlineDll.}
# Bindable tilde expansion commands. 

proc tilde_expand*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_tilde_expand", 
    dynlib: readlineDll.}
# Bindable terminal control commands. 

proc restart_output*(a2: cint, a3: cint): cint{.cdecl, 
    importc: "rl_restart_output", dynlib: readlineDll.}
proc stop_output*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_stop_output", 
    dynlib: readlineDll.}
# Miscellaneous bindable commands. 

proc abort*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_abort", 
                                       dynlib: readlineDll.}
proc tty_status*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_tty_status", 
    dynlib: readlineDll.}
# Bindable commands for incremental and non-incremental history searching. 

proc history_search_forward*(a2: cint, a3: cint): cint{.cdecl, 
    importc: "rl_history_search_forward", dynlib: readlineDll.}
proc history_search_backward*(a2: cint, a3: cint): cint{.cdecl, 
    importc: "rl_history_search_backward", dynlib: readlineDll.}
proc noninc_forward_search*(a2: cint, a3: cint): cint{.cdecl, 
    importc: "rl_noninc_forward_search", dynlib: readlineDll.}
proc noninc_reverse_search*(a2: cint, a3: cint): cint{.cdecl, 
    importc: "rl_noninc_reverse_search", dynlib: readlineDll.}
proc noninc_forward_search_again*(a2: cint, a3: cint): cint{.cdecl, 
    importc: "rl_noninc_forward_search_again", dynlib: readlineDll.}
proc noninc_reverse_search_again*(a2: cint, a3: cint): cint{.cdecl, 
    importc: "rl_noninc_reverse_search_again", dynlib: readlineDll.}
# Bindable command used when inserting a matching close character. 

proc insert_close*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_insert_close", 
    dynlib: readlineDll.}
# Not available unless READLINE_CALLBACKS is defined. 

proc callback_handler_install*(a2: cstring, a3: TvcpFunc){.cdecl, 
    importc: "rl_callback_handler_install", dynlib: readlineDll.}
proc callback_read_char*(){.cdecl, importc: "rl_callback_read_char", 
                            dynlib: readlineDll.}
proc callback_handler_remove*(){.cdecl, importc: "rl_callback_handler_remove", 
                                 dynlib: readlineDll.}
# Things for vi mode. Not available unless readline is compiled -DVI_MODE. 
# VI-mode bindable commands. 

proc vi_redo*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_vi_redo", 
    dynlib: readlineDll.}
proc vi_undo*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_vi_undo", 
    dynlib: readlineDll.}
proc vi_yank_arg*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_vi_yank_arg", 
    dynlib: readlineDll.}
proc vi_fetch_history*(a2: cint, a3: cint): cint{.cdecl, 
    importc: "rl_vi_fetch_history", dynlib: readlineDll.}
proc vi_search_again*(a2: cint, a3: cint): cint{.cdecl, 
    importc: "rl_vi_search_again", dynlib: readlineDll.}
proc vi_search*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_vi_search", 
    dynlib: readlineDll.}
proc vi_complete*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_vi_complete", 
    dynlib: readlineDll.}
proc vi_tilde_expand*(a2: cint, a3: cint): cint{.cdecl, 
    importc: "rl_vi_tilde_expand", dynlib: readlineDll.}
proc vi_prev_word*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_vi_prev_word", 
    dynlib: readlineDll.}
proc vi_next_word*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_vi_next_word", 
    dynlib: readlineDll.}
proc vi_end_word*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_vi_end_word", 
    dynlib: readlineDll.}
proc vi_insert_beg*(a2: cint, a3: cint): cint{.cdecl, 
    importc: "rl_vi_insert_beg", dynlib: readlineDll.}
proc vi_append_mode*(a2: cint, a3: cint): cint{.cdecl, 
    importc: "rl_vi_append_mode", dynlib: readlineDll.}
proc vi_append_eol*(a2: cint, a3: cint): cint{.cdecl, 
    importc: "rl_vi_append_eol", dynlib: readlineDll.}
proc vi_eof_maybe*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_vi_eof_maybe", 
    dynlib: readlineDll.}
proc vi_insertion_mode*(a2: cint, a3: cint): cint{.cdecl, 
    importc: "rl_vi_insertion_mode", dynlib: readlineDll.}
proc vi_insert_mode*(a2: cint, a3: cint): cint{.cdecl, 
    importc: "rl_vi_insert_mode", dynlib: readlineDll.}
proc vi_movement_mode*(a2: cint, a3: cint): cint{.cdecl, 
    importc: "rl_vi_movement_mode", dynlib: readlineDll.}
proc vi_arg_digit*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_vi_arg_digit", 
    dynlib: readlineDll.}
proc vi_change_case*(a2: cint, a3: cint): cint{.cdecl, 
    importc: "rl_vi_change_case", dynlib: readlineDll.}
proc vi_put*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_vi_put", 
                                        dynlib: readlineDll.}
proc vi_column*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_vi_column", 
    dynlib: readlineDll.}
proc vi_delete_to*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_vi_delete_to", 
    dynlib: readlineDll.}
proc vi_change_to*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_vi_change_to", 
    dynlib: readlineDll.}
proc vi_yank_to*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_vi_yank_to", 
    dynlib: readlineDll.}
proc vi_rubout*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_vi_rubout", 
    dynlib: readlineDll.}
proc vi_delete*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_vi_delete", 
    dynlib: readlineDll.}
proc vi_back_to_indent*(a2: cint, a3: cint): cint{.cdecl, 
    importc: "rl_vi_back_to_indent", dynlib: readlineDll.}
proc vi_first_print*(a2: cint, a3: cint): cint{.cdecl, 
    importc: "rl_vi_first_print", dynlib: readlineDll.}
proc vi_char_search*(a2: cint, a3: cint): cint{.cdecl, 
    importc: "rl_vi_char_search", dynlib: readlineDll.}
proc vi_match*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_vi_match", 
    dynlib: readlineDll.}
proc vi_change_char*(a2: cint, a3: cint): cint{.cdecl, 
    importc: "rl_vi_change_char", dynlib: readlineDll.}
proc vi_subst*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_vi_subst", 
    dynlib: readlineDll.}
proc vi_overstrike*(a2: cint, a3: cint): cint{.cdecl, 
    importc: "rl_vi_overstrike", dynlib: readlineDll.}
proc vi_overstrike_delete*(a2: cint, a3: cint): cint{.cdecl, 
    importc: "rl_vi_overstrike_delete", dynlib: readlineDll.}
proc vi_replace*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_vi_replace", 
    dynlib: readlineDll.}
proc vi_set_mark*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_vi_set_mark", 
    dynlib: readlineDll.}
proc vi_goto_mark*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_vi_goto_mark", 
    dynlib: readlineDll.}
# VI-mode utility functions. 

proc vi_check*(): cint{.cdecl, importc: "rl_vi_check", dynlib: readlineDll.}
proc vi_domove*(a2: cint, a3: ptr cint): cint{.cdecl, importc: "rl_vi_domove", 
    dynlib: readlineDll.}
proc vi_bracktype*(a2: cint): cint{.cdecl, importc: "rl_vi_bracktype", 
                                    dynlib: readlineDll.}
proc vi_start_inserting*(a2: cint, a3: cint, a4: cint){.cdecl, 
    importc: "rl_vi_start_inserting", dynlib: readlineDll.}
# VI-mode pseudo-bindable commands, used as utility functions. 

proc vi_fXWord*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_vi_fWord", 
    dynlib: readlineDll.}
proc vi_bXWord*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_vi_bWord", 
    dynlib: readlineDll.}
proc vi_eXWord*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_vi_eWord", 
    dynlib: readlineDll.}
proc vi_fword*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_vi_fword", 
    dynlib: readlineDll.}
proc vi_bword*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_vi_bword", 
    dynlib: readlineDll.}
proc vi_eword*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_vi_eword", 
    dynlib: readlineDll.}
# **************************************************************** 
#								    
#			Well Published Functions		    
#								    
# **************************************************************** 
# Readline functions. 
# Read a line of input.  Prompt with PROMPT.  A NULL PROMPT means none. 

proc readline*(a2: cstring): cstring{.cdecl, importc: "readline", 
                                      dynlib: readlineDll.}
proc free*(mem: cstring) {.importc: "free", nodecl.}
  ## free the buffer that `readline` returned.

proc set_prompt*(a2: cstring): cint{.cdecl, importc: "rl_set_prompt", 
                                     dynlib: readlineDll.}
proc expand_prompt*(a2: cstring): cint{.cdecl, importc: "rl_expand_prompt", 
                                        dynlib: readlineDll.}
proc initialize*(): cint{.cdecl, importc: "rl_initialize", dynlib: readlineDll.}
# Undocumented; unused by readline 

proc discard_argument*(): cint{.cdecl, importc: "rl_discard_argument", 
                                dynlib: readlineDll.}
# Utility functions to bind keys to readline commands. 

proc add_defun*(a2: cstring, a3: CommandFunc, a4: cint): cint{.cdecl, 
    importc: "rl_add_defun", dynlib: readlineDll.}
proc bind_key*(a2: cint, a3: CommandFunc): cint{.cdecl, 
    importc: "rl_bind_key", dynlib: readlineDll.}
proc bind_key_in_map*(a2: cint, a3: CommandFunc, a4: PKeymap): cint{.cdecl, 
    importc: "rl_bind_key_in_map", dynlib: readlineDll.}
proc unbind_key*(a2: cint): cint{.cdecl, importc: "rl_unbind_key", 
                                  dynlib: readlineDll.}
proc unbind_key_in_map*(a2: cint, a3: PKeymap): cint{.cdecl, 
    importc: "rl_unbind_key_in_map", dynlib: readlineDll.}
proc bind_key_if_unbound*(a2: cint, a3: CommandFunc): cint{.cdecl, 
    importc: "rl_bind_key_if_unbound", dynlib: readlineDll.}
proc bind_key_if_unbound_in_map*(a2: cint, a3: CommandFunc, a4: PKeymap): cint{.
    cdecl, importc: "rl_bind_key_if_unbound_in_map", dynlib: readlineDll.}
proc unbind_function_in_map*(a2: CommandFunc, a3: PKeymap): cint{.cdecl, 
    importc: "rl_unbind_function_in_map", dynlib: readlineDll.}
proc unbind_command_in_map*(a2: cstring, a3: PKeymap): cint{.cdecl, 
    importc: "rl_unbind_command_in_map", dynlib: readlineDll.}
proc bind_keyseq*(a2: cstring, a3: CommandFunc): cint{.cdecl, 
    importc: "rl_bind_keyseq", dynlib: readlineDll.}
proc bind_keyseq_in_map*(a2: cstring, a3: CommandFunc, a4: PKeymap): cint{.
    cdecl, importc: "rl_bind_keyseq_in_map", dynlib: readlineDll.}
proc bind_keyseq_if_unbound*(a2: cstring, a3: CommandFunc): cint{.cdecl, 
    importc: "rl_bind_keyseq_if_unbound", dynlib: readlineDll.}
proc bind_keyseq_if_unbound_in_map*(a2: cstring, a3: CommandFunc, 
                                    a4: PKeymap): cint{.cdecl, 
    importc: "rl_bind_keyseq_if_unbound_in_map", dynlib: readlineDll.}
proc generic_bind*(a2: cint, a3: cstring, a4: cstring, a5: PKeymap): cint{.
    cdecl, importc: "rl_generic_bind", dynlib: readlineDll.}
proc variable_value*(a2: cstring): cstring{.cdecl, importc: "rl_variable_value", 
    dynlib: readlineDll.}
proc variable_bind*(a2: cstring, a3: cstring): cint{.cdecl, 
    importc: "rl_variable_bind", dynlib: readlineDll.}
# Backwards compatibility, use rl_bind_keyseq_in_map instead. 

proc set_key*(a2: cstring, a3: CommandFunc, a4: PKeymap): cint{.cdecl, 
    importc: "rl_set_key", dynlib: readlineDll.}
# Backwards compatibility, use rl_generic_bind instead. 

proc macro_bind*(a2: cstring, a3: cstring, a4: PKeymap): cint{.cdecl, 
    importc: "rl_macro_bind", dynlib: readlineDll.}
# Undocumented in the texinfo manual; not really useful to programs. 

proc translate_keyseq*(a2: cstring, a3: cstring, a4: ptr cint): cint{.cdecl, 
    importc: "rl_translate_keyseq", dynlib: readlineDll.}
proc untranslate_keyseq*(a2: cint): cstring{.cdecl, 
    importc: "rl_untranslate_keyseq", dynlib: readlineDll.}
proc named_function*(a2: cstring): CommandFunc{.cdecl, 
    importc: "rl_named_function", dynlib: readlineDll.}
proc function_of_keyseq*(a2: cstring, a3: PKeymap, a4: ptr cint): CommandFunc{.
    cdecl, importc: "rl_function_of_keyseq", dynlib: readlineDll.}
proc list_funmap_names*(){.cdecl, importc: "rl_list_funmap_names", 
                           dynlib: readlineDll.}
proc invoking_keyseqs_in_map*(a2: CommandFunc, a3: PKeymap): cstringArray{.
    cdecl, importc: "rl_invoking_keyseqs_in_map", dynlib: readlineDll.}
proc invoking_keyseqs*(a2: CommandFunc): cstringArray{.cdecl, 
    importc: "rl_invoking_keyseqs", dynlib: readlineDll.}
proc function_dumper*(a2: cint){.cdecl, importc: "rl_function_dumper", 
                                 dynlib: readlineDll.}
proc macro_dumper*(a2: cint){.cdecl, importc: "rl_macro_dumper", 
                              dynlib: readlineDll.}
proc variable_dumper*(a2: cint){.cdecl, importc: "rl_variable_dumper", 
                                 dynlib: readlineDll.}
proc read_init_file*(a2: cstring): cint{.cdecl, importc: "rl_read_init_file", 
    dynlib: readlineDll.}
proc parse_and_bind*(a2: cstring): cint{.cdecl, importc: "rl_parse_and_bind", 
    dynlib: readlineDll.}

proc get_keymap_name*(a2: PKeymap): cstring{.cdecl, 
    importc: "rl_get_keymap_name", dynlib: readlineDll.}

proc set_keymap_from_edit_mode*(){.cdecl, 
                                   importc: "rl_set_keymap_from_edit_mode", 
                                   dynlib: readlineDll.}
proc get_keymap_name_from_edit_mode*(): cstring{.cdecl, 
    importc: "rl_get_keymap_name_from_edit_mode", dynlib: readlineDll.}
# Functions for manipulating the funmap, which maps command names to functions. 

proc add_funmap_entry*(a2: cstring, a3: CommandFunc): cint{.cdecl, 
    importc: "rl_add_funmap_entry", dynlib: readlineDll.}
proc funmap_names*(): cstringArray{.cdecl, importc: "rl_funmap_names", 
                                    dynlib: readlineDll.}
# Undocumented, only used internally -- there is only one funmap, and this
#   function may be called only once. 

proc initialize_funmap*(){.cdecl, importc: "rl_initialize_funmap", 
                           dynlib: readlineDll.}
# Utility functions for managing keyboard macros. 

proc push_macro_input*(a2: cstring){.cdecl, importc: "rl_push_macro_input", 
                                     dynlib: readlineDll.}
# Functions for undoing, from undo.c 

proc add_undo*(a2: Undo_code, a3: cint, a4: cint, a5: cstring){.cdecl, 
    importc: "rl_add_undo", dynlib: readlineDll.}
proc free_undo_list*(){.cdecl, importc: "rl_free_undo_list", dynlib: readlineDll.}
proc do_undo*(): cint{.cdecl, importc: "rl_do_undo", dynlib: readlineDll.}
proc begin_undo_group*(): cint{.cdecl, importc: "rl_begin_undo_group", 
                                dynlib: readlineDll.}
proc end_undo_group*(): cint{.cdecl, importc: "rl_end_undo_group", 
                              dynlib: readlineDll.}
proc modifying*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_modifying", 
    dynlib: readlineDll.}
# Functions for redisplay. 

proc redisplay*(){.cdecl, importc: "rl_redisplay", dynlib: readlineDll.}
proc on_new_line*(): cint{.cdecl, importc: "rl_on_new_line", dynlib: readlineDll.}
proc on_new_line_with_prompt*(): cint{.cdecl, 
                                       importc: "rl_on_new_line_with_prompt", 
                                       dynlib: readlineDll.}
proc forced_update_display*(): cint{.cdecl, importc: "rl_forced_update_display", 
                                     dynlib: readlineDll.}
proc clear_message*(): cint{.cdecl, importc: "rl_clear_message", 
                             dynlib: readlineDll.}
proc reset_line_state*(): cint{.cdecl, importc: "rl_reset_line_state", 
                                dynlib: readlineDll.}
proc crlf*(): cint{.cdecl, importc: "rl_crlf", dynlib: readlineDll.}
proc message*(a2: cstring): cint{.varargs, cdecl, importc: "rl_message", 
                                  dynlib: readlineDll.}
proc show_char*(a2: cint): cint{.cdecl, importc: "rl_show_char", 
                                 dynlib: readlineDll.}
# Undocumented in texinfo manual. 

proc character_len*(a2: cint, a3: cint): cint{.cdecl, 
    importc: "rl_character_len", dynlib: readlineDll.}
# Save and restore internal prompt redisplay information. 

proc save_prompt*(){.cdecl, importc: "rl_save_prompt", dynlib: readlineDll.}
proc restore_prompt*(){.cdecl, importc: "rl_restore_prompt", dynlib: readlineDll.}
# Modifying text. 

proc replace_line*(a2: cstring, a3: cint){.cdecl, importc: "rl_replace_line", 
    dynlib: readlineDll.}
proc insert_text*(a2: cstring): cint{.cdecl, importc: "rl_insert_text", 
                                      dynlib: readlineDll.}
proc delete_text*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_delete_text", 
    dynlib: readlineDll.}
proc kill_text*(a2: cint, a3: cint): cint{.cdecl, importc: "rl_kill_text", 
    dynlib: readlineDll.}
proc copy_text*(a2: cint, a3: cint): cstring{.cdecl, importc: "rl_copy_text", 
    dynlib: readlineDll.}
# Terminal and tty mode management. 

proc prep_terminal*(a2: cint){.cdecl, importc: "rl_prep_terminal", 
                               dynlib: readlineDll.}
proc deprep_terminal*(){.cdecl, importc: "rl_deprep_terminal", 
                         dynlib: readlineDll.}
proc tty_set_default_bindings*(a2: PKeymap){.cdecl, 
    importc: "rl_tty_set_default_bindings", dynlib: readlineDll.}
proc tty_unset_default_bindings*(a2: PKeymap){.cdecl, 
    importc: "rl_tty_unset_default_bindings", dynlib: readlineDll.}
proc reset_terminal*(a2: cstring): cint{.cdecl, importc: "rl_reset_terminal", 
    dynlib: readlineDll.}
proc resize_terminal*(){.cdecl, importc: "rl_resize_terminal", 
                         dynlib: readlineDll.}
proc set_screen_size*(a2: cint, a3: cint){.cdecl, importc: "rl_set_screen_size", 
    dynlib: readlineDll.}
proc get_screen_size*(a2: ptr cint, a3: ptr cint){.cdecl, 
    importc: "rl_get_screen_size", dynlib: readlineDll.}
proc reset_screen_size*(){.cdecl, importc: "rl_reset_screen_size", 
                           dynlib: readlineDll.}
proc get_termcap*(a2: cstring): cstring{.cdecl, importc: "rl_get_termcap", 
    dynlib: readlineDll.}
# Functions for character input. 

proc stuff_char*(a2: cint): cint{.cdecl, importc: "rl_stuff_char", 
                                  dynlib: readlineDll.}
proc execute_next*(a2: cint): cint{.cdecl, importc: "rl_execute_next", 
                                    dynlib: readlineDll.}
proc clear_pending_input*(): cint{.cdecl, importc: "rl_clear_pending_input", 
                                   dynlib: readlineDll.}
proc read_key*(): cint{.cdecl, importc: "rl_read_key", dynlib: readlineDll.}
proc getc*(a2: File): cint{.cdecl, importc: "rl_getc", dynlib: readlineDll.}
proc set_keyboard_input_timeout*(a2: cint): cint{.cdecl, 
    importc: "rl_set_keyboard_input_timeout", dynlib: readlineDll.}
# `Public' utility functions . 

proc extend_line_buffer*(a2: cint){.cdecl, importc: "rl_extend_line_buffer", 
                                    dynlib: readlineDll.}
proc ding*(): cint{.cdecl, importc: "rl_ding", dynlib: readlineDll.}
proc alphabetic*(a2: cint): cint{.cdecl, importc: "rl_alphabetic", 
                                  dynlib: readlineDll.}
proc free*(a2: pointer){.cdecl, importc: "rl_free", dynlib: readlineDll.}
# Readline signal handling, from signals.c 

proc set_signals*(): cint{.cdecl, importc: "rl_set_signals", dynlib: readlineDll.}
proc clear_signals*(): cint{.cdecl, importc: "rl_clear_signals", 
                             dynlib: readlineDll.}
proc cleanup_after_signal*(){.cdecl, importc: "rl_cleanup_after_signal", 
                              dynlib: readlineDll.}
proc reset_after_signal*(){.cdecl, importc: "rl_reset_after_signal", 
                            dynlib: readlineDll.}
proc free_line_state*(){.cdecl, importc: "rl_free_line_state", 
                         dynlib: readlineDll.}
proc echo_signal_char*(a2: cint){.cdecl, importc: "rl_echo_signal_char", 
                                  dynlib: readlineDll.}
proc set_paren_blink_timeout*(a2: cint): cint{.cdecl, 
    importc: "rl_set_paren_blink_timeout", dynlib: readlineDll.}
# Undocumented. 

proc maybe_save_line*(): cint{.cdecl, importc: "rl_maybe_save_line", 
                               dynlib: readlineDll.}
proc maybe_unsave_line*(): cint{.cdecl, importc: "rl_maybe_unsave_line", 
                                 dynlib: readlineDll.}
proc maybe_replace_line*(): cint{.cdecl, importc: "rl_maybe_replace_line", 
                                  dynlib: readlineDll.}
# Completion functions. 

proc complete_internal*(a2: cint): cint{.cdecl, importc: "rl_complete_internal", 
    dynlib: readlineDll.}
proc display_match_list*(a2: cstringArray, a3: cint, a4: cint){.cdecl, 
    importc: "rl_display_match_list", dynlib: readlineDll.}
proc completion_matches*(a2: cstring, a3: Compentry_func): cstringArray{.
    cdecl, importc: "rl_completion_matches", dynlib: readlineDll.}
proc username_completion_function*(a2: cstring, a3: cint): cstring{.cdecl, 
    importc: "rl_username_completion_function", dynlib: readlineDll.}
proc filename_completion_function*(a2: cstring, a3: cint): cstring{.cdecl, 
    importc: "rl_filename_completion_function", dynlib: readlineDll.}
proc completion_mode*(a2: CommandFunc): cint{.cdecl, 
    importc: "rl_completion_mode", dynlib: readlineDll.}
# **************************************************************** 
#								    
#			Well Published Variables		    
#								    
# **************************************************************** 

when false: 
  # The version of this incarnation of the readline library. 
  var library_version*{.importc: "rl_library_version", dynlib: readlineDll.}: cstring
  # e.g., "4.2" 
  var readline_version*{.importc: "rl_readline_version", dynlib: readlineDll.}: cint
  # e.g., 0x0402 
  # True if this is real GNU readline. 
  var gnu_readline_p*{.importc: "rl_gnu_readline_p", dynlib: readlineDll.}: cint
  # Flags word encapsulating the current readline state. 
  var readline_state*{.importc: "rl_readline_state", dynlib: readlineDll.}: cint
  # Says which editing mode readline is currently using.  1 means emacs mode;
  #   0 means vi mode. 
  var editing_mode*{.importc: "rl_editing_mode", dynlib: readlineDll.}: cint
  # Insert or overwrite mode for emacs mode.  1 means insert mode; 0 means
  #   overwrite mode.  Reset to insert mode on each input line. 
  var insert_mode*{.importc: "rl_insert_mode", dynlib: readlineDll.}: cint
  # The name of the calling program.  You should initialize this to
  #   whatever was in argv[0].  It is used when parsing conditionals. 
  var readline_name*{.importc: "rl_readline_name", dynlib: readlineDll.}: cstring
  # The prompt readline uses.  This is set from the argument to
  #   readline (), and should not be assigned to directly. 
  var prompt*{.importc: "rl_prompt", dynlib: readlineDll.}: cstring
  # The prompt string that is actually displayed by rl_redisplay.  Public so
  #   applications can more easily supply their own redisplay functions. 
  var display_prompt*{.importc: "rl_display_prompt", dynlib: readlineDll.}: cstring
  # The line buffer that is in use. 
  var line_buffer*{.importc: "rl_line_buffer", dynlib: readlineDll.}: cstring
  # The location of point, and end. 
  var point*{.importc: "rl_point", dynlib: readlineDll.}: cint
  var theEnd*{.importc: "rl_end", dynlib: readlineDll.}: cint
  # The mark, or saved cursor position. 
  var mark*{.importc: "rl_mark", dynlib: readlineDll.}: cint
  # Flag to indicate that readline has finished with the current input
  #   line and should return it. 
  var done*{.importc: "rl_done", dynlib: readlineDll.}: cint
  # If set to a character value, that will be the next keystroke read. 
  var pending_input*{.importc: "rl_pending_input", dynlib: readlineDll.}: cint
  # Non-zero if we called this function from _rl_dispatch().  It's present
  #   so functions can find out whether they were called from a key binding
  #   or directly from an application. 
  var dispatching*{.importc: "rl_dispatching", dynlib: readlineDll.}: cint
  # Non-zero if the user typed a numeric argument before executing the
  #   current function. 
  var explicit_arg*{.importc: "rl_explicit_arg", dynlib: readlineDll.}: cint
  # The current value of the numeric argument specified by the user. 
  var numeric_arg*{.importc: "rl_numeric_arg", dynlib: readlineDll.}: cint
  # The address of the last command function Readline executed. 
  var last_func*{.importc: "rl_last_func", dynlib: readlineDll.}: CommandFunc
  # The name of the terminal to use. 
  var terminal_name*{.importc: "rl_terminal_name", dynlib: readlineDll.}: cstring
  # The input and output streams. 
  var instream*{.importc: "rl_instream", dynlib: readlineDll.}: File
  var outstream*{.importc: "rl_outstream", dynlib: readlineDll.}: File
  # If non-zero, Readline gives values of LINES and COLUMNS from the environment
  #   greater precedence than values fetched from the kernel when computing the
  #   screen dimensions. 
  var prefer_env_winsize*{.importc: "rl_prefer_env_winsize", dynlib: readlineDll.}: cint
  # If non-zero, then this is the address of a function to call just
  #   before readline_internal () prints the first prompt. 
  var startup_hook*{.importc: "rl_startup_hook", dynlib: readlineDll.}:  hook_func
  # If non-zero, this is the address of a function to call just before
  #   readline_internal_setup () returns and readline_internal starts
  #   reading input characters. 
  var pre_input_hook*{.importc: "rl_pre_input_hook", dynlib: readlineDll.}: hook_func
  # The address of a function to call periodically while Readline is
  #   awaiting character input, or NULL, for no event handling. 
  var event_hook*{.importc: "rl_event_hook", dynlib: readlineDll.}: hook_func
  # The address of the function to call to fetch a character from the current
  #   Readline input stream 
  var getc_function*{.importc: "rl_getc_function", dynlib: readlineDll.}: getc_func
  var redisplay_function*{.importc: "rl_redisplay_function", dynlib: readlineDll.}: voidfunc
  var prep_term_function*{.importc: "rl_prep_term_function", dynlib: readlineDll.}: vintfunc
  var deprep_term_function*{.importc: "rl_deprep_term_function", 
                             dynlib: readlineDll.}: voidfunc
  # Dispatch variables. 
  var executing_keymap*{.importc: "rl_executing_keymap", dynlib: readlineDll.}: PKeymap
  var binding_keymap*{.importc: "rl_binding_keymap", dynlib: readlineDll.}: PKeymap
  # Display variables. 
  # If non-zero, readline will erase the entire line, including any prompt,
  #   if the only thing typed on an otherwise-blank line is something bound to
  #   rl_newline. 
  var erase_empty_line*{.importc: "rl_erase_empty_line", dynlib: readlineDll.}: cint
  # If non-zero, the application has already printed the prompt (rl_prompt)
  #   before calling readline, so readline should not output it the first time
  #   redisplay is done. 
  var already_prompted*{.importc: "rl_already_prompted", dynlib: readlineDll.}: cint
  # A non-zero value means to read only this many characters rather than
  #   up to a character bound to accept-line. 
  var num_chars_to_read*{.importc: "rl_num_chars_to_read", dynlib: readlineDll.}: cint
  # The text of a currently-executing keyboard macro. 
  var executing_macro*{.importc: "rl_executing_macro", dynlib: readlineDll.}: cstring
  # Variables to control readline signal handling. 
  # If non-zero, readline will install its own signal handlers for
  #   SIGINT, SIGTERM, SIGQUIT, SIGALRM, SIGTSTP, SIGTTIN, and SIGTTOU. 
  var catch_signals*{.importc: "rl_catch_signals", dynlib: readlineDll.}: cint
  # If non-zero, readline will install a signal handler for SIGWINCH
  #   that also attempts to call any calling application's SIGWINCH signal
  #   handler.  Note that the terminal is not cleaned up before the
  #   application's signal handler is called; use rl_cleanup_after_signal()
  #   to do that. 
  var catch_sigwinch*{.importc: "rl_catch_sigwinch", dynlib: readlineDll.}: cint
  # Completion variables. 
  # Pointer to the generator function for completion_matches ().
  #   NULL means to use rl_filename_completion_function (), the default
  #   filename completer. 
  var completion_entry_function*{.importc: "rl_completion_entry_function", 
                                  dynlib: readlineDll.}: compentry_func
  # Optional generator for menu completion.  Default is
  #   rl_completion_entry_function (rl_filename_completion_function). 
  var menu_completion_entry_function*{.importc: "rl_menu_completion_entry_function", 
                                       dynlib: readlineDll.}: compentry_func
  # If rl_ignore_some_completions_function is non-NULL it is the address
  #   of a function to call after all of the possible matches have been
  #   generated, but before the actual completion is done to the input line.
  #   The function is called with one argument; a NULL terminated array
  #   of (char *).  If your function removes any of the elements, they
  #   must be free()'ed. 
  var ignore_some_completions_function*{.
      importc: "rl_ignore_some_completions_function", dynlib: readlineDll.}: compignore_func
  # Pointer to alternative function to create matches.
  #   Function is called with TEXT, START, and END.
  #   START and END are indices in RL_LINE_BUFFER saying what the boundaries
  #   of TEXT are.
  #   If this function exists and returns NULL then call the value of
  #   rl_completion_entry_function to try to match, otherwise use the
  #   array of strings returned. 
  var attempted_completion_function*{.importc: "rl_attempted_completion_function", 
                                      dynlib: readlineDll.}: completion_func
  # The basic list of characters that signal a break between words for the
  #   completer routine.  The initial contents of this variable is what
  #   breaks words in the shell, i.e. "n\"\\'`@$>". 
  var basic_word_break_characters*{.importc: "rl_basic_word_break_characters", 
                                    dynlib: readlineDll.}: cstring
  # The list of characters that signal a break between words for
  #   rl_complete_internal.  The default list is the contents of
  #   rl_basic_word_break_characters.  
  var completer_word_break_characters*{.importc: "rl_completer_word_break_characters", 
                                        dynlib: readlineDll.}: cstring
  # Hook function to allow an application to set the completion word
  #   break characters before readline breaks up the line.  Allows
  #   position-dependent word break characters. 
  var completion_word_break_hook*{.importc: "rl_completion_word_break_hook", 
                                   dynlib: readlineDll.}: cpvfunc
  # List of characters which can be used to quote a substring of the line.
  #   Completion occurs on the entire substring, and within the substring   
  #   rl_completer_word_break_characters are treated as any other character,
  #   unless they also appear within this list. 
  var completer_quote_characters*{.importc: "rl_completer_quote_characters", 
                                   dynlib: readlineDll.}: cstring
  # List of quote characters which cause a word break. 
  var basic_quote_characters*{.importc: "rl_basic_quote_characters", 
                               dynlib: readlineDll.}: cstring
  # List of characters that need to be quoted in filenames by the completer. 
  var filename_quote_characters*{.importc: "rl_filename_quote_characters", 
                                  dynlib: readlineDll.}: cstring
  # List of characters that are word break characters, but should be left
  #   in TEXT when it is passed to the completion function.  The shell uses
  #   this to help determine what kind of completing to do. 
  var special_prefixes*{.importc: "rl_special_prefixes", dynlib: readlineDll.}: cstring
  # If non-zero, then this is the address of a function to call when
  #   completing on a directory name.  The function is called with
  #   the address of a string (the current directory name) as an arg.  It
  #   changes what is displayed when the possible completions are printed
  #   or inserted. 
  var directory_completion_hook*{.importc: "rl_directory_completion_hook", 
                                  dynlib: readlineDll.}: icppfunc
  # If non-zero, this is the address of a function to call when completing
  #   a directory name.  This function takes the address of the directory name
  #   to be modified as an argument.  Unlike rl_directory_completion_hook, it
  #   only modifies the directory name used in opendir(2), not what is displayed
  #   when the possible completions are printed or inserted.  It is called
  #   before rl_directory_completion_hook.  I'm not happy with how this works
  #   yet, so it's undocumented. 
  var directory_rewrite_hook*{.importc: "rl_directory_rewrite_hook", 
                               dynlib: readlineDll.}: icppfunc
  # If non-zero, this is the address of a function to call when reading
  #   directory entries from the filesystem for completion and comparing
  #   them to the partial word to be completed.  The function should
  #   either return its first argument (if no conversion takes place) or
  #   newly-allocated memory.  This can, for instance, convert filenames
  #   between character sets for comparison against what's typed at the
  #   keyboard.  The returned value is what is added to the list of
  #   matches.  The second argument is the length of the filename to be
  #   converted. 
  var filename_rewrite_hook*{.importc: "rl_filename_rewrite_hook", 
                              dynlib: readlineDll.}: dequote_func
  # If non-zero, then this is the address of a function to call when
  #   completing a word would normally display the list of possible matches.
  #   This function is called instead of actually doing the display.
  #   It takes three arguments: (char **matches, int num_matches, int max_length)
  #   where MATCHES is the array of strings that matched, NUM_MATCHES is the
  #   number of strings in that array, and MAX_LENGTH is the length of the
  #   longest string in that array. 
  var completion_display_matches_hook*{.importc: "rl_completion_display_matches_hook", 
                                        dynlib: readlineDll.}: compdisp_func
  # Non-zero means that the results of the matches are to be treated
  #   as filenames.  This is ALWAYS zero on entry, and can only be changed
  #   within a completion entry finder function. 
  var filename_completion_desired*{.importc: "rl_filename_completion_desired", 
                                    dynlib: readlineDll.}: cint
  # Non-zero means that the results of the matches are to be quoted using
  #   double quotes (or an application-specific quoting mechanism) if the
  #   filename contains any characters in rl_word_break_chars.  This is
  #   ALWAYS non-zero on entry, and can only be changed within a completion
  #   entry finder function. 
  var filename_quoting_desired*{.importc: "rl_filename_quoting_desired", 
                                 dynlib: readlineDll.}: cint
  # Set to a function to quote a filename in an application-specific fashion.
  #   Called with the text to quote, the type of match found (single or multiple)
  #   and a pointer to the quoting character to be used, which the function can
  #   reset if desired. 
  var filename_quoting_function*{.importc: "rl_filename_quoting_function", 
                                  dynlib: readlineDll.}: quote_func
  # Function to call to remove quoting characters from a filename.  Called
  #   before completion is attempted, so the embedded quotes do not interfere
  #   with matching names in the file system. 
  var filename_dequoting_function*{.importc: "rl_filename_dequoting_function", 
                                    dynlib: readlineDll.}: dequote_func
  # Function to call to decide whether or not a word break character is
  #   quoted.  If a character is quoted, it does not break words for the
  #   completer. 
  var char_is_quoted_p*{.importc: "rl_char_is_quoted_p", dynlib: readlineDll.}: linebuf_func
  # Non-zero means to suppress normal filename completion after the
  #   user-specified completion function has been called. 
  var attempted_completion_over*{.importc: "rl_attempted_completion_over", 
                                  dynlib: readlineDll.}: cint
  # Set to a character describing the type of completion being attempted by
  #   rl_complete_internal; available for use by application completion
  #   functions. 
  var completion_type*{.importc: "rl_completion_type", dynlib: readlineDll.}: cint
  # Set to the last key used to invoke one of the completion functions 
  var completion_invoking_key*{.importc: "rl_completion_invoking_key", 
                                dynlib: readlineDll.}: cint
  # Up to this many items will be displayed in response to a
  #   possible-completions call.  After that, we ask the user if she
  #   is sure she wants to see them all.  The default value is 100. 
  var completion_query_items*{.importc: "rl_completion_query_items", 
                               dynlib: readlineDll.}: cint
  # Character appended to completed words when at the end of the line.  The
  #   default is a space.  Nothing is added if this is '\0'. 
  var completion_append_character*{.importc: "rl_completion_append_character", 
                                    dynlib: readlineDll.}: cint
  # If set to non-zero by an application completion function,
  #   rl_completion_append_character will not be appended. 
  var completion_suppress_append*{.importc: "rl_completion_suppress_append", 
                                   dynlib: readlineDll.}: cint
  # Set to any quote character readline thinks it finds before any application
  #   completion function is called. 
  var completion_quote_character*{.importc: "rl_completion_quote_character", 
                                   dynlib: readlineDll.}: cint
  # Set to a non-zero value if readline found quoting anywhere in the word to
  #   be completed; set before any application completion function is called. 
  var completion_found_quote*{.importc: "rl_completion_found_quote", 
                               dynlib: readlineDll.}: cint
  # If non-zero, the completion functions don't append any closing quote.
  #   This is set to 0 by rl_complete_internal and may be changed by an
  #   application-specific completion function. 
  var completion_suppress_quote*{.importc: "rl_completion_suppress_quote", 
                                  dynlib: readlineDll.}: cint
  # If non-zero, readline will sort the completion matches.  On by default. 
  var sort_completion_matches*{.importc: "rl_sort_completion_matches", 
                                dynlib: readlineDll.}: cint
  # If non-zero, a slash will be appended to completed filenames that are
  #   symbolic links to directory names, subject to the value of the
  #   mark-directories variable (which is user-settable).  This exists so
  #   that application completion functions can override the user's preference
  #   (set via the mark-symlinked-directories variable) if appropriate.
  #   It's set to the value of _rl_complete_mark_symlink_dirs in
  #   rl_complete_internal before any application-specific completion
  #   function is called, so without that function doing anything, the user's
  #   preferences are honored. 
  var completion_mark_symlink_dirs*{.importc: "rl_completion_mark_symlink_dirs", 
                                     dynlib: readlineDll.}: cint
  # If non-zero, then disallow duplicates in the matches. 
  var ignore_completion_duplicates*{.importc: "rl_ignore_completion_duplicates", 
                                     dynlib: readlineDll.}: cint
  # If this is non-zero, completion is (temporarily) inhibited, and the
  #   completion character will be inserted as any other. 
  var inhibit_completion*{.importc: "rl_inhibit_completion", dynlib: readlineDll.}: cint
# Input error; can be returned by (*rl_getc_function) if readline is reading
#   a top-level command (RL_ISSTATE (RL_STATE_READCMD)). 

const 
  READERR* = (- 2)

# Definitions available for use by readline clients. 

const 
  PROMPT_START_IGNORE* = '\x01'
  PROMPT_END_IGNORE* = '\x02'

# Possible values for do_replace argument to rl_filename_quoting_function,
#   called by rl_complete_internal. 

const 
  NO_MATCH* = 0
  SINGLE_MATCH* = 1
  MULT_MATCH* = 2

# Possible state values for rl_readline_state 

const 
  STATE_NONE* = 0x00000000    # no state; before first call 
  STATE_INITIALIZING* = 0x00000001 # initializing 
  STATE_INITIALIZED* = 0x00000002 # initialization done 
  STATE_TERMPREPPED* = 0x00000004 # terminal is prepped 
  STATE_READCMD* = 0x00000008 # reading a command key 
  STATE_METANEXT* = 0x00000010 # reading input after ESC 
  STATE_DISPATCHING* = 0x00000020 # dispatching to a command 
  STATE_MOREINPUT* = 0x00000040 # reading more input in a command function 
  STATE_ISEARCH* = 0x00000080 # doing incremental search 
  STATE_NSEARCH* = 0x00000100 # doing non-inc search 
  STATE_SEARCH* = 0x00000200  # doing a history search 
  STATE_NUMERICARG* = 0x00000400 # reading numeric argument 
  STATE_MACROINPUT* = 0x00000800 # getting input from a macro 
  STATE_MACRODEF* = 0x00001000 # defining keyboard macro 
  STATE_OVERWRITE* = 0x00002000 # overwrite mode 
  STATE_COMPLETING* = 0x00004000 # doing completion 
  STATE_SIGHANDLER* = 0x00008000 # in readline sighandler 
  STATE_UNDOING* = 0x00010000 # doing an undo 
  STATE_INPUTPENDING* = 0x00020000 # rl_execute_next called 
  STATE_TTYCSAVED* = 0x00040000 # tty special chars saved 
  STATE_CALLBACK* = 0x00080000 # using the callback interface 
  STATE_VIMOTION* = 0x00100000 # reading vi motion arg 
  STATE_MULTIKEY* = 0x00200000 # reading multiple-key command 
  STATE_VICMDONCE* = 0x00400000 # entered vi command mode at least once 
  STATE_REDISPLAYING* = 0x00800000 # updating terminal display 
  STATE_DONE* = 0x01000000    # done; accepted line 

template SETSTATE*(x: expr): stmt = 
  readline_state = readline_state or (x)

template UNSETSTATE*(x: expr): stmt = 
  readline_state = readline_state and not (x)

template ISSTATE*(x: expr): expr = 
  (readline_state and x) != 0

type 
  Readline_state*{.pure, final.} = object 
    point*: cint              # line state 
    theEnd*: cint
    mark*: cint
    buffer*: cstring
    buflen*: cint
    ul*: ptr UNDO_LIST
    prompt*: cstring          # global state 
    rlstate*: cint
    done*: cint
    kmap*: PKeymap            # input state 
    lastfunc*: CommandFunc
    insmode*: cint
    edmode*: cint
    kseqlen*: cint
    inf*: File
    outf*: File
    pendingin*: cint
    theMacro*: cstring        # signal state 
    catchsigs*: cint
    catchsigwinch*: cint      # search state 
                              # completion state 
                              # options state 
                              # reserved for future expansion, so the struct size doesn't change 
    reserved*: array[0..64 - 1, char]
{.deprecated: [Treadline_state: Readline_state].}


proc save_state*(a2: ptr Readline_state): cint{.cdecl, 
    importc: "rl_save_state", dynlib: readlineDll.}
proc restore_state*(a2: ptr Readline_state): cint{.cdecl, 
    importc: "rl_restore_state", dynlib: readlineDll.}