2015-07-17 20:34:50 +02:00
|
|
|
|
|
2014-01-19 20:24:16 +01:00
|
|
|
|
put_to_clipboard:
|
|
|
|
|
mov edi,[clipboard_buf]
|
|
|
|
|
test edi,edi
|
|
|
|
|
jz .end
|
2015-07-17 20:34:50 +02:00
|
|
|
|
add edi,12
|
2014-01-19 20:24:16 +01:00
|
|
|
|
mov esi,[copy_buf]
|
2015-07-17 20:34:50 +02:00
|
|
|
|
mov edx,[copy_count]
|
|
|
|
|
mov ax,0x0a0d ; End of String
|
2014-01-19 20:24:16 +01:00
|
|
|
|
cld
|
2015-07-17 20:34:50 +02:00
|
|
|
|
@@: ; convert format from Tinypad<61>to clipboard
|
|
|
|
|
mov ecx,[esi]
|
|
|
|
|
add esi,sizeof.EDITOR_LINE_DATA
|
|
|
|
|
rep movsb
|
2014-01-19 20:24:16 +01:00
|
|
|
|
stosw
|
2015-07-17 20:34:50 +02:00
|
|
|
|
dec edx
|
2014-01-19 20:24:16 +01:00
|
|
|
|
jnz @b
|
|
|
|
|
|
2015-07-17 20:34:50 +02:00
|
|
|
|
sub edi,2 ; delete last EoS
|
2014-01-19 20:24:16 +01:00
|
|
|
|
xor eax,eax
|
|
|
|
|
stosb
|
2015-07-17 20:34:50 +02:00
|
|
|
|
; build the clipboard slot header
|
2014-01-19 20:24:16 +01:00
|
|
|
|
mov esi,[clipboard_buf]
|
|
|
|
|
sub edi,esi
|
2017-09-13 12:55:55 +02:00
|
|
|
|
dec edi
|
2015-07-17 20:34:50 +02:00
|
|
|
|
mov [esi],edi ; clipboard area size
|
2014-01-19 20:24:16 +01:00
|
|
|
|
xor eax,eax
|
2015-07-17 20:34:50 +02:00
|
|
|
|
mov [esi+4],eax ; type 'text'
|
2014-01-19 20:24:16 +01:00
|
|
|
|
inc eax
|
|
|
|
|
mov [esi+8],eax ; cp866 text encoding
|
|
|
|
|
; put slot to the kernel clipboard
|
|
|
|
|
mov edx,[clipboard_buf]
|
|
|
|
|
mov ecx,[edx]
|
|
|
|
|
mcall 54,2
|
2015-07-17 20:34:50 +02:00
|
|
|
|
stdcall mem.Free,[clipboard_buf]
|
|
|
|
|
stdcall mem.Free,[copy_buf]
|
2014-01-19 20:24:16 +01:00
|
|
|
|
xor eax,eax
|
2015-07-17 20:34:50 +02:00
|
|
|
|
mov [copy_buf],eax
|
2014-01-19 20:24:16 +01:00
|
|
|
|
mov [copy_size],eax
|
2015-07-17 20:34:50 +02:00
|
|
|
|
mov [copy_count],eax
|
|
|
|
|
mov [clipboard_buf],eax
|
2014-01-19 20:24:16 +01:00
|
|
|
|
.end:
|
|
|
|
|
ret
|
2015-07-17 20:34:50 +02:00
|
|
|
|
;---------------------------------------------------------------
|
2014-01-19 20:24:16 +01:00
|
|
|
|
get_from_clipboard:
|
2015-07-17 20:34:50 +02:00
|
|
|
|
mov [copy_size],0
|
2014-01-19 20:24:16 +01:00
|
|
|
|
pushad
|
|
|
|
|
mcall 54,0
|
|
|
|
|
test eax,eax
|
2015-07-17 20:34:50 +02:00
|
|
|
|
jz .exit ; no slots of clipboard
|
2014-01-19 20:24:16 +01:00
|
|
|
|
inc eax
|
2015-07-17 20:34:50 +02:00
|
|
|
|
jz .exit ; main list area not found
|
2014-01-19 20:24:16 +01:00
|
|
|
|
sub eax,2
|
|
|
|
|
mov ecx,eax
|
|
|
|
|
mcall 54,1
|
|
|
|
|
inc eax
|
2015-07-17 20:34:50 +02:00
|
|
|
|
jz .exit ; main list area not found
|
2014-01-19 20:24:16 +01:00
|
|
|
|
sub eax,2
|
2015-07-17 20:34:50 +02:00
|
|
|
|
jz .exit ; error
|
2014-01-19 20:24:16 +01:00
|
|
|
|
inc eax
|
|
|
|
|
mov [clipboard_buf],eax
|
|
|
|
|
; check contents of container
|
|
|
|
|
mov ebx,[eax+4]
|
|
|
|
|
test ebx,ebx
|
2015-07-17 20:34:50 +02:00
|
|
|
|
jnz .freeMemory ; not text
|
2014-01-19 20:24:16 +01:00
|
|
|
|
mov ebx,[eax+8]
|
2015-07-17 20:34:50 +02:00
|
|
|
|
dec ebx
|
|
|
|
|
jnz .freeMemory ; not cp866
|
|
|
|
|
mov edi,[clipboard_buf]
|
|
|
|
|
mov al, 10
|
|
|
|
|
mov ecx,[edi]
|
|
|
|
|
add edi,12
|
|
|
|
|
sub ecx,12
|
|
|
|
|
jbe .freeMemory
|
|
|
|
|
cmp byte[edi],0
|
|
|
|
|
jz .freeMemory
|
|
|
|
|
@@:
|
|
|
|
|
dec ecx
|
|
|
|
|
cmp byte[edi+ecx],0
|
|
|
|
|
jz @b
|
|
|
|
|
inc ecx
|
|
|
|
|
push ecx
|
|
|
|
|
cld
|
|
|
|
|
@@: ; count strings
|
|
|
|
|
repnz scasb
|
|
|
|
|
inc ebx
|
|
|
|
|
test ecx,ecx
|
|
|
|
|
jnz @b
|
|
|
|
|
dec edi
|
|
|
|
|
cmp byte[edi],10
|
|
|
|
|
jnz @f
|
|
|
|
|
inc ebx
|
|
|
|
|
@@:
|
|
|
|
|
mov [copy_count],ebx
|
|
|
|
|
lea eax,[ebx*4+ebx+2]
|
|
|
|
|
add eax,[esp]
|
|
|
|
|
stdcall mem.Alloc,eax
|
|
|
|
|
mov [copy_buf],eax
|
|
|
|
|
mov esi,eax
|
|
|
|
|
mov edi,[clipboard_buf]
|
|
|
|
|
add edi,12
|
|
|
|
|
pop ecx
|
|
|
|
|
mov ebx,ecx
|
|
|
|
|
mov al, 10
|
|
|
|
|
.stringSize: ; convert format from clipboard to Tinypad
|
|
|
|
|
repnz scasb
|
|
|
|
|
sub ebx,ecx
|
|
|
|
|
mov edx,edi
|
|
|
|
|
sub edi,ebx
|
|
|
|
|
dec ebx
|
|
|
|
|
test ecx,ecx
|
|
|
|
|
jnz .stringEnd
|
|
|
|
|
.lastString:
|
|
|
|
|
cmp byte[edi+ebx],10
|
|
|
|
|
jz .stringEnd
|
|
|
|
|
cmp byte[edi+ebx],0
|
|
|
|
|
jnz @f
|
|
|
|
|
dec ebx
|
|
|
|
|
jmp .lastString
|
|
|
|
|
.stringEnd:
|
|
|
|
|
dec ebx
|
|
|
|
|
cmp byte[edi+ebx],13
|
|
|
|
|
jz .copyString
|
|
|
|
|
@@:
|
|
|
|
|
inc ebx
|
|
|
|
|
.copyString:
|
|
|
|
|
mov [esi],ebx
|
|
|
|
|
add esi,sizeof.EDITOR_LINE_DATA
|
|
|
|
|
xchg ebx,ecx
|
|
|
|
|
xchg esi,edi
|
|
|
|
|
rep movsb
|
|
|
|
|
mov ecx,ebx
|
|
|
|
|
jcxz .done
|
|
|
|
|
mov esi,edi
|
|
|
|
|
mov edi,edx
|
|
|
|
|
jmp .stringSize
|
|
|
|
|
.done:
|
|
|
|
|
cmp esi,edx
|
|
|
|
|
jz @f
|
|
|
|
|
inc ecx
|
|
|
|
|
mov [edi],ecx
|
|
|
|
|
add edi,sizeof.EDITOR_LINE_DATA
|
|
|
|
|
mov byte[edi],' '
|
|
|
|
|
inc edi
|
|
|
|
|
@@:
|
|
|
|
|
sub edi,[copy_buf]
|
|
|
|
|
mov [copy_size],edi
|
|
|
|
|
.freeMemory:
|
|
|
|
|
stdcall mem.Free,[clipboard_buf]
|
|
|
|
|
mov [clipboard_buf],0
|
2014-01-19 20:24:16 +01:00
|
|
|
|
.exit:
|
|
|
|
|
popad
|
|
|
|
|
ret
|
2015-07-17 20:34:50 +02:00
|
|
|
|
;---------------------------------------------------------------
|
2014-01-19 23:06:48 +01:00
|
|
|
|
check_clipboard_for_popup:
|
|
|
|
|
pushad
|
|
|
|
|
mov [popup_valid_text],0
|
|
|
|
|
mcall 54,0
|
|
|
|
|
test eax,eax
|
2015-07-17 20:34:50 +02:00
|
|
|
|
jz .exit ; no slots of clipboard
|
2014-01-19 23:06:48 +01:00
|
|
|
|
inc eax
|
2015-07-17 20:34:50 +02:00
|
|
|
|
jz .exit ; main list area not found
|
2014-01-19 23:06:48 +01:00
|
|
|
|
sub eax,2
|
|
|
|
|
mov ecx,eax
|
|
|
|
|
mcall 54,1
|
|
|
|
|
inc eax
|
2015-07-17 20:34:50 +02:00
|
|
|
|
jz .exit ; main list area not found
|
2014-01-19 23:06:48 +01:00
|
|
|
|
sub eax,2
|
2015-07-17 20:34:50 +02:00
|
|
|
|
jz .exit ; error
|
2014-01-19 23:06:48 +01:00
|
|
|
|
inc eax
|
|
|
|
|
mov [clipboard_buf],eax
|
|
|
|
|
; check contents of container
|
|
|
|
|
mov ebx,[eax+4]
|
|
|
|
|
test ebx,ebx
|
2015-07-17 20:34:50 +02:00
|
|
|
|
jnz .freeMemory ; not text
|
2014-01-19 23:06:48 +01:00
|
|
|
|
mov ebx,[eax+8]
|
2015-07-17 20:34:50 +02:00
|
|
|
|
dec ebx
|
|
|
|
|
jnz .freeMemory ; not cp866
|
2014-01-19 23:06:48 +01:00
|
|
|
|
mov [popup_valid_text],1
|
2015-07-17 20:34:50 +02:00
|
|
|
|
.freeMemory:
|
|
|
|
|
stdcall mem.Free,[clipboard_buf]
|
|
|
|
|
mov [clipboard_buf],0
|
2014-01-19 23:06:48 +01:00
|
|
|
|
.exit:
|
|
|
|
|
popad
|
|
|
|
|
ret
|