Subversion Repositories Kolibri OS

Rev

Rev 617 | Rev 987 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
824 mikedld 1
diff16 'tp-editor.asm',0,$
259 mikedld 2
 
3
;-----------------------------------------------------------------------------
617 mikedld 4
proc draw_editor ;///// DRAW EDITOR //////////////////////////////////////////
259 mikedld 5
;-----------------------------------------------------------------------------
6
 
267 mikedld 7
	mov	ebx,[cur_editor.Bounds.Left-2]
8
	mov	bx,word[cur_editor.Bounds.Right]
9
	sub	bx,word[cur_editor.Bounds.Left]
259 mikedld 10
	inc	ebx
267 mikedld 11
	mov	ecx,[cur_editor.Bounds.Top-2]
12
	mov	cx,word[cur_editor.Bounds.Bottom]
13
	sub	cx,word[cur_editor.Bounds.Top]
259 mikedld 14
	inc	ecx
15
	mov	edx,[cl_3d_inset]
16
	call	draw_framerect
280 mikedld 17
 
267 mikedld 18
	mov	[cur_editor.Gutter.Visible],0
259 mikedld 19
	test	[options],OPTS_LINENUMS
20
	jnz	@f
297 mikedld 21
	xor	eax,eax
259 mikedld 22
	jmp	.lp1
267 mikedld 23
    @@: inc	[cur_editor.Gutter.Visible]
259 mikedld 24
	mov	edi,p_info+100
297 mikedld 25
	mov	eax,[cur_editor.Lines.Count]
259 mikedld 26
	mov	ecx,10
27
	call	uint2str
28
	lea	eax,[edi-p_info-100]
29
	cmp	eax,3
30
	jae	@f
31
	mov	eax,3
32
    @@: imul	eax,6
33
	add	eax,8
297 mikedld 34
  .lp1: mov	[cur_editor.Gutter.Width],eax
259 mikedld 35
	mov	[left_ofs],eax
36
 
280 mikedld 37
	mov	eax,[cur_editor.Bounds.Right]
38
	sub	eax,[cur_editor.Bounds.Left]
39
	sub	eax,[cur_editor.Gutter.Width]
40
	sub	eax,SCRLW+LCHGW+4
41
	js	.exit
42
	cdq
43
	mov	ebx,6
44
	div	ebx
45
	mov	[columns.scr],eax
46
 
47
	mov	eax,[cur_editor.Bounds.Bottom]
48
	sub	eax,[cur_editor.Bounds.Top]
49
 
50
	sub	eax,SCRLW+3
51
	js	.exit
52
	cdq
53
	mov	ebx,LINEH
54
	div	ebx
55
	mov	[lines.scr],eax
56
 
259 mikedld 57
	call	draw_editor_gutter
58
	call	draw_editor_vscroll
59
	call	draw_editor_hscroll
60
	call	draw_editor_text
61
	call	draw_editor_caret
62
 
280 mikedld 63
  .exit:
259 mikedld 64
	ret
617 mikedld 65
endp
259 mikedld 66
 
67
;-----------------------------------------------------------------------------
617 mikedld 68
proc draw_editor_gutter ;///// DRAW EDITOR GUTTER (LEFT PANEL) ///////////////
259 mikedld 69
;-----------------------------------------------------------------------------
267 mikedld 70
	cmp	[cur_editor.Gutter.Visible],0
259 mikedld 71
	je	.exit
72
 
73
	add	esp,-4*8*2
74
 
267 mikedld 75
	mov	ebx,[cur_editor.Bounds.Left-2]
76
	mov	bx,word[cur_editor.Gutter.Width]
259 mikedld 77
	add	ebx,0x00010000
267 mikedld 78
	mov	ecx,[cur_editor.Bounds.Top-2]
79
	mov	cx,word[cur_editor.Bounds.Bottom]
80
	sub	cx,word[cur_editor.Bounds.Top]
259 mikedld 81
	add	cx,-SCRLW
82
	add	ecx,0x00010000
83
	dec	cx
84
	mcall	13,,,[cl_3d_normal]
85
 
267 mikedld 86
	add	bx,word[cur_editor.Bounds.Left]
259 mikedld 87
	push	bx
88
	shl	ebx,16
89
	pop	bx
267 mikedld 90
	add	ecx,[cur_editor.Bounds.Top]
259 mikedld 91
	mcall	38,,,[cl_3d_inset]
92
 
93
	add	ebx,-2*65536
267 mikedld 94
	mov	bx,word[cur_editor.Bounds.Top]
259 mikedld 95
	add	bx,3
96
	mov	edi,[sc.work_text]
267 mikedld 97
	mov	ecx,[cur_editor.TopLeft.Y]
259 mikedld 98
	inc	ecx
99
	mov	edx,p_info+100
100
    @@: pushad
101
	push	eax edx edi
102
	mov	eax,ecx
103
	mov	ecx,10
104
	mov	edi,edx
105
	call	uint2str
106
	mov	esi,edi
107
	pop	edi edx eax
108
	sub	esi,edx
109
	imul	eax,esi,6*65536
110
	sub	ebx,eax
111
	mcall	4,,edi
112
	popad
113
	add	ebx,LINEH
114
	inc	ecx
267 mikedld 115
	cmp	ecx,[cur_editor.Lines.Count]
259 mikedld 116
	jg	@f
117
	mov	esi,ecx
267 mikedld 118
	sub	esi,[cur_editor.TopLeft.Y]
259 mikedld 119
	cmp	esi,[lines.scr]
120
	jbe	@b
121
    @@: add	esp,4*8*2
122
 
123
  .exit:
124
	ret
617 mikedld 125
endp
259 mikedld 126
 
127
;-----------------------------------------------------------------------------
617 mikedld 128
proc draw_editor_vscroll ;///// DRAW EDITOR VERTICAL SCROLL BAR //////////////
259 mikedld 129
;-----------------------------------------------------------------------------
267 mikedld 130
	mov	ebx,[cur_editor.Bounds.Right]
