Subversion Repositories Kolibri OS

Rev

Rev 5579 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
5579 Pathoswith 1
 
4487 mario79 2
	mov	edi,[clipboard_buf]
3
	test	edi,edi
4
	jz	.end
5
	add	edi,12
5579 Pathoswith 6
	mov	esi,[copy_buf]
4487 mario79 7
	mov	edx,[copy_count]
5579 Pathoswith 8
	mov	ax,0x0a0d	; End of String
9
	cld
4487 mario79 10
@@:	; convert format from Tinypad to clipboard
5579 Pathoswith 11
	mov	ecx,[esi]
12
	add	esi,sizeof.EDITOR_LINE_DATA
13
	rep movsb
14
	stosw
4487 mario79 15
	dec	edx
5579 Pathoswith 16
	jnz	@b
4487 mario79 17
18
 
5579 Pathoswith 19
	xor	eax,eax
4487 mario79 20
	stosb
21
; build the clipboard slot header
5579 Pathoswith 22
	mov	esi,[clipboard_buf]
4487 mario79 23
	sub	edi,esi
24
 dec edi
6975 0CodErr 25
	mov	[esi],edi	; clipboard area size
5579 Pathoswith 26
	xor	eax,eax
4487 mario79 27
	mov	[esi+4],eax	; type 'text'
5579 Pathoswith 28
	inc	eax
4487 mario79 29
	mov	[esi+8],eax	; cp866 text encoding
30
; put slot to the kernel clipboard
31
	mov	edx,[clipboard_buf]
32
	mov	ecx,[edx]
33
	mcall	54,2
34
	stdcall mem.Free,[clipboard_buf]
5579 Pathoswith 35
	stdcall mem.Free,[copy_buf]
36
	xor	eax,eax
4487 mario79 37
	mov	[copy_buf],eax
5579 Pathoswith 38
	mov	[copy_size],eax
4487 mario79 39
	mov	[copy_count],eax
5579 Pathoswith 40
	mov	[clipboard_buf],eax
41
.end:
4487 mario79 42
	ret
43
;---------------------------------------------------------------
5579 Pathoswith 44
get_from_clipboard:
4487 mario79 45
	mov	[copy_size],0
5579 Pathoswith 46
	pushad
4487 mario79 47
	mcall	54,0
48
	test	eax,eax
49
	jz	.exit	; no slots of clipboard
5579 Pathoswith 50
	inc	eax
4487 mario79 51
	jz	.exit	; main list area not found
5579 Pathoswith 52
	sub	eax,2
4487 mario79 53
	mov	ecx,eax
54
	mcall	54,1
55
	inc	eax
56
	jz	.exit	; main list area not found
5579 Pathoswith 57
	sub	eax,2
4487 mario79 58
	jz	.exit	; error
5579 Pathoswith 59
	inc	eax
4487 mario79 60
	mov	[clipboard_buf],eax
61
; check contents of container
62
	mov	ebx,[eax+4]
63
	test	ebx,ebx
64
	jnz	.freeMemory	; not text
5579 Pathoswith 65
	mov	ebx,[eax+8]
4487 mario79 66
	dec	ebx
5579 Pathoswith 67
	jnz	.freeMemory	; not cp866
68
	mov	edi,[clipboard_buf]
69
	mov	al, 10
70
	mov	ecx,[edi]
71
	add	edi,12
72
	sub	ecx,12
73
	jbe	.freeMemory
74
	cmp	byte[edi],0
75
	jz	.freeMemory
76
@@:
77
	dec	ecx
78
	cmp	byte[edi+ecx],0
79
	jz	@b
80
	inc	ecx
81
	push	ecx
82
	cld
83
@@:	; count strings
84
	repnz scasb
85
	inc	ebx
86
	test	ecx,ecx
87
	jnz	@b
88
	dec	edi
89
	cmp	byte[edi],10
90
	jnz	@f
91
	inc	ebx
92
@@:
93
	mov	[copy_count],ebx
94
	lea	eax,[ebx*4+ebx+2]
95
	add	eax,[esp]
96
	stdcall mem.Alloc,eax
97
	mov	[copy_buf],eax
98
	mov	esi,eax
99
	mov	edi,[clipboard_buf]
100
	add	edi,12
101
	pop	ecx
102
	mov	ebx,ecx
103
	mov	al, 10
104
.stringSize:	; convert format from clipboard to Tinypad
105
	repnz scasb
106
	sub	ebx,ecx
107
	mov	edx,edi
108
	sub	edi,ebx
109
	dec	ebx
110
	test	ecx,ecx
111
	jnz	.stringEnd
112
.lastString:
113
	cmp	byte[edi+ebx],10
114
	jz	.stringEnd
115
	cmp	byte[edi+ebx],0
116
	jnz	@f
117
	dec	ebx
118
	jmp	.lastString
119
.stringEnd:
120
	dec	ebx
121
	cmp	byte[edi+ebx],13
122
	jz	.copyString
123
@@:
124
	inc	ebx
125
.copyString:
126
	mov	[esi],ebx
127
	add	esi,sizeof.EDITOR_LINE_DATA
128
	xchg	ebx,ecx
129
	xchg	esi,edi
130
	rep movsb
131
	mov	ecx,ebx
132
	jcxz	.done
133
	mov	esi,edi
134
	mov	edi,edx
135
	jmp	.stringSize
136
.done:
137
	cmp	esi,edx
138
	jz	@f
139
	inc	ecx
140
	mov	[edi],ecx
141
	add	edi,sizeof.EDITOR_LINE_DATA
142
	mov	byte[edi],' '
143
	inc	edi
144
@@:
145
	sub	edi,[copy_buf]
146
	mov	[copy_size],edi
147
.freeMemory:
148
	stdcall mem.Free,[clipboard_buf]
149
	mov	[clipboard_buf],0
150
.exit:
4487 mario79 151
	popad
152
	ret
153
;---------------------------------------------------------------
5579 Pathoswith 154
check_clipboard_for_popup:
4489 mario79 155
	pushad
156
	mov	[popup_valid_text],0
157
	mcall	54,0
158
	test	eax,eax
159
	jz	.exit	; no slots of clipboard
5579 Pathoswith 160
	inc	eax
4489 mario79 161
	jz	.exit	; main list area not found
5579 Pathoswith 162
	sub	eax,2
4489 mario79 163
	mov	ecx,eax
164
	mcall	54,1
165
	inc	eax
166
	jz	.exit	; main list area not found
5579 Pathoswith 167
	sub	eax,2
4489 mario79 168
	jz	.exit	; error
5579 Pathoswith 169
	inc	eax
4489 mario79 170
	mov	[clipboard_buf],eax
171
; check contents of container
172
	mov	ebx,[eax+4]
173
	test	ebx,ebx
174
	jnz	.freeMemory	; not text
5579 Pathoswith 175
	mov	ebx,[eax+8]
4489 mario79 176
	dec	ebx
5579 Pathoswith 177
	jnz	.freeMemory	; not cp866
178
	mov	[popup_valid_text],1
4489 mario79 179
.freeMemory:
5579 Pathoswith 180
	stdcall mem.Free,[clipboard_buf]
181
	mov	[clipboard_buf],0
182
.exit:
4489 mario79 183
	popad
184
	ret
185