Subversion Repositories Kolibri OS

Rev

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