Subversion Repositories Kolibri OS

Rev

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