Fresh IDE . Check-in [3e024fbdf2]
Not logged in

This repository is a mirror!

The original is located on: https://fresh.flatassembler.net/fossil/repo/fresh
If you want to follow the project, please update your remote-url

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

Overview
Comment:Generally here are the changes made during the work on AsmBB and some work on the GUI library.

Better error check in SocketSendall. Added new function "FileTruncateTo" and implemented for Linux and Win32. Work on the TScrollable class and adapting the TTreeView and TAsmEdit for it.

Timelines: family | ancestors | descendants | both | FreshLibDev
Files: files | file ages | folders
SHA1:3e024fbdf2ed4b064818fc7efabc42293872e9ee
User & Date: johnfound 2017-05-11 08:33:44
Context
2017-05-15
07:47
Major change in the markdown parser. Changed the interface of the TranslateMarkdown procedure and renamed to TranslateMarkdown2 in order to prevet compilation of the old sources with bad arguments. check-in: 23e137dab2 user: johnfound tags: FreshLibDev
2017-05-11
08:33
Generally here are the changes made during the work on AsmBB and some work on the GUI library.

Better error check in SocketSendall. Added new function "FileTruncateTo" and implemented for Linux and Win32. Work on the TScrollable class and adapting the TTreeView and TAsmEdit for it. check-in: 3e024fbdf2 user: johnfound tags: FreshLibDev

2017-04-20
05:58
Work on TAsmEdit; check-in: 6386df457c user: johnfound tags: FreshLibDev
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to freshlib/TestFreshLib.fpr.

cannot compute difference between binary files

Changes to freshlib/gui/TAsmEdit.asm.

871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
....
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
....
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
....
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
....
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

        set     esi, TScrollable:PageX, eax

        mov     ecx, [esi+TAsmEdit._line_widths]
        mov     edx, [ecx+TArray.count]
        test    edx, edx
        jz      .xsize_ok

        mov     edx, [ecx+TArray.array+sizeof.TCounter*edx+TCounter.value - sizeof.TCounter]
;        sub     edx, eax
        inc     edx
.xsize_ok:

        OutputValue "Max X: ", edx, 10, -1

        set     esi, TScrollable:MaxX, edx

; set Y scrollers page and

        xor     eax, eax
        cmp     [esi+TAsmEdit._font_height], eax
        lea     eax, [eax+1]
................................................................................

        add     eax, [.quarter_x]

.morex_ok:

        mov     edx, [esi+TAsmEdit._scrX.pos]
        add     edx, eax

        mov     ecx, [esi+TAsmEdit._line_widths]
        mov     ebx, [ecx+TArray.count]
        test    ebx, ebx
        cmovnz  ebx, [ecx+TArray.array+sizeof.TCounter*ebx+TCounter.value - sizeof.TCounter]
        sub     ebx, [esi+TAsmEdit._scrX.page]

        cmp     ebx, edx
        cmovb   ebx, edx

        set     esi, TAsmEdit:MaxX, ebx
        set     esi, TAsmEdit:PosX, edx

        cmp     eax, [.half_x]
        ja      .paint_all

; now scroll the screen left

................................................................................
.morex_ok2:

        xor     ecx, ecx
        mov     edx, [esi+TAsmEdit._scrX.pos]
        sub     edx, eax
        cmovs   edx, ecx

        mov     ecx, [esi+TAsmEdit._line_widths]
        mov     ebx, [ecx+TArray.count]
        test    ebx, ebx
        cmovnz  ebx, [ecx+TArray.array+sizeof.TCounter*ebx+TCounter.value - sizeof.TCounter]

        cmp     ebx, edx
        cmovb   ebx, edx

        set     esi, TAsmEdit:MaxX, ebx
        set     esi, TAsmEdit:PosX, edx

        cmp     eax, [.half_x]
        ja      .paint_all

        mov     edx, eax
        imul    edx, [esi+TAsmEdit._font_width]
................................................................................

        xor     edx, edx                    ; minimal caret pos 0

        mov     ebx, [esi+TAsmEdit._caret_x]
        add     ebx, [.count]
        cmovs   ebx, edx

;        mov     ecx, [esi+TAsmEdit._line_widths]
;        mov     edx, [ecx+TArray.count]
;        test    edx, edx
;        jz      .xmaxok
;        mov     edx, [ecx+TArray.array+sizeof.TCounter*edx+TCounter.value - sizeof.TCounter]
;;        dec     edx
;.xmaxok:
;        cmp     ebx, edx
;        cmova   ebx, edx

        OutputValue "Caret X = ", ebx, 10, -1

        mov     [esi+TAsmEdit._caret_x], ebx
        cmp     [.select], 0
        jne     .select_ok

        mov     [esi+TAsmEdit._selection_x], ebx

.select_ok:
................................................................................
        push    eax
end if

        mov     esi, [.self]

        xor     edx, edx                    ; minimal caret pos 0

        mov     ecx, [esi+TAsmEdit._lines]
        mov     ecx, [ecx+TText.TextLen]
        shr     ecx, 2  ; line count        ; maximal caret pos

        mov     ebx, [esi+TAsmEdit._caret_y]
        add     ebx, [.count]

        cmovs   ebx, edx

        cmp     ebx, ecx
        cmova   ebx, ecx

        mov     [esi+TAsmEdit._caret_y], ebx

        cmp     [.select], 0
        jne     .select_ok

        mov     [esi+TAsmEdit._selection_y], ebx








<

|
<


<
<







 







<
<
<
<
<
<
<
<
<
<
<







 







<
<
<
<
<
<
<
<
<







 







<
<
<
<
<
<
<
<
<
<
<
<







 







<
<
<
<





<
<
<







871
872
873
874
875
876
877

878
879

880
881


882
883
884
885
886
887
888
....
1329
1330
1331
1332
1333
1334
1335











