modernization editbox

git-svn-id: svn://kolibrios.org@289 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Alexey Teplov ( 2007-01-22 13:50:18 +00:00
parent 6cda8bcecd
commit aef32ec859
3 changed files with 119 additions and 94 deletions

View File

@ -1,4 +1,5 @@
; <Lrz> 19.01.2007 ॠ«¨§®¢ « ¢ë¤¥«¥­¨¥ ⥪áâ  ¯® shift
; <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 ¡¨â­®©  à¨ä¬¥â¨ª¨, ¤®¡ ¢¨« ­®¢ë¥ ¡ £¨
@ -144,12 +145,12 @@ ret
shl ecx,16
mov cx,13
; sub ecx,1
mov edx,[esp+4] ;color
; pop edx ;color
; mov edx,ed_color
mov eax,13
int 0x40
;popa
ret 4
ret
jmp @f
.draw_bg:
@ -298,7 +299,7 @@ ret
shl ebx,16
mov bx,ed_width
dec ebx
push dword ed_color
mov edx,ed_color
call .draw_bg_eax
mov dword [esp+28],0
@@: popad
@ -356,7 +357,10 @@ pusha
cmp ah,'9'
ja .no_figure
@@: ; ¯à®¢¥à塞, ­ å®¤¨âáï «¨ ªãàá®à ¢ ª®­æ¥
mov ecx,ed_size
mov edx, ed_max
cmp ecx,edx
jae .no_figure
mov ebx, ed_pos
cmp ebx,edx
jl @f ; ¥á«¨ ¬¥­ìè¥ ¨«¨ à ¢­®
@ -408,24 +412,24 @@ pusha
; 㢥«¨ç¨¢ ¥¬ §­ ç¥­¨¥ à §¬¥à  ¨ ¯®§¨æ¨¨
inc dword ed_size
push dword ed_pos
push 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
jmp .shift;.draw_cursor_text
.delete:
mov edx,ed_size
mov ecx,ed_pos
cmp edx,ecx
jg @f
test word ed_flags,ed_shift_on
jne .del_bac
popa
ret
@@: call .del_char
.bac_del:
@@: call .del_char
jmp .draw_all
;--- ­ ¦ â  ª« ¢¨è  backspace ---
@ -435,21 +439,35 @@ pusha
mov ecx,ed_pos
test ecx,ecx
jnz @f
test word ed_flags,ed_shift_on
jne .bac_del
;jmp @b
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 dword ed_pos
push dword ed_size
push .draw_cursor_text;eax
dec dword ed_size
push .shift;.draw_cursor_text;eax
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
@@: dec dword ed_size
.draw_all2:
call .clear_cursor
call .check_offset
@ -457,16 +475,16 @@ pusha
push eax
mov ebx,ed_offset
add eax,ebx ;eax = w_off= ed_offset+width
mov ebx,[esp+8] ;ed_size
mov ebx,ed_size
cmp eax,ebx
jb @f
mov eax,[esp+12] ; ed_pos
mov eax,ed_pos
sub ebx,eax
mov ecx,ed_offset
sub eax,ecx
jmp .nxt
@@: mov ebx,[esp+12];ed_pos
@@: mov ebx,ed_pos
push ebx
sub eax,ebx
mov ebx,eax ;It is don't optimal
@ -492,44 +510,28 @@ pusha
lea ecx,[edx*2+edx]
shl ecx,1
mov bx,cx
push dword ed_color
mov edx,ed_color
call .draw_bg_eax
ret 8
ret
; jmp .shift
;--- ­ ¦ â  ª« ¢¨è  left ---
.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
.left: call .sh_enable
mov ebx,ed_pos
test ebx,ebx
jz .nd_k
call .clear_cursor
dec dword ed_pos
jmp .nd_k
;--- ­ ¦ â  ª« ¢¨è  right ---
.right:
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
.right: call .sh_enable
mov ebx,ed_pos
cmp ebx,ed_size
je .nd_k
call .clear_cursor
inc dword ed_pos
jmp .nd_k
.home:
; test word ed_flags,ed_shift
; je @f
; push dword ed_pos
; pop dword ed_shift_pos
@@: mov ebx,ed_pos
.home: call .sh_enable
mov ebx,ed_pos
test ebx,ebx
jz .nd_k
call .clear_cursor
@ -537,12 +539,8 @@ pusha
mov ed_pos,eax
jmp .nd_k
.end:
; test word ed_flags,ed_shift
; je @f
; push dword ed_pos
; pop dword ed_shift_pos
@@: mov ebx,ed_pos
.end: call .sh_enable
mov ebx,ed_pos
cmp ebx,dword ed_size
je @f
call .clear_cursor
@ -554,27 +552,6 @@ pusha
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
@ -628,14 +605,7 @@ pusha
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
mov edx,ebx
lea ebx,[eax*2+eax]
shl ebx,1
add ebx,ed_left
@ -644,38 +614,93 @@ pusha
lea ecx,[edx*2+edx]
shl ecx,1
mov bx,cx
; mov ebp,ed_color
; not ebp
push dword shift_color
mov edx,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
.sh_enable:
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
@@: 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
mov ecx,edx
.del_ch_sh:
;----------- ®â« ¤ª 
pushad
mov [data_of_code],0
mov eax,ed_pos;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
;----------- ®â« ¤ª 
push edi
mov edi,ebx
@@:
lodsb
stosb
dec ecx
dec edx
jns @b
pop edi

View File

@ -1,2 +1,2 @@
@fasm editbox.asm checkbox
@fasm editbox.asm editbox
@pause

View File

@ -101,7 +101,7 @@ draw_window: ;
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
;DATA ¤ ­­ë¥
editboxes:
edit1 edit_box 168,10,50,0xffffff,0,0,0,512,ed_buffer.1,ed_focus
edit1 edit_box 168,10,50,0xffffff,0,0,0,100,ed_buffer.1,ed_focus
edit2 edit_box 168,10,30,0xffffff,0,0,0,99,ed_buffer.2,ed_figure_only
edit3 edit_box 35,10,70,0xffffff,0,0,0,9,ed_buffer.3,ed_figure_only
edit4 edit_box 16,10,90,0xffffff,0,0,0,1,ed_buffer.4,ed_figure_only
@ -109,14 +109,14 @@ editboxes_end:
data_of_code dd 0
data_of_code1 dd 0
ed_buffer:
.1: rb 513;512;256
.1: rb 101;512;256
.2: rb 100
.3: rb 10
.4: rb 2
;text_b: db 'Š®«-¢® ᨬ¢®«®¢'
;buffer: dd 0
buffer_end:
hed db 'EDITBOX optimization and retype <Lrz> date 19.01.2007'
hed db 'EDITBOX optimization and retype <Lrz> date 22.01.2007'
i_end1:
rb 2048
i_end: