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

View File

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

View File

@ -101,7 +101,7 @@ draw_window: ;
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
;DATA ¤ ­­ë¥ ;DATA ¤ ­­ë¥
editboxes: 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 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 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 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_code dd 0
data_of_code1 dd 0 data_of_code1 dd 0
ed_buffer: ed_buffer:
.1: rb 513;512;256 .1: rb 101;512;256
.2: rb 100 .2: rb 100
.3: rb 10 .3: rb 10
.4: rb 2 .4: rb 2
;text_b: db 'Š®«-¢® ᨬ¢®«®¢' ;text_b: db 'Š®«-¢® ᨬ¢®«®¢'
;buffer: dd 0 ;buffer: dd 0
buffer_end: 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: i_end1:
rb 2048 rb 2048
i_end: i_end: