Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 305 → Rev 304

/programs/system/run/trunk/editbox.inc
1,15 → 1,6
; <Lrz> 01.02.2007 ¤®à ¡®âª  edit_box, ¨á¯à ¢¨« ¡ £¨.
; <Lrz> 26.01.2007 ­®à¬ «ì­ ï à ¡®â  ª®¬¯ ­¥­â  ¨á¯à ¢¨« äãªæ¨î .check_offset
; <Lrz> 24.01.2007 ¯®ä¨ªá¥« ¡ £¨ ¢ë§¢ ­ë¥ ­¥ ¯à ¢¨«ì­ë¬ ª®¤®¬ )).
; <Lrz> 22.01.2007 ¨§¡ ¢¨«áï ®â £«îª®¢ ¯à¨ à ¡®â¥ á ¢ë¤¥«¥­¨¥¬ ¨ 㤠«¥­¨¥, ª®à४⭠ï à ¡®â  ª« ¢¨è¥© del & backspase
; <Lrz> 20.01.2007 ॠ«¨§®¢ « ¢ë¤¥«¥­¨¥ ⥪áâ  ¯® shift
; <Lrz> 12.12.2006 ॠ«¨§®¢ « ¯®¤¤¥à¦ªã ª­®¯ª¨ insert ¨ ᥣ®¤ï ª®¬¯®­¥­â ¯®ç⨠ࠡ®â ¥â!!!!
; <Lrz> 07.12.2006 ¯à®¤®«¦ ¥âáï à ¡®â  ­ ¤ ¯¥à¥à ¡®âª®© ª®¬¯®­¥­â ,¨§¬¥­¥­¨ï¬ ¯®¤¢¥à£«¨áì ¬­®£¨¥ ä㭪樨, ¯¥à¥à ¡®â ­ ¢ë¢®¤ ⥪áâ ,   â ª  ¦¥  «£®à¨â¬ ¢­¥á¥­¨ï ᨬ¢®«®¢.
; <Lrz> 03.09.2006 ¯® ¢®§¬®¦­®á⨠®âª § «áï ®â 16 ¡¨â­®©  à¨ä¬¥â¨ª¨, ¤®¡ ¢¨« ­®¢ë¥ ¡ £¨
; <Lrz> 09.08.2006 ¯à®¨§¢¥¤¥­  ®¯â¨¬¨§ æ¨ï à ¡®âë ª®­¯®ª DEL ¨ Backspace, 㬥­ì襭 à §¬¥à ¢ë¯®«­ï¥¬®£® ª®¤ .
; <Lrz> 21.07.2006 ¤®¡ ¢«¥­  äã­ªæ¨ï ª­®¯ª¨ Del, ⥯¥àì ¬®¦­® 㤠«ïâì ᨬ¢®«ë ¯à¨ ¯®¬®é¨ ¤ ­­®© ª« ¢¨è¨
; <Lrz> 21.07.2006 ¤®¡ ¢«¥­  äã­ªæ¨ï ª­®¯ª¨ Del, ⥯¥àì ¬®¦­® 㤠«ïâì ᨬ¢®«ë ¯à¨ ¯®¬®é¨ ¤ ­­®© ª®« ¢¨è¨
; €¢â®à: …¢â¨å®¢ Œ ªá¨¬ (Maxxxx32) email: maxxxxm@mail.ru
; „ â  ¯®á«¥¤­¨å ¨§¬¥­¥­¨©: 13.06.06 10:40
; „ â  ¯®á«¥¤­¨å ¨§¬¥­¥­¨©: 13.07.06 10:40
;  ¯¨è¨â¥ ¢ ¨á室­®¬ ª®¤¥ ᢮¥© ¯à®£à ¬¬ë use_edit_box,
; íâ® ¢áâ ¢¨â ­¥®¡å®¤¨¬ë¥ ¯à®æ¥¤ãàë ¢ ª®¤ ¢ è¥© ¯à®£à ¬¬ë.
; à®æ¥¤ãàë:
23,7 → 14,7
; ®áâ ¢¨âì 㪠§ â¥«ì ­  áâàãªâãàã.
; à¨¬¥à áâàãªâãàë:
; some_edit edit_box 100,10,30,0x00ffffff,0,0x00aaaaaa,0,255,some_edit_text
; ¤«¨­ , ¢ëá®â , ¢¥àå, 梥â ä®­ , 梥â à ¬ª¨, ¥á«¨ ¢ë¡à ­,
; ¤«¨­ , «¥¢®, ¢¥àå, 梥â ä®­ , 梥â à ¬ª¨, ¥á«¨ ¢ë¡à ­,
; 梥â à ¬ª¨, ¥á«¨ ­¥ ¢ë¡à ­, ¬ ªá¨¬ «ì­®¥ ª®«¨ç¥á⢮ ᨬ¢®«®¢,
; 㪠§ â¥«ì ­  ¡ãä¥à, £¤¥ ¡ã¤ãâ åà ­¨âáï ᨬ¢®«ë. ãä¥à ¤®«¦¥­
; ®ª ­ç¨¢ âìáï ­ã«¥¬, ­ ¯à¨¬¥à ¥á«¨ ¬ ªá¨¬ «ì­®¥ ª®«¨ç¥á⢮ 255:
50,26 → 41,20
macro use_edit_box
{
edit_box:
ed_width equ [edi] ;è¨à¨­  ª®¬¯®­¥­â 
ed_left equ [edi+4] ;¯®«®¦¥­¨¥ ¯® ®á¨ å
ed_top equ [edi+8] ;¯®«®¦¥­¨¥ ¯® ®á¨ ã
ed_color equ [edi+12] ;梥â ä®­  ª®¬¯®­¥­â 
ed_focus_border_color equ [edi+16] ;梥â à ¬ª¨ ª®¬¯®­¥­â 
ed_blur_border_color equ [edi+20] ;梥⠭¥  ªâ¨¢­®£® ª®¬¯®­¥­â 
ed_text_color equ [edi+24] ;梥â ⥪áâ 
ed_max equ [edi+28] ;ª®«-¢® ᨬ¢®«®¢ ª®â®àë¥ ¬®¦­® ¬ ªá¨¬ «ì­® ¢¢¥áâ¨
ed_text equ [edi+32] ;㪠§ â¥«ì ­  ¡ãä¥à
ed_flags equ [edi+36] ;ä« £¨
ed_size equ [edi+38] ;ª®«-¢® ᨬ¢®«®¢
ed_pos equ [edi+42] ;¯®§¨æ¨ï ªãàá®à 
ed_offset equ [edi+46] ;ᬥ饭¨¥
cl_curs_x equ [edi+50] ;¯à¥¤ë¤ã饥 ª®®à¤¨­ â  ªãàá®à  ¯® å
cl_curs_y equ [edi+54] ;¯à¥¤ë¤ã饥 ª®®à¤¨­ â  ªãàá®à  ¯® ã
ed_shift_pos equ [edi+58]
ed_width equ [edi]
ed_left equ [edi+2]
ed_top equ [edi+4]
ed_color equ [edi+6]
ed_focus_border_color equ [edi+10]
ed_blur_border_color equ [edi+14]
ed_text_color equ [edi+18]
ed_flags equ [edi+22]
ed_max equ [edi+24]
ed_size equ [edi+26]
ed_pos equ [edi+28]
ed_offset equ [edi+30]
ed_text equ [edi+32]
ed_height=14 ; ¢ëá®â 
shift_color=0x6a9480
ed_insert=10000b
ed_insert_cl=1111111111101111b
;==========================================================
;=== ¯à®æ¥¤ãà  ¯à®à¨á®¢ª¨ =================================
;==========================================================
76,17 → 61,18
.draw:
pusha
;--- à¨á㥬 à ¬ªã ---
call .draw_border ; ”ã­ªæ¨ï áâ ¡¨«ì­ 
call .draw_border
 
.draw_bg_cursor_text:
;--- ¨§¬¥­ï¥¬ ᬥ饭¨¥, ¥á«¨ ­ ¤® ---
call .check_offset ;¢ëç¨á«¥­¨¥ ¯®§¨æ¨¨ ªãàá®à  áâ ¡¨«ì­ 
call .check_offset
;--- à¨á㥬 ¢­ãâ७­îî ®¡« áâì ---
call .draw_bg ;­ à¨á®¢ âì ¯àאַ㣮«ì­¨ª à ¡®ç¥© ®¡« áâ¨
call .draw_bg
.draw_cursor_text:
;--- à¨á㥬 ªãàá®à ---
;--- ¬®¦¥â ¥£® ­¥ ­ ¤® à¨á®¢ âì ----
test word ed_flags,ed_focus
je @f
bt word ed_flags,1
jnc @f
call .draw_cursor
@@:
call .draw_text
93,93 → 79,80
popa
ret
 
;.str:
; mov ecx,0x0a ;§ ¤ ¥âáï á¨á⥬  áç¨á«¥­¨ï ¨§¬¥­ïîâáï ॣ¨áâàë ebx,eax,ecx,edx ¢å®¤­ë¥ ¯ à ¬¥âàë eax - ç¨á«®
; ;¯à¥à¥¢®¤ ç¨á«  ¢ ASCII áâப㠢§®¤­ë¥ ¤ ­­ë¥ ecx=á¨á⥬  áç¨á«¥­ï edi  ¤à¥á ªã¤  § ¯¨á뢠âì, ¡ã¤¥¬ áâபã, ¯à¨ç¥¬ ª®­¥æ ¯¥à¥¬¥­­®©
; cmp eax,ecx ;áà ¢­¨âì ¥á«¨ ¢ eax ¬¥­ìè¥ ç¥¬ ¢ ecx â® ¯¥à¥©â¨ ­  @@-1 â.¥. ­  pop eax
; jb @f
; xor edx,edx ;®ç¨áâ¨âì edx
; div ecx ;à §¤¥«¨âì - ®áâ â®ª ¢ edx
; push edx ;¯®«®¦¨âì ¢ á⥪
; ;dec edi ;ᬥ饭¨¥ ­¥®¡å®¤¨¬®¥ ¤«ï § ¯¨á¨ á ª®­æ  áâப¨
; call .str;¯¥à¥©â¨ ­  á ¬ã ᥡï â.¥. ¢ë§¢ âì á ¬ã á¥¡ï ¨ â ª ¤® ⮣® ¬®¬¥­â  ¯®ª  ¢ eax ­¥ áâ ­¥â ¬¥­ìè¥ ç¥¬ ¢ ecx
; pop eax
; @@: ;cmp al,10 ;¯à®¢¥à¨âì ­¥ ¬¥­ìè¥ «¨ §­ ç¥­¨¥ ¢ al 祬 10 (¤«ï á¨á⥬ë áç¨á«¥­ï 10 ¤ ­­ ï ª®¬ ­¤  - «¨è­ ï))
; ;sbb al,$69 ;- ç¥áâ­® ¤ ­­ ï ¨­áâàãªæ¨ï ¬¥­ï § áâ ¢«ï¥â § ¤ã¬ âìáï â.¥. ï ­¥ §­ î ª ª íâ® à ¡®â ¥â
; ;das ;¯®á«¥ ¤ ­­®© ª®¬ ­¤ë ª ª ¡ë ¯à®¨á室¨â 㬥­ì襭¨¥ al ­  66h (¢ ª­¨£¥ ­ ¯¨á ­® ¤à㣮¥)
; or al,0x30 ;¤ ­­ ï ª®¬ ­¤  ª®à®ç¥ 祬 ¤¢¥ ¢ëè¥
; stosb ;§ ¯¨á âì í«¥¬¥­â ¨§ ॣ¨áâà  al ¢ ï祪㠯 ¬ï⨠es:edi
;
; ret ;¢¥à­ãâìáï ç¥­ì ¨­â¥à¥á­ë© 室 â.ª. ¯®ª  ¢ á⥪¥ åà ­¨âìáï ª®«-¢® ¢ë§®¢®¢ â® á⮫쪮 à § ¬ë ¨ ¡ã¤¥¬ ¢ë§ë¢ âìáï
 
