2008-07-16 06:55:19 +02:00
|
|
|
diff16 'tp-common.asm',0,$
|
|
|
|
|
2006-10-11 22:40:53 +02:00
|
|
|
;-----------------------------------------------------------------------------
|
2007-09-01 23:38:00 +02:00
|
|
|
proc clear_selection ;////////////////////////////////////////////////////////
|
2006-10-11 22:40:53 +02:00
|
|
|
;-----------------------------------------------------------------------------
|
|
|
|
push eax ebx
|
2007-01-28 00:36:07 +01:00
|
|
|
mov eax,[cur_editor.SelStart.Y]
|
|
|
|
mov ebx,[cur_editor.Caret.Y]
|
2006-10-11 22:40:53 +02:00
|
|
|
cmp eax,ebx
|
|
|
|
jle @f
|
|
|
|
xchg eax,ebx
|
2007-01-28 00:36:07 +01:00
|
|
|
@@: push [cur_editor.Caret.X] [cur_editor.Caret.Y]
|
|
|
|
pop [cur_editor.SelStart.Y] [cur_editor.SelStart.X]
|
2006-10-11 22:40:53 +02:00
|
|
|
pop ebx eax
|
|
|
|
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 pt_in_rect ;/////////////////////////////////////////////////////////////
|
2006-10-11 22:40:53 +02:00
|
|
|
;-----------------------------------------------------------------------------
|
|
|
|
cmp eax,[ecx+0x0]
|
|
|
|
jl @f
|
|
|
|
cmp ebx,[ecx+0x4]
|
|
|
|
jl @f
|
|
|
|
cmp eax,[ecx+0x8]
|
|
|
|
jg @f
|
|
|
|
cmp ebx,[ecx+0xC]
|
|
|
|
jg @f
|
|
|
|
stc
|
|
|
|
ret
|
|
|
|
@@: clc
|
|
|
|
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 check_bottom_right ;/////////////////////////////////////////////////////
|
2006-10-11 22:40:53 +02:00
|
|
|
;-----------------------------------------------------------------------------
|
|
|
|
push eax
|
2007-01-28 00:36:07 +01:00
|
|
|
mov eax,[cur_editor.TopLeft.Y]
|
2007-09-01 23:38:00 +02:00
|
|
|
or eax,eax
|
|
|
|
jns @f
|
|
|
|
xor eax,eax
|
|
|
|
mov [cur_editor.TopLeft.Y],eax
|
|
|
|
@@: add eax,[lines.scr]
|
2007-01-28 00:36:07 +01:00
|
|
|
cmp eax,[cur_editor.Lines.Count]
|
2006-10-11 22:40:53 +02:00
|
|
|
jbe .lp1
|
2007-01-28 00:36:07 +01:00
|
|
|
mov eax,[cur_editor.Lines.Count]
|
2006-10-11 22:40:53 +02:00
|
|
|
sub eax,[lines.scr]
|
|
|
|
jns @f
|
|
|
|
xor eax,eax
|
2007-01-28 00:36:07 +01:00
|
|
|
@@: mov [cur_editor.TopLeft.Y],eax
|
|
|
|
.lp1: mov eax,[cur_editor.TopLeft.X]
|
2007-09-01 23:38:00 +02:00
|
|
|
or eax,eax
|
|
|
|
jns @f
|
|
|
|
xor eax,eax
|
|
|
|
mov [cur_editor.TopLeft.X],eax
|
|
|
|
@@: add eax,[columns.scr]
|
2007-01-28 00:36:07 +01:00
|
|
|
cmp eax,[cur_editor.Columns.Count]
|
2006-10-11 22:40:53 +02:00
|
|
|
jbe .exit
|
2007-01-28 00:36:07 +01:00
|
|
|
mov eax,[cur_editor.Columns.Count]
|
2006-10-11 22:40:53 +02:00
|
|
|
sub eax,[columns.scr]
|
|
|
|
jns @f
|
|
|
|
xor eax,eax
|
2007-01-28 00:36:07 +01:00
|
|
|
@@: mov [cur_editor.TopLeft.X],eax
|
2006-10-11 22:40:53 +02:00
|
|
|
.exit:
|
|
|
|
pop eax
|
|
|
|
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 get_real_length ;////////////////////////////////////////////////////////
|
2006-10-11 22:40:53 +02:00
|
|
|
;-----------------------------------------------------------------------------
|
2008-12-29 20:08:59 +01:00
|
|
|
mov eax,[esi+EDITOR_LINE_DATA.Size]
|
|
|
|
@@: cmp byte[esi+eax+sizeof.EDITOR_LINE_DATA-1],' '
|
2006-10-11 22:40:53 +02:00
|
|
|
jne @f
|
|
|
|
dec eax
|
|
|
|
jnz @b
|
|
|
|
@@: 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 get_line_offset ;////////////////////////////////////////////////////////
|
2006-10-11 22:40:53 +02:00
|
|
|
;-----------------------------------------------------------------------------
|
|
|
|
; Input:
|
|
|
|
; ECX = line number
|
|
|
|
; Output:
|
|
|
|
; ESI = line data offset
|
|
|
|
;-----------------------------------------------------------------------------
|
|
|
|
push eax ecx
|
2007-01-28 00:36:07 +01:00
|
|
|
mov esi,[cur_editor.Lines]
|
2007-01-03 19:22:05 +01:00
|
|
|
@@: dec ecx
|
|
|
|
js .exit
|
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-03 19:22:05 +01:00
|
|
|
jmp @b
|
2006-10-11 22:40:53 +02:00
|
|
|
.exit:
|
|
|
|
pop ecx eax
|
|
|
|
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 init_sel_vars ;//////////////////////////////////////////////////////////
|
2006-10-11 22:40:53 +02:00
|
|
|
;-----------------------------------------------------------------------------
|
|
|
|
pushad
|
|
|
|
mov [sel.selected],1
|
2007-01-28 00:36:07 +01:00
|
|
|
mov eax,[ebp+EDITOR.SelStart.X]
|
|
|
|
mov ebx,[ebp+EDITOR.SelStart.Y]
|
|
|
|
mov ecx,[ebp+EDITOR.Caret.X]
|
|
|
|
mov edx,[ebp+EDITOR.Caret.Y]
|
2006-10-11 22:40:53 +02:00
|
|
|
cmp ebx,edx
|
|
|
|
jl .lp2
|
|
|
|
jne @f
|
|
|
|
cmp eax,ecx
|
|
|
|
jl .lp2
|
|
|
|
jne .lp1
|
|
|
|
dec [sel.selected]
|
|
|
|
jmp .lp2
|
|
|
|
@@: xchg ebx,edx
|
|
|
|
.lp1: xchg eax,ecx
|
|
|
|
.lp2: mov [sel.begin.x],eax
|
|
|
|
mov [sel.begin.y],ebx
|
|
|
|
mov [sel.end.x],ecx
|
|
|
|
mov [sel.end.y],edx
|
|
|
|
popad
|
|
|
|
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 get_scroll_vars ;////////////////////////////////////////////////////////
|
2006-10-11 22:40:53 +02:00
|
|
|
;-----------------------------------------------------------------------------
|
|
|
|
; Input:
|
|
|
|
; EAX = maximum data size (units)
|
|
|
|
; EBX = visible data size (units)
|
|
|
|
; ECX = current data position (units)
|
|
|
|
; EDX = scrolling area size (pixels)
|
|
|
|
; Output:
|
|
|
|
; EAX = srcoller offset (pixels)
|
|
|
|
; EBX = scroller size (pixels)
|
|
|
|
;-----------------------------------------------------------------------------
|
|
|
|
push eax ebx edx
|
|
|
|
; sub eax,ebx
|
|
|
|
mov esi,eax
|
|
|
|
mov eax,edx
|
|
|
|
imul ebx
|
|
|
|
idiv esi
|
|
|
|
cmp eax,[esp]
|
|
|
|
jge .null
|
|
|
|
cmp eax,AMINS
|
|
|
|
jge @f
|
|
|
|
neg eax
|
|
|
|
add eax,AMINS
|
|
|
|
sub [esp],eax
|
|
|
|
mov eax,AMINS
|
|
|
|
@@: mov [esp+4],eax ; scroller size
|
|
|
|
mov eax,[esp]
|
|
|
|
imul ecx
|
|
|
|
idiv esi
|
|
|
|
or eax,eax
|
|
|
|
jns @f
|
|
|
|
xor eax,eax
|
2007-01-28 00:36:07 +01:00
|
|
|
@@: mov [esp+8],eax ; scroller offset
|
2006-10-11 22:40:53 +02:00
|
|
|
add eax,[esp+4]
|
|
|
|
cmp eax,[esp]
|
|
|
|
jle @f
|
|
|
|
@@:
|
|
|
|
pop edx ebx eax
|
|
|
|
ret
|
|
|
|
.null:
|
|
|
|
mov dword[esp+4],0
|
|
|
|
mov dword[esp+8],0
|
|
|
|
jmp @b
|
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 uint2strz ;//////////////////////////////////////////////////////////////
|
2006-10-11 22:40:53 +02:00
|
|
|
;-----------------------------------------------------------------------------
|
|
|
|
dec ebx
|
|
|
|
jz @f
|
|
|
|
xor edx,edx
|
|
|
|
div ecx
|
|
|
|
push edx
|
|
|
|
call uint2strz
|
|
|
|
pop eax
|
|
|
|
@@: cmp al,10
|
|
|
|
sbb al,$69
|
|
|
|
das
|
|
|
|
stosb
|
|
|
|
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 uint2str ;///////////////////////////////////////////////////////////////
|
2006-10-11 22:40:53 +02:00
|
|
|
;-----------------------------------------------------------------------------
|
|
|
|
cmp eax,ecx
|
|
|
|
jb @f
|
|
|
|
xor edx,edx
|
|
|
|
div ecx
|
|
|
|
push edx
|
|
|
|
call uint2str
|
|
|
|
pop eax
|
|
|
|
@@: cmp al,10
|
|
|
|
sbb al,$69
|
|
|
|
das
|
|
|
|
stosb
|
|
|
|
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 strlen ;/////////////////////////////////////////////////////////////////
|
2007-01-03 19:22:05 +01:00
|
|
|
;-----------------------------------------------------------------------------
|
|
|
|
push ebx
|
|
|
|
mov ebx,eax
|
|
|
|
xor eax,eax
|
|
|
|
@@: cmp byte[ebx+eax],0
|
|
|
|
je @f
|
|
|
|
inc eax
|
|
|
|
jmp @b
|
|
|
|
@@: pop ebx
|
|
|
|
ret
|
2007-09-01 23:38:00 +02:00
|
|
|
endp
|
2007-01-03 19:22:05 +01:00
|
|
|
|
2006-10-11 22:40:53 +02:00
|
|
|
;-----------------------------------------------------------------------------
|
2007-09-01 23:38:00 +02:00
|
|
|
proc rgb_to_gray ;////////////////////////////////////////////////////////////
|
2006-10-11 22:40:53 +02:00
|
|
|
;-----------------------------------------------------------------------------
|
|
|
|
push 0 eax
|
|
|
|
and dword[esp],0x000000FF
|
|
|
|
fild dword[esp]
|
|
|
|
fmul [float_gray_b]
|
|
|
|
shr eax,8
|
|
|
|
mov [esp],eax
|
|
|
|
and dword[esp],0x000000FF
|
|
|
|
fild dword[esp]
|
|
|
|
fmul [float_gray_g]
|
|
|
|
faddp
|
|
|
|
shr eax,8
|
|
|
|
and eax,0x000000FF
|
|
|
|
mov [esp],eax
|
|
|
|
fild dword[esp]
|
|
|
|
fmul [float_gray_r]
|
|
|
|
faddp
|
|
|
|
frndint
|
|
|
|
fist dword[esp]
|
|
|
|
fist dword[esp+1]
|
|
|
|
fistp dword[esp+2]
|
|
|
|
pop eax
|
|
|
|
add esp,4
|
|
|
|
ret
|
2007-09-01 23:38:00 +02:00
|
|
|
endp
|
2006-10-11 22:40:53 +02:00
|
|
|
|
|
|
|
;float_gray_r dd 0.30f
|
|
|
|
;float_gray_g dd 0.59f
|
|
|
|
;float_gray_b dd 0.11f
|
|
|
|
|
|
|
|
;-----------------------------------------------------------------------------
|
2007-09-01 23:38:00 +02:00
|
|
|
proc get_active_menu_item ;///////////////////////////////////////////////////
|
2006-10-11 22:40:53 +02:00
|
|
|
;-----------------------------------------------------------------------------
|
|
|
|
pushad
|
|
|
|
mov [mi_cur],0
|
|
|
|
mcall 37,1
|
|
|
|
movsx ebx,ax
|
|
|
|
sar eax,16
|
|
|
|
mov ecx,__rc
|
|
|
|
pushd 2 0 (main_menu.width+7) (ATOPH-2)
|
|
|
|
popd [__rc+0xC] [__rc+0x8] [__rc+0x4] [__rc+0x0]
|
|
|
|
; add [__rc+0xC],ATOPH-2
|
|
|
|
call pt_in_rect
|
|
|
|
jnc .outside_menu
|
|
|
|
m2m dword[ecx+0x8],dword[ecx+0x0]
|
|
|
|
mov edx,main_menu
|
|
|
|
@@: inc [mi_cur]
|
|
|
|
movzx esi,word[edx+0]
|
|
|
|
add [ecx+0x8],esi
|
|
|
|
call pt_in_rect
|
|
|
|
jc .exit
|
|
|
|
m2m dword[ecx+0x0],dword[ecx+0x8]
|
|
|
|
add edx,8+1
|
|
|
|
movzx esi,byte[edx-1]
|
|
|
|
add edx,esi
|
|
|
|
cmp byte[edx+8],0
|
|
|
|
jne @b
|
|
|
|
mov [mi_cur],0
|
|
|
|
.exit:
|
|
|
|
popad
|
|
|
|
ret
|
|
|
|
.outside_menu:
|
|
|
|
or [mi_cur],-1
|
|
|
|
@@: popad
|
|
|
|
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 get_active_popup_item ;//////////////////////////////////////////////////
|
2006-10-11 22:40:53 +02:00
|
|
|
;-----------------------------------------------------------------------------
|
|
|
|
pushad
|
|
|
|
mov [pi_cur],0
|
|
|
|
mcall 37,1
|
|
|
|
movsx ebx,ax
|
|
|
|
sar eax,16
|
|
|
|
mov ecx,__rc
|
|
|
|
mov dword[ecx+0x0],0
|
|
|
|
mov dword[ecx+0x4],0
|
|
|
|
movzx edx,[ebp+POPUP.width]
|
2007-01-28 00:36:07 +01:00
|
|
|
mov dword[ecx+0x8],edx
|
2006-10-11 22:40:53 +02:00
|
|
|
movzx edx,[ebp+POPUP.height]
|
2007-01-28 00:36:07 +01:00
|
|
|
mov dword[ecx+0xC],edx
|
2006-10-11 22:40:53 +02:00
|
|
|
call pt_in_rect
|
|
|
|
jnc .outside_window
|
|
|
|
inc dword[ecx+0x0]
|
2007-09-01 23:38:00 +02:00
|
|
|
mov dword[ecx+0x4],2
|
2006-10-11 22:40:53 +02:00
|
|
|
dec dword[ecx+0x8]
|
2007-09-01 23:38:00 +02:00
|
|
|
mov dword[ecx+0xC],2+POP_IHEIGHT-1
|
2007-01-28 00:36:07 +01:00
|
|
|
mov edx,[ebp+POPUP.data]
|
2006-10-11 22:40:53 +02:00
|
|
|
@@: inc [pi_cur]
|
|
|
|
inc edx
|
|
|
|
movzx esi,byte[edx-1]
|
|
|
|
cmp byte[edx],'-'
|
|
|
|
jne .lp1
|
|
|
|
pushd [ecx+0xC]
|
2007-09-01 23:38:00 +02:00
|
|
|
sub dword[ecx+0xC],POP_IHEIGHT-POP_SHEIGHT
|
2006-10-11 22:40:53 +02:00
|
|
|
call pt_in_rect
|
|
|
|
popd [ecx+0xC]
|
|
|
|
jc .separator
|
2007-09-01 23:38:00 +02:00
|
|
|
add dword[ecx+0x4],POP_SHEIGHT
|
|
|
|
add dword[ecx+0xC],POP_SHEIGHT
|
2006-10-11 22:40:53 +02:00
|
|
|
jmp .lp3
|
|
|
|
.lp1: call pt_in_rect
|
|
|
|
jnc .lp2
|
|
|
|
mov eax,[pi_cur]
|
2007-01-28 00:36:07 +01:00
|
|
|
test byte[ebp+eax-1],1
|
2006-10-11 22:40:53 +02:00
|
|
|
jnz .exit
|
|
|
|
jmp .separator
|
|
|
|
.lp2: add dword[ecx+0x4],POP_IHEIGHT
|
|
|
|
add dword[ecx+0xC],POP_IHEIGHT
|
|
|
|
add edx,esi
|
|
|
|
inc edx
|
|
|
|
movzx esi,byte[edx-1]
|
|
|
|
.lp3: add edx,esi
|
|
|
|
cmp byte[edx],0
|
|
|
|
jne @b
|
|
|
|
.separator:
|
|
|
|
mov [pi_cur],0
|
|
|
|
.exit:
|
|
|
|
popad
|
|
|
|
ret
|
|
|
|
.outside_window:
|
|
|
|
or [pi_cur],-1
|
|
|
|
jmp .exit
|
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 line_add_spaces ;////////////////////////////////////////////////////////
|
2006-10-11 22:40:53 +02:00
|
|
|
;-----------------------------------------------------------------------------
|
2007-01-18 22:14:15 +01:00
|
|
|
; Input:
|
|
|
|
; ESI = line offset
|
|
|
|
; ECX = needed line length
|
|
|
|
; Output:
|
|
|
|
; EAX = delta
|
2006-10-11 22:40:53 +02:00
|
|
|
;-----------------------------------------------------------------------------
|
2007-01-18 22:14:15 +01:00
|
|
|
xor eax,eax
|
2006-10-11 22:40:53 +02:00
|
|
|
pushad
|
2008-12-29 20:08:59 +01:00
|
|
|
mov edx,[esi+EDITOR_LINE_DATA.Size]
|
2006-10-11 22:40:53 +02:00
|
|
|
cmp ecx,edx
|
|
|
|
jbe .exit
|
|
|
|
sub ecx,edx
|
2008-12-29 20:08:59 +01:00
|
|
|
lea eax,[ecx+sizeof.EDITOR_LINE_DATA]
|
2007-01-18 22:14:15 +01:00
|
|
|
call editor_realloc_lines
|
|
|
|
mov [esp+4*7],eax
|
|
|
|
add esi,eax
|
2006-10-11 22:40:53 +02:00
|
|
|
push ecx
|
2007-01-28 00:36:07 +01:00
|
|
|
mov edi,[cur_editor.Lines]
|
2008-12-29 20:08:59 +01:00
|
|
|
add edi,[cur_editor.Lines.Size] ; !!! CHECK THIS!!! add edi,[edi-4]
|
2007-01-03 19:22:05 +01:00
|
|
|
dec edi
|
2006-10-11 22:40:53 +02:00
|
|
|
mov eax,esi
|
|
|
|
mov esi,edi
|
|
|
|
sub esi,ecx
|
2008-12-29 20:08:59 +01:00
|
|
|
lea ecx,[eax+sizeof.EDITOR_LINE_DATA]
|
2007-01-28 00:36:07 +01:00
|
|
|
add ecx,edx
|
2006-10-11 22:40:53 +02:00
|
|
|
push ecx
|
|
|
|
neg ecx
|
|
|
|
lea ecx,[esi+ecx+1]
|
|
|
|
std
|
|
|
|
rep movsb
|
|
|
|
pop edi ecx
|
2008-12-29 20:08:59 +01:00
|
|
|
add [eax+EDITOR_LINE_DATA.Size],ecx
|
2006-10-11 22:40:53 +02:00
|
|
|
mov al,' '
|
|
|
|
cld
|
|
|
|
rep stosb
|
|
|
|
.exit:
|
|
|
|
popad
|
|
|
|
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 delete_selection ;///////////////////////////////////////////////////////
|
2006-10-11 22:40:53 +02:00
|
|
|
;-----------------------------------------------------------------------------
|
2007-01-03 19:22:05 +01:00
|
|
|
; call init_sel_vars
|
|
|
|
|
2006-10-11 22:40:53 +02:00
|
|
|
cmp [sel.selected],0
|
|
|
|
je .exit.2
|
|
|
|
|
|
|
|
pushad
|
|
|
|
mov ecx,[sel.begin.y]
|
|
|
|
cmp ecx,[sel.end.y]
|
|
|
|
je .single_line
|
|
|
|
call get_line_offset
|
2008-12-29 20:08:59 +01:00
|
|
|
and [esi+EDITOR_LINE_DATA.Flags],not EDITOR_LINE_FLAG_SAVED
|
|
|
|
or [esi+EDITOR_LINE_DATA.Flags],EDITOR_LINE_FLAG_MOFIFIED
|
2006-10-11 22:40:53 +02:00
|
|
|
mov ecx,[sel.begin.x]
|
|
|
|
call line_add_spaces
|
2007-01-18 22:14:15 +01:00
|
|
|
add esi,eax
|
2008-12-29 20:08:59 +01:00
|
|
|
lea edi,[esi+sizeof.EDITOR_LINE_DATA]
|
2006-10-11 22:40:53 +02:00
|
|
|
mov ecx,[sel.end.y]
|
|
|
|
call get_line_offset
|
|
|
|
call get_real_length
|
|
|
|
cmp eax,[sel.end.x]
|
|
|
|
jbe @f
|
|
|
|
mov eax,[sel.end.x]
|
2008-12-29 20:08:59 +01:00
|
|
|
@@: mov ecx,[esi+EDITOR_LINE_DATA.Size]
|
2006-10-11 22:40:53 +02:00
|
|
|
sub ecx,eax
|
|
|
|
mov ebx,[sel.begin.x]
|
|
|
|
add ebx,ecx
|
2008-12-29 20:08:59 +01:00
|
|
|
mov [edi-sizeof.EDITOR_LINE_DATA+EDITOR_LINE_DATA.Size],ebx
|
2006-10-11 22:40:53 +02:00
|
|
|
add edi,[sel.begin.x]
|
2008-12-29 20:08:59 +01:00
|
|
|
lea esi,[esi+eax+sizeof.EDITOR_LINE_DATA]
|
2007-01-28 00:36:07 +01:00
|
|
|
mov ecx,[cur_editor.Lines]
|
2008-07-16 06:55:19 +02:00
|
|
|
add ecx,[cur_editor.Lines.Size] ;*** add ecx,[ecx-4]
|
2006-10-11 22:40:53 +02:00
|
|
|
sub ecx,esi
|
|
|
|
cld
|
|
|
|
rep movsb
|
|
|
|
mov eax,[sel.end.y]
|
|
|
|
sub eax,[sel.begin.y]
|
2007-01-28 00:36:07 +01:00
|
|
|
sub [cur_editor.Lines.Count],eax
|
2006-10-11 22:40:53 +02:00
|
|
|
jmp .exit
|
|
|
|
|
|
|
|
.single_line:
|
|
|
|
call get_line_offset
|
2008-12-29 20:08:59 +01:00
|
|
|
and [esi+EDITOR_LINE_DATA.Flags],not EDITOR_LINE_FLAG_SAVED
|
|
|
|
or [esi+EDITOR_LINE_DATA.Flags],EDITOR_LINE_FLAG_MOFIFIED
|
2006-10-11 22:40:53 +02:00
|
|
|
call get_real_length
|
|
|
|
cmp eax,[sel.begin.x]
|
|
|
|
jbe .exit
|
|
|
|
mov ecx,[sel.end.x]
|
|
|
|
cmp ecx,eax
|
|
|
|
jbe @f
|
|
|
|
mov ecx,eax
|
|
|
|
@@: sub ecx,[sel.begin.x]
|
2008-12-29 20:08:59 +01:00
|
|
|
sub [esi+EDITOR_LINE_DATA.Size],ecx
|
|
|
|
lea edi,[esi+sizeof.EDITOR_LINE_DATA]
|
2006-10-11 22:40:53 +02:00
|
|
|
add edi,[sel.begin.x]
|
|
|
|
lea esi,[edi+ecx]
|
2007-01-28 00:36:07 +01:00
|
|
|
mov ecx,[cur_editor.Lines]
|
2008-07-16 06:55:19 +02:00
|
|
|
add ecx,[cur_editor.Lines.Size] ;*** add ecx,[ecx-4]
|
2006-10-11 22:40:53 +02:00
|
|
|
sub ecx,esi
|
|
|
|
cld
|
|
|
|
rep movsb
|
|
|
|
|
|
|
|
.exit:
|
|
|
|
mov eax,[sel.begin.x]
|
2007-01-28 00:36:07 +01:00
|
|
|
mov [cur_editor.Caret.X],eax
|
|
|
|
mov [cur_editor.SelStart.X],eax
|
2006-10-11 22:40:53 +02:00
|
|
|
mov eax,[sel.begin.y]
|
2007-01-28 00:36:07 +01:00
|
|
|
mov [cur_editor.Caret.Y],eax
|
|
|
|
mov [cur_editor.SelStart.Y],eax
|
2007-01-18 22:14:15 +01:00
|
|
|
|
|
|
|
mov ecx,[cur_editor.Lines.Count]
|
|
|
|
call get_line_offset
|
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
|
|
|
mov eax,[cur_editor.Lines]
|
2008-07-16 06:55:19 +02:00
|
|
|
add eax,[cur_editor.Lines.Size] ;*** add eax,[eax-4]
|
2007-01-18 22:14:15 +01:00
|
|
|
sub esi,eax
|
|
|
|
lea eax,[esi+4096]
|
|
|
|
call editor_realloc_lines
|
|
|
|
|
2006-10-11 22:40:53 +02:00
|
|
|
popad
|
2007-01-28 00:36:07 +01:00
|
|
|
mov [cur_editor.Modified],1
|
2006-10-11 22:40:53 +02:00
|
|
|
clc
|
|
|
|
ret
|
|
|
|
|
|
|
|
.exit.2:
|
|
|
|
stc
|
|
|
|
ret
|
2007-09-01 23:38:00 +02:00
|
|
|
endp
|
2007-01-03 19:22:05 +01:00
|
|
|
|
|
|
|
;-----------------------------------------------------------------------------
|
2007-09-01 23:38:00 +02:00
|
|
|
proc get_selection_size ;/////////////////////////////////////////////////////
|
2007-01-03 19:22:05 +01:00
|
|
|
;-----------------------------------------------------------------------------
|
|
|
|
push ecx esi
|
|
|
|
mov ecx,[sel.end.y]
|
|
|
|
inc ecx
|
|
|
|
call get_line_offset
|
|
|
|
mov eax,esi
|
|
|
|
mov ecx,[sel.begin.y]
|
|
|
|
call get_line_offset
|
|
|
|
sub eax,esi
|
|
|
|
pop esi ecx
|
|
|
|
ret
|
2007-09-01 23:38:00 +02:00
|
|
|
endp
|
2007-01-03 19:22:05 +01:00
|
|
|
|
|
|
|
;-----------------------------------------------------------------------------
|
2007-09-01 23:38:00 +02:00
|
|
|
proc get_lines_in_file ;//////////////////////////////////////////////////////
|
2007-01-03 19:22:05 +01:00
|
|
|
;-----------------------------------------------------------------------------
|
2007-01-18 22:14:15 +01:00
|
|
|
; Input:
|
|
|
|
; ESI = data pointer
|
|
|
|
; ECX = data length
|
|
|
|
; Output:
|
|
|
|
; EAX = lines number
|
|
|
|
; EBX = extra length after tabs expansion
|
2007-01-03 19:22:05 +01:00
|
|
|
;-----------------------------------------------------------------------------
|
2007-01-18 22:14:15 +01:00
|
|
|
push ecx edx esi 0
|
2007-01-03 19:22:05 +01:00
|
|
|
or ebx,-1
|
2007-01-18 22:14:15 +01:00
|
|
|
xor edx,edx
|
2007-01-03 19:22:05 +01:00
|
|
|
.lp0: inc ebx
|
|
|
|
.lp1: dec ecx
|
|
|
|
jle .lp2
|
|
|
|
lodsb
|
2007-01-18 22:14:15 +01:00
|
|
|
cmp al,0
|
|
|
|
je .lp2
|
|
|
|
cmp al,9
|
|
|
|
je .TB
|
2007-01-03 19:22:05 +01:00
|
|
|
cmp al,10
|
|
|
|
je .LF
|
|
|
|
cmp al,13
|
|
|
|
je .CR
|
2007-01-18 22:14:15 +01:00
|
|
|
inc edx
|
2007-01-03 19:22:05 +01:00
|
|
|
jmp .lp1
|
2007-01-18 22:14:15 +01:00
|
|
|
.lp2: lea eax,[ebx+1]
|
|
|
|
pop ebx esi edx ecx
|
2007-01-03 19:22:05 +01:00
|
|
|
ret
|
|
|
|
|
|
|
|
.CR: cmp byte[esi],10
|
2007-01-18 22:14:15 +01:00
|
|
|
jne .LF
|
2007-01-03 19:22:05 +01:00
|
|
|
lodsb
|
2007-01-18 22:14:15 +01:00
|
|
|
.LF: xor edx,edx
|
|
|
|
jmp .lp0
|
|
|
|
.TB: and edx,00000111b
|
|
|
|
add dword[esp],ATABW
|
|
|
|
sub [esp],edx
|
|
|
|
xor edx,edx
|
|
|
|
jmp .lp1
|
2007-09-01 23:38:00 +02:00
|
|
|
endp
|
2007-01-03 19:22:05 +01:00
|
|
|
|
2007-01-28 00:36:07 +01:00
|
|
|
;-----------------------------------------------------------------------------
|
2007-09-01 23:38:00 +02:00
|
|
|
proc update_caption ;/////////////////////////////////////////////////////////
|
2007-01-28 00:36:07 +01:00
|
|
|
;-----------------------------------------------------------------------------
|
|
|
|
lea esi,[cur_editor.FilePath]
|
|
|
|
mov edi,s_title
|
|
|
|
|
2007-02-08 01:34:56 +01:00
|
|
|
xor ecx,ecx
|
2007-01-28 00:36:07 +01:00
|
|
|
@@: lodsb
|
|
|
|
cmp al,0
|
|
|
|
je @f
|
|
|
|
stosb
|
2007-02-08 01:34:56 +01:00
|
|
|
inc ecx
|
2007-01-28 00:36:07 +01:00
|
|
|
jmp @b
|
|
|
|
@@:
|
2007-02-08 01:34:56 +01:00
|
|
|
push ecx
|
2007-01-28 00:36:07 +01:00
|
|
|
mov dword[edi],' - '
|
|
|
|
add edi,3
|
2007-02-08 01:34:56 +01:00
|
|
|
mov esi,htext
|
2007-01-28 00:36:07 +01:00
|
|
|
mov ecx,htext.size
|
|
|
|
cld
|
|
|
|
rep movsb
|
|
|
|
|
|
|
|
mov al,0
|
|
|
|
stosb
|
|
|
|
|
|
|
|
mcall 71,1,s_title
|
|
|
|
|
2007-02-08 01:34:56 +01:00
|
|
|
cmp [do_not_draw],0
|
|
|
|
jne @f
|
|
|
|
lea esi,[cur_editor.FilePath]
|
|
|
|
mov edi,tb_opensave.text
|
|
|
|
mov ecx,[esp]
|
|
|
|
cld
|
|
|
|
rep movsb
|
|
|
|
pop ecx
|
|
|
|
mov [tb_opensave.length],cl
|
|
|
|
clc
|
|
|
|
ret
|
|
|
|
@@:
|
|
|
|
add esp,4
|
2007-01-28 00:36:07 +01:00
|
|
|
clc
|
|
|
|
ret
|
2007-09-01 23:38:00 +02:00
|
|
|
endp
|
2007-01-28 00:36:07 +01:00
|
|
|
|