259 mikedld 131
	shl	ebx,16
132
	add	ebx,(-SCRLW)*65536+SCRLW
267 mikedld 133
	mov	ecx,[cur_editor.Bounds.Top-2]
259 mikedld 134
	mov	cx,SCRLW
297 mikedld 135
	cmp	[bot_mode],0
136
	jne	@f
267 mikedld 137
	mcall	8,,,'VSL' or 0x40000000
297 mikedld 138
    @@: pushad
259 mikedld 139
	sar	ebx,16
140
	sar	ecx,16
141
	push	ebx ecx SCRLW SCRLW
142
	call	draw_3d_panel
143
	popad
144
	mov	eax,8
145
 
146
	pushad
147
	push	0x18
148
	shr	ecx,16
149
	mov	bx,cx
150
	add	ebx,(SCRLW/2-2)*65536+SCRLW/2-3
151
	mcall	4,,[sc.work_text],esp,1
152
	add	esp,4
153
	popad
154
 
267 mikedld 155
	mov	ecx,[cur_editor.Bounds.Bottom]
259 mikedld 156
	shl	ecx,16
157
	add	ecx,(-SCRLW*2)*65536+SCRLW
297 mikedld 158
	cmp	[bot_mode],0
159
	jne	@f
267 mikedld 160
	mcall	,,,'VSG' or 0x40000000
297 mikedld 161
    @@: pushad
259 mikedld 162
	sar	ebx,16
163
	sar	ecx,16
164
	push	ebx ecx SCRLW SCRLW
165
	call	draw_3d_panel
166
	popad
167
	mov	eax,8
168
 
169
	pushad
170
	push	0x19
171
	shr	ecx,16
172
	mov	bx,cx
173
	add	ebx,(SCRLW/2-2)*65536+SCRLW/2-3
174
	mcall	4,,[sc.work_text],esp,1
175
	add	esp,4
176
	popad
177
 
178
	push	ebx
267 mikedld 179
	mov	eax,[cur_editor.Lines.Count]
259 mikedld 180
	mov	ebx,[lines.scr]
267 mikedld 181
	mov	ecx,[cur_editor.TopLeft.Y]
182
	mov	edx,[cur_editor.Bounds.Bottom]
183
	sub	edx,[cur_editor.Bounds.Top]
280 mikedld 184
	add	edx,-SCRLW*3;+1
259 mikedld 185
	call	get_scroll_vars
267 mikedld 186
	mov	[cur_editor.VScroll.Top],eax
187
	mov	[cur_editor.VScroll.Size],ebx
259 mikedld 188
	pop	ebx
189
 
190
	mov	ecx,eax
267 mikedld 191
	add	ecx,[cur_editor.Bounds.Top]
259 mikedld 192
	add	ecx,SCRLW+1
193
 
194
	pushad
195
	sar	ebx,16
267 mikedld 196
	push	ebx ecx SCRLW [cur_editor.VScroll.Size]
259 mikedld 197
	dec	dword[esp]
198
	call	draw_3d_panel
199
	popad
200
	mov	eax,13
201
	add	ebx,1*65536-1
202
 
267 mikedld 203
	mov	ecx,[cur_editor.Bounds.Top-2]
204
	mov	cx,word[cur_editor.VScroll.Top]
259 mikedld 205
	add	ecx,(SCRLW+1)*65536
206
	mov	edx,[sc.work]
207
	or	cx,cx
208
	jle	@f
209
	mcall	13
210
    @@:
267 mikedld 211
	mov	ecx,[cur_editor.Bounds.Top]
212
	add	ecx,[cur_editor.VScroll.Top]
213
	add	ecx,[cur_editor.VScroll.Size]
259 mikedld 214
	add	ecx,SCRLW+1
215
	mov	di,cx
216
	shl	ecx,16
267 mikedld 217
	mov	cx,word[cur_editor.Bounds.Bottom]
259 mikedld 218
	sub	cx,di
219
	sub	cx,SCRLW*2;+1
220
	jle	@f
221
	mcall
222
    @@:
223
	rol	ebx,16
224
	dec	bx
225
	push	bx
226
	rol	ebx,16
227
	pop	bx
267 mikedld 228
	mov	ecx,[cur_editor.Bounds.Top-2]
229
	mov	cx,word[cur_editor.Bounds.Bottom]
259 mikedld 230
	add	ecx,(SCRLW)*65536-SCRLW*2-1
231
	mcall	38,,,[cl_3d_inset]
232
 
233
	ret
617 mikedld 234
endp
259 mikedld 235
 
236
;-----------------------------------------------------------------------------
617 mikedld 237
proc draw_editor_hscroll ;///// DRAW EDITOR HORIZONTAL SCROLL BAR ////////////
259 mikedld 238
;-----------------------------------------------------------------------------
267 mikedld 239
	mov	ebx,[cur_editor.Bounds.Left-2]
259 mikedld 240
	mov	bx,SCRLW
267 mikedld 241
	mov	ecx,[cur_editor.Bounds.Bottom]
259 mikedld 242
	shl	ecx,16
243
	add	ecx,(-SCRLW)*65536+SCRLW
297 mikedld 244
	cmp	[bot_mode],0
245
	jne	@f
267 mikedld 246
	mcall	8,,,'HSL' or 0x40000000
297 mikedld 247
    @@: pushad
259 mikedld 248
	sar	ebx,16
249
	sar	ecx,16
250
	push	ebx ecx SCRLW SCRLW
251
	call	draw_3d_panel
252
	popad
253
 
254
	pushad
255
	push	0x1B
256
	shr	ecx,16
257
	mov	bx,cx
258
	add	ebx,(SCRLW/2-2)*65536+SCRLW/2-3
259
	mcall	4,,[sc.work_text],esp,1
260
	add	esp,4
261
	popad
262
 
267 mikedld 263
	mov	ebx,[cur_editor.Bounds.Right]
259 mikedld 264
	shl	ebx,16
265
	add	ebx,(-SCRLW*2)*65536+SCRLW