1336
1337
1338
1339
1340
1341
1342
....
1408
1409
1410
1411
1412
1413
1414









1415
1416
1417
1418
1419
1420
1421
....
1646
1647
1648
1649
1650
1651
1652












1653
1654
1655
1656
1657
1658
1659
....
1683
1684
1685
1686
1687
1688
1689




1690
1691
1692
1693
1694



1695
1696
1697
1698
1699
1700
1701

        set     esi, TScrollable:PageX, eax

        mov     ecx, [esi+TAsmEdit._line_widths]
        mov     edx, [ecx+TArray.count]
        test    edx, edx
        jz      .xsize_ok

        mov     edx, [ecx+TArray.array+sizeof.TCounter*edx+TCounter.value - sizeof.TCounter]
        sub     edx, eax

.xsize_ok:



        set     esi, TScrollable:MaxX, edx

; set Y scrollers page and

        xor     eax, eax
        cmp     [esi+TAsmEdit._font_height], eax
        lea     eax, [eax+1]
................................................................................

        add     eax, [.quarter_x]

.morex_ok:

        mov     edx, [esi+TAsmEdit._scrX.pos]
        add     edx, eax











        set     esi, TAsmEdit:PosX, edx

        cmp     eax, [.half_x]
        ja      .paint_all

; now scroll the screen left

................................................................................
.morex_ok2:

        xor     ecx, ecx
        mov     edx, [esi+TAsmEdit._scrX.pos]
        sub     edx, eax
        cmovs   edx, ecx










        set     esi, TAsmEdit:PosX, edx

        cmp     eax, [.half_x]
        ja      .paint_all

        mov     edx, eax
        imul    edx, [esi+TAsmEdit._font_width]
................................................................................

        xor     edx, edx                    ; minimal caret pos 0

        mov     ebx, [esi+TAsmEdit._caret_x]
        add     ebx, [.count]
        cmovs   ebx, edx













        mov     [esi+TAsmEdit._caret_x], ebx
        cmp     [.select], 0
        jne     .select_ok

        mov     [esi+TAsmEdit._selection_x], ebx

.select_ok:
................................................................................
        push    eax
end if

        mov     esi, [.self]

        xor     edx, edx                    ; minimal caret pos 0





        mov     ebx, [esi+TAsmEdit._caret_y]
        add     ebx, [.count]

        cmovs   ebx, edx




        mov     [esi+TAsmEdit._caret_y], ebx

        cmp     [.select], 0
        jne     .select_ok

        mov     [esi+TAsmEdit._selection_y], ebx

Changes to freshlib/gui/TScrollable.asm.

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
...
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
...
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
...
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
...
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
...
286
287
288
289
290
291
292


293
294
295
296
297
298
299
...
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
...
534
535
536
537
538
539
540





541
542
543
544
545
546
547
...
677
678
679
680
681
682
683
684
685




















































































686
687
688
689
  param .PageY, ._scrY.page, .SetPage:2
  param .MaxY,  ._scrY.max,  .SetMax:2

  method .SetPos,  .param, .value
  method .SetPage, .param, .value
  method .SetMax,  .param, .value

  method .Destroy

  method .Paint
  method .DrawScrollbars
  method .RestoreBackground

  method .EventMouseMove, .x, .y, .kbdState
  method .EventMouseLeave

  method .EventButtonPress, .button, .kbdState, .x, .y
  method .EventButtonRelease, .button, .kbdState, .x, .y


endobj


;_________________________________________________________________________________________

method TScrollable.Destroy
begin

        push    eax












        mov     eax, [.self]








        stdcall DestroyImage, [eax+TScrollable._BackGroundH]
        stdcall DestroyImage, [eax+TScrollable._BackGroundV]




        pop     eax


        inherited











        return
endp


;_________________________________________________________________________________________


................................................................................
        mov     eax, [.value]

        mov     edx, TScrollable._scrX
        mov     ecx, TScrollable._scrY
        cmp     [.param], TScrollable.PosX
        cmovne  edx, ecx

        mov     ecx, [esi+edx+TScroller.max]
        cmp     eax, ecx
        cmovg   eax, ecx

        mov     [esi+edx+TScroller.pos], eax

        popad
        return
endp

;_________________________________________________________________________________________
................................................................................
        mov     eax, [.value]
        mov     ebx, [esi+edx+TScroller.pos]
        mov     ecx, [esi+edx+TScroller.max]

        cmp     eax, ecx
        cmovg   eax, ecx

        sub     ecx, eax        ; max - page

        cmp     ebx, ecx
        cmovg   ebx, ecx

        xchg    eax, [esi+edx+TScroller.page]
        xchg    ebx, [esi+edx+TScroller.pos]

        cmp     eax, [esi+edx+TScroller.page]
        jne     .refresh

        cmp     ebx, [esi+TScroller.pos]
        je      .finish

.refresh:
;        exec    esi, TScrollable:RestoreBackground
;        exec    esi, TScrollable:DrawScrollbars
;        exec    esi, TScrollable:Refresh

.finish:
        popad
        return
endp

;_________________________________________________________________________________________


................................................................................

        mov     edx, TScrollable._scrX
        mov     ecx, TScrollable._scrY
        cmp     [.param], TScrollable.MaxX
        cmovne  edx, ecx

        mov     eax, [.value]
        mov     ebx, [esi+edx+TScroller.pos]
        mov     ecx, [esi+edx+TScroller.page]

        cmp     ecx, eax
        cmovg   ecx, eax

        push    eax
        sub     eax, ecx

        cmp     ebx, eax
        cmovg   ebx, eax
        pop     eax

        xchg    eax, [esi+edx+TScroller.max]
        xchg    ebx, [esi+edx+TScroller.pos]
        xchg    ecx, [esi+edx+TScroller.page]

        cmp     eax, [esi+edx+TScroller.max]
        jne     .refresh

        cmp     ebx, [esi+edx+TScroller.pos]
        jne     .refresh

        cmp     ecx, [esi+edx+TScroller.page]
        je      .finish

