box_lib: ability to disable editbox. (Fixed color because of fixed editbox struct!)

git-svn-id: svn://kolibrios.org@5679 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
hidnplayr 2015-08-05 09:34:02 +00:00
parent b004b5af85
commit b022e7e98b
2 changed files with 167 additions and 160 deletions

View File

@ -33,26 +33,27 @@ ed_always_focus= 100000000000000b
ed_focus= 10b ;䮪ãá ¯à¨«®¦¥­¨ï
ed_pass= 1b ;¯®«¥ á ¯ à®«¥¬
ed_shift_on= 1000b ;¥á«¨ ­¥ ãáâ ­®¢«¥­ -§­ ç¨â ¢¯¥à¢ë¥ ­ ¦ â shift,¥á«¨ ¡ë« ãáâ ­®¢«¥­, §­ ç¨â ¬ë 㦥 çâ® - â® ¤¥« «¨ 㤥ন¢ ï shift
ed_shift_on_off=1111111111110111b
ed_shift_on_off= not (ed_shift_on)
ed_shift= 100b ;¢ª«îç ¥âáï ¯à¨ ­ ¦ â¨¨ ­  shift â.¥. ¥á«¨ ­ ¦¨¬ î
ed_shift_off= 1111111111111011b
ed_shift_off= not (ed_shift)
ed_shift_bac= 10000b ;¡¨â ¤«ï ®ç¨á⪨ ¢ë¤¥«¥­®£® shift â.¥. ¯à¨ ãáâ ­®¢ª¥ £®¢®à¨â çâ® ¥áâì ¢ë¤¥«¥­¨¥
ed_shift_bac_cl=1111111111101111b ;®ç¨á⪠ ¯à¨ 㤠«¥­¨¨ ¢ë¤¥«¥­¨ï
ed_shift_cl= 1111111111100011b
ed_shift_mcl= 1111111111111011b
ed_shift_bac_cl= not (ed_shift_bac)
ed_shift_cl= not (ed_shift or ed_shift_bac or ed_shift_on)
ed_shift_mcl= not (ed_shift)
ed_left_fl= 100000b
ed_right_fl= 1111111111011111b
ed_right_fl= not (ed_left_fl)
ed_offset_fl= 1000000b
ed_offset_cl= 1111111110111111b
ed_offset_cl= not (ed_offset_fl)
ed_insert= 10000000b
ed_insert_cl= 1111111101111111b
ed_insert_cl= not (ed_insert)
ed_mouse_on = 100000000b
ed_mous_adn_b= 100011000b
ed_mouse_on_off=1111111011111111b
ed_mouse_on_off= not (ed_mouse_on)
ed_ctrl_on = 1000000000b
ed_ctrl_off = 1111110111111111b
ed_ctrl_off = not (ed_ctrl_on)
ed_alt_on = 10000000000b
ed_alt_off = 1111101111111111b
ed_alt_off = not (ed_alt_on)
ed_disabled= 100000000000b
ed_height=14 ; ¢ëá®â 
struc edit_box width,left,top,color,shift_color,focus_border_color,\

View File

