Tinypad: fixed bug#1 (2)

Tinypad: changes in memory management

git-svn-id: svn://kolibrios.org@824 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Mihail Semenyako (mike.dld) 2008-07-16 04:55:19 +00:00
parent 1827396bcc
commit c6fefc9917
12 changed files with 66 additions and 41 deletions

View File

@ -1,3 +1,5 @@
diff16 'tp-button.asm',0,$
button:
mcall 17
cmp al,0

View File

@ -1,3 +1,5 @@
diff16 'tp-common.asm',0,$
;-----------------------------------------------------------------------------
proc clear_selection ;////////////////////////////////////////////////////////
;-----------------------------------------------------------------------------
@ -421,7 +423,7 @@ proc delete_selection ;///////////////////////////////////////////////////////
add edi,[sel.begin.x]
lea esi,[esi+eax+4]
mov ecx,[cur_editor.Lines]
add ecx,[ecx-4]
add ecx,[cur_editor.Lines.Size] ;*** add ecx,[ecx-4]
sub ecx,esi
cld
rep movsb
@ -447,7 +449,7 @@ proc delete_selection ;///////////////////////////////////////////////////////
add edi,[sel.begin.x]
lea esi,[edi+ecx]
mov ecx,[cur_editor.Lines]
add ecx,[ecx-4]
add ecx,[cur_editor.Lines.Size] ;*** add ecx,[ecx-4]
sub ecx,esi
cld
rep movsb
@ -465,7 +467,7 @@ proc delete_selection ;///////////////////////////////////////////////////////
movzx eax,word[esi]
lea esi,[esi+eax+4]
mov eax,[cur_editor.Lines]
add eax,[eax-4]
add eax,[cur_editor.Lines.Size] ;*** add eax,[eax-4]
sub esi,eax
lea eax,[esi+4096]
call editor_realloc_lines
@ -587,11 +589,11 @@ proc mem.Alloc,size ;/////////////////////////////////////////////////////////
;-----------------------------------------------------------------------------
push ebx ecx
mov ecx,[size]
add ecx,4
;*** add ecx,4
mcall 68,12
add ecx,-4
mov [eax],ecx
add eax,4
;*** add ecx,-4
;*** mov [eax],ecx
;*** add eax,4
pop ecx ebx
ret
endp
@ -601,19 +603,19 @@ proc mem.ReAlloc,mptr,size ;//////////////////////////////////////////////////
;-----------------------------------------------------------------------------
push ebx ecx edx
mov ecx,[size]
or ecx,ecx
jz @f
add ecx,4
or ecx,ecx
jz @f
;*** add ecx,4
@@: mov edx,[mptr]
or edx,edx
jz @f
add edx,-4
or edx,edx
jz @f
;*** add edx,-4
@@: mcall 68,20
or eax,eax
jz @f
add ecx,-4
mov [eax],ecx
add eax,4
or eax,eax
jz @f
;*** add ecx,-4
;*** mov [eax],ecx
;*** add eax,4
@@: pop edx ecx ebx
ret
endp
@ -623,9 +625,9 @@ proc mem.Free,mptr ;//////////////////////////////////////////////////////////
;-----------------------------------------------------------------------------
push ebx ecx
mov ecx,[mptr]
or ecx,ecx
jz @f
add ecx,-4
or ecx,ecx
jz @f
;*** add ecx,-4
@@: mcall 68,13
pop ecx ebx
ret

View File

@ -1,3 +1,5 @@
diff16 'tp-dialog.asm',0,$
;-----------------------------------------------------------------------------
proc define_3d_button ;///////////////////////////////////////////////////////
;-----------------------------------------------------------------------------

View File

@ -1,3 +1,5 @@
diff16 'tp-draw.asm',0,$
;-----------------------------------------------------------------------------
proc drawwindow ;///// DRAW WINDOW ///////////////////////////////////////////
;-----------------------------------------------------------------------------

View File

