Subversion Repositories Kolibri OS

Rev

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