Subversion Repositories Kolibri OS

Rev

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