Rev 827 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
824 | mikedld | 1 | diff16 'tp-files.asm',0,$ |
2 | |||
178 | heavyiron | 3 | ;----------------------------------------------------------------------------- |
617 | mikedld | 4 | proc save_file ;////////////////////////////////////////////////////////////// |
178 | heavyiron | 5 | ;----------------------------------------------------------------------------- |
6 | mov esi,tb_opensave.text |
||
7 | mov edi,f_info.path |
||
8 | movzx ecx,[tb_opensave.length] |
||
9 | mov [f_info.length],ecx |
||
10 | cld |
||
11 | rep movsb |
||
12 | mov byte[edi],0 |
||
13 | |||
297 | mikedld | 14 | mov esi,[cur_editor.Lines] |
178 | heavyiron | 15 | |
280 | mikedld | 16 | xor ebx,ebx |
17 | mov ecx,[cur_editor.Lines.Count] |
||
18 | @@: call get_real_length |
||
19 | add ebx,eax |
||
987 | mikedld | 20 | mov eax,[esi+EDITOR_LINE_DATA.Size] |
21 | lea esi,[esi+eax+sizeof.EDITOR_LINE_DATA] |
||
280 | mikedld | 22 | loop @b |
23 | mov eax,[cur_editor.Lines.Count] |
||
24 | shl eax,1 |
||
25 | lea eax,[eax+ebx+1024] |
||
824 | mikedld | 26 | stdcall mem.Alloc,eax |
280 | mikedld | 27 | push eax |
28 | mov esi,[cur_editor.Lines] |
||
297 | mikedld | 29 | mov edi,eax |
280 | mikedld | 30 | |
178 | heavyiron | 31 | .new_string: |
32 | call save_string |
||
987 | mikedld | 33 | cmp dword[esi+EDITOR_LINE_DATA.Size],0 |
178 | heavyiron | 34 | jne .new_string |
280 | mikedld | 35 | pop eax |
297 | mikedld | 36 | sub edi,eax |
37 | add edi,-2 ; minus last CRLF |
||
178 | heavyiron | 38 | |
39 | .systree_save: |
||
40 | mov [f_info70+0],2 |
||
41 | mov [f_info70+12],edi |
||
297 | mikedld | 42 | mov [f_info70+16],eax |
178 | heavyiron | 43 | mov byte[f_info70+20],0 |
44 | mov [f_info70+21],f_info.path |
||
45 | mcall 70,f_info70 |
||
46 | |||
47 | call set_status_fs_error |
||
48 | |||
49 | or eax,eax |
||
50 | jnz .exit.2 |
||
51 | |||
52 | .exit: |
||
827 | mikedld | 53 | mov ebp,cur_editor |
54 | call update_tab_filename |
||
297 | mikedld | 55 | mov [cur_editor.Modified],0 |
178 | heavyiron | 56 | clc |
57 | ret |
||
58 | |||
59 | .exit.2: |
||
60 | stc |
||
61 | ret |
||
617 | mikedld | 62 | endp |
178 | heavyiron | 63 | |
64 | ;----------------------------------------------------------------------------- |
||
617 | mikedld | 65 | proc save_string ;//////////////////////////////////////////////////////////// |
178 | heavyiron | 66 | ;----------------------------------------------------------------------------- |
987 | mikedld | 67 | mov ecx,[esi+EDITOR_LINE_DATA.Size] |
68 | test [esi+EDITOR_LINE_DATA.Flags],EDITOR_LINE_FLAG_MOFIFIED |
||
178 | heavyiron | 69 | jz @f |
987 | mikedld | 70 | or [esi+EDITOR_LINE_DATA.Flags],EDITOR_LINE_FLAG_SAVED |
71 | @@: add esi,sizeof.EDITOR_LINE_DATA |
||
178 | heavyiron | 72 | |
73 | @@: cmp byte[esi+ecx-1],' ' |
||
74 | jne @f |
||
75 | loop @b |
||
76 | @@: jecxz .endcopy |
||
77 | xor edx,edx |
||
78 | mov ebx,edx |
||
79 | mov ah,dl |
||
80 | |||
81 | .next_char: |
||
82 | mov al,[esi+ebx] |
||
83 | inc ebx |
||
987 | mikedld | 84 | test [optim_save],1 |
178 | heavyiron | 85 | jz .put |
86 | test ah,00000001b |
||
87 | jnz .char |
||
88 | cmp al,'"' |
||
89 | jne @f |
||
90 | xor ah,00000100b |
||
91 | jmp .char |
||
92 | @@: cmp al,"'" |
||
93 | jne @f |
||
94 | xor ah,00000010b |
||
95 | jmp .char |
||
96 | @@: test ah,00000110b |
||
97 | jnz .char |
||
98 | cmp al,';' |
||
99 | jne @f |
||
100 | test ah,00000001b |
||
101 | jnz .char |
||
102 | xor ah,00000001b |
||
103 | jmp .char |
||
104 | @@: cmp al,' ' |
||
105 | jne .char |
||
106 | inc edx |
||
107 | test ebx,ATABW-1 |
||
108 | jnz @f |
||
109 | dec edx |
||
110 | jle .put |
||
111 | mov al,9 |
||
112 | xor edx,edx |
||
113 | jmp .put |
||
114 | .char: |
||
115 | or edx,edx |
||
116 | jz .put |
||
117 | push ecx eax |
||
118 | mov ecx,edx |
||
119 | mov al,' ' |
||
120 | rep stosb |
||
121 | pop eax ecx |
||
122 | xor edx,edx |
||
123 | .put: |
||
124 | stosb |
||
125 | @@: loop .next_char |
||
126 | |||
127 | .endcopy: |
||
128 | mov eax,0x0A0D |
||
129 | stosw |
||
987 | mikedld | 130 | add esi,[esi-sizeof.EDITOR_LINE_DATA+EDITOR_LINE_DATA.Size] |
178 | heavyiron | 131 | ret |
617 | mikedld | 132 | endp |
178 | heavyiron | 133 | |
617 | mikedld | 134 | proc set_status_fs_error |
178 | heavyiron | 135 | push eax |
136 | mov esi,s_fs_error |
||
137 | @@: dec eax |
||
138 | js @f |
||
139 | movzx ecx,byte[esi] |
||
140 | lea esi,[esi+ecx+1] |
||
141 | jmp @b |
||
142 | @@: inc esi |
||
143 | mov [s_status],esi |
||
144 | pop eax |
||
259 | mikedld | 145 | call draw_statusbar |
178 | heavyiron | 146 | ret |
617 | mikedld | 147 | endp |
178 | heavyiron | 148 | |
149 | ;----------------------------------------------------------------------------- |
||
617 | mikedld | 150 | proc load_file ;////////////////////////////////////////////////////////////// |
178 | heavyiron | 151 | ;----------------------------------------------------------------------------- |
327 | mikedld | 152 | cmp [tb_opensave.length],0 |
280 | mikedld | 153 | jne @f |
154 | stc |
||
155 | ret |
||
156 | |||
157 | @@: mov esi,tb_opensave.text |
||
259 | mikedld | 158 | mov edi,f_info.path |
159 | movzx ecx,[tb_opensave.length] |
||
160 | mov [f_info.length],ecx |
||
161 | cld |
||
162 | rep movsb |
||
163 | mov byte[edi],0 |
||
178 | heavyiron | 164 | |
259 | mikedld | 165 | xor eax,eax |
166 | mov [f_info70+0],5 |
||
167 | mov [f_info70+4],eax |
||
168 | mov [f_info70+8],eax |
||
169 | mov [f_info70+12],eax |
||
170 | mov [f_info70+16],file_info |
||
171 | mov byte[f_info70+20],al |
||
178 | heavyiron | 172 | mov [f_info70+21],f_info.path |
173 | mcall 70,f_info70 |
||
259 | mikedld | 174 | mov [f_info70+0],0 |
175 | mov eax,dword[file_info.Size] |
||
987 | mikedld | 176 | or eax, eax |
177 | jnz @f |
||
178 | mov eax, 1024 |
||
179 | @@: mov [f_info70+12],eax |
||
824 | mikedld | 180 | stdcall mem.Alloc,eax |
259 | mikedld | 181 | mov [f_info70+16],eax |
182 | mcall 70,f_info70 |
||
178 | heavyiron | 183 | |
184 | call set_status_fs_error |
||
185 | |||
259 | mikedld | 186 | mov esi,[f_info70+16] |
187 | |||
178 | heavyiron | 188 | xchg eax,ebx |
189 | test ebx,ebx |
||
259 | mikedld | 190 | je .file_found |
178 | heavyiron | 191 | cmp ebx,6 ;// ATV driver fix (6 instead of 5) |
259 | mikedld | 192 | je .file_found |
193 | |||
824 | mikedld | 194 | stdcall mem.Free,[f_info70+16] |
178 | heavyiron | 195 | stc |
196 | ret |
||
197 | |||
259 | mikedld | 198 | .file_found: |
199 | mov ecx,eax |
||
297 | mikedld | 200 | cmp [tab_bar.Items.Count],1 |
201 | jne @f |
||
592 | Rus | 202 | cmp [cur_editor.FilePath],0 |
203 | jne @f |
||
297 | mikedld | 204 | cmp [cur_editor.Modified],0 |
205 | jne @f |
||
206 | mov ebp,cur_editor |
||
207 | jmp .lp1 |
||
327 | mikedld | 208 | @@: inc [do_not_draw] |
209 | call create_tab |
||
210 | dec [do_not_draw] |
||
827 | mikedld | 211 | .lp1: call update_tab_filename |
259 | mikedld | 212 | call load_from_memory |
824 | mikedld | 213 | stdcall mem.Free,[f_info70+16] |
297 | mikedld | 214 | |
215 | xor eax,eax |
||
216 | mov [cur_editor.TopLeft.Y],eax |
||
217 | mov [cur_editor.TopLeft.X],eax |
||
218 | mov [cur_editor.Caret.X],eax |
||
219 | mov [cur_editor.Caret.Y],eax |
||
220 | mov [cur_editor.SelStart.X],eax |
||
221 | mov [cur_editor.SelStart.Y],eax |
||
222 | mov [cur_editor.Modified],al |
||
223 | |||
259 | mikedld | 224 | clc |
225 | ret |
||
617 | mikedld | 226 | endp |
178 | heavyiron | 227 | |
259 | mikedld | 228 | ;----------------------------------------------------------------------------- |
617 | mikedld | 229 | proc load_from_memory ;/////////////////////////////////////////////////////// |
259 | mikedld | 230 | ;----------------------------------------------------------------------------- |
231 | ; ECX = data length |
||
232 | ; ESI = data pointer |
||
233 | ; EBP = EDITOR* |
||
234 | ;----------------------------------------------------------------------------- |
||
235 | call get_lines_in_file |
||
267 | mikedld | 236 | mov [ebp+EDITOR.Lines.Count],eax |
280 | mikedld | 237 | lea edx,[ebx+ecx] |
987 | mikedld | 238 | imul ebx,eax,16 |
280 | mikedld | 239 | add ebx,edx |
240 | mov [ebp+EDITOR.Lines.Size],ebx |
||
824 | mikedld | 241 | stdcall mem.ReAlloc,[ebp+EDITOR.Lines],ebx |
267 | mikedld | 242 | mov [ebp+EDITOR.Lines],eax |
178 | heavyiron | 243 | |
267 | mikedld | 244 | mov [ebp+EDITOR.Columns.Count],0 |
259 | mikedld | 245 | mov edi,eax |
246 | mov edx,ecx |
||
178 | heavyiron | 247 | |
248 | .next_line: |
||
249 | mov ebx,edi |
||
987 | mikedld | 250 | add edi,sizeof.EDITOR_LINE_DATA |
178 | heavyiron | 251 | .next_char: |
252 | or edx,edx |
||
253 | jle .exit |
||
254 | lodsb |
||
255 | dec edx |
||
256 | cmp al,13 |
||
257 | je .CR |
||
258 | cmp al,10 |
||
259 | je .LF |
||
260 | cmp al,9 |
||
261 | je .TB |
||
262 | cmp al,0 |
||
263 | je .exit |
||
264 | stosb |
||
265 | jmp .next_char |
||
266 | |||
267 | .exit: |
||
268 | mov ecx,10 |
||
269 | mov al,' ' |
||
270 | rep stosb |
||
987 | mikedld | 271 | lea eax,[edi-sizeof.EDITOR_LINE_DATA] |
178 | heavyiron | 272 | sub eax,ebx |
987 | mikedld | 273 | mov [ebx+EDITOR_LINE_DATA.Size],eax |
274 | mov [ebx+eax+sizeof.EDITOR_LINE_DATA+EDITOR_LINE_DATA.Size],0 |
||
178 | heavyiron | 275 | sub eax,10 |
276 | jnz @f |
||
277 | inc eax |
||
297 | mikedld | 278 | @@: cmp eax,[ebp+EDITOR.Columns.Count] |
178 | heavyiron | 279 | jbe @f |
297 | mikedld | 280 | mov [ebp+EDITOR.Columns.Count],eax |
281 | @@: mov [ebp+EDITOR.Modified],0 |
||
178 | heavyiron | 282 | ret |
283 | |||
284 | .CR: cmp byte[esi],10 |
||
285 | jne .LF |
||
286 | lodsb |
||
287 | dec edx |
||
288 | .LF: mov ecx,10 |
||
289 | mov al,' ' |
||
290 | rep stosb |
||
987 | mikedld | 291 | lea eax,[edi-sizeof.EDITOR_LINE_DATA] |
178 | heavyiron | 292 | sub eax,ebx |
987 | mikedld | 293 | mov [ebx+EDITOR_LINE_DATA.Size],eax |
178 | heavyiron | 294 | add eax,-10 |
297 | mikedld | 295 | cmp eax,[ebp+EDITOR.Columns.Count] |
178 | heavyiron | 296 | jbe .next_line |
297 | mikedld | 297 | mov [ebp+EDITOR.Columns.Count],eax |
178 | heavyiron | 298 | jmp .next_line |
299 | |||
987 | mikedld | 300 | .TB: lea eax,[edi-sizeof.EDITOR_LINE_DATA] |
178 | heavyiron | 301 | sub eax,ebx |
302 | mov ecx,eax |
||
303 | add ecx,ATABW |
||
304 | and ecx,not(ATABW-1) |
||
305 | sub ecx,eax |
||
306 | mov al,' ' |
||
307 | rep stosb |
||
308 | jmp .next_char |
||
617 | mikedld | 309 | endp |
827 | mikedld | 310 | |
311 | ;----------------------------------------------------------------------------- |
||
312 | proc update_tab_filename ;//////////////////////////////////////////////////// |
||
313 | ;----------------------------------------------------------------------------- |
||
314 | ; EBP = TABITEM* |
||
315 | ;----------------------------------------------------------------------------- |
||
316 | push ecx esi edi |
||
317 | inc [do_not_draw] |
||
318 | mov esi,tb_opensave.text |
||
319 | lea edi,[ebp+TABITEM.Editor.FilePath] |
||
320 | movzx ecx,[tb_opensave.length] |
||
321 | cld |
||
322 | rep movsb |
||
323 | mov byte[edi],0 |
||
324 | lea edi,[ebp+TABITEM.Editor.FilePath] |
||
325 | movzx ecx,[tb_opensave.length] |
||
326 | inc ecx |
||
327 | @@: dec ecx |
||
328 | jz @f |
||
329 | cmp byte[edi+ecx-1],'/' |
||
330 | jne @b |
||
331 | @@: mov [ebp+TABITEM.Editor.FileName],ecx |
||
332 | call flush_cur_tab |
||
333 | call update_caption |
||
334 | dec [do_not_draw] |
||
335 | |||
336 | mov [cur_editor.AsmMode],0 |
||
337 | movzx ecx,[tb_opensave.length] |
||
338 | mov ecx,dword[ecx+tb_opensave.text-3] |
||
339 | or ecx,0x202020 |
||
340 | cmp ecx,'asm' |
||
341 | jne @f |
||
342 | inc [cur_editor.AsmMode] |
||
343 | jmp .exit |
||
344 | @@: cmp ecx,'inc' |
||
345 | jne .exit |
||
346 | inc [cur_editor.AsmMode] |
||
347 | |||
348 | .exit: |
||
349 | pop edi esi ecx |
||
350 | ret |
||
351 | endp |