;----------------------------------------------------------
;--- ¯à®æ¥¤ãà  ¯à®à¨á®¢ª¨ ⥪áâ  --------------------------
;----------------------------------------------------------
.draw_text:
;--- ¢ëç¨á«ï¥¬, ᪮«ìª® ¯®¬¥é ¥âáï ᨬ¢®«®¢ ---
call .get_n
;--- çâ®¡ë ¬ãá®à ­¥ à¨á®¢ âì ---
call .get_n
mov esi,ed_size
mov ebx,ed_offset
sub esi,ebx
cmp eax,esi
jae @F
mov esi,eax ;çâ®¡ë ­¥ ¢ë室¨âì §  ¯à¥¤¥«ë íªà ­ 
movsx esi,word ed_size
sub si,ed_offset
cmp ax,si
ja @f
mov si,ax
@@:
 
;--- à¨á㥬 ⥪áâ ---
@@: mov eax,4
mov ebx,ed_left
mov edx,ed_offset
add ebx,2
mov eax,4
mov bx,ed_left
add bx,2
shl ebx,16
mov bx,ed_top
add ebx,4
add bx,4
mov ecx,ed_text_color
movsx edx,word ed_offset
add edx,ed_text
int 0x40
ret
 
;----------------------------------------------------------
;--- ¯à®æ¥¤ãà  ¯à®à¨á®¢ª¨ ä®­  ----------------------------
;¢å®¤­ë¥ ¤ ­­ë¥
;eax
;edx - color
;----------------------------------------------------------
.draw_bg_eax:
mov ecx,ed_top
add ecx,1
shl ecx,16
mov cx,13
mov eax,13
int 0x40
ret
 
