Subversion Repositories Kolibri OS

Rev

Rev 824 | 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:
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
;-----------------------------------------------------------------------------
67
	movzx	ecx,word[esi]
68
	test	dword[esi],0x00010000
69
	jz	@f
70
	or	dword[esi],0x00020000
71
    @@: add	esi,4
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
84
	test	[options],OPTS_OPTIMSAVE
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
130
	movzx	eax,word[esi-4]
131
	add	esi,eax;[esi-4]
132
	ret
617 mikedld 133
endp
178 heavyiron 134
 
617 mikedld 135
proc set_status_fs_error
178 heavyiron 136
	push	eax
137
	mov	esi,s_fs_error
138
    @@: dec	eax
139
	js	@f
140
	movzx	ecx,byte[esi]
141
	lea	esi,[esi+ecx+1]
142
	jmp	@b
143
    @@: inc	esi
144
	mov	[s_status],esi
145
	pop	eax
259 mikedld 146
	call	draw_statusbar
178 heavyiron 147
	ret
617 mikedld 148
endp
178 heavyiron 149
 
150
;-----------------------------------------------------------------------------
617 mikedld 151
proc load_file ;//////////////////////////////////////////////////////////////
178 heavyiron 152
;-----------------------------------------------------------------------------
327 mikedld 153
	cmp	[tb_opensave.length],0
280 mikedld 154
	jne	@f
155
	stc
156
	ret
157
 
158
    @@: mov	esi,tb_opensave.text
259 mikedld 159
	mov	edi,f_info.path
160
	movzx	ecx,[tb_opensave.length]
161
	mov	[f_info.length],ecx
162
	cld
163
	rep	movsb
164
	mov	byte[edi],0
178 heavyiron 165
 
259 mikedld 166
	xor	eax,eax
167
	mov	[f_info70+0],5
168
	mov	[f_info70+4],eax
169
	mov	[f_info70+8],eax
170
	mov	[f_info70+12],eax
171
	mov	[f_info70+16],file_info
172
	mov	byte[f_info70+20],al
178 heavyiron 173
	mov	[f_info70+21],f_info.path
174
	mcall	70,f_info70
259 mikedld 175
	mov	[f_info70+0],0
176
	mov	eax,dword[file_info.Size]
177
	mov	[f_info70+12],eax
824 mikedld 178
	stdcall mem.Alloc,eax
259 mikedld 179
	mov	[f_info70+16],eax
180
	mcall	70,f_info70
178 heavyiron 181
 
182
	call	set_status_fs_error
183
 
259 mikedld 184
	mov	esi,[f_info70+16]
185
 
178 heavyiron 186
	xchg	eax,ebx
187
	test	ebx,ebx
259 mikedld 188
	je	.file_found
178 heavyiron 189
	cmp	ebx,6		 ;// ATV driver fix (6 instead of 5)
259 mikedld 190
	je	.file_found
191
 
824 mikedld 192
	stdcall mem.Free,[f_info70+16]
178 heavyiron 193
	stc
194
	ret
195
 
259 mikedld 196
  .file_found:
197
	mov	ecx,eax
297 mikedld 198
	cmp	[tab_bar.Items.Count],1
199
	jne	@f
592 Rus 200
	cmp	[cur_editor.FilePath],0
201
	jne	@f
297 mikedld 202
	cmp	[cur_editor.Modified],0
203
	jne	@f
204
	mov	ebp,cur_editor
205
	jmp	.lp1
327 mikedld 206
    @@: inc	[do_not_draw]
207
	call	create_tab
208
	dec	[do_not_draw]
827 mikedld 209
  .lp1: call	update_tab_filename
259 mikedld 210
	call	load_from_memory
824 mikedld 211
	stdcall mem.Free,[f_info70+16]
297 mikedld 212
 
213
	xor	eax,eax
214
	mov	[cur_editor.TopLeft.Y],eax
215
	mov	[cur_editor.TopLeft.X],eax
216
	mov	[cur_editor.Caret.X],eax
217
	mov	[cur_editor.Caret.Y],eax
218
	mov	[cur_editor.SelStart.X],eax
219
	mov	[cur_editor.SelStart.Y],eax
220
	mov	[cur_editor.Modified],al
221
 
259 mikedld 222
	clc
223
	ret
617 mikedld 224
endp
178 heavyiron 225
 
259 mikedld 226
;-----------------------------------------------------------------------------
617 mikedld 227
proc load_from_memory ;///////////////////////////////////////////////////////
259 mikedld 228
;-----------------------------------------------------------------------------
229
; ECX = data length
230
; ESI = data pointer
231
; EBP = EDITOR*
232
;-----------------------------------------------------------------------------
233
	call	get_lines_in_file
