Subversion Repositories Kolibri OS

Rev

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