Subversion Repositories Kolibri OS

Rev

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

Rev Author Line No. Line
824 mikedld 1
diff16 'tp-tbox.asm',0,$
2
 
178 heavyiron 3
virtual at ebp
4
  tbox TBOX
5
end virtual
6
 
7
tb.pos.x	db ?
8
tb.sel.x	db ?
9
tb.sel.selected db ?
10
 
617 mikedld 11
proc textbox.get_width
178 heavyiron 12
	push	ebx edx
297 mikedld 13
	movzx	eax,[tbox.width]
178 heavyiron 14
	add	eax,-6
15
	xor	edx,edx
16
	mov	ebx,6
17
	div	ebx
18
	movzx	ebx,[tbox.length]
19
	cmp	eax,ebx
20
	jle	@f
21
	mov	eax,ebx
22
    @@: pop	edx ebx
23
	ret
617 mikedld 24
endp
178 heavyiron 25
 
617 mikedld 26
proc textbox.delete_selection
178 heavyiron 27
	cmp	[tb.sel.selected],0
28
	je	.exit.2
29
	pushad
30
	movzx	ecx,[tbox.length]
31
	sub	cl,[tb.sel.x]
32
	lea	eax,[tbox.text]
33
	movzx	esi,[tb.pos.x]
34
	movzx	edi,[tb.sel.x]
35
	add	esi,eax
36
	add	edi,eax
37
	mov	eax,esi
38
	sub	eax,edi
39
	sub	[tbox.length],al
40
	cld
41
	rep	movsb
42
 
43
  .exit:
44
	mov	al,[tb.sel.x]
45
	mov	[tbox.pos.x],al
46
	mov	[tbox.sel.x],al
47
	popad
48
	clc
49
	ret
50
 
51
  .exit.2:
52
	stc
53
	ret
617 mikedld 54
endp
178 heavyiron 55
 
617 mikedld 56
proc textbox.draw ; TBOX* ebp
178 heavyiron 57
	call	textbox.get_width
58
	movzx	ebx,[tbox.pos.x]
59
	sub	bl,[tbox.ofs.x]
60
	sub	ebx,eax
61
	jle	@f
62
	mov	bl,[tbox.pos.x]
63
	sub	bl,al
64
	mov	[tbox.ofs.x],bl
65
    @@:
66
	mov	[tb.sel.selected],0
67
	mov	al,[tbox.pos.x]
68
	mov	ah,[tbox.sel.x]
69
	cmp	al,ah
70
	je	@f
71
	inc	[tb.sel.selected]
72
	ja	@f
73
	xchg	al,ah
74
    @@: mov	[tb.pos.x],al
75
	mov	[tb.sel.x],ah
76
 
297 mikedld 77
	mcall	13,dword[tbox.width],dword[tbox.height],[color_tbl.back]
259 mikedld 78
	mov	edx,[cl_3d_inset]
178 heavyiron 79
	call	draw_framerect
80
 
81
	call	textbox.get_width
82
	mov	esi,eax
83
	mov	edi,eax
84
 
85
	cmp	ebp,[focused_tb]
86
	je	@f
297 mikedld 87
	mov	ebx,dword[tbox.x-2]
88
	mov	bx,[tbox.y]
89
	movzx	eax,[tbox.height]
178 heavyiron 90
	shr	eax,1
91
	add	eax,4*65536-4
92
	add	ebx,eax
93
	lea	edx,[tbox.text]
297 mikedld 94
	mcall	4,,[color_tbl.text]
178 heavyiron 95
	ret
96
 
97
    @@: movzx	eax,[tb.pos.x]
98
	cmp	al,[tb.sel.x]
99
	je	@f
100
	sub	al,[tbox.ofs.x]
101
	jz	@f
102
	movzx	ebx,[tb.sel.x]
103
	sub	bl,[tbox.ofs.x]
104
	jge	.lp1
105
	xor	ebx,ebx
106
  .lp1: push	eax ebx
107
	sub	eax,ebx
108
	mov	ecx,edi
109
	sub	ecx,ebx
110
	cmp	eax,ecx
111
	jbe	.lp2
112
	mov	eax,ecx
113
  .lp2: imul	eax,6
114
	imul	ebx,6
297 mikedld 115
	movzx	ecx,[tbox.x]
178 heavyiron 116
	add	ecx,3
117
	add	ebx,ecx
118
	shl	ebx,16
119
	add	ebx,eax
297 mikedld 120
	movzx	ecx,[tbox.height]
178 heavyiron 121
	shr	ecx,1
297 mikedld 122
	add	cx,[tbox.y]
178 heavyiron 123
	shl	ecx,16
