KFar 0.62: fixes in editor: correct calculation for number of lines, memory size reduced

git-svn-id: svn://kolibrios.org@1035 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Evgeny Grechnikov (Diamond) 2009-02-14 14:59:07 +00:00
parent 32818c107f
commit 86ae39b381
2 changed files with 92 additions and 36 deletions

View File

@ -202,6 +202,8 @@ edit_file:
jz ..openerr_in_screen jz ..openerr_in_screen
mov ebx, eax mov ebx, eax
@@: @@:
mov ecx, [EditBlockSize] ; bytes rest in the current block
add edi, [EditBlockStart]
.readloop: .readloop:
mov edx, [ebp + editor_data.hPlugin] mov edx, [ebp + editor_data.hPlugin]
test edx, edx test edx, edx
@ -255,31 +257,27 @@ edit_file:
; eax = number of bytes read ; eax = number of bytes read
test eax, eax test eax, eax
jnz @f jnz @f
mov ecx, edi push edi
sub ecx, ebp sub edi, ebp
cmp ecx, [ebp + editor_data.first_block] cmp edi, [ebp + editor_data.first_block]
pop edi
jnz .readdone jnz .readdone
@@: @@:
push eax ebx push eax ebx
mov ebx, [readinfo.data] mov ebx, [readinfo.data]
.loadloop: .loadloop:
mov ecx, [EditBlockSize] test ecx, ecx
cmp eax, ecx jnz .hasplace
ja @f
mov ecx, eax
@@:
sub eax, ecx
push eax push eax
dec esi dec esi
jns .hasblock jns .hasblock
push ecx
add [ebp + editor_data.memsize], 8 add [ebp + editor_data.memsize], 8
add esi, 8 add esi, 8
mov ecx, [ebp + editor_data.memsize] mov ecx, [ebp + editor_data.memsize]
cmp ecx, 80000000h shr 12 cmp ecx, 80000000h shr 12
jb @f jb @f
.nomemory2: .nomemory2:
pop ecx eax ebx eax pop eax ebx eax
call .nomemory call .nomemory
jmp .readfailed jmp .readfailed
@@: @@:
@ -289,20 +287,20 @@ edit_file:
call xpgrealloc call xpgrealloc
test eax, eax test eax, eax
jz .nomemory2 jz .nomemory2
mov ebp, eax
add edi, eax add edi, eax
pop ecx xchg ebp, eax
.hasblock: .hasblock:
push edi
and edi, not 0xFFF
lea eax, [edi + 0x1000] lea eax, [edi + 0x1000]
push eax
sub eax, ebp sub eax, ebp
stosd ; edit_block_header.next stosd ; edit_block_header.next
sub eax, 0x2000 sub eax, 0x2000
stosd ; edit_block_header.prev stosd ; edit_block_header.prev
mov eax, [EditBlockStart] pop eax
add eax, ecx sub eax, edi
add eax, 8
stosd ; edit_block_header.limit stosd ; edit_block_header.limit
push ecx
mov ecx, [EditPlugInfo] mov ecx, [EditPlugInfo]
inc ecx inc ecx
jz @f jz @f
@ -310,49 +308,103 @@ edit_file:
@@: @@:
xor eax, eax xor eax, eax
rep stosb ; info for plugins: zeroed rep stosb ; info for plugins: zeroed
pop ecx add edi, 0x1000
push esi edi ecx mov ecx, [EditBlockSize]
pop eax
.hasplace:
push ecx
cmp eax, ecx
ja @f
mov ecx, eax
@@:
push ecx
push eax
push esi edi
mov esi, ebx mov esi, ebx
add ecx, 3 mov edx, ecx
shr ecx, 2 shr ecx, 2
rep movsd rep movsd
mov ecx, edx
and ecx, 3
rep movsb
mov ebx, esi mov ebx, esi
pop ecx edi mov ecx, edx
pop esi
; calculate number of lines in this block ; calculate number of lines in this block
mov esi, edi
xor edx, edx
test ecx, ecx test ecx, ecx
jz .4 jz .4
mov al, [esi - 1]
mov edx, esi
sub edx, [EditBlockStart]
test edx, 0xFFF
jnz .0
mov al, 0
sub edx, ebp
cmp edx, [ebp + editor_data.first_block]
jz .0
sub edx, 1000h
add edx, ebp
add edx, [edx + edit_block_header.limit]
mov al, [edx - 1]
.0:
xor edx, edx
cmp al, 13
jnz .1
mov dl, 10
.1: .1:
lodsb mov al, [esi]
add esi, 1
cmp al, 13 cmp al, 13
jz @f jz @f
cmp al, 10 cmp al, 10
jz @f jz @f
mov dl, 0 mov dl, 0
jmp .3 sub ecx, 1
jnz .1
jmp .4
@@: @@:
cmp al, dl cmp al, dl
mov dl, 0 mov dl, 0
jz .3 jz .3
inc [ebp + editor_data.numlines] add [ebp + editor_data.numlines], 1
cmp al, 10 cmp al, 10
jz .3 jz .3
mov dl, 10 mov dl, 10
.3: .3:
loop .1 sub ecx, 1
jnz .1
.4: .4:
pop esi pop esi
pop edi
pop eax pop eax
test eax, eax pop ecx
sub [esp], ecx
sub eax, ecx
pop ecx
jnz .loadloop jnz .loadloop
pop ebx eax pop ebx eax
cmp eax, 16384 cmp eax, 16384
jz .readloop jz .readloop
.readdone: .readdone:
push edi
and edi, not 0xFFF
xor eax, eax xor eax, eax
mov ecx, edi stosd ; editor_block_header.next
lea eax, [edi - 4 - 0x1000]
sub eax, ebp
stosd ; editor_block_header.prev
pop eax
sub eax, edi
add eax, 8
stosd ; editor_block_header.limit
mov ecx, [EditPlugInfo]
inc ecx
jz @f
dec ecx
@@:
xor eax, eax
rep stosb
and edi, not 0xFFF
lea ecx, [edi + 0x1000]
sub ecx, ebp sub ecx, ebp
mov edx, ecx mov edx, ecx
shr ecx, 12 shr ecx, 12
@ -363,15 +415,13 @@ edit_file:
mov [ebp + editor_data.freeblocks], edx mov [ebp + editor_data.freeblocks], edx
push edi push edi
.addfree: .addfree:
add edi, 1000h
add edx, 1000h add edx, 1000h
mov [edi], edx mov [edi], edx
add edi, 1000h
loop .addfree loop .addfree
mov [edi-1000h], eax mov [edi], eax
pop edi pop edi
.nofree: .nofree:
sub edi, 1000h
mov [edi + edit_block_header.next], eax
sub edi, ebp sub edi, ebp
mov [ebp + editor_data.last_block], edi mov [ebp + editor_data.last_block], edi
mov ecx, [EditDataSize] mov ecx, [EditDataSize]

