Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 281 → Rev 282

/programs/develop/examples/editbox/trunk/EDITBOX.INC
1,3 → 1,4
; <Lrz> 19.01.2007 ॠ«¨§®¢ « ¢ë¤¥«¥­¨¥ ⥪áâ  ¯® shift
; <Lrz> 12.12.2006 ॠ«¨§®¢ « ¯®¤¤¥à¦ªã ª­®¯ª¨ insert ¨ ᥣ®¤ï ª®¬¯®­¥­â ¯®ç⨠ࠡ®â ¥â!!!!
; <Lrz> 07.12.2006 ¯à®¤®«¦ ¥âáï à ¡®â  ­ ¤ ¯¥à¥à ¡®âª®© ª®¬¯®­¥­â ,¨§¬¥­¥­¨ï¬ ¯®¤¢¥à£«¨áì ¬­®£¨¥ ä㭪樨, ¯¥à¥à ¡®â ­ ¢ë¢®¤ ⥪áâ ,   â ª  ¦¥  «£®à¨â¬ ¢­¥á¥­¨ï ᨬ¢®«®¢.
; <Lrz> 03.09.2006 ¯® ¢®§¬®¦­®á⨠®âª § «áï ®â 16 ¡¨â­®©  à¨ä¬¥â¨ª¨, ¤®¡ ¢¨« ­®¢ë¥ ¡ £¨
52,16 → 53,18
ed_focus_border_color equ [edi+16] ;梥â à ¬ª¨ ª®¬¯®­¥­â 
ed_blur_border_color equ [edi+20] ;梥⠭¥  ªâ¨¢­®£® ª®¬¯®­¥­â 
ed_text_color equ [edi+24] ;梥â ⥪áâ 
ed_flags equ [edi+28] ;ä« £¨
ed_max equ [edi+32] ;ª®«-¢® ᨬ¢®«®¢ ª®â®àë¥ ¬®¦­® ¬ ªá¨¬ «ì­® ¢¢¥áâ¨
ed_size equ [edi+36] ;ª®«-¢® ᨬ¢®«®¢
ed_pos equ [edi+40] ;¯®§¨æ¨ï ªãàá®à 
ed_offset equ [edi+44] ;ᬥ饭¨¥
ed_text equ [edi+48] ;㪠§ â¥«ì ­  ¡ãä¥à
cl_curs_x equ [edi+52] ;¯à¥¤ë¤ã饥 ª®®à¤¨­ â  ªãàá®à  ¯® å
cl_curs_y equ [edi+56] ;¯à¥¤ë¤ã饥 ª®®à¤¨­ â  ªãàá®à  ¯® ã
ed_insert equ [edi+60] ;word
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_insert equ [edi+58] ;word
ed_shift_pos equ [edi+60]
ed_height=14 ; ¢ëá®â 
shift_color=0x6a9480
;==========================================================
;=== ¯à®æ¥¤ãà  ¯à®à¨á®¢ª¨ =================================
;==========================================================
77,7 → 80,7
.draw_cursor_text:
;--- à¨á㥬 ªãàá®à ---
;--- ¬®¦¥â ¥£® ­¥ ­ ¤® à¨á®¢ âì ----
test dword ed_flags,1
test word ed_flags,ed_focus
je @f
call .draw_cursor
@@:
85,6 → 88,25
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 ;¢¥à­ãâìáï ç¥­ì ¨­â¥à¥á­ë© 室 â.ª. ¯®ª  ¢ á⥪¥ åà ­¨âìáï ª®«-¢® ¢ë§®¢®¢ â® á⮫쪮 à § ¬ë ¨ ¡ã¤¥¬ ¢ë§ë¢ âìáï
 
;----------------------------------------------------------
;--- ¯à®æ¥¤ãà  ¯à®à¨á®¢ª¨ ⥪áâ  --------------------------
;----------------------------------------------------------
116,22 → 138,22
;eax
;----------------------------------------------------------
.draw_bg_eax:
pusha
;pusha
mov ecx,ed_top
add ecx,1
shl ecx,16
mov cx,13
; sub ecx,1
 
