Subversion Repositories Kolibri OS

Rev

Rev 8852 | Rev 9616 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

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