Subversion Repositories Kolibri OS

Rev

Rev 280 | Rev 824 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. func check_mouse_in_edit_area
  2.         mcall   37,1
  3.         mov     ebx,eax
  4.         and     ebx,0x0000FFFF
  5.         shr     eax,16
  6.         mov     ecx,[cur_editor.Bounds.Top]
  7.         inc     ecx
  8.         pushd   [cur_editor.Bounds.Left] ecx [cur_editor.Bounds.Right] ecx
  9.         popd    [__rc+0xC] [__rc+0x8] [__rc+0x4] [__rc+0x0]
  10.         sub     [__rc+0x8],SCRLW+6
  11.         mov     ecx,[cur_editor.Gutter.Width]
  12.         add     [__rc+0x0],ecx
  13.         imul    ecx,[lines.scr],LINEH
  14.         dec     ecx
  15.         add     [__rc+0xC],ecx
  16.         mov     ecx,__rc
  17.         call    pt_in_rect
  18.         ret
  19. endf
  20.  
  21. func get_mouse_event
  22.         mcall   37,2
  23.         and     al,3
  24.         mov     bl,[ecx]
  25.         cmp     [ecx],al
  26.         mov     [ecx],al
  27.         jne     @f
  28.         mov     eax,MEV_MOVE
  29.         ret
  30.     @@: mov     bh,al
  31.         and     ebx,0x0101
  32.         cmp     bl,bh
  33.         je      .rb
  34.         test    al,1
  35.         jz      @f
  36.         mov     eax,MEV_LDOWN
  37.         ret
  38.     @@: mov     eax,MEV_LUP
  39.         ret
  40.   .rb:  test    al,2
  41.         jz      @f
  42.         mov     eax,MEV_RDOWN
  43.         ret
  44.     @@: mov     eax,MEV_RUP
  45.         ret
  46. endf
  47.  
  48. mouse_ev dd mouse.l_down,mouse.l_up,mouse.r_down,mouse.r_up,mouse.move
  49.  
  50. mouse:
  51.         mov     ecx,mst
  52.         call    get_mouse_event
  53.         cmp     [bot_mode],0
  54.         je      @f
  55.         mov     ah,al
  56.         mov     al,4
  57.         call    [bot_dlg_handler]
  58.         jmp     still
  59.     @@: cmp     al,MEV_MOVE
  60.         jne     .no_move
  61.         cmp     [popup_active],1
  62.         je      @f
  63.   .no_move:
  64.         mov     [s_status],0
  65.  
  66.         push    eax
  67.         mcall   9,p_info,-1
  68.         cmp     ax,[p_info.window_stack_position]
  69.         pop     eax
  70.         jne     still.skip_write
  71.     @@:
  72. ;!!!        cmp     [just_from_popup],0
  73. ;!!!        je      @f
  74. ;!!!        cmp     al,MEV_LUP
  75. ;!!!        jne     still.skip_write
  76.     @@: mov     [mev],al
  77.         jmp     [mouse_ev+eax*4-4]
  78.  
  79.   .move:
  80.         mcall   37,1
  81.         movsx   ebx,ax
  82.         sar     eax,16
  83.         cmp     [body_capt],0
  84.         jge     .check_body.2
  85.         cmp     [vscrl_capt],0
  86.         jge     .check_vscroll.2
  87.         cmp     [hscrl_capt],0
  88.         jge     .check_hscroll.2
  89.  
  90.         cmp     [do_not_draw],0
  91.         jne     still.skip_write
  92.         mov     eax,[mi_cur]
  93.         call    get_active_menu_item
  94.         cmp     eax,[mi_cur]
  95.         je      still.skip_write
  96.         push    [mi_cur]
  97.         cmp     [popup_active],0
  98.         je      @f
  99.         mov     [mi_cur],eax
  100.     @@: call    draw_main_menu
  101.         pop     [mi_cur]
  102.         cmp     [popup_active],0
  103.         je      still.skip_write
  104.         mov     ecx,[mi_cur]
  105.         or      ecx,ecx
  106.         js      still.skip_write
  107.         mov     eax,[main_menu.popups+ecx*4-4]
  108.         mov     edx,main_menu
  109.         call    dword[main_menu.onshow+ecx*4-4]
  110.         call    setup_main_menu_popup
  111.         mcall   60,2,[h_popup],POPUP_STACK,4
  112.  
  113.         jmp     still.skip_write
  114.  
  115.  
  116.   .r_down:
  117.     @@: cmp     [popup_active],0
  118.         je      @f
  119.         mcall   5,1
  120.         jmp     @b
  121.     @@: cmp     [mouse_captured],0
  122.         jne     still.skip_write
  123.         call    check_mouse_in_edit_area
  124.         jnc     still.skip_write
  125.         mcall   37,0
  126.         mov     [mm.Edit+POPUP.pos],eax
  127.     @@: mcall   37,2
  128.         cmp     eax,ebx
  129.         jnz     @f
  130.         mcall   5,1
  131.         jmp     @b
  132.     @@: and     [mst],0xFD
  133.         call    onshow.edit
  134.         mov     dword[POPUP_STACK],mm.Edit
  135.         mcall   51,1,popup_thread_start,POPUP_STACK
  136.         mov     [h_popup],eax
  137.         jmp     still.skip_write
  138.  
  139.   .r_up:
  140.         jmp     still.skip_write
  141.  
  142.   .l_down:
  143.         call    check_mouse_in_edit_area
  144.         jnc     .check_vscroll
  145.         mov     [mouse_captured],1
  146.         mov     [body_capt],1
  147.  
  148.         call    clear_selection
  149.  
  150.   .check_body.2:
  151.         sub     eax,[cur_editor.Bounds.Left]
  152.         sub     ebx,[cur_editor.Bounds.Top]
  153.         sub     eax,[cur_editor.Gutter.Width]
  154.         sub     eax,LCHGW
  155.         sub     ebx,2
  156.         push    eax
  157.         mov     eax,ebx
  158.         cdq
  159.         mov     ecx,LINEH
  160.         idiv    ecx
  161.     @@: add     eax,[cur_editor.TopLeft.Y]
  162.         mov     ebx,eax
  163.         pop     eax
  164.         cdq
  165.         mov     ecx,6
  166.         idiv    ecx
  167.     @@: add     eax,[cur_editor.TopLeft.X]
  168.  
  169.         cmp     eax,[cur_editor.Columns.Count]
  170.         jl      @f
  171.         mov     eax,[cur_editor.Columns.Count]
  172.     @@: cmp     ebx,[cur_editor.Lines.Count]
  173.         jl      @f
  174.         mov     ebx,[cur_editor.Lines.Count]
  175.         dec     ebx
  176.     @@:
  177.         cmp     [cur_editor.Caret.X],eax
  178.         jne     .change_cur_pos
  179.         cmp     [cur_editor.Caret.Y],ebx
  180.         jne     .change_cur_pos
  181.         call    editor_check_for_changes
  182.         jmp     still.skip_write
  183.  
  184.   .change_cur_pos:
  185.         mov     [cur_editor.Caret.X],eax
  186.         mov     [cur_editor.Caret.Y],ebx
  187.         call    editor_check_for_changes
  188.         jmp     still
  189.  
  190.   .check_vscroll:
  191.         mov     ecx,[cur_editor.Bounds.Right]
  192.         sub     ecx,SCRLW-1
  193.         pushd   ecx [cur_editor.Bounds.Top] ecx [cur_editor.Bounds.Bottom]
  194.         popd    [__rc+0xC] [__rc+0x8] [__rc+0x4] [__rc+0x0]
  195.         add     [__rc+0x8],SCRLW-2
  196.         add     [__rc+0x4],SCRLW-1
  197.         sub     [__rc+0xC],SCRLW*2+1
  198.         mov     ecx,__rc
  199.         call    pt_in_rect
  200.         jnc     .check_hscroll
  201.  
  202.   .check_vscroll.2:
  203.         sub     ebx,[cur_editor.Bounds.Top]
  204.         sub     ebx,SCRLW
  205.         cmp     [vscrl_capt],0
  206.         jge     .vcaptured
  207.         mov     eax,[cur_editor.VScroll.Top]
  208.         cmp     ebx,eax
  209.         jb      .center_vcapture
  210.         add     eax,[cur_editor.VScroll.Size]
  211.         cmp     ebx,eax
  212.         jae     .center_vcapture
  213.         mov     eax,ebx
  214.         sub     eax,[cur_editor.VScroll.Top]
  215.         dec     eax
  216.         mov     [vscrl_capt],eax
  217.         dec     ebx
  218.         jmp     .vcaptured
  219.   .center_vcapture:
  220.         mov     eax,[cur_editor.VScroll.Size]
  221.         shr     eax,1
  222.         mov     [vscrl_capt],eax
  223.   .vcaptured:
  224.         sub     ebx,[vscrl_capt]
  225.         jns     @f
  226.         xor     ebx,ebx
  227.     @@: mov     [mouse_captured],1
  228.         mov     eax,[cur_editor.Bounds.Bottom]
  229.         sub     eax,[cur_editor.Bounds.Top]
  230.         sub     eax,[cur_editor.VScroll.Size]
  231.         sub     eax,SCRLW*3
  232.         cmp     eax,ebx
  233.         jge     @f
  234.         mov     ebx,eax
  235.     @@:
  236.         mov     [cur_editor.VScroll.Top],ebx
  237.         mov     eax,[cur_editor.Lines.Count]
  238.         sub     eax,[lines.scr]
  239.         imul    ebx
  240.         mov     ebx,[cur_editor.Bounds.Bottom]
  241.         sub     ebx,[cur_editor.Bounds.Top]
  242.         sub     ebx,SCRLW*3
  243.         sub     ebx,[cur_editor.VScroll.Size]
  244.         idiv    ebx
  245.         cmp     eax,[cur_editor.TopLeft.Y]
  246.         je      still.skip_write
  247.         mov     [cur_editor.TopLeft.Y],eax
  248.         call    check_bottom_right
  249.         call    draw_editor
  250.         jmp     still.skip_write
  251.  
  252.   .check_hscroll:
  253.         pushd   [cur_editor.Bounds.Left] [cur_editor.Bounds.Bottom] [cur_editor.Bounds.Right] [cur_editor.Bounds.Bottom]
  254.         popd    [__rc+0xC] [__rc+0x8] [__rc+0x4] [__rc+0x0]
  255.         add     [__rc+0x8],-SCRLW*2-1
  256.         add     [__rc+0x4],-SCRLW+1
  257.         add     [__rc+0xC],-1
  258.         add     [__rc+0x0],SCRLW+1
  259.         mov     ecx,__rc
  260.         call    pt_in_rect
  261.         jnc     .check_main_menu
  262.  
  263.   .check_hscroll.2:
  264.         mov     ebx,eax
  265.         sub     ebx,SCRLW+1
  266.         sub     ebx,[cur_editor.Bounds.Left]
  267.         cmp     [hscrl_capt],0
  268.         jge     .hcaptured
  269.         mov     eax,[cur_editor.HScroll.Top]
  270.         cmp     ebx,eax
  271.         jl      .center_hcapture
  272.         add     eax,[cur_editor.HScroll.Size]
  273.         cmp     ebx,eax
  274.         jge     .center_hcapture
  275.         mov     eax,ebx
  276.         sub     eax,[cur_editor.HScroll.Top]
  277.         dec     eax
  278.         mov     [hscrl_capt],eax
  279.         dec     ebx
  280.         jmp     .hcaptured
  281.   .center_hcapture:
  282.         mov     eax,[cur_editor.HScroll.Size]
  283.         shr     eax,1
  284.         mov     [hscrl_capt],eax
  285.   .hcaptured:
  286.         sub     ebx,[hscrl_capt]
  287.         jns     @f
  288.         xor     ebx,ebx
  289.     @@: mov     [mouse_captured],1
  290.         mov     eax,[cur_editor.Bounds.Right]
  291.         sub     eax,[cur_editor.HScroll.Size]
  292.         sub     eax,SCRLW*3+1
  293.         cmp     eax,ebx
  294.         jge     @f
  295.         mov     ebx,eax
  296.     @@:
  297.         mov     [cur_editor.HScroll.Top],ebx
  298.         mov     eax,[cur_editor.Columns.Count]
  299.         sub     eax,[columns.scr]
  300.         imul    ebx
  301.         mov     ebx,[cur_editor.Bounds.Right]
  302.         sub     ebx,SCRLW*3+1
  303.         sub     ebx,[cur_editor.HScroll.Size]
  304.         idiv    ebx
  305.         cmp     eax,[cur_editor.TopLeft.X]
  306.         je      still.skip_write
  307.         mov     [cur_editor.TopLeft.X],eax
  308.         call    check_bottom_right
  309.         call    draw_editor
  310.         jmp     still.skip_write
  311.  
  312.   .check_main_menu:
  313.         cmp     [do_not_draw],0
  314.         jne     .capture_off
  315.  
  316.     @@: mcall   37,2
  317.         test    eax,0x01
  318.         jz      @f
  319.         mcall   5,1
  320.         jmp     @b
  321.     @@: and     [mst],0xFE
  322.  
  323.         cmp     [mi_cur],0
  324.         jle     .capture_off
  325.         mov     ecx,[mi_cur]
  326.         mov     eax,[main_menu.popups+ecx*4-4]
  327.         mov     edx,main_menu
  328.         call    dword[main_menu.onshow+ecx*4-4]
  329.         call    setup_main_menu_popup
  330.         mcall   51,1,popup_thread_start,POPUP_STACK
  331.         mov     [h_popup],eax
  332.  
  333.   .l_up:
  334.   .capture_off:
  335.         or      eax,-1
  336.         mov     [vscrl_capt],eax
  337.         mov     [hscrl_capt],eax
  338.         mov     [body_capt],eax
  339.         mov     [mouse_captured],0
  340. ;!!!        mov     [just_from_popup],0
  341.         jmp     still.skip_write
  342.