297 mikedld 266
	cmp	[bot_mode],0
267
	jne	@f
267 mikedld 268
	mcall	8,,,'HSG' or 0x40000000
297 mikedld 269
    @@: pushad
259 mikedld 270
	sar	ebx,16
271
	sar	ecx,16
272
	push	ebx ecx SCRLW SCRLW
273
	call	draw_3d_panel
274
	popad
275
 
276
	pushad
277
	push	0x1A
278
	shr	ecx,16
279
	mov	bx,cx
280
	add	ebx,(SCRLW/2-2)*65536+SCRLW/2-3
281
	mcall	4,,[sc.work_text],esp,1
282
	add	esp,4
283
	popad
284
 
285
	push	ecx
267 mikedld 286
	mov	eax,[cur_editor.Columns.Count]
259 mikedld 287
	mov	ebx,[columns.scr]
267 mikedld 288
	mov	ecx,[cur_editor.TopLeft.X]
289
	mov	edx,[cur_editor.Bounds.Right]
280 mikedld 290
	sub	edx,[cur_editor.Bounds.Left]
259 mikedld 291
	add	edx,-(SCRLW*3)
292
	call	get_scroll_vars
267 mikedld 293
	mov	[cur_editor.HScroll.Top],eax
294
	mov	[cur_editor.HScroll.Size],ebx
259 mikedld 295
	pop	ecx
296
 
297
	mov	ebx,eax
267 mikedld 298
	add	ebx,[cur_editor.Bounds.Left]
259 mikedld 299
	add	ebx,SCRLW+1
300
	shl	ebx,16
267 mikedld 301
	mov	bx,word[cur_editor.HScroll.Size]
259 mikedld 302
 
303
	pushad
304
	sar	ecx,16
305
	rol	ebx,16
306
	movsx	eax,bx
307
	sar	ebx,16
308
	dec	ebx
309
	push	eax ecx ebx SCRLW
310
	call	draw_3d_panel
311
	popad
312
	add	ecx,1*65536-1
313
 
267 mikedld 314
	mov	ebx,[cur_editor.Bounds.Left-2]
315
	mov	bx,word[cur_editor.Bounds.Left]
316
	mov	bx,word[cur_editor.HScroll.Top]
259 mikedld 317
	add	ebx,(1+SCRLW)*65536
318
	mcall	13,,,[sc.work]
267 mikedld 319
	mov	ebx,[cur_editor.Bounds.Left]
259 mikedld 320
	add	ebx,1+SCRLW
267 mikedld 321
	add	ebx,[cur_editor.HScroll.Top]
322
	add	ebx,[cur_editor.HScroll.Size]
259 mikedld 323
	mov	di,bx
324
	shl	ebx,16
267 mikedld 325
	mov	bx,word[cur_editor.Bounds.Right]
259 mikedld 326
	sub	bx,di
327
	sub	bx,SCRLW*2
328
	jle	@f
329
	mcall
330
    @@:
267 mikedld 331
	mov	ebx,[cur_editor.Bounds.Left-2]
332
	mov	bx,word[cur_editor.Bounds.Right]
259 mikedld 333
	add	ebx,(SCRLW)*65536-SCRLW*2-1
334
	rol	ecx,16
335
	dec	cx
336
	push	cx
337
	rol	ecx,16
338
	pop	cx
339
	mcall	38,,,[cl_3d_inset]
340
 
341
	ret
617 mikedld 342
endp
259 mikedld 343
 
344
;-----------------------------------------------------------------------------
617 mikedld 345
proc draw_editor_text.part ;///// DRAW EDITOR TEXT (PARTLY) //////////////////
297 mikedld 346
;-----------------------------------------------------------------------------
347
; EAX = start line
348
; EBX = end line
349
;-----------------------------------------------------------------------------
350
	cmp	[cur_editor.Lines],0
351
	jne	@f
352
	ret
353
    @@: push	eax
354
	mov	eax,[cur_editor.Bounds.Bottom]
355
	sub	eax,[cur_editor.Bounds.Top]
356
	cmp	eax,LINEH
357
	pop	eax
358
	jge	@f
359
	ret
360
    @@:
361
	mov	ebp,cur_editor
362
	call	init_sel_vars
363
	call	check_bottom_right
364
 
365
	pushad
366
 
367
	push	eax
368
	mov	eax,[cur_editor.Bounds.Left]
369
	add	eax,[cur_editor.Gutter.Width]
370
	add	eax,LCHGW+3
371
	mov	[left_ofs],eax
372
	mov	eax,[cur_editor.Bounds.Top]
373
	add	eax,3
374
	mov	[top_ofs],eax
375
	pop	eax
376
 
377
	cmp	[lines.scr],0
378
	jle	.exit
379
 
380
	cmp	eax,ebx
381
	jle	@f
382
	xchg	eax,ebx
383
    @@: cmp	eax,[cur_editor.TopLeft.Y]
384
	jge	@f
385
	mov	eax,[cur_editor.TopLeft.Y]
386
    @@: mov	ecx,[cur_editor.TopLeft.Y]
387
	add	ecx,[lines.scr]
388
	cmp	ebx,ecx
389
	jl	@f
390
	dec	ecx
391
	mov	ebx,ecx
392
    @@: cmp	eax,ebx
393
	jg	.exit
394
 
395
	mov	ecx,eax
396
	push	eax
397
	call	get_line_offset
398
 
399
  .start:
400
	mov	ecx,ebx
401
	sub	ecx,eax
402
	inc	ecx
403
 
404
	mov	ebx,[top_ofs]
405
	add	ebx,[left_ofs-2]
406
	sub	eax,[cur_editor.TopLeft.Y]
407
	imul	eax,LINEH
408
	add	ebx,eax
409
 
410
	imul	ebp,[cur_editor.TopLeft.X],6*65536
411
	mov	[draw_blines],0
412
 
413
	jmp	draw_editor_text.next_line
414
 
415
  .exit:
416
	popad
417
	ret