.refresh:
;        exec    esi, TScrollable:RestoreBackground
;        exec    esi, TScrollable:DrawScrollbars
;        exec    esi, TScrollable:Refresh

.finish:
        popad
        return
endp



;_________________________________________________________________________________________
................................................................................
begin
        pushad

        mov     esi, [.self]
        mov     ebx, [esi+TScrollable._canvas]
        test    ebx, ebx
        jz      .finish

; Free the previous stored images.

        stdcall DestroyImage, [esi+TScrollable._BackGroundH]
        stdcall DestroyImage, [esi+TScrollable._BackGroundV]

; Create new

        mov     ecx, [esi+TScrollable._width]
        mov     edx, [esi+TScrollable._height]
        sub     ecx, [GUI.scrollWidth]

        stdcall CreateImage, ecx, [GUI.scrollWidth]
        mov     [esi+TScrollable._BackGroundH], eax

        stdcall CreateImage, [GUI.scrollWidth], edx
        mov     [esi+TScrollable._BackGroundV], eax

        exec    esi, TScrollable:DrawScrollbars

.finish:
        popad
        return
endp
................................................................................
        mov     ebx, [esi+TWindow._canvas]
        test    ebx, ebx
        jz      .finish

        xor     eax, eax
        mov     ecx, [esi+TScrollable._width]
        mov     edx, [esi+TScrollable._height]



        sub     ecx, [GUI.scrollWidth]
        stdcall CopyImageRect, [esi+TScrollable._BackGroundV], eax, eax, ebx, ecx, eax, [GUI.scrollWidth], edx

        sub     edx, [GUI.scrollWidth]
        stdcall CopyImageRect, [esi+TScrollable._BackGroundH], eax, eax, ebx, eax, edx, ecx, [GUI.scrollWidth]

................................................................................

; draw the slider X

        lea     eax, [esi+TScrollable._scrX]
        stdcall _SliderPixels2, eax, [.rectX.width]

        mov     edi, [esi+TScrollable._scrX.state]











        stdcall BlendSolidRect, ebx, eax, [.rectX.y], edx, [.rectX.height], [GUI.clScrollSlider+4*edi]

        add     eax, edx
        stdcall BlendTriangle, ebx, eax, [.rectX.y], [GUI.scrollWidth], trtLower or trtLeft, [GUI.clScrollSlider+4*edi]

; draw the slider Y

        lea     eax, [esi+TScrollable._scrY]
        stdcall _SliderPixels2, eax, [.rectY.height]

        mov     edi, [esi+TScrollable._scrY.state]















        stdcall BlendSolidRect, ebx, [.rectY.x], eax, [.rectY.width], edx, [GUI.clScrollSlider+4*edi]

        add     eax, edx
        stdcall BlendTriangle, ebx, [.rectY.x], eax, [GUI.scrollWidth], trtUpper or trtRight, [GUI.clScrollSlider+4*edi]

        mov     ecx, [.rectX.x]
        mov     edx, [.rectX.y]
        add     [.rectX.width], ecx
        add     [.rectX.height], edx

        mov     ecx, [.rectY.x]
................................................................................

        mov     ebx, eax
        shl     eax, 4
        lea     eax, [esi+TScrollable._scrX + eax]
        stdcall _SliderPixels2, eax, [esi+TScrollable._width + 4*ebx]
        mov     edi, [.x + 4*ebx]






        sub     edi, eax
        jl      .before

        cmp     edi, edx
        jg      .after

; inside the slider - capture the mouse.
................................................................................
        return

.zero:
        xor     eax, eax
        jmp     .ok
endp























































































endmodule










|










>






|

>
|
>
>
>
>
>
>
>
>
>
>
>
>
|
>
>

>
>
>
>
>
|
|
>
>
>

|
>

<
>
>
>
>
>
>
>
>
>
>
>







 







<
<
<
<







 







<
<
<
<
<
|
<

<
<
<
<
<
<
<
<
<
<
<
<







 







<
<
<
<
<
<
<
<
<
<
<
<
<
|
<
<

<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







 







|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|







 







>
>







 







>
>
>
>
>
>
>
>
>
>
>
|


|







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|


|







 







>
>
>
>
>







 









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




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
...
136
137
138
139
140
141
142




143
144
145
146
147
148
149
...
163
164
165
166
167
168
169





170

171












172
173
174
175
176
177
178
...
184
185
186
187
188
189
190













191


192















193
194
195
196
197
198
199
...
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
...
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
...
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
...
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
...
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
  param .PageY, ._scrY.page, .SetPage:2
  param .MaxY,  ._scrY.max,  .SetMax:2

  method .SetPos,  .param, .value
  method .SetPage, .param, .value
  method .SetMax,  .param, .value

  method .__UpdateCanvas

  method .Paint
  method .DrawScrollbars
  method .RestoreBackground

  method .EventMouseMove, .x, .y, .kbdState
  method .EventMouseLeave

  method .EventButtonPress, .button, .kbdState, .x, .y
  method .EventButtonRelease, .button, .kbdState, .x, .y
  method .EventScroll, .direction, .command, .value

endobj


;_________________________________________________________________________________________

method TScrollable.__UpdateCanvas
begin
        inherited
        pushad

        mov     esi, [.self]
        mov     ebx, [esi+TWindow._canvas]
        mov     edi, [esi+TScrollable._BackGroundH]
        mov     edx, [esi+TScrollable._BackGroundV]

        test    ebx, ebx
        jz      .destroy

        test    edi, edi
        jz      .create_new

        mov     eax, [ebx+TImage.width]
        cmp     eax, [edi+TImage.width]
        jne     .destroy

        mov     eax, [ebx+TImage.height]
        cmp     eax, [edx+TImage.height]
        je      .finish                         ; the size is ok!

