Subversion Repositories Kolibri OS

Rev

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

  1. macro use_key_no_process  up,down,esc,enter,tab,numl,capsl,scrolll
  2. {
  3. if up eq
  4. else
  5.         cmp     ah,177
  6.         jz      edit_box.editbox_exit
  7. end if
  8. if down eq
  9. else
  10.         cmp     ah,178
  11.         jz      edit_box.editbox_exit
  12. end if
  13. if esc eq
  14. else
  15.         cmp     ah,27   ;ESC - ª« ¢¨è  ))
  16.         jz      edit_box.editbox_exit
  17. end if
  18. if enter eq
  19. else
  20.         cmp     ah,13   ;ENTER - ª« ¢¨è  ))
  21.         jz      edit_box.editbox_exit
  22. end if
  23. if tab eq
  24. else
  25.         cmp     ah,9   ;TAB - ª« ¢¨è  ))
  26.         jz      edit_box.editbox_exit
  27. end if
  28. if numl eq
  29. else
  30.         cmp     ah,4   ;Num Lock - ª« ¢¨è  ))
  31.         jz      edit_box.editbox_exit
  32. end if
  33. if capsl eq
  34. else
  35.         cmp     ah,2   ;Caps Lock - ª« ¢¨è  ))
  36.         jz      edit_box.editbox_exit
  37. end if
  38. if scrolll eq
  39. else
  40.         cmp     ah,1   ;Scroll Lock - ª« ¢¨è  ))
  41.         jz      edit_box.editbox_exit
  42. end if
  43. }
  44.  
  45.  
  46. align 16
  47. edit_box:
  48. .draw:
  49.         pushad
  50.         mov     edi,[esp+36]
  51.         and     dword ed_text_color,17FFFFFFh
  52.         mov     ecx,ed_text_color
  53.         mov     ebx,ecx
  54.         shr     ecx,28
  55.         shl     ebx,4
  56.         shr     ebx,28
  57.         inc     ebx
  58.         mov     eax,6
  59.         jecxz   @f
  60.         mov     al, 8
  61. @@:
  62.         mul     bl
  63.         mov     ed_char_width,eax
  64.         mov     al, 9
  65.         jecxz   @f
  66.         mov     al, 16
  67. @@:
  68.         mul     bl
  69.         add     eax,4
  70.         mov     ed_height,eax
  71.         call    .draw_border
  72. .draw_bg_cursor_text:
  73.         call    .check_offset
  74.         call    .draw_bg
  75.         call    .draw_shift
  76. .draw_cursor_text:
  77.         call    .draw_text
  78.         test    word ed_flags,ed_focus
  79.         jz      .editbox_exit
  80.         call    .draw_cursor
  81. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  82. ;Ž¡é¨© ¢ë室 ¨§ editbox ¤«ï ¢á¥å ä㭪権 ¨ ¯®áâ ®¡à ¡®â稪®¢;;
  83. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  84. .editbox_exit:
  85.         popad
  86.         ret 4
  87.  
  88. ;==========================================================
  89. ;=== ®¡à ¡®âª  ª« ¢¨ âãàë =================================
  90. ;==========================================================
  91. align 16
  92. edit_box_key:
  93.         pushad
  94.         mov     edi,[esp+36]
  95.         test    word ed_flags,ed_focus ; ¥á«¨ ­¥ ¢ 䮪ãá¥, ¢ë室¨¬
  96.         jz      edit_box.editbox_exit
  97.         test    word ed_flags,ed_mouse_on or ed_disabled
  98.         jnz     edit_box.editbox_exit
  99. ;--------------------------------------
  100. ; this code for Win-keys, works with
  101. ; kernel SVN r.3356 or later
  102.         push    eax
  103.         push    ebx
  104.         mcall   SF_KEYBOARD,SSF_GET_CONTROL_KEYS
  105.         test    ax,0x200        ; LWin
  106.         jnz     .win_key_pressed
  107.         test    ax,0x400        ; RWin
  108.         jz      @f
  109. .win_key_pressed:
  110.         pop     ebx
  111.         pop     eax
  112.         jmp     edit_box.editbox_exit
  113.  
  114. @@:     pop     ebx
  115.         pop     eax
  116. ;--------------------------------------
  117. ;à®¢¥àª  ­ ¦ â shift ?
  118.         call    edit_box_key.check_shift_ctrl_alt
  119. ;----------------------------------------------------------
  120. ;--- ¯à®¢¥à塞, çâ® ­ ¦ â® --------------------------------
  121. ;----------------------------------------------------------
  122.         cmp     ah,8
  123.         jz      edit_box_key.backspace
  124.         cmp     ah,0xb6
  125.         jz      edit_box_key.delete
  126.         cmp     ah,176
  127.         jz      edit_box_key.left
  128.         cmp     ah,179
  129.         jz      edit_box_key.right
  130.         cmp     ah,180
  131.         jz      edit_box_key.home
  132.         cmp     ah,181
  133.         jz      edit_box_key.end
  134.         cmp     ah,185  ;insert
  135.         jz      edit_box_key.insert
  136. ; ª®¬¡¨­ æ¨¨ Ctrl + ª« ¢¨è 
  137.         test    word ed_flags,ed_ctrl_on
  138.         jz      @f
  139. ; ¯à®¢¥àª  ᪠­ª®¤ 
  140.         ror     eax,8
  141.         cmp     ah,45 ; Ctrl + X
  142.         je      edit_box_key.ctrl_x        
  143.         cmp     ah,46 ; Ctrl + C
  144.         je      edit_box_key.ctrl_c
  145.         cmp     ah,47 ; Ctrl + V
  146.         je      edit_box_key.ctrl_v
  147.         rol     eax,8
  148. @@:
  149. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  150. ;‡ £«ã誠 ­  ®¡à ¡®âªã ª« ¢¨è ¢¢¥àå ¨ ¢­¨§ â.¥. ¯à¨ ®¡­ à㦥­¨¨ íâ¨å ª®¤®¢ ¯à®¨á室¨â ¢ë室 ¨§ ®¡à ¡®â稪 
  151. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  152. use_key_no_process   up,down,esc,enter,tab,numl,capsl,scrolll
  153. ;--- ­ ¦ â  ¤àã£ ï ª« ¢¨è  ---
  154. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  155. ;à®¢¥àª  ãáâ ­®¢«¥­ «¨ ä« £ ¯à¨ ª®â®à®¬ ­ã¦­® ¢ë¢®¤¨âì ⮫쪮 æ¨äàë ¢ ­ã¦­®¬ ¡®ªá¥, ¥á«¨ â ª®© ­¥®¡å®¤¨¬®á⨠­¥â, ­ã¦­® § ª®¬¥­â¨à®¢ âì ¬ ªà®á
  156. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  157.         test    word ed_flags,ed_figure_only  ; ⮫쪮 æ¨äàë?
  158.         jz      @f
  159.         cmp     ah,'0'
  160.         jb      edit_box.editbox_exit
  161.         cmp     ah,'9'
  162.         ja      edit_box.editbox_exit
  163. @@:
  164.  
  165. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  166. ;¯à®¢¥àª  ­  shift, ¡ë« «¨ ­ ¦ â
  167. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  168.         test    word ed_flags,ed_shift_on
  169.         je      @f
  170. ; edx = ed_size, ecx = ed_pos
  171.         push    eax
  172.         mov     edx,ed_size
  173.         mov     ecx, ed_pos
  174.         pusha
  175. ; clear input area
  176.         mov     ebp,ed_color
  177.         movzx   ebx, word ed_shift_pos
  178.         call    edit_box_key.sh_cl_
  179.         mov     ebp,ed_size
  180.         call    edit_box_key.clear_bg
  181.         popa
  182.         call    edit_box_key.del_char
  183.         mov     ebx,ed_size
  184.         sub     bx,ed_shift_pos
  185.         mov     ed_size,ebx
  186.         pop     eax
  187. @@:
  188.  
  189. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  190. ; ¯à®¢¥à塞, ­ å®¤¨âáï «¨ ªãàá®à ¢ ª®­æ¥ + ¤ «ì­¥©è ï ®¡à ¡®âª 
  191. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  192.         mov     ecx,ed_size
  193.         mov     edx, ed_max
  194.         test    word ed_flags,ed_insert
  195.         jne     @f
  196.         cmp     ecx,edx
  197.         jae     edit_box.editbox_exit
  198. @@:     mov     ebx, ed_pos
  199.         cmp     ebx,edx
  200.         jnl     edit_box.editbox_exit
  201.         mov     ecx,ed_size
  202.         push    edi eax
  203.         mov     ebp,edi
  204.         mov     esi,ed_text
  205.         add     esi,ecx
  206.         mov     edi,esi
  207.         cmp     ecx,ebx
  208.         je      edit_box_key.In_k
  209.         test    dword bp_flags,ed_insert
  210.         jne     edit_box_key.ins_v
  211.         pusha
  212.         mov     edi,ebp
  213.         mov     ebp,ed_size
  214.         call    edit_box_key.clear_bg
  215.         popa
  216.         sub     ecx,ebx
  217.         inc     edi
  218.         std
  219.         inc     ecx
  220. @@:
  221.         lodsb
  222.         stosb
  223.         loop    @b
  224. edit_box_key.In_k:
  225.         cld
  226.         pop     eax
  227.         mov     al,ah
  228.         stosb
  229.         pop     edi
  230.         inc     dword ed_size
  231.         inc     dword ed_pos
  232.         call    edit_box_key.draw_all2
  233.         jmp     edit_box_key.shift
  234.  
  235. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  236. ;Ž¡à ¡®âª  ª« ¢¨è insert,delete.backspace,home,end,left,right
  237. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  238. edit_box_key.insert:
  239.         test    word ed_flags,ed_insert
  240.         je      @f
  241.         and     word ed_flags,ed_insert_cl
  242.         jmp     edit_box.editbox_exit
  243.  
  244. @@:     or      word ed_flags,ed_insert
  245.         jmp     edit_box.editbox_exit
  246.  
  247. edit_box_key.ins_v:
  248.         dec     dword bp_size
  249.         sub     esi,ecx
  250.         add     esi,ebx
  251.         mov     edi,esi
  252.         pusha
  253.         mov     edi,ebp
  254.         mov     ebp,ed_pos
  255.         call    edit_box_key.clear_bg
  256.         popa
  257.         jmp     edit_box_key.In_k
  258.  
  259. edit_box_key.delete:
  260.         mov     edx,ed_size
  261.         mov     ecx,ed_pos
  262.         cmp     edx,ecx
  263.         jg      edit_box_key.bac_del
  264.         test    word ed_flags,ed_shift_on
  265.         jne     edit_box_key.del_bac
  266.         popad
  267.         ret     4
  268.  
  269. edit_box_key.bac_del:
  270.         call    edit_box_key.del_char
  271.         jmp     edit_box_key.draw_all
  272.  
  273. edit_box_key.backspace:
  274.         test    word ed_flags,ed_shift_on
  275.         jne     edit_box_key.delete
  276.         mov     ecx,ed_pos
  277.         test    ecx,ecx
  278.         jnz     edit_box_key.del_bac
  279.         popad
  280.         ret     4
  281.  
  282. edit_box_key.del_bac:
  283.         mov     edx,ed_size
  284.         cmp     edx,ecx ;if ed_pos=ed_size
  285.         je      @f
  286.         dec     ecx
  287.         call    edit_box_key.del_char
  288. @@:     test    word ed_flags,ed_shift_on
  289.         jne     edit_box_key.bac_del
  290.         dec     dword ed_pos
  291. edit_box_key.draw_all:
  292.         push    edit_box_key.shift
  293.         test    word ed_flags,ed_shift_on
  294.         je      @f
  295.         movzx   eax, word ed_shift_pos
  296.         mov     ebx,ed_size
  297.         sub     ebx,eax
  298.         mov     ed_size,ebx
  299.         mov     ebp,ed_color
  300.         call    edit_box.clear_cursor
  301.         call    edit_box.check_offset        
  302.         and     word ed_flags,ed_shift_cl
  303.         jmp     edit_box.draw_bg
  304.  
  305. @@:     dec     dword ed_size
  306. edit_box_key.draw_all2:
  307.         and     word ed_flags,ed_shift_cl
  308.         mov     ebp,ed_color
  309.         call    edit_box.clear_cursor
  310.         call    edit_box.check_offset
  311.         mov     ebp,ed_size
  312.         jmp     edit_box_key.clear_bg
  313.  
  314. ;--- ­ ¦ â  ª« ¢¨è  left ---
  315. edit_box_key.left:
  316.         mov     ebx,ed_pos
  317.         test    ebx,ebx
  318.         jz      edit_box_key.sh_st_of
  319.         or      word ed_flags,ed_left_fl
  320.         call    edit_box_key.sh_first_sh
  321.         dec     dword ed_pos
  322.         call    edit_box.draw_bg
  323.         call    edit_box.draw_shift
  324.         call    edit_box_key.sh_enable
  325.         jmp     edit_box.draw_cursor_text
  326.  
  327. ;--- ­ ¦ â  ª« ¢¨è  right ---
  328. edit_box_key.right:
  329.         mov     ebx,ed_pos
  330.         cmp     ebx,ed_size
  331.         je      edit_box_key.sh_st_of
  332.         and     word ed_flags,ed_right_fl
  333.         call    edit_box_key.sh_first_sh
  334.         inc     dword ed_pos
  335.         call    edit_box.draw_bg
  336.         call    edit_box.draw_shift
  337.         call    edit_box_key.sh_enable
  338.         jmp     edit_box.draw_cursor_text
  339.  
  340. edit_box_key.home:
  341.         mov     ebx,ed_pos
  342.         test    ebx,ebx
  343.         jz      edit_box_key.sh_st_of
  344.         call    edit_box_key.sh_first_sh
  345.         xor     eax,eax
  346.         mov     ed_pos,eax
  347.         call    edit_box.draw_bg
  348.         call    edit_box.draw_shift
  349.         call    edit_box_key.sh_home_end
  350.         jmp     edit_box.draw_cursor_text
  351.  
  352. ;--- ­ ¦ â  ª« ¢¨è  end ---
  353. edit_box_key.end:
  354.         mov     ebx,ed_pos
  355.         cmp     ebx,ed_size
  356.         je      edit_box_key.sh_st_of
  357.         call    edit_box_key.sh_first_sh
  358.         mov     eax,ed_size
  359.         mov     ed_pos,eax
  360.         call    edit_box.draw_bg
  361.         call    edit_box.draw_shift
  362.         call    edit_box_key.sh_home_end
  363.         jmp     edit_box.draw_cursor_text
  364. ;----------------------------------------
  365. StrInsert:
  366. ; SizeOf(TmpBuf) >= StrLen(Src) + StrLen(Dst) + 1              
  367. Dst    equ [esp + 16] ; - destination buffer
  368. Src    equ [esp + 12] ; - source to insert from
  369. Pos    equ [esp + 8] ; - position for insert
  370. DstMax equ [esp + 4]  ; - maximum Dst length(exclude terminating null)
  371. SrcCount equ [esp - 4]
  372. DstCount equ [esp - 8]
  373. TmpBuf   equ [esp - 12]  ; - temporary buffer
  374.         mov    edi, Src
  375.         mov    ecx, -1
  376.         xor    eax, eax
  377.         repne scasb
  378.         mov    eax, -2
  379.         sub    eax, ecx
  380.         mov    SrcCount, eax                
  381.         mov    edi, Dst
  382.         add    edi, Pos
  383.         mov    ecx, -1
  384.         xor    eax, eax
  385.         repne scasb
  386.         mov    eax, -2
  387.         sub    eax, ecx
  388.         inc    eax
  389.         mov    DstCount, eax                
  390.         mov    ecx, eax
  391.         add    ecx, SrcCount
  392.         add    ecx, Pos
  393.         mcall   SF_SYS_MISC,SSF_MEM_ALLOC
  394.         mov    TmpBuf, eax          
  395.         mov    esi, Dst
  396.         mov    edi, TmpBuf
  397.         mov    ecx, Pos
  398.         mov    edx, ecx
  399.         rep movsb        
  400.         mov    esi, Src
  401.         mov    edi, TmpBuf
  402.         add    edi, Pos
  403.         mov    ecx, SrcCount
  404.         add    edx, ecx
  405.         rep movsb        
  406.         mov    esi, Pos
  407.         add    esi, Dst
  408.         mov    ecx, DstCount
  409.         add    edx, ecx
  410.         rep movsb        
  411.         mov    esi, TmpBuf
  412.         mov    edi, Dst
  413. ; ecx = MIN(edx, DstSize)        
  414.         cmp    edx, DstMax
  415.         sbb    ecx, ecx                                  
  416.         and    edx, ecx
  417.         not    ecx
  418.         and    ecx, DstMax
  419.         add    ecx, edx                                  
  420.         mov    eax, ecx ; return total length
  421.         rep movsb        
  422.         mov    ecx, TmpBuf
  423.         mcall   SF_SYS_MISC,SSF_MEM_FREE                                
  424.         ret    16
  425. restore Dst    
  426. restore Src      
  427. restore Pos    
  428. restore DstSize
  429. restore TmpBuf
  430. restore SrcCount
  431. restore DstCount
  432. ;----------------------------------------        
  433. edit_box_key.ctrl_x:
  434.         test   word ed_flags,ed_shift_on
  435.         jz     edit_box.editbox_exit        
  436.         push    dword 'X'  ; this value need below to determine which action is used
  437.         jmp     edit_box_key.ctrl_c.pushed
  438.        
  439. edit_box_key.ctrl_c:
  440.         test   word ed_flags,ed_shift_on
  441.         jz     edit_box.editbox_exit
  442.         push    dword 'C'  ; this value need below to determine which action is used
  443. .pushed:        
  444. ; add memory area
  445.         mov     ecx,ed_size
  446.         add     ecx,3*4
  447.         mcall   SF_SYS_MISC,SSF_MEM_ALLOC
  448. ; building the clipboard slot header
  449.         xor     ecx,ecx
  450.         mov     [eax+4],ecx ; type 'text'
  451.         inc     ecx
  452.         mov     [eax+8],ecx ; cp866 text encoding
  453.         mov     ecx,ed_pos      
  454.         movzx   ebx,word ed_shift_pos
  455.         sub     ecx,ebx
  456. .abs: ; make ecx = abs(ecx)
  457.                neg     ecx
  458.                jl            .abs
  459.         add     ecx,3*4
  460.         mov     [eax],ecx
  461.         sub     ecx,3*4        
  462.         mov     edx,ed_pos
  463.         movzx   ebx,word ed_shift_pos
  464.         cmp     edx,ebx
  465.         jle     @f
  466.         mov     edx,ebx
  467. @@:        
  468. ; copy data
  469.         mov     esi,ed_text
  470.         add     esi,edx
  471.         push    edi
  472.         mov     edi,eax
  473.         add     edi,3*4
  474.         cld
  475.         rep     movsb
  476.         pop     edi
  477. ; put slot to the kernel clipboard
  478.         mov     edx,eax
  479.         mov     ecx,[edx]
  480.         push    eax
  481.         mcall   SF_CLIPBOARD,SSF_WRITE_CB
  482.         pop     ecx
  483. ; remove unnecessary memory area
  484.         mcall   SF_SYS_MISC,SSF_MEM_FREE
  485. .exit:
  486.         pop     eax        ; determine current action (ctrl+X or ctrl+C)
  487.         cmp     eax, 'X'
  488.         je      edit_box_key.delete
  489.         jmp     edit_box.editbox_exit
  490.  
  491. edit_box_key.ctrl_v:
  492.         mcall   SF_CLIPBOARD,SSF_GET_SLOT_COUNT
  493. ; no slots of clipboard ?
  494.         test    eax,eax
  495.         jz      .exit
  496. ; main list area not found ?
  497.         inc     eax
  498.         test    eax,eax
  499.         jz      .exit
  500.         sub     eax,2
  501.         mov     ecx,eax
  502.         mcall   SF_CLIPBOARD,SSF_READ_CB
  503. ; main list area not found ?
  504.         inc     eax
  505.         test    eax,eax
  506.         jz      .exit
  507. ; error ?
  508.         sub     eax,2
  509.         test    eax,eax
  510.         jz      .exit
  511.         inc     eax
  512. ; check contents of container
  513.         mov     ebx,[eax+4]
  514. ; check for text
  515.         test    ebx,ebx
  516.         jnz     .no_valid_text
  517.         mov     ebx,[eax+8]
  518. ; check for cp866
  519.         cmp     bl,1
  520.         jnz     .no_valid_text
  521. ; if something selected then need to delete it        
  522.         test   word ed_flags,ed_shift_on
  523.         jz     .selected_done
  524.         push   eax; dummy parameter ; need to
  525.         push   dword .selected_done ; correctly return
  526.         pushad                      ; from edit_box_key.delete
  527.         jmp    edit_box_key.delete
  528. .selected_done:        
  529.         mov     ecx,[eax]
  530.         sub     ecx,3*4
  531. ; in ecx size of string to insert  
  532.         add     ecx,ed_size
  533.         mov     edx,ed_max
  534.         cmp     ecx,edx
  535.         jb      @f
  536.         mov     ecx,edx
  537. @@:
  538.         mov     esi,eax
  539.         add     esi,3*4
  540.         push    eax edi
  541. ;---------------------------------------;        
  542.         mov     ed_size,ecx        
  543.        
  544.         push   dword ed_text ; Dst  
  545.         push   esi           ; Src  
  546.         push   dword ed_pos  ; Pos in Dst
  547.         push   dword ed_max  ; DstMax
  548.         call   StrInsert          
  549. ;---------------------------------------;        
  550. ;        mov     edi,ed_text
  551. ;        cld
  552. ;@@:
  553. ;        lodsb
  554. ;        cmp     al,0x0d ; EOS (end of string)
  555. ;        je      .replace
  556. ;        cmp     al,0x0a ; EOS (end of string)
  557. ;        jne     .continue
  558. ;.replace:
  559. ;        mov     al,0x20 ; space
  560. ;.continue:
  561. ;        stosb
  562. ;        dec     ecx
  563. ;        jnz     @b
  564.         pop     edi eax
  565. .no_valid_text:
  566. ; remove unnecessary memory area
  567.         mov     ecx,eax
  568.         mcall   SF_SYS_MISC,SSF_MEM_FREE
  569. .exit:
  570.         jmp     edit_box.draw_bg_cursor_text
  571.  
  572. ;==========================================================
  573. ;=== ®¡à ¡®âª  ¬ëè¨ =======================================
  574. ;==========================================================
  575. ;save for stdcall ebx,esi,edi,ebp
  576. align 16
  577. edit_box_mouse:
  578.         pushad
  579.         mov     edi,[esp+36]
  580.         test    word ed_flags,ed_disabled
  581.         jnz     edit_box.editbox_exit
  582.  
  583. ;----------------------------------------------------------
  584. ;--- ¯®«ãç ¥¬ á®áâ®ï­¨¥ ª­®¯®ª ¬ëè¨ -----------------------
  585. ;----------------------------------------------------------
  586.         mcall   SF_MOUSE_GET,SSF_BUTTON
  587. ;----------------------------------------------------------
  588. ;--- ¯à®¢¥à塞 á®áâ®ï­¨¥ ----------------------------------
  589. ;----------------------------------------------------------
  590.         test    eax,1
  591.         jnz     edit_box_mouse.mouse_left_button
  592.         and     word ed_flags,ed_mouse_on_off
  593.         mov     ebx,ed_mouse_variable
  594.         push    0
  595.         pop     dword [ebx]
  596.         jmp     edit_box.editbox_exit
  597.  
  598. .mouse_left_button:
  599. ;----------------------------------------------------------
  600. ;--- ¡«®ª¨à®¢ª  ®â 䮪ãá¨à®¢ª¨ ¢ ¤àã£¨å ¡®ªá å ¯à¨ ¯®¯ ¤ ­¨¨ ­  ­¨å ªãàá®à 
  601. ;----------------------------------------------------------
  602.         mov     eax,ed_mouse_variable
  603.         push    dword [eax]
  604.         pop     eax
  605.         test    eax,eax
  606.         jz      @f
  607.         cmp     eax,edi
  608.         je      @f
  609.         jmp     edit_box_mouse._blur
  610. ;----------------------------------------------------------
  611. ;--- ¯®«ãç ¥¬ ª®®à¤¨­ âë ¬ëè¨ ®â­®á¨â¥«ì­® 0 â.¥ ¢á¥© ®¡« á⨠íªà ­ 
  612. ;----------------------------------------------------------
  613. @@:
  614.         mcall   SF_MOUSE_GET,SSF_WINDOW_POSITION
  615. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  616. ;”ã­ªæ¨ï ®¡à ¡®âª¨  ¬ë誨 ¯®«ã祭¨¥ ª®®à¤¨­ â ¨ ¯à®¢¥àª  ¨å + ¢ë¤¥«¥­¨ï
  617. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  618. ; ¥ 㤥ন¢ ¥¬ «¨ ¬ë ª« ¢¨èã ¬ë誨, ¯¥à¥¬¥é ï ªãàá®à?
  619.         test    word ed_flags,ed_mouse_on
  620.         jne     edit_box_mouse.mouse_wigwag
  621. ; ¯à®¢¥à塞, ¯®¯ ¤ ¥â «¨ ªãàá®à ¢ edit box
  622.         mov     ebx,ed_top
  623.         cmp     ax,bx
  624.         jl      edit_box_mouse._blur
  625.         add     ebx,ed_height
  626.         cmp     ax,bx
  627.         jg      edit_box_mouse._blur
  628.         shr     eax,16
  629.         mov     ebx,ed_left
  630.         cmp     ax,bx
  631.         jl      edit_box_mouse._blur
  632.         add     ebx,ed_width
  633.         cmp     ax,bx
  634.         jg      edit_box_mouse._blur
  635. ; ¨§¬¥­ï¥¬ ¯®§¨æ¨î ªãàá®à 
  636.         push    eax
  637.         mov     ebp,ed_color
  638.         call    edit_box.clear_cursor
  639.         pop     eax
  640. edit_box_mouse._mvpos:
  641.         xor     edx,edx
  642.         sub     eax,ed_left
  643.         div     word ed_char_width
  644.         add     eax,ed_offset
  645.         cmp     eax,ed_size
  646.         jna     edit_box_mouse._mshift
  647.         mov     eax,ed_size
  648. edit_box_mouse._mshift:
  649. ; ᥪæ¨ï ®¡à ¡®âª¨ shift ¨ ¢ë¤¥«¥­¨ï ¯® shift
  650.         test    word ed_flags,ed_shift_bac
  651.         je      @f
  652.         mov     ebp,ed_color
  653.         movzx   ebx, word ed_shift_pos
  654.         push    eax
  655.         call    edit_box_key.sh_cl_
  656.         and     word ed_flags,ed_shift_bac_cl
  657.         pop     eax
  658. @@:
  659.         test    word ed_flags,ed_mouse_on
  660.         jne     @f
  661.         mov     ed_shift_pos,ax
  662.         or      word  ed_flags,ed_mouse_on
  663.         mov     ed_pos,eax
  664.         mov     ebx,ed_mouse_variable
  665.         push    edi
  666.         pop     dword [ebx]
  667.         bts     word ed_flags,1
  668.         call    edit_box.draw_bg
  669.         jmp     edit_box_mouse.m_sh
  670.  
  671. @@:     cmp     ax,ed_shift_pos
  672.         je      edit_box.editbox_exit
  673.         mov     ed_pos,eax
  674.         call    edit_box.draw_bg
  675.         mov     ebp,shift_color
  676.         movzx   ebx, word ed_shift_pos
  677.         call    edit_box_key.sh_cl_
  678.         or      word ed_flags,ed_mous_adn_b
  679. edit_box_mouse.m_sh:
  680.         call    edit_box.draw_text
  681.         call    edit_box.draw_cursor
  682. ; ¯à®æ¥¤ãà  ãáâ ­®¢ª¨ 䮪ãá 
  683.         jmp     edit_box_mouse.drc
  684.  
  685. edit_box_mouse._blur:
  686.         test    word ed_flags,ed_always_focus
  687.         jne     edit_box.editbox_exit
  688.         btr     word ed_flags,1 ; ¥á«¨ ­¥ ¢ 䮪ãá¥, ¢ë室¨¬
  689.         jnc     edit_box.editbox_exit
  690.         mov     ebp,ed_color
  691.         call    edit_box.clear_cursor
  692. edit_box_mouse.drc:
  693.         call    edit_box.draw_border
  694.         jmp     edit_box.editbox_exit
  695.  
  696. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  697. ;Ž¡é¨¥ ä㭪樨 ®¡à ¡®âª¨
  698. ;----------------------------------------------------------
  699. ;--- ¯à®æ¥¤ãà  ¯à®à¨á®¢ª¨ ¢ë¤¥«¥­­®© ç á⨠----------------
  700. ;----------------------------------------------------------
  701. edit_box.draw_shift:
  702.         test    word ed_flags,ed_shift_bac ;ãáâ ­®¢ª  ä« £ , ¢ë¤¥«¥­­®© ®¡« áâ¨
  703.         jz      @f
  704.         mov     ebp,shift_color
  705.         movzx   ebx, word ed_shift_pos
  706.         call    edit_box_key.sh_cl_
  707. @@:     ret
  708. ;----------------------------------------------------------
  709. ;--- ¯à®æ¥¤ãà  ¯à®à¨á®¢ª¨ ⥪áâ  --------------------------
  710. ;----------------------------------------------------------
  711. edit_box.draw_text:
  712.         call    edit_box.get_n
  713.         mov     esi,ed_size
  714.         sub     esi,ed_offset
  715.         cmp     eax,esi
  716.         jae     @f
  717.         mov     esi,eax
  718. @@:
  719.         test    esi,esi
  720.         jz      @f
  721.         mov     eax,SF_DRAW_TEXT
  722.         mov     ebx,ed_left
  723.         add     ebx,2
  724.         shl     ebx,16
  725.         add     ebx,ed_top
  726.         add     ebx,3
  727.         mov     ecx,ed_text_color
  728.         test    dword ed_flags,ed_pass
  729.         jnz     .password
  730.         mov     edx,ed_text
  731.         add     edx,ed_offset
  732.         mcall
  733. @@:
  734.         ret
  735.  
  736. .password:
  737.         mov     ebp,esi
  738.         mov     esi,1
  739.         mov     edx,txt_pass
  740. @@:
  741.         mcall
  742.         rol     ebx,16
  743.         add     ebx,ed_char_width
  744.         rol     ebx,16
  745.         dec     ebp
  746.         jnz     @b
  747.         ret
  748.  
  749. txt_pass db '*'
  750. ;----------------------------------------------------------
  751. ;--- ¯à®æ¥¤ãà  ¯à®à¨á®¢ª¨ ä®­  ----------------------------
  752. ;----------------------------------------------------------
  753. edit_box.draw_bg:
  754.         mov     ebx,ed_left
  755.         inc     ebx
  756.         shl     ebx,16
  757.         add     ebx,ed_width
  758.         dec     ebx
  759.         mov     edx,ed_color
  760.         test    word ed_flags, ed_disabled
  761.         jz      edit_box.draw_bg_eax
  762.         mov     edx, 0xCACACA   ; TODO: add disabled_color field to editbox struct
  763. edit_box.draw_bg_eax:
  764.         mov     ecx,ed_top
  765.         inc     ecx
  766.         shl     ecx,16
  767.         add     ecx,ed_height
  768.         mcall   SF_DRAW_RECT
  769.         ret
  770.  
  771. ;----------------------------------------------------------
  772. ;--- ¯à®æ¥¤ãà  ¯®«ã祭¨ï ª®«¨ç¥á⢠ ᨬ¢®«®¢ ¢ ⥪ã饩 è¨à¨­¥ ª®¬¯®­¥­â 
  773. ;----------------------------------------------------------
  774. edit_box.get_n:
  775.         mov     eax,ed_width
  776.         sub     eax,4
  777.         xor     edx,edx
  778.         div     word ed_char_width
  779.         ret
  780.  
  781. ;----------------------------------------------------------
  782. ;------------------ Draw Cursor Procedure -----------------
  783. ;----------------------------------------------------------
  784. ; in: ebp = Color
  785. edit_box.clear_cursor:
  786.         movzx   ebx, word cl_curs_x
  787.         cmp     ebx, ed_left ;¯®¯ ¤ ¥â «¨ ªãàá®à ⥪á⮢®¥ ¯®«¥?
  788.         jle     @f
  789.         mov     edx, ebp
  790.         movzx   ecx, word cl_curs_y
  791.         cmp     ecx, ed_top
  792.         jg      edit_box.draw_curs
  793. @@:
  794.         ret
  795.  
  796. edit_box.draw_cursor:
  797.         mov     edx, ed_text_color
  798.         mov     eax, ed_pos
  799.         sub     eax, ed_offset
  800.         mul     dword ed_char_width
  801.         mov     ebx, eax
  802.         add     ebx, ed_left
  803.         inc     ebx
  804.         mov     ecx, ed_top
  805.         add     ecx, 2
  806.         mov     cl_curs_x, bx
  807.         mov     cl_curs_y, cx
  808. edit_box.draw_curs:
  809.         mov     eax, ebx
  810.         shl     ebx, 16
  811.         or      ebx, eax
  812.         mov     eax, ecx
  813.         shl     ecx, 16
  814.         or      ecx, eax
  815.         add     ecx, ed_height
  816.         sub     ecx, 3
  817.         mcall   SF_DRAW_LINE
  818.         ret
  819.  
  820. ;----------------------------------------------------------
  821. ;--- ¯à®æ¥¤ãà  à¨á®¢ ­¨ï à ¬ª¨ ----------------------------
  822. ;----------------------------------------------------------
  823. edit_box.draw_border:
  824.         test    word ed_flags,ed_focus
  825.         mov     edx,ed_focus_border_color
  826.         jne     @f
  827.         mov     edx,ed_blur_border_color
  828. @@:
  829.         mov     ebx,ed_left
  830.         mov     ecx,ebx
  831.         shl     ebx,16
  832.         add     ebx,ecx
  833.         add     ebx,ed_width
  834.         mov     ecx,ed_top
  835.         mov     esi,ecx
  836.         shl     ecx,16
  837.         add     ecx,esi
  838.         mcall   SF_DRAW_LINE ; top
  839.         mov     esi,ecx
  840.         inc     ecx
  841.         add     ecx,ed_height
  842.         mov     ebp,ecx
  843.         shl     ecx,16
  844.         mov     cx,bp
  845.         mcall   ; bottom
  846.         mov     cx,si
  847.         mov     ebp,ebx
  848.         sub     ebx,ed_width
  849.         mcall   ; left
  850.         mov     ebx,ebp
  851.         shl     ebx,16
  852.         mov     bx,bp
  853.         mcall   ; right
  854.         ret
  855.  
  856. ;----------------------------------------------------------
  857. ;--- ¯à®¢¥àª , § è¥« «¨ ªãàá®à §  £à ­¨æë ¨, ¥á«¨ ­ ¤®, ---
  858. ;--- ¨§¬¥­ï¥¬ ᬥ饭¨¥ ------------------------------------
  859. ;--- ¥á«¨ ᬥ饭¨¥ ¡ë«®, ãáâ ­®¢ª  ä« £  ed_offset_cl, ¨­ ç¥,
  860. ; ¥á«¨ ­¨ç¥£® ­¥ ¨§¬¥­¨«®áì, â® ¢ëáâ ¢«¥­¨¥ ed_offset_fl
  861. ; ¢ ®¡é¥© ¡¨â®¢®© ¬ âà¨æ¥ á®áâ®ï­¨ï ª®¬¯®­¥­â®¢ word ed_flags
  862. ;----------------------------------------------------------
  863. edit_box.check_offset:
  864.         pushad
  865.         mov     ecx,ed_pos
  866.         mov     ebx,ed_offset
  867.         cmp     ebx,ecx
  868.         ja      edit_box.sub_8
  869.         push    ebx
  870.         call    edit_box.get_n
  871.         pop     ebx
  872.         mov     edx,ebx
  873.         add     edx,eax
  874.         inc     edx     ;­¥®¡å®¤¨¬® ¤«ï ­®à¬ «ì­®£® ¯®«®¦¥­¨ï ªãàá®à  ¢ ªà ©­¥© «¥¢®© ¯®§¨æ¨¨
  875.         cmp     edx,ecx
  876.         ja      @f
  877.         mov     edx,ed_size
  878.         cmp     edx,ecx
  879.         je      edit_box.add_end
  880.         sub     edx,ecx
  881.         cmp     edx,8
  882.         jbe     edit_box.add_8
  883.         add     ebx,8
  884.         jmp     edit_box.chk_d
  885.  
  886. @@:     or      word ed_flags,ed_offset_fl
  887.         popad
  888.         ret
  889.  
  890. edit_box.sub_8:
  891.         test    ecx,ecx
  892.         jz      @f
  893.         sub     ebx,8   ;ebx=ed_offset
  894.         ja      edit_box.chk_d
  895. @@:
  896.         xor     ebx,ebx
  897.         jmp     edit_box.chk_d
  898.  
  899. edit_box.add_end:
  900.         sub     edx,eax
  901.         mov     ebx,edx
  902.         jmp     edit_box.chk_d
  903.  
  904. edit_box.add_8:
  905.         add     ebx,edx
  906. edit_box.chk_d:
  907.         mov     ed_offset,ebx
  908.         call    edit_box.draw_bg
  909.         and     word ed_flags,ed_offset_cl
  910.         popad
  911.         ret
  912.  
  913. align 4
  914. proc edit_box_set_text, edit:dword, text:dword
  915.         pushad
  916.         mov     edi,[edit]
  917.         mov     ecx,ed_max
  918.         inc     ecx
  919.         mov     edi,[text]
  920.         xor     al,al
  921.         cld
  922.         repne scasb
  923.         mov     ecx,edi
  924.         mov     edi,[edit]
  925.         mov     esi,[text]
  926.         sub     ecx,esi
  927.         dec     ecx
  928.         mov     ed_size,ecx
  929.         mov     ed_pos,ecx
  930.         and     word ed_flags,ed_shift_cl
  931.         mov     edi,ed_text
  932.         repne movsb
  933.         mov     byte[edi],0
  934.         popad
  935.         ret
  936. endp
  937.  
  938. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  939. ;”㭪樨 ¤«ï à ¡®âë á key
  940. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  941.  
  942. ;Ž¡à ¡®âª  Shift ¤«ï á­ïâ¨ï ¢ë¤¥«¥­¨ï ­¥¨§¢¥áâ­®© ®¡« áâ¨
  943. edit_box_key.shift:
  944.         call    edit_box.draw_bg
  945.         test    word ed_flags,ed_shift
  946.         je      edit_box_key.f_exit
  947.         mov     ebp,shift_color
  948.         or      word ed_flags,ed_shift_bac ;ãáâ ­®¢ª  ä« £ , ¢ë¤¥«¥­­®© ®¡« áâ¨
  949.         movzx   ebx, word ed_shift_pos
  950.         call    edit_box_key.sh_cl_
  951.         jmp     edit_box.draw_cursor_text
  952.  
  953. edit_box_key.f_exit:
  954.         call    edit_box.check_offset
  955.         and     word ed_flags,ed_shift_cl
  956.         call    edit_box_key.enable_null
  957.         jmp     edit_box.draw_cursor_text
  958.  
  959. edit_box_key.sh_cl_:
  960. ;®¡à ¡®âª  ®ç¨á⪨, ¯à¨ «¥¢®¬ - ¯à ¢®¬ ¤¢¨¦¥­¨¨ ¢ë¤¥«¥­¨ï
  961. ;¤«ï ®¡à ¡®âª¨ á­ïâ¨ï ¢ë¤¥«¥­¨ï
  962. ;¢å®¤­ë¥ ¯ à ¬¥âàë ebp=color ebx=ed_shift_pos
  963.         mov     eax,ed_pos
  964.         cmp     eax,ebx
  965.         jae     edit_box_key.sh_n
  966.         push    eax  ;¬¥­ì襥 ¢ eax
  967.         push    ebx  ;¡®«ì襥
  968.         jmp     edit_box_key.sh_n1
  969.  
  970. edit_box_key.sh_n:
  971.         push    ebx
  972.         push    eax
  973. edit_box_key.sh_n1:
  974.         call    edit_box.check_offset
  975.         call    edit_box.get_n
  976.         mov     edx,eax ;size of ed_box
  977.         mov     ecx,ed_offset
  978.         add     eax,ecx ;eax = w_off= ed_offset+width
  979.         mov     edx,eax ;save
  980.         pop     ebx     ;¡®«ì襥
  981.         pop     eax     ;¬¥­ì襥
  982.         cmp     eax,ecx         ;áà ¢­¥­¨¥ ¬¥­ì襣® á offset.
  983.         jae     edit_box_key.f_f            ;¥á«¨ ¡®«ìè¥
  984.         xor     eax,eax
  985.         cmp     edx,ebx         ;cà ¢­¨¬ à §¬¥à w_off á ¡®«ì訬
  986.         jnb     @f
  987.         mov     ebx,edx
  988. @@:
  989.         sub     ebx,ecx
  990.         jmp     edit_box_key.nxt_f
  991.  
  992. edit_box_key.f_f:
  993.         sub     eax,ecx
  994.         cmp     edx,ebx         ;cà ¢­¨¬ à §¬¥à w_off á ¡®«ì訬
  995.         jle     @f
  996.         sub     ebx,ecx
  997.         sub     ebx,eax
  998.         jmp     edit_box_key.nxt_f
  999.  
  1000. @@:     mov     ebx,edx
  1001.         sub     ebx,ecx
  1002.         sub     ebx,eax
  1003. edit_box_key.nxt_f:
  1004.         mul     dword ed_char_width
  1005.         xchg    eax,ebx
  1006.         mul     dword ed_char_width
  1007.         add     ebx,ed_left
  1008.         inc     ebx
  1009.         shl     ebx,16
  1010.         inc     eax
  1011.         mov     bx, ax
  1012.         mov     edx,ebp ;shift_color
  1013.         call    edit_box.draw_bg_eax
  1014.         jmp     edit_box_key.enable_null
  1015.  
  1016. ;“áâ ­®¢ª - á­ï⨥ ¢ë¤¥«¥­¨ï ¢ ®¤¨­ ᨬ¢®«
  1017. edit_box_key.drw_sim:
  1018.         mov     eax,ed_pos
  1019.         call    edit_box_key.draw_rectangle
  1020.         jmp     edit_box_key.enable_null
  1021.  
  1022. ;”ã­ªæ¨ï ãáâ ­®¢ª¨ ¢ë¤¥«¥­¨ï ¯à¨ ¤¢¨¦¥­¨¨ ¢«¥¢® ¨ ¢¯à ¢® ¨ ­ ¦ â¨¨ shift
  1023. edit_box_key.draw_wigwag:
  1024.         mov     ebp,shift_color
  1025.         call    edit_box.clear_cursor
  1026.         or      word ed_flags,ed_shift_bac ;ãáâ ­®¢ª  ä« £  ¢ë¤¥«¥­­®© ®¡« áâ¨
  1027.         mov     ebp,shift_color
  1028.         mov     eax,ed_pos
  1029.         test    word ed_flags,ed_left_fl
  1030.         jnz     edit_box_key.draw_rectangle
  1031.         dec     eax
  1032.         jmp     edit_box_key.draw_rectangle
  1033.  
  1034. ;”ã­ªæ¨ï 㤠«¥­¨ï ¢ë¤¥«¥­¨ï ¯à¨ ¤¢¨¦¥­¨¨ ¢«¥¢® ¨ ¢¯à ¢® ¨ ­ ¦ â¨¨ shift
  1035. edit_box_key.draw_wigwag_cl:
  1036.         mov     ebp,ed_color
  1037.         call    edit_box.clear_cursor
  1038.         mov     ebp,ed_color
  1039.         mov     eax,ed_pos
  1040.         test    word ed_flags,ed_left_fl
  1041.         jnz     edit_box_key.draw_rectangle
  1042.         dec     eax
  1043.         jmp     edit_box_key.draw_rectangle
  1044.  
  1045. ;¢å®¤­®© ¯ à ¬¥âà ebx - ed_pos
  1046. edit_box_key.sh_first_sh:
  1047.         test    word ed_flags,ed_shift
  1048.         je      @f
  1049.         mov     ed_shift_pos_old,bx
  1050.         test    word ed_flags,ed_shift_on
  1051.         jne     @f
  1052.         mov     ed_shift_pos,bx
  1053.         or      word ed_flags,ed_shift_on
  1054. @@:     ret
  1055. ;Ž¡à ¡®âª  ªà ©­¨å ¯®«®¦¥­¨© ¢ editbox ¯à¨ ­ ¦ â®¬ shift
  1056. ;¯à®¨§¢®¤¨â á­ï⨥ ¢ë¤¥«¥­¨ï, ¥á«¨ ­¥â shift
  1057. ;¨­ ç¥ ¢®®¡é¥ ¢ë室¨â
  1058. edit_box_key.sh_st_of:
  1059.         test    word ed_flags,ed_shift
  1060.         jne     @f
  1061.         test    word ed_flags,ed_shift_bac
  1062.         je      @f
  1063.         call    edit_box.draw_bg
  1064.         mov     ebp,ed_color
  1065.         movzx   ebx, word ed_shift_pos
  1066.         call    edit_box_key.sh_cl_  ;®ç¨á⪠ ¢ë¤¥«¥­®£® äà £¬¥­â 
  1067.         and     word ed_flags,ed_shift_cl ; ®ç¨á⪠ ®â ⮣®, çâ® ã¡à «¨ ¢ë¤¥«¥­¨¥
  1068.         jmp     edit_box.draw_cursor_text
  1069.  
  1070. @@:     and     word ed_flags,ed_shift_off
  1071.         popad
  1072.         ret     4
  1073. ;¯à®¢¥àª  á®áâ®ï­¨ï shift, ¡ë« «¨ ®­ ­ ¦ â à ­ìè¥?
  1074. edit_box_key.sh_enable:
  1075.         test    word ed_flags,ed_shift
  1076.         jne     edit_box_key.sh_ext_en ;­ à¨á®¢ âì § ªà è¥­­ë© ¯àאַ㣮«ì­¨ª
  1077.         test    word ed_flags,ed_shift_bac
  1078.         je      @f
  1079.         call    edit_box.check_offset
  1080.         mov     ebp,ed_color
  1081.         movzx   ebx, word ed_shift_pos
  1082.         call    edit_box_key.sh_cl_  ;®ç¨á⪠ ¢ë¤¥«¥­­®£® äà £¬¥­â 
  1083.         call    edit_box_key.draw_wigwag_cl
  1084.         and     word ed_flags,ed_shift_cl ; 1¢ à ­¥ ­ã¦­®
  1085.         ret
  1086.  
  1087. @@:     mov     ebp,ed_color
  1088.         call    edit_box.clear_cursor
  1089.         jmp     edit_box.check_offset
  1090.  
  1091. edit_box_key.sh_ext_en:
  1092.         call    edit_box.check_offset
  1093.         test    word ed_flags,ed_offset_fl
  1094.         je      @f
  1095. ;¨á®¢ ­¨¥ § ªà è¥­­ëå ¯àאַ㣮«ì­¨ª®¢ ¨ ¨å ®ç¨á⪠
  1096.         movzx   eax, word ed_shift_pos
  1097.         mov     ebx,ed_pos
  1098.         movzx   ecx, word ed_shift_pos_old
  1099. ;¯à®¢¥àª  ¨ à¨á®¢ ­¨¥ § ªà è¥­­ëå ®¡« á⥩
  1100.         cmp     eax,ecx
  1101.         je      edit_box_key.1_shem
  1102.         jb      edit_box_key.smaller
  1103.         cmp     ecx,ebx
  1104.         ja      edit_box_key.1_shem
  1105.         call    edit_box_key.draw_wigwag_cl ;clear
  1106.         jmp     edit_box_key.sh_e_end
  1107.  
  1108. edit_box_key.smaller:
  1109.         cmp     ecx,ebx
  1110.         jb      edit_box_key.1_shem
  1111.         call    edit_box_key.draw_wigwag_cl ;clear
  1112.         jmp     edit_box_key.sh_e_end
  1113.  
  1114. edit_box_key.1_shem:
  1115.         call    edit_box_key.draw_wigwag
  1116. edit_box_key.sh_e_end:
  1117.         and     word ed_flags,ed_shift_off
  1118.         ret
  1119.  
  1120. @@:     mov     ebp,shift_color
  1121.         movzx   ebx, word ed_shift_pos
  1122.         call    edit_box_key.sh_cl_
  1123.         jmp     edit_box_key.sh_e_end
  1124. ;äã­ªæ¨ï ¤«ï ®¡à ¡®âª¨ shift ¯à¨ ­ ¦ â¨¨ home and end
  1125. edit_box_key.sh_home_end:
  1126.         mov     ebp,ed_color
  1127.         call    edit_box.clear_cursor
  1128.         test    word ed_flags,ed_shift_bac
  1129.         je      @f
  1130.         mov     ebp,ed_color
  1131.         movzx   ebx, word ed_shift_pos_old
  1132.         call    edit_box_key.sh_cl_
  1133. @@:
  1134.         test    word ed_flags,ed_shift
  1135.         je      edit_box_key.sh_exit_ ;¢ë©â¨
  1136.         mov     ebp,shift_color
  1137.         movzx   ebx, word ed_shift_pos
  1138.         call    edit_box_key.sh_cl_
  1139.         or      word ed_flags,ed_shift_bac ;ãáâ ­®¢ª  ä« £ , ¢ë¤¥«¥­­®© ®¡« áâ¨
  1140.         jmp     edit_box_key.sh_e_end
  1141.  
  1142. edit_box_key.sh_exit_:
  1143.         call    edit_box.draw_bg
  1144.         jmp     edit_box.check_offset
  1145.  
  1146. ;äã­ªæ¨ï ¢­¥á¥­¨ï 0 ¯®  ¤à¥áã ed_size+1
  1147. edit_box_key.enable_null:
  1148.         pusha
  1149.         mov     eax,ed_size
  1150.         mov     ebx,ed_text
  1151.         test    eax,eax
  1152.         add     eax,ebx
  1153.         jne     @f
  1154.         inc     eax
  1155. @@:     xor     ebx,ebx
  1156.         mov     [eax],bl
  1157.         popad
  1158.         ret
  1159.  
  1160. ;- 㤠«¥­¨¥ ᨬ¢®« 
  1161. ;‚室­ë¥ ¤ ­­ë¥ edx=ed_size;ecx=ed_pos
  1162. edit_box_key.del_char:
  1163.         mov     esi,ed_text
  1164.         test    word ed_flags,ed_shift_on
  1165.         je      @f
  1166.         movzx   eax, word ed_shift_pos
  1167.         mov     ebx,esi
  1168.         cmp     eax,ecx
  1169.         jae     edit_box_key.dh_n
  1170.         mov     ed_pos,eax      ;çâ®¡ë ­¥ ¡ë«® ã¡¥£ ­¨ï ªãàá®à 
  1171.         mov     ebp,ecx
  1172.         sub     ebp,eax
  1173.         add     ebx,eax  ;eax ¬¥­ìè¥
  1174.         sub     edx,ecx
  1175.         add     esi,ecx
  1176.         mov     ed_shift_pos,bp
  1177.         jmp     edit_box_key.del_ch_sh
  1178.  
  1179. edit_box_key.dh_n:
  1180.         mov     ebp,eax
  1181.         sub     ebp,ecx
  1182.         add     ebx,ecx
  1183.         sub     edx,eax
  1184.         add     esi,eax
  1185.         mov     ed_shift_pos,bp
  1186.         jmp     edit_box_key.del_ch_sh
  1187.  
  1188. @@:     add     esi,ecx ;㪠§ â¥«ì + ᬥ饭¨¥ ª ॠ«ì­®¬ã ¡ãä¥àã
  1189.         mov     ebx,esi
  1190.         inc     esi
  1191.         cld
  1192.         sub     edx,ecx
  1193. edit_box_key.del_ch_sh:
  1194.         push    edi
  1195.         mov     edi,ebx
  1196. @@:
  1197.         lodsb
  1198.         stosb
  1199.         dec     edx
  1200.         jns     @b
  1201.         pop     edi
  1202.         ret
  1203. ;¢ëç¨á«¨âì § ªà è¨¢ ¥¬ãî ®¡« áâì
  1204. ;ᮣ« è¥­¨¥ ¢ ebp - ¯¥à¥¤ ¥âáï ed_size
  1205. edit_box_key.clear_bg:
  1206.         call    edit_box.get_n  ;¯®«ãç¨âì à §¬¥à ¢ ᨬ¢®« å è¨à¨­ë ª®¬¯®­¥­â 
  1207.         push    eax
  1208.         mov     ebx,ed_offset
  1209.         add     eax,ebx ;eax = w_off= ed_offset+width
  1210.         mov     ebx,ebp ;ed_size
  1211.         cmp     eax,ebx
  1212.         jb      @f
  1213.         mov     eax,ed_pos
  1214.         sub     ebx,eax
  1215.         mov     ecx,ed_offset
  1216.         sub     eax,ecx
  1217.         jmp     edit_box_key.nxt
  1218.  
  1219. @@:     mov     ebx,ed_pos
  1220.         push    ebx
  1221.         sub     eax,ebx
  1222.         mov     ebx,eax ;It is not optimal
  1223.         pop     eax     ;ed_pos
  1224.         mov     ecx,ed_offset
  1225.         sub     eax,ecx
  1226. edit_box_key.nxt:
  1227.         mov     ebp,eax  ;¯à®¢¥àª  ­  ¢ë室 § ªà è¨¢ ¥¬®© ®¡« á⨠§  ¯à¥¤¥«ë ¤«¨­ë
  1228.         add     ebp,ebx
  1229.         pop     edx
  1230.         cmp     ebp,edx
  1231.         je      @f
  1232.         inc     ebx
  1233. @@:
  1234.         mul     dword ed_char_width
  1235.         xchg    eax,ebx
  1236.         mul     dword ed_char_width
  1237.         add     ebx,ed_left
  1238.         inc     ebx
  1239.         shl     ebx,16
  1240.         inc     eax
  1241.         mov     bx, ax
  1242.         mov     edx,ed_color
  1243.         jmp     edit_box.draw_bg_eax
  1244.  
  1245. ;;;;;;;;;;;;;;;;;;;
  1246. ;;; Ž¡à ¡®âª  ¯à¨¬¨â¨¢®¢
  1247. ;;;;;;;;;;;;;;;;;;;;
  1248. ; à¨á®¢ âì ¯àאַ㣮«ì­¨ª, 梥⠯¥à¥¤ ¥âáï ¢ ebp
  1249. ;¢å®¤­ë¥ ¯ à ¬¥âàë:
  1250. ;eax=dword ed_pos
  1251. ;ebp=-梥â ed_color or shift_color
  1252. edit_box_key.draw_rectangle:
  1253.         sub     eax,ed_offset
  1254.         mul     dword ed_char_width
  1255.         add     eax,ed_left
  1256.         inc     eax
  1257.         shl     eax,16
  1258.         add     eax,ed_char_width
  1259.         mov     ebx,eax
  1260.         mov     edx,ebp
  1261.         jmp     edit_box.draw_bg_eax
  1262.  
  1263. ;;;;;;;;;;;;;;;;;;
  1264. ;;à®¢¥àª  ­ ¦ â «¨ shift
  1265. ;;;;;;;;;;;;;;;;;;
  1266. edit_box_key.check_shift_ctrl_alt:
  1267.         pusha
  1268.         mcall   SF_KEYBOARD,SSF_GET_CONTROL_KEYS
  1269.         test    al,11b
  1270.         je      @f
  1271.         or      word ed_flags,ed_shift   ;ãáâ ­®¢¨¬ ä« £ Shift
  1272. @@:
  1273.         and     word ed_flags,ed_ctrl_off ; ®ç¨á⨬ ä« £ Ctrl
  1274.         test    al,1100b
  1275.         je      @f
  1276.         or      word ed_flags,ed_ctrl_on   ;ãáâ ­®¢¨¬ ä« £ Ctrl
  1277. @@:
  1278.         and     word ed_flags,ed_alt_off ; ®ç¨á⨬ ä« £ Alt
  1279.         test    al,110000b
  1280.         je      @f
  1281.         or      word ed_flags,ed_alt_on   ;ãáâ ­®¢¨¬ ä« £ Alt
  1282. @@:
  1283.         popad
  1284.         ret
  1285.  
  1286. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1287. ;”㭪樨 ¤«ï à ¡®âë á mouse
  1288. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1289. edit_box_mouse.mouse_wigwag:
  1290.         push    eax
  1291.         call    edit_box.draw_bg
  1292.         call    edit_box.draw_shift
  1293.         pop     eax
  1294.         or      word ed_flags,ed_shift_bac+ed_shift_on+ed_shift
  1295. ;Ž¡à ¡®âª  ¯®«®¦¥­¨ï ¢ë¤¥«¥­­®£® ⥪áâ , ª®£¤  ¯à®¨á室¨â ¢ë室 §  ¯à¥¤¥«ë editbox
  1296.         test    eax,eax
  1297.         js      edit_box_mouse.mleft
  1298.         shr     eax,16
  1299.         sub     eax,ed_left
  1300.         jc      edit_box_mouse.mleft
  1301.         cmp     ed_width,eax
  1302.         jc      edit_box_mouse.mright
  1303.         xor     edx,edx
  1304.         div     word ed_char_width
  1305. ;Ž¡à ¡®âª  ¯®«®¦¥­¨ï ¢ë¤¥«¥­­®£® ⥪áâ , ¢ ¯à¥¤¥« å ®¡« á⨠editbox
  1306. ;®«ã稫¨ ª®®à¤¨­ âë ¢ eax ¬ë誨, â.¥. ªã¤  ®­  ¯¥à¥¬¥á⨫ áì
  1307. ;¨á®¢ ­¨¥ § ªà è¥­­ëå ¯àאַ㣮«ì­¨ª®¢ ¨ ¨å ®ç¨á⪠
  1308.         add     eax,ed_offset
  1309.         cmp     eax,ed_size
  1310.         ja      edit_box_mouse.mwigvag
  1311. edit_box_mouse.mdraw:
  1312.         mov     ed_pos,eax
  1313. ;¨á®¢ ­¨¥ § ªà è¥­­ëå ¯àאַ㣮«ì­¨ª®¢ ¨ ¨å ®ç¨á⪠
  1314.         movzx   ecx, word ed_shift_pos
  1315.         movzx   ebx, word ed_shift_pos_old
  1316.         mov     ed_shift_pos_old,ax
  1317. ;¯à®¢¥àª  ¨ à¨á®¢ ­¨¥ § ªà è¥­­ëå ®¡« á⥩
  1318.         cmp     ecx,ebx
  1319.         je      edit_box_mouse.m1_shem  ;¤¢¨¦¥­¨ï ­¥ ¡ë«® à ­¥¥
  1320.         jb      edit_box_mouse.msmaller ;¡ë«® ¤¢¨¦¥­¨¥ ->
  1321.         cmp     ebx,eax
  1322.         ja      edit_box_mouse.m1_shem  ;¡ë«® ¤¢¨¦¥­¨¥ <-
  1323.         je      edit_box_mouse.mwigvag
  1324.         mov     ebp,ed_color
  1325.         call    edit_box_key.sh_cl_     ;®ç¨áâ¨âì ®¡« áâì c ed_pos ed_shift_pos_old
  1326.         jmp     edit_box_mouse.mwigvag
  1327.  
  1328. edit_box_mouse.msmaller:
  1329.         cmp     ebx,eax
  1330.         jb      edit_box_mouse.m1_shem
  1331.         mov     ebp,ed_color
  1332.         call    edit_box_key.sh_cl_
  1333.         jmp     edit_box_mouse.mwigvag
  1334.  
  1335. edit_box_mouse.m1_shem:
  1336.         mov     ebp,shift_color
  1337.         mov     ebx,ecx
  1338.         call    edit_box_key.sh_cl_
  1339. edit_box_mouse.mwigvag:
  1340.         and     word ed_flags,ed_shift_mcl
  1341.         jmp     edit_box.draw_cursor_text
  1342.  
  1343. edit_box_mouse.mleft:
  1344.         mov     eax,ed_pos
  1345.         cmp     eax,0
  1346.         jbe     edit_box_mouse.mwigvag
  1347.         dec     eax
  1348.         call    edit_box.check_offset
  1349.         push    eax
  1350.         movzx   ebx, word ed_shift_pos
  1351.         mov     ebp,shift_color
  1352.         call    edit_box_key.sh_cl_
  1353.         pop     eax
  1354.         jmp     edit_box_mouse.mdraw
  1355.  
  1356. edit_box_mouse.mright:
  1357.         mov     eax,ed_pos
  1358.         mov     ebx,ed_size
  1359.         cmp     eax,ebx
  1360.         jae     edit_box_mouse.mwigvag
  1361.         inc     eax
  1362.         call    edit_box.check_offset
  1363.         movzx   ebx, word ed_shift_pos
  1364.         mov     ebp,shift_color
  1365.         push    eax
  1366.         call    edit_box_key.sh_cl_
  1367.         pop     eax
  1368.         jmp     edit_box_mouse.mdraw
  1369.  
  1370.  
  1371. ed_struc_size=84
  1372.