Subversion Repositories Kolibri OS

Rev

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