.destroy:
        stdcall DestroyImage, edi
        stdcall DestroyImage, edx
        xor     eax, eax
        mov     [esi+TScrollable._BackGroundH], eax
        mov     [esi+TScrollable._BackGroundV], eax

        test    ebx, ebx
        jz      .finish


.create_new:
        mov     ecx, [GUI.scrollWidth]

        stdcall CreateImage, [ebx+TImage.width], ecx
        mov     [esi+TScrollable._BackGroundH], eax

        stdcall CreateImage, ecx, [ebx+TImage.height]
        mov     [esi+TScrollable._BackGroundV], eax

.finish:
        popad
        return
endp


;_________________________________________________________________________________________


................................................................................
        mov     eax, [.value]

        mov     edx, TScrollable._scrX
        mov     ecx, TScrollable._scrY
        cmp     [.param], TScrollable.PosX
        cmovne  edx, ecx





        mov     [esi+edx+TScroller.pos], eax

        popad
        return
endp

;_________________________________________________________________________________________
................................................................................
        mov     eax, [.value]
        mov     ebx, [esi+edx+TScroller.pos]
        mov     ecx, [esi+edx+TScroller.max]

        cmp     eax, ecx
        cmovg   eax, ecx






        mov     [esi+edx+TScroller.page], eax














        popad
        return
endp

;_________________________________________________________________________________________


................................................................................

        mov     edx, TScrollable._scrX
        mov     ecx, TScrollable._scrY
        cmp     [.param], TScrollable.MaxX
        cmovne  edx, ecx

        mov     eax, [.value]













        mov     [esi+edx+TScroller.max], eax


















        popad
        return
endp



;_________________________________________________________________________________________
................................................................................
begin
        pushad

        mov     esi, [.self]
        mov     ebx, [esi+TScrollable._canvas]
        test    ebx, ebx
        jz      .finish
;
;; Free the previous stored images.
;
;        stdcall DestroyImage, [esi+TScrollable._BackGroundH]
;        stdcall DestroyImage, [esi+TScrollable._BackGroundV]
;
;; Create new
;
;        mov     ecx, [esi+TScrollable._width]
;        mov     edx, [esi+TScrollable._height]
;        sub     ecx, [GUI.scrollWidth]
;
;        stdcall CreateImage, ecx, [GUI.scrollWidth]
;        mov     [esi+TScrollable._BackGroundH], eax
;
;        stdcall CreateImage, [GUI.scrollWidth], edx
;        mov     [esi+TScrollable._BackGroundV], eax

        exec    esi, TScrollable:DrawScrollbars

.finish:
        popad
        return
endp
................................................................................
        mov     ebx, [esi+TWindow._canvas]
        test    ebx, ebx
        jz      .finish

        xor     eax, eax
        mov     ecx, [esi+TScrollable._width]
        mov     edx, [esi+TScrollable._height]

; save the background

        sub     ecx, [GUI.scrollWidth]
        stdcall CopyImageRect, [esi+TScrollable._BackGroundV], eax, eax, ebx, ecx, eax, [GUI.scrollWidth], edx

        sub     edx, [GUI.scrollWidth]
        stdcall CopyImageRect, [esi+TScrollable._BackGroundH], eax, eax, ebx, eax, edx, ecx, [GUI.scrollWidth]

................................................................................

; draw the slider X

        lea     eax, [esi+TScrollable._scrX]
        stdcall _SliderPixels2, eax, [.rectX.width]

        mov     edi, [esi+TScrollable._scrX.state]

        mov     ecx, [.rectX.width]
        sub     ecx, edx
        cmp     eax, ecx
        cmovg   eax, ecx

        mov     ecx, [esi+TScrollable._scrX.pos]
        cmp     ecx, [esi+TScrollable._scrX.max]
        cmovg   ecx, [GUI.clScrollSliderOvf+4*edi]
        cmovle  ecx, [GUI.clScrollSlider+4*edi]

        stdcall BlendSolidRect, ebx, eax, [.rectX.y], edx, [.rectX.height], ecx

        add     eax, edx
        stdcall BlendTriangle, ebx, eax, [.rectX.y], [GUI.scrollWidth], trtLower or trtLeft, ecx

; draw the slider Y

        lea     eax, [esi+TScrollable._scrY]
        stdcall _SliderPixels2, eax, [.rectY.height]

        mov     edi, [esi+TScrollable._scrY.state]

        OutputValue "Length Y:", [.rectY.height], 10, -1
        OutputValue "Pos Y:", eax, 10, -1
        OutputValue "Page Y:", edx, 10, -1

        mov     ecx, [.rectY.height]
        sub     ecx, edx
        cmp     eax, ecx
        cmovg   eax, ecx

        mov     ecx, [esi+TScrollable._scrY.pos]
        cmp     ecx, [esi+TScrollable._scrY.max]
        cmovg   ecx, [GUI.clScrollSliderOvf+4*edi]
        cmovle  ecx, [GUI.clScrollSlider+4*edi]

        stdcall BlendSolidRect, ebx, [.rectY.x], eax, [.rectY.width], edx, ecx

        add     eax, edx
        stdcall BlendTriangle, ebx, [.rectY.x], eax, [GUI.scrollWidth], trtUpper or trtRight, ecx

        mov     ecx, [.rectX.x]
        mov     edx, [.rectX.y]
        add     [.rectX.width], ecx
        add     [.rectX.height], edx

        mov     ecx, [.rectY.x]
................................................................................

        mov     ebx, eax
        shl     eax, 4
        lea     eax, [esi+TScrollable._scrX + eax]
        stdcall _SliderPixels2, eax, [esi+TScrollable._width + 4*ebx]
        mov     edi, [.x + 4*ebx]

        mov     ecx, [esi+TScrollable._width + 4*ebx]   ; if pos is > max
        sub     ecx, edx
        cmp     eax, ecx
        cmovg   eax, ecx

        sub     edi, eax
        jl      .before

        cmp     edi, edx
        jg      .after