pusha
movsx ebx,ax
lea ebx,[ebx*2+ebx]
shl bx,1
shl ebx,16
shr eax,16
lea eax,[eax*2+eax]
shl ax,1
add ax,ed_left
add ax,2
mov bx,ax
ror ebx,16
jmp @f
.draw_bg:
mov ebx,ed_left
add ebx,1
pusha
mov bx,ed_left
inc bx
shl ebx,16
mov bx,ed_width
sub ebx,1
dec bx
 
@@:
mov ecx,ed_top
mov eax,13
add ecx,1
mov cx,ed_top
inc cx
shl ecx,16
mov cx,ed_height
dec cx
 
mov edx,ed_color
mov cx,ed_height
sub ecx,1
mov eax,13
int 0x40
popa
ret
 
;----------------------------------------------------------
;--- ¯à®æ¥¤ãà  ¯®«ã祭¨ï ª®«¨ç¥á⢠ ᨬ¢®«®¢ ¢ ⥪ã饩 é¨à¨­¥ ª®¬¯®­¥­â  --------------
;--- ¯à®æ¥¤ãà  ¯®«ã祭¨ï ª®«¨ç¥á⢠ ᨬ¢®«®¢ --------------
;----------------------------------------------------------
.get_n:
mov eax,ed_width ;¯®«ã祬 è¨à¨­ã ª®¬¯®­¥­â 
xor edx,edx ;१ã«ìâ â à á¯®«®£ ¥âáï ¢ ¯ à¥ edx:eax ¢ eax - ®áâ â®ª
sub eax,4 ;¢ëç⨬ 4
mov ebx,6 ;§ £à㧬¨ ¤¥«¨â¥«ì
div ebx ;à §¬¤¥«¨¬ ­  6
xor edx,edx
movsx eax,word ed_width
sub ax,4
mov bx,6
div bx
ret
 
;----------------------------------------------------------
187,40 → 160,26
;----------------------------------------------------------
.clear_cursor:
mov edx,ed_color
test word ed_flags,ed_shift
je @f
mov edx,shift_color
@@:
mov ebx,cl_curs_x
mov ecx,cl_curs_y
jmp .draw_curs
jmp @f
.draw_cursor:
 
mov edx,ed_text_color
@@:
mov ebx,ed_pos
mov ecx,ed_offset
sub ebx,ecx
 
lea ebx,[ebx*2+ebx]
shl ebx,1
;imul ebx,6
movsx ebx,word ed_pos
sub bx,ed_offset
;lea ebx,[ebx*2+ebx]
;shl ebx,1
imul ebx,6
add bx,ed_left
mov ecx,ed_top
inc ebx
add ecx,2
mov ebp,ebx
inc bx
push bx
shl ebx,16
mov bx,bp
mov ebp,ecx
pop bx
mov cx,ed_top
add cx,2
push cx
shl ecx,16
mov cx,bp
pop cx
add cx,ed_height-4
mov cl_curs_x,ebx
mov cl_curs_y,ecx
.draw_curs:
mov eax,38
int 0x40
ret
230,547 → 189,349
;----------------------------------------------------------
.draw_border:
;--- 梥â à ¬ª¨ ---
test dword ed_flags,ed_focus
bt word ed_flags,1
mov edx,ed_focus_border_color
jne @f
jc @f
mov edx,ed_blur_border_color
@@:
;--- ᢥàåã ---
mov eax,38
mov ebx,ed_left
mov ecx,ebx
mov bx,ed_left
push bx
shl ebx,16
mov bx,cx
pop bx
add bx,ed_width
mov ecx, ed_top
mov esi,ecx
mov cx,ed_top
push cx
shl ecx,16
mov cx,si
pop cx
mov eax,38
int 0x40
 
;--- á­¨§ã ---
mov esi,ecx
add ecx,ed_height
mov ebp,ecx
push cx
add cx,ed_height
push cx
shl ecx,16
mov cx,bp
pop cx
int 0x40
;--- á«¥¢  ---
mov cx,si
mov ebp,ebx
pop cx
push bx
sub bx,ed_width
int 0x40
 
;--- á¯à ¢  ---
mov ebx,ebp
pop bx
push bx
shl ebx,16
mov bx,bp
pop bx
int 0x40
ret
 
;----------------------------------------------------------
;--- ¯à®¢¥àª , § è¥« «¨ ªãàá®à §  £à ­¨æë ¨, ¥á«¨ ­ ¤®, ---
;--- ¨§¬¥­ï¥¬ ᬥ饭¨¥ ------------------------------------
;--- eax = -1, ¥á«¨ ­¥ ¨§¬¥­¨«®áì ¨«¨ eax = 0, ¥á«¨
;--- eax = 1, ¥á«¨ ­¥ ¨§¬¥­¨«®áì ¨«¨ eax = 0, ¥á«¨
; ¨§¬¥­¨«®áì
;----------------------------------------------------------
.check_offset:
pushad
mov ecx,ed_pos
mov ebx,ed_offset
cmp ebx,ecx
ja .sub_8
 
push ebx
call .get_n ;¯®«ã稬 ª®«-¢® ᨬ¢®«®¢ ¢ ¯ à¥ ॣ¨áâ஢ edx:eax
pop ebx
mov edx,ebx
add edx,eax ;ed_offset+width editbox
cmp edx,ecx
push word ed_offset
call .get_n
;--- ¯à ¢¥¥ ---
mov bx,ed_offset
add bx,ax
cmp bx,ed_pos
ja @f
 
mov edx,ed_size
cmp edx,ecx
je .add_end
 
sub edx,ecx
cmp edx,8
jbe .add_8
add ebx,8
jmp .chk_d
 
.sub_8: cmp ecx,0
je .sub_min
cmp ebx,8
jbe .sub_min
sub ebx,8 ;ebx=ed_offset
jmp .chk_d
.sub_min:
xor ebx,ebx
jmp .chk_d
 
.add_end:sub edx,eax
mov ebx,edx
jmp .chk_d
.add_8: add ebx,edx
 
; ;----------- ®â« ¤ª 
; pushad
; mov [data_of_code],0
; mov eax,ebx;ed_offset
; mov edi,data_of_code
; call .str
; ;à¨á®¢ ­¨¥ ä®­ 
; mov eax,13
; mov ebx,178*65536+36
; mov ecx,28*65536+10
; xor edx,edx
; int 0x40
; ;¢ë¢®¤ §­ ç¥­¨ï ­  íªà ­
; mov eax,4
; mov ebx,180*65536+30
; mov ecx,0x10DDBBCC
; mov edx,data_of_code
; mov esi,4
; int 0x40
; popad
; ;----------- ®â« ¤ª 
 
.chk_d: mov ed_offset,ebx
 
call .draw_bg
mov dword [esp+28],-1
popad
ret
 
mov bx,ed_pos
mov cx,ax
shr cx,2
sub bx,cx
mov cx,ax
shr cx,1
sub bx,cx
mov ed_offset,bx
@@:
mov dword [esp+28],0
popad
;--- «¥¢¥¥ ---
mov bx,ed_offset
cmp bx,ed_pos
jb @f
mov bx,ed_pos
mov cx,ax
shr cx,2
sub bx,cx
jnc $+5
xor bx,bx
mov ed_offset,bx
@@:
xor eax,eax
pop bx
cmp bx,ed_offset
jne @f
inc eax
@@:
ret
 
 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; mov ebx,eax
; mov eax,ed_pos
; xor edx,edx
; idiv ebx
; xor edx,edx
; imul eax,ebx
; mov ed_offset,eax
; pop ebx
; cmp ax,bx
; je @f
;;;;;;;; ¤ ­­ë¥ ¤«ï § ªà è¨¢ ­¨ï ¢á¥© ¯®«®áë ¯àאַ㣮«ì­¨ª 
; mov ebx,ed_left
; inc ebx
; shl ebx,16
; mov bx,ed_width
; dec ebx
; mov edx,ed_color
; call .draw_bg_eax
; mov dword [esp+28],0
;@@: popad
; ret
;==========================================================
;=== ®¡à ¡®âª  ª« ¢¨ âãàë =================================
;==========================================================
.key:
pusha
test word ed_flags,ed_focus ; ¥á«¨ ­¥ ¢ 䮪ãá¥, ¢ë室¨¬
je .no_figure ;@f
bt word ed_flags,1 ; ¥á«¨ ­¥ ¢ 䮪ãá¥, ¢ë室¨¬
jc @f
popa
ret
@@:
 
xor ecx,ecx
push eax
inc ecx
mov eax,66
mov ebx,3
int 0x40
test al,0x03
je @f
or word ed_flags,ed_shift
 
@@: pop eax
;----------------------------------------------------------
;--- ¯à®¢¥à塞, çâ® ­ ¦ â® --------------------------------
;----------------------------------------------------------
cmp ah,8
jz .backspace
je .backspace
cmp ah,0xb6
jz .delete
je .delete
cmp ah,176
jz .left
je .left
cmp ah,179
jz .right
je .right
cmp ah,180
jz .home
je .home
cmp ah,181
jz .end
cmp ah,185 ;insert
jz .insert
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;‡ £«ã誠 ­  ®¡à ¡®âªã ª« ¢¨è ¢¢¥àå ¨ ¢­¨§
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
cmp ah,177
jz .no_figure
cmp ah,178
jz .no_figure
cmp ah,27 ;ESC - ª« ¢¨è  ))
jz .no_figure
je .end
 
