Subversion Repositories Kolibri OS

Rev

Rev 5692 | Blame | Last modification | View Log | Download | RSS feed

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