Subversion Repositories Kolibri OS

Rev

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