;--- ­ ¦ â  ¤àã£ ï ª« ¢¨è  ---
test word ed_flags,ed_figure_only ; ⮫쪮 æ¨äàë ?
jz @f
bt word ed_flags,15 ; ⮫쪮 æ¨äàë ?
jnc @f
cmp ah,'0'
jb .no_figure
cmp ah,'9'
ja .no_figure
 
 
;¯à®¢¥àª  ­  shift
@@: test word ed_flags,ed_shift_on
je @f
;‚室­ë¥ ¤ ­­ë¥ edx=ed_size;ecx=ed_pos
push eax
mov edx,ed_size
mov ecx,ed_pos
call .del_char
;;;;
mov eax,ed_shift_pos
mov ebx,ed_size
sub ebx,eax
mov ed_size,ebx
pop eax
 
; ¯à®¢¥à塞, ­ å®¤¨âáï «¨ ªãàá®à ¢ ª®­æ¥
@@: mov ecx,ed_size
mov edx, ed_max
cmp ecx,edx
jae .no_figure
mov ebx, ed_pos
cmp ebx,edx
jl @f ; ¥á«¨ ¬¥­ìè¥ ¨«¨ à ¢­®
jmp @f
.no_figure:
popa
ret
.insert: test word ed_flags,ed_insert ;not word ed_insert
je .insert_1
and word ed_flags,ed_insert_cl
jmp .no_figure
.insert_1:
or word ed_flags,ed_insert
jmp .no_figure
.ins_v:
dec dword [ebp+38];ed_size ;processing is insert
sub esi,ecx
add esi,ebx
mov edi,esi
jmp .In_k
@@: ; ᤢ¨£ ¥¬ ᨬ¢®«ë ¯®á«¥ ªãàá®à  ¢¯à ¢®
mov ecx,ed_size
push edi eax
mov ebp,edi
mov esi,ed_text ; “ª § â¥«ì ­  ¡ãä¥à
;ã¤¥¬ à ¡®â âì á® áâப®©
add esi,ecx ;add ed_size ¤®¡ ¢¨¬ max size
mov edi,esi
@@:
; ¯à®¢¥à塞, ­ å®¤¨âáï «¨ ªãàá®à ¢ ª®­æ¥
mov bx,ed_max
cmp bx,ed_pos
jne @f ; ¥á«¨ ¤ , ¢ ª®­¥æ ¯à®æ¥¤ãàë
popa
ret
@@:
; ᤢ¨£ ¥¬ ᨬ¢®«ë ¯®á«¥ ªãàá®à  ¢¯à ¢®
mov edx,ed_text
dec edx
xor ecx,ecx
mov cx,ed_size
cmp cx,ed_pos
je @f
.mov_right_next:
mov bh,[edx+ecx]
mov [edx+ecx+1],bh
dec cx
cmp cx,ed_pos
jne .mov_right_next
@@:
 
cmp ecx,ebx ;…᫨ ã ­ á ¯®§¨æ¨ï ªãàá®à  = ⥪ã饬ã à §¬¥àã ­ ¯¥ç â ­­ëå ᨬ¢®«®¢ â.¥. ªãàá®à á⮨⠢ ª®­æ¥
je .In_k
 
test word [ebp+36],ed_insert ;IF insert is enable â.ª. edi ¨§¬¥­¥­  ¤à¥á㥬 ç¥à¥§ ebp
jne .ins_v
; ¢áâ ¢«ï¥¬ ª®¤ ª« ¢¨è¨ â㤠, £¤¥ ªãàá®à
mov edx,ed_text
movsx ebx,word ed_pos
mov [ebx+edx],ah
 
sub ecx,ebx ; ©¤¥¬ ª®«-¢® ᨬ¢®«®¢ ¤«ï ¯¥à¥¤¢¨¦¥­¨ï.
inc edi ;‘¬¥á⨬ ­ è¨ ᨬ¢®«ë ¢ ¯à ¢®
std
inc ecx
@@:
;--------
lodsb
stosb
;--------
loop @b
.In_k: cld
pop eax
mov al,ah
stosb
pop edi
; ¢áâ ¢«ï¥¬ ª®¤ ª« ¢¨è¨ â㤠, £¤¥ ªãàá®à
call .clear_cursor
; 㢥«¨ç¨¢ ¥¬ §­ ç¥­¨¥ à §¬¥à  ¨ ¯®§¨æ¨¨
inc dword ed_size
inc dword ed_pos
call .draw_all2
jmp .shift;.draw_cursor_text
inc word ed_pos
mov bx,ed_size
cmp bx,ed_max
je .draw_bg_cursor_text;.key_end_draw
inc word ed_size
 
;push word ed_offset
call .check_offset
;pop ax
;cmp ax,ed_offset
;jne .draw_bg_cursor_text
test eax,eax
jz .draw_bg_cursor_text
 
call .get_n
sub ax,ed_pos
add ax,ed_offset
inc ax
shl eax,16
mov ax,ed_pos
sub ax,ed_offset
dec ax
ror eax,16
call .draw_bg_eax
 
jmp .draw_cursor_text
 
;jmp .draw_cursor_text;.key_end_draw
 
.delete:
mov edx,ed_size
mov ecx,ed_pos
cmp edx,ecx
jg .bac_del
test word ed_flags,ed_shift_on
jne .del_bac
mov dx,ed_size
mov cx,ed_pos
;inc edx
;add ecx,900
;sub ecx,1
cmp dx,cx
jg @f
popa
ret
.bac_del:
call .del_char
jmp .draw_all
@@:
mov edx,ed_text
;dec edx
.mov_stop_next:
mov bh,[edx+ecx+1]
mov [edx+ecx],bh
inc cx
mov bx,ed_size
;dec bx
;dec bx
cmp cx,bx
jne .mov_stop_next
 