View File

@ -7,8 +7,8 @@ memsize dd mem
dd stacktop dd stacktop
dd 0, app_path dd 0, app_path
version equ '0.61' version equ '0.62'
version_dword equ 0*10000h + 61 version_dword equ 0*10000h + 62
min_width = 54 min_width = 54
max_width = 255 max_width = 255
@ -8195,6 +8195,8 @@ aCancel db ' Cancel ',0
aCancelLength = $ - aCancel - 1 aCancelLength = $ - aCancel - 1
aCancelB db '[ Cancel ]',0 aCancelB db '[ Cancel ]',0
aCancelBLength = $ - aCancelB - 1 aCancelBLength = $ - aCancelB - 1
aCancelB2 = aCancelB
aCancelB2Length = $ - aCancelB2 - 1
aCopyCaption db 'Copy',0 aCopyCaption db 'Copy',0
aCopy db '[ Copy ]',0 aCopy db '[ Copy ]',0
aCopyLength = $ - aCopy - 1 aCopyLength = $ - aCopy - 1
@ -8272,7 +8274,9 @@ aReverseSearch db 'Reverse search',0
aStringNotFound db 'Could not find the string',0 aStringNotFound db 'Could not find the string',0
aFileSearch db 'Find file',0 aFileSearch db 'Find file',0
aFileMasks db 'A file mask or several file masks:',0 aFileMasks db 'A file mask or several file masks:',0
aFileMasksLen = $ - aFileMasks - 1
aContainingText db 'Containing text:',0 aContainingText db 'Containing text:',0
aContainingTextLen = $ - aContainingText - 1
aSearchingIn db 'Searching "" in:',0 aSearchingIn db 'Searching "" in:',0
aSearchingInLen = $ - aSearchingIn - 1 aSearchingInLen = $ - aSearchingIn - 1
aSearchDone db 'Search done. Found ? file(s)',0 aSearchDone db 'Search done. Found ? file(s)',0
@ -8285,6 +8289,7 @@ aView db '[ View ]',0
aViewLen = $ - aView - 1 aViewLen = $ - aView - 1
aEditConfigErr1 db 'Error in configuration of plugins for the editor.',0 aEditConfigErr1 db 'Error in configuration of plugins for the editor.',0
aEditConfigErr2 db 'Try to remove unnecessary plugins.',0 aEditConfigErr2 db 'Try to remove unnecessary plugins.',0
aEditNoMemory db 'The file is too big for the editor.',0
aLine db ' Line' aLine db ' Line'
aCol db ' Col ' aCol db ' Col '
aEditorTitle db 'Editor',0 aEditorTitle db 'Editor',0
@ -8293,6 +8298,7 @@ aSave db 'Save',0
aDontSave db 'Do not save',0 aDontSave db 'Do not save',0
aContinueEdit db 'Continue editing',0 aContinueEdit db 'Continue editing',0
aCannotSaveToPlugin db 'Saving is not supported for plugin panels',0 aCannotSaveToPlugin db 'Saving is not supported for plugin panels',0
aCannotSearchOnPlugin db 'The search on plugin panels is not supported yet',0
aCancelled db 'Operation has been interrupted',0 aCancelled db 'Operation has been interrupted',0
aConfirmCancel db 'Do you really want to cancel it?',0 aConfirmCancel db 'Do you really want to cancel it?',0
end if end if