Subversion Repositories Kolibri OS

Rev

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

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