617 mikedld 418
endp
297 mikedld 419
 
420
;-----------------------------------------------------------------------------
617 mikedld 421
proc draw_editor_text ;///// DRAW EDITOR TEXT ////////////////////////////////
259 mikedld 422
;-----------------------------------------------------------------------------
280 mikedld 423
	cmp	[cur_editor.Lines],0
424
	jne	@f
425
	ret
426
    @@: mov	eax,[cur_editor.Bounds.Bottom]
267 mikedld 427
	sub	eax,[cur_editor.Bounds.Top]
259 mikedld 428
	cmp	eax,LINEH
429
	jge	@f
430
	ret
431
    @@:
297 mikedld 432
	mov	ebp,cur_editor
259 mikedld 433
	call	init_sel_vars
434
	call	check_bottom_right
435
 
436
	pushad
437
 
267 mikedld 438
	mov	eax,[cur_editor.Bounds.Left]
439
	add	eax,[cur_editor.Gutter.Width]
259 mikedld 440
	add	eax,LCHGW+3
441
	mov	[left_ofs],eax
267 mikedld 442
	mov	eax,[cur_editor.Bounds.Top]
259 mikedld 443
	add	eax,3
444
	mov	[top_ofs],eax
445
 
446
	mov	ebx,[top_ofs]
447
	add	ebx,[left_ofs-2]
448
 
297 mikedld 449
	mov	ecx,[cur_editor.TopLeft.Y]
259 mikedld 450
	push	ecx
451
	call	get_line_offset
452
 
453
  .start:
454
	add	esp,4
455
	mov	ecx,[lines.scr]
456
	or	ecx,ecx
457
	jle	.exit
458
	add	esp,-4
459
 
297 mikedld 460
	imul	ebp,[cur_editor.TopLeft.X],6*65536
461
	mov	[draw_blines],1
259 mikedld 462
 
463
  .next_line:
464
 
465
	push	ecx ebx
466
 
467
	mov	ecx,ebx
468
	shl	ecx,16
469
	mov	cl,LINEH
267 mikedld 470
	mov	ebx,[cur_editor.Bounds.Right]
259 mikedld 471
	add	ebx,-SCRLW
472
	add	ebx,[left_ofs-2]
473
	sub	ebx,[left_ofs]
474
	add	ebx,-2*65536+2
475
 
476
  ; selection (text background)
477
	mov	[in_sel],0
297 mikedld 478
	mov	edx,[color_tbl.back]
259 mikedld 479
	mov	eax,[esp+4*2]
480
	cmp	eax,[sel.begin.y]
481
	jl	.lp6
482
	je	.lp1
483
	cmp	eax,[sel.end.y]
484
	jg	.lp6
485
	je	.lp3
486
	jmp	.lp6.2
487
  .lp1: mov	eax,[sel.begin.y]
488
	cmp	eax,[sel.end.y]
489
	je	.lp5
490
  .lp2: mov	eax,[sel.begin.x]
297 mikedld 491
	sub	eax,[cur_editor.TopLeft.X]
259 mikedld 492
	jle	.lp6.2
493
	cmp	eax,[columns.scr]
494
	jge	.lp6
495
	imul	eax,6
496
	pushad
497
	sub	bx,ax
498
	rol	ebx,16
499
	mov	bx,ax
500
	add	ebx,[left_ofs]
501
	add	ebx,-2
502
	rol	ebx,16
297 mikedld 503
	mov	edx,[color_tbl.back.sel]
259 mikedld 504
	mcall	13
505
	popad
506
	mov	bx,ax
507
	mov	[in_sel],2
508
	jmp	.lp6
509
  .lp3: mov	eax,[sel.begin.y]
510
	cmp	eax,[sel.end.y]
511
	je	.lp5
512
  .lp4: mov	eax,[sel.end.x]
297 mikedld 513
	sub	eax,[cur_editor.TopLeft.X]
259 mikedld 514
	jle	.lp6
515
	cmp	eax,[columns.scr]
516
	jg	.lp6.2
517
	imul	eax,6
518
	pushad
519
	sub	bx,ax
520
	rol	ebx,16
297 mikedld 521
	add	eax,[left_ofs]
259 mikedld 522
	add	eax,-2
523
	mov	bx,ax
524
	rol	ebx,16
525
	mcall	13
526
	popad
527
	inc	eax
297 mikedld 528
	mov	edx,[color_tbl.back.sel]
259 mikedld 529
	mov	bx,ax
530
	mov	[in_sel],3
531
	jmp	.lp6
297 mikedld 532
  .lp5: mov	eax,[cur_editor.TopLeft.X]
259 mikedld 533
	cmp	eax,[sel.begin.x]
534
	jge	.lp4
535
	add	eax,[columns.scr]
536
	cmp	eax,[sel.end.x]
537
	jl	.lp2
538
	mov	eax,[sel.begin.x]
539
	cmp	eax,[sel.end.x]
540
	je	.lp6
297 mikedld 541
	sub	eax,[cur_editor.TopLeft.X]
259 mikedld 542
	imul	eax,6
543
	pushad
544
	mov	ebx,[sel.end.x]
545
	sub	ebx,[sel.begin.x]
546
	imul	ebx,6
547
	sal	ebx,16
548
	dec	eax
549
	add	eax,[left_ofs]
550
	mov	bx,ax
551
	rol	ebx,16
297 mikedld 552
	mov	edx,[color_tbl.back.sel]
259 mikedld 553
	mcall	13
554
	movzx	eax,bx
555
	sar	ebx,16
556
	add	eax,ebx
557
	mov	ebx,eax
558
	sal	ebx,16
559
	sub	ax,[esp+4*4]
560
	neg	ax
561
	add	ax,word[left_ofs]
562
	add	ax,-2
563
	mov	bx,ax
297 mikedld 564
	mov	edx,[color_tbl.back]
259 mikedld 565
	mcall	13
566
	popad
567
	mov	bx,ax
568
	mov	[in_sel],4
569
	jmp	.lp6
570
 
