Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 616 → Rev 617

/programs/develop/tinypad/trunk/tp-common.asm
1,5 → 1,5
;-----------------------------------------------------------------------------
func clear_selection ;////////////////////////////////////////////////////////
proc clear_selection ;////////////////////////////////////////////////////////
;-----------------------------------------------------------------------------
push eax ebx
mov eax,[cur_editor.SelStart.Y]
11,10 → 11,10
pop [cur_editor.SelStart.Y] [cur_editor.SelStart.X]
pop ebx eax
ret
endf
endp
 
;-----------------------------------------------------------------------------
func pt_in_rect ;/////////////////////////////////////////////////////////////
proc pt_in_rect ;/////////////////////////////////////////////////////////////
;-----------------------------------------------------------------------------
cmp eax,[ecx+0x0]
jl @f
28,14 → 28,18
ret
@@: clc
ret
endf
endp
 
;-----------------------------------------------------------------------------
func check_bottom_right ;/////////////////////////////////////////////////////
proc check_bottom_right ;/////////////////////////////////////////////////////
;-----------------------------------------------------------------------------
push eax
mov eax,[cur_editor.TopLeft.Y]
add eax,[lines.scr]
or eax,eax
jns @f
xor eax,eax
mov [cur_editor.TopLeft.Y],eax
@@: add eax,[lines.scr]
cmp eax,[cur_editor.Lines.Count]
jbe .lp1
mov eax,[cur_editor.Lines.Count]
44,7 → 48,11
xor eax,eax
@@: mov [cur_editor.TopLeft.Y],eax
.lp1: mov eax,[cur_editor.TopLeft.X]
add eax,[columns.scr]
or eax,eax
jns @f
xor eax,eax
mov [cur_editor.TopLeft.X],eax
@@: add eax,[columns.scr]
cmp eax,[cur_editor.Columns.Count]
jbe .exit
mov eax,[cur_editor.Columns.Count]
55,10 → 63,10
.exit:
pop eax
ret
endf
endp
 
;-----------------------------------------------------------------------------
func get_real_length ;////////////////////////////////////////////////////////
proc get_real_length ;////////////////////////////////////////////////////////
;-----------------------------------------------------------------------------
movzx eax,word[esi]
@@: cmp byte[esi+eax+4-1],' '
66,10 → 74,10
dec eax
jnz @b
@@: ret
endf
endp
 
;-----------------------------------------------------------------------------
func get_line_offset ;////////////////////////////////////////////////////////
proc get_line_offset ;////////////////////////////////////////////////////////
;-----------------------------------------------------------------------------
; Input:
; ECX = line number
86,10 → 94,10
.exit:
pop ecx eax
ret
endf
endp
 
;-----------------------------------------------------------------------------
func init_sel_vars ;//////////////////////////////////////////////////////////
proc init_sel_vars ;//////////////////////////////////////////////////////////
;-----------------------------------------------------------------------------
pushad
mov [sel.selected],1
113,10 → 121,10
mov [sel.end.y],edx
popad
ret
endf
endp
 
;-----------------------------------------------------------------------------
func get_scroll_vars ;////////////////////////////////////////////////////////
proc get_scroll_vars ;////////////////////////////////////////////////////////
;-----------------------------------------------------------------------------
; Input:
; EAX = maximum data size (units)
159,10 → 167,10
mov dword[esp+4],0
mov dword[esp+8],0
jmp @b
endf
endp
 
;-----------------------------------------------------------------------------
func uint2strz ;//////////////////////////////////////////////////////////////
proc uint2strz ;//////////////////////////////////////////////////////////////
;-----------------------------------------------------------------------------
dec ebx
jz @f
176,10 → 184,10
das
stosb
ret
endf
endp
 
;-----------------------------------------------------------------------------
func uint2str ;///////////////////////////////////////////////////////////////
proc uint2str ;///////////////////////////////////////////////////////////////
;-----------------------------------------------------------------------------
cmp eax,ecx
jb @f
193,10 → 201,10
das
stosb
ret
endf
endp
 
;-----------------------------------------------------------------------------
func strlen ;/////////////////////////////////////////////////////////////////
proc strlen ;/////////////////////////////////////////////////////////////////
;-----------------------------------------------------------------------------
push ebx
mov ebx,eax
207,10 → 215,10
jmp @b
@@: pop ebx
ret
endf
endp
 
;-----------------------------------------------------------------------------
func rgb_to_gray ;////////////////////////////////////////////////////////////
proc rgb_to_gray ;////////////////////////////////////////////////////////////
;-----------------------------------------------------------------------------
push 0 eax
and dword[esp],0x000000FF
235,7 → 243,7
pop eax
add esp,4
ret
endf
endp
 
;float_gray_r dd 0.30f
;float_gray_g dd 0.59f
242,7 → 250,7
;float_gray_b dd 0.11f
 
;-----------------------------------------------------------------------------
func get_active_menu_item ;///////////////////////////////////////////////////
proc get_active_menu_item ;///////////////////////////////////////////////////
;-----------------------------------------------------------------------------
pushad
mov [mi_cur],0
276,10 → 284,10
or [mi_cur],-1
@@: popad
ret
endf
endp
 