; inside the slider - capture the mouse.
................................................................................
        return

.zero:
        xor     eax, eax
        jmp     .ok
endp



method TScrollable.EventScroll
begin
        pushad

        mov     esi, [.self]

        cmp     [.direction], scrollX
        je      .horiz_scroll

        cmp     [.command], scWheelUp
        je      .scrollupy

        cmp     [.command], scWheelDn
        je      .scrolldny

        cmp     [.command], scTrack
        jne     .finish

        set     esi, TScrollable:PosY, [.value]

.finish:
        popad
        return

.scrollupy:
        get     eax, esi, TScrollable:PosY
        dec     eax
        jns     @f
        xor     eax, eax
@@:
        set     esi, TScrollable:PosY, eax
        jmp     .finish


.scrolldny:
        get     ecx, esi, TScrollable:MaxY
        get     eax, esi, TScrollable:PosY

        inc     eax
        cmp     eax, ecx
        jle     @f
        dec     eax
@@:
        set     [.self], TScrollable:PosY, eax
        jmp     .finish


.horiz_scroll:
        cmp     [.command], scWheelUp
        je      .scrollupx

        cmp     [.command], scWheelDn
        je      .scrolldnx

        cmp     [.command], scTrack
        jne     .finish

        set     esi, TScrollable:PosX, [.value]
        jmp     .finish


.scrollupx:
        get     eax, esi, TScrollable:PosX
        dec     eax
        jns     @f
        xor     eax, eax
@@:
        set     esi, TScrollable:PosX, eax
        jmp     .finish


.scrolldnx:
        get     eax, esi, TScrollable:PosX
        get     ecx, esi, TScrollable:MaxX
        cmp     eax, ecx
        jg      @f
        inc     eax
@@:
        set     [.self], TScrollable:PosX, eax
        jmp     .finish
endp



endmodule



Changes to freshlib/gui/TTreeView.asm.

49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
...
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
...
329
330
331
332
333
334
335





336
337
338
339
340
341
342
...
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
...
396
397
398
399
400
401
402








403
404
405
406
407
408
409
...
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
...
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
...
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
...
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
...
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
...
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
...
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
  .shift = 5

ends




object TTreeView, TScrollWindow

  ._items dd ?    ; TArray with TTreeViewItem elements.
  ._index dd ?    ; TArray with dword index to the displayable items of ._items array.

  ._focused    dd ?

  ._line_height dd ?
................................................................................
        pushad

        mov     esi, [.self]
        mov     ecx, [esi+TWindow._width]
        mov     edx, [esi+TWindow._height]
        mov     edi, [GUI.boxBorderWidth]

        mov     eax, ecx
        mov     ebx, edx

        sub     eax, [GUI.scrollWidth]          ; width - scrollWidth
        sub     ebx, [GUI.scrollWidth]          ; height - scrollWidth

        sub     eax, edi                        ; width - boxBorderWidth
        sub     ebx, edi                        ; height - boxBorderWidth

        shl     edi, 1

        sub     edx, edi                        ; total client height - borders.
        js      .finish

        sub     ecx, edi                        ; total client width
        js      .finish

        set     [esi+TTreeView.YScroller], TScrollbar:x, eax
        set     [esi+TTreeView.YScroller], TScrollbar:y, [GUI.boxBorderWidth]
        set     [esi+TTreeView.YScroller], TScrollbar:height, edx

        set     [esi+TTreeView.XScroller], TScrollbar:x, [GUI.boxBorderWidth]
        set     [esi+TTreeView.XScroller], TScrollbar:y, ebx
        set     [esi+TTreeView.XScroller], TScrollbar:width, ecx
        set     [esi+TTreeView.XScroller], TScrollbar:Page, eax

        mov     ecx, [esi+TTreeView._max_width]
        sub     ecx, eax
        jns     @f
        xor     ecx, ecx
@@:
        cmp     ecx, [esi+TTreeView._start_x]
        jge     .set_max_x

        set     esi, TTreeView:StartX, ecx

.set_max_x:
        set     [esi+TTreeView.XScroller], TScrollbar:Max, ecx


        mov     ecx, [esi+TTreeView._line_height]
        mov     eax, edx
        cdq

        div     ecx
        test    edx, edx
        jz      @f
        inc     eax
@@:
        set     [esi+TTreeView.YScroller], TScrollbar:Page, eax

        mov     ebx, [esi+TTreeView._index]
        test    ebx, ebx
        jz      .finish

        mov     ebx, [ebx+TArray.count]
        sub     ebx, eax
        inc     ebx
        jns     @f
        xor     ebx, ebx
@@:
        cmp     ebx, [esi+TTreeView._start_y]
        jge     .set_start_y

        set     esi, TTreeView:StartY, ebx

.set_start_y:
        set     [esi+TTreeView.YScroller], TScrollbar:Max, ebx

.finish:
        popad
        return
endp


................................................................................


method TTreeView.Paint
.bounds TBounds
.end_item dd ?
begin
        pushad






        mov     esi, [.self]
        get     ebx, esi, TWindow:Canvas
        test    ebx, ebx
        jz      .finish

        xor     eax, eax
................................................................................
        mov     eax, [esi+TTreeView._items]
        mov     ebx, [eax+TArray.count]
        shl     ebx, TTreeViewItem.shift
        lea     ebx, [eax+TArray.array+ebx]
        mov     [.end_item], ebx

        mov     edi, [esi+TTreeView._index]
        mov     ecx, [esi+TTreeView._start_y]
        mov     edx, [esi+TTreeView._margin_top]

.loop:
        cmp     ecx, [edi+TArray.count]
        jae     .end_paint

        mov     eax, [edi+TArray.array + 4*ecx]