mov edx,ed_color
mov edx,[esp+4] ;color
; mov edx,ed_color
mov eax,13
int 0x40
popa
ret
;popa
ret 4
 
jmp @f
.draw_bg:
pusha
;pusha
mov ebx,ed_left
add ebx,1
shl ebx,16
148,7 → 170,7
mov edx,ed_color
mov eax,13
int 0x40
popa
;popa
ret
 
;----------------------------------------------------------
167,10 → 189,15
;----------------------------------------------------------
.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
.draw_cursor:
 
mov edx,ed_text_color
@@:
mov ebx,ed_pos
207,7 → 234,7
;----------------------------------------------------------
.draw_border:
;--- 梥â à ¬ª¨ ---
test dword ed_flags,1
test dword ed_flags,ed_focus
mov edx,ed_focus_border_color
jne @f
mov edx,ed_blur_border_color
271,6 → 298,7
shl ebx,16
mov bx,ed_width
dec ebx
push dword ed_color
call .draw_bg_eax
mov dword [esp+28],0
@@: popad
280,8 → 308,20
;==========================================================
.key:
pusha
test dword ed_flags,1 ; ¥á«¨ ­¥ ¢ 䮪ãá¥, ¢ë室¨¬
test word ed_flags,ed_focus ; ¥á«¨ ­¥ ¢ 䮪ãá¥, ¢ë室¨¬
je .no_figure ;@f
 
push eax
mov ecx,1
mov eax,66
mov ebx,3
int 0x40
xor ebx,ebx
test al,0x03
je @f
or word ed_flags,ed_shift
 
@@: pop eax
;----------------------------------------------------------
;--- ¯à®¢¥à塞, çâ® ­ ¦ â® --------------------------------
;----------------------------------------------------------
324,6 → 364,7
popa
ret
.insert: not word ed_insert
 
jmp .no_figure
.ins_v:
pop eax edi
366,10 → 407,16
; ¢áâ ¢«ï¥¬ ª®¤ ª« ¢¨è¨ â㤠, £¤¥ ªãàá®à
; 㢥«¨ç¨¢ ¥¬ §­ ç¥­¨¥ à §¬¥à  ¨ ¯®§¨æ¨¨
inc dword ed_size
 
push dword ed_pos
push dword ed_size
; push .return
call .draw_all2
inc dword ed_pos
;.return:
jmp .draw_cursor_text
.delete:
 
mov edx,ed_size
mov ecx,ed_pos
 
399,7 → 446,8
dec dword ed_pos
 
.draw_all:
; mov eax,.draw_cursor_text
push dword ed_pos
push dword ed_size
push .draw_cursor_text;eax
dec dword ed_size
.draw_all2:
409,19 → 457,19
push eax
mov ebx,ed_offset
add eax,ebx ;eax = w_off= ed_offset+width
mov ebx,ed_size
mov ebx,[esp+8] ;ed_size
cmp eax,ebx
jb @f
mov eax,ed_pos
mov eax,[esp+12] ; ed_pos
sub ebx,eax
mov ecx,ed_offset
sub eax,ecx
jmp .nxt
@@: mov ebx,ed_pos
@@: mov ebx,[esp+12];ed_pos
push ebx
sub eax,ebx
mov ebx,eax ;don't optimal
mov ebx,eax ;It is don't optimal
pop eax ;ed_pos
mov ecx,ed_offset
444,11 → 492,18
lea ecx,[edx*2+edx]
shl ecx,1
mov bx,cx
push dword ed_color
call .draw_bg_eax
ret
ret 8
;--- ­ ¦ â  ª« ¢¨è  left ---
.left:
mov ebx,ed_pos
.left: test word ed_flags,ed_shift
je @f
test word ed_flags,ed_shift_on
jne @f
push dword ed_pos
pop dword ed_shift_pos
or word ed_flags,ed_shift_on
@@: mov ebx,ed_pos
test ebx,ebx
jz .nd_k
call .clear_cursor
456,7 → 511,14
jmp .nd_k
;--- ­ ¦ â  ª« ¢¨è  right ---
.right:
mov ebx,ed_pos
test word ed_flags,ed_shift
je @f
test word ed_flags,ed_shift_on
jne @f
push dword ed_pos
pop dword ed_shift_pos
or word ed_flags,ed_shift_on
@@: mov ebx,ed_pos
cmp ebx,ed_size
je .nd_k
call .clear_cursor
463,7 → 525,11
inc dword ed_pos
jmp .nd_k
.home:
mov ebx,ed_pos
; test word ed_flags,ed_shift
; je @f
; push dword ed_pos
; pop dword ed_shift_pos
@@: mov ebx,ed_pos
test ebx,ebx
jz .nd_k
call .clear_cursor
472,7 → 538,11
jmp .nd_k
 
