Check-in [f370378f5a]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Implemented rendering of markdown formatted files. Partially...
Timelines: family | ancestors | descendants | both | HelpServer
Files: files | file ages | folders
SHA1:f370378f5a5379c2941509db35b1916fd8655f45
User & Date: johnfound 2014-03-17 20:58:45
Context
2014-03-18
06:59
Some major changes in the request processing. check-in: b78d53666f user: johnfound tags: HelpServer
2014-03-17
20:58
Implemented rendering of markdown formatted files. Partially... check-in: f370378f5a user: johnfound tags: HelpServer
16:43
Create new branch named "HelpServer" check-in: 1fef166cab user: johnfound tags: HelpServer
Changes

Added phWeb/html_header.inc.



















>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <link rel="stylesheet" href="help.css" type="text/css" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="Content-Style-Type" content="text/css" />
    <title>Fresh IDE html help</title>
  </head>
  <body>

Changes to phWeb/phWeb.

cannot compute difference between binary files

Changes to phWeb/phWeb.exe.

cannot compute difference between binary files

Changes to phWeb/phWeb.fpr.

cannot compute difference between binary files

Changes to phWeb/static.asm.








1



2
3
4
5
6
7
8
9
10
11

12








13

14




















15


16
17
18
19
20
21
22
23







proc HandlerStatic, .hSocket, .hFileName



begin
        pushad

if defined options.DebugMode & options.DebugMode
        stdcall FileWriteString, [STDERR], [.hFileName]
        stdcall FileWriteString, [STDERR], cCRLF
end if

        stdcall LoadBinaryFile, [.hFileName]
        jc      .finish2










        mov     esi, eax






















        stdcall SocketSend, [.hSocket], esi, ecx, 0


        stdcall FreeMem, esi

.finish2:
        popad
        return
endp


>
>
>
>
>
>
>

>
>
>










>

>
>
>
>
>
>
>
>
|
>

>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

>
>








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
iglobal
  cMarkdownHeader file 'html_header.inc'
                  dd   0
endg



proc HandlerStatic, .hSocket, .hFileName

  .md_result TMarkdownResults

begin
        pushad

if defined options.DebugMode & options.DebugMode
        stdcall FileWriteString, [STDERR], [.hFileName]
        stdcall FileWriteString, [STDERR], cCRLF
end if

        stdcall LoadBinaryFile, [.hFileName]
        jc      .finish2
        mov     esi, eax


; check the file type:

        stdcall StrExtractExt, [.hFileName]
        jc      .finish2

        push    eax
        stdcall StrPtr, eax
        mov     eax, [eax]
        stdcall StrDel ; from the stack

        cmp     eax, '.md'
        jne     .send_static

; markdown formatted file.

        lea     eax, [.md_result]
        stdcall TranslateMarkdown, esi, 0, FALSE, eax

        stdcall SocketSendStr, [.hSocket], cMarkdownHeader
        stdcall SocketSendStr, [.hSocket], [.md_result.hContent]
        stdcall SocketSendStr, [.hSocket], '</body></html>'

        stdcall StrDel, [.md_result.hContent]
        stdcall StrDel, [.md_result.hIndex]
        stdcall StrDel, [.md_result.hKeywords]
        stdcall StrDel, [.md_result.hDescription]
        jmp     .free


.send_static:
        stdcall SocketSend, [.hSocket], esi, ecx, 0

.free:
        stdcall FreeMem, esi

.finish2:
        popad
        return
endp


Added phWeb/www/FreshLibRef.md.





















































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>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
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
FreshLib reference
# Chapter 6 FreshLib reference

## Overview 

FreshLib is an assembly library aimed to ease the development of assembly
language applications, freely portable between different platforms,
such as Win32 or Linux.

The library is coded in [FASM][flat assembler] syntax
and is intended to be easily used within [Fresh IDE],
although it could be used for plain FASM development.

The library consists of two layers: one, that is OS dependent and
a second one that is OS independent. The OS dependent layer is very
small, in order to help porting it for different OSes. This layer
only makes interface to the core OS functions, such as memory allocations,
file access, drawing functions, simple window management etc.

The OS independent layer is responsible for the main application functionality
allowing creation of different kind of windows and controls, processing of the
system messages, work with dynamic strings, arrays and other data processing.

FreshLib is mainly intended for developing GUI applications, as they
are the most challenging to be ported across different platforms.
FreshLib is also created with visual programming in mind, so it contains
a flexible, event driven and OS independent template engine allowing
visual creation of application user interfaces.

FreshLib is in early development stage and probably will be changed
many times in order to reach their objectives: to be small, fast and
easy to use.

The main intention is to keep the bloat off the library, but containing
all necessary accessories for comfortable programming of a very wide
range of applications.

The architecture of FreshLib is open and it can be freely expanded
with other libraries without increasing the size of applications.
In other words, only those parts of the library that are effectively
used will be compiled on the final executable.

------------------------------------------------------------------------

## About this manual 

This manual is a "work in progress". Any
part of it can be changed at any time.

Of course, some of the libraries described in this document are more
stable and finished like the macro, system and data libraries. Therefore,
the chapters about these libraries are less likely to be changed.
Other libraries (like graphics and GUI), will be heavily modified
so the manual will be changed accordingly.


------------------------------------------------------------------------

## Structure of the library. 

FreshLib contains many code and macros libraries, structured hierarchically
and depending on each other. Here is shown a part of the library directory tree:
;begin
    freshlib/
        compiler/
            Linux/
            Win32/
        data/
            Linux/
            Win32/
        dialogs/
            Linux/
            Win32/
        ...
;end
The library is structured to support different platforms transparently.
You can see, that the tree consists of main sub-directories, that
contains OS independent libraries, separated by topics.
For example *system* subdirectory contains libraries for accessing system
resources such as memory, files, etc. *data* contains libraries for data
handling and so on.
Every topic directory have also several sub-directories, that contains OS
dependent code these directories are named after the platform they serve. 
(In this moment only Linux and Win32 OSes are supported).

------------------------------------------------------------------------

## Compiler setup for FreshLib use.

You can use any FASM compiler to compile applications that uses FreshLib.
In order to be compiled properly, FreshLib needs environment variables
named `lib` and `TargetOS` to be defined.

The variable `lib` contains the path to the main directory of FreshLib
and the variable `TargetOS` contains the target platform, the application
will be compiled for. The value of `TargerOS` is identical to the name of
OS dependent directories in FreshLib.

There are several ways these variables to be defined, depending on
the compiler you use [FASM], [FASMW] or [Fresh IDE].

1. These variable can be defined in the OS environment - see your OS documentation for details.
this approach is more universal - it works for all kind of FASM compilers. The main drawback is
that you have to use OS specific commands and probably will have to edit some system files.

1. Definition in the section `[environment]` of *"fasm.ini"* or *"Fresh.ini"* file, depending on the
IDE you are using. This approach works for both FASMW and Fresh IDE, but in Fresh, the same
effect can be done from inside the IDE. Besides, defined this way, the environment variables
becomes "global" - active for all projects compiled with FASMW or Fresh.

1. From inside Fresh IDE.

In Fresh IDE, the environment variables are named *alias*,
because they serve to provide short alias for the file paths. Two types of alias (environment variables)
lists are supported by Fresh: *global aliases* and *project aliases*. Global aliases are
defined in the IDE options dialog: *Options|IDE options|Aliases*. Here is the screenshot
of this dialog:

  [!_images/AliasesDlg.png][IDE options dialog, section "Aliases"]

The global aliases are active for every project compiled with Fresh and are stored in the Fresh.ini file,
inside the Fresh program directory.

Project aliases are defined in the Project options dialog: *Project|Project
options* or from the project manager, click on the button *Settings* at the top
and select *Project options*. The project options dialog is shown on the following screenshot:

  [!_images/ProjectOptions.png][Project based aliases can be edited in the project options dialog.]

The project aliases are stored inside the project file (.fpr) and they are project specific.

For FreshLib it is not important what list will be used, but it is
more convenient for `lib` variable to be defined in the global list
and for `TargetOS` variable to be defined in the project aliases. In such way
the common parameter (the place of the library) will be set once for all projects, and
the particular parameter (the target OS) will be set separately for every project.

Also, there is very convenient way of changing the value of project
aliases — if several values are specified in the project alias, separated
with `|` char (for example: `Win32|Linux`), Fresh will provide fast switching
between these values from the project manager options menu, as shown on the picture:

   [!_images/fastswitch.png][The aliases with more than one value will appear in the popup menu for fast changing.]

When Fresh searches for needed alias names, during the compilation, it searches first in the project
aliase list, then the global aliases and at the end, the OS environment variables. Of course, if
the alias is not found on these places, the compilation fails with error.


[FASM] http://flatassembler.net

[FASMW] http://flatassembler.net

[Fresh] http://fresh.flatassembler.net

[Fresh IDE] http://fresh.flatassembler.net

------------------------------------------------------------------------

## FreshLib compiling options 

FreshLib uses some options in order to set the behavior of the compiler and the 
different macro libraries.
These options are defined as a local constants of the label *"options."*
Here is a list:

