From 86ae39b381356b1059bcb8b08acdf59fc8b7c3d8 Mon Sep 17 00:00:00 2001 From: "Evgeny Grechnikov (Diamond)" Date: Sat, 14 Feb 2009 14:59:07 +0000 Subject: [PATCH] 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 --- programs/fs/kfar/trunk/editor.inc | 118 +++++++++++++++++++++--------- programs/fs/kfar/trunk/kfar.asm | 10 ++- 2 files changed, 92 insertions(+), 36 deletions(-) diff --git a/programs/fs/kfar/trunk/editor.inc b/programs/fs/kfar/trunk/editor.inc index 1dd08d7183..8a99e63444 100644 --- a/programs/fs/kfar/trunk/editor.inc +++ b/programs/fs/kfar/trunk/editor.inc @@ -202,6 +202,8 @@ edit_file: jz ..openerr_in_screen mov ebx, eax @@: + mov ecx, [EditBlockSize] ; bytes rest in the current block + add edi, [EditBlockStart] .readloop: mov edx, [ebp + editor_data.hPlugin] test edx, edx @@ -255,31 +257,27 @@ edit_file: ; eax = number of bytes read test eax, eax jnz @f - mov ecx, edi - sub ecx, ebp - cmp ecx, [ebp + editor_data.first_block] + push edi + sub edi, ebp + cmp edi, [ebp + editor_data.first_block] + pop edi jnz .readdone @@: push eax ebx mov ebx, [readinfo.data] .loadloop: - mov ecx, [EditBlockSize] - cmp eax, ecx - ja @f - mov ecx, eax -@@: - sub eax, ecx + test ecx, ecx + jnz .hasplace push eax dec esi jns .hasblock - push ecx add [ebp + editor_data.memsize], 8 add esi, 8 mov ecx, [ebp + editor_data.memsize] cmp ecx, 80000000h shr 12 jb @f .nomemory2: - pop ecx eax ebx eax + pop eax ebx eax call .nomemory jmp .readfailed @@: @@ -289,20 +287,20 @@ edit_file: call xpgrealloc test eax, eax jz .nomemory2 - mov ebp, eax add edi, eax - pop ecx + xchg ebp, eax .hasblock: + push edi + and edi, not 0xFFF lea eax, [edi + 0x1000] - push eax sub eax, ebp stosd ; edit_block_header.next sub eax, 0x2000 stosd ; edit_block_header.prev - mov eax, [EditBlockStart] - add eax, ecx + pop eax + sub eax, edi + add eax, 8 stosd ; edit_block_header.limit - push ecx mov ecx, [EditPlugInfo] inc ecx jz @f @@ -310,49 +308,103 @@ edit_file: @@: xor eax, eax rep stosb ; info for plugins: zeroed - pop ecx - push esi edi ecx + add edi, 0x1000 + 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 - add ecx, 3 + mov edx, ecx shr ecx, 2 rep movsd + mov ecx, edx + and ecx, 3 + rep movsb mov ebx, esi - pop ecx edi + mov ecx, edx + pop esi ; calculate number of lines in this block - mov esi, edi - xor edx, edx test ecx, ecx 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: - lodsb + mov al, [esi] + add esi, 1 cmp al, 13 jz @f cmp al, 10 jz @f mov dl, 0 - jmp .3 + sub ecx, 1 + jnz .1 + jmp .4 @@: cmp al, dl mov dl, 0 jz .3 - inc [ebp + editor_data.numlines] + add [ebp + editor_data.numlines], 1 cmp al, 10 jz .3 mov dl, 10 .3: - loop .1 + sub ecx, 1 + jnz .1 .4: pop esi - pop edi pop eax - test eax, eax + pop ecx + sub [esp], ecx + sub eax, ecx + pop ecx jnz .loadloop pop ebx eax cmp eax, 16384 jz .readloop .readdone: + push edi + and edi, not 0xFFF 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 mov edx, ecx shr ecx, 12 @@ -363,15 +415,13 @@ edit_file: mov [ebp + editor_data.freeblocks], edx push edi .addfree: + add edi, 1000h add edx, 1000h mov [edi], edx - add edi, 1000h loop .addfree - mov [edi-1000h], eax + mov [edi], eax pop edi .nofree: - sub edi, 1000h - mov [edi + edit_block_header.next], eax sub edi, ebp mov [ebp + editor_data.last_block], edi mov ecx, [EditDataSize] diff --git a/programs/fs/kfar/trunk/kfar.asm b/programs/fs/kfar/trunk/kfar.asm index 231ccf7700..f303045d8e 100644 --- a/programs/fs/kfar/trunk/kfar.asm +++ b/programs/fs/kfar/trunk/kfar.asm @@ -7,8 +7,8 @@ memsize dd mem dd stacktop dd 0, app_path -version equ '0.61' -version_dword equ 0*10000h + 61 +version equ '0.62' +version_dword equ 0*10000h + 62 min_width = 54 max_width = 255 @@ -8195,6 +8195,8 @@ aCancel db ' Cancel ',0 aCancelLength = $ - aCancel - 1 aCancelB db '[ Cancel ]',0 aCancelBLength = $ - aCancelB - 1 +aCancelB2 = aCancelB +aCancelB2Length = $ - aCancelB2 - 1 aCopyCaption db 'Copy',0 aCopy db '[ Copy ]',0 aCopyLength = $ - aCopy - 1 @@ -8272,7 +8274,9 @@ aReverseSearch db 'Reverse search',0 aStringNotFound db 'Could not find the string',0 aFileSearch db 'Find file',0 aFileMasks db 'A file mask or several file masks:',0 +aFileMasksLen = $ - aFileMasks - 1 aContainingText db 'Containing text:',0 +aContainingTextLen = $ - aContainingText - 1 aSearchingIn db 'Searching "" in:',0 aSearchingInLen = $ - aSearchingIn - 1 aSearchDone db 'Search done. Found ? file(s)',0 @@ -8285,6 +8289,7 @@ aView db '[ View ]',0 aViewLen = $ - aView - 1 aEditConfigErr1 db 'Error in configuration of plugins for the editor.',0 aEditConfigErr2 db 'Try to remove unnecessary plugins.',0 +aEditNoMemory db 'The file is too big for the editor.',0 aLine db ' Line' aCol db ' Col ' aEditorTitle db 'Editor',0 @@ -8293,6 +8298,7 @@ aSave db 'Save',0 aDontSave db 'Do not save',0 aContinueEdit db 'Continue editing',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 aConfirmCancel db 'Do you really want to cancel it?',0 end if