Box_Lib - Editbox support for Clipboard (Ctrl + C|V)

git-svn-id: svn://kolibrios.org@4601 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Marat Zakiyanov (Mario79) 2014-03-01 19:33:34 +00:00
parent 45668e124d
commit 2fa4df3549
3 changed files with 137 additions and 4 deletions

View File

@ -20,6 +20,7 @@ include '../../../../macros.inc'
include '../../../../proc32.inc' include '../../../../proc32.inc'
include 'bl_sys.mac' include 'bl_sys.mac'
include 'box_lib.mac' ;macro which should make life easier :) include 'box_lib.mac' ;macro which should make life easier :)
;include '../../../../debug.inc'
;----------------------------------------------------------------------------- ;-----------------------------------------------------------------------------
mem.alloc dd ? ;ôóíêöèÿ äëÿ âûäåëåíèÿ ïàìÿòè mem.alloc dd ? ;ôóíêöèÿ äëÿ âûäåëåíèÿ ïàìÿòè

View File

@ -49,6 +49,10 @@ ed_insert_cl= 1111111101111111b
ed_mouse_on = 100000000b ed_mouse_on = 100000000b
ed_mous_adn_b= 100011000b ed_mous_adn_b= 100011000b
ed_mouse_on_off=1111111011111111b ed_mouse_on_off=1111111011111111b
ed_ctrl_on = 1000000000b
ed_ctrl_off = 1111110111111111b
ed_alt_on = 10000000000b
ed_alt_off = 1111101111111111b
ed_height=14 ; ¢ëá®â  ed_height=14 ; ¢ëá®â 
struc edit_box width,left,top,color,shift_color,focus_border_color,\ struc edit_box width,left,top,color,shift_color,focus_border_color,\

View File

@ -8,6 +8,7 @@ macro use_editbox_draw
edit_box: edit_box:
.draw: .draw:
pushad pushad
.draw_1:
;--- à¨á㥬 à ¬ªã --- ;--- à¨á㥬 à ¬ªã ---
mov edi,dword [esp+36] mov edi,dword [esp+36]
call .draw_border ; ”ã­ªæ¨ï áâ ¡¨«ì­  call .draw_border ; ”ã­ªæ¨ï áâ ¡¨«ì­ 
@ -68,7 +69,7 @@ pushad
pop eax pop eax
;-------------------------------------- ;--------------------------------------
;<3B>஢¥àª  ­ ¦ â shift ? ;<3B>஢¥àª  ­ ¦ â shift ?
call edit_box_key.check_shift call edit_box_key.check_shift_ctrl_alt
;---------------------------------------------------------- ;----------------------------------------------------------
;--- ¯à®¢¥à塞, çâ® ­ ¦ â® -------------------------------- ;--- ¯à®¢¥à塞, çâ® ­ ¦ â® --------------------------------
;---------------------------------------------------------- ;----------------------------------------------------------
@ -86,6 +87,17 @@ pushad
jz edit_box_key.end jz edit_box_key.end
cmp ah,185 ;insert cmp ah,185 ;insert
jz edit_box_key.insert jz edit_box_key.insert
; ª®¬¡¨­ æ¨¨ Ctrl + ª« ¢¨è 
test word ed_flags,ed_ctrl_on
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
@@:
;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;‡ £«ã誠 ­  ®¡à ¡®âªã ª« ¢¨è ¢¢¥àå ¨ ¢­¨§ â.¥. ¯à¨ ®¡­ à㦥­¨¨ íâ¨å ª®¤®¢ ¯à®¨á室¨â ¢ë室 ¨§ ®¡à ¡®â稪  ;‡ £«ã誠 ­  ®¡à ¡®âªã ª« ¢¨è ¢¢¥àå ¨ ¢­¨§ â.¥. ¯à¨ ®¡­ à㦥­¨¨ íâ¨å ª®¤®¢ ¯à®¨á室¨â ¢ë室 ¨§ ®¡à ¡®â稪 
;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -779,12 +791,22 @@ edit_box_key.draw_rectangle:
;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;
;;<3B>஢¥àª  ­ ¦ â «¨ shift ;;<3B>஢¥àª  ­ ¦ â «¨ shift
;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;
edit_box_key.check_shift: edit_box_key.check_shift_ctrl_alt:
pusha ;á®åà ­¨¬ ¢á¥ ॣ¨áâàë pusha ;á®åà ­¨¬ ¢á¥ ॣ¨áâàë
mcall 66,3 mcall 66,3
test al,0x03 test al,11b
je @f je @f
or word ed_flags,ed_shift ;ãáâ ­®¢¨¬ ä« £ or word ed_flags,ed_shift ;ãáâ ­®¢¨¬ ä« £ Shift
@@:
and word ed_flags,ed_ctrl_off ; ®ç¨á⨬ ä« £ Ctrl
test al,1100b
je @f
or word ed_flags,ed_ctrl_on ;ãáâ ­®¢¨¬ ä« £ Ctrl
@@:
and word ed_flags,ed_alt_off ; ®ç¨á⨬ ä« £ Alt
test al,110000b
je @f
or word ed_flags,ed_alt_on ;ãáâ ­®¢¨¬ ä« £ Alt
@@:edit_ex @@:edit_ex
} }
@ -1052,6 +1074,112 @@ edit_box_key.end:
mov ed_pos,eax mov ed_pos,eax
call edit_box_key.sh_home_end call edit_box_key.sh_home_end
jmp edit_box.draw_cursor_text jmp edit_box.draw_cursor_text
;-----------------------------------------------------------------------------
edit_box_key.ctrl_c:
; add memory area
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
; copy data
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
; remove unnecessary memory area
mcall 68,13
;--------------------------------------
.exit:
jmp edit_box.editbox_exit
;-----------------------------------------------------------------------------
edit_box_key.ctrl_v:
mcall 54,0
; no slots of clipboard ?
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
; main list area not found ?
inc eax
test eax,eax
jz .exit
; error ?
sub eax,2
test eax,eax
jz .exit
inc eax
; check contents of container
mov ebx,[eax+4]
; check for text
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
@@:
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
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
;--------------------------------------
.no_valid_text:
; remove unnecessary memory area
mov ecx,eax
mcall 68,13
;--------------------------------------
.exit:
jmp edit_box.draw_1
} }
macro use_mouse_func macro use_mouse_func