Subversion Repositories Kolibri OS

Rev

Rev 6994 | 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.         mov     edx, ebp
  785.         movzx   ebx, word cl_curs_x
  786.         movzx   ecx, word cl_curs_y  
  787.         jmp     edit_box.draw_curs
  788.  
  789. edit_box.draw_cursor:
  790.         mov     edx, ed_text_color          
  791.         mov     eax, ed_pos
  792.         sub     eax, ed_offset
  793.         mul     dword ed_char_width        
  794.         mov     ebx, eax
  795.         add     ebx, ed_left
  796.         inc     ebx    
  797.         mov     ecx, ed_top
  798.         add     ecx, 2        
  799.         mov     cl_curs_x, bx
  800.         mov     cl_curs_y, cx
  801. edit_box.draw_curs:        
  802.         mov     eax, ebx        
  803.         shl     ebx, 16
  804.         or      ebx, eax
  805.         mov     eax, ecx                    
  806.         shl     ecx, 16
  807.         or      ecx, eax
  808.         add     ecx, ed_height
  809.         sub     ecx, 3
  810.         mcall   SF_DRAW_LINE
  811.         ret
  812.  
  813. ;----------------------------------------------------------
  814. ;--- ¯à®æ¥¤ãà  à¨á®¢ ­¨ï à ¬ª¨ ----------------------------
  815. ;----------------------------------------------------------
  816. edit_box.draw_border:
  817.         test    word ed_flags,ed_focus
  818.         mov     edx,ed_focus_border_color
  819.         jne     @f
  820.         mov     edx,ed_blur_border_color
  821. @@:
  822.         mov     ebx,ed_left
  823.         mov     ecx,ebx
  824.         shl     ebx,16
  825.         add     ebx,ecx
  826.         add     ebx,ed_width
  827.         mov     ecx,ed_top
  828.         mov     esi,ecx
  829.         shl     ecx,16
  830.         add     ecx,esi
  831.         mcall   SF_DRAW_LINE ; top
  832.         mov     esi,ecx
  833.         inc     ecx
  834.         add     ecx,ed_height
  835.         mov     ebp,ecx
  836.         shl     ecx,16
  837.         mov     cx,bp
  838.         mcall   ; bottom
  839.         mov     cx,si
  840.         mov     ebp,ebx
  841.         sub     ebx,ed_width
  842.         mcall   ; left
  843.         mov     ebx,ebp
  844.         shl     ebx,16
  845.         mov     bx,bp
  846.         mcall   ; right
  847.         ret
  848.  
  849. ;----------------------------------------------------------
  850. ;--- ¯à®¢¥àª , § è¥« «¨ ªãàá®à §  £à ­¨æë ¨, ¥á«¨ ­ ¤®, ---
  851. ;--- ¨§¬¥­ï¥¬ ᬥ饭¨¥ ------------------------------------
  852. ;--- ¥á«¨ ᬥ饭¨¥ ¡ë«®, ãáâ ­®¢ª  ä« £  ed_offset_cl, ¨­ ç¥,
  853. ; ¥á«¨ ­¨ç¥£® ­¥ ¨§¬¥­¨«®áì, â® ¢ëáâ ¢«¥­¨¥ ed_offset_fl
  854. ; ¢ ®¡é¥© ¡¨â®¢®© ¬ âà¨æ¥ á®áâ®ï­¨ï ª®¬¯®­¥­â®¢ word ed_flags
  855. ;----------------------------------------------------------
  856. edit_box.check_offset:
  857.         pushad
  858.         mov     ecx,ed_pos
  859.         mov     ebx,ed_offset
  860.         cmp     ebx,ecx
  861.         ja      edit_box.sub_8
  862.         push    ebx
  863.         call    edit_box.get_n
  864.         pop     ebx
  865.         mov     edx,ebx
  866.         add     edx,eax
  867.         inc     edx     ;­¥®¡å®¤¨¬® ¤«ï ­®à¬ «ì­®£® ¯®«®¦¥­¨ï ªãàá®à  ¢ ªà ©­¥© «¥¢®© ¯®§¨æ¨¨
  868.         cmp     edx,ecx
  869.         ja      @f
  870.         mov     edx,ed_size
  871.         cmp     edx,ecx
  872.         je      edit_box.add_end
  873.         sub     edx,ecx
  874.         cmp     edx,8
  875.         jbe     edit_box.add_8
  876.         add     ebx,8
  877.         jmp     edit_box.chk_d
  878.  
  879. @@:     or      word ed_flags,ed_offset_fl
  880.         popad
  881.         ret
  882.  
  883. edit_box.sub_8:
  884.         test    ecx,ecx
  885.         jz      @f
  886.         sub     ebx,8   ;ebx=ed_offset
  887.         ja      edit_box.chk_d
  888. @@:
  889.         xor     ebx,ebx
  890.         jmp     edit_box.chk_d
  891.  
  892. edit_box.add_end:
  893.         sub     edx,eax
  894.         mov     ebx,edx
  895.         jmp     edit_box.chk_d
  896.  
  897. edit_box.add_8:
  898.         add     ebx,edx
  899. edit_box.chk_d:
  900.         mov     ed_offset,ebx
  901.         call    edit_box.draw_bg
  902.         and     word ed_flags,ed_offset_cl
  903.         popad
  904.         ret
  905.  
  906. align 4
  907. proc edit_box_set_text, edit:dword, text:dword
  908.         pushad
  909.         mov     edi,[edit]
  910.         mov     ecx,ed_max
  911.         inc     ecx
  912.         mov     edi,[text]
  913.         xor     al,al
  914.         cld
  915.         repne scasb
  916.         mov     ecx,edi
  917.         mov     edi,[edit]
  918.         mov     esi,[text]
  919.         sub     ecx,esi
  920.         dec     ecx
  921.         mov     ed_size,ecx
  922.         mov     ed_pos,ecx
  923.         and     word ed_flags,ed_shift_cl
  924.         mov     edi,ed_text
  925.         repne movsb
  926.         mov     byte[edi],0
  927.         popad
  928.         ret
  929. endp
  930.  
  931. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  932. ;”㭪樨 ¤«ï à ¡®âë á key
  933. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  934.  
  935. ;Ž¡à ¡®âª  Shift ¤«ï á­ïâ¨ï ¢ë¤¥«¥­¨ï ­¥¨§¢¥áâ­®© ®¡« áâ¨
  936. edit_box_key.shift:
  937.         call    edit_box.draw_bg
  938.         test    word ed_flags,ed_shift
  939.         je      edit_box_key.f_exit
  940.         mov     ebp,shift_color
  941.         or      word ed_flags,ed_shift_bac ;ãáâ ­®¢ª  ä« £ , ¢ë¤¥«¥­­®© ®¡« áâ¨
  942.         movzx   ebx, word ed_shift_pos
  943.         call    edit_box_key.sh_cl_
  944.         jmp     edit_box.draw_cursor_text
  945.  
  946. edit_box_key.f_exit:
  947.         call    edit_box.check_offset
  948.         and     word ed_flags,ed_shift_cl
  949.         call    edit_box_key.enable_null
  950.         jmp     edit_box.draw_cursor_text
  951.  
  952. edit_box_key.sh_cl_:
  953. ;®¡à ¡®âª  ®ç¨á⪨, ¯à¨ «¥¢®¬ - ¯à ¢®¬ ¤¢¨¦¥­¨¨ ¢ë¤¥«¥­¨ï
  954. ;¤«ï ®¡à ¡®âª¨ á­ïâ¨ï ¢ë¤¥«¥­¨ï
  955. ;¢å®¤­ë¥ ¯ à ¬¥âàë ebp=color ebx=ed_shift_pos
  956.         mov     eax,ed_pos
  957.         cmp     eax,ebx
  958.         jae     edit_box_key.sh_n
  959.         push    eax  ;¬¥­ì襥 ¢ eax
  960.         push    ebx  ;¡®«ì襥
  961.         jmp     edit_box_key.sh_n1
  962.  
  963. edit_box_key.sh_n:
  964.         push    ebx
  965.         push    eax
  966. edit_box_key.sh_n1:
  967.         call    edit_box.check_offset
  968.         call    edit_box.get_n
  969.         mov     edx,eax ;size of ed_box
  970.         mov     ecx,ed_offset
  971.         add     eax,ecx ;eax = w_off= ed_offset+width
  972.         mov     edx,eax ;save
  973.         pop     ebx     ;¡®«ì襥
  974.         pop     eax     ;¬¥­ì襥
  975.         cmp     eax,ecx         ;áà ¢­¥­¨¥ ¬¥­ì襣® á offset.
  976.         jae     edit_box_key.f_f            ;¥á«¨ ¡®«ìè¥
  977.         xor     eax,eax
  978.         cmp     edx,ebx         ;cà ¢­¨¬ à §¬¥à w_off á ¡®«ì訬
  979.         jnb     @f
  980.         mov     ebx,edx
  981. @@:
  982.         sub     ebx,ecx
  983.         jmp     edit_box_key.nxt_f
  984.  
  985. edit_box_key.f_f:
  986.         sub     eax,ecx
  987.         cmp     edx,ebx         ;cà ¢­¨¬ à §¬¥à w_off á ¡®«ì訬
  988.         jle     @f
  989.         sub     ebx,ecx
  990.         sub     ebx,eax
  991.         jmp     edit_box_key.nxt_f
  992.  
  993. @@:     mov     ebx,edx
  994.         sub     ebx,ecx
  995.         sub     ebx,eax
  996. edit_box_key.nxt_f:
  997.         mul     dword ed_char_width
  998.         xchg    eax,ebx
  999.         mul     dword ed_char_width
  1000.         add     ebx,ed_left
  1001.         inc     ebx
  1002.         shl     ebx,16
  1003.         inc     eax
  1004.         mov     bx, ax
  1005.         mov     edx,ebp ;shift_color
  1006.         call    edit_box.draw_bg_eax
  1007.         jmp     edit_box_key.enable_null
  1008.  
  1009. ;“áâ ­®¢ª - á­ï⨥ ¢ë¤¥«¥­¨ï ¢ ®¤¨­ ᨬ¢®«
  1010. edit_box_key.drw_sim:
  1011.         mov     eax,ed_pos
  1012.         call    edit_box_key.draw_rectangle
  1013.         jmp     edit_box_key.enable_null
  1014.  
  1015. ;”ã­ªæ¨ï ãáâ ­®¢ª¨ ¢ë¤¥«¥­¨ï ¯à¨ ¤¢¨¦¥­¨¨ ¢«¥¢® ¨ ¢¯à ¢® ¨ ­ ¦ â¨¨ shift
  1016. edit_box_key.draw_wigwag:
  1017.         mov     ebp,shift_color
  1018.         call    edit_box.clear_cursor
  1019.         or      word ed_flags,ed_shift_bac ;ãáâ ­®¢ª  ä« £  ¢ë¤¥«¥­­®© ®¡« áâ¨
  1020.         mov     ebp,shift_color
  1021.         mov     eax,ed_pos
  1022.         test    word ed_flags,ed_left_fl
  1023.         jnz     edit_box_key.draw_rectangle
  1024.         dec     eax
  1025.         jmp     edit_box_key.draw_rectangle
  1026.  
  1027. ;”ã­ªæ¨ï 㤠«¥­¨ï ¢ë¤¥«¥­¨ï ¯à¨ ¤¢¨¦¥­¨¨ ¢«¥¢® ¨ ¢¯à ¢® ¨ ­ ¦ â¨¨ shift
  1028. edit_box_key.draw_wigwag_cl:
  1029.         mov     ebp,ed_color
  1030.         call    edit_box.clear_cursor
  1031.         mov     ebp,ed_color
  1032.         mov     eax,ed_pos
  1033.         test    word ed_flags,ed_left_fl
  1034.         jnz     edit_box_key.draw_rectangle
  1035.         dec     eax
  1036.         jmp     edit_box_key.draw_rectangle
  1037.  
  1038. ;¢å®¤­®© ¯ à ¬¥âà ebx - ed_pos
  1039. edit_box_key.sh_first_sh:
  1040.         test    word ed_flags,ed_shift
  1041.         je      @f
  1042.         mov     ed_shift_pos_old,bx
  1043.         test    word ed_flags,ed_shift_on
  1044.         jne     @f
  1045.         mov     ed_shift_pos,bx
  1046.         or      word ed_flags,ed_shift_on
  1047. @@:     ret
  1048. ;Ž¡à ¡®âª  ªà ©­¨å ¯®«®¦¥­¨© ¢ editbox ¯à¨ ­ ¦ â®¬ shift
  1049. ;¯à®¨§¢®¤¨â á­ï⨥ ¢ë¤¥«¥­¨ï, ¥á«¨ ­¥â shift
  1050. ;¨­ ç¥ ¢®®¡é¥ ¢ë室¨â
  1051. edit_box_key.sh_st_of:
  1052.         test    word ed_flags,ed_shift
  1053.         jne     @f
  1054.         test    word ed_flags,ed_shift_bac
  1055.         je      @f
  1056.         call    edit_box.draw_bg
  1057.         mov     ebp,ed_color
  1058.         movzx   ebx, word ed_shift_pos
  1059.         call    edit_box_key.sh_cl_  ;®ç¨á⪠ ¢ë¤¥«¥­®£® äà £¬¥­â 
  1060.         and     word ed_flags,ed_shift_cl ; ®ç¨á⪠ ®â ⮣®, çâ® ã¡à «¨ ¢ë¤¥«¥­¨¥
  1061.         jmp     edit_box.draw_cursor_text
  1062.  
  1063. @@:     and     word ed_flags,ed_shift_off
  1064.         popad
  1065.         ret     4
  1066. ;¯à®¢¥àª  á®áâ®ï­¨ï shift, ¡ë« «¨ ®­ ­ ¦ â à ­ìè¥?
  1067. edit_box_key.sh_enable:
  1068.         test    word ed_flags,ed_shift
  1069.         jne     edit_box_key.sh_ext_en ;­ à¨á®¢ âì § ªà è¥­­ë© ¯àאַ㣮«ì­¨ª
  1070.         test    word ed_flags,ed_shift_bac
  1071.         je      @f
  1072.         call    edit_box.check_offset
  1073.         mov     ebp,ed_color
  1074.         movzx   ebx, word ed_shift_pos
  1075.         call    edit_box_key.sh_cl_  ;®ç¨á⪠ ¢ë¤¥«¥­­®£® äà £¬¥­â 
  1076.         call    edit_box_key.draw_wigwag_cl
  1077.         and     word ed_flags,ed_shift_cl ; 1¢ à ­¥ ­ã¦­®
  1078.         ret
  1079.  
  1080. @@:     mov     ebp,ed_color
  1081.         call    edit_box.clear_cursor
  1082.         jmp     edit_box.check_offset
  1083.  
  1084. edit_box_key.sh_ext_en:
  1085.         call    edit_box.check_offset
  1086.         test    word ed_flags,ed_offset_fl
  1087.         je      @f
  1088. ;¨á®¢ ­¨¥ § ªà è¥­­ëå ¯àאַ㣮«ì­¨ª®¢ ¨ ¨å ®ç¨á⪠
  1089.         movzx   eax, word ed_shift_pos
  1090.         mov     ebx,ed_pos
  1091.         movzx   ecx, word ed_shift_pos_old
  1092. ;¯à®¢¥àª  ¨ à¨á®¢ ­¨¥ § ªà è¥­­ëå ®¡« á⥩
  1093.         cmp     eax,ecx
  1094.         je      edit_box_key.1_shem
  1095.         jb      edit_box_key.smaller
  1096.         cmp     ecx,ebx
  1097.         ja      edit_box_key.1_shem
  1098.         call    edit_box_key.draw_wigwag_cl ;clear
  1099.         jmp     edit_box_key.sh_e_end
  1100.  
  1101. edit_box_key.smaller:
  1102.         cmp     ecx,ebx
  1103.         jb      edit_box_key.1_shem
  1104.         call    edit_box_key.draw_wigwag_cl ;clear
  1105.         jmp     edit_box_key.sh_e_end
  1106.  
  1107. edit_box_key.1_shem:
  1108.         call    edit_box_key.draw_wigwag
  1109. edit_box_key.sh_e_end:
  1110.         and     word ed_flags,ed_shift_off
  1111.         ret
  1112.  
  1113. @@:     mov     ebp,shift_color
  1114.         movzx   ebx, word ed_shift_pos
  1115.         call    edit_box_key.sh_cl_
  1116.         jmp     edit_box_key.sh_e_end
  1117. ;äã­ªæ¨ï ¤«ï ®¡à ¡®âª¨ shift ¯à¨ ­ ¦ â¨¨ home and end
  1118. edit_box_key.sh_home_end:
  1119.         mov     ebp,ed_color
  1120.         call    edit_box.clear_cursor
  1121.         test    word ed_flags,ed_shift_bac
  1122.         je      @f
  1123.         mov     ebp,ed_color
  1124.         movzx   ebx, word ed_shift_pos_old
  1125.         call    edit_box_key.sh_cl_
  1126. @@:
  1127.         test    word ed_flags,ed_shift
  1128.         je      edit_box_key.sh_exit_ ;¢ë©â¨
  1129.         mov     ebp,shift_color
  1130.         movzx   ebx, word ed_shift_pos
  1131.         call    edit_box_key.sh_cl_
  1132.         or      word ed_flags,ed_shift_bac ;ãáâ ­®¢ª  ä« £ , ¢ë¤¥«¥­­®© ®¡« áâ¨
  1133.         jmp     edit_box_key.sh_e_end
  1134.  
  1135. edit_box_key.sh_exit_:
  1136.         call    edit_box.draw_bg
  1137.         jmp     edit_box.check_offset
  1138.  
  1139. ;äã­ªæ¨ï ¢­¥á¥­¨ï 0 ¯®  ¤à¥áã ed_size+1
  1140. edit_box_key.enable_null:
  1141.         pusha
  1142.         mov     eax,ed_size
  1143.         mov     ebx,ed_text
  1144.         test    eax,eax
  1145.         add     eax,ebx
  1146.         jne     @f
  1147.         inc     eax
  1148. @@:     xor     ebx,ebx
  1149.         mov     [eax],bl
  1150.         popad
  1151.         ret
  1152.  
  1153. ;- 㤠«¥­¨¥ ᨬ¢®« 
  1154. ;‚室­ë¥ ¤ ­­ë¥ edx=ed_size;ecx=ed_pos
  1155. edit_box_key.del_char:
  1156.         mov     esi,ed_text
  1157.         test    word ed_flags,ed_shift_on
  1158.         je      @f
  1159.         movzx   eax, word ed_shift_pos
  1160.         mov     ebx,esi
  1161.         cmp     eax,ecx
  1162.         jae     edit_box_key.dh_n
  1163.         mov     ed_pos,eax      ;çâ®¡ë ­¥ ¡ë«® ã¡¥£ ­¨ï ªãàá®à 
  1164.         mov     ebp,ecx
  1165.         sub     ebp,eax
  1166.         add     ebx,eax  ;eax ¬¥­ìè¥
  1167.         sub     edx,ecx
  1168.         add     esi,ecx
  1169.         mov     ed_shift_pos,bp
  1170.         jmp     edit_box_key.del_ch_sh
  1171.  
  1172. edit_box_key.dh_n:
  1173.         mov     ebp,eax
  1174.         sub     ebp,ecx
  1175.         add     ebx,ecx
  1176.         sub     edx,eax
  1177.         add     esi,eax
  1178.         mov     ed_shift_pos,bp
  1179.         jmp     edit_box_key.del_ch_sh
  1180.  
  1181. @@:     add     esi,ecx ;㪠§ â¥«ì + ᬥ饭¨¥ ª ॠ«ì­®¬ã ¡ãä¥àã
  1182.         mov     ebx,esi
  1183.         inc     esi
  1184.         cld
  1185.         sub     edx,ecx
  1186. edit_box_key.del_ch_sh:
  1187.         push    edi
  1188.         mov     edi,ebx
  1189. @@:
  1190.         lodsb
  1191.         stosb
  1192.         dec     edx
  1193.         jns     @b
  1194.         pop     edi
  1195.         ret
  1196. ;¢ëç¨á«¨âì § ªà è¨¢ ¥¬ãî ®¡« áâì
  1197. ;ᮣ« è¥­¨¥ ¢ ebp - ¯¥à¥¤ ¥âáï ed_size
  1198. edit_box_key.clear_bg:
  1199.         call    edit_box.get_n  ;¯®«ãç¨âì à §¬¥à ¢ ᨬ¢®« å è¨à¨­ë ª®¬¯®­¥­â 
  1200.         push    eax
  1201.         mov     ebx,ed_offset
  1202.         add     eax,ebx ;eax = w_off= ed_offset+width
  1203.         mov     ebx,ebp ;ed_size
  1204.         cmp     eax,ebx
  1205.         jb      @f
  1206.         mov     eax,ed_pos
  1207.         sub     ebx,eax
  1208.         mov     ecx,ed_offset
  1209.         sub     eax,ecx
  1210.         jmp     edit_box_key.nxt
  1211.  
  1212. @@:     mov     ebx,ed_pos
  1213.         push    ebx
  1214.         sub     eax,ebx
  1215.         mov     ebx,eax ;It is not optimal
  1216.         pop     eax     ;ed_pos
  1217.         mov     ecx,ed_offset
  1218.         sub     eax,ecx
  1219. edit_box_key.nxt:
  1220.         mov     ebp,eax  ;¯à®¢¥àª  ­  ¢ë室 § ªà è¨¢ ¥¬®© ®¡« á⨠§  ¯à¥¤¥«ë ¤«¨­ë
  1221.         add     ebp,ebx
  1222.         pop     edx
  1223.         cmp     ebp,edx
  1224.         je      @f
  1225.         inc     ebx
  1226. @@:
  1227.         mul     dword ed_char_width
  1228.         xchg    eax,ebx
  1229.         mul     dword ed_char_width
  1230.         add     ebx,ed_left
  1231.         inc     ebx
  1232.         shl     ebx,16
  1233.         inc     eax
  1234.         mov     bx, ax
  1235.         mov     edx,ed_color
  1236.         jmp     edit_box.draw_bg_eax
  1237.  
  1238. ;;;;;;;;;;;;;;;;;;;
  1239. ;;; Ž¡à ¡®âª  ¯à¨¬¨â¨¢®¢
  1240. ;;;;;;;;;;;;;;;;;;;;
  1241. ; à¨á®¢ âì ¯àאַ㣮«ì­¨ª, 梥⠯¥à¥¤ ¥âáï ¢ ebp
  1242. ;¢å®¤­ë¥ ¯ à ¬¥âàë:
  1243. ;eax=dword ed_pos
  1244. ;ebp=-梥â ed_color or shift_color
  1245. edit_box_key.draw_rectangle:
  1246.         sub     eax,ed_offset
  1247.         mul     dword ed_char_width
  1248.         add     eax,ed_left
  1249.         inc     eax
  1250.         shl     eax,16
  1251.         add     eax,ed_char_width
  1252.         mov     ebx,eax
  1253.         mov     edx,ebp
  1254.         jmp     edit_box.draw_bg_eax
  1255.  
  1256. ;;;;;;;;;;;;;;;;;;
  1257. ;;à®¢¥àª  ­ ¦ â «¨ shift
  1258. ;;;;;;;;;;;;;;;;;;
  1259. edit_box_key.check_shift_ctrl_alt:
  1260.         pusha
  1261.         mcall   SF_KEYBOARD,SSF_GET_CONTROL_KEYS
  1262.         test    al,11b
  1263.         je      @f
  1264.         or      word ed_flags,ed_shift   ;ãáâ ­®¢¨¬ ä« £ Shift
  1265. @@:
  1266.         and     word ed_flags,ed_ctrl_off ; ®ç¨á⨬ ä« £ Ctrl
  1267.         test    al,1100b
  1268.         je      @f
  1269.         or      word ed_flags,ed_ctrl_on   ;ãáâ ­®¢¨¬ ä« £ Ctrl
  1270. @@:
  1271.         and     word ed_flags,ed_alt_off ; ®ç¨á⨬ ä« £ Alt
  1272.         test    al,110000b
  1273.         je      @f
  1274.         or      word ed_flags,ed_alt_on   ;ãáâ ­®¢¨¬ ä« £ Alt
  1275. @@:
  1276.         popad
  1277.         ret
  1278.  
  1279. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1280. ;”㭪樨 ¤«ï à ¡®âë á mouse
  1281. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1282. edit_box_mouse.mouse_wigwag:
  1283.         push    eax
  1284.         call    edit_box.draw_bg
  1285.         call    edit_box.draw_shift
  1286.         pop     eax
  1287.         or      word ed_flags,ed_shift_bac+ed_shift_on+ed_shift
  1288. ;Ž¡à ¡®âª  ¯®«®¦¥­¨ï ¢ë¤¥«¥­­®£® ⥪áâ , ª®£¤  ¯à®¨á室¨â ¢ë室 §  ¯à¥¤¥«ë editbox
  1289.         test    eax,eax
  1290.         js      edit_box_mouse.mleft
  1291.         shr     eax,16
  1292.         sub     eax,ed_left
  1293.         jc      edit_box_mouse.mleft
  1294.         cmp     ed_width,eax
  1295.         jc      edit_box_mouse.mright
  1296.         xor     edx,edx
  1297.         div     word ed_char_width
  1298. ;Ž¡à ¡®âª  ¯®«®¦¥­¨ï ¢ë¤¥«¥­­®£® ⥪áâ , ¢ ¯à¥¤¥« å ®¡« á⨠editbox
  1299. ;®«ã稫¨ ª®®à¤¨­ âë ¢ eax ¬ë誨, â.¥. ªã¤  ®­  ¯¥à¥¬¥á⨫ áì
  1300. ;¨á®¢ ­¨¥ § ªà è¥­­ëå ¯àאַ㣮«ì­¨ª®¢ ¨ ¨å ®ç¨á⪠
  1301.         add     eax,ed_offset
  1302.         cmp     eax,ed_size
  1303.         ja      edit_box_mouse.mwigvag
  1304. edit_box_mouse.mdraw:
  1305.         mov     ed_pos,eax
  1306. ;¨á®¢ ­¨¥ § ªà è¥­­ëå ¯àאַ㣮«ì­¨ª®¢ ¨ ¨å ®ç¨á⪠
  1307.         movzx   ecx, word ed_shift_pos
  1308.         movzx   ebx, word ed_shift_pos_old
  1309.         mov     ed_shift_pos_old,ax
  1310. ;¯à®¢¥àª  ¨ à¨á®¢ ­¨¥ § ªà è¥­­ëå ®¡« á⥩
  1311.         cmp     ecx,ebx
  1312.         je      edit_box_mouse.m1_shem  ;¤¢¨¦¥­¨ï ­¥ ¡ë«® à ­¥¥
  1313.         jb      edit_box_mouse.msmaller ;¡ë«® ¤¢¨¦¥­¨¥ ->
  1314.         cmp     ebx,eax
  1315.         ja      edit_box_mouse.m1_shem  ;¡ë«® ¤¢¨¦¥­¨¥ <-
  1316.         je      edit_box_mouse.mwigvag
  1317.         mov     ebp,ed_color
  1318.         call    edit_box_key.sh_cl_     ;®ç¨áâ¨âì ®¡« áâì c ed_pos ed_shift_pos_old
  1319.         jmp     edit_box_mouse.mwigvag
  1320.  
  1321. edit_box_mouse.msmaller:
  1322.         cmp     ebx,eax
  1323.         jb      edit_box_mouse.m1_shem
  1324.         mov     ebp,ed_color
  1325.         call    edit_box_key.sh_cl_
  1326.         jmp     edit_box_mouse.mwigvag
  1327.  
  1328. edit_box_mouse.m1_shem:
  1329.         mov     ebp,shift_color
  1330.         mov     ebx,ecx
  1331.         call    edit_box_key.sh_cl_
  1332. edit_box_mouse.mwigvag:
  1333.         and     word ed_flags,ed_shift_mcl
  1334.         jmp     edit_box.draw_cursor_text
  1335.  
  1336. edit_box_mouse.mleft:
  1337.         mov     eax,ed_pos
  1338.         cmp     eax,0
  1339.         jbe     edit_box_mouse.mwigvag
  1340.         dec     eax
  1341.         call    edit_box.check_offset
  1342.         push    eax
  1343.         movzx   ebx, word ed_shift_pos
  1344.         mov     ebp,shift_color
  1345.         call    edit_box_key.sh_cl_
  1346.         pop     eax
  1347.         jmp     edit_box_mouse.mdraw
  1348.  
  1349. edit_box_mouse.mright:
  1350.         mov     eax,ed_pos
  1351.         mov     ebx,ed_size
  1352.         cmp     eax,ebx
  1353.         jae     edit_box_mouse.mwigvag
  1354.         inc     eax
  1355.         call    edit_box.check_offset
  1356.         movzx   ebx, word ed_shift_pos
  1357.         mov     ebp,shift_color
  1358.         push    eax
  1359.         call    edit_box_key.sh_cl_
  1360.         pop     eax
  1361.         jmp     edit_box_mouse.mdraw
  1362.  
  1363.  
  1364. ed_struc_size=84
  1365.