Subversion Repositories Kolibri OS

Rev

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