124
	add	ecx,-5*65536+10
297 mikedld 125
	mcall	13,,,[color_tbl.back.sel]
178 heavyiron 126
 
127
	mov	esi,[esp]
128
	lea	edx,[tbox.text]
129
	movzx	eax,[tbox.ofs.x]
130
	add	edx,eax
297 mikedld 131
	mov	ebx,dword[tbox.x-2]
132
	mov	bx,[tbox.y]
133
	movzx	eax,[tbox.height]
178 heavyiron 134
	shr	eax,1
135
	add	eax,4*65536-4
136
	add	ebx,eax
137
	mov	eax,4
138
	or	esi,esi
139
	jz	.lp3
297 mikedld 140
	mcall	,,[color_tbl.text]
178 heavyiron 141
  .lp3: sub	edi,esi
142
	jnz	.lp4
143
	add	esp,8
144
	jmp	.exit
145
  .lp4:
146
	add	edx,esi
147
	imul	esi,6*65536
148
	add	ebx,esi
149
	pop	ecx esi
150
	sub	esi,ecx
151
	cmp	esi,edi
152
	jbe	.lp5
153
	mov	esi,edi
154
  .lp5:
297 mikedld 155
	mcall	,,[color_tbl.text.sel]
178 heavyiron 156
	sub	edi,esi
157
	jz	.exit
158
	add	edx,esi
159
	imul	esi,6*65536
160
	add	ebx,esi
161
	lea	ecx,[tbox.text]
297 mikedld 162
	mcall	,,[color_tbl.text],,edi
178 heavyiron 163
	jmp	.exit
164
 
165
    @@: lea	edx,[tbox.text]
166
	movzx	eax,[tbox.ofs.x]
167
	add	edx,eax
297 mikedld 168
	mov	ebx,dword[tbox.x-2]
169
	mov	bx,[tbox.y]
170
	movzx	eax,[tbox.height]
178 heavyiron 171
	shr	eax,1
172
	add	eax,4*65536-4
173
	add	ebx,eax
174
	movzx	eax,[tbox.ofs.x]
175
	call	textbox.get_width
176
	mov	esi,eax
297 mikedld 177
	mcall	4,,[color_tbl.text]
178 heavyiron 178
 
179
  .exit:
180
	movzx	ebx,[tbox.pos.x]
181
	movzx	eax,[tbox.ofs.x]
182
	sub	ebx,eax
183
	imul	ebx,6
297 mikedld 184
	movzx	eax,[tbox.x]
178 heavyiron 185
	add	eax,3
186
	add	ebx,eax
187
	push	bx
188
	shl	ebx,16
189
	pop	bx
297 mikedld 190
	movzx	ecx,[tbox.height]
178 heavyiron 191
	shr	ecx,1
297 mikedld 192
	add	cx,[tbox.y]
178 heavyiron 193
	push	cx
194
	shl	ecx,16
195
	pop	cx
196
	add	ecx,-5*65536+4
197
	mcall	38,,,0x01000000
198
	add	ebx,0x00010001
199
	mcall
200
	ret
617 mikedld 201
endp
178 heavyiron 202
 
617 mikedld 203
proc textbox.key
178 heavyiron 204
	mov	ebp,[focused_tb]
205
	mov	esi,accel_table_textbox
206
  .acc: cmp	ebx,[esi]
207
	jne	@f
208
	call	dword[esi+4]
209
	jmp	.exit.2
210
    @@: add	esi,8
211
	cmp	byte[esi],0
212
	jne	.acc
213
 
826 mikedld 214
	test	[chr],KM_CTRLALT
178 heavyiron 215
	jnz	.exit
216
	cmp	[tbox.length],255
217
	je	.exit
218
 
826 mikedld 219
	movzx	eax,byte[chr]
178 heavyiron 220
	movzx	eax,[eax+key0]
221
	or	al,al
222
	jz	.exit
223
	mov	al,[eax+key1]
224
	cmp	[tb_casesen],0
225
	je	@f
226
	cmp	al,$60
227
	jle	@f
228
	add	al,[add_table-$60+eax]
229
    @@:
230
	call	textbox.delete_selection
231
 
232
	mov	ecx,255
233
	sub	cl,[tbox.pos.x]
234
	lea	edi,[tbox.text]
235
	add	edi,255
236
	lea	esi,[edi-1]
237
	std
238
	rep	movsb
239
	stosb
240
	cld
241
	inc	[tbox.length]
242
	call	key.tb.right
243
 
244
  .exit.2:
245
	call	textbox.draw
246
  .exit:
247
	ret
617 mikedld 248
endp
178 heavyiron 249
 
