Subversion Repositories Kolibri OS

Rev

Rev 7906 | Rev 8681 | 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. edit_box.get_n:
  776.         mov     eax,ed_width
  777.         sub     eax,4
  778.         xor     edx,edx
  779.         div     word ed_char_width
  780.         ret
  781.  
  782. ;----------------------------------------------------------
  783. ;------------------ Draw Cursor Procedure -----------------
  784. ;----------------------------------------------------------
  785. ; in: ebp = Color
  786. edit_box.clear_cursor:
  787.         movzx   ebx, word cl_curs_x
  788.         cmp     ebx, ed_left ;¯®¯ ¤ ¥â «¨ ªãàá®à ⥪á⮢®¥ ¯®«¥?
  789.         jle     @f
  790.         mov     edx, ebp
  791.         movzx   ecx, word cl_curs_y
  792.         cmp     ecx, ed_top
  793.         jg      edit_box.draw_curs
  794. @@:
  795.         ret
  796.  
  797. edit_box.draw_cursor:
  798.         mov     edx, ed_text_color
  799.         mov     eax, ed_pos
  800.         sub     eax, ed_offset
  801.         mul     dword ed_char_width
  802.         mov     ebx, eax
  803.         add     ebx, ed_left
  804.         inc     ebx
  805.         mov     ecx, ed_top
  806.         add     ecx, 2
  807.         mov     cl_curs_x, bx
  808.         mov     cl_curs_y, cx
  809. edit_box.draw_curs:
  810.         mov     eax, ebx
  811.         shl     ebx, 16
  812.         or      ebx, eax
  813.         mov     eax, ecx
  814.         shl     ecx, 16
  815.         or      ecx, eax
  816.         add     ecx, ed_height
  817.         sub     ecx, 3
  818.         mcall   SF_DRAW_LINE
  819.         ret
  820.  
  821. ;----------------------------------------------------------
  822. ;--- ¯à®æ¥¤ãà  à¨á®¢ ­¨ï à ¬ª¨ ----------------------------
  823. ;----------------------------------------------------------
  824. edit_box.draw_border:
  825.         test    word ed_flags,ed_focus
  826.         mov     edx,ed_focus_border_color
  827.         jne     @f
  828.         mov     edx,ed_blur_border_color
  829. @@:
  830.        ;mov     edx,$808080
  831.         mov     ebx,ed_left
  832.         mov     eax,ebx
  833.         shl     ebx,16
  834.         add     ebx,eax
  835.         ;add     ebx,ed_width
  836.         mov     ecx,ed_top
  837.         mov     eax,ecx
  838.         shl     ecx,16
  839.         add     ecx,eax
  840.         push    ecx
  841.         inc     ecx
  842.         add     ecx,ed_height
  843.         mcall   SF_DRAW_LINE ; left
  844.         xchg    ecx,[esp]
  845.         add     ebx,ed_width
  846.         mcall                ; top
  847.        ;or      edx,-1
  848.         pop     ecx
  849.         push    cx
  850.         push    cx
  851.         push    ebx
  852.         push    bx
  853.         push    bx
  854.         pop     ebx
  855.         mcall                ; right
  856.         pop     ebx
  857.         pop     ecx
  858.         mcall                ; bottom
  859.         ret
  860.  
  861. ;----------------------------------------------------------
  862. ;--- ¯à®¢¥àª , § è¥« «¨ ªãàá®à §  £à ­¨æë ¨, ¥á«¨ ­ ¤®, ---
  863. ;--- ¨§¬¥­ï¥¬ ᬥ饭¨¥ ------------------------------------
  864. ;--- ¥á«¨ ᬥ饭¨¥ ¡ë«®, ãáâ ­®¢ª  ä« £  ed_offset_cl, ¨­ ç¥,
  865. ; ¥á«¨ ­¨ç¥£® ­¥ ¨§¬¥­¨«®áì, â® ¢ëáâ ¢«¥­¨¥ ed_offset_fl
  866. ; ¢ ®¡é¥© ¡¨â®¢®© ¬ âà¨æ¥ á®áâ®ï­¨ï ª®¬¯®­¥­â®¢ word ed_flags
  867. ;----------------------------------------------------------
  868. edit_box.check_offset:
  869.         pushad
  870.         mov     ecx,ed_pos
  871.         mov     ebx,ed_offset
  872.         cmp     ebx,ecx
  873.         ja      edit_box.sub_8
  874.         push    ebx
  875.         call    edit_box.get_n
  876.         pop     ebx
  877.         mov     edx,ebx
  878.         add     edx,eax
  879.         inc     edx     ;­¥®¡å®¤¨¬® ¤«ï ­®à¬ «ì­®£® ¯®«®¦¥­¨ï ªãàá®à  ¢ ªà ©­¥© «¥¢®© ¯®§¨æ¨¨
  880.         cmp     edx,ecx
  881.         ja      @f
  882.         mov     edx,ed_size
  883.         cmp     edx,ecx
  884.         je      edit_box.add_end
  885.         sub     edx,ecx
  886.         cmp     edx,8
  887.         jbe     edit_box.add_8
  888.         add     ebx,8
  889.         jmp     edit_box.chk_d
  890.  
  891. @@:     or      word ed_flags,ed_offset_fl
  892.         popad
  893.         ret
  894.  
  895. edit_box.sub_8:
  896.         test    ecx,ecx
  897.         jz      @f
  898.         sub     ebx,8   ;ebx=ed_offset
  899.         ja      edit_box.chk_d
  900. @@:
  901.         xor     ebx,ebx
  902.         jmp     edit_box.chk_d
  903.  
  904. edit_box.add_end:
  905.         sub     edx,eax
  906.         mov     ebx,edx
  907.         jmp     edit_box.chk_d
  908.  
  909. edit_box.add_8:
  910.         add     ebx,edx
  911. edit_box.chk_d:
  912.         mov     ed_offset,ebx
  913.         call    edit_box.draw_bg
  914.         and     word ed_flags,ed_offset_cl
  915.         popad
  916.         ret
  917.  
  918. align 4
  919. proc edit_box_set_text, edit:dword, text:dword
  920.         pushad
  921.         mov     edi,[edit]
  922.         mov     ecx,ed_max
  923.         inc     ecx
  924.         mov     edi,[text]
  925.         xor     al,al
  926.         cld
  927.         repne scasb
  928.         mov     ecx,edi
  929.         mov     edi,[edit]
  930.         mov     esi,[text]
  931.         sub     ecx,esi
  932.         dec     ecx
  933.         mov     ed_size,ecx
  934.         mov     ed_pos,ecx
  935.         and     word ed_flags,ed_shift_cl
  936.         mov     edi,ed_text
  937.         repne movsb
  938.         mov     byte[edi],0
  939.         popad
  940.         ret
  941. endp
  942.  
  943. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  944. ;”㭪樨 ¤«ï à ¡®âë á key
  945. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  946.  
  947. ;Ž¡à ¡®âª  Shift ¤«ï á­ïâ¨ï ¢ë¤¥«¥­¨ï ­¥¨§¢¥áâ­®© ®¡« áâ¨
  948. edit_box_key.shift:
  949.         call    edit_box.draw_bg
  950.         test    word ed_flags,ed_shift
  951.         je      edit_box_key.f_exit
  952.         mov     ebp,shift_color
  953.         or      word ed_flags,ed_shift_bac ;ãáâ ­®¢ª  ä« £ , ¢ë¤¥«¥­­®© ®¡« áâ¨
  954.         movzx   ebx, word ed_shift_pos
  955.         call    edit_box_key.sh_cl_
  956.         jmp     edit_box.draw_cursor_text
  957.  
  958. edit_box_key.f_exit:
  959.         call    edit_box.check_offset
  960.         and     word ed_flags,ed_shift_cl
  961.         call    edit_box_key.enable_null
  962.         jmp     edit_box.draw_cursor_text
  963.  
  964. edit_box_key.sh_cl_:
  965. ;®¡à ¡®âª  ®ç¨á⪨, ¯à¨ «¥¢®¬ - ¯à ¢®¬ ¤¢¨¦¥­¨¨ ¢ë¤¥«¥­¨ï
  966. ;¤«ï ®¡à ¡®âª¨ á­ïâ¨ï ¢ë¤¥«¥­¨ï
  967. ;¢å®¤­ë¥ ¯ à ¬¥âàë ebp=color ebx=ed_shift_pos
  968.         mov     eax,ed_pos
  969.         cmp     eax,ebx
  970.         jae     edit_box_key.sh_n
  971.         push    eax  ;¬¥­ì襥 ¢ eax
  972.         push    ebx  ;¡®«ì襥
  973.         jmp     edit_box_key.sh_n1
  974.  
  975. edit_box_key.sh_n:
  976.         push    ebx
  977.         push    eax
  978. edit_box_key.sh_n1:
  979.         call    edit_box.check_offset
  980.         call    edit_box.get_n
  981.         mov     edx,eax ;size of ed_box
  982.         mov     ecx,ed_offset
  983.         add     eax,ecx ;eax = w_off= ed_offset+width
  984.         mov     edx,eax ;save
  985.         pop     ebx     ;¡®«ì襥
  986.         pop     eax     ;¬¥­ì襥
  987.         cmp     eax,ecx         ;áà ¢­¥­¨¥ ¬¥­ì襣® á offset.
  988.         jae     edit_box_key.f_f            ;¥á«¨ ¡®«ìè¥
  989.         xor     eax,eax
  990.         cmp     edx,ebx         ;cà ¢­¨¬ à §¬¥à w_off á ¡®«ì訬
  991.         jnb     @f
  992.         mov     ebx,edx
  993. @@:
  994.         sub     ebx,ecx
  995.         jmp     edit_box_key.nxt_f
  996.  
  997. edit_box_key.f_f:
  998.         sub     eax,ecx
  999.         cmp     edx,ebx         ;cà ¢­¨¬ à §¬¥à w_off á ¡®«ì訬
  1000.         jle     @f
  1001.         sub     ebx,ecx
  1002.         sub     ebx,eax
  1003.         jmp     edit_box_key.nxt_f
  1004.  
  1005. @@:     mov     ebx,edx
  1006.         sub     ebx,ecx
  1007.         sub     ebx,eax
  1008. edit_box_key.nxt_f:
  1009.         mul     dword ed_char_width
  1010.         xchg    eax,ebx
  1011.         mul     dword ed_char_width
  1012.         add     ebx,ed_left
  1013.         inc     ebx
  1014.         shl     ebx,16
  1015.         inc     eax
  1016.         mov     bx, ax
  1017.         mov     edx,ebp ;shift_color
  1018.         call    edit_box.draw_bg_eax
  1019.         jmp     edit_box_key.enable_null
  1020.  
  1021. ;“áâ ­®¢ª - á­ï⨥ ¢ë¤¥«¥­¨ï ¢ ®¤¨­ ᨬ¢®«
  1022. edit_box_key.drw_sim:
  1023.         mov     eax,ed_pos
  1024.         call    edit_box_key.draw_rectangle
  1025.         jmp     edit_box_key.enable_null
  1026.  
  1027. ;”ã­ªæ¨ï ãáâ ­®¢ª¨ ¢ë¤¥«¥­¨ï ¯à¨ ¤¢¨¦¥­¨¨ ¢«¥¢® ¨ ¢¯à ¢® ¨ ­ ¦ â¨¨ shift
  1028. edit_box_key.draw_wigwag:
  1029.         mov     ebp,shift_color
  1030.         call    edit_box.clear_cursor
  1031.         or      word ed_flags,ed_shift_bac ;ãáâ ­®¢ª  ä« £  ¢ë¤¥«¥­­®© ®¡« áâ¨
  1032.         mov     ebp,shift_color
  1033.         mov     eax,ed_pos
  1034.         test    word ed_flags,ed_left_fl
  1035.         jnz     edit_box_key.draw_rectangle
  1036.         dec     eax
  1037.         jmp     edit_box_key.draw_rectangle
  1038.  
  1039. ;”ã­ªæ¨ï 㤠«¥­¨ï ¢ë¤¥«¥­¨ï ¯à¨ ¤¢¨¦¥­¨¨ ¢«¥¢® ¨ ¢¯à ¢® ¨ ­ ¦ â¨¨ shift
  1040. edit_box_key.draw_wigwag_cl:
  1041.         mov     ebp,ed_color
  1042.         call    edit_box.clear_cursor
  1043.         mov     ebp,ed_color
  1044.         mov     eax,ed_pos
  1045.         test    word ed_flags,ed_left_fl
  1046.         jnz     edit_box_key.draw_rectangle
  1047.         dec     eax
  1048.         jmp     edit_box_key.draw_rectangle
  1049.  
  1050. ;¢å®¤­®© ¯ à ¬¥âà ebx - ed_pos
  1051. edit_box_key.sh_first_sh:
  1052.         test    word ed_flags,ed_shift
  1053.         je      @f
  1054.         mov     ed_shift_pos_old,bx
  1055.         test    word ed_flags,ed_shift_on
  1056.         jne     @f
  1057.         mov     ed_shift_pos,bx
  1058.         or      word ed_flags,ed_shift_on
  1059. @@:     ret
  1060. ;Ž¡à ¡®âª  ªà ©­¨å ¯®«®¦¥­¨© ¢ editbox ¯à¨ ­ ¦ â®¬ shift
  1061. ;¯à®¨§¢®¤¨â á­ï⨥ ¢ë¤¥«¥­¨ï, ¥á«¨ ­¥â shift
  1062. ;¨­ ç¥ ¢®®¡é¥ ¢ë室¨â
  1063. edit_box_key.sh_st_of:
  1064.         test    word ed_flags,ed_shift
  1065.         jne     @f
  1066.         test    word ed_flags,ed_shift_bac
  1067.         je      @f
  1068.         call    edit_box.draw_bg
  1069.         mov     ebp,ed_color
  1070.         movzx   ebx, word ed_shift_pos
  1071.         call    edit_box_key.sh_cl_  ;®ç¨á⪠ ¢ë¤¥«¥­®£® äà £¬¥­â 
  1072.         and     word ed_flags,ed_shift_cl ; ®ç¨á⪠ ®â ⮣®, çâ® ã¡à «¨ ¢ë¤¥«¥­¨¥
  1073.         jmp     edit_box.draw_cursor_text
  1074.  
  1075. @@:     and     word ed_flags,ed_shift_off
  1076.         popad
  1077.         ret     4
  1078. ;¯à®¢¥àª  á®áâ®ï­¨ï shift, ¡ë« «¨ ®­ ­ ¦ â à ­ìè¥?
  1079. edit_box_key.sh_enable:
  1080.         test    word ed_flags,ed_shift
  1081.         jne     edit_box_key.sh_ext_en ;­ à¨á®¢ âì § ªà è¥­­ë© ¯àאַ㣮«ì­¨ª
  1082.         test    word ed_flags,ed_shift_bac
  1083.         je      @f
  1084.         call    edit_box.check_offset
  1085.         mov     ebp,ed_color
  1086.         movzx   ebx, word ed_shift_pos
  1087.         call    edit_box_key.sh_cl_  ;®ç¨á⪠ ¢ë¤¥«¥­­®£® äà £¬¥­â 
  1088.         call    edit_box_key.draw_wigwag_cl
  1089.         and     word ed_flags,ed_shift_cl ; 1¢ à ­¥ ­ã¦­®
  1090.         ret
  1091.  
  1092. @@:     mov     ebp,ed_color
  1093.         call    edit_box.clear_cursor
  1094.         jmp     edit_box.check_offset
  1095.  
  1096. edit_box_key.sh_ext_en:
  1097.         call    edit_box.check_offset
  1098.         test    word ed_flags,ed_offset_fl
  1099.         je      @f
  1100. ;¨á®¢ ­¨¥ § ªà è¥­­ëå ¯àאַ㣮«ì­¨ª®¢ ¨ ¨å ®ç¨á⪠
  1101.         movzx   eax, word ed_shift_pos
  1102.         mov     ebx,ed_pos
  1103.         movzx   ecx, word ed_shift_pos_old
  1104. ;¯à®¢¥àª  ¨ à¨á®¢ ­¨¥ § ªà è¥­­ëå ®¡« á⥩
  1105.         cmp     eax,ecx
  1106.         je      edit_box_key.1_shem
  1107.         jb      edit_box_key.smaller
  1108.         cmp     ecx,ebx
  1109.         ja      edit_box_key.1_shem
  1110.         call    edit_box_key.draw_wigwag_cl ;clear
  1111.         jmp     edit_box_key.sh_e_end
  1112.  
  1113. edit_box_key.smaller:
  1114.         cmp     ecx,ebx
  1115.         jb      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.1_shem:
  1120.         call    edit_box_key.draw_wigwag
  1121. edit_box_key.sh_e_end:
  1122.         and     word ed_flags,ed_shift_off
  1123.         ret
  1124.  
  1125. @@:     mov     ebp,shift_color
  1126.         movzx   ebx, word ed_shift_pos
  1127.         call    edit_box_key.sh_cl_
  1128.         jmp     edit_box_key.sh_e_end
  1129. ;äã­ªæ¨ï ¤«ï ®¡à ¡®âª¨ shift ¯à¨ ­ ¦ â¨¨ home and end
  1130. edit_box_key.sh_home_end:
  1131.         mov     ebp,ed_color
  1132.         call    edit_box.clear_cursor
  1133.         test    word ed_flags,ed_shift_bac
  1134.         je      @f
  1135.         mov     ebp,ed_color
  1136.         movzx   ebx, word ed_shift_pos_old
  1137.         call    edit_box_key.sh_cl_
  1138. @@:
  1139.         test    word ed_flags,ed_shift
  1140.         je      edit_box_key.sh_exit_ ;¢ë©â¨
  1141.         mov     ebp,shift_color
  1142.         movzx   ebx, word ed_shift_pos
  1143.         call    edit_box_key.sh_cl_
  1144.         or      word ed_flags,ed_shift_bac ;ãáâ ­®¢ª  ä« £ , ¢ë¤¥«¥­­®© ®¡« áâ¨
  1145.         jmp     edit_box_key.sh_e_end
  1146.  
  1147. edit_box_key.sh_exit_:
  1148.         call    edit_box.draw_bg
  1149.         jmp     edit_box.check_offset
  1150.  
  1151. ;äã­ªæ¨ï ¢­¥á¥­¨ï 0 ¯®  ¤à¥áã ed_size+1
  1152. edit_box_key.enable_null:
  1153.         pusha
  1154.         mov     eax,ed_size
  1155.         mov     ebx,ed_text
  1156.         test    eax,eax
  1157.         add     eax,ebx
  1158.         jne     @f
  1159.         inc     eax
  1160. @@:     xor     ebx,ebx
  1161.         mov     [eax],bl
  1162.         popad
  1163.         ret
  1164.  
  1165. ;- 㤠«¥­¨¥ ᨬ¢®« 
  1166. ;‚室­ë¥ ¤ ­­ë¥ edx=ed_size;ecx=ed_pos
  1167. edit_box_key.del_char:
  1168.         mov     esi,ed_text
  1169.         test    word ed_flags,ed_shift_on
  1170.         je      @f
  1171.         movzx   eax, word ed_shift_pos
  1172.         mov     ebx,esi
  1173.         cmp     eax,ecx
  1174.         jae     edit_box_key.dh_n
  1175.         mov     ed_pos,eax      ;çâ®¡ë ­¥ ¡ë«® ã¡¥£ ­¨ï ªãàá®à 
  1176.         mov     ebp,ecx
  1177.         sub     ebp,eax
  1178.         add     ebx,eax  ;eax ¬¥­ìè¥
  1179.         sub     edx,ecx
  1180.         add     esi,ecx
  1181.         mov     ed_shift_pos,bp
  1182.         jmp     edit_box_key.del_ch_sh
  1183.  
  1184. edit_box_key.dh_n:
  1185.         mov     ebp,eax
  1186.         sub     ebp,ecx
  1187.         add     ebx,ecx
  1188.         sub     edx,eax
  1189.         add     esi,eax
  1190.         mov     ed_shift_pos,bp
  1191.         jmp     edit_box_key.del_ch_sh
  1192.  
  1193. @@:     add     esi,ecx ;㪠§ â¥«ì + ᬥ饭¨¥ ª ॠ«ì­®¬ã ¡ãä¥àã
  1194.         mov     ebx,esi
  1195.         inc     esi
  1196.         cld
  1197.         sub     edx,ecx
  1198. edit_box_key.del_ch_sh:
  1199.         push    edi
  1200.         mov     edi,ebx
  1201. @@:
  1202.         lodsb
  1203.         stosb
  1204.         dec     edx
  1205.         jns     @b
  1206.         pop     edi
  1207.         ret
  1208. ;¢ëç¨á«¨âì § ªà è¨¢ ¥¬ãî ®¡« áâì
  1209. ;ᮣ« è¥­¨¥ ¢ ebp - ¯¥à¥¤ ¥âáï ed_size
  1210. edit_box_key.clear_bg:
  1211.         call    edit_box.get_n  ;¯®«ãç¨âì à §¬¥à ¢ ᨬ¢®« å è¨à¨­ë ª®¬¯®­¥­â 
  1212.         push    eax
  1213.         mov     ebx,ed_offset
  1214.         add     eax,ebx ;eax = w_off= ed_offset+width
  1215.         mov     ebx,ebp ;ed_size
  1216.         cmp     eax,ebx
  1217.         jb      @f
  1218.         mov     eax,ed_pos
  1219.         sub     ebx,eax
  1220.         mov     ecx,ed_offset
  1221.         sub     eax,ecx
  1222.         jmp     edit_box_key.nxt
  1223.  
  1224. @@:     mov     ebx,ed_pos
  1225.         push    ebx
  1226.         sub     eax,ebx
  1227.         mov     ebx,eax ;It is not optimal
  1228.         pop     eax     ;ed_pos
  1229.         mov     ecx,ed_offset
  1230.         sub     eax,ecx
  1231. edit_box_key.nxt:
  1232.         mov     ebp,eax  ;¯à®¢¥àª  ­  ¢ë室 § ªà è¨¢ ¥¬®© ®¡« á⨠§  ¯à¥¤¥«ë ¤«¨­ë
  1233.         add     ebp,ebx
  1234.         pop     edx
  1235.         cmp     ebp,edx
  1236.         je      @f
  1237.         inc     ebx
  1238. @@:
  1239.         mul     dword ed_char_width
  1240.         xchg    eax,ebx
  1241.         mul     dword ed_char_width
  1242.         add     ebx,ed_left
  1243.         inc     ebx
  1244.         shl     ebx,16
  1245.         inc     eax
  1246.         mov     bx, ax
  1247.         mov     edx,ed_color
  1248.         jmp     edit_box.draw_bg_eax
  1249.  
  1250. ;;;;;;;;;;;;;;;;;;;
  1251. ;;; Ž¡à ¡®âª  ¯à¨¬¨â¨¢®¢
  1252. ;;;;;;;;;;;;;;;;;;;;
  1253. ; à¨á®¢ âì ¯àאַ㣮«ì­¨ª, 梥⠯¥à¥¤ ¥âáï ¢ ebp
  1254. ;¢å®¤­ë¥ ¯ à ¬¥âàë:
  1255. ;eax=dword ed_pos
  1256. ;ebp=-梥â ed_color or shift_color
  1257. edit_box_key.draw_rectangle:
  1258.         sub     eax,ed_offset
  1259.         mul     dword ed_char_width
  1260.         add     eax,ed_left
  1261.         inc     eax
  1262.         shl     eax,16
  1263.         add     eax,ed_char_width
  1264.         mov     ebx,eax
  1265.         mov     edx,ebp
  1266.         jmp     edit_box.draw_bg_eax
  1267.  
  1268. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1269. ;”㭪樨 ¤«ï à ¡®âë á mouse
  1270. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1271. edit_box_mouse.mouse_wigwag:
  1272.         push    eax
  1273.         call    edit_box.draw_bg
  1274.         call    edit_box.draw_shift
  1275.         pop     eax
  1276.         or      word ed_flags,ed_shift_bac+ed_shift_on+ed_shift
  1277. ;Ž¡à ¡®âª  ¯®«®¦¥­¨ï ¢ë¤¥«¥­­®£® ⥪áâ , ª®£¤  ¯à®¨á室¨â ¢ë室 §  ¯à¥¤¥«ë editbox
  1278.         test    eax,eax
  1279.         js      edit_box_mouse.mleft
  1280.         shr     eax,16
  1281.         sub     eax,ed_left
  1282.         jc      edit_box_mouse.mleft
  1283.         cmp     ed_width,eax
  1284.         jc      edit_box_mouse.mright
  1285.         xor     edx,edx
  1286.         div     word ed_char_width
  1287. ;Ž¡à ¡®âª  ¯®«®¦¥­¨ï ¢ë¤¥«¥­­®£® ⥪áâ , ¢ ¯à¥¤¥« å ®¡« á⨠editbox
  1288. ;®«ã稫¨ ª®®à¤¨­ âë ¢ eax ¬ë誨, â.¥. ªã¤  ®­  ¯¥à¥¬¥á⨫ áì
  1289. ;¨á®¢ ­¨¥ § ªà è¥­­ëå ¯àאַ㣮«ì­¨ª®¢ ¨ ¨å ®ç¨á⪠
  1290.         add     eax,ed_offset
  1291.         cmp     eax,ed_size
  1292.         ja      edit_box_mouse.mwigvag
  1293. edit_box_mouse.mdraw:
  1294.         mov     ed_pos,eax
  1295. ;¨á®¢ ­¨¥ § ªà è¥­­ëå ¯àאַ㣮«ì­¨ª®¢ ¨ ¨å ®ç¨á⪠
  1296.         movzx   ecx, word ed_shift_pos
  1297.         movzx   ebx, word ed_shift_pos_old
  1298.         mov     ed_shift_pos_old,ax
  1299. ;¯à®¢¥àª  ¨ à¨á®¢ ­¨¥ § ªà è¥­­ëå ®¡« á⥩
  1300.         cmp     ecx,ebx
  1301.         je      edit_box_mouse.m1_shem  ;¤¢¨¦¥­¨ï ­¥ ¡ë«® à ­¥¥
  1302.         jb      edit_box_mouse.msmaller ;¡ë«® ¤¢¨¦¥­¨¥ ->
  1303.         cmp     ebx,eax
  1304.         ja      edit_box_mouse.m1_shem  ;¡ë«® ¤¢¨¦¥­¨¥ <-
  1305.         je      edit_box_mouse.mwigvag
  1306.         mov     ebp,ed_color
  1307.         call    edit_box_key.sh_cl_     ;®ç¨áâ¨âì ®¡« áâì c ed_pos ed_shift_pos_old
  1308.         jmp     edit_box_mouse.mwigvag
  1309.  
  1310. edit_box_mouse.msmaller:
  1311.         cmp     ebx,eax
  1312.         jb      edit_box_mouse.m1_shem
  1313.         mov     ebp,ed_color
  1314.         call    edit_box_key.sh_cl_
  1315.         jmp     edit_box_mouse.mwigvag
  1316.  
  1317. edit_box_mouse.m1_shem:
  1318.         mov     ebp,shift_color
  1319.         mov     ebx,ecx
  1320.         call    edit_box_key.sh_cl_
  1321. edit_box_mouse.mwigvag:
  1322.         and     word ed_flags,ed_shift_mcl
  1323.         jmp     edit_box.draw_cursor_text
  1324.  
  1325. edit_box_mouse.mleft:
  1326.         mov     eax,ed_pos
  1327.         cmp     eax,0
  1328.         jbe     edit_box_mouse.mwigvag
  1329.         dec     eax
  1330.         call    edit_box.check_offset
  1331.         push    eax
  1332.         movzx   ebx, word ed_shift_pos
  1333.         mov     ebp,shift_color
  1334.         call    edit_box_key.sh_cl_
  1335.         pop     eax
  1336.         jmp     edit_box_mouse.mdraw
  1337.  
  1338. edit_box_mouse.mright:
  1339.         mov     eax,ed_pos
  1340.         mov     ebx,ed_size
  1341.         cmp     eax,ebx
  1342.         jae     edit_box_mouse.mwigvag
  1343.         inc     eax
  1344.         call    edit_box.check_offset
  1345.         movzx   ebx, word ed_shift_pos
  1346.         mov     ebp,shift_color
  1347.         push    eax
  1348.         call    edit_box_key.sh_cl_
  1349.         pop     eax
  1350.         jmp     edit_box_mouse.mdraw
  1351.  
  1352.  
  1353. ed_struc_size=84
  1354.