@ -1,3 +1,4 @@
diff16 'tp-editor.asm',0,$
;-----------------------------------------------------------------------------
proc draw_editor ;///// DRAW EDITOR //////////////////////////////////////////
@ -979,7 +980,7 @@ proc editor_realloc_lines ;///// ADD $DELTA$ TO LINES SIZE ///////////////////
mov eax,[cur_editor.Lines]
mov [cur_editor.Lines.Size],ebx
mov ecx,eax
stdcall mem.ReAlloc,eax,ebx
stdcall mem.ReAlloc,eax,ebx
mov [cur_editor.Lines],eax
sub eax,ecx
pop ecx ebx
@ -999,6 +1000,11 @@ proc editor_check_for_changes ;///// EDITOR CHANGES CHECKER //////////////////
.direct:
xor edx,edx
mov ecx,[cur_editor.Caret.Y]
call get_line_offset
call get_real_length
mov ecx,eax
mov eax,[cur_editor.Lines.Count]
cmp eax,[checker_ed.Lines.Count]
je @f
@ -1014,12 +1020,9 @@ proc editor_check_for_changes ;///// EDITOR CHANGES CHECKER //////////////////
@@: or dl,dl
jnz .redraw
mov ecx,[cur_editor.Caret.Y]
call get_line_offset
call get_real_length
cmp eax,[checker_ed_ll]
cmp ecx,[checker_ed_ll]
je @f
mov [checker_ed_ll],eax
mov [checker_ed_ll],ecx
or dl,REDRAW_ONELINE
@@:
mov eax,[cur_editor.Caret.Y]
@ -1107,6 +1110,7 @@ proc editor_check_for_changes ;///// EDITOR CHANGES CHECKER //////////////////
jmp .exit
.redraw:
mov [checker_ed_ll],ecx
push edx
call draw_editor_gutter
call draw_editor_text

View File

@ -1,3 +1,5 @@
diff16 'tp-files.asm',0,$
;-----------------------------------------------------------------------------
proc save_file ;//////////////////////////////////////////////////////////////
;-----------------------------------------------------------------------------
@ -21,7 +23,7 @@ proc save_file ;//////////////////////////////////////////////////////////////
mov eax,[cur_editor.Lines.Count]
shl eax,1
lea eax,[eax+ebx+1024]
stdcall mem.Alloc,eax
stdcall mem.Alloc,eax
push eax
mov esi,[cur_editor.Lines]
mov edi,eax
@ -171,7 +173,7 @@ proc load_file ;//////////////////////////////////////////////////////////////
mov [f_info70+0],0
mov eax,dword[file_info.Size]
mov [f_info70+12],eax
stdcall mem.Alloc,eax
stdcall mem.Alloc,eax
mov [f_info70+16],eax
mcall 70,f_info70
@ -185,7 +187,7 @@ proc load_file ;//////////////////////////////////////////////////////////////
cmp ebx,6 ;// ATV driver fix (6 instead of 5)
je .file_found
stdcall mem.Free,[f_info70+16]
stdcall mem.Free,[f_info70+16]
stc
ret
@ -220,7 +222,7 @@ proc load_file ;//////////////////////////////////////////////////////////////
call flush_cur_tab
pop edi esi ecx
call load_from_memory
stdcall mem.Free,[f_info70+16]
stdcall mem.Free,[f_info70+16]
xor eax,eax
mov [cur_editor.TopLeft.Y],eax
@ -264,7 +266,7 @@ proc load_from_memory ;///////////////////////////////////////////////////////
imul ebx,eax,14
add ebx,edx
mov [ebp+EDITOR.Lines.Size],ebx
stdcall mem.ReAlloc,[ebp+EDITOR.Lines],ebx
stdcall mem.ReAlloc,[ebp+EDITOR.Lines],ebx
mov [ebp+EDITOR.Lines],eax
mov [ebp+EDITOR.Columns.Count],0

View File