250
textbox.mouse:
251
	ret
252
 
617 mikedld 253
proc key.tb.bkspace
178 heavyiron 254
	call	textbox.delete_selection
255
	jnc	@f
256
 
257
	cmp	[tbox.pos.x],0
258
	je	@f
259
	call	key.tb.left
260
	jmp	key.tb.del.direct
261
 
262
    @@: ret
617 mikedld 263
endp
178 heavyiron 264
 
617 mikedld 265
proc key.tb.home
178 heavyiron 266
	xor	al,al
267
	mov	[tbox.pos.x],al
268
	mov	[tbox.sel.x],al
269
	mov	[tbox.ofs.x],al
270
	ret
617 mikedld 271
endp
178 heavyiron 272
 
617 mikedld 273
proc key.tb.left
178 heavyiron 274
	mov	al,[tbox.pos.x]
275
	mov	[tbox.sel.x],al
276
	dec	al
277
	js	@f
278
	mov	[tbox.pos.x],al
279
	mov	[tbox.sel.x],al
280
	cmp	[tbox.ofs.x],al
281
	jl	@f
282
	sub	[tbox.ofs.x],8
283
	jge	@f
284
	mov	[tbox.ofs.x],0
285
    @@: ret
617 mikedld 286
endp
178 heavyiron 287
 
617 mikedld 288
proc key.tb.right
178 heavyiron 289
	call	textbox.get_width
290
	mov	bl,[tbox.pos.x]
291
	mov	[tbox.sel.x],bl
292
	inc	bl
293
	cmp	bl,[tbox.length]
294
	ja	@f
295
	mov	[tbox.pos.x],bl
296
	mov	[tbox.sel.x],bl
297
	sub	bl,[tbox.ofs.x]
298
	cmp	bl,al
299
	jbe	@f
300
	inc	[tbox.ofs.x]
301
    @@: ret
617 mikedld 302
endp
178 heavyiron 303
 
617 mikedld 304
proc key.tb.end
178 heavyiron 305
	call	textbox.get_width
306
	movzx	ebx,[tbox.length]
307
	mov	[tbox.pos.x],bl
308
	mov	[tbox.sel.x],bl
309
	sub	ebx,eax
310
	jge	@f
311
	xor	bl,bl
312
    @@: mov	[tbox.ofs.x],bl
313
	ret
617 mikedld 314
endp
178 heavyiron 315
 
617 mikedld 316
proc key.tb.del
178 heavyiron 317
	call	textbox.delete_selection
318
	jnc	@f
319
  .direct:
320
	movzx	ecx,[tbox.length]
321
	sub	cl,[tbox.pos.x]
322
	jz	@f
323
	lea	eax,[tbox.text]
324
	movzx	edi,[tbox.pos.x]
325
	add	edi,eax
326
	lea	esi,[edi+1]
327
	dec	[tbox.length]
328
	cld
329
	rep	movsb
330
 
331
    @@: ret
617 mikedld 332
endp
178 heavyiron 333
 
617 mikedld 334
proc key.tb.shift_home
178 heavyiron 335
	xor	al,al
336
	mov	[tbox.pos.x],al
337
	mov	[tbox.ofs.x],al
338
	ret
617 mikedld 339
endp
178 heavyiron 340
 
617 mikedld 341
proc key.tb.shift_left
178 heavyiron 342
	mov	al,[tbox.pos.x]
343
	dec	al
344
	js	@f
345
	mov	[tbox.pos.x],al
346
	cmp	[tbox.ofs.x],al
347
	jl	@f
348
	sub	[tbox.ofs.x],8
349
	jge	@f
350
	mov	[tbox.ofs.x],0
351
    @@: ret
617 mikedld 352
endp
178 heavyiron 353
 
617 mikedld 354
proc key.tb.shift_right
178 heavyiron 355
	call	textbox.get_width
356
	mov	bl,[tbox.pos.x]
357
	inc	bl
358
	cmp	bl,[tbox.length]
359
	ja	@f
360
	mov	[tbox.pos.x],bl
361
	sub	bl,[tbox.ofs.x]
362
	cmp	bl,al
363
	jbe	@f
364
	inc	[tbox.ofs.x]
365
    @@: ret
617 mikedld 366
endp
178 heavyiron 367
 
617 mikedld 368
proc key.tb.shift_end
178 heavyiron 369
	call	textbox.get_width
370
	movzx	ebx,[tbox.length]
371
	mov	[tbox.pos.x],bl
372
	sub	ebx,eax
373
	jge	@f
374
	xor	bl,bl
375
    @@: mov	[tbox.ofs.x],bl
376
	ret
617 mikedld 377
endp