Subversion Repositories Kolibri OS

Rev

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

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