................................................................................
        mov     ecx, [GUI.tvBorder]
        or      ecx, bxNoFill
        stdcall [DrawBox], [esi+TTreeView._canvas], eax, [GUI.clTreeViewBack], ecx, [GUI.boxBorderWidth]


.finish:
        inherited









        popad
        return
endp


proc TTreeView.__PaintOneItem, .pTreeView, .pItem, .pNextItem, .hsize, .vsize, .y, .focused
................................................................................
        mov     esi, [.pItem]
        mov     edi, [.pTreeView]

        mov     ecx, [esi+TTreeViewItem.level]
        imul    ecx, [.hsize]

        add     ecx, [edi+TTreeView._margin_left] ; left margin.
        sub     ecx, [edi+TTreeView._start_x]     ; left offset.

        mov     eax, [GUI.clTreeViewText]
        mov     ebx, [GUI.clTreeViewBack]

        test    [esi+TTreeViewItem.state], tvisSelected
        jz      @f
        mov     eax, [GUI.clTreeSelectedTxt]
................................................................................
        return

.up:
        mov     edx, 1
        jmp     .moveup

.pgup:
        get     edx, [esi+TTreeView.YScroller], TScrollbar:Page
        dec     edx


.moveup:
        mov     ebx, [esi+TTreeView._focused]

        test    [.kbdState], maskShift
................................................................................
        sub     ebx, edx
        jns     @f

        xor     ebx, ebx
@@:
        set     esi, TTreeView:FocusedItem, ebx

        cmp     ebx, [esi+TTreeView._start_y]
        jae     .refresh

        set     esi, TTreeView:StartY, ebx
        jmp     .finish

.refresh:
        exec    esi, TTreeView:Refresh

.finish:
        popad
        return


.down:
        mov     edx, 1
        jmp     .move_down

.pgdn:
        get     edx, [esi+TTreeView.YScroller], TScrollbar:Page
        dec     edx


.move_down:
        mov     edi, [esi+TTreeView._index]
        mov     ebx, [esi+TTreeView._focused]

................................................................................
        jnz     .sel_dn_ok

        exec    esi, TTreeView:ClearSelection, not tvisSelected

.sel_dn_ok:
        set     esi, TTreeView:FocusedItem, ebx

        get     ecx, [esi+TTreeView.YScroller], TScrollbar:Page

        sub     ecx, 2
        sub     ebx, ecx

        cmp     ebx, [esi+TTreeView._start_y]
        jle     .refresh

        set     esi, TTreeView:StartY, ebx
        jmp     .finish

endp



method TTreeView.EventButtonPress        ;, .button, .kbdState, .x, .y
begin


        pushad

        mov     esi, [.self]

        exec    esi, TTreeView:HitTest, [.x], [.y]

        cmp     eax, tvhtNone
        je      .finish2

        cmp     eax, tvhtExpandIcon
        je      .expand_collapse

        test    [.kbdState], maskCtrl
        jnz     @f
        exec    esi, TTreeView:ClearSelection, not tvisSelected
................................................................................

        xor     [edx+TTreeViewItem.state], tvisExpanded
        exec    esi, TTreeView:__RebuildIndex

.finish:
        exec    [.self], TWindow:Refresh

.finish2:
        popad
        return
endp




................................................................................
        mov     eax, [esi+TTreeView._height]
        mov     [.maxy], eax

        mov     eax, [esi+TTreeView._items]
        mov     eax, [eax+TArray.count]

        mov     ecx, [.start_item]
        mov     edx, [esi+TTreeView._start_y]

        shl     eax, TTreeViewItem.shift
        shl     ecx, TTreeViewItem.shift
        shl     edx, TTreeViewItem.shift

        add     eax, [esi+TTreeView._items]
        add     ecx, [esi+TTreeView._items]
................................................................................
        xor     edx, edx
        mov     ecx, [esi+TTreeView._line_height]

        mov     [.index], edx

        div     ecx

        add     eax, [esi+TTreeView._start_y]
        mov     ebx, [esi+TTreeView._index]

        cmp     eax, [ebx+TArray.count]
        jae     .not_found

        mov     [.index], eax








|







 







<


|


|







|
<

<
<
<
<
<
<
<
<
<
|
|

|

|


|


<
>










|











|


|


|







 







>
>
>
>
>







 







|







 







>
>
>
>
>
>
>
>







 







|







 







|







 







|
|

|
<

|

<
<









|







 







|




|
|

|








>
>







|







 







|







 







|







 







|







49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
...
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
...
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
...
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
...
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
...
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
...
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
...
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
...
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
...
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
...
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
...
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
  .shift = 5

ends




object TTreeView, TScrollable

  ._items dd ?    ; TArray with TTreeViewItem elements.
  ._index dd ?    ; TArray with dword index to the displayable items of ._items array.

  ._focused    dd ?

  ._line_height dd ?
................................................................................
        pushad

        mov     esi, [.self]
        mov     ecx, [esi+TWindow._width]
        mov     edx, [esi+TWindow._height]
        mov     edi, [GUI.boxBorderWidth]


        mov     ebx, edx

        sub     ecx, [GUI.scrollWidth]          ; width - scrollWidth
        sub     ebx, [GUI.scrollWidth]          ; height - scrollWidth

        sub     ecx, edi                        ; width - boxBorderWidth
        sub     ebx, edi                        ; height - boxBorderWidth

        shl     edi, 1

        sub     edx, edi                        ; total client height - borders.
        js      .finish

        set     esi, TTreeView:PageX, ecx











        mov     eax, [esi+TTreeView._max_width]
        sub     eax, ecx
        jns     @f
        xor     eax, eax
@@:
        cmp     eax, [esi+TTreeView._scrX.pos]
        jge     .set_max_x

        set     esi, TTreeView:PosX, eax

.set_max_x:

        set     esi, TTreeView:MaxX, ecx

        mov     ecx, [esi+TTreeView._line_height]
        mov     eax, edx
        cdq

        div     ecx
        test    edx, edx
        jz      @f
        inc     eax
