Subversion Repositories Kolibri OS

Rev

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