571
  .lp6.2:
297 mikedld 572
	mov	edx,[color_tbl.back.sel]
259 mikedld 573
	inc	[in_sel]
574
  .lp6:
575
	mcall	13
576
 
577
	lodsd
578
 
579
	pushad
297 mikedld 580
	mov	edx,[color_tbl.back]
259 mikedld 581
	test	eax,0x00010000
582
	jz	@f
297 mikedld 583
	mov	edx,[color_tbl.line.moded]
259 mikedld 584
	test	eax,0x00020000
585
	jz	@f
297 mikedld 586
	mov	edx,[color_tbl.line.saved]
259 mikedld 587
    @@: mov	ebx,[left_ofs]
267 mikedld 588
 
259 mikedld 589
	add	ebx,-LCHGW-2;-4
590
	shl	ebx,16
591
	mov	bx,LCHGW
592
	mcall	13
593
	popad
594
 
595
	xor	ecx,ecx
596
	and	eax,0x0000FFFF
597
	mov	[cur_line_len],eax
598
 
599
	or	eax,eax
600
	ja	.next_block
601
	add	esp,4*2
297 mikedld 602
	jmp	.exit
259 mikedld 603
 
604
  .next_block:
605
 
606
	push	esi ecx
297 mikedld 607
	call	.get_next_part
259 mikedld 608
	pop	ebx
609
 
610
	push	ecx
611
	mov	ecx,eax
612
 
613
	push	esi ebx
614
	mov	eax,ebx
297 mikedld 615
	sub	ebx,[cur_editor.TopLeft.X]
259 mikedld 616
	cmp	ebx,[columns.scr]
617
	jge	.skip_t
618
	add	ebx,esi
619
	jle	.skip_t
620
	mov	ebx,[esp+8+4*2] ;// 4*2=esi+ebx
297 mikedld 621
	sub	eax,[cur_editor.TopLeft.X]
259 mikedld 622
	jge	.qqq
623
	sub	edx,eax
624
	add	esi,eax
625
	xor	eax,eax
626
	jmp	.qqq2
627
  .qqq:
628
	imul	eax,6*65536
629
  .qqq2:
630
	and	ebx,0x0000FFFF
297 mikedld 631
	add	eax,[left_ofs-2]
259 mikedld 632
	add	ebx,eax
633
 
634
	mov	eax,[esp]   ; ebx
635
	add	eax,[esp+4] ; esi
297 mikedld 636
	sub	eax,[cur_editor.TopLeft.X]
259 mikedld 637
	sub	eax,[columns.scr]
638
	jle	.qweqwe
639
	sub	esi,eax
640
  .qweqwe:
641
 
642
	mov	al,[in_sel]
643
	cmp	al,0
644
	je	.draw_t
645
	dec	al
646
	jz	.ya4
647
  .nt1: dec	al
648
	jnz	.nt2
649
	mov	eax,[esp]
650
	cmp	eax,[sel.begin.x]
651
	jge	.ya4
652
	add	eax,[esp+4]
653
	cmp	eax,[sel.begin.x]
654
	jl	.draw_t
655
;---[ selection crosses block from the right ]-(-
656
  .ya1: mov	eax,esi
657
	mov	esi,[sel.begin.x]
658
	sub	esi,[esp]
659
	pushad
297 mikedld 660
	mov	ecx,[cur_editor.TopLeft.X]
259 mikedld 661
	sub	ecx,[esp+4*8]
662
	jle	@f
663
	sub	esi,ecx
664
	sub	[esp+4],ecx
665
    @@: sub	eax,esi
666
	add	edx,esi
667
	imul	esi,6
668
	rol	ebx,16
669
	add	bx,si
670
	rol	ebx,16
671
	mov	esi,eax
297 mikedld 672
	mov	ecx,[color_tbl.text.sel]
259 mikedld 673
	mcall	4
674
	popad
675
	jmp	.draw_t
676
;----------------------------------------------)-
677
  .nt2: dec	al
678
	jnz	.nt3
679
	mov	eax,[esp]
680
	cmp	eax,[sel.end.x]
681
	jge	.draw_t
682
	add	eax,[esp+4]
683
	cmp	eax,[sel.end.x]
684
	jl	.ya4
685
;---[ selection crosses block from the left ]--(-
686
  .ya2: mov	eax,[sel.end.x]
687
	sub	eax,[esp]
688
	push	ebx
689
	mov	ebx,[esp+4]
297 mikedld 690
	sub	ebx,[cur_editor.TopLeft.X]
259 mikedld 691
	jge	.ya2.1
692
	add	eax,ebx
693
  .ya2.1:
694
	pop	ebx
695
	pushad
696
	mov	esi,eax
297 mikedld 697
	mov	ecx,[color_tbl.text.sel]
259 mikedld 698
	mcall	4
699
	popad
700
	sub	esi,eax
701
	add	edx,eax
702
	imul	eax,6*65536
703
	add	ebx,eax
704
	jmp	.draw_t
705
;----------------------------------------------)-
706
  .nt3: mov	eax,[esp]
707
	cmp	eax,[sel.end.x]
708
	jge	.draw_t
709
	cmp	eax,[sel.begin.x]
710
	jge	@f
711
	add	eax,[esp+4]
712
	cmp	eax,[sel.begin.x]
713
	jl	.draw_t
714
	cmp	eax,[sel.end.x]
715
	jl	.ya1
716
;---[ selection inside block ]-----------------(-
717
	mov	eax,esi
718
	mov	esi,[sel.begin.x]
719
	sub	esi,[esp]
720
	push	eax
721
	mov	eax,[esp+4]
297 mikedld 722
	sub	eax,[cur_editor.TopLeft.X]
259 mikedld 723
	jge	.nt3.1
724
	add	esi,eax
725
  .nt3.1:
726
	pop	eax
727
	sub	eax,esi
728
	pushad
729
	add	edx,esi
730
	imul	esi,6*65536
731
	add	ebx,esi
732
	mov	esi,[sel.end.x]
733
	sub	esi,[sel.begin.x]
297 mikedld 734
	mov	ecx,[color_tbl.text.sel]
259 mikedld 735
	sub	eax,esi
736
	push	eax
737
	mcall	4
738
	add	edx,esi
739
	imul	esi,6*65536
740
	add	ebx,esi
741
	pop	esi
742
	mov	ecx,[esp+4*6]
743
	mcall	4
744
	popad
745
	jmp	.draw_t
746
;----------------------------------------------)-
747
    @@: add	eax,esi