@@:
        set     esi, TTreeView:PageY, eax

        mov     ebx, [esi+TTreeView._index]
        test    ebx, ebx
        jz      .finish

        mov     ebx, [ebx+TArray.count]
        sub     ebx, eax
        inc     ebx
        jns     @f
        xor     ebx, ebx
@@:
        cmp     ebx, [esi+TTreeView._scrY.pos]
        jge     .set_start_y

        set     esi, TTreeView:PosY, ebx

.set_start_y:
        set     esi, TTreeView:MaxY, ebx

.finish:
        popad
        return
endp


................................................................................


method TTreeView.Paint
.bounds TBounds
.end_item dd ?
begin
        pushad

if defined options.DebugMode & options.DebugMode
        stdcall  GetFineTimestamp
        push     eax
end if

        mov     esi, [.self]
        get     ebx, esi, TWindow:Canvas
        test    ebx, ebx
        jz      .finish

        xor     eax, eax
................................................................................
        mov     eax, [esi+TTreeView._items]
        mov     ebx, [eax+TArray.count]
        shl     ebx, TTreeViewItem.shift
        lea     ebx, [eax+TArray.array+ebx]
        mov     [.end_item], ebx

        mov     edi, [esi+TTreeView._index]
        get     ecx, esi, TTreeView:PosY
        mov     edx, [esi+TTreeView._margin_top]

.loop:
        cmp     ecx, [edi+TArray.count]
        jae     .end_paint

        mov     eax, [edi+TArray.array + 4*ecx]
................................................................................
        mov     ecx, [GUI.tvBorder]
        or      ecx, bxNoFill
        stdcall [DrawBox], [esi+TTreeView._canvas], eax, [GUI.clTreeViewBack], ecx, [GUI.boxBorderWidth]


.finish:
        inherited

if defined options.DebugMode & options.DebugMode

        stdcall GetFineTimestamp
        sub     eax, [esp]
        OutputValue "TreeView.Paint time: ", eax, 10, -1
        add     esp, 4
end if

        popad
        return
endp


proc TTreeView.__PaintOneItem, .pTreeView, .pItem, .pNextItem, .hsize, .vsize, .y, .focused
................................................................................
        mov     esi, [.pItem]
        mov     edi, [.pTreeView]

        mov     ecx, [esi+TTreeViewItem.level]
        imul    ecx, [.hsize]

        add     ecx, [edi+TTreeView._margin_left] ; left margin.
        sub     ecx, [edi+TTreeView._scrX.pos]    ; left offset.

        mov     eax, [GUI.clTreeViewText]
        mov     ebx, [GUI.clTreeViewBack]

        test    [esi+TTreeViewItem.state], tvisSelected
        jz      @f
        mov     eax, [GUI.clTreeSelectedTxt]
................................................................................
        return

.up:
        mov     edx, 1
        jmp     .moveup

.pgup:
        get     edx, esi, TTreeView:PageY
        dec     edx


.moveup:
        mov     ebx, [esi+TTreeView._focused]

        test    [.kbdState], maskShift
................................................................................
        sub     ebx, edx
        jns     @f

        xor     ebx, ebx
@@:
        set     esi, TTreeView:FocusedItem, ebx

        cmp     ebx, [esi+TTreeView._scrY.pos]
        jae     .finish

        set     esi, TTreeView:PosY, ebx


.finish:
        exec    esi, TTreeView:Refresh


        popad
        return


.down:
        mov     edx, 1
        jmp     .move_down

.pgdn:
        get     edx, esi, TTreeView:PageY
        dec     edx


.move_down:
        mov     edi, [esi+TTreeView._index]
        mov     ebx, [esi+TTreeView._focused]

................................................................................
        jnz     .sel_dn_ok

        exec    esi, TTreeView:ClearSelection, not tvisSelected

.sel_dn_ok:
        set     esi, TTreeView:FocusedItem, ebx

        get     ecx, esi, TTreeView:PageY

        sub     ecx, 2
        sub     ebx, ecx

        cmp     ebx, [esi+TTreeView._scrY.pos]
        jle     .finish

        set     esi, TTreeView:PosY, ebx
        jmp     .finish

endp



method TTreeView.EventButtonPress        ;, .button, .kbdState, .x, .y
begin
        inherited [.button], [.kbdState], [.x], [.y]

        pushad

        mov     esi, [.self]

        exec    esi, TTreeView:HitTest, [.x], [.y]

        cmp     eax, tvhtNone
        je      .finish

        cmp     eax, tvhtExpandIcon
        je      .expand_collapse

        test    [.kbdState], maskCtrl
        jnz     @f
        exec    esi, TTreeView:ClearSelection, not tvisSelected
................................................................................

        xor     [edx+TTreeViewItem.state], tvisExpanded
        exec    esi, TTreeView:__RebuildIndex

.finish:
        exec    [.self], TWindow:Refresh

;.finish2:
        popad
        return
endp




................................................................................
        mov     eax, [esi+TTreeView._height]
        mov     [.maxy], eax

        mov     eax, [esi+TTreeView._items]
        mov     eax, [eax+TArray.count]

        mov     ecx, [.start_item]
        get     edx, esi, TTreeView:PosY

        shl     eax, TTreeViewItem.shift
        shl     ecx, TTreeViewItem.shift
        shl     edx, TTreeViewItem.shift

        add     eax, [esi+TTreeView._items]
        add     ecx, [esi+TTreeView._items]
................................................................................
        xor     edx, edx
        mov     ecx, [esi+TTreeView._line_height]

        mov     [.index], edx

        div     ecx

        add     eax, [esi+TTreeView._scrY.pos]
        mov     ebx, [esi+TTreeView._index]

        cmp     eax, [ebx+TArray.count]
        jae     .not_found

        mov     [.index], eax

