Rev 178 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 178 | Rev 259 | ||
---|---|---|---|
1 | ;----------------------------------------------------------------------------- |
1 | ;----------------------------------------------------------------------------- |
2 | func save_file ;////////////////////////////////////////////////////////////// |
2 | func save_file ;////////////////////////////////////////////////////////////// |
3 | ;----------------------------------------------------------------------------- |
3 | ;----------------------------------------------------------------------------- |
4 | 4 | ||
5 | mov esi,tb_opensave.text |
5 | mov esi,tb_opensave.text |
6 | mov edi,f_info.path |
6 | mov edi,f_info.path |
7 | movzx ecx,[tb_opensave.length] |
7 | movzx ecx,[tb_opensave.length] |
8 | mov [f_info.length],ecx |
8 | mov [f_info.length],ecx |
9 | cld |
9 | cld |
10 | rep movsb |
10 | rep movsb |
11 | mov byte[edi],0 |
11 | mov byte[edi],0 |
12 | 12 | ||
13 | mov esi,AREA_EDIT ; 0x70000 = 448 Kbytes (maximum) |
13 | mov esi,[cur_tab.Editor.Data] ;! AREA_EDIT ; 0x70000 = 448 Kbytes (maximum) |
14 | mov edi,AREA_TEMP |
14 | mov edi,0 ;!!! AREA_TEMP |
15 | 15 | ||
16 | .new_string: |
16 | .new_string: |
17 | call save_string |
17 | call save_string |
18 | cmp dword[esi],0 |
18 | cmp dword[esi],0 |
19 | jne .new_string |
19 | jne .new_string |
20 | sub edi,AREA_TEMP+2 ; minus last CRLF |
20 | sub edi,0 ;!!! AREA_TEMP+2 ; minus last CRLF |
21 | ;! mov [filelen],edi |
21 | ;! mov [filelen],edi |
22 | cmp byte[f_info.path],'/' |
22 | cmp byte[f_info.path],'/' |
23 | je .systree_save |
23 | je .systree_save |
24 | mcall 33,f_info.path,AREA_TEMP,edi,0;[filelen],0 |
24 | mcall 33,f_info.path,0,edi,0 ;!!! AREA_TEMP,edi,0;[filelen],0 |
25 | or eax,eax |
25 | or eax,eax |
26 | jz .exit |
26 | jz .exit |
27 | ; call file_not_found |
27 | ; call file_not_found |
28 | jmp .exit.2 |
28 | jmp .exit.2 |
29 | 29 | ||
30 | .systree_save: |
30 | .systree_save: |
31 | ;! mov eax,[filelen] |
31 | ;! mov eax,[filelen] |
32 | ; mov [f_info+8],edi ;! eax |
32 | ; mov [f_info+8],edi ;! eax |
33 | ; mov [f_info+0],1 |
33 | ; mov [f_info+0],1 |
34 | ; mov esi,s_fname |
34 | ; mov esi,s_fname |
35 | ; mov edi,f_info.path |
35 | ; mov edi,f_info.path |
36 | ; mov ecx,PATHL |
36 | ; mov ecx,PATHL |
37 | ; cld |
37 | ; cld |
38 | ; rep movsb |
38 | ; rep movsb |
39 | ;mcall 58,f_info |
39 | ;mcall 58,f_info |
40 | 40 | ||
41 | mov [f_info70+0],2 |
41 | mov [f_info70+0],2 |
42 | mov [f_info70+12],edi |
42 | mov [f_info70+12],edi |
43 | mov [f_info70+16],AREA_TEMP |
43 | mov [f_info70+16],0 ;!!! AREA_TEMP |
44 | mov byte[f_info70+20],0 |
44 | mov byte[f_info70+20],0 |
45 | mov [f_info70+21],f_info.path |
45 | mov [f_info70+21],f_info.path |
46 | mcall 70,f_info70 |
46 | mcall 70,f_info70 |
47 | 47 | ||
48 | call set_status_fs_error |
48 | call set_status_fs_error |
49 | 49 | ||
50 | or eax,eax |
50 | or eax,eax |
51 | jnz .exit.2 |
51 | jnz .exit.2 |
52 | 52 | ||
53 | .exit: |
53 | .exit: |
54 | mov [modified],0 |
54 | mov [cur_tab.Editor.Modified],0 ;! [modified],0 |
55 | clc |
55 | clc |
56 | ret |
56 | ret |
57 | 57 | ||
58 | .exit.2: |
58 | .exit.2: |
59 | stc |
59 | stc |
60 | ret |
60 | ret |
61 | endf |
61 | endf |
62 | 62 | ||
63 | ;----------------------------------------------------------------------------- |
63 | ;----------------------------------------------------------------------------- |
64 | func save_string ;//////////////////////////////////////////////////////////// |
64 | func save_string ;//////////////////////////////////////////////////////////// |
65 | ;----------------------------------------------------------------------------- |
65 | ;----------------------------------------------------------------------------- |
66 | movzx ecx,word[esi] |
66 | movzx ecx,word[esi] |
67 | test dword[esi],0x00010000 |
67 | test dword[esi],0x00010000 |
68 | jz @f |
68 | jz @f |
69 | or dword[esi],0x00020000 |
69 | or dword[esi],0x00020000 |
70 | @@: add esi,4 |
70 | @@: add esi,4 |
71 | ; mov ecx,eax |
71 | ; mov ecx,eax |
72 | 72 | ||
73 | @@: cmp byte[esi+ecx-1],' ' |
73 | @@: cmp byte[esi+ecx-1],' ' |
74 | jne @f |
74 | jne @f |
75 | loop @b |
75 | loop @b |
76 | @@: jecxz .endcopy |
76 | @@: jecxz .endcopy |
77 | xor edx,edx |
77 | xor edx,edx |
78 | mov ebx,edx |
78 | mov ebx,edx |
79 | mov ah,dl |
79 | mov ah,dl |
80 | 80 | ||
81 | .next_char: |
81 | .next_char: |
82 | mov al,[esi+ebx] |
82 | mov al,[esi+ebx] |
83 | inc ebx |
83 | inc ebx |
84 | ; cmp [asm_mode],0 |
84 | ; cmp [asm_mode],0 |
85 | ; je .put |
85 | ; je .put |
86 | test [options],OPTS_OPTIMSAVE |
86 | test [options],OPTS_OPTIMSAVE |
87 | jz .put |
87 | jz .put |
88 | test ah,00000001b |
88 | test ah,00000001b |
89 | jnz .char |
89 | jnz .char |
90 | cmp al,'"' |
90 | cmp al,'"' |
91 | jne @f |
91 | jne @f |
92 | xor ah,00000100b |
92 | xor ah,00000100b |
93 | jmp .char |
93 | jmp .char |
94 | @@: cmp al,"'" |
94 | @@: cmp al,"'" |
95 | jne @f |
95 | jne @f |
96 | xor ah,00000010b |
96 | xor ah,00000010b |
97 | jmp .char |
97 | jmp .char |
98 | @@: test ah,00000110b |
98 | @@: test ah,00000110b |
99 | jnz .char |
99 | jnz .char |
100 | cmp al,';' |
100 | cmp al,';' |
101 | jne @f |
101 | jne @f |
102 | test ah,00000001b |
102 | test ah,00000001b |
103 | jnz .char |
103 | jnz .char |
104 | xor ah,00000001b |
104 | xor ah,00000001b |
105 | jmp .char |
105 | jmp .char |
106 | @@: cmp al,' ' |
106 | @@: cmp al,' ' |
107 | jne .char |
107 | jne .char |
108 | inc edx |
108 | inc edx |
109 | test ebx,ATABW-1 |
109 | test ebx,ATABW-1 |
110 | jnz @f |
110 | jnz @f |
111 | dec edx |
111 | dec edx |
112 | jle .put |
112 | jle .put |
113 | mov al,9 |
113 | mov al,9 |
114 | xor edx,edx |
114 | xor edx,edx |
115 | jmp .put |
115 | jmp .put |
116 | .char: |
116 | .char: |
117 | or edx,edx |
117 | or edx,edx |
118 | jz .put |
118 | jz .put |
119 | push ecx eax |
119 | push ecx eax |
120 | mov ecx,edx |
120 | mov ecx,edx |
121 | mov al,' ' |
121 | mov al,' ' |
122 | rep stosb |
122 | rep stosb |
123 | pop eax ecx |
123 | pop eax ecx |
124 | xor edx,edx |
124 | xor edx,edx |
125 | .put: |
125 | .put: |
126 | stosb |
126 | stosb |
127 | @@: loop .next_char |
127 | @@: loop .next_char |
128 | 128 | ||
129 | .endcopy: |
129 | .endcopy: |
130 | mov eax,0x0A0D |
130 | mov eax,0x0A0D |
131 | stosw |
131 | stosw |
132 | movzx eax,word[esi-4] |
132 | movzx eax,word[esi-4] |
133 | add esi,eax;[esi-4] |
133 | add esi,eax;[esi-4] |
134 | ret |
134 | ret |
135 | endf |
135 | endf |
136 | 136 | ||
137 | func set_status_fs_error |
137 | func set_status_fs_error |
138 | push eax |
138 | push eax |
139 | mov esi,s_fs_error |
139 | mov esi,s_fs_error |
140 | @@: dec eax |
140 | @@: dec eax |
141 | js @f |
141 | js @f |
142 | movzx ecx,byte[esi] |
142 | movzx ecx,byte[esi] |
143 | lea esi,[esi+ecx+1] |
143 | lea esi,[esi+ecx+1] |
144 | jmp @b |
144 | jmp @b |
145 | @@: inc esi |
145 | @@: inc esi |
146 | mov [s_status],esi |
146 | mov [s_status],esi |
147 | pop eax |
147 | pop eax |
148 | call writepos |
148 | call draw_statusbar |
149 | ret |
149 | ret |
150 | endf |
150 | endf |
151 | 151 | ||
152 | ;----------------------------------------------------------------------------- |
152 | ;----------------------------------------------------------------------------- |
153 | func load_hd_file ;/////////////////////////////////////////////////////////// |
153 | func load_file ;////////////////////////////////////////////////////////////// |
154 | ;----------------------------------------------------------------------------- |
154 | ;----------------------------------------------------------------------------- |
155 | mov [f_info+0],0 |
155 | mov esi,tb_opensave.text |
156 | mov [f_info+8],300000/512 |
156 | mov edi,f_info.path |
157 | ; mov esi,s_fname |
157 | movzx ecx,[tb_opensave.length] |
158 | ; mov edi,f_info.path;pathfile_read |
158 | mov [f_info.length],ecx |
159 | ; mov ecx,PATHL |
- | |
160 | ; cld |
159 | cld |
161 | ; rep movsb |
160 | rep movsb |
162 | ;mcall 58,f_info ; fileinfo_read |
161 | mov byte[edi],0 |
- | 162 | ||
163 | 163 | xor eax,eax |
|
164 | mov [f_info70+0],0 |
164 | mov [f_info70+0],5 |
165 | mov [f_info70+4],0 |
165 | mov [f_info70+4],eax |
166 | mov [f_info70+8],0 |
166 | mov [f_info70+8],eax |
167 | mov [f_info70+12],300000;/512 |
167 | mov [f_info70+12],eax |
168 | mov [f_info70+16],AREA_TEMP |
168 | mov [f_info70+16],file_info |
169 | mov byte[f_info70+20],0 |
169 | mov byte[f_info70+20],al |
170 | mov [f_info70+21],f_info.path |
170 | mov [f_info70+21],f_info.path |
- | 171 | mcall 70,f_info70 |
|
- | 172 | mov [f_info70+0],0 |
|
- | 173 | mov eax,dword[file_info.Size] |
|
- | 174 | mov [f_info70+12],eax |
|
- | 175 | call mem.Alloc |
|
- | 176 | mov [f_info70+16],eax |
|
171 | mcall 70,f_info70 |
177 | mcall 70,f_info70 |
172 | 178 | ||
173 | call set_status_fs_error |
179 | call set_status_fs_error |
- | 180 | ||
- | 181 | mov esi,[f_info70+16] |
|
174 | 182 | ||
175 | xchg eax,ebx |
- | |
176 | inc eax |
183 | xchg eax,ebx |
177 | test ebx,ebx |
184 | test ebx,ebx |
178 | je load_file.file_found |
185 | je .file_found |
179 | cmp ebx,6 ;// ATV driver fix (6 instead of 5) |
186 | cmp ebx,6 ;// ATV driver fix (6 instead of 5) |
- | 187 | je .file_found |
|
180 | je load_file.file_found |
188 | |
- | 189 | mov eax,[f_info70+16] |
|
181 | ; jmp file_not_found |
190 | call mem.Free |
182 | stc |
191 | stc |
183 | ret |
- | |
184 | endf |
- | |
185 | - | ||
186 | ;----------------------------------------------------------------------------- |
- | |
187 | func load_file ;////////////////////////////////////////////////////////////// |
- | |
- | 192 | ret |
|
- | 193 | ||
- | 194 | .file_found: |
|
- | 195 | mov ecx,eax |
|
188 | ;----------------------------------------------------------------------------- |
196 | call create_tab |
- | 197 | push ecx esi edi |
|
189 | 198 | mov esi,tb_opensave.text |
|
190 | mov esi,tb_opensave.text |
199 | lea edi,[ebp+TABITEM.Editor.FilePath] |
191 | mov edi,f_info.path |
- | |
192 | movzx ecx,[tb_opensave.length] |
- | |
193 | mov [f_info.length],ecx |
200 | ;mov ecx,[f_info.length] |
194 | cld |
201 | movzx ecx,[tb_opensave.length] |
195 | rep movsb |
- | |
- | 202 | rep movsb |
|
- | 203 | mov byte[edi],0 |
|
196 | mov byte[edi],0 |
204 | lea edi,[ebp+TABITEM.Editor.FilePath] |
197 | 205 | movzx ecx,[tb_opensave.length] |
|
- | 206 | @@: cmp byte[edi+ecx-1],'/' |
|
198 | cmp byte[f_info.path],'/' |
207 | je @f |
199 | je load_hd_file |
208 | dec ecx |
200 | 209 | jmp @b |
|
201 | mcall 6,f_info.path,0,16800,AREA_TEMP ; 6 = open file |
210 | @@: mov [ebp+TABITEM.Editor.FileName],ecx |
202 | inc eax ; eax = -1 -> file not found |
211 | call flush_cur_tab |
- | 212 | pop edi esi ecx |
|
- | 213 | call load_from_memory |
|
203 | jnz .file_found |
214 | mov eax,[f_info70+16] |
204 | ; jmp file_not_found |
215 | call mem.Free |
- | 216 | clc |
|
- | 217 | ret |
|
- | 218 | endf |
|
- | 219 | ||
- | 220 | ;----------------------------------------------------------------------------- |
|
205 | stc |
221 | func load_from_memory ;/////////////////////////////////////////////////////// |
- | 222 | ;----------------------------------------------------------------------------- |
|
- | 223 | ; ECX = data length |
|
- | 224 | ; ESI = data pointer |
|
- | 225 | ; EBP = EDITOR* |
|
- | 226 | ;----------------------------------------------------------------------------- |
|
206 | ret |
227 | call get_lines_in_file |
207 | 228 | mov [ebp+EDITOR.Lines],eax |
|
208 | .file_found: |
229 | imul ebx,eax,14 |
209 | dec eax |
230 | add ebx,ecx |
- | 231 | mov eax,[ebp+EDITOR.Data] |
|
210 | mov [filesize],eax |
232 | call mem.ReAlloc |
211 | mov [lines],1 |
233 | mov [ebp+EDITOR.Data],eax |
212 | mov [columns],0 |
234 | |
213 | mov esi,AREA_TEMP |
235 | mov [ebp+EDITOR.Columns],0 |
214 | mov edi,AREA_EDIT |
236 | mov edi,eax |
215 | mov edx,eax |
237 | mov edx,ecx |
216 | 238 | ||
217 | .next_line: |
239 | .next_line: |
218 | mov ebx,edi |
240 | mov ebx,edi |
219 | add edi,4 |
241 | add edi,4 |
220 | .next_char: |
242 | .next_char: |
221 | or edx,edx |
243 | or edx,edx |
222 | jle .exit |
244 | jle .exit |
223 | lodsb |
245 | lodsb |
224 | dec edx |
246 | dec edx |
225 | cmp al,13 |
247 | cmp al,13 |
226 | je .CR |
248 | je .CR |
227 | cmp al,10 |
249 | cmp al,10 |
228 | je .LF |
250 | je .LF |
229 | cmp al,9 |
251 | cmp al,9 |
230 | je .TB |
252 | je .TB |
231 | cmp al,0 |
253 | cmp al,0 |
232 | je .exit |
254 | je .exit |
233 | stosb |
255 | stosb |
234 | jmp .next_char |
256 | jmp .next_char |
235 | 257 | ||
236 | .exit: |
258 | .exit: |
237 | mov ecx,10 |
259 | mov ecx,10 |
238 | mov al,' ' |
260 | mov al,' ' |
239 | rep stosb |
261 | rep stosb |
240 | lea eax,[edi-4] |
262 | lea eax,[edi-4] |
241 | sub eax,ebx |
263 | sub eax,ebx |
242 | mov [ebx],eax |
264 | mov [ebx],eax |
243 | mov dword[ebx+eax+4],0 |
265 | mov dword[ebx+eax+4],0 |
244 | sub eax,10 |
266 | sub eax,10 |
245 | jnz @f |
267 | jnz @f |
246 | inc eax |
268 | inc eax |
247 | @@: cmp eax,[columns] |
269 | @@: cmp eax,[ebp+EDITOR.Columns] ;! eax,[columns] |
248 | jbe @f |
270 | jbe @f |
249 | mov [columns],eax |
271 | mov [ebp+EDITOR.Columns],eax ;! [columns],eax |
250 | @@: mov [modified],0 |
272 | @@: mov [ebp+EDITOR.Modified],0 ;! [modified],0 |
251 | clc |
- | |
252 | ret |
273 | ret |
253 | 274 | ||
254 | .CR: cmp byte[esi],10 |
275 | .CR: cmp byte[esi],10 |
255 | jne .LF |
276 | jne .LF |
256 | lodsb |
277 | lodsb |
257 | dec edx |
278 | dec edx |
258 | .LF: mov ecx,10 |
279 | .LF: mov ecx,10 |
259 | mov al,' ' |
280 | mov al,' ' |
260 | rep stosb |
281 | rep stosb |
261 | lea eax,[edi-4] |
282 | lea eax,[edi-4] |
262 | sub eax,ebx |
283 | sub eax,ebx |
263 | mov [ebx],eax |
284 | mov [ebx],eax |
264 | inc [lines] |
285 | ;inc [cur_tab.Editor.Lines] ;! [lines] |
265 | add eax,-10 |
286 | add eax,-10 |
266 | cmp eax,[columns] |
287 | cmp eax,[ebp+EDITOR.Columns] ;! eax,[columns] |
267 | jbe .next_line |
288 | jbe .next_line |
268 | mov [columns],eax |
289 | mov [ebp+EDITOR.Columns],eax ;! [columns],eax |
269 | jmp .next_line |
290 | jmp .next_line |
270 | 291 | ||
271 | .TB: lea eax,[edi-4] |
292 | .TB: lea eax,[edi-4] |
272 | sub eax,ebx |
293 | sub eax,ebx |
273 | mov ecx,eax |
294 | mov ecx,eax |
274 | add ecx,ATABW |
295 | add ecx,ATABW |
275 | and ecx,not(ATABW-1) |
296 | and ecx,not(ATABW-1) |
276 | sub ecx,eax |
297 | sub ecx,eax |
277 | mov al,' ' |
298 | mov al,' ' |
278 | rep stosb |
299 | rep stosb |
279 | jmp .next_char |
300 | jmp .next_char |
280 | endf |
301 | endf |
281 | - | ||
282 | ;----------------------------------------------------------------------------- |
- | |
283 | func new_file ;/////////////////////////////////////////////////////////////// |
- | |
284 | ;----------------------------------------------------------------------------- |
- | |
285 | ; mcall 55,eax,error_beep ; beep |
- | |
286 | mov [lines],1 ; open empty document |
- | |
287 | mov [columns],1 |
- | |
288 | xor eax,eax |
- | |
289 | mov [top_line],eax |
- | |
290 | mov [pos.x],eax |
- | |
291 | mov [pos.y],eax |
- | |
292 | mov edi,AREA_EDIT+4 |
- | |
293 | mov ecx,10 |
- | |
294 | mov [edi-4],ecx |
- | |
295 | mov [edi+10],eax |
- | |
296 | mov al,' ' |
- | |
297 | cld |
- | |
298 | rep stosb |
- | |
299 | - | ||
300 | mov [f_info.length],0 |
- | |
301 | mov [modified],0 |
- | |
302 | mov [asm_mode],0 |
- | |
303 | call update_caption |
- | |
304 | call drawwindow |
- | |
305 | - | ||
306 | ret |
- | |
307 | endf |
- | |
308 | 302 |