Subversion Repositories Kolibri OS

Rev

Rev 259 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

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