Subversion Repositories Kolibri OS

Rev

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