748
	dec	eax
749
	cmp	eax,[sel.end.x]
750
	jge	.ya2
751
;---[ block inside selection ]-----------------(-
297 mikedld 752
  .ya4: mov	ecx,[color_tbl.text.sel]
259 mikedld 753
;----------------------------------------------)-
754
 
755
  .draw_t:
297 mikedld 756
	mcall	4
259 mikedld 757
  .skip_t:
758
	pop	eax eax ; ebx esi
759
	imul	eax,6
760
	add	[esp+4*2+2],ax
761
	pop	ecx esi
297 mikedld 762
	cmp	ecx,[cur_line_len]
259 mikedld 763
	jl	.next_block
764
 
765
	pop	ebx ecx
766
	and	ebx,0x0000FFFF
767
	add	ebx,[left_ofs-2]
768
	add	ebx,LINEH
297 mikedld 769
	add	esi,[cur_line_len]
259 mikedld 770
	inc	dword[esp]
771
	dec	ecx
772
	jg	.next_line
773
 
774
  .exit:
775
 
297 mikedld 776
	cmp	[draw_blines],0
777
	je	.exit.2
267 mikedld 778
	mov	eax,[cur_editor.Bounds.Left]
779
	add	eax,[cur_editor.Gutter.Width]
259 mikedld 780
	inc	eax
781
	mov	ebx,eax
782
	shl	ebx,16
267 mikedld 783
	mov	bx,word[cur_editor.Bounds.Right]
259 mikedld 784
	sub	bx,ax
785
	add	ebx,-SCRLW
297 mikedld 786
	mov	edx,[color_tbl.back]
280 mikedld 787
	mov	eax,13
788
	mov	ecx,[esp-8]
789
	add	ecx,LINEH
790
	shl	ecx,16
791
	mov	cx,word[cur_editor.Bounds.Bottom]
792
	sub	cx,[esp-8]
793
	add	cx,-SCRLW-LINEH
794
	jle	@f
795
	mcall
796
    @@: mov	ecx,[cur_editor.Bounds.Top-2]
797
	mov	cx,2
798
	add	ecx,0x00010000
799
	mcall
800
	mov	ebx,[cur_editor.Bounds.Right]
801
	mov	ecx,[cur_editor.Bounds.Bottom]
802
	shl	ebx,16
803
	shl	ecx,16
804
	add	ebx,-(SCRLW-1)*65536+SCRLW-1
805
	add	ecx,-(SCRLW-1)*65536+SCRLW-1
806
	mcall
259 mikedld 807
 
297 mikedld 808
  .exit.2:
259 mikedld 809
	popad
810
	add	esp,4
811
	ret
617 mikedld 812
endp
259 mikedld 813
 
814
;-----------------------------------------------------------------------------
617 mikedld 815
proc draw_editor_text.get_next_part ;/////////////////////////////////////////
297 mikedld 816
;-----------------------------------------------------------------------------
817
; Input:
818
;  ECX = current letter
819
;  ESI = string
820
; Output:
821
;  ECX = color
822
;  EDX = string
823
;  ESI = length
824
;-----------------------------------------------------------------------------
825
	cmp	[cur_editor.AsmMode],0
826
	je	.plain.text
827
	xor	ebx,ebx
828
	mov	edx,ecx
829
	add	esi,ecx
830
	mov	edi,symbols
831
	mov	al,[esi]
832
	cmp	al,';'
833
	je	.comment
834
	mov	ecx,symbols.size
835
	repne	scasb
836
	je	.symbol
837
	cmp	al,'$'
838
	jne	@f
839
	mov	edi,symbols
840
	mov	al,[esi+1]
841
	mov	ecx,symbols.size
842
	repne	scasb
843
	je	.not_symbol
844
	jmp	.number
845
    @@: cmp	al,'0'
846
	jb	@f
847
	cmp	al,'9'
848
	jbe	.number
849
    @@: cmp	al,"'"
850
	je	.string
851
	cmp	al,'"'
852
	je	.string
853
  .not_symbol:
854
	inc	ebx
855
	inc	edx
856
	cmp	edx,[cur_line_len]
857
	jge	@f
858
	mov	edi,symbols
859
	mov	al,[esi+ebx]
860
	cmp	al,';'
861
	je	@f
862
	mov	ecx,symbols.size
863
	repne	scasb
864
	jne	.not_symbol
865
    @@: mov	ecx,edx
866
	mov	edx,esi
867
	mov	esi,ebx
868
	mov	eax,[color_tbl.text]
869
	ret
870
  .symbol:
871
	inc	ebx
872
	inc	edx
873
	cmp	edx,[cur_line_len]
874
	jge	@f
875
	mov	edi,symbols
876
	mov	al,[esi+ebx]
877
	mov	ecx,symbols.size
878
	repne	scasb
879
	je	.symbol
880
    @@: mov	ecx,edx
881
	mov	edx,esi
882
	mov	esi,ebx
883
	mov	eax,[color_tbl.symbol]
884
	ret
885
  .comment:
886
	neg	edx
887
	add	edx,[cur_line_len]
888
	xchg	edx,esi
889
	mov	ecx,[cur_line_len]
890
	mov	eax,[color_tbl.comment]
891
	ret
892
  .number:
893
	inc	ebx
894
	inc	edx
895
	cmp	edx,[cur_line_len]
896
	jge	@f
897
	mov	edi,symbols
898
	mov	al,[esi+ebx]
899
	cmp	al,';'
900
	je	@f
901
	mov	ecx,symbols.size
902
	repne	scasb
903
	jne	.number
904
    @@: mov	ecx,edx
905
	mov	edx,esi
906
	mov	esi,ebx
907
	mov	eax,[color_tbl.number]
908
	ret
909
  .string:
910
	inc	ebx
911
	inc	edx
912
	cmp	edx,[cur_line_len]
913
	jge	@f
914
	cmp	[esi+ebx],al
915
	jne	.string
916
	inc	ebx
917
	inc	edx
918
    @@:
919
	mov	ecx,edx
920
	mov	edx,esi
921
	mov	esi,ebx
922
	mov	eax,[color_tbl.string]
923
	ret
924
  .plain.text:
925
	mov	edx,[cur_line_len]
926
	xchg	edx,esi
927
	mov	ecx,[cur_line_len]
928
	mov	eax,[color_tbl.text]
929
	ret
617 mikedld 930
endp
297 mikedld 931
 
932
;-----------------------------------------------------------------------------
617 mikedld 933
proc draw_editor_caret ;///// DRAW EDITOR TEXT CARET /////////////////////////
259 mikedld 934
;-----------------------------------------------------------------------------
935
	cmp	[bot_mode],0
936
	jne	@f
267 mikedld 937
	mov	ebx,[cur_editor.Caret.X]
938
	sub	ebx,[cur_editor.TopLeft.X]
259 mikedld 939
	js	@f
940
	cmp	ebx,[columns.scr]
941
	ja	@f
942
	imul	ebx,6
943
	add	ebx,[left_ofs]
944
	dec	ebx
945
	push	bx
946
	shl	ebx,16
947
	pop	bx
267 mikedld 948
	mov	eax,[cur_editor.Caret.Y]
949
	sub	eax,[cur_editor.TopLeft.Y]
259 mikedld 950
	js	@f
951
	cmp	eax,[lines.scr]
952
	jge	@f
953
	imul	eax,LINEH
954
	add	eax,[top_ofs]
955
	mov	esi,eax
956
	shl	esi,16
957
	add	eax,LINEH-2
958
	mov	si,ax
959
	mov	ecx,2
960
	cmp	[ins_mode],0
961
	jne	.lp8
962
	add	cl,4
963
  .lp8: push	ecx
964
	mcall	38,,esi,0x01000000
965
	add	ebx,0x00010001
966
	pop	ecx
967
	loop	.lp8
968
    @@:
969
	ret
617 mikedld 970
endp
280 mikedld 971
 
972
;-----------------------------------------------------------------------------
617 mikedld 973
proc editor_realloc_lines ;///// ADD $DELTA$ TO LINES SIZE ///////////////////
280 mikedld 974
;-----------------------------------------------------------------------------
975
; EAX = delta
976
;-----------------------------------------------------------------------------
977
	push	ebx ecx
978
	mov	ebx,[cur_editor.Lines.Size]
979
	add	ebx,eax
980
	mov	eax,[cur_editor.Lines]
981
	mov	[cur_editor.Lines.Size],ebx
982
	mov	ecx,eax
824 mikedld 983
	stdcall mem.ReAlloc,eax,ebx
280 mikedld 984
	mov	[cur_editor.Lines],eax
985
	sub	eax,ecx
986
	pop	ecx ebx
987
	ret
617 mikedld 988
endp
297 mikedld 989
 
990
REDRAW_TEXT	 = 00000001b
991
REDRAW_HSCROLL	 = 00000010b
992
REDRAW_VSCROLL	 = 00000100b
993
REDRAW_ONELINE	 = 00001000b
994
REDRAW_TWOLINES  = 00010000b
995
 
996
;-----------------------------------------------------------------------------
617 mikedld 997
proc editor_check_for_changes ;///// EDITOR CHANGES CHECKER //////////////////
297 mikedld 998
;-----------------------------------------------------------------------------
999
	call	.check_cursor_visibility
312 mikedld 1000
  .direct:
297 mikedld 1001
	xor	edx,edx
1002
 
824 mikedld 1003
	mov	ecx,[cur_editor.Caret.Y]
1004
	call	get_line_offset
1005
	call	get_real_length
1006
	mov	ecx,eax
1007
 
311 mikedld 1008
	mov	eax,[cur_editor.Lines.Count]
1009
	cmp	eax,[checker_ed.Lines.Count]
1010
	je	@f
1011
	or	dl,REDRAW_TEXT+REDRAW_VSCROLL+REDRAW_HSCROLL
1012
    @@: mov	eax,[cur_editor.TopLeft.Y]
297 mikedld 1013
	cmp	eax,[checker_ed.TopLeft.Y]
1014
	je	@f
1015
	or	dl,REDRAW_TEXT+REDRAW_VSCROLL
1016
    @@: mov	eax,[cur_editor.TopLeft.X]
1017
	cmp	eax,[checker_ed.TopLeft.X]
1018
	je	@f
1019
	or	dl,REDRAW_TEXT+REDRAW_HSCROLL
1020
    @@: or	dl,dl
1021
	jnz	.redraw
1022
 
824 mikedld 1023
	cmp	ecx,[checker_ed_ll]
311 mikedld 1024
	je	@f
824 mikedld 1025
	mov	[checker_ed_ll],ecx
311 mikedld 1026
	or	dl,REDRAW_ONELINE
1027
    @@:
297 mikedld 1028
	mov	eax,[cur_editor.Caret.Y]
1029
	cmp	eax,[checker_ed.Caret.Y]
1030
	je	@f
1031
	or	dl,REDRAW_TWOLINES
1032
    @@: mov	eax,[cur_editor.Caret.X]
1033
	cmp	eax,[checker_ed.Caret.X]
1034
	je	@f
1035
	or	dl,REDRAW_ONELINE
1036
    @@: mov	ebp,cur_editor
1037
	call	init_sel_vars
1038
	mov	al,[sel.selected]
1039
	mov	ebp,checker_ed
1040
	call	init_sel_vars
1041
	cmp	al,[sel.selected]
1042
	je	@f
1043
	cmp	al,0
1044
	je	.clear_sel
1045
	jmp	.draw_sel
1046
    @@: cmp	al,0
1047
	jne	.redraw_sel
1048
 
1049
	or	dl,dl
1050
	jz	.exit
1051
	test	dl,REDRAW_TWOLINES
1052
	jz	.one_line
1053
	push	edx
1054
	mov	eax,[checker_ed.Caret.Y]
1055
	mov	ebx,eax
1056
	call	draw_editor_text.part
1057
	pop	edx
1058
  .one_line:
1059
	mov	eax,[cur_editor.Caret.Y]
1060
	mov	ebx,eax
1061
	call	draw_editor_text.part
1062
	call	draw_editor_caret
1063
	jmp	.exit
1064
 
1065
  .clear_sel:
1066
	;// use checker_ed
1067
	mov	eax,[sel.begin.y]
1068
	mov	ebx,[sel.end.y]
1069
	push	eax ebx
1070
	call	draw_editor_text.part
1071
	pop	edx ecx
1072
	mov	eax,[cur_editor.Caret.Y]
1073
	cmp	eax,ecx
1074
	jb	@f
1075
	cmp	eax,edx
1076
	jbe	.lp1
1077
    @@: mov	ebx,eax
1078
	call	draw_editor_text.part
1079
  .lp1: call	draw_editor_caret
1080
	jmp	.exit
1081
 
1082
  .draw_sel:
1083
	;// use cur_editor
1084
	mov	ebp,cur_editor
1085
	call	init_sel_vars
1086
	mov	eax,[sel.begin.y]
1087
	mov	ebx,[sel.end.y]
1088
	push	eax ebx
1089
	call	draw_editor_text.part
1090
	pop	edx ecx
1091
	mov	eax,[checker_ed.Caret.Y]
1092
	cmp	eax,ecx
1093
	jb	@f
1094
	cmp	eax,edx
1095
	jbe	.lp2
1096
    @@: mov	ebx,eax
1097
	call	draw_editor_text.part
1098
  .lp2: call	draw_editor_caret
1099
	jmp	.exit
1100
 
1101
  .redraw_sel:
1102
	;// use checker_ed and cur_editor
1103
	mov	eax,[checker_ed.Caret.Y]
1104
	mov	ebx,[cur_editor.Caret.Y]
1105
	cmp	eax,ebx
1106
	jb	@f
1107
	xchg	eax,ebx
1108
    @@: call	draw_editor_text.part
1109
	call	draw_editor_caret
1110
	jmp	.exit
1111
 
1112
  .redraw:
824 mikedld 1113
	mov	[checker_ed_ll],ecx
297 mikedld 1114
	push	edx
1115
	call	draw_editor_gutter
1116
	call	draw_editor_text
1117
	call	draw_editor_caret
1118
	test	byte[esp],REDRAW_VSCROLL
1119
	jz	@f
1120
	call	draw_editor_vscroll
1121
    @@: pop	edx
1122
	test	dl,REDRAW_HSCROLL
1123
	jz	@f
1124
	call	draw_editor_hscroll
1125
    @@: jmp	.exit
1126
 
1127
  .exit:
1128
	mov	esi,cur_editor
1129
	mov	edi,checker_ed
1130
	mov	ecx,sizeof.EDITOR/4
1131
	cld
1132
	rep	movsd
1133
	ret
1134
 
1135
  .check_cursor_visibility:
1136
	push	eax ebx
1137
    .chk_y:
1138
	mov	eax,[cur_editor.Caret.Y]
1139
	or	eax,eax
1140
	jge	@f
1141
	mov	[cur_editor.Caret.Y],0
1142
	jmp	.chk_dy
1143
    @@: cmp	eax,[cur_editor.Lines.Count]
1144
	jl	.chk_dy
1145
	mov	eax,[cur_editor.Lines.Count]
1146
	dec	eax
1147
	mov	[cur_editor.Caret.Y],eax
1148
    .chk_dy:
1149
	mov	eax,[cur_editor.TopLeft.Y]
1150
	cmp	eax,[cur_editor.Caret.Y]
1151
	jle	@f
1152
	m2m	[cur_editor.TopLeft.Y],[cur_editor.Caret.Y]
1153
    @@: add	eax,[lines.scr]
1154
	cmp	eax,[cur_editor.Caret.Y]
1155
	jg	.chk_x
1156
	mov	eax,[cur_editor.Caret.Y]
1157
	sub	eax,[lines.scr]
1158
	inc	eax
1159
	mov	[cur_editor.TopLeft.Y],eax
1160
    .chk_x:
1161
	mov	eax,[cur_editor.Caret.X]
1162
	or	eax,eax
1163
	jge	@f
1164
	mov	[cur_editor.Caret.X],0
1165
	jmp	.chk_dx
1166
    @@: cmp	eax,[cur_editor.Columns.Count]
1167
	jl	.chk_dx
1168
	mov	eax,[cur_editor.Columns.Count]
1169
	mov	[cur_editor.Caret.X],eax
1170
    .chk_dx:
1171
	mov	eax,[cur_editor.TopLeft.X]
1172
	cmp	eax,[cur_editor.Caret.X]
1173
	jle	@f
1174
	m2m	[cur_editor.TopLeft.X],[cur_editor.Caret.X]
1175
    @@: add	eax,[columns.scr]
1176
	cmp	eax,[cur_editor.Caret.X]
1177
	jg	@f
1178
	mov	eax,[cur_editor.Caret.X]
1179
	sub	eax,[columns.scr]
1180
	inc	eax
1181
	mov	[cur_editor.TopLeft.X],eax
1182
    @@: cmp	[mev],MEV_LDOWN
1183
	jne	@f
1184
	push	[cur_editor.Caret.X] [cur_editor.Caret.Y]
1185
	pop	[cur_editor.SelStart.Y] [cur_editor.SelStart.X]
1186
    @@: pop	ebx eax
1187
	ret
617 mikedld 1188
endp