267 mikedld 234
	mov	[ebp+EDITOR.Lines.Count],eax
280 mikedld 235
	lea	edx,[ebx+ecx]
259 mikedld 236
	imul	ebx,eax,14
280 mikedld 237
	add	ebx,edx
238
	mov	[ebp+EDITOR.Lines.Size],ebx
824 mikedld 239
	stdcall mem.ReAlloc,[ebp+EDITOR.Lines],ebx
267 mikedld 240
	mov	[ebp+EDITOR.Lines],eax
178 heavyiron 241
 
267 mikedld 242
	mov	[ebp+EDITOR.Columns.Count],0
259 mikedld 243
	mov	edi,eax
244
	mov	edx,ecx
178 heavyiron 245
 
246
  .next_line:
247
	mov	ebx,edi
248
	add	edi,4
249
  .next_char:
250
	or	edx,edx
251
	jle	.exit
252
	lodsb
253
	dec	edx
254
	cmp	al,13
255
	je	.CR
256
	cmp	al,10
257
	je	.LF
258
	cmp	al,9
259
	je	.TB
260
	cmp	al,0
261
	je	.exit
262
	stosb
263
	jmp	.next_char
264
 
265
  .exit:
266
	mov	ecx,10
267
	mov	al,' '
268
	rep	stosb
269
	lea	eax,[edi-4]
270
	sub	eax,ebx
271
	mov	[ebx],eax
272
	mov	dword[ebx+eax+4],0
273
	sub	eax,10
274
	jnz	@f
275
	inc	eax
297 mikedld 276
    @@: cmp	eax,[ebp+EDITOR.Columns.Count]
178 heavyiron 277
	jbe	@f
297 mikedld 278
	mov	[ebp+EDITOR.Columns.Count],eax
279
    @@: mov	[ebp+EDITOR.Modified],0
178 heavyiron 280
	ret
281
 
282
  .CR:	cmp	byte[esi],10
283
	jne	.LF
284
	lodsb
285
	dec	edx
286
  .LF:	mov	ecx,10
287
	mov	al,' '
288
	rep	stosb
289
	lea	eax,[edi-4]
290
	sub	eax,ebx
291
	mov	[ebx],eax
292
	add	eax,-10
297 mikedld 293
	cmp	eax,[ebp+EDITOR.Columns.Count]
178 heavyiron 294
	jbe	.next_line
297 mikedld 295
	mov	[ebp+EDITOR.Columns.Count],eax
178 heavyiron 296
	jmp	.next_line
297
 
298
  .TB:	lea	eax,[edi-4]
299
	sub	eax,ebx
300
	mov	ecx,eax
301
	add	ecx,ATABW
302
	and	ecx,not(ATABW-1)
303
	sub	ecx,eax
304
	mov	al,' '
305
	rep	stosb
306
	jmp	.next_char
617 mikedld 307
endp
827 mikedld 308
 
309
;-----------------------------------------------------------------------------
310
proc update_tab_filename ;////////////////////////////////////////////////////
311
;-----------------------------------------------------------------------------
312
; EBP = TABITEM*
313
;-----------------------------------------------------------------------------
314
	push	ecx esi edi
315
	inc	[do_not_draw]
316
	mov	esi,tb_opensave.text
317
	lea	edi,[ebp+TABITEM.Editor.FilePath]
318
	movzx	ecx,[tb_opensave.length]
319
	cld
320
	rep	movsb
321
	mov	byte[edi],0
322
	lea	edi,[ebp+TABITEM.Editor.FilePath]
323
	movzx	ecx,[tb_opensave.length]
324
	inc	ecx
325
    @@: dec	ecx
326
	jz	@f
327
	cmp	byte[edi+ecx-1],'/'
328
	jne	@b
329
    @@: mov	[ebp+TABITEM.Editor.FileName],ecx
330
	call	flush_cur_tab
331
	call	update_caption
332
	dec	[do_not_draw]
333
 
334
	mov	[cur_editor.AsmMode],0
335
	movzx	ecx,[tb_opensave.length]
336
	mov	ecx,dword[ecx+tb_opensave.text-3]
337
	or	ecx,0x202020
338
	cmp	ecx,'asm'
339
	jne	@f
340
	inc	[cur_editor.AsmMode]
341
	jmp	.exit
342
    @@: cmp	ecx,'inc'
343
	jne	.exit
344
	inc	[cur_editor.AsmMode]
345
 
346
  .exit:
347
	pop	edi esi ecx
348
	ret
349
endp