Subversion Repositories Kolibri OS

Rev

Rev 592 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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