Subversion Repositories Kolibri OS

Rev

Rev 7558 | Rev 7904 | 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.         push    ecx
  552. ; in ecx size of string to insert
  553.         add     ecx,ed_size
  554.         mov     edx,ed_max
  555.         cmp     ecx,edx
  556.         jb      @f
  557.         mov     ecx,edx
  558. @@:
  559.         mov     esi,eax
  560.         add     esi,3*4
  561.         push    eax edi
  562. ;---------------------------------------;
  563.         mov     ed_size,ecx
  564.  
  565.         push   dword ed_text ; Dst
  566.         push   esi           ; Src
  567.         push   dword ed_pos  ; Pos in Dst
  568.         push   dword ed_max  ; DstMax
  569.         call   StrInsert
  570. ;---------------------------------------;
  571. ;        mov     edi,ed_text
  572. ;        cld
  573. ;@@:
  574. ;        lodsb
  575. ;        cmp     al,0x0d ; EOS (end of string)
  576. ;        je      .replace
  577. ;        cmp     al,0x0a ; EOS (end of string)
  578. ;        jne     .continue
  579. ;.replace:
  580. ;        mov     al,0x20 ; space
  581. ;.continue:
  582. ;        stosb
  583. ;        dec     ecx
  584. ;        jnz     @b
  585.         pop    edi eax
  586. ;move cursor to the end of the inserted string         
  587.         pop    ecx
  588.         add    ecx,ed_pos
  589.         cmp    ecx,ed_max
  590.         jbe    @f
  591.         mov    ecx,ed_max
  592. @@:
  593.                 mov    ed_pos, ecx
  594. .no_valid_text:
  595. ; remove unnecessary memory area
  596.         mov     ecx,eax
  597.         mcall   SF_SYS_MISC,SSF_MEM_FREE
  598. .exit:
  599.         jmp     edit_box.draw_bg_cursor_text
  600.  
  601. edit_box_key.ctrl_a:
  602.         mov     eax,ed_size
  603.         mov     ed_pos,eax
  604.         xor     eax,eax
  605.         mov     ed_shift_pos,eax
  606.         or      word ed_flags,ed_shift_bac+ed_shift_on
  607.         jmp     edit_box.draw_bg_cursor_text
  608.  
  609. ;==========================================================
  610. ;=== ®¡à ¡®âª  ¬ëè¨ =======================================
  611. ;==========================================================
  612. ;save for stdcall ebx,esi,edi,ebp
  613. align 16
  614. edit_box_mouse:
  615.         pushad
  616.         mov     edi,[esp+36]
  617.         test    word ed_flags,ed_disabled
  618.         jnz     edit_box.editbox_exit
  619.  
  620. ;----------------------------------------------------------
  621. ;--- ¯®«ãç ¥¬ á®áâ®ï­¨¥ ª­®¯®ª ¬ëè¨ -----------------------
  622. ;----------------------------------------------------------
  623.         mcall   SF_MOUSE_GET,SSF_BUTTON
  624. ;----------------------------------------------------------
  625. ;--- ¯à®¢¥à塞 á®áâ®ï­¨¥ ----------------------------------
  626. ;----------------------------------------------------------
  627.         test    eax,1
  628.         jnz     edit_box_mouse.mouse_left_button
  629.         and     word ed_flags,ed_mouse_on_off
  630.         mov     ebx,ed_mouse_variable
  631.         push    0
  632.         pop     dword [ebx]
  633.         jmp     edit_box.editbox_exit
  634.  
  635. .mouse_left_button:
  636. ;----------------------------------------------------------
  637. ;--- ¡«®ª¨à®¢ª  ®â 䮪ãá¨à®¢ª¨ ¢ ¤àã£¨å ¡®ªá å ¯à¨ ¯®¯ ¤ ­¨¨ ­  ­¨å ªãàá®à 
  638. ;----------------------------------------------------------
  639.         mov     eax,ed_mouse_variable
  640.         push    dword [eax]
  641.         pop     eax
  642.         test    eax,eax
  643.         jz      @f
  644.         cmp     eax,edi
  645.         je      @f
  646.         jmp     edit_box_mouse._blur
  647. ;----------------------------------------------------------
  648. ;--- ¯®«ãç ¥¬ ª®®à¤¨­ âë ¬ëè¨ ®â­®á¨â¥«ì­® 0 â.¥ ¢á¥© ®¡« á⨠íªà ­ 
  649. ;----------------------------------------------------------
  650. @@:
  651.         mcall   SF_MOUSE_GET,SSF_WINDOW_POSITION
  652. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  653. ;”ã­ªæ¨ï ®¡à ¡®âª¨  ¬ë誨 ¯®«ã祭¨¥ ª®®à¤¨­ â ¨ ¯à®¢¥àª  ¨å + ¢ë¤¥«¥­¨ï
  654. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  655. ; ¥ 㤥ন¢ ¥¬ «¨ ¬ë ª« ¢¨èã ¬ë誨, ¯¥à¥¬¥é ï ªãàá®à?
  656.         test    word ed_flags,ed_mouse_on
  657.         jne     edit_box_mouse.mouse_wigwag
  658. ; ¯à®¢¥à塞, ¯®¯ ¤ ¥â «¨ ªãàá®à ¢ edit box
  659.         mov     ebx,ed_top
  660.         cmp     ax,bx
  661.         jl      edit_box_mouse._blur
  662.         add     ebx,ed_height
  663.         cmp     ax,bx
  664.         jg      edit_box_mouse._blur
  665.         shr     eax,16
  666.         mov     ebx,ed_left
  667.         cmp     ax,bx
  668.         jl      edit_box_mouse._blur
  669.         add     ebx,ed_width
  670.         cmp     ax,bx
  671.         jg      edit_box_mouse._blur
  672. ; ¨§¬¥­ï¥¬ ¯®§¨æ¨î ªãàá®à 
  673.         push    eax
  674.         mov     ebp,ed_color
  675.         call    edit_box.clear_cursor
  676.         pop     eax
  677. edit_box_mouse._mvpos:
  678.         xor     edx,edx
  679.         sub     eax,ed_left
  680.         div     word ed_char_width
  681.         add     eax,ed_offset
  682.         cmp     eax,ed_size
  683.         jna     edit_box_mouse._mshift
  684.         mov     eax,ed_size
  685. edit_box_mouse._mshift:
  686. ; ᥪæ¨ï ®¡à ¡®âª¨ shift ¨ ¢ë¤¥«¥­¨ï ¯® shift
  687.         test    word ed_flags,ed_shift_bac
  688.         je      @f
  689.         mov     ebp,ed_color
  690.         movzx   ebx, word ed_shift_pos
  691.         push    eax
  692.         call    edit_box_key.sh_cl_
  693.         and     word ed_flags,ed_shift_bac_cl
  694.         pop     eax
  695. @@:
  696.         test    word ed_flags,ed_mouse_on
  697.         jne     @f
  698.         mov     ed_shift_pos,ax
  699.         or      word  ed_flags,ed_mouse_on
  700.         mov     ed_pos,eax
  701.         mov     ebx,ed_mouse_variable
  702.         push    edi
  703.         pop     dword [ebx]
  704.         bts     word ed_flags,1
  705.         call    edit_box.draw_bg
  706.         jmp     edit_box_mouse.m_sh
  707.  
  708. @@:     cmp     ax,ed_shift_pos
  709.         je      edit_box.editbox_exit
  710.         mov     ed_pos,eax
  711.         call    edit_box.draw_bg
  712.         mov     ebp,shift_color
  713.         movzx   ebx, word ed_shift_pos
  714.         call    edit_box_key.sh_cl_
  715.         or      word ed_flags,ed_mous_adn_b
  716. edit_box_mouse.m_sh:
  717.         call    edit_box.draw_text
  718.         call    edit_box.draw_cursor
  719. ; ¯à®æ¥¤ãà  ãáâ ­®¢ª¨ 䮪ãá 
  720.         jmp     edit_box_mouse.drc
  721.  
  722. edit_box_mouse._blur:
  723.         test    word ed_flags,ed_always_focus
  724.         jne     edit_box.editbox_exit
  725.         btr     word ed_flags,1 ; ¥á«¨ ­¥ ¢ 䮪ãá¥, ¢ë室¨¬
  726.         jnc     edit_box.editbox_exit
  727.         mov     ebp,ed_color
  728.         call    edit_box.clear_cursor
  729. edit_box_mouse.drc:
  730.         call    edit_box.draw_border
  731.         jmp     edit_box.editbox_exit
  732.  
  733. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  734. ;Ž¡é¨¥ ä㭪樨 ®¡à ¡®âª¨
  735. ;----------------------------------------------------------
  736. ;--- ¯à®æ¥¤ãà  ¯à®à¨á®¢ª¨ ¢ë¤¥«¥­­®© ç á⨠----------------
  737. ;----------------------------------------------------------
  738. edit_box.draw_shift:
  739.         test    word ed_flags,ed_shift_bac ;ãáâ ­®¢ª  ä« £ , ¢ë¤¥«¥­­®© ®¡« áâ¨
  740.         jz      @f
  741.         mov     ebp,shift_color
  742.         movzx   ebx, word ed_shift_pos
  743.         call    edit_box_key.sh_cl_
  744. @@:     ret
  745. ;----------------------------------------------------------
  746. ;--- ¯à®æ¥¤ãà  ¯à®à¨á®¢ª¨ ⥪áâ  --------------------------
  747. ;----------------------------------------------------------
  748. edit_box.draw_text:
  749.         call    edit_box.get_n
  750.         mov     esi,ed_size
  751.         sub     esi,ed_offset
  752.         cmp     eax,esi
  753.         jae     @f
  754.         mov     esi,eax
  755. @@:
  756.         test    esi,esi
  757.         jz      @f
  758.         mov     eax,SF_DRAW_TEXT
  759.         mov     ebx,ed_left
  760.         add     ebx,2
  761.         shl     ebx,16
  762.         add     ebx,ed_top
  763.         add     ebx,3
  764.         mov     ecx,ed_text_color
  765.         test    dword ed_flags,ed_pass
  766.         jnz     .password
  767.         mov     edx,ed_text
  768.         add     edx,ed_offset
  769.         mcall
  770. @@:
  771.         ret
  772.  
  773. .password:
  774.         mov     ebp,esi
  775.         mov     esi,1
  776.         mov     edx,txt_pass
  777. @@:
  778.         mcall
  779.         rol     ebx,16
  780.         add     ebx,ed_char_width
  781.         rol     ebx,16
  782.         dec     ebp
  783.         jnz     @b
  784.         ret
  785.  
  786. txt_pass db '*'
  787. ;----------------------------------------------------------
  788. ;--- ¯à®æ¥¤ãà  ¯à®à¨á®¢ª¨ ä®­  ----------------------------
  789. ;----------------------------------------------------------
  790. edit_box.draw_bg:
  791.         mov     ebx,ed_left
  792.         inc     ebx
  793.         shl     ebx,16
  794.         add     ebx,ed_width
  795.         dec     ebx
  796.         mov     edx,ed_color
  797.         test    word ed_flags, ed_disabled
  798.         jz      edit_box.draw_bg_eax
  799.         mov     edx, 0xCACACA   ; TODO: add disabled_color field to editbox struct
  800. edit_box.draw_bg_eax:
  801.         mov     ecx,ed_top
  802.         inc     ecx
  803.         shl     ecx,16
  804.         add     ecx,ed_height
  805.         mcall   SF_DRAW_RECT
  806.         ret
  807.  
  808. ;----------------------------------------------------------
  809. ;--- ¯à®æ¥¤ãà  ¯®«ã祭¨ï ª®«¨ç¥á⢠ ᨬ¢®«®¢ ¢ ⥪ã饩 è¨à¨­¥ ª®¬¯®­¥­â 
  810. ;----------------------------------------------------------
  811. edit_box.get_n:
  812.         mov     eax,ed_width
  813.         sub     eax,4
  814.         xor     edx,edx
  815.         div     word ed_char_width
  816.         ret
  817.  
  818. ;----------------------------------------------------------
  819. ;------------------ Draw Cursor Procedure -----------------
  820. ;----------------------------------------------------------
  821. ; in: ebp = Color
  822. edit_box.clear_cursor:
  823.         movzx   ebx, word cl_curs_x
  824.         cmp     ebx, ed_left ;¯®¯ ¤ ¥â «¨ ªãàá®à ⥪á⮢®¥ ¯®«¥?
  825.         jle     @f
  826.         mov     edx, ebp
  827.         movzx   ecx, word cl_curs_y
  828.         cmp     ecx, ed_top
  829.         jg      edit_box.draw_curs
  830. @@:
  831.         ret
  832.  
  833. edit_box.draw_cursor:
  834.         mov     edx, ed_text_color
  835.         mov     eax, ed_pos
  836.         sub     eax, ed_offset
  837.         mul     dword ed_char_width
  838.         mov     ebx, eax
  839.         add     ebx, ed_left
  840.         inc     ebx
  841.         mov     ecx, ed_top
  842.         add     ecx, 2
  843.         mov     cl_curs_x, bx
  844.         mov     cl_curs_y, cx
  845. edit_box.draw_curs:
  846.         mov     eax, ebx
  847.         shl     ebx, 16
  848.         or      ebx, eax
  849.         mov     eax, ecx
  850.         shl     ecx, 16
  851.         or      ecx, eax
  852.         add     ecx, ed_height
  853.         sub     ecx, 3
  854.         mcall   SF_DRAW_LINE
  855.         ret
  856.  
  857. ;----------------------------------------------------------
  858. ;--- ¯à®æ¥¤ãà  à¨á®¢ ­¨ï à ¬ª¨ ----------------------------
  859. ;----------------------------------------------------------
  860. edit_box.draw_border:
  861.         test    word ed_flags,ed_focus
  862.         mov     edx,ed_focus_border_color
  863.         jne     @f
  864.         mov     edx,ed_blur_border_color
  865. @@:
  866.         mov     ebx,ed_left
  867.         mov     ecx,ebx
  868.         shl     ebx,16
  869.         add     ebx,ecx
  870.         add     ebx,ed_width
  871.         mov     ecx,ed_top
  872.         mov     esi,ecx
  873.         shl     ecx,16
  874.         add     ecx,esi
  875.         mcall   SF_DRAW_LINE ; top
  876.         mov     esi,ecx
  877.         inc     ecx
  878.         add     ecx,ed_height
  879.         mov     ebp,ecx
  880.         shl     ecx,16
  881.         mov     cx,bp
  882.         mcall   ; bottom
  883.         mov     cx,si
  884.         mov     ebp,ebx
  885.         sub     ebx,ed_width
  886.         mcall   ; left
  887.         mov     ebx,ebp
  888.         shl     ebx,16
  889.         mov     bx,bp
  890.         mcall   ; right
  891.         ret
  892.  
  893. ;----------------------------------------------------------
  894. ;--- ¯à®¢¥àª , § è¥« «¨ ªãàá®à §  £à ­¨æë ¨, ¥á«¨ ­ ¤®, ---
  895. ;--- ¨§¬¥­ï¥¬ ᬥ饭¨¥ ------------------------------------
  896. ;--- ¥á«¨ ᬥ饭¨¥ ¡ë«®, ãáâ ­®¢ª  ä« £  ed_offset_cl, ¨­ ç¥,
  897. ; ¥á«¨ ­¨ç¥£® ­¥ ¨§¬¥­¨«®áì, â® ¢ëáâ ¢«¥­¨¥ ed_offset_fl
  898. ; ¢ ®¡é¥© ¡¨â®¢®© ¬ âà¨æ¥ á®áâ®ï­¨ï ª®¬¯®­¥­â®¢ word ed_flags
  899. ;----------------------------------------------------------
  900. edit_box.check_offset:
  901.         pushad
  902.         mov     ecx,ed_pos
  903.         mov     ebx,ed_offset
  904.         cmp     ebx,ecx
  905.         ja      edit_box.sub_8
  906.         push    ebx
  907.         call    edit_box.get_n
  908.         pop     ebx
  909.         mov     edx,ebx
  910.         add     edx,eax
  911.         inc     edx     ;­¥®¡å®¤¨¬® ¤«ï ­®à¬ «ì­®£® ¯®«®¦¥­¨ï ªãàá®à  ¢ ªà ©­¥© «¥¢®© ¯®§¨æ¨¨
  912.         cmp     edx,ecx
  913.         ja      @f
  914.         mov     edx,ed_size
  915.         cmp     edx,ecx
  916.         je      edit_box.add_end
  917.         sub     edx,ecx
  918.         cmp     edx,8
  919.         jbe     edit_box.add_8
  920.         add     ebx,8
  921.         jmp     edit_box.chk_d
  922.  
  923. @@:     or      word ed_flags,ed_offset_fl
  924.         popad
  925.         ret
  926.  
  927. edit_box.sub_8:
  928.         test    ecx,ecx
  929.         jz      @f
  930.         sub     ebx,8   ;ebx=ed_offset
  931.         ja      edit_box.chk_d
  932. @@:
  933.         xor     ebx,ebx
  934.         jmp     edit_box.chk_d
  935.  
  936. edit_box.add_end:
  937.         sub     edx,eax
  938.         mov     ebx,edx
  939.         jmp     edit_box.chk_d
  940.  
  941. edit_box.add_8:
  942.         add     ebx,edx
  943. edit_box.chk_d:
  944.         mov     ed_offset,ebx
  945.         call    edit_box.draw_bg
  946.         and     word ed_flags,ed_offset_cl
  947.         popad
  948.         ret
  949.  
  950. align 4
  951. proc edit_box_set_text, edit:dword, text:dword
  952.         pushad
  953.         mov     edi,[edit]
  954.         mov     ecx,ed_max
  955.         inc     ecx
  956.         mov     edi,[text]
  957.         xor     al,al
  958.         cld
  959.         repne scasb
  960.         mov     ecx,edi
  961.         mov     edi,[edit]
  962.         mov     esi,[text]
  963.         sub     ecx,esi
  964.         dec     ecx
  965.         mov     ed_size,ecx
  966.         mov     ed_pos,ecx
  967.         and     word ed_flags,ed_shift_cl
  968.         mov     edi,ed_text
  969.         repne movsb
  970.         mov     byte[edi],0
  971.         popad
  972.         ret
  973. endp
  974.  
  975. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  976. ;”㭪樨 ¤«ï à ¡®âë á key
  977. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  978.  
  979. ;Ž¡à ¡®âª  Shift ¤«ï á­ïâ¨ï ¢ë¤¥«¥­¨ï ­¥¨§¢¥áâ­®© ®¡« áâ¨
  980. edit_box_key.shift:
  981.         call    edit_box.draw_bg
  982.         test    word ed_flags,ed_shift
  983.         je      edit_box_key.f_exit
  984.         mov     ebp,shift_color
  985.         or      word ed_flags,ed_shift_bac ;ãáâ ­®¢ª  ä« £ , ¢ë¤¥«¥­­®© ®¡« áâ¨
  986.         movzx   ebx, word ed_shift_pos
  987.         call    edit_box_key.sh_cl_
  988.         jmp     edit_box.draw_cursor_text
  989.  
  990. edit_box_key.f_exit:
  991.         call    edit_box.check_offset
  992.         and     word ed_flags,ed_shift_cl
  993.         call    edit_box_key.enable_null
  994.         jmp     edit_box.draw_cursor_text
  995.  
  996. edit_box_key.sh_cl_:
  997. ;®¡à ¡®âª  ®ç¨á⪨, ¯à¨ «¥¢®¬ - ¯à ¢®¬ ¤¢¨¦¥­¨¨ ¢ë¤¥«¥­¨ï
  998. ;¤«ï ®¡à ¡®âª¨ á­ïâ¨ï ¢ë¤¥«¥­¨ï
  999. ;¢å®¤­ë¥ ¯ à ¬¥âàë ebp=color ebx=ed_shift_pos
  1000.         mov     eax,ed_pos
  1001.         cmp     eax,ebx
  1002.         jae     edit_box_key.sh_n
  1003.         push    eax  ;¬¥­ì襥 ¢ eax
  1004.         push    ebx  ;¡®«ì襥
  1005.         jmp     edit_box_key.sh_n1
  1006.  
  1007. edit_box_key.sh_n:
  1008.         push    ebx
  1009.         push    eax
  1010. edit_box_key.sh_n1:
  1011.         call    edit_box.check_offset
  1012.         call    edit_box.get_n
  1013.         mov     edx,eax ;size of ed_box
  1014.         mov     ecx,ed_offset
  1015.         add     eax,ecx ;eax = w_off= ed_offset+width
  1016.         mov     edx,eax ;save
  1017.         pop     ebx     ;¡®«ì襥
  1018.         pop     eax     ;¬¥­ì襥
  1019.         cmp     eax,ecx         ;áà ¢­¥­¨¥ ¬¥­ì襣® á offset.
  1020.         jae     edit_box_key.f_f            ;¥á«¨ ¡®«ìè¥
  1021.         xor     eax,eax
  1022.         cmp     edx,ebx         ;cà ¢­¨¬ à §¬¥à w_off á ¡®«ì訬
  1023.         jnb     @f
  1024.         mov     ebx,edx
  1025. @@:
  1026.         sub     ebx,ecx
  1027.         jmp     edit_box_key.nxt_f
  1028.  
  1029. edit_box_key.f_f:
  1030.         sub     eax,ecx
  1031.         cmp     edx,ebx         ;cà ¢­¨¬ à §¬¥à w_off á ¡®«ì訬
  1032.         jle     @f
  1033.         sub     ebx,ecx
  1034.         sub     ebx,eax
  1035.         jmp     edit_box_key.nxt_f
  1036.  
  1037. @@:     mov     ebx,edx
  1038.         sub     ebx,ecx
  1039.         sub     ebx,eax
  1040. edit_box_key.nxt_f:
  1041.         mul     dword ed_char_width
  1042.         xchg    eax,ebx
  1043.         mul     dword ed_char_width
  1044.         add     ebx,ed_left
  1045.         inc     ebx
  1046.         shl     ebx,16
  1047.         inc     eax
  1048.         mov     bx, ax
  1049.         mov     edx,ebp ;shift_color
  1050.         call    edit_box.draw_bg_eax
  1051.         jmp     edit_box_key.enable_null
  1052.  
  1053. ;“áâ ­®¢ª - á­ï⨥ ¢ë¤¥«¥­¨ï ¢ ®¤¨­ ᨬ¢®«
  1054. edit_box_key.drw_sim:
  1055.         mov     eax,ed_pos
  1056.         call    edit_box_key.draw_rectangle
  1057.         jmp     edit_box_key.enable_null
  1058.  
  1059. ;”ã­ªæ¨ï ãáâ ­®¢ª¨ ¢ë¤¥«¥­¨ï ¯à¨ ¤¢¨¦¥­¨¨ ¢«¥¢® ¨ ¢¯à ¢® ¨ ­ ¦ â¨¨ shift
  1060. edit_box_key.draw_wigwag:
  1061.         mov     ebp,shift_color
  1062.         call    edit_box.clear_cursor
  1063.         or      word ed_flags,ed_shift_bac ;ãáâ ­®¢ª  ä« £  ¢ë¤¥«¥­­®© ®¡« áâ¨
  1064.         mov     ebp,shift_color
  1065.         mov     eax,ed_pos
  1066.         test    word ed_flags,ed_left_fl
  1067.         jnz     edit_box_key.draw_rectangle
  1068.         dec     eax
  1069.         jmp     edit_box_key.draw_rectangle
  1070.  
  1071. ;”ã­ªæ¨ï 㤠«¥­¨ï ¢ë¤¥«¥­¨ï ¯à¨ ¤¢¨¦¥­¨¨ ¢«¥¢® ¨ ¢¯à ¢® ¨ ­ ¦ â¨¨ shift
  1072. edit_box_key.draw_wigwag_cl:
  1073.         mov     ebp,ed_color
  1074.         call    edit_box.clear_cursor
  1075.         mov     ebp,ed_color
  1076.         mov     eax,ed_pos
  1077.         test    word ed_flags,ed_left_fl
  1078.         jnz     edit_box_key.draw_rectangle
  1079.         dec     eax
  1080.         jmp     edit_box_key.draw_rectangle
  1081.  
  1082. ;¢å®¤­®© ¯ à ¬¥âà ebx - ed_pos
  1083. edit_box_key.sh_first_sh:
  1084.         test    word ed_flags,ed_shift
  1085.         je      @f
  1086.         mov     ed_shift_pos_old,bx
  1087.         test    word ed_flags,ed_shift_on
  1088.         jne     @f
  1089.         mov     ed_shift_pos,bx
  1090.         or      word ed_flags,ed_shift_on
  1091. @@:     ret
  1092. ;Ž¡à ¡®âª  ªà ©­¨å ¯®«®¦¥­¨© ¢ editbox ¯à¨ ­ ¦ â®¬ shift
  1093. ;¯à®¨§¢®¤¨â á­ï⨥ ¢ë¤¥«¥­¨ï, ¥á«¨ ­¥â shift
  1094. ;¨­ ç¥ ¢®®¡é¥ ¢ë室¨â
  1095. edit_box_key.sh_st_of:
  1096.         test    word ed_flags,ed_shift
  1097.         jne     @f
  1098.         test    word ed_flags,ed_shift_bac
  1099.         je      @f
  1100.         call    edit_box.draw_bg
  1101.         mov     ebp,ed_color
  1102.         movzx   ebx, word ed_shift_pos
  1103.         call    edit_box_key.sh_cl_  ;®ç¨á⪠ ¢ë¤¥«¥­®£® äà £¬¥­â 
  1104.         and     word ed_flags,ed_shift_cl ; ®ç¨á⪠ ®â ⮣®, çâ® ã¡à «¨ ¢ë¤¥«¥­¨¥
  1105.         jmp     edit_box.draw_cursor_text
  1106.  
  1107. @@:     and     word ed_flags,ed_shift_off
  1108.         popad
  1109.         ret     4
  1110. ;¯à®¢¥àª  á®áâ®ï­¨ï shift, ¡ë« «¨ ®­ ­ ¦ â à ­ìè¥?
  1111. edit_box_key.sh_enable:
  1112.         test    word ed_flags,ed_shift
  1113.         jne     edit_box_key.sh_ext_en ;­ à¨á®¢ âì § ªà è¥­­ë© ¯àאַ㣮«ì­¨ª
  1114.         test    word ed_flags,ed_shift_bac
  1115.         je      @f
  1116.         call    edit_box.check_offset
  1117.         mov     ebp,ed_color
  1118.         movzx   ebx, word ed_shift_pos
  1119.         call    edit_box_key.sh_cl_  ;®ç¨á⪠ ¢ë¤¥«¥­­®£® äà £¬¥­â 
  1120.         call    edit_box_key.draw_wigwag_cl
  1121.         and     word ed_flags,ed_shift_cl ; 1¢ à ­¥ ­ã¦­®
  1122.         ret
  1123.  
  1124. @@:     mov     ebp,ed_color
  1125.         call    edit_box.clear_cursor
  1126.         jmp     edit_box.check_offset
  1127.  
  1128. edit_box_key.sh_ext_en:
  1129.         call    edit_box.check_offset
  1130.         test    word ed_flags,ed_offset_fl
  1131.         je      @f
  1132. ;¨á®¢ ­¨¥ § ªà è¥­­ëå ¯àאַ㣮«ì­¨ª®¢ ¨ ¨å ®ç¨á⪠
  1133.         movzx   eax, word ed_shift_pos
  1134.         mov     ebx,ed_pos
  1135.         movzx   ecx, word ed_shift_pos_old
  1136. ;¯à®¢¥àª  ¨ à¨á®¢ ­¨¥ § ªà è¥­­ëå ®¡« á⥩
  1137.         cmp     eax,ecx
  1138.         je      edit_box_key.1_shem
  1139.         jb      edit_box_key.smaller
  1140.         cmp     ecx,ebx
  1141.         ja      edit_box_key.1_shem
  1142.         call    edit_box_key.draw_wigwag_cl ;clear
  1143.         jmp     edit_box_key.sh_e_end
  1144.  
  1145. edit_box_key.smaller:
  1146.         cmp     ecx,ebx
  1147.         jb      edit_box_key.1_shem
  1148.         call    edit_box_key.draw_wigwag_cl ;clear
  1149.         jmp     edit_box_key.sh_e_end
  1150.  
  1151. edit_box_key.1_shem:
  1152.         call    edit_box_key.draw_wigwag
  1153. edit_box_key.sh_e_end:
  1154.         and     word ed_flags,ed_shift_off
  1155.         ret
  1156.  
  1157. @@:     mov     ebp,shift_color
  1158.         movzx   ebx, word ed_shift_pos
  1159.         call    edit_box_key.sh_cl_
  1160.         jmp     edit_box_key.sh_e_end
  1161. ;äã­ªæ¨ï ¤«ï ®¡à ¡®âª¨ shift ¯à¨ ­ ¦ â¨¨ home and end
  1162. edit_box_key.sh_home_end:
  1163.         mov     ebp,ed_color
  1164.         call    edit_box.clear_cursor
  1165.         test    word ed_flags,ed_shift_bac
  1166.         je      @f
  1167.         mov     ebp,ed_color
  1168.         movzx   ebx, word ed_shift_pos_old
  1169.         call    edit_box_key.sh_cl_
  1170. @@:
  1171.         test    word ed_flags,ed_shift
  1172.         je      edit_box_key.sh_exit_ ;¢ë©â¨
  1173.         mov     ebp,shift_color
  1174.         movzx   ebx, word ed_shift_pos
  1175.         call    edit_box_key.sh_cl_
  1176.         or      word ed_flags,ed_shift_bac ;ãáâ ­®¢ª  ä« £ , ¢ë¤¥«¥­­®© ®¡« áâ¨
  1177.         jmp     edit_box_key.sh_e_end
  1178.  
  1179. edit_box_key.sh_exit_:
  1180.         call    edit_box.draw_bg
  1181.         jmp     edit_box.check_offset
  1182.  
  1183. ;äã­ªæ¨ï ¢­¥á¥­¨ï 0 ¯®  ¤à¥áã ed_size+1
  1184. edit_box_key.enable_null:
  1185.         pusha
  1186.         mov     eax,ed_size
  1187.         mov     ebx,ed_text
  1188.         test    eax,eax
  1189.         add     eax,ebx
  1190.         jne     @f
  1191.         inc     eax
  1192. @@:     xor     ebx,ebx
  1193.         mov     [eax],bl
  1194.         popad
  1195.         ret
  1196.  
  1197. ;- 㤠«¥­¨¥ ᨬ¢®« 
  1198. ;‚室­ë¥ ¤ ­­ë¥ edx=ed_size;ecx=ed_pos
  1199. edit_box_key.del_char:
  1200.         mov     esi,ed_text
  1201.         test    word ed_flags,ed_shift_on
  1202.         je      @f
  1203.         movzx   eax, word ed_shift_pos
  1204.         mov     ebx,esi
  1205.         cmp     eax,ecx
  1206.         jae     edit_box_key.dh_n
  1207.         mov     ed_pos,eax      ;çâ®¡ë ­¥ ¡ë«® ã¡¥£ ­¨ï ªãàá®à 
  1208.         mov     ebp,ecx
  1209.         sub     ebp,eax
  1210.         add     ebx,eax  ;eax ¬¥­ìè¥
  1211.         sub     edx,ecx
  1212.         add     esi,ecx
  1213.         mov     ed_shift_pos,bp
  1214.         jmp     edit_box_key.del_ch_sh
  1215.  
  1216. edit_box_key.dh_n:
  1217.         mov     ebp,eax
  1218.         sub     ebp,ecx
  1219.         add     ebx,ecx
  1220.         sub     edx,eax
  1221.         add     esi,eax
  1222.         mov     ed_shift_pos,bp
  1223.         jmp     edit_box_key.del_ch_sh
  1224.  
  1225. @@:     add     esi,ecx ;㪠§ â¥«ì + ᬥ饭¨¥ ª ॠ«ì­®¬ã ¡ãä¥àã
  1226.         mov     ebx,esi
  1227.         inc     esi
  1228.         cld
  1229.         sub     edx,ecx
  1230. edit_box_key.del_ch_sh:
  1231.         push    edi
  1232.         mov     edi,ebx
  1233. @@:
  1234.         lodsb
  1235.         stosb
  1236.         dec     edx
  1237.         jns     @b
  1238.         pop     edi
  1239.         ret
  1240. ;¢ëç¨á«¨âì § ªà è¨¢ ¥¬ãî ®¡« áâì
  1241. ;ᮣ« è¥­¨¥ ¢ ebp - ¯¥à¥¤ ¥âáï ed_size
  1242. edit_box_key.clear_bg:
  1243.         call    edit_box.get_n  ;¯®«ãç¨âì à §¬¥à ¢ ᨬ¢®« å è¨à¨­ë ª®¬¯®­¥­â 
  1244.         push    eax
  1245.         mov     ebx,ed_offset
  1246.         add     eax,ebx ;eax = w_off= ed_offset+width
  1247.         mov     ebx,ebp ;ed_size
  1248.         cmp     eax,ebx
  1249.         jb      @f
  1250.         mov     eax,ed_pos
  1251.         sub     ebx,eax
  1252.         mov     ecx,ed_offset
  1253.         sub     eax,ecx
  1254.         jmp     edit_box_key.nxt
  1255.  
  1256. @@:     mov     ebx,ed_pos
  1257.         push    ebx
  1258.         sub     eax,ebx
  1259.         mov     ebx,eax ;It is not optimal
  1260.         pop     eax     ;ed_pos
  1261.         mov     ecx,ed_offset
  1262.         sub     eax,ecx
  1263. edit_box_key.nxt:
  1264.         mov     ebp,eax  ;¯à®¢¥àª  ­  ¢ë室 § ªà è¨¢ ¥¬®© ®¡« á⨠§  ¯à¥¤¥«ë ¤«¨­ë
  1265.         add     ebp,ebx
  1266.         pop     edx
  1267.         cmp     ebp,edx
  1268.         je      @f
  1269.         inc     ebx
  1270. @@:
  1271.         mul     dword ed_char_width
  1272.         xchg    eax,ebx
  1273.         mul     dword ed_char_width
  1274.         add     ebx,ed_left
  1275.         inc     ebx
  1276.         shl     ebx,16
  1277.         inc     eax
  1278.         mov     bx, ax
  1279.         mov     edx,ed_color
  1280.         jmp     edit_box.draw_bg_eax
  1281.  
  1282. ;;;;;;;;;;;;;;;;;;;
  1283. ;;; Ž¡à ¡®âª  ¯à¨¬¨â¨¢®¢
  1284. ;;;;;;;;;;;;;;;;;;;;
  1285. ; à¨á®¢ âì ¯àאַ㣮«ì­¨ª, 梥⠯¥à¥¤ ¥âáï ¢ ebp
  1286. ;¢å®¤­ë¥ ¯ à ¬¥âàë:
  1287. ;eax=dword ed_pos
  1288. ;ebp=-梥â ed_color or shift_color
  1289. edit_box_key.draw_rectangle:
  1290.         sub     eax,ed_offset
  1291.         mul     dword ed_char_width
  1292.         add     eax,ed_left
  1293.         inc     eax
  1294.         shl     eax,16
  1295.         add     eax,ed_char_width
  1296.         mov     ebx,eax
  1297.         mov     edx,ebp
  1298.         jmp     edit_box.draw_bg_eax
  1299.  
  1300. ;;;;;;;;;;;;;;;;;;
  1301. ;;à®¢¥àª  ­ ¦ â «¨ shift
  1302. ;;;;;;;;;;;;;;;;;;
  1303. edit_box_key.check_shift_ctrl_alt:
  1304.         pusha
  1305.         mcall   SF_KEYBOARD,SSF_GET_CONTROL_KEYS
  1306.         test    al,11b
  1307.         je      @f
  1308.         or      word ed_flags,ed_shift   ;ãáâ ­®¢¨¬ ä« £ Shift
  1309. @@:
  1310.         and     word ed_flags,ed_ctrl_off ; ®ç¨á⨬ ä« £ Ctrl
  1311.         test    al,1100b
  1312.         je      @f
  1313.         or      word ed_flags,ed_ctrl_on   ;ãáâ ­®¢¨¬ ä« £ Ctrl
  1314. @@:
  1315.         and     word ed_flags,ed_alt_off ; ®ç¨á⨬ ä« £ Alt
  1316.         test    al,110000b
  1317.         je      @f
  1318.         or      word ed_flags,ed_alt_on   ;ãáâ ­®¢¨¬ ä« £ Alt
  1319. @@:
  1320.         popad
  1321.         ret
  1322.  
  1323. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1324. ;”㭪樨 ¤«ï à ¡®âë á mouse
  1325. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1326. edit_box_mouse.mouse_wigwag:
  1327.         push    eax
  1328.         call    edit_box.draw_bg
  1329.         call    edit_box.draw_shift
  1330.         pop     eax
  1331.         or      word ed_flags,ed_shift_bac+ed_shift_on+ed_shift
  1332. ;Ž¡à ¡®âª  ¯®«®¦¥­¨ï ¢ë¤¥«¥­­®£® ⥪áâ , ª®£¤  ¯à®¨á室¨â ¢ë室 §  ¯à¥¤¥«ë editbox
  1333.         test    eax,eax
  1334.         js      edit_box_mouse.mleft
  1335.         shr     eax,16
  1336.         sub     eax,ed_left
  1337.         jc      edit_box_mouse.mleft
  1338.         cmp     ed_width,eax
  1339.         jc      edit_box_mouse.mright
  1340.         xor     edx,edx
  1341.         div     word ed_char_width
  1342. ;Ž¡à ¡®âª  ¯®«®¦¥­¨ï ¢ë¤¥«¥­­®£® ⥪áâ , ¢ ¯à¥¤¥« å ®¡« á⨠editbox
  1343. ;®«ã稫¨ ª®®à¤¨­ âë ¢ eax ¬ë誨, â.¥. ªã¤  ®­  ¯¥à¥¬¥á⨫ áì
  1344. ;¨á®¢ ­¨¥ § ªà è¥­­ëå ¯àאַ㣮«ì­¨ª®¢ ¨ ¨å ®ç¨á⪠
  1345.         add     eax,ed_offset
  1346.         cmp     eax,ed_size
  1347.         ja      edit_box_mouse.mwigvag
  1348. edit_box_mouse.mdraw:
  1349.         mov     ed_pos,eax
  1350. ;¨á®¢ ­¨¥ § ªà è¥­­ëå ¯àאַ㣮«ì­¨ª®¢ ¨ ¨å ®ç¨á⪠
  1351.         movzx   ecx, word ed_shift_pos
  1352.         movzx   ebx, word ed_shift_pos_old
  1353.         mov     ed_shift_pos_old,ax
  1354. ;¯à®¢¥àª  ¨ à¨á®¢ ­¨¥ § ªà è¥­­ëå ®¡« á⥩
  1355.         cmp     ecx,ebx
  1356.         je      edit_box_mouse.m1_shem  ;¤¢¨¦¥­¨ï ­¥ ¡ë«® à ­¥¥
  1357.         jb      edit_box_mouse.msmaller ;¡ë«® ¤¢¨¦¥­¨¥ ->
  1358.         cmp     ebx,eax
  1359.         ja      edit_box_mouse.m1_shem  ;¡ë«® ¤¢¨¦¥­¨¥ <-
  1360.         je      edit_box_mouse.mwigvag
  1361.         mov     ebp,ed_color
  1362.         call    edit_box_key.sh_cl_     ;®ç¨áâ¨âì ®¡« áâì c ed_pos ed_shift_pos_old
  1363.         jmp     edit_box_mouse.mwigvag
  1364.  
  1365. edit_box_mouse.msmaller:
  1366.         cmp     ebx,eax
  1367.         jb      edit_box_mouse.m1_shem
  1368.         mov     ebp,ed_color
  1369.         call    edit_box_key.sh_cl_
  1370.         jmp     edit_box_mouse.mwigvag
  1371.  
  1372. edit_box_mouse.m1_shem:
  1373.         mov     ebp,shift_color
  1374.         mov     ebx,ecx
  1375.         call    edit_box_key.sh_cl_
  1376. edit_box_mouse.mwigvag:
  1377.         and     word ed_flags,ed_shift_mcl
  1378.         jmp     edit_box.draw_cursor_text
  1379.  
  1380. edit_box_mouse.mleft:
  1381.         mov     eax,ed_pos
  1382.         cmp     eax,0
  1383.         jbe     edit_box_mouse.mwigvag
  1384.         dec     eax
  1385.         call    edit_box.check_offset
  1386.         push    eax
  1387.         movzx   ebx, word ed_shift_pos
  1388.         mov     ebp,shift_color
  1389.         call    edit_box_key.sh_cl_
  1390.         pop     eax
  1391.         jmp     edit_box_mouse.mdraw
  1392.  
  1393. edit_box_mouse.mright:
  1394.         mov     eax,ed_pos
  1395.         mov     ebx,ed_size
  1396.         cmp     eax,ebx
  1397.         jae     edit_box_mouse.mwigvag
  1398.         inc     eax
  1399.         call    edit_box.check_offset
  1400.         movzx   ebx, word ed_shift_pos
  1401.         mov     ebp,shift_color
  1402.         push    eax
  1403.         call    edit_box_key.sh_cl_
  1404.         pop     eax
  1405.         jmp     edit_box_mouse.mdraw
  1406.  
  1407.  
  1408. ed_struc_size=84
  1409.