Subversion Repositories Kolibri OS

Rev

Rev 5579 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

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