[#options.FastEnter] `options.FastEnter` controls the behavior of the [#proc] macro.

When *options.FastEnter = 1* the procedure entry/leave code will be created with
faster, but bigger push ebp/pop ebp instructions.

When *options.FastEnter = 0* — enter/leave instructions are used.

[#options.ShowSkipped] `options.ShowSkipped` controls the information displayed during compilation.

When *options.ShowSkipped = 1* the compiler will display in the output window the procedures
that are not compiled because they are not used in the program.

[#options.ShowSizes] `options.ShowSizes` controls the behaviour of the DispSize macro.

When *options.ShowSizes = 0* the macro [#DispSize] will be disabled.

[#options.DebugMode] `options.DebugMode` controls the behaviour of the debug macros.

When *options.DebugMode = 1* the macros from [#simpledebug] library will generate debug code and
debug console will be created on running the application.

When *options.DebugMode = 0* these macros will not generate code and the debug console will not be
created.

------------------------------------------------------------------------

## FreshLib code conventions 

### Naming conventions 

1. The names prefixed with one or more underscores ("_") are not recomended for use by the user.
These are internaly used labels that can be changed later. More underscores in the prefix - 
more "internal" is the given identifier.

For example one underscore ( like this: `_AlmostPrivate`) means - "use it carefully". 

Three underscores (for example `___SomeVeryPrivateLabel`) means - don't use it at all. 
It is for internal use only and will be changed later!

2. The names are considered to be used with code completion editor - i.e. there is no long equal 
prefixes of the names, but there are short "class" prefixes.
For example most of the procedures in StrLib begin with "Str" prefix. 

3. In general, FreshLib uses [CamelCase] naming convention, with constants in lowerCamelCase and 
procedures in HigherCamelCase.

4. All local labels and procedure arguments are prefixed with dot — ".";

5. Almost all of the [#struct] and all of [#object] definitions are prefixed with "T" prefix — for 
example [#TTimer] or [#TButton]

6. The file names convention. All file names with extension `.inc` doesn't contain any code or
data definition. Only macro and constants definitions are permitted.

The files with '.asm' extension can define code and data. Although, the code and data in FreshLib
can exists in the compiled binary, only if they are used. Not used data or code, included in
the binary should be considered a bug.

[CamelCase]  http://en.wikipedia.org/wiki/CamelCase


### Register preserving convention

1. The rule is - preserve all you are using. All procedures in FreshLib preserves all registers, 
except these used for returning result values.

;quote
Note: There is some small retreat from this rule - in the object handling procedures, some register 
are preserved internaly, so the object class procedures may not preserve them. 
See [#object.asm] library for details.

Another exception are the user defined callbacks - FreshLib always preserves the registers before calling
callback procedures and restores after that.
;end

2. CF is widely used for returning error status or boolean result. 
As a rule *CF=0* means no error; *CF=1* means error.

The use of CF is described always in the description of the respective procedures.

3. The procedures can return result in more than one register. As a rule, EAX is the result register 
for the most procedures, but sometimes other registers are used - in order to provide better 
interface for assembly programming.

For example number of procedures return X,Y values in EAX, EDX registers.

* EAX — commonly used for returning 32bit values;

* EDX — second choise - used together with EAX for 64 bit values, or as a second returned value.

* ECX — usually some count. For example if EAX returns pointer to some memory, ECX will contains the 
data size. See [#LoadBinaryFile] for example.

------------------------------------------------------------------------

## Using FreshLib

There are only two files, the user should include in order to use FreshLib. They are both located
in the "freshlib" directory, usually referred by %lib% directory alias.

These files are:

* `%lib%/freshlib.inc` - contains all macro and OS dependent equates definitions.

* `%lib%/freshlib.asm` - contains all code of FreshLib. Only the used code will actually be included
in the result binary.

The minimal application with FreshLib have following code:

;begin
include "%lib%/freshlib.inc"

@BinaryType GUI

include "%lib%/freshlib.asm"

start:
        InitializeAll

        ; Place your code here

        FinalizeAll
        stdcall Terminate, 0

@AllImportEmbeded
@AllDataEmbeded
;end

The macros [#@BinaryType], [#@AllImportEmbeded], [#@AllDataEmbeded] will be explained later in the 
next chapter.

------------------------------------------------------------------------
## Data definitions in FreshLib program

FreshLib uses advanced data definitions macros, that allows data definitions to be mixed with the 
code, but then to be grouped and inserted in the data section of the program.
This kind of definitions greatly improves the readability of the program, because keeps the data
near to the code that uses it. It is especially important on big projects where the code is spreaded
among multiply files.
There are two main types of data - uninitialized and initialized data.

The initialized data definitions are enclosed inside [iglobal], [endg] macros and the uninitialized 
data in [uglobal], [endg] macros. Inside these blocks you can use all FASM data definition directives
or any other valid FASM code. Note only, that in `uglobal` block only the size of the data matters, 
if you use some defined data, the values will be lost.

;begin
iglobal
  MyGlobalVar dd 123, 456, 789
endg

uglobal
  SomeUndefinedVar rd 1
  SomeArray        rb 256
endg

;end

Another useful macro is [text] (actually it is `struc`). It defines some string constant anywhere in
the source code. The string constant is later defined in the data section of the program.

When used data definition macros, the user should define the data section with the macro [@AllDataEmbeded] or
[@AllDataSection] somewhere at appropriate place in the program, where all data should stay.


------------------------------------------------------------------------

## FreshLib directory "compiler/"

This directory contains only one macro library: *"executable.inc"*

### "executable.inc" library 

This library defines the macros that are going to be used for creating the main structure of
the program. The implementation of these macros is OS dependent, as long as the type of the
executable file is OS dependent: PE for Win32 and ELF for Linux. The use of the library, however
is OS independent and is common for all supported OSes.
Depending on the value of `TargetOS` alias, the library will create PE executable or DLL
`(%TargetOS%='Win32')`, or ELF executable or shared library `(%TargetOS%='Linux')`

*NOTE:* Every of the macros from this library must be used only once in the program.

--------------

[#@BinaryType] `macro @BinaryType type`

This macro sets the type of the executable. The argument `type` can accept one of the following
values: `GUI`, `console` or `DLL`.

This macro also begins the main code section of the executable and defines the entry label of the 
program. The entry label is fixed to `start:`.

For example, following code will tell the compiler to compile the program as a GUI application:
;begin
      include '%lib%/freshlib.inc'
      @BinaryType GUI
;end

--------------

[#@AllDataSection] `macro @AllDataSection`
[#@AllDataEmbeded] `macro @AllDataEmbeded`

These macros defines all data definitions in the program, defined in `uglobal` and `iglobal` blocks 
and the text constants defined using `text` macro.

@AllDataSection, defines the data in a separate program "section". The meaning of the "section" 
term is different, depending on TargetOS definition. In Win32 it is `section '.data' data readable writeable`. 
In Linux it is `segment readable writeable`

@AllDataEmbeded defines the data, embeded in the code section of the program (created by @BinaryType macro).

Only one of these macros must be used. Usually @AllDataEmbeded will create smaller executable, although
some negative effects are possible, because embeded data and code is often considered "bad practice"

--------------

[#@AllImportSection] `macro @AllImportSection`
[#@AllImportEmbeded] `macro @AllImportEmbeded`

These macros automatically defines the import section of the program. This section is created
automatically depending on what functions was used in the program. 

Similar to the data section macros, @AllImportSection will create this data as a separate section, 
while @AllImportEmbeded will try to embed this data in the code section. 
(NOTE: In ELF executable format, the import data must be in separate segment, so
on TargetOS=Linux @AllImportSection and @AllImportEmbeded are equal.)

If embeded import section is used together with embeded data section, the import section should be
defined before the data section, because of undefined data definitions, that must reside at the end 
of the section (code section in the case of embeded data).

------------------------------------------------------------------------

## FreshLib directory "equates/"

[#allequates.inc] *"allequates.inc"* library. This library defines all
constants and structures needed for OS dependent parts of FreshLib.

Actually, the user should never use these constants and structures in the portable program.

The constants and structures that the user should use are defined in the respective libraries,
not in *"allequates.inc"*.

This library will be included automatically by "%lib%/freshlib.inc" file, so the user should not care
about this library at all.

------------------------------------------------------------------------

## FreshLib directory "imports/" 

[#allimports.asm]Another directory that contains only OS dependent definitions is *"imports/"* with a library
file to be included in the project: *"allimports.asm"*

This file is automatically included in the [#@AllImportSection] and [#@AllImportEmbeded] macros.
Then it will generate the proper import section, depending on the target platform and functions used 
by the OS dependent parts of FreshLib.

FreshLib contains very big catalog of shared libraries for Windows and decent set of Linux
shared libraries. The import macros used by FreshLib includes in the import section of the
program, only the functions used by the program, so it will never define redundant import items.

The user must never call directly imported functions from inside a portable application, except if
the imported dynamic library is portable as well. (as sqlite3.dll, for example)

------------------------------------------------------------------------

## FreshLib directory "macros/" 

This directory contains several libraries that provides common convenience functions to be
used with big assembly projects. 

All these libraries will be included automatically in "%lib%/freshlib.inc" file.

There is no overhead including all these libraries, because there is no code to be generated, 
just macro definitions. 
There is a little delay in compile time but thanks to fasm's speed, it is barely noticeable.

Lets examine each one of these libraries.

### "_stdcall.inc" library 

In general this library provides ways of definition and invocation of the procedures with
argument passing through the stack. It supports STDCALL and CCALL calling conventions.

-------------------

[#proc] `macro proc name, [arg]`
[#begin] `macro begin`
[#endp] `macro endp`
[#return] `macro return`
[#cret] `macro cret`
[#locals] `macro locals`
[#endl] `macro endl`

These macros define a procedure, create a stack frame for the local variables and define
symbolic names for the arguments. The macro "proc" defines the global label "name" as a name
for the procedure. All arguments and local variables are defined as a local labels with regard
to the name of the procedure. That is why all arguments and local variables must have names
beginning with dot.

Between the line with *proc* and *begin*, any number of local variables can be defined.
The macro *begin* marks the begining of the procedural code.

The macro *endp* marks the end of the procedural code.

The return from procedure instruction is provided by macros *return* or *cret* depending on
the calling convention we want to use: *return* clears the arguments from the stack and *cret*
does not.

Inside the procedure, a secondary stack frame can be allocated with the pair *locals* and *endl*.
All data definitions, enclosed between these macros will define a secondary stack frame that
is a continuation of the stack frame defined between *proc* and *begin*.

Any number of *locals* and *endl* pairs can be used, but all of these secondary stack frames
will overlap between each other. This feature is specially intended to provide savings of stack
space and at the same time, to provide talking variable names for the different parts of more
complex procedures.

For example (in Win32) let we have complex window procedure that have to process
multiple messages. 

One of the message handlers may need one variable `.rect`.

Another message handler may need two variables called `.point1` and `.point2`.

But the procedure as a whole is never going to need all those variables at the
same time, because it process only one message at a time. On the other hand it
may need the variable `.ctrldata` for every message processed. The optimal solution
is to define the variables as shown in the following example:

;begin
    proc CtrlWinProc, .hwnd, .wmsg, .wparam, .lparam
    .ctrldata dd ?
    begin
        invoke GetWindowLong, [.hwnd], GWL_USERDATA
        mov    [.ctrldata], eax

        cmp    [.wmsg], WM_MESSAGE1
        je     .message1
        cmp    [.wmsg], WM_MESSAGE2
        je     .message2
        return

    .message1:
    locals
      .rect RECT
    endl
        ; do something.
        return

    .message2:
    locals
      .point1 POINT
      .point2 POINT
    endl
        ; do something. 
        return
    endp
;end

The assignment of the stack memory for the above example is shown in the table:
;table
(1, 2) Address

(3, 1) Stack frames
;-----------------------
Common

Locals 1

Locals 2
;-----------------------
EBP-20

--

.rect.left

.point1.x
;-----------------------
EBP-16

--

.rect.top

.point1.y
;-----------------------
EBP-12

--

.rect.right

.point2.x
;-----------------------
EBP-8

--

.rect.bottom

.point2.y
;-----------------------
EBP-4

.ctrldata

--

--

;end

;;begin
;;+---------+---------+--------------+-------------+
;;|         |           Stack frames               |
;;+ address +---------+--------------+-------------+
;;|         |  common |   locals 1   |   locals2   |
;;|:-------:|:-------:|:------------:|:-----------:|
;;| EBP-20  |         | .rect.left   |   .point1.x |
;;| EBP-16  |         | .rect.top    |   .point1.y |
;;| EBP-12  |         | .rect.right  |   .point2.x |
;;| EBP-08  |         | .rect.bottom |   .point2.y |
;;| EBP-04  |.ctrldata|              |             |
;;+---------+---------+--------------+-------------+
;;        Procedure local labels memory map.
;;end

As you can see, *.rect* occupies the same memory as *.point1* and *.point2*,
but *.ctrldata* is never overlapped and exists independently.

As a general rule, you have to use the definitions between "proc" and "begin" for local
variables that are used in every call of the procedure and separate locals/endl definitions
for variables needed for the particular branches inside the procedure.
This approach will always provide the optimal size for the locals stack frame.

--------------------

[#initialize] `macro initialize`
[#finalize] `macro finalize`

The macros "initialize" and "finalize" defines one special type of procedures that, during
compilation are registered in a two separate lists - one for "initialize" and one for
"finalize" procedures. Procedures defined with "initialize" and "finalize" must have no any
arguments.

After that, using the macros "InitializeAll" and "FinalizeAll", all these procedures can be
call at once. "initialize" procedures are call in the order of their definition and "finalize"
procedures in reverse order.

These macros provides standard and consistent way for initialization and the
finalization of the libraries and modules of the application.

FreshLib uses this mechanism and the user is free to use it also.


-------------------------


[#stdcall] `macro stdcall proc, [arg]`
[#ccall]   `macro ccall proc, [arg]`
[#invoke]  `macro invoke proc, [arg]`
[#cinvoke] `macro cinvoke proc, [arg]`

These macros call the procedures with STDCALL and CCALL calling convention.

`stdcall` macro pushes the arguments to the stack in reverse order and then call
the procedure with label *proc*. As long as the macro "stdcall" does not provide
any stack cleanup (this duty is assigned to the procedure) the arguments can be
pushed in free manner using, for example, separate push instructions for part of
the arguments and arguments in the stdcall line for the remaining arguments.
This can be very convenient in some cases. For example see the following source:
;begin
    stdcall CreateSomeObject
    push    eax
    stdcall DoSomething
    stdcall DeleteSomeObject
;end
Here, the procedure DoSomething changes the value of eax, so the handle is saved
in the stack. The procedure DeleteSomeObject needs one argument — a handle of
the object. But as long as the proper value is already in the stack, it is
mindless to pop the value and then to push it again. So the source calls
DeleteSomeObject without any arguments. The procedure knows the proper number
of arguments (one in this example) and clean the stack properly.

The standard (and wrong) approach is to pop the argument from the stack and then
to pass it to the procedure explicitly is the stdcall statement:
;begin
    stdcall  CreateSomeObject
    push     eax                ; save the handle.
    stdcall  DoSomething
    pop      eax                ; ??? Why ???
    stdcall  DeleteSomeObject, eax
;end
This source will generate the meaningless instructions sequence:
;begin
    pop      eax
    push     eax
;end
*invoke* macro is the same as "stdcall" with the only difference - it calls the procedure
indirectly ( `call [proc]` instead of `call proc` ).  This mechanism usualy is used to call
the functions imported from external dynamic linked libraries.
Of course, the imported functions can be call with `stdcall [someproc]` but the *invoke*
macro helps to better distinguish what procedures are imported and what are internal for the
program.

*NOTE:* The user should never use *invoke* in the portable programs, because such programs
never use directly OS dependent import functions.


*ccall* macro calls a procedure with CCALL convention. This means that the procedure returns
with simple "retn", without cleaning the parameters from the stack. Then "ccall" macro provides
instructions that remove the arguments from the stack.

Because ccall have to know the exact count of passed arguments, all arguments have to be passed
explicitly as a values in the ccall statement.
Tricks as described above will not work properly and leads to stack not properly cleaned after
the call.

"cinvoke" is the same as ccall, but using indirect call. The reason for existing of "cinvoke"
macro is the same as with "invoke" macro — better legibility of the source.

*About the calling conventions:* While all Win32 dynamic linked libraries uses STDCALL
convention, most (if not all) of Linux libraries uses CCALL convention.

*All code libraries of Fresh use STDCALL calling convention and it is platform independient.*

-------------------------------------------------------------------------------------

### "_globals.inc" library 

This library defines several macros intended to deal with data definitions.

Usually all data definitions have to be placed in special section of the
executable file. ([#_DataSection] in FreshLib). This is not very convenient, because the code
that process this data and the data definitions must reside in separate places of the source
code, and in most cases even in different files.

The idea of *"globals.inc"* macro library is to allow the data definition to be
described anywhere in the source code, but these definitions to be defined at
once, at the place the programmer wants - usually in the data section of the
program.

--------------------

[#uglobal] `macro uglobal`
[#iglobal] `macro iglobal`
[#endg] `macro endg`
[#IncludeAllGlobals] `macro IncludeAllGlobals`

*uglobal* begins block for undefined data definition. The block ends with *endg*
macro. Between "uglobal" and "endg" macro any count of data definitions can be
inserted.

Note that because uglobal block defines undefined data, it is only the labels
and the size of data that have meaning inside this block. Any data, defined with
data definition directive will not increase the size of the executable file, but will
be allocated when the executable is loaded in the memory.

The undefined data will be defined later at the place where "IncludeAllGlobals"
macro resides. In order to not increase the size of the executable file,
the undefined data is always placed at the end of all data definitions.

"iglobal" macro, again combined with "endg" defines initialized data. The data
defined in the block will be created at "IncludeAllGlobals" statement.

This block increases the size of the executable file, because it contains
sensible data, that have to be included in the file.

Actually, neither *uglobal*, nor *iglobal* blocks defines any data immediately.
Instead, the data definitions are stored in a list. The real definition occurs
later, when *IncludeAllGlobals* macro is invoked.
For this reason, *IncludeAllGlobals* must be placed in the source after all used
global data blocks.

The programmer should never use explicitely IncludeAllGlobals. This macro will be invoked
on [#@AllDataSection] or [#@AllDataEmbeded] macros use.

---------------------

[#text] `struc text [val]`

The macro *"text"* is actually a structure. It needs to be preceded by some label name.

This macro accepts string or number arguments. When it is invoked with string arguments,
it defines a zero terminated string constant, and also a local constant *.length*
equal to the length of the string without terminating zero. When invoked with number as argument,
*"text"* defines label at the address *val* and does not defines .length constant.

The *"text"* macro, the same way as *iglobal* and *uglobal*, simply stores string data for
defer definition. This definition, occurs in IncludeAllGlobals invocation.
Note that the real definition will be made only if the string is used in the program.
Not used strings will not be defined.

Look at the following example:
;begin
        myName text 'John',$20,'Smith'
;end
This code will define the data and constant labels following way:
;begin
        if used myName
          myName db 'John Smith'
          .length = $-myName
                 db 0
        end if
;end

Why to define separate macro for the strings and not to use the normal iglobal
block? At first, *text* macro defines a real data only if this data is used
somewhere in the source. This way is prevented bloating of the code with
unneeded data definitions.

;quote
Also, the macro "text" was planned to check the strings
content and to not define any string more than once. In the case of repetitive strings,
this macro should return the pointer to the already defined string constant.

In that case, it would be very convenient and harmless to use unnamed string constants
in the function calling macros - stdcall, ccall etc.

Unfortunately, regardless of the power of fasm macro language, this functionality
cannot be implemented. Or, more precisely, it can be implemented, but the
implementation is too slow for any real project use.

This ineffective implementation is still leaved inside the file *"_globals.inc"* -
commented block that defines macro with name "*InitStringList*". If someone have
ideas about fixing this problem, please send it to me!
;end

------------------

[#var] `macro var expr`

The macro *var* defines dword variable with a given value. The use is following:
;begin
        var MyVar = 1234
;end
The only differens from the usual use of *dd* directive is that the variable will be
defined only if used in the source.

Note that the variable is created at the place where *var* is used, so you need to place it
inside a *iglobal* block if you want it to be defined in the global data place.

---------------------

### "_struct.inc" library 

This library contains only two simple macros:

[#struct] `macro struct name`
[#ends] `ends`

*struct* macro is aimed to provide easy creation of data structures. The "struc"
directive in FASM is known to not create actual labels, but only the template
for the label definitions. So, we need to create an instance of the data
structure in order to have addresses and offsets of its fields.

But very often we don't have static data structure of the given type, but data
structure, pointed by some of the registers. In this case in order to use
offsets to the fields of the data structure, we need to define at least one
virtual instance of the structure at address 0. Then we can use the values of
the fields as an offsets in the instructions - for example:
;begin
    mov eax, [esi+RECT.right].
;end
So, this is exactly what "struct" macro does. Besides it defines the "struc"
structure with the given fields, it creates a single virtual instance of this
structure, in order to be used later for register addressing.
Also, the macro defines local constant of *sizeof.* global label equal to the
byte size of the structure.
In all remaining functionality it behaves exactly as the struc directive.

The syntax of struct macro is the following:
;begin
    struct StructureName
      .field1 dd ?
      .field2 RECT
      .fieldN:
    ends
;end
The definition begins with "struct" followed by the structure name.
The definition ends with "ends" directive. Between both, any local label
definition becomes a member of the structure.
The above definition, results in following code:
;begin
    struc StructureName {
      .field1 dd ?
      .field2 RECT
      .fieldN:
    }
    virtual at 0
      StructureName StructureName
      sizeof.StructureName = $
    end virtual
;end

--------------------------------------------------------------

### "_display.inc" library 

This library contains macros that enhance the functionality of standard FASM
"display" directive.


[#disp] `macro disp [arg]`

The macro "disp" displays the strings given in the arguments, just as "display"
FASM directive does. Additionally it can display numbers in any given radix:
;begin
    disp <number, radix>
;end

---------------

[#DispSize] `macro DispSize Text, Sz`

"DispSize" is very specialized macro, that displays the text and number in
the following form:
;begin
Size of [Text] is: Sz bytes
;end
The size number is automatically scaled to bytes or kbytes, depending on the
value of Sz.

This macro allows easy display and control of the sizes of particular areas of
the program - data structures, subroutines etc.

DispSize macro behavior is controlled by [#options.ShowSizes] option.

-----------------

[#display] How Fresh implements "display" directive

There are some specifics in Fresh, concerning message displaying. The "display"
directive in Fresh works in a slightly different way than the original FASM directive.

It outputs text in Fresh message window. Each message can have one of six icons,
or it can have no icon at all. And because message window is implemented as a
TreeView control, you can organize your messages into groups (directories).

Implementation is a bit "tricky" - when you display a character whose code is
less than 16, it is interpreted in a special way. Characters from 1 to 6 set an
icon of current message. It sounds complicated, but it is quite simple. Try:
;begin
    display 2, "some message"
;end
It will display "some message" with an error icon. Another codes are used for
controlling directory structure. Try to type following lines and see what would
happen:
;begin
    display 3, "message at root", 0x09
    display 3, "child message1", 0x0a
    display 3, "child message2", 0x0d
    display 3, "again at root", 0x0a
;end
Of course you don't have to put each message in separate display directive, you
can, with the same result write:

display 3, "at root",$09,3,"child1",$0a,3,"child2", $0d,3,"again at root",$0a

Here is the complete list of all special characters and their meanings:
;table
char

meaning

note
;-------------
$01

set current icon to "warning"

 [?_images/warning.gif]
;------------------
$02

set current icon to "error"

 [?_images/error.gif]
;-----------------
$03

set current icon to "info"

 [?_images/information.gif]
;----------------
$04

set current icon to "find"

 [?_images/find.gif]
;----------------
$05

set current icon to "none"

--
;----------------
$06

set current icon to "debug" 

 [?_images/debug.gif]
;----------------
$08 

end current row and set one level back.

--
;----------------
$09

end current row and set it as new directory.

--
;----------------
$0a

end current row and keep current level.

--
;----------------
$0d

end current row and set current level to root level.

--
;end


;;begin
;;+------+--------------------------------------------------------+
;;| char |   meaning                                              |
;;|:----:|:-------------------------------------------------------|
;;| $01  |   set current icon to "warning"                        |
;;| $02  |   set current icon to "error"                          |
;;| $03  |   set current icon to "info"                           |
;;| $04  |   set current icon to "find"                           |
;;| $05  |   set current icon to "none"                           |
;;| $06  |   set current icon to "debug"                          |
;;| $08  |   end current row and set one level back.              |
;;| $09  |   end current row and set it as new directory.         |
;;| $0a  |   end current row and keep current level               |
;;| $0d  |   end current row and set current level to root level  |
;;+------+--------------------------------------------------------+
;;          display directive special characters
;;end


-------------------


## FreshLib directory "system/" 


-----------------


### "memory.asm" library 

This library provides OS independent way of allocating, reallocating and freeing
dynamic memory blocks.
All other libraries in FreshLib that needs dynamic memory, use this library.

The user who needs such memory blocks should use it as well.

--------------

[#GetMem] `proc GetMem, .size`

Allocates `[.size]` byte of dynamic memory.

Returns:

 `CF=0`; EAX = pointer to the allocated memory;

 `CF=1`; EAX=0 if the memory can not be allocated.

The memory is filled with NULL.

------------------

[#FreeMem] `proc FreeMem, .ptr`

Frees the specified in `[.ptr]` dynamically allocated memory.
Returns nothing.

-------------------

[#ResizeMem] `proc ResizeMem, .ptr, .newsize`

Reallocates memory on address `[.ptr]` to the new size in `[.newsize]`

Returns:

CF=0; EAX = pointer to the allocated memory;

CF=1; EAX=`[.ptr]` if the memory can not be reallocated.
In this case, the memory block is not changed

The increased part of the memory block is not zeroed.

-----------------


### "files.asm" library 


[#FileOpen] `proc FileOpen, .filename`

The procedure opens the file with filename in `[.filename]` for reading.

Returns:

`CF=0`; EAX = Handle to the file.

`CF=1`; EAX = Error code.

-------------------

[#FileCreate] `proc FileCreate, .filename`

Creates a file or opens the existing one and truncates its size to 0. The file is opened for writing.

Returns:

`CF=0`; EAX = Handle to the file.

`CF=1`; EAX = Error code.


----------------------

[#FileClose] `proc FileClose, .handle`

Closes the previously opened file.

Returns:

`CF=0`; EAX = Handle to the file.
`CF=1`; EAX = Error code.

----------------------

[#FileRead] `proc FileRead, .handle, .buffer, .count`

Reads `[.count]` bytes from the file `[.handle]` in the buffer at `[.buffer]`.

Returns:

`CF=0`; EAX = The count of actually read bytes.
`CF=1`; EAX = Error code.

---------------------

[#FileWrite] `proc FileWrite, .handle, .buffer, .count`

Writes `[.count]` bytes from the buffer `[.buffer]` to the file with handle `[.handle]`.

Returns:

`CF=0`; EAX = The count of actually written bytes.

`CF=1`; EAX = Error code.

------------------------

[#FileSeek] `proc FileSeek, .handle, .dist, .direction`

Moves the file pointer of the file `[.handle]` on `[.dist]` distance (in bytes) relative to `[.direction]`.

Direction is one of the following values:

`fsFromBegin` — relative to the file begin.

`fsFromEnd` — relative to the file end (then `[.dist]` should be negative).

`fsFromCurrent` — relative to the current position.

[#FileDelete] `proc FileDelete, .filename`

Deletes the file with filename in `[.filename]`

Returns:

`CF=0`; The file was deleted.
`CF=1`; EAX = Error code.

--------------------------

[#GetErrorString] `proc GetErrorString, .code`

Returns in EAX, pointer to the human readable error message, corresponding to the error code
passed in `[.code]`

The message string have to be passed to FreeErrorString, when not needed.

---------------------------

[#FreeErrorString] `proc FreeErrorString, .ptrString`

Frees the error string `[.ptrString]`, previously returned by GetErrorString. As long as the
error strings are allocated by the OS, they have to be free by OS as well.
Returns nothing.

--------------------------

[#LoadBinaryFile] `proc LoadBinaryFile, .ptrFileName`

Loads the whole file `[.ptrFileName]` to the dynamically allocated memory block.

Returns:

`CF=0`; EAX = pointer to the allocated memory; ECX = the size of the loaded file.

`CF=1`; EAX = Error code. ECX = 0; The memory is not allocated.

The allocated memory have to be free after use with [#FreeMem].

---------------------------

[#SaveBinaryFile] `proc SaveBinaryFile, .ptrFileName, .aptr, .size`

Creates or overwrites the file `[.ptrFileName]` with the `[.size]` bytes from the buffer `[.aptr]`;

Returns:

`CF=0`; EAX = count of the bytes actually write;
`CF=1`; EAX = error code;

--------------------------

[#FileExists] `proc FileExists, .ptrFileName`

Check the existence of the file with name in `[.ptrFileName]`.

Returnds:

`CF=1` — the file *does not* exists.
`CF=0` — the file exists.

The existence of the file is checked using [#FileOpen] procedure.
If the file can be opened, it is considered existing.

-----------------

### "process.asm" library 


[#Terminate] `proc Terminate, .exit_code`

Terminates the application and all of its threads.
Returns `[.exit_code]` to the OS.

This procedure simply does not returns, because the application stops.

----------------------

[#ThreadCreate] `proc ThreadCreate, .ptr_to_function, .ptr_to_args`

Creates new thread. `[.ptr_to_function]` points to the thread procedure.
The thread procedure should have one argument.
When the thread starts, `[.ptr_to_args]` is passed as a thread argument.

Returns:

`CF=0`; EAX = is a handle to the new thread. In the different OSes this value can have different meaning.
But it identifies the thread anyway.

`CF=1`; EAX = error code;

------------------------

[#MutexCreate] `proc MutexCreate, .ptrName, .ptrMutex`

Creates new mutex with name `[.ptrName]` and save its handle to `[.ptrMutex]` variable.

The calling thread takes the owneship of the mutex.

If `[.ptrName]` = 0, unnamed mutex will be created.

------------------------

[#WaitForMutex] `proc WaitForMutex, .ptrMutex, .timeout`

Waits until the mutex is released and takes the ownership.

Returns:

`CF=0` — the mutex ownership is successfuly obtained.
`CF=1` — the timeout was expired.


[#MutexRelease] `proc MutexRelease, .ptrMutex`

Releases the ownership of the specified mutex.

-----------------------

[#MutexDestroy] proc MutexDestroy, .ptrMutex

Destroys the mutex `[.ptrMutex]`

-----------------

### "clipboard.asm" library 

[#clipboard.asm] clipboard.asm library contains very simple clipboard functions that 
works only on text data.

------------------

[#ClipboardRead] `proc ClipboardRead`

Returns in EAX handle to the string with the current clipboard content.
If the clipboard is empty or contains not textual information, EAX=0;
The user should delete the string when not needed by passing it to [#StrDel].

--------------------

[#ClipboardWrite] `proc ClipboardWrite, .hstring`

Writes the string `[.hstring]` to the clipboard.
Returns nothing.

-----------------

## FreshLib directory "timers/" 


### "timers.asm" library 

[#timers.asm] library deals with user created timers and also contains some 
procedures for work with the system time and date.

------------------------------------

[#TTimer] `TTimer` structure.

The timers in FreshLib are represented with the following memory structure:
;begin
    struct TTimer
      .next dd ?

      .interval dd ?
      .value    dd ?


      .flags    dd ?
      .Callback dd ?
      .Expired  dd ?
      .tag      dd ?
    ends
;end
The fields are:

  * `.next` —  Don't change this. It is a pointer to the next timer in the timers chain. It is for internal use only.

  * `.interval` — the interval of the time in ms

  * `.value` — The current value of the timer in ms. When this value becomes higher than `[.interval]` an event is 
fired and the value becomes 0. This value is incremented by the system dependent time step - probably something like 1..100ms

  * `.flags` — contains a set of tmfXXXX flag values. Determines the behavior of the timer. See below for description of the flags.

  * `.Callback` — pointer to the callback procedure of the timer.
                  The callback procedure should accept one argument with the pointer to the timer that fired the event: `proc OnTimer, .ptrTimer`

  * `.Expired`  —  count of the timer expirations, if the callback procedure was not called.

  * `.tag`  —  user defined value associated with the timer.


The `.flags` field can have one or more of the following values:

 * `tmfDoNothing`  — when the timer expires no action should be performed. .Expired field of the timer will be incremented.

 * `tmfCallProc` —   `[TTimer.Callback]` contains pointer to the procedure that to be executed once per timer expiration.

 * `tmfSyncDestroy` — If this flag is set, the timer will be destroyed on the next timer expiration.
                      In this case, the configured event is fired and then the timer is destroyed.
                      The flag is checked after the event returns, so the event handler can reset this flag and thus to prevent destruction.

 * `tmfRunning` — If this flag is set, the timer runs. If the event handler resets this flag, the timer will fire only once and will be suspended.

-----------------------

[#TimerCreate] `proc TimerCreate`

Creates a new timer.

Returns:

 * CF=0; EAX= pointer to the TTimer structure. The timer is created suspended.
         The user can set or reset tmfRunning in `[.flags]` in order to start or stop the timer.
         Also, the user have to enter proper values in the remaining fields.

 * CF=1; Error allocating memory.

---------------------- 

[#TimerDestroy] `proc TimerDestroy, .ptrTimer`

Destroys the timer `[.ptrTimer]`

------------------


## FreshLib directory "simpledebug/"

### "debug.asm" library 

[#simpledebug] This library includes number or macros and procedures aimed to assist the debugging
process of the application. These macros display different data values on the debugging
console.

The library contains its own output procedures, so it does not depend on the other used libraries.

All the macros from this library generate code only when [#options.DebugMode] = 1, so the
programmer can include as many debug statements as needed and leave them in the source.
They will not be included in the final binary.
The debug macros will always preserve all registers, except the EFLAGS register.

-------------

[#DebugMsg] `macro DebugMsg msg`

Displays the text message `msg` to the debug console.
Example:
;begin
     DebugMsg 'The program executes here!'
;end

----------------

[#OutputRegister] `macro OutputRegister reg, radix`

Outputs the content of some register in the given radix. Example:
;begin
    OutputRegister regEAX, 10
;end
The possible register values are: `regEDI`, `regESI`, `regEBP`, `regESP`, `regEBX`, `regEDX`, `regECX`, `regEAX`

----------------

[#OutputMemory] `macro OutputMemory pointer, size`

OutputMemory will dump `[size]` bytes of memory at address `[pointer]`; Example:
;begin
    OutputMemory esi, 128
;end

---------------

[#OutputNumber] `macro OutputNumber number, radix, digits`

Outputs *digits* digits of the *number* in *radix* radix. Example:
;begin
    OutputNumber 12345, 16, 8
;end

------------------

[#GetTimestamp] `proc GetTimestamp`

Returns in eax timestamp measured in milliseconds (ms).

-----------------


## FreshLib directory "data/" 

This directory contains several libraries that handles different data structures.
The libraries are mostly OS independent.
Actually the only OS dependent part is one small routine in Win32 section, that
converts strings from UTF-8 to UTF-16 because Windows can't handle UTF-8 strings
directly.

------------------

### "arrays.asm" library 

This library handles dynamic arrays, containing elements of arbitrary size.
All elements of the array have the same size.

[#TArray] TArray structure have following definition:
;begin
    struct TArray
      .count     dd ?
      .capacity  dd ?
      .itemsize  dd ?
      .lparam    dd ?
      label .array dword
    ends
;end
The above structure represents the header of the array. The actual array will
have arbitrary size, depending on the element count and size.

The first element of the array begins on offset *TArray.array* from the begining
of the memory block.

The field *TArray.count* contains the current element count of the array.

The field *TArray.capacity* contains the current capacity of the array.
It is because the library usually allocates more memory than is needed for the array
element count.
This approach reduces memory allocations and reallocations and
thus increases the speed of inserting and deleting elements in the array.
How many memory will be allocated depends on the user setting of the variable
ResizeIt (defined in memory.asm). This variable contains a pointer to the
procedure that simply increases the value of ECX to the next suitable value.

The field *TArray.itemsize* contains the size in bytes of one array element.
Changing of this value is not recommended.

The field *TArray.lparam* is for user defined parameter, associated with the array.

-----------------------------

[#CreateArray] `proc CreateArray, .itemSize`

This procedure creates new array with item size `[.ItemSize]`

The procedure returns CF=0 if the array is properly created and pointer to the
array is placed in EAX.

In case the memory cannot be allocated, the procedure returns CF=1.
To free the allocated array, use [#FreeMem] procedure.

------------------------------

[#AddArrayItems] `proc AddArrayItems, .ptrArray, .count`

This procedure adds new array items at the end of the array pointed by `[.ptrArray]`

The procedure returns two values:

EAX contains pointer to the first of the new appended elements.

EDX contains pointer to the array (in the process of appending of the new
element, it is possible the whole array to be moved to the new address in
memory, so the programmer should store the value of EDX for the future
reference to the array.

In case, the new memory can not be allocated, the procedure returns CF=1 and
EDX contains the proper pointer to the original array.

----------------------------------

[#InsertArrayItems] `proc InsertArrayItems, .ptrArray, .iElement, .count`

This procedure inserts `[.count]` new elements at the `[.iElement]` position of the
array pointed by `[.ptrArray]`

If `[.iElement]` is larger or equal to `[TArray.count]` the elements are appended
at the end of the array. (Just like AddArrayItems) Otherwise, all elements are
moved to make room for the new elements.

The procedure returns exactly the same results as AddArrayItems procedure — EDX
points to the array and EAX points to the first of the new inserted elements.

CF is an error flag.

---------------------------------

[#GetArrayItem] `proc GetArrayItem, .array, .item`

CF=0; Returns in EAX pointer to the array item with index `[.item]`.

CF=1; The requested item does not exists ( `[.item]` >= `[.array.count]` ). In this case,
EAX contains pointer to the end of the array the byte next after the last array element.

---------------------------------

[#DeleteArrayItems] `proc DeleteArrayItems, .ptrArray, .iElement, .count`

This procedure deletes `[.count]` items with begin index `[.iElement]` the `[.ptrArray]`
dynamic array. If the capacity of the array is bigger than the recommended for
the new count, then the array is resized. The recommended size is calculated
using ResizeIt procedure from memory library.

Returns EDX - pointer to the TArray. In the most cases this pointer will not be
changed, but this also depends on the current OS memory allocation API, so it
is safer to store the pointer for future use, instead of one passed to the
procedure.

This procedure can not fail, because deleting element is always possible. In
some rare cases it can fail to reallocate smaller memory block, but this is
not a problem for the array consistency.

---------------------------

[#VacuumArray] `proc VacuumArray, .ptrArray`

This procedure removes the reserved memory from the array in order to make it
as small as possible.
Note, that the first insert/append operation after the vacuum operation will be very slow.
The memory economized this way depends on reallocation strategy and can be from 25 to 100% in some cases.

--------------------------

[#ListIndexOf] `proc ListIndexOf, .ptrList, .Item`

The list is a special case of array with item size equal to 4 bytes (dword).
This procedure searches the list `[.ptrList]` for item equal to `[.Item]` and
returns the index of the element in EAX. In case of error CF=1.

---------------------------

[#ListFree] `proc ListFree, .ptrList, .FreeProc`

Frees all elements of the list `[.ptrList]`, calling `[.FreeProc]` for every
element of the list.

FreeProc callback procedure have one argument of type dword that is the value
of the current list element. The definition of the callback procedure is similar
to following:

;begin
    proc FreeMyListItem, .ptrItem
    begin
            ;do something with the item being freed
            return
    endp
;end


-----------------


### "strlib.asm" library 

[#StrLib]

Using strings in assembler was often problematic for programmers - static
strings can't be resized, so they had to reserve as many bytes as they thought
user could need, and it still could be not enough. For that reason we created
Dynamic String Library - a library that operates on dynamic strings, that are
automatically resized when needed. Also, StrLib contains many functions that
perform different string operations — comparison, inserting one string into
another, etc.
In StrLib, the strings are represented by handles, not by pointers. This way,
the string can be freely resized and moved in memory.
StrLib can distinguish the handle values from pointer and will process properly
both of them. When the processing is possible, the procedures will operate
on static strings in memory.

[#StrLib string format]

The strings in the StrLib are stored in specific format. The format is defined
following way:
;begin
    struc string {
      .capacity dd ?
      .len      dd ?
      label .data byte
    }

    virtual at -(sizeof.string)
      string string
      sizeof.string = $-string
    end virtual
;end
The structure string have variable length and is dynamically allocated.

The field *string.capacity* on offset `-8` contains the allocated memory size in bytes.

The field *string.len* on offset `-4` contains the current length of the string in bytes.

The string content begins on offset 0. The content of the string always ends with at least one
zero byte, so the string format is compatible with ASCIIZ format used in the most OS API.

All procedures in StrLib will set `[string.len]` to the proper value and will use it in the
string processing.

If the programmer manipulates the string data directly, he should set `[string.len]` himself, or
call [#StrFixLen] in order to let StrLib to scan the string and to fix the length field.


[#StrLib procedures]

StrLib procedure reference:

[#StrNew]
;begin
        proc StrNew
;end
Creates new dynamic string and returns its handle.

[#StrDel]
;begin
        proc StrDel, .hstring
;end
Frees the memory occupied by given string. If the .hstring is pointer to memory, StrDel
will try to find it in the table of created strings and if found, will free it as well.
If the string passed by pointer is not found in the list - StrDel exits without error.
Note, that passing pointer can degrade the performance of the procedure.

[#StrPtr]
;begin
        proc StrPtr, .hstring
;end
Returns in EAX the pointer of the string with handle `[.hstring]`
If .hstring is pointer EAX will be equal to `[.hstring]`
If the handle is invalid, StrPtr returns CF=1 and EAX=0.


[#StrLen]
;begin
        proc StrLen, .hstring
;end
Returns the length of the string in bytes, excluding the terminating zero.
If `[.hstring]` is handle, the procedure returns directly the stored length of the string.
If `[.hstring]` is pointer, the functions scans the string and computes the length.
Thus, passing handle is much faster, especially for long strings.


[#StrDup]
;begin
        proc StrDup, .hstring
;end
Creates new string and copy the content of `[.hstring]` to it.
Returns in EAX — handle of the new string.
`[.hstring]` can be memory pointer or string handle.



[#StrFixLen]
;begin
        proc StrFixLen, .hstring
;end
StrFixLen scans the string in order to compute its actual length and then writes this length
in the field `[string.len]`.
StrFixLen should be call only with handle of the string as argument. It will process pointer as
well, but will assume there is a field `[string.len]` at offset `-4`.
The user should call StrFixLen only if the `[string.len]` field does not contains the proper value,
because of some reason - for example the user made some string processing that changes the length
of the string or the string data is returned by some OS function that does not care about string
length.


[#StrSetCapacity]
;begin
        proc StrSetCapacity, .hString, .capacity
;end
This function ensures that the allocated for the string memory is enough to hold at least
`[.capacity]` bytes. If needed the string memory is reallocated.
Returns pointer to the string data in EAX.
If the reallocation is impossible, returns CF=1;


[#StrCopy]
;begin
    proc StrCopy, .dest, .source
;end

Copies the content of `[.source]` string to `[.dest]` string.
`[.dest]` must be a handle.
`[.source]` can be handle or pointer.
Returns nothing.



[#StrCompCase]
[#StrCompNoCase]
;begin
    proc StrCompCase, .str1, .str2
    proc StrCompNoCase, .str1, .str2
;end
Compares two strings - case sensitive (StrCompCase) or string not sensitive (StrCompNoCase).

Returns CF = 1 if the strings are equal.

Returns CF = 0 if the strings are different.

The speed of this procedure varies depending on passed strings and its content.
The worst case is when the strings are passed as pointers and have equal lengths.
The best case is when the strings are passed as handles and have different lengths.


[#StrCat]
;begin
    proc StrCat, .dest, .source
;end
Concatenates the string `[.source]` to the end of the string `[.dest]`.

[#StrCharPos]
;begin
    proc StrCharPos, .hString, .char
;end
StrCharPos returns a pointer to the first occurence of a given char in specified string.

[#StrPos]
;begin
    proc StrPos, .hstring, .hpattern
;end
StrPos returns in EAX a pointer to the first occurence of a `[.hpattern]` string in
`[.hstring]` or NULL if the pattern was not found.


[#StrCopyPart]
;begin
    proc StrCopyPart, .dest, .source, .pos, .len
;end
Extracts `[.len]` bytes on position `[.pos]` from the string `[.source]` and copies them
to the string `[.dest]`.
Returns CF=1 if the needed memory can not be allocated.


[#StrExtract]
;begin
    proc StrExtract, .string, .pos, .len
;end
Extracts `[.len]` bytes on position `[.pos]` from the string `[.source]` and copies them
to the new created string.
Returns the created string in EAX or CF=1 if the needed memory can not be allocated.


[#StrSplit]
;begin
    proc StrSplit, .hString, .pos
;end
Splits the string `[.hstring]` into two parts on byte possition `[.pos]`.
The left part remains in `[.hstring]`; The right part is returned as new created string in EAX.
Note that the memory of the `[.hstring]` will not be reallocated, only the length of the string
will be set accordingly.


[#StrInsert]
;begin
    proc StrInsert, .dest, .source, .pos
;end
Inserts the `[.source]` string on possition `[.pos]` into the `[.dest]` string.
Returns nothing.


[#NumToStr]
;begin
    proc NumToStr, .num, .flags
;end
Converts number `[.num]` in any radix to string.
Returns the new created string in EAX.

`[.flags]` controls the way number have to be converted.
.flags is dword value that contains following values:

byte0 - number of digits if ntsFixedWidth is specified.

byte1 - radix for the convertion. Some radixes have predefined constants:
;begin
    ntsBin  = $0200
    ntsQuad = $0400
    ntsOct  = $0800
    ntsDec  = $0a00
    ntsHex  = $1000
;end

byte2, byte3 - flags:
;begin
    ntsSigned       = $00000
    ntsUnsigned     = $10000
    ntsFixedWidth   = $20000
;end

[#StrToNumEx]
;begin
    proc StrToNumEx, .hstring
;end
Converts `[.hstring]` to number.
Returns CF=0 and value in EAX if the conversion was successful, or
CF=1 and EAX = 0 if not.

The procedure supports the FASM numbers format:

`0x1111`, `$1111` or `1111h` will be converted as HEX;

`1111` as decimal;

`1111b` as binary;

`1111o` as octal.


[#StrCharCat]
;begin
    proc StrCharCat, .hString, .char
;end
Appends up to 4 bytes fro `[.char]` at the end of `[.hString]`


[#StrCharInsert]
;begin
    proc StrCharInsert, .hString, .char, .pos
;end
Inserts up to 4 characters from `[.char]` into the `[.pos]` position of the `[.hString]`


[#StrClipSpacesR]
[#StrClipSpacesL]

;begin
    proc StrClipSpacesR, .hString
    proc StrClipSpacesL, .hString
;end

Removes the spaces from the start (StrClipSpacesL) or from the end (StrClipSpacesR)
of the string `[.hString]`.


[#StrCleanDupSpaces]
;begin
    proc StrCleanDupSpaces, .hString
;end
Removes duplicating spaces from the string `[.hStrin]` and leaves only single spaces.
For example the string ("." represents the space char) "123.....456" will be processed to "123.456".

[#StrHash]
;begin
    proc StrHash, .hString
;end
Computes the hash value from the string `[.hString]`.
This procedure implements FNV-1b algorithm.

Returns 32 bit hash value in EAX.


[#DataHash]
;begin
    proc DataHash, .ptrData, .len
;end
Computes the hash value from the memory array at address `[.ptrData]` with byte length `[.len]`.
This procedure also uses FNV-1b algorithm.

Returns 32 bit hash value in EAX.


[#StrLenUtf8]
;begin
    proc StrLenUtf8, .hString, .len
;end
Computes the length in chars of the first `[.len]` bytes of the UTF-8 encoded string `[.hString]`
The scan of the string ends on one of the two conditions — terminating zero byte
is reached or `[.len]` bytes are processed. So, if `[.len] == -1` the scan will always end on the
end of the string.


[#StrOffsUtf8]
;begin
    proc StrOffsUtf8, .hString, .pos
;end
Returns in EAX the address of the `[.pos]` character of the UTF-8 encoded string `[.hString]`
If the length of the string is less than `[.pos]` — returns NULL.


[#DecodeUtf8]
;begin
    proc DecodeUtf8, .chars
;end
Decodes 4 bytes in `[.chars]` to UNICODE dword value.

Returns:
`CF=0` — no error; eax — unicode value; edx — byte count of the char. `[1..4]`

`CF=1` — invalid utf-8 char; if eax = edx = 0;  the character can not be decoded;
if edx <> 0 — eax = the overlong encoded character. edx = byte count of the char.

*Note:* When CF=1 and `[.chars]` is overlong encoded char, eax contains the proper
value and edx contains the proper length. But it is still invalid character, according
to the standards.

[#ExpandTabs]
;begin
    proc ExpandTabs, .hstring, .tabstop
;end

Converts the tab characters in `[.hstring]` into space characters, according to `[.tabstop]` length.
Returns in EAX a value, that indicates by how many chars the length of the string increased.


-----------------


### "uConfig.asm" library 

uCongig library is implementation of small [hierarchical] database engine, intended to keep program settings and
preferences in OS independent manner.
The data in the uConfig database have tree structure similar to the file system directory structure
or to Windows registry structure.
Every record or directory in the database has its own key — dword value.
Usually it is convenient to use as a key 4 char ASCII string in order to be human readable, but
it is not mandatory.
;quote
The uConfig format is not "human readable", "universal", "super-puper", etc.
It was designed with only two aims:

1. Small and simple engine, suitable to be used from assembly.

2. Relatively robust database format.

So, if someone wants some new advanced features - these features should make the engine
smaller or at least to keep its current size.
;end

[hierarchical] http://en.wikipedia.org/wiki/Hierarchical_database_model

The database have two representations — packed "file representation" and
expanded "memory representation".
Database operations can be provided only on expanded form.

The base of the database is TConfigRecord structure. The database itself is an array of
TConfigRecords.

[#TConfigRecord]
;begin
    struct TConfigRecord
      .KeyName  dd ?
      .DataSize dd ?
      .Type     dd ?
      .Data     dd ?
    ends
;end
The fields have following meaning:

* .KeyName — contains the key of the record.

* .DataSize — the size of the data in bytes if .Data field contains pointer to the data.

* .Type is one of the following values:
;quote
*  cdtNULL     = 0
*  cdtInteger  = 1  — .Data contains the number.
*  cdtString   = 2  — .Data contains string handle (see [#StrLib])
*  cdtBlob     = 3  — .Data contains pointer to the blob data. .DataSize — its size
*  cdtConfig   = 4  — .Data contains pointer to the [#TArray] of TConfigRecords — i.e. uConfig database.
;end
* .Data — data value if fits in dword or pointer to the data for the bigger formats.

There are number of procedures intended to provide manipulation of uConfig database:

[#LoadCongigDB]
;begin
    proc LoadConfigDB, .ptrSource, .signature
;end
Loads the "file representation" of database and expands it to "memory representation".
".signature" is DWORD value, that identifies the database. The signature is actually 8 bytes long —
the first dword identify the file as a uConfig database and the second dword are user defined.

The procedure returns:

CF=0; EAX = pointer to the root level of the expanded database

CF=1; Database error:
;quote
EAX = `-1` : Bad signature

EAX = `-2` : Damaged database. Some control sum is wrong.
;end


[#SaveConfigFile]
;begin
    proc SaveConfigFile, .ptrRoot, .signature
;end
Creates "file representation" of the database as a memory TArray of dword. The user have to save
this image to the file if needed.

* .ptrRoot is pointer to TArray ot TConfigRecord.

* .signature if the desired signature for the database file.

The procedure returns pointer to TArray. The user should free it later.


[#FreeConfigDB]
;begin
    proc FreeConfigDB, .ptrRoot
;end
Frees the uConfig database and all its records.

[#GetConfigParam]
;begin
    proc GetConfigParam, .ptrConfig, .pDirectory, .name
;end
Search the database `[.ptrConfig]` for the record with keyname `[.name]`

Returns EAX = poiner to the TConfigRecord or NULL if the record is missing.

`[.pDirectory]` should point to the zero terminated array of dwords with the path to the directory
of the needed record. `[.pDirectory]` can be NULL.

[#GetConfigParam.AsString]
;begin
    proc GetConfigParam.AsString, .ptrConfig, .pDirectory, .name
;end
Returns handle to string with textual representation of the value of the database record.
The user have to free this string later with [#StrDel].
This procedure is intended to be use for screen display of the values of the database.
Depending on the type of the field it returns:

 *  cdtNULL — "NULL"

 *  cdtInteger  — The number converted to decimal string.

 *  cdtString   — A copy of the string.

 *  cdtBlob — "BLOB"

 *  cdtConfig  — "SDIR"


[#DelConfigParam]
;begin
    proc DelConfigParam, .ptrVarConfig, .pDirectory, .name
;end
Deletes the specified config record. Returns nothing.



[#SetConfigParam]
;begin
    proc SetConfigParam, .ptrVarConfig, .pDirectory, .name, .type, .value, .size
;end
Set the value of the given config record. If the record exists, the value will be changed.
If the record with the given name does not exists, it will be created.
Returns error in CF. If CF=1 the specified directory does not exists.



-----------------


### "memstream.asm" library 


-----------------


## FreshLib directory "graphics/"

The graphics library provides procedures that draw graphics images and text on
the screen. The library is OS dependent and is placed in the directory
"graphics" in the root directory of FreshLib.

The main conception of this library is ".raster" - represented by handle
object, where the drawing happens. 

The exact meaning for this object is
different for the different OSes — in Win32 it is named "device context", in
Linux it is "drawable" - window or pixmap.

--------------------

### "context.asm" library 


--------------------

### "draw.asm" library 

--------------------

### "fonts.asm" library 

--------------------

### "text.asm" library 

--------------------

### "images.asm" library 

--------------------

### "giflib.asm" library 

--------------------

### "backbuffer.asm" library 

--------------------

## FreshLib directory "mouse/" 

-------------------

### "mouse.asm" library 

------------------

## FreshLib directory "GUI/" 


This directory contains the libraries providing portable GUI for assembly
programming.

Note that these libraries are in very early stage of development, so the
description in this chapter is preliminary and probably will be changed in
one or another way in the near future.

The main idea behind the GUI library is to make one small OS dependent layer of
functions, that to serve as an interface between the OS and the OS independent
layer of the library.

The first will translate OS events, such as mouse, keyboard, timers etc to one
common standard of OS independent event handlers of the user interface
objects — windows, buttons and other widgets.

The biggest advantage of this approach is that the porting of the library
is very easy — most of the code is OS independent and only little part of it
have to be rewriten in order to port the whole library to a new OS.

The biggest drawback of this approach is the bigger size of the library,
because, with this architecture, all controls in the library have to be created
from scratch. It is impossible to use graphic controls that the OS provides —
particularly Win32 controls - buttons, simple text editors, labels, combo boxes
list and tree view controls etc.

This library is not aimed to use all complex GUI system of the target OS.
At first time, the goal of Fresh GUI library is to provide minimal, but decent
functionality that will do the job — writing portable GUI applications in
assembly language.

The GUI library is actually set of libraries.
These libraries defines many data structures and procedures that together, form
something that conditionally can be called "Object oriented" environment.
It is object oriented, as long as it deals with GUI "objects" - forms,
controls, menus etc.

On the other hand, the library does not limit the programmer in the way HLL OOP
limits him. The user have full access to all data structures of the program.
The "encapsulation" principle is fairly impossible in the assembly programming.

All objects in Fresh GUI library, are in fact structures of data.
For every created object, the library allocates some memory and fills this memory
with object parameters data.

There are two types of data structures that describe GUI objects - classes and
instances.

The *class* is a structure that contains data commonly used by all objects of
given type — for example all buttons use one class structure `CButton`.

*Instance* is a data structure that describes the properties and behavior of
particular GUI object — for example button with icon "open file" that opens
a file when the user click on it.

### Classes 

[#class]

*"Class"* in FreshLib is a data structure, that have the following definition:
;begin
    struct TObjectClass
      .ptrParent           dd 0
      .dataSize            dd 0
      .procCreate          dd 0
      .procDestroy         dd 0
      .procGetParam        dd 0
      .procSetParam        dd 0
      .procExecCmd         dd 0
      .procSysEventHandler dd 0
    ends
;end
`.ptrParent` is a pointer to other TObjectClass structure, that appears as a
parent class for the given class.

`.dataSize` contains the size in bytes of the object instance structure.

The following fields are pointers to procedures that provides the "engine"
of the object. All of these pointers as a rule can be NULL, if there is no need
for such processing.

[#.procCreate]

`.procCreate` is a pointer to procedure that creates instance object of the given class.
This field can be NULL. It has the following definition:
;begin
    proc Create, .obj
;end
This procedure sets needed values in the object instance data structure.

*Note:* This procedure does not allocate any memory. The needed memory block is allocated by
the [#objects] library and the pointer to this allocated block is passed to this procedure in the
argument `.obj`.

[#.procDestroy]

`.procDestroy` is a procedure that destroys an instance of the given class.
;begin
    proc Destroy, .obj
;end
Frees the memory, images, fonts and other resources, allocated for the object `.obj` during
its existence. Must not free the object itself.


[#.procGetParam]

.procGetParam is a pointer to the procedure that retrieves and returns the properties of the object.
;begin
    proc GetParam, .obj, .paramID
;end
Returns the value of the object `[.obj]` parameter with ID=`[.paramID]`

[#.procSetParam]

.procSetParam is a pointer to the procedure that set the properties of the object.
;begin
    proc Set, .obj, .paramID, .value
;end
For object `[.obj]`, set the value of the parameter with ID=`[.paramID]`


[#.procExecCmd]

.procExecCmd is a pointer to the procedure that executes object method.
;begin
    proc ExecCmd, .obj, .method
;end
For the object `[.obj]` this procedure executes the method with ID in `[.method]`.

The methods can have arbitrary number of arguments, that are defined in the
 [#object] definition (see below). When the method is executed, the procedure
`[.procExecCmd]` accepts pointer to the arguments array in the register EBX.

The user is supposed to call methods of the object with the macro "execute"
The macro is defined following way:

[#execute]
;begin
    macro execute obj*, meth*, [arg]
;end

[#.procSysEventHandler]

.procSysEventHandler is a pointer to the procedure that process the system
events that are send to the object, i.e. mouse events, keyboard events etc.
;begin
    proc SysEventHandler, .obj, .pEvent
;end
Process one system event for object `[.obj]`. `[.pEvent]` contains pointer to the
system event.

All of the above callback procedures are called internally and should not be
used by the user of the library. How these procedure are called will be described later.

TObjectClass structure is defined statically in memory, in compile time, only
once for every object class. Its definition is located in the library for the
respective GUI element. For example CButton class structure is defined in the
file TButton.asm that contains the code and data of the object class Button.

In order to make construction of such structures easy, macro with name
ObjectClass is defined in objects.asm

[#ObjectClass]
;begin
    macro ObjectClass name*, parent*,   \
                      procCreate*,      \
                      procDestroy*,     \
                      procGetParam*,    \
                      procSetParam*,    \
                      procExecCmd*,     \
                      procSysEvents*
;end
Every defined ObjectClass have a label that points to the begin of the structure.
The name of this label is the name of the class, prefixed with "C".

One example of ObjectClass definition is the definition of Window object class:
;begin
    ObjectClass Window, Object,     \
                TWindow.Create,     \
                TWindow.Destroy,    \
                TWindow.Get,        \
                TWindow.Set,        \
                TWindow.ExecCmd,    \
                TWindow.SysEventHandler
;end

This definition creates following data structure in the memory:
;begin
    CWindow:    dd  CObject
                dd  sizeof.TWindow
                dd  TWindow.Create
                dd  TWindow.Destroy
                dd  TWindow.Get
                dd  TWindow.Set,
                dd  TWindow.ExecCmd
                dd  TWindow.SysEventHandler
;end

### Object instance structure

[#object]
[#endobj]
[#instance]

Object instance is data structure that contains different fields. By that it is
very similar to the normal FASM structures. As structures, the object is only
description of the data but not the data itself.

Objects can inherit field definitions by its parent objects. The memory instance
of the object is allocated dynamically in runtime, when the object is created
by call to the respective FreshLib procedures.

The definition of the object looks like following:
;begin
    object TObject
      .ptrClass     dd ?

      .mxAccess     dd ?
      .ptrVar       dd ?

      .OnCreate     dd ?
      .OnDestroy    dd ?

      method .AddChild, .objchild
    endobj

    object TWindow, TObject
      .handle       dd ?
      .Fcaption     dd ?
      .Fcursor      dd ?

      param .x
      param .y
      param .width
      param .height
      param .visible
      param .caption
      param .parent
      param .cursor

      method .Refresh
    endobj


    object TButton, TWindow
      .state      dd ?
      .Ficon      dd ?
      .FiconAlign dd ?
      .Ftextalign dd ?

      .OnClick dd ?

      param .TextAlign
      param .Icon
      param .IconPosition
    endobj
;end

By convention the names of the objects are composed by the name of the class,
prefixed with "T".

You can see that the object TWindow contains data fields, parameters and methods.
The parameters defined by "param" macro are compile time constants which values
are assigned automatically. These constants are local labels for the object
structure.
They are also inherited from the parent structure.

The methods are very similar to parameters, in that they are constants, defined
in compile time. But besides the value, the method also have list of
arguments, passed to the method, when executed.

In the above example, TButton.width parameter is inherited from TWindow and
have the same value as TWindow.width parameter.

Also, TWindow have all fields of TObject defined as well.

If we have to translate TWindow definition in plain FASM syntax it will looks
similar to this:
;begin
    struc TWindow {
      .ptrClass     dd ?

      .mxAccess     dd ?
      .ptrVar       dd ?

      .OnCreate     dd ?
      .OnDestroy    dd ?

      .handle       dd ?
      .Fcaption     dd ?
      .Fcursor      dd ?

      .AddChild = $80000000
      .x        = $80000001
      .y        = $80000002
      .width    = $80000003
      .height   = $80000004
      .visible  = $80000005
      .caption  = $80000006
      .parent   = $80000007
      .cursor   = $80000008
      .Refresh  = $80000009
    }
    virtual at 0
      TWindow TWindow
      sizeof.TWindow = $
    end virtual
;end

------------------

### "objects.asm" library. 

[#object]

------------------


### "sysevents.asm" library 

[#sysevents.asm]

This library contains event codes and data structures for FreshGUI OS independent
events. For now only several events are defined:
;begin
    ; mouse events
    seMouseMove
    seMouseEnter
    seMouseLeave
    seMouseBtnPress
    seMouseBtnRelease
    seMouseBtnClick
    seMouseBtnDblClick

    ; keyboard events
    seKbdKeyPress
    seKbdKeyRelease
    seKbdStatusChanged
    seKbdChar

    ; Window handling events
    sePaint
    seScroll
    seFocusIn
    seFocusOut
    seMoveResize
;end
These events cover mouse, keyboard and window appearance and behavior events.

Every event have some arguments that have to be sent to the recipient event handler.
The event code and the event arguments are contained in data structure, defined for
every kind of events.

The first dword of the event structure is the field .event that contains the
event code.

Here are the structures defined in sysevents.asm


[#TSysEvent]
;begin
    struct TSysEvent
      .event  dd  ?
    ends
;end
The base event structure. The field `.event` contains the code of the event, as described above.


[#TMouseMoveEvent]
;begin
    struct TMouseMoveEvent
      . TSysEvent
      .x         dd ?
      .y         dd ?
    ends
;end
The event is generated when the mouse cursor moves over some window.
The fields `.x` and `.y` contains the coordinates of the mouse cursor relative to
the upper-left cornet of the window, this message is sent to.


[#TMouseButtonEvent]
;begin
     struct TMouseButtonEvent
      . TSysEvent
      .Button    dd ?
      .kbdStatus dd ?
    ends
;end
This event is generated when some of the mouse buttons changes its state.
The button that changes its state is specified in the field `.Button`.

This field can accept following values:
;begin
    mbLeft      = 0
    mbMiddle    = 1
    mbRight     = 2
;end
The field `.kbdStatus` contains the status of remaining mouse buttons and
keyboard modifying buttons. These buttons are represented by bits in the field:
;begin
    maskBtnLeft     = $0100
    maskBtnMiddle   = $0200
    maskBtnRight    = $0400
    maskCtrl        = $0800
    maskShift       = $1
    maskCapsLock    = $2
    maskCtrl        = $4
    maskAlt         = $8
    maskScrLk       = $10
;end

[#TMouseEnterEvent]
;begin
    struct TMouseEnterEvent
      . TSysEvent
    ends
;end
This event is generated when the mouse cursor enters or leaves some control.
There is no additional parameters besides the event code.


[#TKeyboardEvent]
;begin
    struct TKeyboardEvent
      . TSysEvent
      .key       dd  ?
      .kbdStatus dd  ?
    ends
;end

This event is generated on keyboard button press/release. The field `.key` contains
the code of the pressed button. `.kbdStatus` have the same meaning and the same
values as in TMouseButtonEvent.


[#TPaintEvent]
;begin
    struct TPaintEvent
      . TSysEvent
      .context dd ?
      .rect    RECT
    ends
;end
TPaintEvent is generated when given control have to be repainted. The field `.context`
contains a pointer to [#TContext] structure where the program have to draw.

The field `.rect` is the rectangle of the control that needs to be repainted.


[#TScrollEvent]
;begin
    struct TScrollEvent
      . TSysEvent
      .ScrollBar  dd ?      ; 0
      .ScrollCmd  dd ?      ;
      .Value      dd ?      ; Distance for scUp and scDown and position for scTrack
    ends
;end
This event is sent to the window when it needs to be scrolled.
The field `.ScrollBar` have value 0 for the horizontal scrolling and 1 for vertival.
There are defined constants for these values:
;begin
    scrollX = 0
    scrollY = 1
;end
The field `.ScrollCmd` can have following values:
;begin
    scTrack   = 1
    scUp      = 2
    scDown    = 3
    scWheelUp = 4
    scWheelDn = 5
;end
The field `.Value` contains the absolute position where to scroll the window, for the
command scTrack, and relative distance of the scroll for all remaining commands.


[#TCloseEvent]
;begin
    struct TCloseEvent
      . TSysEvent
      .reason dd ?          ; how the close was requested?
    ends
;end

This event is sent to the window, when the window have to be closed.
`.reason` field defines the reason for the operation. It can have following values:
;begin
    cerFromUser = 0  ;The user pressed X button on the window header, pressed alt+F4
                     from the keyboard, or choose "Close" from the title menu.

    cerFromProgram = 1 ; Method Close was executed from the program.
;end

[#TFocusEvent]
;begin
    struct TFocusInEvent
      . TSysEvent
    ends
;end
This event is sent when the window receives or lose the focus.


[#TMoveResizeEvent]
;begin
    struct TMoveResizeEvent
      . TSysEvent
      .newX  dd ?
      .newY  dd ?
      .newWidth  dd ?
      .newHeight dd ?
    ends
;end
This event is generated when the user resizes the window or moves it to another place.
The fields specify the new coordinates and sizes.


-------------------

### "main.asm" library. 

[#main.asm]

This library implements the procedures for the main program loop of the GUI application.
The modal dialogs procedure is also here.


[#Run]
;begin
    proc Run
;end
This procedure is the main program loop of the GUI application.
The procedure Run process all pending system events, then calls once the OnIdle
event handler of the [#TApplication] object and then sleeps until new events are
sent by the OS.

When the OS terminates the application — the procedure returns an exit code.

The programmer uses this procedure following way:
;begin
        stdcall Run
        push    eax             ; eax contains the exit code.

        FinalizeAll             ; free all resources.

        stdcall Terminate       ; the exit code is already in the stack.
;end

[#ShowModal]
;begin
    proc ShowModal, .pForm, .pParent
;end
Shows the form `[.pForm]` as a modal dialog window with parent window `[.pParent]` —
i.e. the parent window is disabled until the modal windows is visible.

The procedure returns the modal result in EAX. The modal result is also stored in
`TForm.ModalResult` field of the modal form.


[#ProcessSystemEvents]
;begin
    proc ProcessSystemEvents
;end
This procedure process the events generated by the OS. If there are waiting
events in the queue, the procedure reads them, translates them to FreshGUI
event data structures and calls the event handlers of the respective windows.

If there is no pending events in the queue, ProcessSystemEvents ends with CF=0

The second task this procedure serves is to detect the end of the application.
In this case it ends with CF=1.

This procedure is call from the main event loop of the application. ([#Run] procedure).
Also, the user can periodically call this procedure in order to not allow
hanging of the user interface during long processing of some data.


[#WaitForSystemEvent]
;begin
    proc WaitForSystemEvent
;end
This procedure waits until some system message is posted to the application
event queue. Then it exits. During the wait, very low CPU power is consumed
by the application.


-------------------


### "ObjTemplates.asm" library 

[#templates]

This library contains the template engine of FreshGUI.
The template engine provides creation of complex window structures with tree
layout from memory data structure, called template. The templates makes
creation of dialog windows containing children windows and non visual objects.

Templates can be visually created and edited. The template format used by
FreshLib is flexible and allows all parameters and fields of the objects to
be set to needed values during creation of the window.


The template is consisted from one or more data structures of type TObjTemplate,
defined following way:
;begin
    struct TObjTemplate
      .flags     dd  ?
      .class     dd  ?
      .ptrVar    dd  ?
      .paramsize dd  ?
      .params:
    ends
;end
`.flags` — controls what is the place of the object in the whole tree structure.
Can accept one or more of the following values, combined with OR:

`tfChild`  — means the object is a child of the last object with tfParent set.

`tfParent` — means the given object is parent and there will be at least one next
TObjTemplate structure that will be a child object.

`tfEnd` — means the given object is the last child of its parent.
Note, that one object can be parent and child in the same time.
If the current template element is at the root level — the processing of
template stops, after creating the current element and all its children.

.class - pointer to TObjectClass data structure for the created object.

.ptrVar - pointer to dword variable that to accept the pointer to the created object.

.paramsize — the size of the additional data to the end of the template.
Note, that TObjTemplate is variable length structure, not fixed. sizeof.TObjTemplate
contains the size of the header part of the structure.

.params — after the header fields there can be arbitrary count of dword pairs:
(paramID, Value) that to be set to the object during creation. This sequence
ends with dword $FFFFFF (-1) value for paramID.

Easy creation of templates is provided with macro ObjTemplate:

[#ObjTemplate]
;begin
    macro ObjTemplate  flags, class, name, [id, param]
;end
This macro allows use of string values for params and computes automatically
the values for TObjTemplate.paramsize;
The macro have following arguments:

* flags — set of (tfChild, tfParent, tfEnd) constants.

* class — the base name of the object class (without prefix C) — i.e. Form,
        Window, Button, etc.

* name — label of the variable to receive the pointer to the created object.

* id — parameter ID or offset in the object structure.

* param — value of the parameter. Can be dword number or string constant. In the
case the parameter value is string, it will be automatically created in
the memory and the pointer to this string will be placed as a param value.

One example of template structure:
;begin
    ObjTemplate  tfParent or tfEnd, Form, frmMain,      \
                             visible, TRUE,             \
                             x, 100,                    \
                             y, 50,                     \
                             width, 640,                \
                             height, 480,               \
                             caption, 'Fresh portable Win32/Linux application test.'

      ObjTemplate  tfChild, Button, btnChild1,          \
                             visible, TRUE,             \
                             x, 64,                     \
                             y, 48,                     \
                             width, 64,                 \
                             height, 24,                \
                             caption, 'Button1',        \
                             OnClick, Button1Click

      ObjTemplate  tfChild or tfEnd, Button, btnChild2, \
                             x, 136,                    \
                             y, 48,                     \
                             width, 64,                 \
                             height, 24,                \
                             caption, 'Button2' ,       \
                             visible, TRUE
;end

The template engine provides one single procedure:

[#CreateFromTemplate]
;begin
    proc CreateFromTemplate, .ptrTemplate, .parent
;end
This procedure creates all objects from the template, pointed by `[.ptrTemplate]`
as a parent of `[.parent]` argument.

`.ptrTemplate` points to TObjTemplate structure.

`.parent` points to TObject descendant structure. In most cases it will be
actually descendant of TWindow or NULL if the created object is not a child
of any window.

Returns: *EBX* contains a pointer to the topmost of the created object
(it is first of the created objects)

All pointers of the objects are stored in the specified in the template
variables ( i.e. `[TObjTemplate.ptrVar]`)


------------------

### "TObject.asm" library 

[#TObject]

This library implements TObject object class. This is the root class for all object clases in
FreshLib. It is defined following way:
;begin
    object TObject
      .ptrClass     dd ?

      .mxAccess     dd ?
      .ptrVar       dd ?

      .OnCreate     dd ?
      .OnDestroy    dd ?

      method .AddChild, .objchild
    endobj
;end

------------------

### "TApplication.asm" library 

[#TApplication]
;begin
    object TApplication, TObject
      .MainWindow   dd ?
      .Accelerators dd ?
      .OnIdle       dd ?
    endobj
;end
This object class represents the whole GUI application and handles some properties that are
application-wide. For example it keeps the main windows of the application, the list of
keyboard accelerators, etc.
Only one instance of this object must be created during the initialization of the application,
before the call of [#Run] procedure.

`.MainWindow` field is a pointer to the main window of the application. When this window is
closed, the whole application terminates as well.

`.Accelerators` fields is a pointer to a list with application-wide keyboard accelerators.

`.OnIdle` is an application callback that will be call once everytime the events queue is empty.
The user can process here some tasks that have to be processed with low priority. The usual
use of this callback is to detect what toolbar buttons and menu items have to be enabled or
disabled, depending to the current state of the program.


------------------

### "TWindows.asm" library 

[#TWindow]
;begin
    object TWindow, TObject

      .handle       dd ?

      ._x           dd ?
      ._y           dd ?
      ._width       dd ?
      ._height      dd ?

      ._visible     dd ?

      ._bounds_changed dd ?

      ._border      dd ?

      ._align       dd ?

      ._FreeArea    TBounds

      ._caption     dd ?
      ._cursor      dd ?

      .OnKeyPress   dd ?

    ; parameters

      param .x
      param .y
      param .width
      param .height

      param .Align

      param .FreeArea

      param .borderKind
      param .Zorder

      param .Visible
      param .Caption
      param .Parent
      param .Cursor
      param .Children

      method .Refresh
      method .Focus
      method .AlignChildren
      method .ToBack
      method .ToFront

      method ._ComputeFreeArea
    endobj
;end

------------------


### "TScrollWindow.asm" library 

[#TScrollWindow]

;begin
    object TScrollWindow, TWindow
      ._HScroller TScrollbar
      ._VScroller TScrollbar

      method HScrollSet, .Pos, .Max, .Page
      method VScrollSet, .Pos, .Max, .Page
    endobj
;end


------------------

### "TForm.asm" library 

[#TForm]
;begin
    object TForm, TWindow

      .ModalResult  dd ?

      .OnClose dd ?

      param .type
    endobj
;end

------------------

### "TButton.asm" library 

[#TButton]
;begin
    object TButton, TWindow
      .state      dd ?
      .Ficon      dd ?
      .FiconAlign dd ?
      .Ftextalign dd ?

      .ModalResult dd ?
      .OnClick dd ?

      param .TextAlign
      param .Icon
      param .IconPosition
    endobj
;end


------------------

### "TLabel.asm" library 

[#TLabel]
;begin
    object TLabel, TWindow
      .Ftextalign dd ?

      param .TextAlign        ; text align flags.
      param .Control          ; control that to be activated
    endobj
;end

------------------

### "TImagelabel.asm" library 

[#TImageLabel]
;begin
    object TImageLabel, TWindow
      .FImageAlign dd ?
      .FImage      dd ?
      .FMask       dd ?
      .FBackground dd ?

      param .ImageAlign
      param .Image
      param .Mask
    endobj
;end


------------------

### "TEdit.asm" library 

[#TEdit]
;begin
    object TEdit, TWindow
      ._Text  dd ?
      ._Len   dd ?  ; the length of the string in characters. (UTF-8)
      ._Start dd ?  ; Where the string begins to be displayed in the edit window.
      ._Pos   dd ?  ; Position of the caret in the string.
      ._Sel   dd ?  ; Position of the selction in the string.

      ._MarginLeft dd ?
      ._MarginRight dd ?

      ._Focused dd ? ; flag

      param .Text
    endobj
;end


------------------

### "TProgressbar.asm" library 

[#TProgress]
;begin
    object TProgress, TWindow
      ._Pos   dd ?
      ._Max   dd ?
      ._Color dd ?

      param .Pos
      param .Max
      param .Color

      method .Step
    endobj
;end

------------------

### "TTreeView.asm" library 

[#TTreeView]
;begin
    object TTreeView, TScrollWindow
      ._items dd ?
      ._first dd ?
      ._pShadow dd ?

      .OnItemDelete  dd ?

      param .Focused

      method .AddItem, .iParent
      method .DelItem, .iItem
      method .GetItem, .index
    endobj
;end

------------------

## FreshLib directory "FreshEdit/" 

This directory contains one additional control class — TFreshEdit.
It is complex and powerful text editor control, intended to be used
in the advanced programmer's text editors - such as Fresh IDE.

------------------

### "TFreshEdit.asm" library 


[#TFreshEdit]

;begin
    object TFreshEdit, TScrollWindow
      ._Font            dd  ?   ; font of the editor.

    ; main editor font sizes
      ._fontheight      dd  ?   ; in pixels.
      ._fontwidth       dd  ?   ; in pixels.
      ._fontdescent     dd  ?   ; in pixels.

    ; system font sizes (used for additional texts and line numbers)
      ._fontheight2     dd  ?   ; in pixels.
      ._fontwidth2      dd  ?   ; in pixels.
      ._fontdescent2    dd  ?   ; in pixels.

      .__LeftMargin     dd  ?   ; width of the left margin field. Auto computed.
      .__NumberMargin   dd  ?   ; width of the field for the line number. Auto computed.

      ._cols            dd  ?   ; width of the window in text columns.
      ._rows            dd  ?   ; height of the window in text rows.
                                ; must to be update on resize and on font change.

      ._pLines          dd  ?   ; pointer to TArray of TEditorLine items.
      ._pLengths        dd  ?   ; pointer to TArray with counts of the lines with given length.

      ._pUndoList       dd  ?   ; pointer to TArray of TUndoInfo
      ._pRedoList       dd  ?   ; pointer to TArray of TUndoInfo

      ._pShadow         dd  ?   ; pointer to TBackBuffer object.
      ._fShadowValid    dd  ?   ;

    ; view change fields

      ._TopLine         dd  ?   ; number of the line that is at the topmost line of the window.
      ._TopOffset       dd  ?   ; how many rows the top line is off the screen (for word wrapped lines)
      ._LeftColumn      dd  ?   ; the column of the text at the leftmost side of the window.

      ._CaretChar       dd  ?   ; the number of the char the caret resides.
      ._CaretLine       dd  ?   ; the index of the line the caret resides.

      ._SelChar         dd  ?
      ._SelLine         dd  ?

      ._fReadOnly       dd  ?
      ._SelMode         dd  ?        ; NOTE: on selmBlock, the word wrap should be OFF
      ._InsMode         dd  ?
      ._TabStop         dd  ?

    ; end change fields

      ._prevTopLine     dd  ?
      ._prevTopOffset   dd  ?
      ._prevLeftColumn  dd  ?

      ._prevCaretChar   dd  ?
      ._prevCaretLine   dd  ?

      ._prevxDelta      dd  ?
      ._prevyDelta      dd  ?

      ._prevSelMode     dd  ?
      ._prevInsMode     dd  ?

    ; end backup fields

      ._DragButton      dd  ?

      ._procSyntax      dd  ?   ; syntax highlighter procedure.

    ; icons and masks for the left margin
      ._iconBreakpointA dd  ?       ; active breakpoint icon.
      ._iconBreakpointI dd  ?       ; inactive breakpoint icon.
      ._iconDebugInfo   dd  ?
      ._maskBreakpointA dd  ?
      ._maskBreakpointI dd  ?
      ._maskDebugInfo   dd  ?
      ._iconUnfold      dd  ?
      ._iconFold        dd  ?
      ._maskUnfold      dd  ?

    ; Event handlers

      .OnControlKey     dd  ?

    ; Parameters
      param .Selection      ; selected text read/write

      param .CurrentLine    ; TEditorLine where caret resides. read only
      param .Text           ; whole text; read/write
      param .MaxLineLen

    ; Methods

      method .Clear          ; clears the text in the editor.

    ; navigation methods

      method .Move, .direction, .count, .force      ; moves the caret

      method .LineBegin
      method .LineEnd
      method .ScreenBegin
      method .ScreenEnd
      method .FileBegin
      method .FileEnd

    ; editing methods

      method .DeleteSel
      method .InsertLine, .index    ; index = -1 inserts at current position of the caret.
                                    ; index = -2 appends the line at the end of the text.
      method .DeleteLine, .index    ; index = -1 deletes the line on the current position of the caret.

    ; block processing methods.
      method .DeleteText, .lineFrom, .charFrom, .lineTo, .charTo, .BlockKind
      method .GetText, .lineFrom, .charFrom, .lineTo, .charTo, .BlockKind

    ; Undo/Redo functions.

      method .RegisterForUndo, .operation, .data

      method .Undo
      method .Redo

      method .ClearUndo

    ; these two methods are flexible, but very slow.
    ; .Text parameter seting is fastest way to change whole text of the editor.

      method .InsertChar, .char
      method .InsertString, .hstring    ; inserts a string at the caret position.
                                        ; If the string contains formating chars they are
                                        ; processed properly.
      method .DelChar      ; deletes the char under the caret.

    ; format and appearance methods
      method .FormatLine, .index

    ; themes methods

      method LoadTheme, .configdb, .directory

    endobj
;end

------------------

### "fasm_syntax.asm" library 


[#SyntaxFASM]
;begin
    proc SyntaxFASM, .hString, .pAttr, .SynContext
;end


------------------

Added phWeb/www/help.css.























































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
/* Common layout styles                                 */
/* They will define the common web site appearance      */

body {
   font-family: Verdana, Helvetica, sans-serif;
   font-size: 10pt;
   background-color: #fffff0;
}

/* Styles for the article formating. */

table {
   border-left-width: 0px;
   border-top-width: 0px;
   border-right-width: 0px;
   border-bottom-width: 0px;

   border-style: solid;
   border-color: #606060;
   background-color: white;
   border-collapse: collapse;
   margin: auto;
}


table td {
   font-size: 10pt;
   border-right-width: 1px;
   border-bottom-width: 1px;
   border-left-width: 1px;
   border-top-width: 1px;

   border-style: solid;
   border-color: #606060;
   padding-left: 4px;
   padding-right: 4px;
   padding-top: 1px;
   padding-bottom: 1px;
   margin: 0px;
}


h1 {
   color: black;
   font-size: 13pt;
   text-align: center;
}


h2 {
  font-size: 11pt;
  margin-top: 20pt;
  margin-bottom: 10pt;
  text-align: left;
}

h3 {
  font-size: 10pt;
  margin-top: 20pt;
  margin-bottom: 10pt;
  text-align: left;
}

h4 {
  font-size: 9pt;
  margin-top: 10pt;
  margin-bottom: 8pt;
  text-align: left;
}


p {
   text-align: justify;
   font-size: 10pt;
   margin-top: 0.75em;
   margin-bottom: 0.75em;
}


p.uli {
  display: list-item;
  list-style: disc inside;
}


code, tt {
  font-family: "Courier New", monospace;
  font-size: 10pt;
  font-weight: bold;

  padding: 0px 3px 0px 3px;
  text-indent: 0px;
  display: inline;
  white-space: nowrap;
}


div.code {
  padding: 4px;
  margin: 0.5em;

  font-family: "Courier New", monospace;
  font-size: 10pt;
  font-weight: bold;

  overflow: auto;
  max-height: 30em;
  max-width: 150%;
  white-space: pre;

  background-color: white;
  border: 2px solid gray;
}


img.txt {
  margin-left:auto;
  margin-right: auto;
  display: block;
  clear: both;
  max-width: 100%;
}


div.bq {
  border: 0px solid #808080;
  padding: 1em;
  padding-left: 2em;
  margin: 0.5em;

  background-color: #f8f8f8;
  opacity: 0.7;
  filter:alpha(opacity=70);

  -webkit-box-shadow: 3px 3px 5px #808080;
  -moz-box-shadow: 3px 3px 5px #808080;
  box-shadow: 3px 3px 5px #808080;

  clear: both;
}

/* Article anchors content */
a.a:before {
 text-decoration: none;
 display: inline-block;
 overflow: hidden;
 content: url(images/anchor.gif);
 vertical-align: middle;
}


hr {
 margin-top: 1em;
 margin-bottom: 1em;
}