Changes to freshlib/gui/themes/flat_gui.asm.

113
114
115
116
117
118
119

120
121
122
123
124
125
126
              clProgressBar,      HEX, clTurquoise,                          \
              progressBorder,     NUM, bxFlat,                               \
\
\ ; TScrollbar colors and styles
\
              clScrollBk,         HEX, <clSilver and $3fffffff, clSilver and $a0ffffff>,     \
              clScrollSlider,     HEX, <clAsbestos and $7fffffff, clTurquoise>,              \

              borderScroll,       NUM, bxNone,                                               \
              scrollWidth,        NUM, 12,                                                   \
              minSliderHeight,    NUM, 24,                                                   \
\
\ ; TLabel colors and styles
\
              clLabelBk,          HEX, $00000000,                                            \







>







113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
              clProgressBar,      HEX, clTurquoise,                          \
              progressBorder,     NUM, bxFlat,                               \
\
\ ; TScrollbar colors and styles
\
              clScrollBk,         HEX, <clSilver and $3fffffff, clSilver and $a0ffffff>,     \
              clScrollSlider,     HEX, <clAsbestos and $7fffffff, clTurquoise>,              \
              clScrollSliderOvf,  HEX, <clOrange and $3fffffff, clOrange>,                \
              borderScroll,       NUM, bxNone,                                               \
              scrollWidth,        NUM, 12,                                                   \
              minSliderHeight,    NUM, 24,                                                   \
\
\ ; TLabel colors and styles
\
              clLabelBk,          HEX, $00000000,                                            \

Changes to freshlib/system/Linux/files.asm.

221
222
223
224
225
226
227























228
229
230
231
232
233
234
        cmp     eax, -1
        jle     .error

        mov     ecx, eax
        mov     eax, sys_ftruncate
        mov     ebx, [.handle]
        int     $80























        cmp     eax,-1
        jle     .error

        clc
        pop     ebx ecx edx
        return








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







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
        cmp     eax, -1
        jle     .error

        mov     ecx, eax
        mov     eax, sys_ftruncate
        mov     ebx, [.handle]
        int     $80
        cmp     eax,-1
        jle     .error

        clc
        pop     ebx ecx edx
        return

.error:
        neg     eax
        stc
        pop     ebx ecx edx
        return
endp


body FileTruncateTo     ; , .handle, .length
begin
        push    edx ecx ebx

        mov     eax, sys_ftruncate
        mov     ecx, [.length]
        mov     ebx, [.handle]
        int     $80
        cmp     eax,-1
        jle     .error

        clc
        pop     ebx ecx edx
        return

Changes to freshlib/system/Win32/files.asm.

219
220
221
222
223
224
225

226





227








228
229

























230
231
232
233
234
235
236
endp




body FileTruncate
begin

        invoke  SetEndOfFile, [.handle]





        return








endp




























;----------------------------------------------------
; if CF = 0 - the file was deleted
; if CF = 1, eax is error code.
;----------------------------------------------------
body FileDelete







>

>
>
>
>
>

>
>
>
>
>
>
>
>


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







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
endp




body FileTruncate
begin
        push    ecx edx
        invoke  SetEndOfFile, [.handle]
        test    eax, eax
        jz      .error

        clc
        pop     edx ecx
        return

.error:
if used GetErrorString
        invoke  GetLastError
end if
        stc
        pop     ecx edx
        return
endp


body FileTruncateTo ;, .handle, .length
begin
        push    ecx edx

        invoke  SetFilePointer, [.handle], [.length], 0, fsFromBegin
        cmp     eax, -1
        je      .error

        invoke  SetEndOfFile, [.handle]
        test    eax, eax
        jz      .error

        clc
        pop     edx ecx
        return

.error:
if used GetErrorString
        invoke  GetLastError
end if
        stc
        pop     ecx edx
        return
endp


;----------------------------------------------------
; if CF = 0 - the file was deleted
; if CF = 1, eax is error code.
;----------------------------------------------------
body FileDelete

Changes to freshlib/system/files.asm.

45
46
47
48
49
50
51


52
53
54
55
56
57
58
;----------------------------------------------------
; if CF = 0, eax is the new possition in the file
; if CF = 1, eax is error code.
;----------------------------------------------------
interface FileSeek, .handle, .dist, .direction

interface FileTruncate, .handle



;----------------------------------------------------
; if CF = 0 - the file was deleted
; if CF = 1, eax is error code.
;----------------------------------------------------
interface FileDelete, .filename








>
>







45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
;----------------------------------------------------
; if CF = 0, eax is the new possition in the file
; if CF = 1, eax is error code.
;----------------------------------------------------
interface FileSeek, .handle, .dist, .direction

interface FileTruncate, .handle

interface FileTruncateTo, .handle, .length

;----------------------------------------------------
; if CF = 0 - the file was deleted
; if CF = 1, eax is error code.
;----------------------------------------------------
interface FileDelete, .filename

Changes to freshlib/system/network.asm.

125
126
127
128
129
130
131



132
133
134
135
136
137
138
        mov     ecx, [.Size]
        jecxz   .finish_ok

.loop:
        stdcall SocketSend, [.hSocket], esi, ecx, 0
        jc      .finish_err




;        OutputValue "Send bytes:", eax, 10, -1

        add     esi, eax
        sub     ecx, eax
        jnz     .loop

.finish_ok:







>
>
>







125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
        mov     ecx, [.Size]
        jecxz   .finish_ok

.loop:
        stdcall SocketSend, [.hSocket], esi, ecx, 0
        jc      .finish_err

        test    eax, eax
        jz      .finish_err

;        OutputValue "Send bytes:", eax, 10, -1

        add     esi, eax
        sub     ecx, eax
        jnz     .loop

.finish_ok:

Changes to freshlib/test_code0/TestTV.fpr.

cannot compute difference between binary files