; 㬥­ìè ¥¬ §­ ç¥­¨¥ ¯®§¨æ¨¨ ¨ à §¬¥à 
;dec word ed_pos
dec word ed_size
;push word ed_offset
call .check_offset
;pop ax
;cmp ax,ed_offset
;jne .draw_bg_cursor_text
test eax,eax
jz .draw_bg_cursor_text
 
call .get_n
sub ax,ed_pos
add ax,ed_offset
shl eax,16
mov ax,ed_pos
sub ax,ed_offset
ror eax,16
call .draw_bg_eax
 
jmp .draw_cursor_text
popa
ret
 
;--- ­ ¦ â  ª« ¢¨è  backspace ---
.backspace:
; ¯à®¢¥à塞, ªãàá®à ã «¥¢®£® ªà ï ?
mov edx,ed_size
mov ecx,ed_pos
test ecx,ecx
jnz .del_bac
test word ed_flags,ed_shift_on
jne .bac_del
mov bx,ed_pos
;cmp bx,0
;jne @f; .key_end ; ¥á«¨ ¤ , ¢ ª®­¥æ
test bx,bx
jnz @f
popa
ret
.del_bac:
cmp edx,ecx ;if ed_pos=ed_size
je @f
dec ecx
call .del_char
@@: test word ed_flags,ed_shift_on
jne .bac_del
dec dword ed_pos
@@:
 
.draw_all:
push .shift;.draw_cursor_text;eax
; ᤢ¨£ ¥¬ ᨬ¢®«ë ¯®á«¥ ªãàá®à  ¢«¥¢®
mov edx,ed_text
dec edx
movsx ecx,word ed_pos
 
test word ed_flags,ed_shift_on
je @f
mov eax,ed_shift_pos
mov ebx,ed_size
sub ebx,eax
mov ed_size,ebx
jmp .draw_all2
.mov_left_next:
mov bh,[edx+ecx+1]
mov [edx+ecx],bh
inc cx
mov bx,ed_size
inc bx
cmp cx,bx
jne .mov_left_next
 
@@: dec dword ed_size
; 㬥­ìè ¥¬ §­ ç¥­¨¥ ¯®§¨æ¨¨ ¨ à §¬¥à 
dec word ed_pos
dec word ed_size
 
.draw_all2:
and word ed_flags,ed_shift_cl
call .clear_cursor
;push word ed_offset
call .check_offset
;;;;;;;;;;;;;;;
;pop ax
;cmp ax,ed_offset
;jne .draw_bg_cursor_text
test eax,eax
jne @f
call .draw_bg
ret
;;;;;;;;;;;;;;;
@@: call .get_n
push eax
mov ebx,ed_offset
add eax,ebx ;eax = w_off= ed_offset+width
mov ebx,ed_size
jz .draw_bg_cursor_text
cmp eax,ebx
jb @f
mov eax,ed_pos
sub ebx,eax
mov ecx,ed_offset
sub eax,ecx
jmp .nxt
@@: mov ebx,ed_pos
push ebx
sub eax,ebx
mov ebx,eax ;It is don't optimal
call .get_n
sub ax,ed_pos
add ax,ed_offset
shl eax,16
mov ax,ed_pos
sub ax,ed_offset
ror eax,16
call .draw_bg_eax
pop eax ;ed_pos
mov ecx,ed_offset
sub eax,ecx
jmp .draw_cursor_text
popa
ret
 
.nxt:
mov ebp,eax ;¯à®¢¥àª  ­  ¢ë室 § ªà è¨¢ ¥¬®© ®¡« á⨠§  ¯à¥¤¥«ë ¤«¨­ë
add ebp,ebx
pop edx
cmp ebp,edx
je @f
inc ebx
 
@@: mov edx,ebx
lea ebx,[eax*2+eax]
shl ebx,1
add ebx,ed_left
inc ebx
shl ebx,16
lea ecx,[edx*2+edx]
shl ecx,1
mov bx,cx
mov edx,ed_color
call .draw_bg_eax
ret
; jmp .shift
;--- ­ ¦ â  ª« ¢¨è  left ---
.left: call .sh_enable
mov ebx,ed_pos
test ebx,ebx
jz .nd_k
.left:
mov bx,ed_pos
;cmp bx,0
;je @f
test bx,bx
jz @f
call .clear_cursor
dec dword ed_pos
jmp .nd_k
dec word ed_pos
call .check_offset
test eax,eax
jz .draw_bg_cursor_text
call .draw_cursor
@@:
popa
ret
 
;--- ­ ¦ â  ª« ¢¨è  right ---
.right: call .sh_enable
mov ebx,ed_pos
cmp ebx,ed_size
je .nd_k
.right:
mov bx,ed_pos
cmp bx,ed_size
je @f
call .clear_cursor
inc dword ed_pos
jmp .nd_k
.home: call .sh_enable
mov ebx,ed_pos
test ebx,ebx
jz .nd_k
inc word ed_pos
call .check_offset
test eax,eax
jz .draw_bg_cursor_text
call .draw_cursor
@@:
popa
ret
 
.home:
mov bx,ed_pos
test bx,bx
jz @f
call .clear_cursor
xor eax,eax
mov ed_pos,eax
jmp .nd_k
mov ed_pos,ax
call .check_offset
test eax,eax
jz .draw_bg_cursor_text
call .draw_cursor
@@:
popa
ret
 
.end: call .sh_enable
mov ebx,ed_pos
cmp ebx,dword ed_size
je .nd_k
.end:
mov bx,ed_pos
cmp bx,ed_size
je @f
call .clear_cursor
mov eax,ed_size
mov ed_pos,eax
.nd_k: call .check_offset
;test eax,eax
;jz .draw_bg_cursor_text
mov ax,ed_size
mov ed_pos,ax
call .check_offset
test eax,eax
jz .draw_bg_cursor_text
call .draw_cursor
 
.shift: ;;;;;;;SHIFT
call .draw_bg ;­¥ ®¯â¨¬ «ì­®
test word ed_flags,ed_shift
je .f_exit
;;;;;;SHIFT end
mov eax,dword ed_pos
mov ebx,dword ed_shift_pos
cmp eax,ebx
jae .sh_n
push eax ;¬¥­ì襥 ¢ eax
push ebx ;¡®«ì襥
jmp .sh_n1
;¥á«¨ ¨­ ç¥
.sh_n: push ebx
push eax
.sh_n1:
; jmp .draw_all2
;;;;;;;;;;;;;;;;;;;;;;;;;
;call .clear_cursor
call .check_offset
call .get_n
mov edx,eax ;size of ed_box
; push eax
mov ecx,ed_offset
add eax,ecx ;eax = w_off= ed_offset+width
mov ebp,eax ;save
pop ebx ;¡®«ì襥
pop eax ;¬¥­ì襥
 
cmp eax,ecx ;áà ¢­¥­¨¥ á ¬¥­ì襣® á offset.
jae .f_f ;¥á«¨ ¡®«ìè¥
xor eax,eax
cmp ebp,ebx ;cà ¢­¨¬ à §¬¥à w_off á ¡®«ì訬
jb @f
sub ebx,ecx
jmp .nxt_f
@@: mov ebx,ebp
sub ebx,ecx
jmp .nxt_f
 
.f_f:
sub eax,ecx
cmp ebp,ebx ;cà ¢­¨¬ à §¬¥à w_off á ¡®«ì訬
jle @f
sub ebx,ecx
sub ebx,eax
jmp .nxt_f
@@:
mov ebx,ebp
sub ebx,ecx
sub ebx,eax
.nxt_f:
mov edx,ebx
lea ebx,[eax*2+eax]
shl ebx,1
add ebx,ed_left
inc ebx
shl ebx,16
lea ecx,[edx*2+edx]
shl ecx,1
mov bx,cx
mov edx,shift_color
call .draw_bg_eax
and word ed_flags,1111111111111011b
jmp .draw_cursor_text
;;;;;;;;;;;;;;;;;;;;;
 
.f_exit: and word ed_flags,ed_shift_cl
jmp .draw_cursor_text
 
;¯à®¢¥àª  á®áâ®ï­¨ï shift ¡ë« «¨ ®­ ­ ¦ â à ­ìè¥?
.sh_enable:
test word ed_flags,ed_shift
je @f
test word ed_flags,ed_shift_on
jne .sh_ext_en
push dword ed_pos
pop dword ed_shift_pos
or word ed_flags,ed_shift_on
popa
ret
 
@@: and word ed_flags,ed_shift_cl
.sh_ext_en: ret
 
;- 㤠«¥­¨¥ ᨬ¢®« 
;‚室­ë¥ ¤ ­­ë¥ edx=ed_size;ecx=ed_pos
.del_char:
mov esi,ed_text
test word ed_flags,ed_shift_on
je @f
mov eax,dword ed_shift_pos
mov ebx,esi
cmp eax,ecx
jae .dh_n
 
mov ed_pos,eax ;çâ® ¡ë ­¥ ¡ë«® ã¡¥£ ­¨ï ªãàá®à 
mov ebp,ecx
sub ebp,eax
add ebx,eax ;eax ¬¥­ìè¥
sub edx,ecx
add esi,ecx
 
 
mov ed_shift_pos,ebp
jmp .del_ch_sh
;¥á«¨ ¨­ ç¥
.dh_n:
mov ebp,eax
sub ebp,ecx
add ebx,ecx
sub edx,eax
add esi,eax
mov ed_shift_pos,ebp
jmp .del_ch_sh
 
@@: add esi,ecx ;㪠§ â¥«ì + ᬥ饭¨¥ ª ॠ«ì­®¬ã ¡ãää¥àã
mov ebx,esi
inc esi
cld
 
sub edx,ecx
.del_ch_sh:
 
push edi
mov edi,ebx
@@:
lodsb
stosb
dec edx
jns @b
pop edi
ret
;==========================================================
;=== ®¡à ¡®âª  ¬ëè¨ =======================================
;==========================================================
785,9 → 546,15
;----------------------------------------------------------
;--- ¯à®¢¥à塞 á®áâ®ï­¨¥ ----------------------------------
;----------------------------------------------------------
test eax,1
jnz .mouse_left_button
@@: popa
bt eax,0
jc .mouse_left_button
 
bt eax,1
jc @f
btr word ed_flags,2
@@:
 
popa
ret
 
.mouse_left_button:
794,7 → 561,10
;----------------------------------------------------------
;--- ¯®«ãç ¥¬ ª®®à¤¨­ âë ¬ëè¨ -----------------------------
;----------------------------------------------------------
bts word ed_flags,2
jc .mouse_pressed
mov eax,37
;mov ebx,1
xor ebx,ebx
inc ebx
int 0x40
801,7 → 571,7
;----------------------------------------------------------
;--- ¯à®¢¥à塞, ¯®¯ ¤ ¥â «¨ ªãàá®à ¢ edit box -------------
;----------------------------------------------------------
mov ebx,ed_top
mov bx,ed_top
cmp ax,bx
jl ._blur;.mouse_end_no_focus
 
818,6 → 588,7
add bx,ed_width
cmp ax,bx
jg ._blur;.mouse_end_no_focus
 