@ -8,7 +8,7 @@ macro use_editbox_draw
edit_box:
.draw:
pushad
.draw_1:
.draw_1:
;--- à¨á㥬 à ¬ªã ---
mov edi,dword [esp+36]
call .draw_border ; ”ã­ªæ¨ï áâ ¡¨«ì­ 
@ -23,7 +23,7 @@ edit_box:
;--- à¨á㥬 ªãàá®à ---
;--- ¬®¦¥â ¥£® ­¥ ­ ¤® à¨á®¢ âì ----
test word ed_flags,ed_focus
jz @f
jz @f
call .draw_cursor
@@:
call .draw_text
@ -46,27 +46,27 @@ edit_box_key:
pushad
mov edi,dword [esp+36]
test word ed_flags,ed_focus ; ¥á«¨ ­¥ ¢ 䮪ãá¥, ¢ë室¨¬
je edit_box.editbox_exit
test word ed_flags,ed_mouse_on
jne edit_box.editbox_exit
jz edit_box.editbox_exit
test word ed_flags,ed_mouse_on or ed_disabled
jnz edit_box.editbox_exit
;--------------------------------------
; this code for Win-keys, works with
; kernel SVN r.3356 or later
push eax
push ebx
mcall 66,3
test ax,0x200 ; LWin
jnz .win_key_pressed
test ax,0x400 ; RWin
jz @f
push eax
push ebx
mcall 66,3
test ax,0x200 ; LWin
jnz .win_key_pressed
test ax,0x400 ; RWin
jz @f
.win_key_pressed:
pop ebx
pop eax
jmp edit_box.editbox_exit
pop ebx
pop eax
jmp edit_box.editbox_exit
@@:
pop ebx
pop eax
pop ebx
pop eax
;--------------------------------------
;<3B>஢¥àª  ­ ¦ â shift ?
call edit_box_key.check_shift_ctrl_alt
@ -89,14 +89,14 @@ pushad
jz edit_box_key.insert
; ª®¬¡¨­ æ¨¨ Ctrl + ª« ¢¨è 
test word ed_flags,ed_ctrl_on
jz @f
jz @f
; ¯à®¢¥àª  ᪠­ª®¤ 
ror eax,8
cmp ah,46 ; Ctrl + C
je edit_box_key.ctrl_c
cmp ah,47 ; Ctrl + V
je edit_box_key.ctrl_v
rol eax,8
rol eax,8
@@:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;‡ £«ã誠 ­  ®¡à ¡®âªã ª« ¢¨è ¢¢¥àå ¨ ¢­¨§ â.¥. ¯à¨ ®¡­ à㦥­¨¨ íâ¨å ª®¤®¢ ¯à®¨á室¨â ¢ë室 ¨§ ®¡à ¡®â稪 
@ -130,6 +130,8 @@ macro use_editbox_mouse
edit_box_mouse:
pushad
mov edi,dword [esp+36]
test word ed_flags,ed_disabled
jnz edit_box.editbox_exit
;debug
;----------------------------------------------------------
;--- ¯®«ãç ¥¬ á®áâ®ï­¨¥ ª­®¯®ª ¬ëè¨ -----------------------
@ -141,9 +143,9 @@ pushad
test eax,1
jnz edit_box_mouse.mouse_left_button
and word ed_flags,ed_mouse_on_off
mov ebx,dword ed_mouse_variable
push 0
pop dword [ebx]
mov ebx,dword ed_mouse_variable
push 0
pop dword [ebx]
; mov dword [ebx],ebx
jmp edit_box.editbox_exit
.mouse_left_button:
@ -151,8 +153,8 @@ pushad
;--- ¡«®ª¨à®¢ª  ®â 䮪ãá¨à®¢ª¨ ¢ ¤àã£¨å ¡®ªá å ¯à¨ ¯®¯ ¤ ­¨¨ ­  ­¨å ªãàá®à 
;----------------------------------------------------------
mov eax,dword ed_mouse_variable
push dword [eax]
pop eax
push dword [eax]
pop eax
test eax,eax
jz @f
cmp eax,edi
@ -224,10 +226,10 @@ edit_box.draw_text:
mov ecx,ed_text_color
add ebx,4
add edx,ed_text
test word ed_flags,ed_pass
jz @f
call edit_box.draw_password
jmp .end_f
test word ed_flags,ed_pass
jz @f
call edit_box.draw_password
jmp .end_f
@@:
mcall
.end_f:
@ -237,20 +239,20 @@ txt_pass db '*',0
proc edit_box.draw_password
locals
s_len dw ? ;¤«¨­  ¢ë¢®¤¨¬®£® ⥪áâ 
s_len dw ? ;¤«¨­  ¢ë¢®¤¨¬®£® ⥪áâ 
endl
cmp esi,1
jl .end_f ;¥á«¨ áâப  ¯ãáâ ï
mov [s_len],si
xor esi,esi
inc esi
lea edx,[txt_pass]
cmp esi,1
jl .end_f ;¥á«¨ áâப  ¯ãáâ ï
mov [s_len],si
xor esi,esi
inc esi
lea edx,[txt_pass]
@@:
mcall
add ebx,6 shl 16 ;¤®¡ ¢«ï¥¬ áâ ­¤ àâ­ãî è¨à¨­ã ᨬ¢®« 
dec word[s_len]
cmp word[s_len],0
jg @b
mcall
add ebx,6 shl 16 ;¤®¡ ¢«ï¥¬ áâ ­¤ àâ­ãî è¨à¨­ã ᨬ¢®« 
dec word[s_len]
cmp word[s_len],0
jg @b
.end_f:
ret
endp
@ -265,6 +267,10 @@ edit_box.draw_bg:
mov ebx,ed_left
add ebx,1
mov edx,ed_color
test word ed_flags, ed_disabled
jz @f
mov edx, 0x00cacaca ; TODO: add new value disabled_color to editbox struct
@@:
shl ebx,16
add ebx,ed_width
sub ebx,1
@ -398,7 +404,7 @@ pushad
jmp edit_box.chk_d
edit_box.sub_8:
test ecx,ecx
test ecx,ecx
jz edit_box.sub_min
cmp ebx,8
jbe edit_box.sub_min
@ -424,25 +430,25 @@ edit_ex
align 4
proc edit_box_set_text, edit:dword, text:dword
pushad
mov edi,dword[edit]
mov ecx,ed_max
inc ecx ;ãç¨â뢠¥¬ ¡ã¤ã饥 ®¡à¥§ ­¨¥ áâப¨ ¤«ï ascii 0
mov edi,dword[text]
xor al,al
cld
repne scasb ;¯®¨áª ¢ áâப¥ edi ᨬ¢®«  al
mov ecx,edi ;ecx = text + ¬¨­. §­ ç¥­¨¥ ¨§: 1) ed_max ¨«¨ 2) ¤«¨­ë áâப¨ text
mov edi,dword[edit]
mov ecx,ed_max
inc ecx ;ãç¨â뢠¥¬ ¡ã¤ã饥 ®¡à¥§ ­¨¥ áâப¨ ¤«ï ascii 0
mov edi,dword[text]
xor al,al
cld
repne scasb ;¯®¨áª ¢ áâப¥ edi ᨬ¢®«  al
mov ecx,edi ;ecx = text + ¬¨­. §­ ç¥­¨¥ ¨§: 1) ed_max ¨«¨ 2) ¤«¨­ë áâப¨ text
mov edi,dword[edit]
mov esi,dword[text]
sub ecx,esi ;ecx = ¤«¨­  áâப¨ text (­® ­¥ ¡®«ìè¥ ç¥¬ ed_max)
dec ecx
mov ed_size,ecx ;áâ ¢¨¬ ­®¢ë© à §¬¥à áâப¨
mov ed_pos,ecx ;áâ ¢¨¬ ªãàá®à ¢ ª®­¥æ ­®¢®© áâப¨
and word ed_flags,ed_shift_cl ;á­¨¬ ¥¬ ¢ë¤¥«¥­¨¥ ¥á«¨ ®­® ¡ë«®
mov edi,ed_text
repne movsb ;ª®¯¨à®¢ ­¨¥ ⥪á⮢®© áâப¨ text ¢ edit_box
mov byte[edi],0 ;áâ ¢¨¬ ascii 0 ¢ ª®­æ¥ áâப¨
mov edi,dword[edit]
mov esi,dword[text]
sub ecx,esi ;ecx = ¤«¨­  áâப¨ text (­® ­¥ ¡®«ìè¥ ç¥¬ ed_max)
dec ecx
mov ed_size,ecx ;áâ ¢¨¬ ­®¢ë© à §¬¥à áâப¨
mov ed_pos,ecx ;áâ ¢¨¬ ªãàá®à ¢ ª®­¥æ ­®¢®© áâப¨
and word ed_flags,ed_shift_cl ;á­¨¬ ¥¬ ¢ë¤¥«¥­¨¥ ¥á«¨ ®­® ¡ë«®
mov edi,ed_text
repne movsb ;ª®¯¨à®¢ ­¨¥ ⥪á⮢®© áâப¨ text ¢ edit_box
mov byte[edi],0 ;áâ ¢¨¬ ascii 0 ¢ ª®­æ¥ áâப¨
popad
ret
endp
@ -462,7 +468,7 @@ edit_box_key.shift: ;;;;;;;SHIFT
jmp edit_box.draw_cursor_text
;;;;;;;;;;;;;;;;;;;;;
edit_box_key.f_exit:
call edit_box.check_offset
call edit_box.check_offset
and word ed_flags,ed_shift_cl
call edit_box_key.enable_null
jmp edit_box.draw_cursor_text
@ -480,7 +486,7 @@ edit_box_key.sh_cl_:
jmp edit_box_key.sh_n1
;¥á«¨ ¨­ ç¥
edit_box_key.sh_n:
push ebx
push ebx
push eax
edit_box_key.sh_n1:
call edit_box.check_offset
@ -663,7 +669,7 @@ edit_box_key.sh_home_end:
jmp edit_box_key.sh_e_end
edit_box_key.sh_exit_:
call edit_box.draw_bg
call edit_box.check_offset
call edit_box.check_offset
ret
;äã­ªæ¨ï ¢­¥á¥­¨ï 0 ¯®  ¤à¥áã ed_size+1
edit_box_key.enable_null:
@ -799,12 +805,12 @@ pusha ;
or word ed_flags,ed_shift ;ãáâ ­®¢¨¬ ä« £ Shift
@@:
and word ed_flags,ed_ctrl_off ; ®ç¨á⨬ ä« £ Ctrl
test al,1100b
test al,1100b
je @f
or word ed_flags,ed_ctrl_on ;ãáâ ­®¢¨¬ ä« £ Ctrl
@@:
and word ed_flags,ed_alt_off ; ®ç¨á⨬ ä« £ Alt
test al,110000b
test al,110000b
je @f
or word ed_flags,ed_alt_on ;ãáâ ­®¢¨¬ ä« £ Alt
@@:edit_ex
@ -938,7 +944,7 @@ popa
;--------
loop @b
edit_box_key.In_k:
cld
cld
pop eax
mov al,ah
stosb
@ -962,7 +968,7 @@ edit_box_key.insert: test word ed_flags,ed_insert ;not word ed_insert
jmp edit_box.editbox_exit
edit_box_key.ins_v:
; dec dword [ebp+48];ed_size ;processing is insert
dec dword bp_size
dec dword bp_size
sub esi,ecx
add esi,ebx
mov edi,esi
@ -1035,7 +1041,7 @@ edit_box_key.draw_all2:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;--- ­ ¦ â  ª« ¢¨è  left ---
edit_box_key.left:
mov ebx,ed_pos
mov ebx,ed_pos
test ebx,ebx
jz edit_box_key.sh_st_of
or word ed_flags,ed_left_fl
@ -1046,7 +1052,7 @@ edit_box_key.left:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;--- ­ ¦ â  ª« ¢¨è  right ---
edit_box_key.right:
mov ebx,ed_pos
mov ebx,ed_pos
cmp ebx,ed_size
je edit_box_key.sh_st_of
and word ed_flags,ed_right_fl
@ -1077,106 +1083,106 @@ edit_box_key.end:
;-----------------------------------------------------------------------------
edit_box_key.ctrl_c:
; add memory area
mov ecx,ed_size
add ecx,3*4
mcall 68,12
mov ecx,ed_size
add ecx,3*4
mcall 68,12
; building the clipboard slot header
xor ecx,ecx
mov [eax+4],ecx ; type 'text'
inc ecx
mov [eax+8],ecx ; cp866 text encoding
mov ecx,ed_size
add ecx,3*4
mov [eax],ecx
sub ecx,3*4
xor ecx,ecx
mov [eax+4],ecx ; type 'text'
inc ecx
mov [eax+8],ecx ; cp866 text encoding
mov ecx,ed_size
add ecx,3*4
mov [eax],ecx
sub ecx,3*4
; copy data
mov esi,ed_text
push edi
mov edi,eax
add edi,3*4
cld
rep movsb
pop edi
mov esi,ed_text
push edi
mov edi,eax
add edi,3*4
cld
rep movsb
pop edi
; put slot to the kernel clipboard
mov edx,eax
mov ecx,[edx]
push eax
mcall 54,2
pop ecx
mov edx,eax
mov ecx,[edx]
push eax
mcall 54,2
pop ecx
; remove unnecessary memory area
mcall 68,13
mcall 68,13
;--------------------------------------
.exit:
jmp edit_box.editbox_exit
;-----------------------------------------------------------------------------
edit_box_key.ctrl_v:
mcall 54,0
mcall 54,0
; no slots of clipboard ?
test eax,eax
jz .exit
; main list area not found ?
inc eax
test eax,eax
jz .exit
test eax,eax
jz .exit
; main list area not found ?
inc eax
test eax,eax
jz .exit
sub eax,2
mov ecx,eax
mcall 54,1
sub eax,2
mov ecx,eax
mcall 54,1
; main list area not found ?
inc eax
test eax,eax
jz .exit
inc eax
test eax,eax
jz .exit
; error ?
sub eax,2
test eax,eax
jz .exit
sub eax,2
test eax,eax
jz .exit
inc eax
inc eax
; check contents of container
mov ebx,[eax+4]
mov ebx,[eax+4]
; check for text
test ebx,ebx
jnz .no_valid_text
mov ebx,[eax+8]
test ebx,ebx
jnz .no_valid_text
mov ebx,[eax+8]
; check for cp866
cmp bl,1
jnz .no_valid_text
mov ecx,[eax]
sub ecx,3*4
cmp ecx,ed_max
jb @f
mov ecx,ed_max
cmp bl,1
jnz .no_valid_text
mov ecx,[eax]
sub ecx,3*4
cmp ecx,ed_max
jb @f
mov ecx,ed_max
@@:
mov esi,eax
add esi,3*4
mov ed_size,ecx
mov ed_pos,ecx
push eax edi
mov edi,ed_text
cld
mov esi,eax
add esi,3*4
mov ed_size,ecx
mov ed_pos,ecx
push eax edi
mov edi,ed_text
cld
@@:
lodsb
cmp al,0x0d ; EOS (end of string)
je .replace
lodsb
cmp al,0x0d ; EOS (end of string)
je .replace
cmp al,0x0a ; EOS (end of string)
jne .continue
cmp al,0x0a ; EOS (end of string)
jne .continue
.replace:
mov al,0x20 ; space
.continue:
stosb
dec ecx
jnz @b
; rep movsb
pop edi eax
;--------------------------------------
mov al,0x20 ; space
.continue:
stosb
dec ecx
jnz @b
; rep movsb
pop edi eax
;--------------------------------------
.no_valid_text:
; remove unnecessary memory area
mov ecx,eax
mcall 68,13
mov ecx,eax
mcall 68,13
;--------------------------------------
.exit:
jmp edit_box.draw_1
@ -1348,9 +1354,9 @@ edit_box_mouse._mshift:
; mov dword [mouse_flag],edi ;ãáâ ­®¢¨¬ ¨¤¥­â¨ä¨ª â®à
mov ebx,dword ed_mouse_variable
push edi
pop dword [ebx]
mov ebx,dword ed_mouse_variable
push edi
pop dword [ebx]
@ -1366,7 +1372,7 @@ edit_box_mouse._mshift:
call edit_box_key.sh_cl_
or word ed_flags,ed_mous_adn_b ;ãáâ ­®¢¨¬ ¡¨â, çâ® ¬ë ¢ë¤¥«¨«¨ +shift_on +
edit_box_mouse.m_sh:
call edit_box.draw_text
call edit_box.draw_text
call edit_box.draw_cursor
;----------------------------------------------------------
;--- ¯à®æ¥¤ãà  ãáâ ­®¢ª¨ 䮪ãá  ---------------------------