.end:
mov ebx,ed_pos
; test word ed_flags,ed_shift
; je @f
; push dword ed_pos
; pop dword ed_shift_pos
@@: mov ebx,ed_pos
cmp ebx,dword ed_size
je @f
call .clear_cursor
479,10 → 549,114
mov eax,ed_size
mov ed_pos,eax
.nd_k: call .check_offset
test eax,eax
jz .draw_bg_cursor_text
;test eax,eax
;jz .draw_bg_cursor_text
call .draw_cursor
 
.shift: ;;;;;;;SHIFT
;----------- ®â« ¤ª 
pushad
mov [data_of_code],0
mov ax,word ed_flags
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
;----------- ®â« ¤ª 
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 ebp,eax ;¯à®¢¥àª  ­  ¢ë室 § ªà è¨¢ ¥¬®© ®¡« á⨠§  ¯à¥¤¥«ë ¤«¨­ë
; add ebp,ebx
; pop edx
; cmp ebp,edx
; je .ff
; inc ebx
 
.ff: 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 ebp,ed_color
; not ebp
push dword shift_color
call .draw_bg_eax
; pop edx
; or word ed_flags,ed_shift
and word ed_flags,1111111111111011b
jmp .draw_cursor_text
;;;;;;;;;;;;;;;;;;;;;
 
.f_exit: and word ed_flags,ed_shift_cl
jmp .draw_cursor_text
@@:
popa
ret
;- 㤠«¥­¨¥ ᨬ¢®« 
522,9 → 696,6
;----------------------------------------------------------
test eax,1
jnz .mouse_left_button
; or eax,1
; jc @f
; btr dword ed_flags,2
@@: popa
ret
 
572,10 → 743,7
@@:
mov ed_pos,ax
call .check_offset
; test eax,eax
; jz .draw_bg_cursor_text
call .draw_cursor
 
call .focus
 
.mouse_pressed:
591,13 → 759,13
.blur:
pusha
._blur:
btr dword ed_flags,0
btr dword ed_flags,1
jnc @f
call .clear_cursor
jmp .blur_end
.focus:
pusha
bts dword ed_flags,0
bts dword ed_flags,1
jc @f
call .draw_cursor
.blur_end:
622,6 → 790,9
}
ed_figure_only=1000000000000000b
ed_focus=10b
ed_shift_on=1000b
ed_shift=100b
ed_shift_cl=0011b
macro draw_edit_boxes start,end
{
mov edi,start
651,7 → 822,7
add edi,ed_struc_size
loop @b
}
ed_struc_size=62
ed_struc_size=64
struc edit_box width,left,top,color,focus_border_color,\
blur_border_color,text_color,max,text,flags,size
{
662,15 → 833,16
.focus_border_color dd focus_border_color
.blur_border_color dd blur_border_color
.text_color dd text_color
.flags dd flags+0
.max dd max
.text dd text
.flags dw flags+0
.size dd size+0
.pos dd 0
.offset dd 0
.text dd text
.cl_curs_x dd 0
.cl_curs_y dd 0
.insert dw 0
.shift dd 0
}
 
macro edit_boxes_set_sys_color start,end,color_table