@ -1,3 +1,5 @@
diff16 'tp-key.asm',0,$
key:
mov ecx,1
mcall 66,3
@ -544,7 +546,7 @@ proc key.ctrl_v
mov ecx,[copy_size]
sub ecx,4
mov edi,[cur_editor.Lines]
add edi,[edi-4]
add edi,[cur_editor.Lines.Size] ;*** add edi,[edi-4]
dec edi
mov eax,esi
mov esi,edi
@ -691,7 +693,7 @@ proc key.ctrl_y ;///// DELETE CURRENT LINE ///////////////////////////////////
dec [cur_editor.Lines.Count]
mov ecx,[cur_editor.Lines]
add ecx,[ecx-4]
add ecx,[cur_editor.Lines.Size] ;*** add ecx,[ecx-4]
sub ecx,esi
shr ecx,2
cld
@ -1079,7 +1081,7 @@ proc key.del ;///// DELETE NEXT CHAR OR SELECTION ////////////////////////////
@@:
push ecx
mov edi,[cur_editor.Lines]
add edi,[edi-4]
add edi,[cur_editor.Lines.Size] ;*** add edi,[edi-4]
dec edi
lea esi,[edi+8]
sub esi,ecx
@ -1102,7 +1104,7 @@ proc key.del ;///// DELETE NEXT CHAR OR SELECTION ////////////////////////////
movzx eax,word[esi-4]
add esi,eax
mov ecx,[cur_editor.Lines]
add ecx,[ecx-4]
add ecx,[cur_editor.Lines.Size] ;*** add ecx,[ecx-4]
sub ecx,esi
cld
@@: rep movsb
@ -1127,7 +1129,7 @@ proc key.del ;///// DELETE NEXT CHAR OR SELECTION ////////////////////////////
movzx eax,word[esi]
lea esi,[esi+eax+4]
mov eax,[cur_editor.Lines]
add eax,[eax-4]
add eax,[cur_editor.Lines.Size] ;*** add eax,[eax-4]
sub esi,eax
lea eax,[esi+4096]
call editor_realloc_lines
@ -1249,7 +1251,7 @@ proc key.tab ;///// TABULATE /////////////////////////////////////////////////
pop eax
pushad
mov ecx,[cur_editor.Lines]
add ecx,[ecx-4]
add ecx,[cur_editor.Lines.Size] ;*** add ecx,[ecx-4]
dec ecx
mov edi,ecx
add ecx,-10+1
@ -1392,7 +1394,7 @@ proc key.return ;///// CARRIAGE RETURN ///////////////////////////////////////
push ecx
mov edi,[cur_editor.Lines]
add edi,[edi-4]
add edi,[cur_editor.Lines.Size] ;*** add edi,[edi-4]
dec edi
lea esi,[edi+4]
sub esi,ecx
@ -1410,7 +1412,7 @@ proc key.return ;///// CARRIAGE RETURN ///////////////////////////////////////
movzx ecx,word[ebp]
add esi,ecx
mov ecx,[cur_editor.Lines]
add ecx,[ecx-4]
add ecx,[cur_editor.Lines.Size] ;*** add ecx,[ecx-4]
sub ecx,esi
cld
@@: rep movsb

View File

@ -1,3 +1,5 @@
diff16 'tp-mouse.asm',0,$
proc check_mouse_in_edit_area
mcall 37,1
mov ebx,eax

View File

@ -1,3 +1,4 @@
diff16 'tp-popup.asm',0,$
;POP_WIDTH = (popup_text.max_title+popup_text.max_accel+6)*6
POP_IHEIGHT = 16

View File

@ -1,3 +1,5 @@
diff16 'tp-recode.asm',0,$
recode:
.866.1251:
@ -37,4 +39,4 @@ recode:
jmp @b
.exit:
ret

View File

@ -1,3 +1,5 @@
diff16 'tp-tabctl.asm',0,$
;-----------------------------------------------------------------------------
proc flush_cur_tab ;///// SAVE CURRENT TAB DATA TO CONTROL ///////////////////
;-----------------------------------------------------------------------------

View File

@ -1,3 +1,5 @@
diff16 'tp-tbox.asm',0,$
virtual at ebp
tbox TBOX
end virtual