2008-07-16 06:55:19 +02:00
|
|
|
diff16 'tp-files.asm',0,$
|
|
|
|
|
2006-10-11 22:40:53 +02:00
|
|
|
;-----------------------------------------------------------------------------
|
2007-09-01 23:38:00 +02:00
|
|
|
proc save_file ;//////////////////////////////////////////////////////////////
|
2006-10-11 22:40:53 +02:00
|
|
|
;-----------------------------------------------------------------------------
|
|
|
|
mov esi,tb_opensave.text
|
|
|
|
mov edi,f_info.path
|
|
|
|
movzx ecx,[tb_opensave.length]
|
|
|
|
mov [f_info.length],ecx
|
|
|
|
cld
|
|
|
|
rep movsb
|
|
|
|
mov byte[edi],0
|
|
|
|
|
2007-01-28 00:36:07 +01:00
|
|
|
mov esi,[cur_editor.Lines]
|
2007-01-18 22:14:15 +01:00
|
|
|
|
|
|
|
xor ebx,ebx
|
|
|
|
mov ecx,[cur_editor.Lines.Count]
|
|
|
|
@@: call get_real_length
|
|
|
|
add ebx,eax
|
2008-12-29 20:08:59 +01:00
|
|
|
mov eax,[esi+EDITOR_LINE_DATA.Size]
|
|
|
|
lea esi,[esi+eax+sizeof.EDITOR_LINE_DATA]
|
2007-01-18 22:14:15 +01:00
|
|
|
loop @b
|
|
|
|
mov eax,[cur_editor.Lines.Count]
|
|
|
|
shl eax,1
|
|
|
|
lea eax,[eax+ebx+1024]
|
2008-07-16 06:55:19 +02:00
|
|
|
stdcall mem.Alloc,eax
|
2007-01-18 22:14:15 +01:00
|
|
|
push eax
|
|
|
|
mov esi,[cur_editor.Lines]
|
2007-01-28 00:36:07 +01:00
|
|
|
mov edi,eax
|
2006-10-11 22:40:53 +02:00
|
|
|
|
|
|
|
.new_string:
|
|
|
|
call save_string
|
2008-12-29 20:08:59 +01:00
|
|
|
cmp dword[esi+EDITOR_LINE_DATA.Size],0
|
2006-10-11 22:40:53 +02:00
|
|
|
jne .new_string
|
2007-01-18 22:14:15 +01:00
|
|
|
pop eax
|
2007-01-28 00:36:07 +01:00
|
|
|
sub edi,eax
|
|
|
|
add edi,-2 ; minus last CRLF
|
2006-10-11 22:40:53 +02:00
|
|
|
|
|
|
|
.systree_save:
|
|
|
|
mov [f_info70+0],2
|
|
|
|
mov [f_info70+12],edi
|
2007-01-28 00:36:07 +01:00
|
|
|
mov [f_info70+16],eax
|
2006-10-11 22:40:53 +02:00
|
|
|
mov byte[f_info70+20],0
|
|
|
|
mov [f_info70+21],f_info.path
|
|
|
|
mcall 70,f_info70
|
|
|
|
|
|
|
|
call set_status_fs_error
|
|
|
|
|
|
|
|
or eax,eax
|
|
|
|
jnz .exit.2
|
|
|
|
|
|
|
|
.exit:
|
2008-07-18 06:52:49 +02:00
|
|
|
mov ebp,cur_editor
|
|
|
|
call update_tab_filename
|
2007-01-28 00:36:07 +01:00
|
|
|
mov [cur_editor.Modified],0
|
2006-10-11 22:40:53 +02:00
|
|
|
clc
|
|
|
|
ret
|
|
|
|
|
|
|
|
.exit.2:
|
|
|
|
stc
|
|
|
|
ret
|
2007-09-01 23:38:00 +02:00
|
|
|
endp
|
2006-10-11 22:40:53 +02:00
|
|
|
|
|
|
|
;-----------------------------------------------------------------------------
|
2007-09-01 23:38:00 +02:00
|
|
|
proc save_string ;////////////////////////////////////////////////////////////
|
2006-10-11 22:40:53 +02:00
|
|
|
;-----------------------------------------------------------------------------
|
2008-12-29 20:08:59 +01:00
|
|
|
mov ecx,[esi+EDITOR_LINE_DATA.Size]
|
|
|
|
test [esi+EDITOR_LINE_DATA.Flags],EDITOR_LINE_FLAG_MOFIFIED
|
2006-10-11 22:40:53 +02:00
|
|
|
jz @f
|
2008-12-29 20:08:59 +01:00
|
|
|
or [esi+EDITOR_LINE_DATA.Flags],EDITOR_LINE_FLAG_SAVED
|
|
|
|
@@: add esi,sizeof.EDITOR_LINE_DATA
|
2006-10-11 22:40:53 +02:00
|
|
|
|
|
|
|
@@: cmp byte[esi+ecx-1],' '
|
|
|
|
jne @f
|
|
|
|
loop @b
|
|
|
|
@@: jecxz .endcopy
|
|
|
|
xor edx,edx
|
|
|
|
mov ebx,edx
|
|
|
|
mov ah,dl
|
|
|
|
|
|
|
|
.next_char:
|
|
|
|
mov al,[esi+ebx]
|
|
|
|
inc ebx
|
2008-12-29 20:08:59 +01:00
|
|
|
test [optim_save],1
|
2006-10-11 22:40:53 +02:00
|
|
|
jz .put
|
|
|
|
test ah,00000001b
|
|
|
|
jnz .char
|
|
|
|
cmp al,'"'
|
|
|
|
jne @f
|
|
|
|
xor ah,00000100b
|
|
|
|
jmp .char
|
|
|
|
@@: cmp al,"'"
|
|
|
|
jne @f
|
|
|
|
xor ah,00000010b
|
|
|
|
jmp .char
|
|
|
|
@@: test ah,00000110b
|
|
|
|
jnz .char
|
|
|
|
cmp al,';'
|
|
|
|
jne @f
|
|
|
|
test ah,00000001b
|
|
|
|
jnz .char
|
|
|
|
xor ah,00000001b
|
|
|
|
jmp .char
|
|
|
|
@@: cmp al,' '
|
|
|
|
jne .char
|
|
|
|
inc edx
|
|
|
|
test ebx,ATABW-1
|
|
|
|
jnz @f
|
|
|
|
dec edx
|
|
|
|
jle .put
|
|
|
|
mov al,9
|
|
|
|
xor edx,edx
|
|
|
|
jmp .put
|
|
|
|
.char:
|
|
|
|
or edx,edx
|
|
|
|
jz .put
|
|
|
|
push ecx eax
|
|
|
|
mov ecx,edx
|
|
|
|
mov al,' '
|
|
|
|
rep stosb
|
|
|
|
pop eax ecx
|
|
|
|
xor edx,edx
|
|
|
|
.put:
|
|
|
|
stosb
|
|
|
|
@@: loop .next_char
|
|
|
|
|
|
|
|
.endcopy:
|
|
|
|
mov eax,0x0A0D
|
|
|
|
stosw
|
2008-12-29 20:08:59 +01:00
|
|
|
add esi,[esi-sizeof.EDITOR_LINE_DATA+EDITOR_LINE_DATA.Size]
|
2006-10-11 22:40:53 +02:00
|
|
|
ret
|
2007-09-01 23:38:00 +02:00
|
|
|
endp
|
2006-10-11 22:40:53 +02:00
|
|
|
|
2007-09-01 23:38:00 +02:00
|
|
|
proc set_status_fs_error
|
2006-10-11 22:40:53 +02:00
|
|
|
push eax
|
|
|
|
mov esi,s_fs_error
|
|
|
|
@@: dec eax
|
|
|
|
js @f
|
|
|
|
movzx ecx,byte[esi]
|
|
|
|
lea esi,[esi+ecx+1]
|
|
|
|
jmp @b
|
|
|
|
@@: inc esi
|
|
|
|
mov [s_status],esi
|
|
|
|
pop eax
|
2007-01-03 19:22:05 +01:00
|
|
|
call draw_statusbar
|
2006-10-11 22:40:53 +02:00
|
|
|
ret
|
2007-09-01 23:38:00 +02:00
|
|
|
endp
|
2006-10-11 22:40:53 +02:00
|
|
|
|
|
|
|
;-----------------------------------------------------------------------------
|
2007-09-01 23:38:00 +02:00
|
|
|
proc load_file ;//////////////////////////////////////////////////////////////
|
2006-10-11 22:40:53 +02:00
|
|
|
;-----------------------------------------------------------------------------
|
2007-02-08 01:34:56 +01:00
|
|
|
cmp [tb_opensave.length],0
|
2007-01-18 22:14:15 +01:00
|
|
|
jne @f
|
|
|
|
stc
|
|
|
|
ret
|
|
|
|
|
|
|
|
@@: mov esi,tb_opensave.text
|
2007-01-03 19:22:05 +01:00
|
|
|
mov edi,f_info.path
|
|
|
|
movzx ecx,[tb_opensave.length]
|
|
|
|
mov [f_info.length],ecx
|
|
|
|
cld
|
|
|
|
rep movsb
|
|
|
|
mov byte[edi],0
|
2006-10-11 22:40:53 +02:00
|
|
|
|
2007-01-03 19:22:05 +01:00
|
|
|
xor eax,eax
|
|
|
|
mov [f_info70+0],5
|
|
|
|
mov [f_info70+4],eax
|
|
|
|
mov [f_info70+8],eax
|
|
|
|
mov [f_info70+12],eax
|
|
|
|
mov [f_info70+16],file_info
|
|
|
|
mov byte[f_info70+20],al
|
2006-10-11 22:40:53 +02:00
|
|
|
mov [f_info70+21],f_info.path
|
|
|
|
mcall 70,f_info70
|
2007-01-03 19:22:05 +01:00
|
|
|
mov [f_info70+0],0
|
|
|
|
mov eax,dword[file_info.Size]
|
2008-12-29 20:08:59 +01:00
|
|
|
or eax, eax
|
|
|
|
jnz @f
|
|
|
|
mov eax, 1024
|
|
|
|
@@: mov [f_info70+12],eax
|
2008-07-16 06:55:19 +02:00
|
|
|
stdcall mem.Alloc,eax
|
2007-01-03 19:22:05 +01:00
|
|
|
mov [f_info70+16],eax
|
|
|
|
mcall 70,f_info70
|
2006-10-11 22:40:53 +02:00
|
|
|
|
|
|
|
call set_status_fs_error
|
|
|
|
|
2007-01-03 19:22:05 +01:00
|
|
|
mov esi,[f_info70+16]
|
|
|
|
|
2006-10-11 22:40:53 +02:00
|
|
|
xchg eax,ebx
|
|
|
|
test ebx,ebx
|
2007-01-03 19:22:05 +01:00
|
|
|
je .file_found
|
2006-10-11 22:40:53 +02:00
|
|
|
cmp ebx,6 ;// ATV driver fix (6 instead of 5)
|
2007-01-03 19:22:05 +01:00
|
|
|
je .file_found
|
|
|
|
|
2008-07-16 06:55:19 +02:00
|
|
|
stdcall mem.Free,[f_info70+16]
|
2006-10-11 22:40:53 +02:00
|
|
|
stc
|
|
|
|
ret
|
|
|
|
|
2007-01-03 19:22:05 +01:00
|
|
|
.file_found:
|
|
|
|
mov ecx,eax
|
2007-01-28 00:36:07 +01:00
|
|
|
cmp [tab_bar.Items.Count],1
|
|
|
|
jne @f
|
2007-07-26 23:41:48 +02:00
|
|
|
cmp [cur_editor.FilePath],0
|
|
|
|
jne @f
|
2007-01-28 00:36:07 +01:00
|
|
|
cmp [cur_editor.Modified],0
|
|
|
|
jne @f
|
|
|
|
mov ebp,cur_editor
|
|
|
|
jmp .lp1
|
2007-02-08 01:34:56 +01:00
|
|
|
@@: inc [do_not_draw]
|
|
|
|
call create_tab
|
|
|
|
dec [do_not_draw]
|
2008-07-18 06:52:49 +02:00
|
|
|
.lp1: call update_tab_filename
|
2007-01-03 19:22:05 +01:00
|
|
|
call load_from_memory
|
2008-07-16 06:55:19 +02:00
|
|
|
stdcall mem.Free,[f_info70+16]
|
2007-01-28 00:36:07 +01:00
|
|
|
|
|
|
|
xor eax,eax
|
|
|
|
mov [cur_editor.TopLeft.Y],eax
|
|
|
|
mov [cur_editor.TopLeft.X],eax
|
|
|
|
mov [cur_editor.Caret.X],eax
|
|
|
|
mov [cur_editor.Caret.Y],eax
|
|
|
|
mov [cur_editor.SelStart.X],eax
|
|
|
|
mov [cur_editor.SelStart.Y],eax
|
|
|
|
mov [cur_editor.Modified],al
|
|
|
|
|
2007-01-03 19:22:05 +01:00
|
|
|
clc
|
2006-10-11 22:40:53 +02:00
|
|
|
ret
|
2007-09-01 23:38:00 +02:00
|
|
|
endp
|
2006-10-11 22:40:53 +02:00
|
|
|
|
2007-01-03 19:22:05 +01:00
|
|
|
;-----------------------------------------------------------------------------
|
2007-09-01 23:38:00 +02:00
|
|
|
proc load_from_memory ;///////////////////////////////////////////////////////
|
2007-01-03 19:22:05 +01:00
|
|
|
;-----------------------------------------------------------------------------
|
|
|
|
; ECX = data length
|
|
|
|
; ESI = data pointer
|
|
|
|
; EBP = EDITOR*
|
|
|
|
;-----------------------------------------------------------------------------
|
|
|
|
call get_lines_in_file
|
2007-01-10 07:03:39 +01:00
|
|
|
mov [ebp+EDITOR.Lines.Count],eax
|
2007-01-18 22:14:15 +01:00
|
|
|
lea edx,[ebx+ecx]
|
2008-12-29 20:08:59 +01:00
|
|
|
imul ebx,eax,16
|
2007-01-18 22:14:15 +01:00
|
|
|
add ebx,edx
|
|
|
|
mov [ebp+EDITOR.Lines.Size],ebx
|
2008-07-16 06:55:19 +02:00
|
|
|
stdcall mem.ReAlloc,[ebp+EDITOR.Lines],ebx
|
2007-01-10 07:03:39 +01:00
|
|
|
mov [ebp+EDITOR.Lines],eax
|
2007-01-03 19:22:05 +01:00
|
|
|
|
2007-01-10 07:03:39 +01:00
|
|
|
mov [ebp+EDITOR.Columns.Count],0
|
2007-01-03 19:22:05 +01:00
|
|
|
mov edi,eax
|
|
|
|
mov edx,ecx
|
2006-10-11 22:40:53 +02:00
|
|
|
|
|
|
|
.next_line:
|
|
|
|
mov ebx,edi
|
2008-12-29 20:08:59 +01:00
|
|
|
add edi,sizeof.EDITOR_LINE_DATA
|
2006-10-11 22:40:53 +02:00
|
|
|
.next_char:
|
|
|
|
or edx,edx
|
|
|
|
jle .exit
|
|
|
|
lodsb
|
|
|
|
dec edx
|
|
|
|
cmp al,13
|
|
|
|
je .CR
|
|
|
|
cmp al,10
|
|
|
|
je .LF
|
|
|
|
cmp al,9
|
|
|
|
je .TB
|
|
|
|
cmp al,0
|
|
|
|
je .exit
|
|
|
|
stosb
|
|
|
|
jmp .next_char
|
|
|
|
|
|
|
|
.exit:
|
|
|
|
mov ecx,10
|
|
|
|
mov al,' '
|
|
|
|
rep stosb
|
2008-12-29 20:08:59 +01:00
|
|
|
lea eax,[edi-sizeof.EDITOR_LINE_DATA]
|
2006-10-11 22:40:53 +02:00
|
|
|
sub eax,ebx
|
2008-12-29 20:08:59 +01:00
|
|
|
mov [ebx+EDITOR_LINE_DATA.Size],eax
|
|
|
|
mov [ebx+eax+sizeof.EDITOR_LINE_DATA+EDITOR_LINE_DATA.Size],0
|
2006-10-11 22:40:53 +02:00
|
|
|
sub eax,10
|
|
|
|
jnz @f
|
|
|
|
inc eax
|
2007-01-28 00:36:07 +01:00
|
|
|
@@: cmp eax,[ebp+EDITOR.Columns.Count]
|
2006-10-11 22:40:53 +02:00
|
|
|
jbe @f
|
2007-01-28 00:36:07 +01:00
|
|
|
mov [ebp+EDITOR.Columns.Count],eax
|
|
|
|
@@: mov [ebp+EDITOR.Modified],0
|
2006-10-11 22:40:53 +02:00
|
|
|
ret
|
|
|
|
|
|
|
|
.CR: cmp byte[esi],10
|
|
|
|
jne .LF
|
|
|
|
lodsb
|
|
|
|
dec edx
|
|
|
|
.LF: mov ecx,10
|
|
|
|
mov al,' '
|
|
|
|
rep stosb
|
2008-12-29 20:08:59 +01:00
|
|
|
lea eax,[edi-sizeof.EDITOR_LINE_DATA]
|
2006-10-11 22:40:53 +02:00
|
|
|
sub eax,ebx
|
2008-12-29 20:08:59 +01:00
|
|
|
mov [ebx+EDITOR_LINE_DATA.Size],eax
|
2006-10-11 22:40:53 +02:00
|
|
|
add eax,-10
|
2007-01-28 00:36:07 +01:00
|
|
|
cmp eax,[ebp+EDITOR.Columns.Count]
|
2006-10-11 22:40:53 +02:00
|
|
|
jbe .next_line
|
2007-01-28 00:36:07 +01:00
|
|
|
mov [ebp+EDITOR.Columns.Count],eax
|
2006-10-11 22:40:53 +02:00
|
|
|
jmp .next_line
|
|
|
|
|
2008-12-29 20:08:59 +01:00
|
|
|
.TB: lea eax,[edi-sizeof.EDITOR_LINE_DATA]
|
2006-10-11 22:40:53 +02:00
|
|
|
sub eax,ebx
|
|
|
|
mov ecx,eax
|
|
|
|
add ecx,ATABW
|
|
|
|
and ecx,not(ATABW-1)
|
|
|
|
sub ecx,eax
|
|
|
|
mov al,' '
|
|
|
|
rep stosb
|
|
|
|
jmp .next_char
|
2007-09-01 23:38:00 +02:00
|
|
|
endp
|
2008-07-18 06:52:49 +02:00
|
|
|
|
|
|
|
;-----------------------------------------------------------------------------
|
|
|
|
proc update_tab_filename ;////////////////////////////////////////////////////
|
|
|
|
;-----------------------------------------------------------------------------
|
|
|
|
; EBP = TABITEM*
|
|
|
|
;-----------------------------------------------------------------------------
|
|
|
|
push ecx esi edi
|
|
|
|
inc [do_not_draw]
|
|
|
|
mov esi,tb_opensave.text
|
|
|
|
lea edi,[ebp+TABITEM.Editor.FilePath]
|
|
|
|
movzx ecx,[tb_opensave.length]
|
|
|
|
cld
|
|
|
|
rep movsb
|
|
|
|
mov byte[edi],0
|
|
|
|
lea edi,[ebp+TABITEM.Editor.FilePath]
|
|
|
|
movzx ecx,[tb_opensave.length]
|
|
|
|
inc ecx
|
|
|
|
@@: dec ecx
|
|
|
|
jz @f
|
|
|
|
cmp byte[edi+ecx-1],'/'
|
|
|
|
jne @b
|
|
|
|
@@: mov [ebp+TABITEM.Editor.FileName],ecx
|
|
|
|
call flush_cur_tab
|
|
|
|
call update_caption
|
|
|
|
dec [do_not_draw]
|
|
|
|
|
|
|
|
mov [cur_editor.AsmMode],0
|
|
|
|
movzx ecx,[tb_opensave.length]
|
|
|
|
mov ecx,dword[ecx+tb_opensave.text-3]
|
|
|
|
or ecx,0x202020
|
|
|
|
cmp ecx,'asm'
|
|
|
|
jne @f
|
|
|
|
inc [cur_editor.AsmMode]
|
|
|
|
jmp .exit
|
|
|
|
@@: cmp ecx,'inc'
|
|
|
|
jne .exit
|
|
|
|
inc [cur_editor.AsmMode]
|
|
|
|
|
|
|
|
.exit:
|
|
|
|
pop edi esi ecx
|
|
|
|
ret
|
|
|
|
endp
|