;-----------------------------------------------------------------------------
func get_active_popup_item ;//////////////////////////////////////////////////
proc get_active_popup_item ;//////////////////////////////////////////////////
;-----------------------------------------------------------------------------
pushad
mov [pi_cur],0
296,9 → 304,9
call pt_in_rect
jnc .outside_window
inc dword[ecx+0x0]
mov dword[ecx+0x4],3
mov dword[ecx+0x4],2
dec dword[ecx+0x8]
mov dword[ecx+0xC],3+POP_IHEIGHT-1
mov dword[ecx+0xC],2+POP_IHEIGHT-1
mov edx,[ebp+POPUP.data]
@@: inc [pi_cur]
inc edx
306,12 → 314,12
cmp byte[edx],'-'
jne .lp1
pushd [ecx+0xC]
sub dword[ecx+0xC],POP_IHEIGHT-4
sub dword[ecx+0xC],POP_IHEIGHT-POP_SHEIGHT
call pt_in_rect
popd [ecx+0xC]
jc .separator
add dword[ecx+0x4],4
add dword[ecx+0xC],4
add dword[ecx+0x4],POP_SHEIGHT
add dword[ecx+0xC],POP_SHEIGHT
jmp .lp3
.lp1: call pt_in_rect
jnc .lp2
335,10 → 343,10
.outside_window:
or [pi_cur],-1
jmp .exit
endf
endp
 
;-----------------------------------------------------------------------------
func line_add_spaces ;////////////////////////////////////////////////////////
proc line_add_spaces ;////////////////////////////////////////////////////////
;-----------------------------------------------------------------------------
; Input:
; ESI = line offset
378,10 → 386,10
.exit:
popad
ret
endf
endp
 
;-----------------------------------------------------------------------------
func delete_selection ;///////////////////////////////////////////////////////
proc delete_selection ;///////////////////////////////////////////////////////
;-----------------------------------------------------------------------------
; call init_sel_vars
 
470,10 → 478,10
.exit.2:
stc
ret
endf
endp
 
;-----------------------------------------------------------------------------
func get_selection_size ;/////////////////////////////////////////////////////
proc get_selection_size ;/////////////////////////////////////////////////////
;-----------------------------------------------------------------------------
push ecx esi
mov ecx,[sel.end.y]
485,10 → 493,10
sub eax,esi
pop esi ecx
ret
endf
endp
 
;-----------------------------------------------------------------------------
func get_lines_in_file ;//////////////////////////////////////////////////////
proc get_lines_in_file ;//////////////////////////////////////////////////////
;-----------------------------------------------------------------------------
; Input:
; ESI = data pointer
528,10 → 536,10
sub [esp],edx
xor edx,edx
jmp .lp1
endf
endp
 
;-----------------------------------------------------------------------------
func update_caption ;/////////////////////////////////////////////////////////
proc update_caption ;/////////////////////////////////////////////////////////
;-----------------------------------------------------------------------------
lea esi,[cur_editor.FilePath]
mov edi,s_title
572,12 → 580,13
add esp,4
clc
ret
endf
endp
 
;-----------------------------------------------------------------------------
func mem.Alloc ;//////////////////////////////////////////////////////////////
proc mem.Alloc,size ;/////////////////////////////////////////////////////////
;-----------------------------------------------------------------------------
push ebx ecx
mov eax,[size]
lea ecx,[eax+4+4095]
and ecx,not 4095
mcall 68,12
586,12 → 595,20
add eax,4
pop ecx ebx
ret
endf
@^
push ebx ecx
mcall 68,12,[size]
pop ecx ebx
ret
^@
endp
 
;-----------------------------------------------------------------------------
func mem.ReAlloc ;////////////////////////////////////////////////////////////
proc mem.ReAlloc,mptr,size ;//////////////////////////////////////////////////
;-----------------------------------------------------------------------------
push ebx ecx esi edi eax
mov eax,[mptr]
mov ebx,[size]
or eax,eax
jz @f
lea ecx,[ebx+4+4095]
599,8 → 616,7
add ecx,-4
cmp ecx,[eax-4]
je .exit
@@: mov eax,ebx
call mem.Alloc
@@: stdcall mem.Alloc,ebx
xchg eax,[esp]
or eax,eax
jz .exit
616,18 → 632,31
cld
rep movsd
xchg eax,[esp]
call mem.Free
stdcall mem.Free,eax
.exit:
pop eax edi esi ecx ebx
ret
endf
@^
push ebx ecx edx
mcall 68,20,[size],[mptr]
pop edx ecx ebx
ret
^@
endp
 
;-----------------------------------------------------------------------------
func mem.Free ;///////////////////////////////////////////////////////////////
proc mem.Free,mptr ;//////////////////////////////////////////////////////////
;-----------------------------------------------------------------------------
push ebx ecx
mov eax,[mptr]
lea ecx,[eax-4]
mcall 68,13
pop ecx ebx
ret
endf
@^
push ebx ecx
mcall 68,13,[mptr]
pop ecx ebx
ret
^@
endp