;--- ¨§¬¥­ï¥¬ ¯®§¨æ¨î ªãàá®à  ---
push eax
call .clear_cursor
834,29 → 605,40
@@:
mov ed_pos,ax
call .check_offset
test eax,eax
jz .draw_bg_cursor_text
call .draw_cursor
;----------------------------------------------------------
;--- ¯à®æ¥¤ãà  ãáâ ­®¢ª¨ 䮪ãá  ---------------------------
;----------------------------------------------------------
bts word ed_flags,1
jc .mouse_pressed
call .draw_cursor
call .draw_border
 
call .focus
 
.mouse_pressed:
popa
ret
 
;.mouse_end_no_focus:
; call .blur
;popa
;ret
;.blur:
;pusha
 
 
;----------------------------------------------------------
;--- ¯à®æ¥¤ãà  ãáâ ­®¢ª¨ 䮪ãá  ---------------------------
;----------------------------------------------------------
.blur:
pusha
._blur:
test word ed_flags,ed_always_focus
jne @f
btr word ed_flags,1 ; ¥á«¨ ­¥ ¢ 䮪ãá¥, ¢ë室¨¬
bt word ed_flags,14
jc @f
btr word ed_flags,1
jnc @f
call .clear_cursor
jmp .blur_end
.focus:
pusha
bts word ed_flags,1
jc @f
call .draw_cursor
.blur_end:
call .draw_border
@@:
popa
868,7 → 650,7
;.blur:
;pusha
;._blur:
;btr ed_flags,1
;btr word ed_flags,1
;jnc @f
;call .draw_border
;call .clear_cursor
879,9 → 661,7
ed_figure_only=1000000000000000b
ed_always_focus=100000000000000b
ed_focus=10b
ed_shift_on=1000b
ed_shift=100b
ed_shift_cl=1111111111110011b
ed_struc_size=36
macro draw_edit_boxes start,end
{
mov edi,start
911,26 → 691,23
add edi,ed_struc_size
loop @b
}
ed_struc_size=62
 
struc edit_box width,left,top,color,focus_border_color,\
blur_border_color,text_color,max,text,flags,size
{
.width dd width
.left dd left
.top dd top
.width dw width
.left dw left
.top dw top
.color dd color
.focus_border_color dd focus_border_color
.blur_border_color dd blur_border_color
.text_color dd text_color
.max dd max
.flags dw flags+0
.max dw max
.size dw size+0
.pos dw 0
.offset dw 0
.text dd text
.flags dw flags+0
.size dd size+0
.pos dd 0
.offset dd 0
.cl_curs_x dd 0
.cl_curs_y dd 0
.shift dd 0
}
 
macro edit_boxes_set_sys_color start,end,color_table
/programs/system/run/trunk/macros.inc
1,6 → 1,13
;--- ¤à㣨¥ ¬ ªà®áë ---
include 'editbox.inc'
include 'txtbut.inc'
;include 'gp.inc'
;include 'label.inc'
;include 'checkbox.inc'
;include 'file_sys.inc'
;include 'textwork.inc'
;include 'ini.inc'
 
include 'lang.inc'
 
;--- § £®«®¢®ª ---
/programs/system/run/trunk/run.asm
156,10 → 156,10
shl ebx,15
mov bx,window_x
mov edx,[sc.work]
or edx,0xb3000000
or edx,0x03000000
xor eax,eax
mov esi,[sc.grab_text]
mov edi,hed
xor esi,esi
xor edi,edi
int 0x40
 
get_procinfo app
166,13 → 166,14
 
mov ax,[app.width]
sub ax,20
mov [input_fn.width],eax
mov [input_fn.width],ax
mov [run_but.width],ax
 
mov ebx,10000
mov bx,5
shl ebx,16
mov bx,ax
add bx,10
mov cx,47
add bx,15
mov cx,70
push cx
shl ecx,16
pop cx
189,8 → 190,8
ret
 
draw_status:
mov ebx,5*65536+(window_x-5-10)
mov ecx,(window_y-39)*65536+12
mov ebx,5*65536+(window_x-5-5)
mov ecx,(window_y-16)*65536+12
mov edx,[sc.work]
mov eax,13
int 0x40
204,18 → 205,18
jmp @b
@@:
mov eax,4
mov ebx,6*65536+(window_y-37)
mov ebx,10*65536+(window_y-14)
mov ecx,[sc.work_text]
int 0x40
ret
 
run_but txt_button 0,5,15,30,2,0,0,run_but_text,
run_but txt_button 0,10,15,50,2,0,0,run_but_text,
if lang eq ru
run_but_text db '‡€“‘’ˆ’œ',0
else
run_but_text db 'RUN',0
end if
input_fn edit_box 0,5,10,0xffffff,0,0xaaaaaa,0,511,fn,ed_focus+\
input_fn edit_box 0,10,30,0xffffff,0,0xaaaaaa,0,511,fn,ed_focus+\
ed_always_focus
 
if lang eq ru
240,11 → 241,6
many_processes db 'Too many processes',0 ; 32
end if
 
if lang eq ru
hed db 'RUN ®â ¯¥à¢®£® ”¥¢à «ï 2007 £®¤ ',0
else
hed db 'RUN of the first of FEBRUARY 2007 year',0
end if
status dd hello
 
file_info:
/programs/system/run/trunk/run.txt
1,6 → 1,3
<Lrz> 01.02.2007 „®¡ ¢¨« ¬®¤¥à­¨§¨à®¢ ­­ë© ª®¬¯®­¥­â edit_box,
ã«ãç訫 ¨ ¯¥à¥¯¨á « ç áâì ª®¤ .
 
RUN - § ¯ã᪠«ª  ¯à®£à ¬¬ ¢ Š®«¨¡à¨Ž‘ ç¥à¥§ 70-î äã­ªæ¨î.
 
‡ ¯ã᪠¯à®£à ¬¬