2008-07-16 06:55:19 +02:00
|
|
|
diff16 'tp-mouse.asm',0,$
|
|
|
|
|
2007-09-01 23:38:00 +02:00
|
|
|
proc check_mouse_in_edit_area
|
2006-10-11 22:40:53 +02:00
|
|
|
mcall 37,1
|
|
|
|
mov ebx,eax
|
|
|
|
and ebx,0x0000FFFF
|
|
|
|
shr eax,16
|
2007-01-28 00:36:07 +01:00
|
|
|
mov ecx,[cur_editor.Bounds.Top]
|
2006-10-11 22:40:53 +02:00
|
|
|
inc ecx
|
2007-01-28 00:36:07 +01:00
|
|
|
pushd [cur_editor.Bounds.Left] ecx [cur_editor.Bounds.Right] ecx
|
2006-10-11 22:40:53 +02:00
|
|
|
popd [__rc+0xC] [__rc+0x8] [__rc+0x4] [__rc+0x0]
|
|
|
|
sub [__rc+0x8],SCRLW+6
|
2007-01-18 22:14:15 +01:00
|
|
|
mov ecx,[cur_editor.Gutter.Width]
|
|
|
|
add [__rc+0x0],ecx
|
2006-10-11 22:40:53 +02:00
|
|
|
imul ecx,[lines.scr],LINEH
|
|
|
|
dec ecx
|
|
|
|
add [__rc+0xC],ecx
|
|
|
|
mov ecx,__rc
|
|
|
|
call pt_in_rect
|
|
|
|
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_mouse_event
|
2006-10-11 22:40:53 +02:00
|
|
|
mcall 37,2
|
|
|
|
and al,3
|
|
|
|
mov bl,[ecx]
|
|
|
|
cmp [ecx],al
|
|
|
|
mov [ecx],al
|
|
|
|
jne @f
|
2007-09-01 23:38:00 +02:00
|
|
|
mcall 37,7
|
|
|
|
or eax,eax
|
|
|
|
jz .mv
|
|
|
|
add [ecx+6],ax
|
|
|
|
shr eax,16
|
|
|
|
add [ecx+4],ax
|
|
|
|
mov eax,MEV_WHEEL
|
|
|
|
ret
|
|
|
|
.mv: mov eax,MEV_MOVE
|
2006-10-11 22:40:53 +02:00
|
|
|
ret
|
|
|
|
@@: mov bh,al
|
|
|
|
and ebx,0x0101
|
|
|
|
cmp bl,bh
|
|
|
|
je .rb
|
|
|
|
test al,1
|
|
|
|
jz @f
|
|
|
|
mov eax,MEV_LDOWN
|
|
|
|
ret
|
|
|
|
@@: mov eax,MEV_LUP
|
|
|
|
ret
|
|
|
|
.rb: test al,2
|
|
|
|
jz @f
|
|
|
|
mov eax,MEV_RDOWN
|
|
|
|
ret
|
|
|
|
@@: mov eax,MEV_RUP
|
|
|
|
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
|
|
|
mouse_ev dd mouse.l_down,mouse.l_up,mouse.r_down,mouse.r_up,mouse.wheel,mouse.move
|
2006-10-11 22:40:53 +02:00
|
|
|
|
|
|
|
mouse:
|
|
|
|
mov ecx,mst
|
|
|
|
call get_mouse_event
|
|
|
|
cmp [bot_mode],0
|
|
|
|
je @f
|
|
|
|
mov ah,al
|
|
|
|
mov al,4
|
|
|
|
call [bot_dlg_handler]
|
|
|
|
jmp still
|
|
|
|
@@: cmp al,MEV_MOVE
|
|
|
|
jne .no_move
|
|
|
|
cmp [popup_active],1
|
|
|
|
je @f
|
|
|
|
.no_move:
|
|
|
|
mov [s_status],0
|
|
|
|
|
|
|
|
push eax
|
|
|
|
mcall 9,p_info,-1
|
|
|
|
cmp ax,[p_info.window_stack_position]
|
|
|
|
pop eax
|
|
|
|
jne still.skip_write
|
|
|
|
@@:
|
2007-01-28 00:36:07 +01:00
|
|
|
;!!! cmp [just_from_popup],0
|
|
|
|
;!!! je @f
|
|
|
|
;!!! cmp al,MEV_LUP
|
|
|
|
;!!! jne still.skip_write
|
2006-10-11 22:40:53 +02:00
|
|
|
@@: mov [mev],al
|
|
|
|
jmp [mouse_ev+eax*4-4]
|
|
|
|
|
2007-09-01 23:38:00 +02:00
|
|
|
.wheel:
|
|
|
|
movsx eax,word[mst+4]
|
|
|
|
lea eax,[eax*3]
|
|
|
|
add [cur_editor.TopLeft.X],eax
|
|
|
|
movsx eax,word[mst+6]
|
|
|
|
lea eax,[eax*3]
|
|
|
|
add [cur_editor.TopLeft.Y],eax
|
|
|
|
xor eax,eax
|
|
|
|
mov [mst+4],eax
|
|
|
|
call check_bottom_right
|
|
|
|
call draw_editor
|
|
|
|
jmp still.skip_write
|
|
|
|
|
2006-10-11 22:40:53 +02:00
|
|
|
.move:
|
|
|
|
mcall 37,1
|
|
|
|
movsx ebx,ax
|
|
|
|
sar eax,16
|
|
|
|
cmp [body_capt],0
|
|
|
|
jge .check_body.2
|
|
|
|
cmp [vscrl_capt],0
|
|
|
|
jge .check_vscroll.2
|
|
|
|
cmp [hscrl_capt],0
|
|
|
|
jge .check_hscroll.2
|
|
|
|
|
|
|
|
cmp [do_not_draw],0
|
|
|
|
jne still.skip_write
|
|
|
|
mov eax,[mi_cur]
|
|
|
|
call get_active_menu_item
|
|
|
|
cmp eax,[mi_cur]
|
|
|
|
je still.skip_write
|
|
|
|
push [mi_cur]
|
|
|
|
cmp [popup_active],0
|
|
|
|
je @f
|
|
|
|
mov [mi_cur],eax
|
|
|
|
@@: call draw_main_menu
|
|
|
|
pop [mi_cur]
|
|
|
|
cmp [popup_active],0
|
|
|
|
je still.skip_write
|
|
|
|
mov ecx,[mi_cur]
|
|
|
|
or ecx,ecx
|
|
|
|
js still.skip_write
|
|
|
|
mov eax,[main_menu.popups+ecx*4-4]
|
|
|
|
mov edx,main_menu
|
|
|
|
call dword[main_menu.onshow+ecx*4-4]
|
|
|
|
call setup_main_menu_popup
|
|
|
|
mcall 60,2,[h_popup],POPUP_STACK,4
|
|
|
|
|
|
|
|
jmp still.skip_write
|
|
|
|
|
|
|
|
|
|
|
|
.r_down:
|
|
|
|
@@: cmp [popup_active],0
|
|
|
|
je @f
|
|
|
|
mcall 5,1
|
|
|
|
jmp @b
|
|
|
|
@@: cmp [mouse_captured],0
|
|
|
|
jne still.skip_write
|
|
|
|
call check_mouse_in_edit_area
|
|
|
|
jnc still.skip_write
|
|
|
|
mcall 37,0
|
2007-01-03 19:22:05 +01:00
|
|
|
mov [mm.Edit+POPUP.pos],eax
|
2006-10-11 22:40:53 +02:00
|
|
|
@@: mcall 37,2
|
|
|
|
cmp eax,ebx
|
|
|
|
jnz @f
|
|
|
|
mcall 5,1
|
|
|
|
jmp @b
|
|
|
|
@@: and [mst],0xFD
|
|
|
|
call onshow.edit
|
2007-01-03 19:22:05 +01:00
|
|
|
mov dword[POPUP_STACK],mm.Edit
|
2006-10-11 22:40:53 +02:00
|
|
|
mcall 51,1,popup_thread_start,POPUP_STACK
|
|
|
|
mov [h_popup],eax
|
|
|
|
jmp still.skip_write
|
|
|
|
|
|
|
|
.r_up:
|
|
|
|
jmp still.skip_write
|
|
|
|
|
|
|
|
.l_down:
|
|
|
|
call check_mouse_in_edit_area
|
|
|
|
jnc .check_vscroll
|
|
|
|
mov [mouse_captured],1
|
|
|
|
mov [body_capt],1
|
|
|
|
|
|
|
|
call clear_selection
|
|
|
|
|
|
|
|
.check_body.2:
|
2007-01-28 00:36:07 +01:00
|
|
|
sub eax,[cur_editor.Bounds.Left]
|
|
|
|
sub ebx,[cur_editor.Bounds.Top]
|
2007-01-18 22:14:15 +01:00
|
|
|
sub eax,[cur_editor.Gutter.Width]
|
|
|
|
sub eax,LCHGW
|
|
|
|
sub ebx,2
|
2006-10-11 22:40:53 +02:00
|
|
|
push eax
|
|
|
|
mov eax,ebx
|
2007-01-28 00:36:07 +01:00
|
|
|
cdq
|
2006-10-11 22:40:53 +02:00
|
|
|
mov ecx,LINEH
|
|
|
|
idiv ecx
|
2007-01-28 00:36:07 +01:00
|
|
|
@@: add eax,[cur_editor.TopLeft.Y]
|
2006-10-11 22:40:53 +02:00
|
|
|
mov ebx,eax
|
|
|
|
pop eax
|
2007-01-28 00:36:07 +01:00
|
|
|
cdq
|
2006-10-11 22:40:53 +02:00
|
|
|
mov ecx,6
|
|
|
|
idiv ecx
|
2007-01-28 00:36:07 +01:00
|
|
|
@@: add eax,[cur_editor.TopLeft.X]
|
2006-10-11 22:40:53 +02:00
|
|
|
|
2007-01-28 00:36:07 +01:00
|
|
|
cmp eax,[cur_editor.Columns.Count]
|
2006-10-11 22:40:53 +02:00
|
|
|
jl @f
|
2007-01-28 00:36:07 +01:00
|
|
|
mov eax,[cur_editor.Columns.Count]
|
|
|
|
@@: cmp ebx,[cur_editor.Lines.Count]
|
2006-10-11 22:40:53 +02:00
|
|
|
jl @f
|
2007-01-28 00:36:07 +01:00
|
|
|
mov ebx,[cur_editor.Lines.Count]
|
2006-10-11 22:40:53 +02:00
|
|
|
dec ebx
|
|
|
|
@@:
|
2007-01-28 00:36:07 +01:00
|
|
|
cmp [cur_editor.Caret.X],eax
|
2006-10-11 22:40:53 +02:00
|
|
|
jne .change_cur_pos
|
2007-01-28 00:36:07 +01:00
|
|
|
cmp [cur_editor.Caret.Y],ebx
|
|
|
|
jne .change_cur_pos
|
|
|
|
call editor_check_for_changes
|
|
|
|
jmp still.skip_write
|
2006-10-11 22:40:53 +02:00
|
|
|
|
|
|
|
.change_cur_pos:
|
2007-01-28 00:36:07 +01:00
|
|
|
mov [cur_editor.Caret.X],eax
|
|
|
|
mov [cur_editor.Caret.Y],ebx
|
|
|
|
call editor_check_for_changes
|
2006-10-11 22:40:53 +02:00
|
|
|
jmp still
|
|
|
|
|
|
|
|
.check_vscroll:
|
2007-01-18 22:14:15 +01:00
|
|
|
mov ecx,[cur_editor.Bounds.Right]
|
2007-01-28 00:36:07 +01:00
|
|
|
sub ecx,SCRLW-1
|
|
|
|
pushd ecx [cur_editor.Bounds.Top] ecx [cur_editor.Bounds.Bottom]
|
2006-10-11 22:40:53 +02:00
|
|
|
popd [__rc+0xC] [__rc+0x8] [__rc+0x4] [__rc+0x0]
|
2007-01-28 00:36:07 +01:00
|
|
|
add [__rc+0x8],SCRLW-2
|
|
|
|
add [__rc+0x4],SCRLW-1
|
|
|
|
sub [__rc+0xC],SCRLW*2+1
|
2006-10-11 22:40:53 +02:00
|
|
|
mov ecx,__rc
|
|
|
|
call pt_in_rect
|
|
|
|
jnc .check_hscroll
|
|
|
|
|
|
|
|
.check_vscroll.2:
|
2007-01-28 00:36:07 +01:00
|
|
|
sub ebx,[cur_editor.Bounds.Top]
|
|
|
|
sub ebx,SCRLW
|
2006-10-11 22:40:53 +02:00
|
|
|
cmp [vscrl_capt],0
|
|
|
|
jge .vcaptured
|
2007-01-28 00:36:07 +01:00
|
|
|
mov eax,[cur_editor.VScroll.Top]
|
2006-10-11 22:40:53 +02:00
|
|
|
cmp ebx,eax
|
|
|
|
jb .center_vcapture
|
2007-01-28 00:36:07 +01:00
|
|
|
add eax,[cur_editor.VScroll.Size]
|
2006-10-11 22:40:53 +02:00
|
|
|
cmp ebx,eax
|
|
|
|
jae .center_vcapture
|
|
|
|
mov eax,ebx
|
2007-01-28 00:36:07 +01:00
|
|
|
sub eax,[cur_editor.VScroll.Top]
|
2006-10-11 22:40:53 +02:00
|
|
|
dec eax
|
|
|
|
mov [vscrl_capt],eax
|
|
|
|
dec ebx
|
|
|
|
jmp .vcaptured
|
|
|
|
.center_vcapture:
|
2007-01-28 00:36:07 +01:00
|
|
|
mov eax,[cur_editor.VScroll.Size]
|
2006-10-11 22:40:53 +02:00
|
|
|
shr eax,1
|
|
|
|
mov [vscrl_capt],eax
|
|
|
|
.vcaptured:
|
|
|
|
sub ebx,[vscrl_capt]
|
|
|
|
jns @f
|
|
|
|
xor ebx,ebx
|
|
|
|
@@: mov [mouse_captured],1
|
2007-01-28 00:36:07 +01:00
|
|
|
mov eax,[cur_editor.Bounds.Bottom]
|
|
|
|
sub eax,[cur_editor.Bounds.Top]
|
|
|
|
sub eax,[cur_editor.VScroll.Size]
|
|
|
|
sub eax,SCRLW*3
|
2006-10-11 22:40:53 +02:00
|
|
|
cmp eax,ebx
|
|
|
|
jge @f
|
|
|
|
mov ebx,eax
|
|
|
|
@@:
|
2007-01-28 00:36:07 +01:00
|
|
|
mov [cur_editor.VScroll.Top],ebx
|
|
|
|
mov eax,[cur_editor.Lines.Count]
|
2006-10-11 22:40:53 +02:00
|
|
|
sub eax,[lines.scr]
|
|
|
|
imul ebx
|
2007-01-28 00:36:07 +01:00
|
|
|
mov ebx,[cur_editor.Bounds.Bottom]
|
|
|
|
sub ebx,[cur_editor.Bounds.Top]
|
|
|
|
sub ebx,SCRLW*3
|
|
|
|
sub ebx,[cur_editor.VScroll.Size]
|
2006-10-11 22:40:53 +02:00
|
|
|
idiv ebx
|
2007-01-28 00:36:07 +01:00
|
|
|
cmp eax,[cur_editor.TopLeft.Y]
|
2006-10-11 22:40:53 +02:00
|
|
|
je still.skip_write
|
2007-01-28 00:36:07 +01:00
|
|
|
mov [cur_editor.TopLeft.Y],eax
|
2006-10-11 22:40:53 +02:00
|
|
|
call check_bottom_right
|
2007-01-28 00:36:07 +01:00
|
|
|
call draw_editor
|
2006-10-11 22:40:53 +02:00
|
|
|
jmp still.skip_write
|
|
|
|
|
|
|
|
.check_hscroll:
|
2007-01-28 00:36:07 +01:00
|
|
|
pushd [cur_editor.Bounds.Left] [cur_editor.Bounds.Bottom] [cur_editor.Bounds.Right] [cur_editor.Bounds.Bottom]
|
2006-10-11 22:40:53 +02:00
|
|
|
popd [__rc+0xC] [__rc+0x8] [__rc+0x4] [__rc+0x0]
|
2007-01-18 22:14:15 +01:00
|
|
|
add [__rc+0x8],-SCRLW*2-1
|
|
|
|
add [__rc+0x4],-SCRLW+1
|
|
|
|
add [__rc+0xC],-1
|
|
|
|
add [__rc+0x0],SCRLW+1
|
2006-10-11 22:40:53 +02:00
|
|
|
mov ecx,__rc
|
|
|
|
call pt_in_rect
|
|
|
|
jnc .check_main_menu
|
|
|
|
|
|
|
|
.check_hscroll.2:
|
|
|
|
mov ebx,eax
|
2007-01-18 22:14:15 +01:00
|
|
|
sub ebx,SCRLW+1
|
|
|
|
sub ebx,[cur_editor.Bounds.Left]
|
2006-10-11 22:40:53 +02:00
|
|
|
cmp [hscrl_capt],0
|
|
|
|
jge .hcaptured
|
2007-01-28 00:36:07 +01:00
|
|
|
mov eax,[cur_editor.HScroll.Top]
|
2006-10-11 22:40:53 +02:00
|
|
|
cmp ebx,eax
|
|
|
|
jl .center_hcapture
|
2007-01-28 00:36:07 +01:00
|
|
|
add eax,[cur_editor.HScroll.Size]
|
2006-10-11 22:40:53 +02:00
|
|
|
cmp ebx,eax
|
|
|
|
jge .center_hcapture
|
|
|
|
mov eax,ebx
|
2007-01-28 00:36:07 +01:00
|
|
|
sub eax,[cur_editor.HScroll.Top]
|
2006-10-11 22:40:53 +02:00
|
|
|
dec eax
|
|
|
|
mov [hscrl_capt],eax
|
|
|
|
dec ebx
|
|
|
|
jmp .hcaptured
|
|
|
|
.center_hcapture:
|
2007-01-28 00:36:07 +01:00
|
|
|
mov eax,[cur_editor.HScroll.Size]
|
2006-10-11 22:40:53 +02:00
|
|
|
shr eax,1
|
|
|
|
mov [hscrl_capt],eax
|
|
|
|
.hcaptured:
|
|
|
|
sub ebx,[hscrl_capt]
|
|
|
|
jns @f
|
|
|
|
xor ebx,ebx
|
|
|
|
@@: mov [mouse_captured],1
|
2007-01-28 00:36:07 +01:00
|
|
|
mov eax,[cur_editor.Bounds.Right]
|
|
|
|
sub eax,[cur_editor.HScroll.Size]
|
|
|
|
sub eax,SCRLW*3+1
|
2006-10-11 22:40:53 +02:00
|
|
|
cmp eax,ebx
|
|
|
|
jge @f
|
|
|
|
mov ebx,eax
|
|
|
|
@@:
|
2007-01-28 00:36:07 +01:00
|
|
|
mov [cur_editor.HScroll.Top],ebx
|
|
|
|
mov eax,[cur_editor.Columns.Count]
|
2006-10-11 22:40:53 +02:00
|
|
|
sub eax,[columns.scr]
|
|
|
|
imul ebx
|
2007-01-28 00:36:07 +01:00
|
|
|
mov ebx,[cur_editor.Bounds.Right]
|
|
|
|
sub ebx,SCRLW*3+1
|
|
|
|
sub ebx,[cur_editor.HScroll.Size]
|
2006-10-11 22:40:53 +02:00
|
|
|
idiv ebx
|
2007-01-28 00:36:07 +01:00
|
|
|
cmp eax,[cur_editor.TopLeft.X]
|
2006-10-11 22:40:53 +02:00
|
|
|
je still.skip_write
|
2007-01-28 00:36:07 +01:00
|
|
|
mov [cur_editor.TopLeft.X],eax
|
2006-10-11 22:40:53 +02:00
|
|
|
call check_bottom_right
|
2007-01-28 00:36:07 +01:00
|
|
|
call draw_editor
|
2006-10-11 22:40:53 +02:00
|
|
|
jmp still.skip_write
|
|
|
|
|
|
|
|
.check_main_menu:
|
|
|
|
cmp [do_not_draw],0
|
|
|
|
jne .capture_off
|
|
|
|
|
|
|
|
@@: mcall 37,2
|
|
|
|
test eax,0x01
|
|
|
|
jz @f
|
|
|
|
mcall 5,1
|
|
|
|
jmp @b
|
|
|
|
@@: and [mst],0xFE
|
|
|
|
|
|
|
|
cmp [mi_cur],0
|
|
|
|
jle .capture_off
|
|
|
|
mov ecx,[mi_cur]
|
|
|
|
mov eax,[main_menu.popups+ecx*4-4]
|
|
|
|
mov edx,main_menu
|
|
|
|
call dword[main_menu.onshow+ecx*4-4]
|
|
|
|
call setup_main_menu_popup
|
|
|
|
mcall 51,1,popup_thread_start,POPUP_STACK
|
|
|
|
mov [h_popup],eax
|
|
|
|
|
|
|
|
.l_up:
|
|
|
|
.capture_off:
|
|
|
|
or eax,-1
|
|
|
|
mov [vscrl_capt],eax
|
|
|
|
mov [hscrl_capt],eax
|
|
|
|
mov [body_capt],eax
|
|
|
|
mov [mouse_captured],0
|
2007-01-28 00:36:07 +01:00
|
|
|
;!!! mov [just_from_popup],0
|
2006-10-11 22:40:53 +02:00
|
|
|
jmp still.skip_write
|