Subversion Repositories Kolibri OS

Rev

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