Subversion Repositories Kolibri OS

Rev

Rev 350 | Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1. ; <Lrz> 06.03.2007 ¥à¥¯¨á « ¯®«­®áâìî  «£®à¨â¬ ã¯à ¢«¥­¨ï shift
  2. ; <Lrz> 15.02.2007 ã«ãç襭¨¥ á­ïâ¨ï ¢ë¤¥«¥­¨ï ¨ ¯¥à¥à¨á®¢ª¨ ®ç¨é ¥¬®© ®¡« áâ¨, §­ ç¨â¥«ì­® ¯à¨ïâ­¥¥ à ¡®â ¥â ª®¬¯®­¥­â
  3. ; <Lrz> 13.02.2007 ã¡à « ¯® ¢®§¬®¦­®á⨠¬¥àæ ­¨¥, ã«ãç襭  ®¡à ¡®âª  ¯¥à¥à¨á®¢ª¨ ä®­ 
  4. ; ¤®¡ ¢¨« ä¨âçã ¢­¥á¥­¨ï 0å0 ¯®  ¤à¥áã ed_size ¨­ ç¥ ã Maxxx32 ¡ë«¨ ­¥á®áâ몮¢ª¨ ¢ ª®¤¥. à¨ç¨­  ¢ ⮬, çâ® ®¯â¨¬¨§ æ¨ï ¡ë«  ᢥ¤¥­  ª ⮬ã, çâ® ï ­¥ ç¨á⨫ ᨬ¢®«ë ¢ ¡ãä¥à¥, ª®£¤  㤠«ï«, ï ¯à®áâ® ¨å ­¥ ¢ë¢®¤¨«, ¨ ¯®â®¬, ª®£¤  ¢­®á¨«áï ­®¢ë© ᨬ¢®«, ®­ ¯®¯à®áâã § â¨à « 㦥 ¨¬¥î騩áï. …᫨ ¡ë, ¯à®£à ¬¬  ®¡à ¡ â뢠«  ª®­¥æ áâப¨ ¯® ed_size, ¯à®¡«¥¬ë ­¥ ¢®§­¨ª«®. ® ᥩç á íâ®â ­¥¤®áâ â®ª ¨á¯à ¢«¥­.
  5. ; <Lrz> 01.02.2007 ¤®à ¡®âª  edit_box, ¨á¯à ¢¨« ¡ £¨.
  6. ; <Lrz> 26.01.2007 ­®à¬ «ì­ ï à ¡®â  ª®¬¯ ­¥­â  ¨á¯à ¢¨« äãªæ¨î .check_offset
  7. ; <Lrz> 24.01.2007 ¯®ä¨ªá¥« ¡ £¨ ¢ë§¢ ­ë¥ ­¥ ¯à ¢¨«ì­ë¬ ª®¤®¬ )).
  8. ; <Lrz> 22.01.2007 ¨§¡ ¢¨«áï ®â £«îª®¢ ¯à¨ à ¡®â¥ á ¢ë¤¥«¥­¨¥¬ ¨ 㤠«¥­¨¥, ª®à४⭠ï à ¡®â  ª« ¢¨è¥© del & backspase
  9. ; <Lrz> 20.01.2007 ॠ«¨§®¢ « ¢ë¤¥«¥­¨¥ ⥪áâ  ¯® shift
  10. ; <Lrz> 12.12.2006 ॠ«¨§®¢ « ¯®¤¤¥à¦ªã ª­®¯ª¨ insert ¨ ᥣ®¤ï ª®¬¯®­¥­â ¯®ç⨠ࠡ®â ¥â!!!!
  11. ; <Lrz> 07.12.2006 ¯à®¤®«¦ ¥âáï à ¡®â  ­ ¤ ¯¥à¥à ¡®âª®© ª®¬¯®­¥­â ,¨§¬¥­¥­¨ï¬ ¯®¤¢¥à£«¨áì ¬­®£¨¥ ä㭪樨, ¯¥à¥à ¡®â ­ ¢ë¢®¤ ⥪áâ ,   â ª  ¦¥  «£®à¨â¬ ¢­¥á¥­¨ï ᨬ¢®«®¢.
  12. ; <Lrz> 03.09.2006 ¯® ¢®§¬®¦­®á⨠®âª § «áï ®â 16 ¡¨â­®©  à¨ä¬¥â¨ª¨, ¤®¡ ¢¨« ­®¢ë¥ ¡ £¨
  13. ; <Lrz> 09.08.2006 ¯à®¨§¢¥¤¥­  ®¯â¨¬¨§ æ¨ï à ¡®âë ª®­¯®ª DEL ¨ Backspace, 㬥­ì襭 à §¬¥à ¢ë¯®«­ï¥¬®£® ª®¤ .
  14. ; <Lrz> 21.07.2006 ¤®¡ ¢«¥­  äã­ªæ¨ï ª­®¯ª¨ Del, ⥯¥àì ¬®¦­® 㤠«ïâì ᨬ¢®«ë ¯à¨ ¯®¬®é¨ ¤ ­­®© ª« ¢¨è¨
  15. ; €¢â®à: …¢â¨å®¢ Œ ªá¨¬ (Maxxxx32) email: maxxxxm@mail.ru
  16. ; „ â  ¯®á«¥¤­¨å ¨§¬¥­¥­¨©: 13.06.06 10:40
  17. ;   ¯¨è¨â¥ ¢ ¨á室­®¬ ª®¤¥ ᢮¥© ¯à®£à ¬¬ë use_edit_box,
  18. ; íâ® ¢áâ ¢¨â ­¥®¡å®¤¨¬ë¥ ¯à®æ¥¤ãàë ¢ ª®¤ ¢ è¥© ¯à®£à ¬¬ë.
  19. ;  à®æ¥¤ãàë:
  20. ;   edit_box.draw - ¯®«­ ï ¯¥à¥à¨á®¢ª ;
  21. ;   edit_box.key - ®¡à ¡®âª  ª« ¢¨ âãàë;
  22. ;   edit_box.mouse - ®¡à ¡®âª  ¬ëè¨;
  23. ;   edit_box.focus - ãáâ ­®¢ª  䮪ãá ;
  24. ;   edit_box.blur - ¥£® à §¬ë¢ ­¨¥;
  25. ;   edit_box.get_n - ¯®«ãç¨âì ª®«¨ç¥á⢮ ¯à®à¨á®¢ë¢ ¥¬ëå ᨬ¢®«®¢.
  26. ;  à¨ ¢ë§®¢¥ «î¡ëå ¨§ íâ¨å ¯à®æ¥¤ãà ¢ ॣ¨áâॠedi á«¥¤ã¥â
  27. ; ®áâ ¢¨âì 㪠§ â¥«ì ­  áâàãªâãàã.
  28. ;  à¨¬¥à áâàãªâãàë:
  29. ; some_edit edit_box 100,10,30,0x00ffffff,0,0x00aaaaaa,0,255,some_edit_text
  30. ; ¤«¨­ , ¢ëá®â , ¢¥àå, 梥â ä®­ , 梥â à ¬ª¨, ¥á«¨ ¢ë¡à ­,
  31. ; 梥â à ¬ª¨, ¥á«¨ ­¥ ¢ë¡à ­, ¬ ªá¨¬ «ì­®¥ ª®«¨ç¥á⢮ ᨬ¢®«®¢,
  32. ; 㪠§ â¥«ì ­  ¡ãä¥à, £¤¥ ¡ã¤ãâ åà ­¨âáï ᨬ¢®«ë. ãä¥à ¤®«¦¥­
  33. ; ®ª ­ç¨¢ âìáï ­ã«¥¬, ­ ¯à¨¬¥à ¥á«¨ ¬ ªá¨¬ «ì­®¥ ª®«¨ç¥á⢮ 255:
  34. ;  some_edit_text:
  35. ;       rb      256 ;255+1
  36.  
  37. ;  à¨¬¥à ¢ë§®¢  ¯à®æ¥¤ãàë:
  38. ;       mov     edi,some_edit
  39. ;       call    edit_box.draw
  40.  
  41. ;  à¨ ¢ë§®¢¥ ¯à®æ¥¤ãàë edit_box.key ª®¤ ª« ¢¨è¨ ¤®«¦¥­
  42. ; ­ å®¤¨âáï ¢ ah, â® ¥áâì ¯¥à¥¤ ¢ë§®¢®¬ í⮩ ¯à®æ¥¤ãàë ­ ¤® ¢ë§¢ âì
  43. ; 2-ãî á¨á¥¬­ãî äã­ªæ¨î, ­ ¯à¨¬¥à:
  44. ;       mov     eax,2
  45. ;       int     0x40
  46. ;       mov     edi,some_edit1
  47. ;       call    edit_box.key
  48. ;       mov     edi,some_edit2
  49. ;       call    edit_box.key
  50. ;  ¥à¥¤ ¢ë§®¢®¬ ®¡à ¡®â稪  ¬ëè¨ á«¥¤ã¥â ¯à®¢¥à¨âì, ï¥âáï «¨ ®ª­®
  51. ;  ªâ¨¢­ë¬.
  52. ;  …᫨ 饫箪 ¬ëè¨ ¡ë« ¯à®©§¢¥¤¥­ §  ¯à¥¤¥« ¬¨ edit box
  53. ; 䮪ãá â¥àï¥âáï.
  54. macro use_edit_box
  55. {
  56. edit_box:
  57. ed_width        equ [edi]               ;è¨à¨­  ª®¬¯®­¥­â 
  58. ed_left         equ [edi+4]             ;¯®«®¦¥­¨¥ ¯® ®á¨ å
  59. ed_top          equ [edi+8]             ;¯®«®¦¥­¨¥ ¯® ®á¨ ã
  60. ed_color        equ [edi+12]            ;梥â ä®­  ª®¬¯®­¥­â 
  61. ed_focus_border_color   equ [edi+16]    ;梥â à ¬ª¨ ª®¬¯®­¥­â 
  62. ed_blur_border_color    equ [edi+20]    ;梥⠭¥  ªâ¨¢­®£® ª®¬¯®­¥­â 
  63. ed_text_color   equ [edi+24]            ;梥â ⥪áâ 
  64. ed_max          equ [edi+28]                    ;ª®«-¢® ᨬ¢®«®¢ ª®â®àë¥ ¬®¦­® ¬ ªá¨¬ «ì­® ¢¢¥áâ¨
  65. ed_text         equ [edi+32]                    ;㪠§ â¥«ì ­  ¡ãä¥à
  66. ed_flags        equ [edi+36]            ;ä« £¨
  67. ed_size equ [edi+38]                    ;ª®«-¢® ᨬ¢®«®¢
  68. ed_pos  equ [edi+42]                    ;¯®§¨æ¨ï ªãàá®à 
  69. ed_offset       equ [edi+46]            ;ᬥ饭¨¥
  70. cl_curs_x       equ [edi+50]            ;¯à¥¤ë¤ã饥 ª®®à¤¨­ â  ªãàá®à  ¯® å
  71. cl_curs_y       equ [edi+54]            ;¯à¥¤ë¤ã饥 ª®®à¤¨­ â  ªãàá®à  ¯® ã
  72. ed_shift_pos    equ [edi+58]
  73. ed_shift_pos_old equ [edi+62]
  74. ;==========================================================
  75. ;=== ¯à®æ¥¤ãà  ¯à®à¨á®¢ª¨ =================================
  76. ;==========================================================
  77. .draw:
  78. pusha
  79. ;--- à¨á㥬 à ¬ªã ---
  80.         call    .draw_border            ; ”ã­ªæ¨ï áâ ¡¨«ì­ 
  81. .draw_bg_cursor_text:
  82. ;--- ¨§¬¥­ï¥¬ ᬥ饭¨¥, ¥á«¨ ­ ¤® ---
  83.         call    .check_offset           ;¢ëç¨á«¥­¨¥ ¯®§¨æ¨¨ ªãàá®à  áâ ¡¨«ì­ 
  84. ;--- à¨á㥬 ¢­ãâ७­îî ®¡« áâì ---
  85.         call    .draw_bg                ;­ à¨á®¢ âì ¯àאַ㣮«ì­¨ª à ¡®ç¥© ®¡« áâ¨
  86. .draw_cursor_text:
  87. ;--- à¨á㥬 ªãàá®à ---
  88.         ;--- ¬®¦¥â ¥£® ­¥ ­ ¤® à¨á®¢ âì ----
  89.         test    word ed_flags,ed_focus
  90.         je      @f
  91.         call    .draw_cursor
  92. @@:
  93.         call    .draw_text
  94. popa
  95. ret
  96.  
  97. ;.str:
  98. ;       mov ecx,0x0a ;§ ¤ ¥âáï á¨á⥬  áç¨á«¥­¨ï ¨§¬¥­ïîâáï ॣ¨áâàë ebx,eax,ecx,edx ¢å®¤­ë¥ ¯ à ¬¥âàë eax - ç¨á«®
  99. ;        ;¯à¥à¥¢®¤ ç¨á«  ¢ ASCII áâப㠢§®¤­ë¥ ¤ ­­ë¥ ecx=á¨á⥬  áç¨á«¥­ï edi  ¤à¥á ªã¤  § ¯¨á뢠âì, ¡ã¤¥¬ áâபã, ¯à¨ç¥¬ ª®­¥æ ¯¥à¥¬¥­­®©
  100. ;       cmp eax,ecx  ;áà ¢­¨âì ¥á«¨ ¢ eax ¬¥­ìè¥ ç¥¬ ¢ ecx â® ¯¥à¥©â¨ ­  @@-1 â.¥. ­  pop eax
  101. ;       jb @f
  102. ;       xor edx,edx  ;®ç¨áâ¨âì edx
  103. ;       div ecx      ;à §¤¥«¨âì - ®áâ â®ª ¢ edx
  104. ;       push edx     ;¯®«®¦¨âì ¢ á⥪
  105. ;       ;dec edi             ;ᬥ饭¨¥ ­¥®¡å®¤¨¬®¥ ¤«ï § ¯¨á¨ á ª®­æ  áâப¨
  106. ;       call .str;¯¥à¥©â¨ ­  á ¬ã ᥡï â.¥. ¢ë§¢ âì á ¬ã á¥¡ï ¨ â ª ¤® ⮣® ¬®¬¥­â  ¯®ª  ¢ eax ­¥ áâ ­¥â ¬¥­ìè¥ ç¥¬ ¢ ecx
  107. ;       pop eax
  108. ;       @@: ;cmp al,10 ;¯à®¢¥à¨âì ­¥ ¬¥­ìè¥ «¨ §­ ç¥­¨¥ ¢ al 祬 10 (¤«ï á¨á⥬ë áç¨á«¥­ï 10 ¤ ­­ ï ª®¬ ­¤  - «¨è­ ï))
  109. ;       ;sbb al,$69  ;- ç¥áâ­® ¤ ­­ ï ¨­áâàãªæ¨ï ¬¥­ï § áâ ¢«ï¥â § ¤ã¬ âìáï â.¥. ï ­¥ §­ î ª ª íâ® à ¡®â ¥â
  110. ;       ;das        ;¯®á«¥ ¤ ­­®© ª®¬ ­¤ë ª ª ¡ë ¯à®¨á室¨â 㬥­ì襭¨¥ al ­  66h  (¢ ª­¨£¥ ­ ¯¨á ­® ¤à㣮¥)
  111. ;       or al,0x30  ;¤ ­­ ï ª®¬ ­¤  ª®à®ç¥  ç¥¬ ¤¢¥ ¢ëè¥
  112. ;       stosb       ;§ ¯¨á âì í«¥¬¥­â ¨§ ॣ¨áâà  al ¢ ï祪㠯 ¬ï⨠es:edi
  113.  ;
  114. ;       ret         ;¢¥à­ãâìáï ç¥­ì ¨­â¥à¥á­ë© 室 â.ª. ¯®ª  ¢ á⥪¥ åà ­¨âìáï ª®«-¢® ¢ë§®¢®¢ â® á⮫쪮 à § ¬ë ¨ ¡ã¤¥¬ ¢ë§ë¢ âìáï
  115.  
  116. ;----------------------------------------------------------
  117. ;--- ¯à®æ¥¤ãà  ¯à®à¨á®¢ª¨ ⥪áâ  --------------------------
  118. ;----------------------------------------------------------
  119. .draw_text:
  120. ;--- ¢ëç¨á«ï¥¬, ᪮«ìª® ¯®¬¥é ¥âáï ᨬ¢®«®¢ ---
  121. ;--- çâ®¡ë ¬ãá®à ­¥ à¨á®¢ âì ---
  122.         call    .get_n
  123.         mov     esi,ed_size
  124.         mov     ebx,ed_offset
  125.         sub     esi,ebx
  126.         cmp     eax,esi
  127.         jae     @F
  128.         mov     esi,eax         ;çâ®¡ë ­¥ ¢ë室¨âì §  ¯à¥¤¥«ë íªà ­ 
  129. ;--- à¨á㥬 ⥪áâ ---
  130. @@:     mov     eax,4
  131.         mov     ebx,ed_left
  132.         mov     edx,ed_offset
  133.         add     ebx,2
  134.         shl     ebx,16
  135.         mov     bx,ed_top
  136.         add     ebx,4
  137.         mov     ecx,ed_text_color
  138.         add     edx,ed_text
  139.         int     0x40
  140. ret
  141. ;----------------------------------------------------------
  142. ;--- ¯à®æ¥¤ãà  ¯à®à¨á®¢ª¨ ä®­  ----------------------------
  143. ;¢å®¤­ë¥ ¤ ­­ë¥
  144. ;eax
  145. ;edx - color
  146. ;----------------------------------------------------------
  147. ;¢å®¤ ⮫쪮 梥â edx
  148. .draw_bg:
  149.         mov     ebx,ed_left
  150.         add     ebx,1
  151.         shl     ebx,16
  152.         mov     bx,ed_width
  153.         sub     ebx,1
  154.         mov     edx,ed_color
  155. .draw_bg_eax:
  156.         mov     ecx,ed_top
  157.         mov     eax,13
  158.         add     ecx,1
  159.         shl     ecx,16
  160.         mov     cx,ed_height
  161.         dec     ecx
  162.         int     0x40
  163. ret
  164.  
  165. ;----------------------------------------------------------
  166. ;--- ¯à®æ¥¤ãà  ¯®«ã祭¨ï ª®«¨ç¥á⢠ ᨬ¢®«®¢ ¢ ⥪ã饩 é¨à¨­¥ ª®¬¯®­¥­â  --------------
  167. ;----------------------------------------------------------
  168. .get_n:
  169.         mov     eax,ed_width    ;¯®«ã祬 è¨à¨­ã ª®¬¯®­¥­â 
  170.         xor     edx,edx   ;१ã«ìâ â à á¯®«®£ ¥âáï ¢ ¯ à¥ edx:eax ¢ eax - ®áâ â®ª
  171.         sub     eax,4           ;¢ëç⨬ 4
  172.         mov     ebx,6           ;§ £à㧬¨ ¤¥«¨â¥«ì
  173.         div     ebx             ;à §¬¤¥«¨¬ ­  6
  174. ret
  175.  
  176. ;----------------------------------------------------------
  177. ;--- ¯à®æ¥¤ãà  à¨á®¢ ­¨ï ªãàá®à  --------------------------
  178. ;----------------------------------------------------------
  179. ;¢å®¤­ë¥ ebp- 梥â
  180. .clear_cursor:
  181.         mov     edx,ebp
  182.         mov     ebx,cl_curs_x
  183.         mov     ecx,cl_curs_y
  184.         jmp     .draw_curs
  185. .draw_cursor:
  186.  
  187.         mov     edx,ed_text_color
  188. ;@@:
  189.         mov     ebx,ed_pos
  190.         mov     ecx,ed_offset
  191.         sub     ebx,ecx
  192.  
  193.         lea     ebx,[ebx*2+ebx]
  194.         shl     ebx,1
  195.         ;imul   ebx,6
  196.         add     bx,ed_left
  197.         mov     ecx,ed_top
  198.         inc     ebx
  199.         add     ecx,2
  200.         mov     ebp,ebx
  201.         shl     ebx,16
  202.         mov     bx,bp
  203.         mov     ebp,ecx
  204.        
  205.         shl     ecx,16
  206.         mov     cx,bp
  207.         add     cx,ed_height-4
  208.        
  209.         mov     cl_curs_x,ebx
  210.         mov     cl_curs_y,ecx
  211. .draw_curs:              
  212.         mov     eax,38
  213.         int     0x40
  214. ret
  215.  
  216. ;----------------------------------------------------------
  217. ;--- ¯à®æ¥¤ãà  à¨á®¢ ­¨ï à ¬ª¨ ----------------------------
  218. ;----------------------------------------------------------
  219. .draw_border:
  220. ;--- 梥â à ¬ª¨ ---
  221.         test    dword ed_flags,ed_focus
  222.         mov     edx,ed_focus_border_color
  223.         jne     @f
  224.         mov     edx,ed_blur_border_color
  225. @@:
  226. ;--- ᢥàåã ---
  227.         mov     eax,38
  228.         mov     ebx,ed_left
  229.         mov     ecx,ebx
  230.         shl     ebx,16
  231.         mov     bx,cx
  232.         add     bx,ed_width
  233.         mov     ecx, ed_top
  234.         mov     esi,ecx
  235.         shl     ecx,16
  236.         mov     cx,si
  237.         int     0x40
  238.  
  239. ;--- á­¨§ã ---
  240.         mov     esi,ecx
  241.         add     ecx,ed_height
  242.         mov     ebp,ecx
  243.         shl     ecx,16
  244.         mov     cx,bp
  245.         int     0x40
  246.  
  247. ;--- á«¥¢  ---
  248.         mov     cx,si
  249.         mov     ebp,ebx
  250.         sub     bx,ed_width
  251.         int     0x40
  252.  
  253. ;--- á¯à ¢  ---
  254.         mov     ebx,ebp
  255.         shl     ebx,16
  256.         mov     bx,bp
  257.         int     0x40
  258. ret
  259. ;----------------------------------------------------------
  260. ;--- ¯à®¢¥àª , § è¥« «¨ ªãàá®à §  £à ­¨æë ¨, ¥á«¨ ­ ¤®, ---
  261. ;--- ¨§¬¥­ï¥¬ ᬥ饭¨¥ ------------------------------------
  262. ;--- eax = -1, ¥á«¨ ­¥ ¨§¬¥­¨«®áì ¨«¨ eax = 0, ¥á«¨
  263. ; ¨§¬¥­¨«®áì
  264. ;----------------------------------------------------------
  265. .check_offset:
  266. pusha
  267.         mov     ecx,ed_pos
  268.         mov     ebx,ed_offset
  269.         cmp     ebx,ecx
  270.         ja      .sub_8
  271.  
  272.         push    ebx
  273.         call    .get_n                  ;¯®«ã稬 ª®«-¢® ᨬ¢®«®¢ ¢ ¯ à¥ ॣ¨áâ஢ edx:eax
  274.         pop     ebx
  275.         mov     edx,ebx
  276.         add     edx,eax         ;ed_offset+width editbox
  277.         cmp     edx,ecx
  278.         ja      @f
  279.  
  280.         mov     edx,ed_size
  281.         cmp     edx,ecx
  282.         je      .add_end
  283.  
  284.         sub     edx,ecx
  285.         cmp     edx,8
  286.         jbe     .add_8
  287.         add     ebx,8
  288.         jmp     .chk_d
  289.  
  290. .sub_8: cmp     ecx,0
  291.         je      .sub_min
  292.         cmp     ebx,8
  293.         jbe     .sub_min
  294.         sub     ebx,8   ;ebx=ed_offset
  295.         jmp     .chk_d
  296. .sub_min:
  297.         xor     ebx,ebx
  298.         jmp     .chk_d
  299.  
  300. .add_end:sub    edx,eax
  301.         mov     ebx,edx
  302.         jmp     .chk_d
  303. .add_8: add     ebx,edx
  304. .chk_d: mov     ed_offset,ebx
  305.         call    .draw_bg
  306.         ;mov    dword [esp+28],-1
  307. popa
  308.         ret
  309. @@:
  310.         mov     dword [esp+28],0
  311. popa
  312.         ret
  313. ;==========================================================
  314. ;=== ®¡à ¡®âª  ª« ¢¨ âãàë =================================
  315. ;==========================================================
  316. .key:
  317. pusha
  318.         test    word ed_flags,ed_focus ; ¥á«¨ ­¥ ¢ 䮪ãá¥, ¢ë室¨¬
  319.         je      @b
  320. ;à®¢¥àª  ­  ­ ¦ âë shift
  321.         xor     ecx,ecx
  322.         push    eax    
  323.         inc     ecx
  324.         mov     eax,66
  325.         mov     ebx,3
  326.         int     0x40
  327.         test    al,0x03
  328.         je      @f
  329.         or      word ed_flags,ed_shift   ;ãáâ ­®¢¨¬ ä« £
  330.  
  331. @@:     pop     eax   ;¢®ááâ ­®¢¨¬ áç¨â ­ë© ᨬ¢®« á ª« ¢¨ âãàë
  332. ;----------------------------------------------------------
  333. ;--- ¯à®¢¥à塞, çâ® ­ ¦ â® --------------------------------
  334. ;----------------------------------------------------------
  335.         cmp     ah,8
  336.         jz      .backspace
  337.         cmp     ah,0xb6
  338.         jz      .delete
  339.         cmp     ah,176
  340.         jz      .left
  341.         cmp     ah,179
  342.         jz      .right
  343.         cmp     ah,180
  344.         jz      .home
  345.         cmp     ah,181
  346.         jz      .end
  347.         cmp     ah,185  ;insert
  348.         jz      .insert
  349. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  350. ;‡ £«ã誠 ­  ®¡à ¡®âªã ª« ¢¨è ¢¢¥àå ¨ ¢­¨§
  351. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;   
  352.         cmp     ah,177
  353.         jz      .no_figure
  354.         cmp     ah,178
  355.         jz      .no_figure
  356.         cmp     ah,27   ;ESC - ª« ¢¨è  ))
  357.         jz      .no_figure
  358. ;--- ­ ¦ â  ¤àã£ ï ª« ¢¨è  ---
  359.         test    word ed_flags,ed_figure_only  ; ⮫쪮 æ¨äàë ?
  360.         jz      @f
  361.         cmp     ah,'0'
  362.         jb      .no_figure
  363.         cmp     ah,'9'
  364.         ja      .no_figure
  365.  
  366.  
  367. ;¯à®¢¥àª  ­  shift
  368. @@:     test    word ed_flags,ed_shift_on
  369.         je      @f
  370.         ;‚室­ë¥ ¤ ­­ë¥ edx=ed_size;ecx=ed_pos
  371.  
  372.         push    eax
  373.         mov     edx,ed_size
  374.         mov     ecx,ed_pos
  375.         pusha
  376.        
  377.         ;cmp    edx,ecx
  378.         ;jne    .sh_cl
  379. ;clear
  380.         mov     ebp,edx ;ed_size
  381.         call    .clear_bg
  382.         mov     ebp,ed_color
  383.         call    .sh_cl_
  384.  
  385. .sh_nxt:popa
  386.         call    .del_char
  387.        
  388. ;;;;
  389.         mov     eax,dword ed_shift_pos
  390.         mov     ebx,ed_size
  391.         sub     ebx,eax
  392.         mov     ed_size,ebx
  393.         pop     eax
  394.  
  395.         ; ¯à®¢¥à塞, ­ å®¤¨âáï «¨ ªãàá®à ¢ ª®­æ¥
  396. @@:     mov     ecx,ed_size
  397.         mov     edx, ed_max
  398.         test    word ed_flags,ed_insert
  399.         jne     @f
  400.         cmp     ecx,edx
  401.         jae     .no_figure
  402. @@:     mov     ebx, ed_pos
  403.         cmp     ebx,edx
  404.         jl      @f ; ¥á«¨ ¬¥­ìè¥ ¨«¨ à ¢­®
  405. .no_figure:
  406.         popa
  407.         ret
  408. .insert: test   word ed_flags,ed_insert ;not    word ed_insert
  409.          je     .insert_1
  410.          and    word ed_flags,ed_insert_cl
  411.         jmp     .no_figure
  412. .insert_1:
  413.         or      word ed_flags,ed_insert
  414.         jmp     .no_figure
  415. .ins_v:
  416.         dec     dword [ebp+38];ed_size    ;processing is insert
  417.         sub     esi,ecx
  418.         add     esi,ebx
  419.         mov     edi,esi
  420. ;clear
  421. pusha
  422.         mov     edi,ebp
  423.         mov     ebp,ed_pos
  424.         call    .clear_bg
  425. popa
  426.         jmp     .In_k
  427. @@:     ; ᤢ¨£ ¥¬ ᨬ¢®«ë ¯®á«¥ ªãàá®à  ¢¯à ¢®
  428.         mov     ecx,ed_size
  429.         push    edi eax
  430.         mov     ebp,edi
  431.         mov     esi,ed_text     ; “ª § â¥«ì ­  ¡ãä¥à
  432.                                 ;ã¤¥¬ à ¡®â âì á® áâப®©
  433.         add     esi,ecx         ;add ed_size ¤®¡ ¢¨¬ max size
  434.         mov     edi,esi
  435.  
  436.         cmp     ecx,ebx         ;…᫨ ã ­ á ¯®§¨æ¨ï ªãàá®à  = ⥪ã饬ã à §¬¥àã ­ ¯¥ç â ­­ëå ᨬ¢®«®¢ â.¥. ªãàá®à á⮨⠢ ª®­æ¥
  437.         je      .In_k
  438.  
  439.         test    word [ebp+36],ed_insert ;IF insert is enable  â.ª. edi ¨§¬¥­¥­  ¤à¥á㥬 ç¥à¥§ ebp
  440.         jne     .ins_v
  441. ;clear
  442. pusha
  443.         mov     edi,ebp
  444.         mov     ebp,ed_size
  445.         call    .clear_bg
  446. popa
  447.         sub     ecx,ebx         ; ©¤¥¬ ª®«-¢® ᨬ¢®«®¢ ¤«ï ¯¥à¥¤¢¨¦¥­¨ï.
  448.         inc     edi             ;‘¬¥á⨬ ­ è¨ ᨬ¢®«ë ¢ ¯à ¢®
  449.         std
  450.         inc     ecx
  451.    @@: 
  452.         ;--------
  453.         lodsb
  454.         stosb
  455.         ;--------
  456.         loop    @b
  457. .In_k:  cld
  458.         pop eax
  459.         mov al,ah
  460.         stosb
  461.         pop edi
  462. ; ¢áâ ¢«ï¥¬ ª®¤ ª« ¢¨è¨ â㤠, £¤¥ ªãàá®à
  463.         ; 㢥«¨ç¨¢ ¥¬ §­ ç¥­¨¥ à §¬¥à  ¨ ¯®§¨æ¨¨
  464.         inc      dword ed_size
  465.         inc      dword ed_pos
  466.         call    .draw_all2
  467.         jmp     .shift;.draw_cursor_text
  468. .delete:       
  469.         mov     edx,ed_size
  470.         mov     ecx,ed_pos
  471.         cmp     edx,ecx
  472.         jg      .bac_del
  473.         test    word ed_flags,ed_shift_on
  474.         jne     .del_bac
  475.         popa
  476.         ret
  477. .bac_del:      
  478.         call    .del_char
  479.         jmp     .draw_all
  480.        
  481. ;--- ­ ¦ â  ª« ¢¨è  backspace ---
  482. .backspace:
  483.         ; ¯à®¢¥à塞, ªãàá®à ã «¥¢®£® ªà ï ?
  484.         mov     edx,ed_size
  485.         mov     ecx,ed_pos
  486.         test    ecx,ecx
  487.         jnz     .del_bac
  488.         test    word ed_flags,ed_shift_on
  489.         jne     .bac_del
  490.         popa
  491.         ret
  492. .del_bac:
  493.         cmp     edx,ecx ;if ed_pos=ed_size
  494.         je      @f
  495.         dec     ecx
  496.         call    .del_char
  497. @@:     test    word ed_flags,ed_shift_on
  498.         jne     .bac_del
  499.         dec      dword ed_pos
  500.  
  501. .draw_all:
  502.         push    .shift;.draw_cursor_text;eax
  503.  
  504.         test    word ed_flags,ed_shift_on
  505.         je      @f
  506.         mov     eax,dword ed_shift_pos
  507.         mov     ebx,ed_size
  508.         sub     ebx,eax
  509.         mov     ed_size,ebx
  510.  
  511.         mov     ebp,ed_color
  512.         call    .clear_cursor
  513.         call    .check_offset
  514.         call    .draw_bg
  515.  
  516.         ret
  517.  
  518. @@:     dec      dword ed_size
  519.  
  520. .draw_all2:
  521.         and    word ed_flags,ed_shift_cl
  522.         mov     ebp,ed_color
  523.         call    .clear_cursor
  524.         call    .check_offset
  525.         mov     ebp,ed_size
  526.         call    .clear_bg
  527.         ret
  528.         ;jmp    .shift
  529. ;--- ­ ¦ â  ª« ¢¨è  left ---
  530. .left:  mov     ebx,ed_pos
  531.         test    ebx,ebx
  532.         jz      .sh_st_of
  533.         or      word ed_flags,ed_left_fl
  534.         call    .sh_first_sh
  535.         dec      dword ed_pos
  536.         call    .sh_enable
  537.         jmp     .draw_cursor_text
  538. ;--- ­ ¦ â  ª« ¢¨è  right ---
  539. .right: mov     ebx,ed_pos
  540.         cmp     ebx,ed_size
  541.         je      .sh_st_of
  542.         and     word ed_flags,ed_right_fl
  543.         call    .sh_first_sh
  544.         inc     dword  ed_pos
  545.         call    .sh_enable
  546.         jmp     .draw_cursor_text
  547. .home:  
  548.         mov     ebx,ed_pos
  549.         test    ebx,ebx
  550.         jz      .sh_st_of
  551.         call    .sh_first_sh
  552.         xor     eax,eax
  553.         mov     ed_pos,eax
  554.         call    .sh_home_end
  555.         jmp     .draw_cursor_text
  556. .end:  
  557.         mov     ebx,ed_pos
  558.         cmp     ebx,dword ed_size
  559.         je      .sh_st_of
  560.         mov     eax,ed_size
  561.         mov     ed_pos,eax
  562.         call    .sh_home_end
  563.         jmp     .draw_cursor_text
  564. ;Ž¡à ¡®âª  Shift ¤«ï á­ïâ¨ï ¢ë¤¥«¥­¨ï ­¥¨§¢¥áâ­®© ®¡« áâ¨
  565. .shift: ;;;;;;;SHIFT
  566.         test    word ed_flags,ed_shift
  567.         je      .f_exit
  568.  
  569. @@:     mov     ebp,shift_color
  570.         or      word ed_flags,ed_shift_bac ;ãáâ ­®¢ª  ä« £ , ¢ë¤¥«¥­­®© ®¡« áâ¨
  571.         call    .sh_cl_
  572.         jmp     .draw_cursor_text
  573. ;;;;;;;;;;;;;;;;;;;;;
  574. .f_exit:call    .check_offset
  575.         and    word ed_flags,ed_shift_cl
  576.         call    .enable_null
  577.         jmp     .draw_cursor_text
  578. .sh_cl_:
  579. ;;;;;;SHIFT end
  580. ;®¡à ¡®âª  ®ç¨á⪨, ¯à¨ «¥¢®¬ - ¯à ¢®¬ ¤¢¨¦¥­¨¨ ¢ë¤¥«¥­¨ï
  581. ;¤«ï ®¡à ¡®âª¨ á­ïâ¨ï ¢ë¤¥«¥­¨ï
  582. ;       or      word ed_flags,ed_shift_bac ;ãáâ ­®¢ª  ä« £ , ¢ë¤¥«¥­­®© ®¡« áâ¨
  583.         mov     eax,dword       ed_pos
  584.         mov     ebx,dword       ed_shift_pos
  585.         cmp     eax,ebx
  586.         jae     .sh_n
  587.         push    eax  ;¬¥­ì襥 ¢ eax
  588.         push    ebx  ;¡®«ì襥
  589.         jmp     .sh_n1
  590.                      ;¥á«¨ ¨­ ç¥
  591. .sh_n:  push    ebx  
  592.         push    eax
  593. .sh_n1:
  594.         call    .check_offset
  595. ;       test    eax,eax
  596. ;       jz      .drw_sim
  597.         call    .get_n
  598.         mov     edx,eax ;size of ed_box
  599. ;       push    eax
  600.         mov     ecx,ed_offset
  601.         add     eax,ecx ;eax = w_off= ed_offset+width
  602.         mov     edx,eax ;save
  603.         pop     ebx     ;¡®«ì襥
  604.         pop     eax     ;¬¥­ì襥
  605.  
  606.         cmp     eax,ecx         ;áà ¢­¥­¨¥ á ¬¥­ì襣® á offset.
  607.         jae     .f_f            ;¥á«¨ ¡®«ìè¥
  608.         xor     eax,eax
  609.         cmp     edx,ebx         ;cà ¢­¨¬ à §¬¥à w_off á ¡®«ì訬
  610.         jb      @f
  611.         sub     ebx,ecx
  612.         jmp     .nxt_f
  613. @@:     mov     ebx,edx
  614.         sub     ebx,ecx
  615.         jmp     .nxt_f
  616.  
  617. .f_f:  
  618.         sub     eax,ecx
  619.         cmp     edx,ebx         ;cà ¢­¨¬ à §¬¥à w_off á ¡®«ì訬
  620.         jle     @f
  621.         sub     ebx,ecx
  622.         sub     ebx,eax
  623.         jmp     .nxt_f
  624. @@:
  625.         mov     ebx,edx
  626.         sub     ebx,ecx
  627.         sub     ebx,eax
  628. .nxt_f:
  629.         mov     edx,ebx
  630.         lea     ebx,[eax*2+eax]
  631.         shl     ebx,1
  632.         add     ebx,ed_left
  633.         inc     ebx
  634.         shl     ebx,16
  635.         lea     ecx,[edx*2+edx]
  636.         shl     ecx,1  
  637.         mov     bx,cx
  638.         inc     ebx
  639.         mov     edx,ebp;shift_color
  640.  
  641.         call    .draw_bg_eax
  642. @@:     ;and    word ed_flags,1111111111111011b
  643.         call    .enable_null
  644.         ;mov    dword   ed_shift_pos,0
  645.         ret
  646. ;;;;;;;;;;;;;;;;;;;;;
  647. ;“áâ ­®¢ª - á­ï⨥ ¢ë¤¥«¥­¨ï ¢ ®¤¨­ ᨬ¢®«
  648. ;;;;;;;;;;;;;;;;;;;;;
  649. .drw_sim:
  650.         mov     eax,dword       ed_pos
  651.         call    .draw_rectangle   ;­ à¨á®¢ âì ¯àאַ㣮«ì­¨ª á § ¤ ­­ë¬ 梥⮬
  652.         jmp     @b
  653. ;;;;;;;;;;;;;;;;;;;;;
  654.  
  655. ;;;;;;;;;;
  656. ;”ãªæ¨ï ãáâ ­®¢ª¨ ¢ë¤¥«¥­¨ï ¯à¨ ¤¢¨¦¥­¨ï ¢«¥¢® ¨ ¢¯à ¢® ¨ ­ ¦ â¨¨ shift
  657. ;‹®£¨ª :
  658. ;;;;;;;;;;
  659. .draw_wigwag:
  660. ;äã­ªæ¨ï ãáâ ­®¢ª¨ ¯¥à¥¬¥­­ëå
  661.         mov     ebp,shift_color
  662.         call    .clear_cursor
  663.  
  664.         or      word ed_flags,ed_shift_bac ;ãáâ ­®¢ª  ä« £ , ¢ë¤¥«¥­­®© ®¡« áâ¨
  665.         mov     ebp,shift_color
  666.         mov     eax,dword       ed_pos
  667.         ;mov    ebx,dword       ed_shift_pos
  668.         test    word ed_flags,ed_left_fl
  669.         jz      .low
  670. ;       sub     eax,2
  671.         ;dec    eax
  672.         jmp     @f
  673. ;;;;;;;;;;
  674. ;”ãªæ¨ï 㤠«¥­¨ï ¢ë¤¥«¥­¨ï ¯à¨ ¤¢¨¦¥­¨ï ¢«¥¢® ¨ ¢¯à ¢® ¨ ­ ¦ â¨¨ shift
  675. ;‹®£¨ª :
  676. ;;;;;;;;;;
  677. .draw_wigwag_cl:
  678. ;äã­ªæ¨ï ãáâ ­®¢ª¨ ¯¥à¥¬¥­­ëå
  679.         mov     ebp,ed_color
  680.         call    .clear_cursor
  681.  
  682.         mov     ebp,ed_color
  683.         mov     eax,dword       ed_pos
  684.         ;mov    ebx,dword       ed_shift_pos
  685.         test    word ed_flags,ed_left_fl
  686.         jz      .low
  687.         ;dec    eax
  688. @@:     call    .draw_rectangle  ;­ à¨á®¢ âì ¯àאַ㣮«ì­¨ª § ªà è¨¢ ¥¬®© ®¡« áâ¨
  689.         ret
  690. .low:   dec     eax
  691.         jmp     @b
  692. ;¢å®¤­®© ¯ à ¬¥âà ebx - ed_pos
  693. .sh_first_sh:
  694.         test    word ed_flags,ed_shift
  695.         je      @f
  696.         mov     dword ed_shift_pos_old,ebx
  697.         test    word ed_flags,ed_shift_on
  698.         jne     @f
  699.         mov     dword ed_shift_pos,ebx
  700.         or      word ed_flags,ed_shift_on
  701. @@:     ret
  702.  
  703. ;Ž¡à ¡®âª  ªà ©­¨å ¯®«®¦¥­¨© ¢ editbox ¯à¨ ­ ¦ â®¬ shift
  704. ;¯à®¨§¢®¤¨â á­ï⨥ ¢ë¤¥«¥­¨¥, ¥á«¨ ­¥â shift
  705. ;¨­ ç¥ ¢®®¡é¥ ¢ë室¨â
  706. .sh_st_of:
  707.         test    word ed_flags,ed_shift
  708.         jne     @f
  709.         test    word ed_flags,ed_shift_bac
  710.         je      @f
  711.         mov     ebp,ed_color
  712.         call    .sh_cl_  ;®ç¨á⪠ ¢ë¤¥«¥­®£® äà £¬¥­â 
  713.         call    .draw_wigwag_cl
  714.         and     word ed_flags,ed_shift_cl ; ®ç¨á⪠ ®â ⮣® çâ® ã¡à «¨ ¢ë¤¥«¥­¨¥
  715.         jmp     .draw_cursor_text
  716. @@:
  717.         ;-----------  ®â« ¤ª 
  718. ;       pushad
  719. ;       mov     dword [ed_buffer.3],0
  720. ;       mov eax,ebx;word ed_flags
  721. ;       mov edi,ed_buffer.3
  722. ;       call .str
  723. ;       ;à¨á®¢ ­¨¥ ä®­ 
  724. ;       mov eax,13
  725. ;       mov ebx,178*65536+70
  726. ;       mov ecx,28*65536+10
  727. ;       xor edx,edx
  728. ;       int 0x40
  729. ;       ;¢ë¢®¤ §­ ç¥­¨ï ­  íªà ­
  730. ;       mov eax,4
  731. ;       mov ebx,180*65536+30
  732. ;       mov ecx,0x10DDBBCC
  733. ;       mov edx,ed_buffer.3
  734. ;       mov esi,8
  735. ;       int 0x40
  736. ;       popad
  737.         ;----------- ®â« ¤ª 
  738.         and     word ed_flags,ed_shift_off
  739.         popa
  740.         ret    
  741.  
  742. ;¯à®¢¥àª  á®áâ®ï­¨ï shift ¡ë« «¨ ®­ ­ ¦ â à ­ìè¥?
  743. .sh_enable:
  744.         test    word ed_flags,ed_shift
  745.         jne     .sh_ext_en ;­ à¨á®¢ âì § ªà è¥­ë© ¯àאַ㣮«ì­¨ª
  746.  
  747.         test    word ed_flags,ed_shift_bac
  748.         je      @f
  749.         call    .check_offset
  750.  
  751.         mov     ebp,ed_color
  752.         call    .sh_cl_  ;®ç¨á⪠ ¢ë¤¥«¥­®£® äà £¬¥­â 
  753.         call    .draw_wigwag_cl
  754.         and     word ed_flags,ed_shift_cl ; 1¢ à ­¥ ­ã¦­®
  755.         ret
  756.  
  757. @@:     mov     ebp,ed_color
  758.         call    .clear_cursor
  759.         call    .check_offset
  760.         ret
  761. .sh_ext_en:    
  762.         call    .check_offset
  763.         test    eax,eax
  764.         jnz     @f
  765. ;¨á®¢ ­¨¥ § ªà è¥­ëå ¯àאַ㣮«ì­¨ª®¢ ¨ ®ç¨á⪠ ¨å
  766.         mov     eax,dword       ed_shift_pos
  767.         mov     ebx,dword       ed_pos
  768.         mov     ecx,dword       ed_shift_pos_old
  769. ;¯à®¢¥àª  ¨ à¨á®¢ ­¨¥ § ªà è¥­ëå ®¡« á⥩
  770.         cmp     eax,ecx
  771.         je      .1_shem
  772.         jb      .smaller
  773.         cmp     ecx,ebx
  774.         ja      .1_shem
  775.         call    .draw_wigwag_cl ;clear
  776.         jmp     .sh_e_end
  777. .smaller:
  778.         cmp     ecx,ebx
  779.         jb      .1_shem
  780.         call    .draw_wigwag_cl ;clear
  781.         jmp     .sh_e_end
  782. ;alike  =
  783. .1_shem: call   .draw_wigwag
  784. .sh_e_end:      and     word ed_flags,ed_shift_off
  785.         ret
  786. @@:     mov     ebp,shift_color
  787.         call    .sh_cl_
  788.         jmp     .sh_e_end
  789. ;äã­ªæ¨ï ¤«ï ®¡à ¡®âª¨ shift ¯à¨ ­ ¦ â¨¨ home and end
  790. .sh_home_end:
  791.         mov     ebp,ed_color
  792.         call    .clear_cursor
  793.         test    word ed_flags,ed_shift_bac
  794.         je      @f
  795.         mov     ebp,ed_color
  796.         call    .sh_cl_
  797.  
  798. @@:     test    word ed_flags,ed_shift
  799.         je      .sh_exit_ ;­ à¨á®¢ âì § ªà è¥­ë© ¯àאַ㣮«ì­¨ª (®¡« áâì)
  800.         call    .check_offset
  801.         mov     ebp,shift_color
  802.         call    .sh_cl_
  803.         or      word ed_flags,ed_shift_bac ;ãáâ ­®¢ª  ä« £ , ¢ë¤¥«¥­­®© ®¡« áâ¨
  804.         jmp     .sh_e_end
  805. .sh_exit_:      ret
  806.  
  807.  
  808. ;       test    word ed_flags,ed_shift_bac
  809. ;        je      @f
  810.  
  811.  
  812.  
  813.  
  814.  
  815.  
  816.  
  817.  
  818.  
  819. ;äã­ªæ¨ï ¢­¥á¥­¨ï 0 ¯®  ¤à¥áã ed_size+1
  820. .enable_null:
  821.         pusha
  822.         mov     eax,ed_size
  823.         mov     ebx,ed_text
  824.         add     eax,ebx
  825.         inc     eax
  826.         xor     ebx,ebx
  827.         mov     [eax],bl
  828.         popa
  829.         ret
  830.  
  831.         ;- 㤠«¥­¨¥ ᨬ¢®« 
  832.         ;‚室­ë¥ ¤ ­­ë¥ edx=ed_size;ecx=ed_pos
  833. .del_char:
  834.         mov     esi,ed_text
  835.         test    word ed_flags,ed_shift_on
  836.         je      @f
  837.         mov     eax,dword ed_shift_pos
  838.         mov     ebx,esi
  839.         cmp     eax,ecx
  840.         jae     .dh_n
  841.  
  842.         mov     ed_pos,eax      ;çâ® ¡ë ­¥ ¡ë«® ã¡¥£ ­¨ï ªãàá®à 
  843.         mov     ebp,ecx
  844.         sub     ebp,eax
  845.         add     ebx,eax  ;eax ¬¥­ìè¥
  846.         sub     edx,ecx
  847.         add     esi,ecx
  848.  
  849.         mov     dword ed_shift_pos,ebp
  850.         jmp     .del_ch_sh
  851.                      ;¥á«¨ ¨­ ç¥
  852. .dh_n:  
  853.         mov     ebp,eax
  854.         sub     ebp,ecx
  855.         add     ebx,ecx
  856.         sub     edx,eax
  857.         add     esi,eax
  858.         mov     dword ed_shift_pos,ebp
  859.         jmp     .del_ch_sh
  860.  
  861. @@:     add     esi,ecx ;㪠§ â¥«ì + ᬥ饭¨¥ ª ॠ«ì­®¬ã ¡ãää¥àã
  862.         mov     ebx,esi
  863.         inc     esi
  864.         cld
  865.  
  866.         sub     edx,ecx
  867. .del_ch_sh:
  868.  
  869.         push    edi
  870.         mov     edi,ebx
  871. @@:
  872.         lodsb
  873.         stosb
  874.         dec edx
  875.         jns @b
  876.        
  877.         pop edi
  878.         ret
  879.  
  880. ;¢ëç¨á«¨âì § ªà è¨¢ ¥¬ãî ®¡« áâì
  881. ;ᮣ« è¥­¨¥ ¢ ebp - ¯¥à¥¤ ¥âáï ed_size
  882. .clear_bg:
  883.         call    .get_n  ;¯®«ãç¨âì à §¬¥à ¢ ᨬ¢®« å è¨à¨­ë ª®¬¯®­¥­â 
  884.         push    eax
  885.         mov     ebx,ed_offset
  886.         add     eax,ebx ;eax = w_off= ed_offset+width
  887.         mov     ebx,ebp ;ed_size
  888.        
  889.         cmp     eax,ebx
  890.         jb      @f
  891.         mov     eax,ed_pos
  892.         sub     ebx,eax
  893.         mov     ecx,ed_offset
  894.         sub     eax,ecx
  895.         jmp     .nxt
  896. @@:     mov     ebx,ed_pos
  897.         push    ebx
  898.         sub     eax,ebx
  899.         mov     ebx,eax ;It is don't optimal
  900.        
  901.         pop     eax     ;ed_pos
  902.         mov     ecx,ed_offset
  903.         sub     eax,ecx
  904.  
  905. .nxt:
  906.         mov     ebp,eax  ;¯à®¢¥àª  ­  ¢ë室 § ªà è¨¢ ¥¬®© ®¡« á⨠§  ¯à¥¤¥«ë ¤«¨­ë
  907.         add     ebp,ebx
  908.         pop     edx
  909.         cmp     ebp,edx
  910.         je      @f
  911.         inc     ebx
  912.  
  913. @@:     mov     edx,ebx
  914.         lea     ebx,[eax*2+eax]
  915.         shl     ebx,1
  916.         add     ebx,ed_left
  917.         inc     ebx
  918.         shl     ebx,16
  919.         lea     ecx,[edx*2+edx]
  920.         shl     ecx,1  
  921.         mov     bx,cx
  922.         mov     edx,ed_color
  923.         call    .draw_bg_eax
  924.         ret
  925. ;;;;;;;;;;;;;;;;;;;
  926. ;;; Ž¡à ¡®âª  ¯à¨¬¨â¨¢®¢
  927. ;;;;;;;;;;;;;;;;;;;;
  928. ; à¨á®¢ âì ¯àאַ㣮«ì­¨ª, 梥⠯¥à¥¤ ¥âáï ¢ ebp
  929. ;¢å®¤­ë¥ ¯ à ¬¥âàë:
  930. ;eax=dword ed_pos
  931. ;ebp=-梥â ed_color or shift_color
  932. .draw_rectangle:
  933. ;        mov    eax,dword ed_pos
  934.         mov     ecx,dword ed_offset
  935.         sub     eax,ecx
  936.         lea     ebx,[eax*2+eax]
  937.         shl     ebx,1
  938.         inc     ebx
  939.         add     ebx,ed_left
  940.         shl     ebx,16
  941.         mov     bx,6
  942.         mov     edx,ebp
  943.         call    .draw_bg_eax
  944.         ret
  945. ;==========================================================
  946. ;=== ®¡à ¡®âª  ¬ëè¨ =======================================
  947. ;==========================================================
  948. .mouse:
  949. pusha
  950. ;----------------------------------------------------------
  951. ;--- ¯®«ãç ¥¬ á®áâ®ï­¨¥ ª­®¯®ª ¬ëè¨ -----------------------
  952. ;----------------------------------------------------------
  953.         mov     eax,37
  954.         mov     ebx,2
  955.         int     0x40
  956. ;----------------------------------------------------------
  957. ;--- ¯à®¢¥à塞 á®áâ®ï­¨¥ ----------------------------------
  958. ;----------------------------------------------------------
  959.         test    eax,1
  960.         jnz     .mouse_left_button
  961.         popa
  962.         ret
  963.  
  964. .mouse_left_button:
  965. ;----------------------------------------------------------
  966. ;--- ¯®«ãç ¥¬ ª®®à¤¨­ âë ¬ëè¨ -----------------------------
  967. ;----------------------------------------------------------
  968.         mov     eax,37
  969.         xor     ebx,ebx
  970.         inc     ebx
  971.         int     0x40
  972. ;----------------------------------------------------------
  973. ;--- ¯à®¢¥à塞, ¯®¯ ¤ ¥â «¨ ªãàá®à ¢ edit box -------------
  974. ;----------------------------------------------------------
  975.         mov     ebx,ed_top
  976.         cmp     ax,bx
  977.         jl      ._blur;.mouse_end_no_focus
  978.  
  979.         add     bx,ed_height
  980.         cmp     ax,bx
  981.         jg      ._blur;.mouse_end_no_focus
  982.  
  983.         shr     eax,16
  984.  
  985.         mov     bx,ed_left
  986.         cmp     ax,bx
  987.         jl      ._blur;.mouse_end_no_focus
  988.  
  989.         add     bx,ed_width
  990.         cmp     ax,bx
  991.         jg      ._blur;.mouse_end_no_focus
  992. ;--- ¨§¬¥­ï¥¬ ¯®§¨æ¨î ªãàá®à  ---
  993.         push    eax
  994.         mov     ebp,ed_color
  995.         call    .clear_cursor
  996.         pop     eax
  997.         xor     dx,dx
  998.         sub     ax,ed_left
  999.         add     ax,2
  1000.         mov     bx,6
  1001.         div     bx
  1002.         add     ax,ed_offset
  1003.         cmp     ax,ed_size
  1004.         jna      @f
  1005.         mov     ax,ed_size
  1006. @@:
  1007.         mov     ed_pos,ax
  1008.         call    .check_offset
  1009.         call    .draw_cursor
  1010. ;----------------------------------------------------------
  1011. ;--- ¯à®æ¥¤ãà  ãáâ ­®¢ª¨ 䮪ãá  ---------------------------
  1012. ;----------------------------------------------------------
  1013.         bts     word ed_flags,1
  1014.         jc      @f
  1015.         call    .draw_cursor
  1016.         jmp     .drc
  1017.  
  1018.  
  1019. ._blur:
  1020.         test    word ed_flags,ed_always_focus
  1021.         jne     @f
  1022.         btr     word ed_flags,1 ; ¥á«¨ ­¥ ¢ 䮪ãá¥, ¢ë室¨¬
  1023.         jnc     @f
  1024.         mov     ebp,ed_color
  1025.         call    .clear_cursor
  1026. .drc:   call    .draw_border
  1027. @@:
  1028. popa
  1029. ret
  1030.  
  1031. ;----------------------------------------------------------
  1032. ;--- ¯à®æ¥¤ãà  à §¬ë¢ ­¨ï 䮪ãá  --------------------------
  1033. ;----------------------------------------------------------
  1034. ;.blur:
  1035. ;pusha
  1036. ;._blur:
  1037.         ;btr     ed_flags,1
  1038.         ;jnc     @f
  1039.         ;call    .draw_border
  1040.         ;call    .clear_cursor
  1041. ;@@:
  1042. ;popa
  1043. ;ret
  1044. }
  1045. ed_figure_only= 1000000000000000b
  1046. ed_always_focus= 100000000000000b
  1047. ed_focus=10b
  1048. ed_shift_on=                1000b   ;¥á«¨ ­¥ ãáâ ­®¢«¥­ -§­ ç¨â ¢¯¥à¢ë¥ ­ ¦ â shift,¥á«¨ ¡ë« ãáâ ­®¢«¥­, §­ ç¨â ¬ë 㦥 çâ® - â® ¤¥« «¨ 㤥ন¢ ï shift
  1049. ed_shift=                    100b   ;¢ª«îç ¥âáï ¯à¨ ­ ¦ â¨¨ ­  shift â.¥. ¥á«¨ ­ ¦¨¬ î
  1050. ed_shift_off=   1111111111111011b
  1051. ed_shift_bac=              10000b   ;¡¨â ¤«ï ®ç¨á⪨ ¢ë¤¥«¥­®£® shift â.¥. ¯à¨ ãáâ ­®¢ª¥ £®¢®à¨â çâ® ¥áâì ¢ë¤¥«¥­¨¥
  1052. ed_shift_cl=    1111111111100011b
  1053. ed_left_fl=               100000b
  1054. ed_right_fl=    1111111111011111b
  1055. ed_insert=              10000000b
  1056. ed_insert_cl=   1111111101111111b
  1057. ed_height=14 ; ¢ëá®â 
  1058. shift_color=0x6a9480
  1059. macro draw_edit_boxes start,end
  1060. {
  1061.         mov     edi,start
  1062.         mov     ecx,((end-start)/ed_struc_size)
  1063. @@:
  1064.         call    edit_box.draw
  1065.         add     edi,ed_struc_size
  1066.         loop    @b
  1067. }
  1068.  
  1069. macro mouse_edit_boxes start,end
  1070. {
  1071.         mov     edi,start
  1072.         mov     ecx,((end-start)/ed_struc_size)
  1073. @@:
  1074.         call    edit_box.mouse
  1075.         add     edi,ed_struc_size
  1076.         loop    @b
  1077. }
  1078.  
  1079. macro key_edit_boxes start,end
  1080. {
  1081.         mov     edi,start
  1082.         mov     ecx,((end-start)/ed_struc_size)
  1083. @@:
  1084.         call    edit_box.key
  1085.         add     edi,ed_struc_size
  1086.         loop    @b
  1087. }
  1088. ed_struc_size=66
  1089. struc  edit_box width,left,top,color,focus_border_color,\
  1090.        blur_border_color,text_color,max,text,flags,size
  1091. {
  1092. .width dd width
  1093. .left dd left
  1094. .top dd top
  1095. .color dd color
  1096. .focus_border_color dd focus_border_color
  1097. .blur_border_color dd blur_border_color
  1098. .text_color dd text_color
  1099. .max dd max
  1100. .text dd text
  1101. .flags dw flags+0
  1102. .size dd size+0
  1103. .pos dd 0
  1104. .offset dd 0
  1105. .cl_curs_x dd 0
  1106. .cl_curs_y dd 0
  1107. .shift   dd 0
  1108. .shift_old   dd 0
  1109. }
  1110.  
  1111. macro edit_boxes_set_sys_color start,end,color_table
  1112. {
  1113.         mov     edi,start
  1114.         mov     ecx,((end-start)/ed_struc_size)
  1115.         mov     esi,color_table
  1116. @@:
  1117.         mov     eax,[esi+36]
  1118.         mov     ebx,[esi+20]
  1119.         mov     ed_focus_border_color,eax
  1120.         shr     bh,1
  1121.         shr     bl,1
  1122.         shr     ah,1
  1123.         shr     al,1
  1124.         add     ah,bh
  1125.         add     al,bl
  1126.         ror     eax,16
  1127.         ror     ebx,16
  1128.         shr     bl,1
  1129.         shr     al,1
  1130.         add     al,bl
  1131.         ror     eax,16
  1132.         mov     ed_blur_border_color,eax
  1133.         add     edi,ed_struc_size
  1134.         loop    @b
  1135. }
  1136.  
  1137. macro draw_edit_box ed_ptr
  1138. {
  1139.         mov     edi,ed_ptr
  1140.         call    edit_box.draw
  1141. }
  1142.  
  1143. macro mouse_edit_box ed_ptr
  1144. {
  1145.         mov     edi,ed_ptr
  1146.         call    edit_box.mouse
  1147. }
  1148.  
  1149. macro key_edit_box ed_ptr
  1150. {
  1151.         mov     edi,ed_ptr
  1152.         call    edit_box.key
  1153. }