Subversion Repositories Kolibri OS

Rev

Rev 824 | 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
987 mikedld 19
	test	[line_nums],1
259 mikedld 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
	pushad
297 mikedld 578
	mov	edx,[color_tbl.back]
987 mikedld 579
	test	[esi+EDITOR_LINE_DATA.Flags],EDITOR_LINE_FLAG_MOFIFIED
259 mikedld 580
	jz	@f
297 mikedld 581
	mov	edx,[color_tbl.line.moded]
987 mikedld 582
	test	[esi+EDITOR_LINE_DATA.Flags],EDITOR_LINE_FLAG_SAVED
259 mikedld 583
	jz	@f
297 mikedld 584
	mov	edx,[color_tbl.line.saved]
259 mikedld 585
    @@: mov	ebx,[left_ofs]
267 mikedld 586
 
259 mikedld 587
	add	ebx,-LCHGW-2;-4
588
	shl	ebx,16
589
	mov	bx,LCHGW
590
	mcall	13
591
	popad
592
 
593
	xor	ecx,ecx
987 mikedld 594
	mov	eax,[esi+EDITOR_LINE_DATA.Size]
259 mikedld 595
	mov	[cur_line_len],eax
987 mikedld 596
	add	esi,sizeof.EDITOR_LINE_DATA
259 mikedld 597
 
598
	or	eax,eax
599
	ja	.next_block
600
	add	esp,4*2
297 mikedld 601
	jmp	.exit
259 mikedld 602
 
603
  .next_block:
604
 
605
	push	esi ecx
297 mikedld 606
	call	.get_next_part
259 mikedld 607
	pop	ebx
608
 
609
	push	ecx
610
	mov	ecx,eax
611
 
612
	push	esi ebx
613
	mov	eax,ebx
297 mikedld 614
	sub	ebx,[cur_editor.TopLeft.X]
259 mikedld 615
	cmp	ebx,[columns.scr]
616
	jge	.skip_t
617
	add	ebx,esi
618
	jle	.skip_t
619
	mov	ebx,[esp+8+4*2] ;// 4*2=esi+ebx
297 mikedld 620
	sub	eax,[cur_editor.TopLeft.X]
259 mikedld 621
	jge	.qqq
622
	sub	edx,eax
623
	add	esi,eax
624
	xor	eax,eax
625
	jmp	.qqq2
626
  .qqq:
627
	imul	eax,6*65536
628
  .qqq2:
629
	and	ebx,0x0000FFFF
297 mikedld 630
	add	eax,[left_ofs-2]
259 mikedld 631
	add	ebx,eax
632
 
633
	mov	eax,[esp]   ; ebx
634
	add	eax,[esp+4] ; esi
297 mikedld 635
	sub	eax,[cur_editor.TopLeft.X]
259 mikedld 636
	sub	eax,[columns.scr]
637
	jle	.qweqwe
638
	sub	esi,eax
639
  .qweqwe:
640
 
641
	mov	al,[in_sel]
642
	cmp	al,0
643
	je	.draw_t
644
	dec	al
645
	jz	.ya4
646
  .nt1: dec	al
647
	jnz	.nt2
648
	mov	eax,[esp]
649
	cmp	eax,[sel.begin.x]
650
	jge	.ya4
651
	add	eax,[esp+4]
652
	cmp	eax,[sel.begin.x]
653
	jl	.draw_t
654
;---[ selection crosses block from the right ]-(-
655
  .ya1: mov	eax,esi
656
	mov	esi,[sel.begin.x]
657
	sub	esi,[esp]
658
	pushad
297 mikedld 659
	mov	ecx,[cur_editor.TopLeft.X]
259 mikedld 660
	sub	ecx,[esp+4*8]
661
	jle	@f
662
	sub	esi,ecx
663
	sub	[esp+4],ecx
664
    @@: sub	eax,esi
665
	add	edx,esi
666
	imul	esi,6
667
	rol	ebx,16
668
	add	bx,si
669
	rol	ebx,16
670
	mov	esi,eax
297 mikedld 671
	mov	ecx,[color_tbl.text.sel]
259 mikedld 672
	mcall	4
673
	popad
674
	jmp	.draw_t
675
;----------------------------------------------)-
676
  .nt2: dec	al
677
	jnz	.nt3
678
	mov	eax,[esp]
679
	cmp	eax,[sel.end.x]
680
	jge	.draw_t
681
	add	eax,[esp+4]
682
	cmp	eax,[sel.end.x]
683
	jl	.ya4
684
;---[ selection crosses block from the left ]--(-
685
  .ya2: mov	eax,[sel.end.x]
686
	sub	eax,[esp]
687
	push	ebx
688
	mov	ebx,[esp+4]
297 mikedld 689
	sub	ebx,[cur_editor.TopLeft.X]
259 mikedld 690
	jge	.ya2.1
691
	add	eax,ebx
692
  .ya2.1:
693
	pop	ebx
694
	pushad
695
	mov	esi,eax
297 mikedld 696
	mov	ecx,[color_tbl.text.sel]
259 mikedld 697
	mcall	4
698
	popad
699
	sub	esi,eax
700
	add	edx,eax
701
	imul	eax,6*65536
702
	add	ebx,eax
703
	jmp	.draw_t
704
;----------------------------------------------)-
705
  .nt3: mov	eax,[esp]
706
	cmp	eax,[sel.end.x]
707
	jge	.draw_t
708
	cmp	eax,[sel.begin.x]
709
	jge	@f
710
	add	eax,[esp+4]
711
	cmp	eax,[sel.begin.x]
712
	jl	.draw_t
713
	cmp	eax,[sel.end.x]
714
	jl	.ya1
715
;---[ selection inside block ]-----------------(-
716
	mov	eax,esi
717
	mov	esi,[sel.begin.x]
718
	sub	esi,[esp]
719
	push	eax
720
	mov	eax,[esp+4]
297 mikedld 721
	sub	eax,[cur_editor.TopLeft.X]
259 mikedld 722
	jge	.nt3.1
723
	add	esi,eax
724
  .nt3.1:
725
	pop	eax
726
	sub	eax,esi
727
	pushad
728
	add	edx,esi
729
	imul	esi,6*65536
730
	add	ebx,esi
731
	mov	esi,[sel.end.x]
732
	sub	esi,[sel.begin.x]
297 mikedld 733
	mov	ecx,[color_tbl.text.sel]
259 mikedld 734
	sub	eax,esi
735
	push	eax
736
	mcall	4
737
	add	edx,esi
738
	imul	esi,6*65536
739
	add	ebx,esi
740
	pop	esi
741
	mov	ecx,[esp+4*6]
742
	mcall	4
743
	popad
744
	jmp	.draw_t
745
;----------------------------------------------)-
746
    @@: add	eax,esi
747
	dec	eax
748
	cmp	eax,[sel.end.x]
749
	jge	.ya2
750
;---[ block inside selection ]-----------------(-
297 mikedld 751
  .ya4: mov	ecx,[color_tbl.text.sel]
259 mikedld 752
;----------------------------------------------)-
753
 
754
  .draw_t:
297 mikedld 755
	mcall	4
259 mikedld 756
  .skip_t:
757
	pop	eax eax ; ebx esi
758
	imul	eax,6
759
	add	[esp+4*2+2],ax
760
	pop	ecx esi
297 mikedld 761
	cmp	ecx,[cur_line_len]
259 mikedld 762
	jl	.next_block
763
 
764
	pop	ebx ecx
765
	and	ebx,0x0000FFFF
766
	add	ebx,[left_ofs-2]
767
	add	ebx,LINEH
297 mikedld 768
	add	esi,[cur_line_len]
259 mikedld 769
	inc	dword[esp]
770
	dec	ecx
771
	jg	.next_line
772
 
773
  .exit:
774
 
297 mikedld 775
	cmp	[draw_blines],0
776
	je	.exit.2
267 mikedld 777
	mov	eax,[cur_editor.Bounds.Left]
778
	add	eax,[cur_editor.Gutter.Width]
259 mikedld 779
	inc	eax
780
	mov	ebx,eax
781
	shl	ebx,16
267 mikedld 782
	mov	bx,word[cur_editor.Bounds.Right]
259 mikedld 783
	sub	bx,ax
784
	add	ebx,-SCRLW
297 mikedld 785
	mov	edx,[color_tbl.back]
280 mikedld 786
	mov	eax,13
787
	mov	ecx,[esp-8]
788
	add	ecx,LINEH
789
	shl	ecx,16
790
	mov	cx,word[cur_editor.Bounds.Bottom]
791
	sub	cx,[esp-8]
792
	add	cx,-SCRLW-LINEH
793
	jle	@f
794
	mcall
795
    @@: mov	ecx,[cur_editor.Bounds.Top-2]
796
	mov	cx,2
797
	add	ecx,0x00010000
798
	mcall
799
	mov	ebx,[cur_editor.Bounds.Right]
800
	mov	ecx,[cur_editor.Bounds.Bottom]
801
	shl	ebx,16
802
	shl	ecx,16
803
	add	ebx,-(SCRLW-1)*65536+SCRLW-1
804
	add	ecx,-(SCRLW-1)*65536+SCRLW-1
805
	mcall
259 mikedld 806
 
297 mikedld 807
  .exit.2:
259 mikedld 808
	popad
809
	add	esp,4
810
	ret
617 mikedld 811
endp
259 mikedld 812
 
813
;-----------------------------------------------------------------------------
617 mikedld 814
proc draw_editor_text.get_next_part ;/////////////////////////////////////////
297 mikedld 815
;-----------------------------------------------------------------------------
816
; Input:
817
;  ECX = current letter
818
;  ESI = string
819
; Output:
820
;  ECX = color
821
;  EDX = string
822
;  ESI = length
823
;-----------------------------------------------------------------------------
824
	cmp	[cur_editor.AsmMode],0
825
	je	.plain.text
826
	xor	ebx,ebx
827
	mov	edx,ecx
828
	add	esi,ecx
829
	mov	edi,symbols
830
	mov	al,[esi]
831
	cmp	al,';'
832
	je	.comment
833
	mov	ecx,symbols.size
834
	repne	scasb
835
	je	.symbol
836
	cmp	al,'$'
837
	jne	@f
838
	mov	edi,symbols
839
	mov	al,[esi+1]
840
	mov	ecx,symbols.size
841
	repne	scasb
842
	je	.not_symbol
843
	jmp	.number
844
    @@: cmp	al,'0'
845
	jb	@f
846
	cmp	al,'9'
847
	jbe	.number
848
    @@: cmp	al,"'"
849
	je	.string
850
	cmp	al,'"'
851
	je	.string
852
  .not_symbol:
853
	inc	ebx
854
	inc	edx
855
	cmp	edx,[cur_line_len]
856
	jge	@f
857
	mov	edi,symbols
858
	mov	al,[esi+ebx]
859
	cmp	al,';'
860
	je	@f
861
	mov	ecx,symbols.size
862
	repne	scasb
863
	jne	.not_symbol
864
    @@: mov	ecx,edx
865
	mov	edx,esi
866
	mov	esi,ebx
867
	mov	eax,[color_tbl.text]
868
	ret
869
  .symbol:
870
	inc	ebx
871
	inc	edx
872
	cmp	edx,[cur_line_len]
873
	jge	@f
874
	mov	edi,symbols
875
	mov	al,[esi+ebx]
876
	mov	ecx,symbols.size
877
	repne	scasb
878
	je	.symbol
879
    @@: mov	ecx,edx
880
	mov	edx,esi
881
	mov	esi,ebx
882
	mov	eax,[color_tbl.symbol]
883
	ret
884
  .comment:
885
	neg	edx
886
	add	edx,[cur_line_len]
887
	xchg	edx,esi
888
	mov	ecx,[cur_line_len]
889
	mov	eax,[color_tbl.comment]
890
	ret
891
  .number:
892
	inc	ebx
893
	inc	edx
894
	cmp	edx,[cur_line_len]
895
	jge	@f
896
	mov	edi,symbols
897
	mov	al,[esi+ebx]
898
	cmp	al,';'
899
	je	@f
900
	mov	ecx,symbols.size
901
	repne	scasb
902
	jne	.number
903
    @@: mov	ecx,edx
904
	mov	edx,esi
905
	mov	esi,ebx
906
	mov	eax,[color_tbl.number]
907
	ret
908
  .string:
909
	inc	ebx
910
	inc	edx
911
	cmp	edx,[cur_line_len]
912
	jge	@f
913
	cmp	[esi+ebx],al
914
	jne	.string
915
	inc	ebx
916
	inc	edx
917
    @@:
918
	mov	ecx,edx
919
	mov	edx,esi
920
	mov	esi,ebx
921
	mov	eax,[color_tbl.string]
922
	ret
923
  .plain.text:
924
	mov	edx,[cur_line_len]
925
	xchg	edx,esi
926
	mov	ecx,[cur_line_len]
927
	mov	eax,[color_tbl.text]
928
	ret
617 mikedld 929
endp
297 mikedld 930
 
931
;-----------------------------------------------------------------------------
617 mikedld 932
proc draw_editor_caret ;///// DRAW EDITOR TEXT CARET /////////////////////////
259 mikedld 933
;-----------------------------------------------------------------------------
934
	cmp	[bot_mode],0
935
	jne	@f
267 mikedld 936
	mov	ebx,[cur_editor.Caret.X]
937
	sub	ebx,[cur_editor.TopLeft.X]
259 mikedld 938
	js	@f
939
	cmp	ebx,[columns.scr]
940
	ja	@f
941
	imul	ebx,6
942
	add	ebx,[left_ofs]
943
	dec	ebx
944
	push	bx
945
	shl	ebx,16
946
	pop	bx
267 mikedld 947
	mov	eax,[cur_editor.Caret.Y]
948
	sub	eax,[cur_editor.TopLeft.Y]
259 mikedld 949
	js	@f
950
	cmp	eax,[lines.scr]
951
	jge	@f
952
	imul	eax,LINEH
953
	add	eax,[top_ofs]
954
	mov	esi,eax
955
	shl	esi,16
956
	add	eax,LINEH-2
957
	mov	si,ax
958
	mov	ecx,2
959
	cmp	[ins_mode],0
960
	jne	.lp8
961
	add	cl,4
962
  .lp8: push	ecx
963
	mcall	38,,esi,0x01000000
964
	add	ebx,0x00010001
965
	pop	ecx
966
	loop	.lp8
967
    @@:
968
	ret
617 mikedld 969
endp
280 mikedld 970
 
971
;-----------------------------------------------------------------------------
617 mikedld 972
proc editor_realloc_lines ;///// ADD $DELTA$ TO LINES SIZE ///////////////////
280 mikedld 973
;-----------------------------------------------------------------------------
974
; EAX = delta
975
;-----------------------------------------------------------------------------
976
	push	ebx ecx
977
	mov	ebx,[cur_editor.Lines.Size]
978
	add	ebx,eax
979
	mov	eax,[cur_editor.Lines]
980
	mov	[cur_editor.Lines.Size],ebx
981
	mov	ecx,eax
824 mikedld 982
	stdcall mem.ReAlloc,eax,ebx
280 mikedld 983
	mov	[cur_editor.Lines],eax
984
	sub	eax,ecx
985
	pop	ecx ebx
986
	ret
617 mikedld 987
endp
297 mikedld 988
 
989
REDRAW_TEXT	 = 00000001b
990
REDRAW_HSCROLL	 = 00000010b
991
REDRAW_VSCROLL	 = 00000100b
992
REDRAW_ONELINE	 = 00001000b
993
REDRAW_TWOLINES  = 00010000b
994
 
995
;-----------------------------------------------------------------------------
617 mikedld 996
proc editor_check_for_changes ;///// EDITOR CHANGES CHECKER //////////////////
297 mikedld 997
;-----------------------------------------------------------------------------
998
	call	.check_cursor_visibility
312 mikedld 999
  .direct:
297 mikedld 1000
	xor	edx,edx
1001
 
824 mikedld 1002
	mov	ecx,[cur_editor.Caret.Y]
1003
	call	get_line_offset
1004
	call	get_real_length
1005
	mov	ecx,eax
1006
 
311 mikedld 1007
	mov	eax,[cur_editor.Lines.Count]
1008
	cmp	eax,[checker_ed.Lines.Count]
1009
	je	@f
1010
	or	dl,REDRAW_TEXT+REDRAW_VSCROLL+REDRAW_HSCROLL
1011
    @@: mov	eax,[cur_editor.TopLeft.Y]
297 mikedld 1012
	cmp	eax,[checker_ed.TopLeft.Y]
1013
	je	@f
1014
	or	dl,REDRAW_TEXT+REDRAW_VSCROLL
1015
    @@: mov	eax,[cur_editor.TopLeft.X]
1016
	cmp	eax,[checker_ed.TopLeft.X]
1017
	je	@f
1018
	or	dl,REDRAW_TEXT+REDRAW_HSCROLL
1019
    @@: or	dl,dl
1020
	jnz	.redraw
1021
 
824 mikedld 1022
	cmp	ecx,[checker_ed_ll]
311 mikedld 1023
	je	@f
824 mikedld 1024
	mov	[checker_ed_ll],ecx
311 mikedld 1025
	or	dl,REDRAW_ONELINE
1026
    @@:
297 mikedld 1027
	mov	eax,[cur_editor.Caret.Y]
1028
	cmp	eax,[checker_ed.Caret.Y]
1029
	je	@f
1030
	or	dl,REDRAW_TWOLINES
1031
    @@: mov	eax,[cur_editor.Caret.X]
1032
	cmp	eax,[checker_ed.Caret.X]
1033
	je	@f
1034
	or	dl,REDRAW_ONELINE
1035
    @@: mov	ebp,cur_editor
1036
	call	init_sel_vars
1037
	mov	al,[sel.selected]
1038
	mov	ebp,checker_ed
1039
	call	init_sel_vars
1040
	cmp	al,[sel.selected]
1041
	je	@f
1042
	cmp	al,0
1043
	je	.clear_sel
1044
	jmp	.draw_sel
1045
    @@: cmp	al,0
1046
	jne	.redraw_sel
1047
 
1048
	or	dl,dl
1049
	jz	.exit
1050
	test	dl,REDRAW_TWOLINES
1051
	jz	.one_line
1052
	push	edx
1053
	mov	eax,[checker_ed.Caret.Y]
1054
	mov	ebx,eax
1055
	call	draw_editor_text.part
1056
	pop	edx
1057
  .one_line:
1058
	mov	eax,[cur_editor.Caret.Y]
1059
	mov	ebx,eax
1060
	call	draw_editor_text.part
1061
	call	draw_editor_caret
1062
	jmp	.exit
1063
 
1064
  .clear_sel:
1065
	;// use checker_ed
1066
	mov	eax,[sel.begin.y]
1067
	mov	ebx,[sel.end.y]
1068
	push	eax ebx
1069
	call	draw_editor_text.part
1070
	pop	edx ecx
1071
	mov	eax,[cur_editor.Caret.Y]
1072
	cmp	eax,ecx
1073
	jb	@f
1074
	cmp	eax,edx
1075
	jbe	.lp1
1076
    @@: mov	ebx,eax
1077
	call	draw_editor_text.part
1078
  .lp1: call	draw_editor_caret
1079
	jmp	.exit
1080
 
1081
  .draw_sel:
1082
	;// use cur_editor
1083
	mov	ebp,cur_editor
1084
	call	init_sel_vars
1085
	mov	eax,[sel.begin.y]
1086
	mov	ebx,[sel.end.y]
1087
	push	eax ebx
1088
	call	draw_editor_text.part
1089
	pop	edx ecx
1090
	mov	eax,[checker_ed.Caret.Y]
1091
	cmp	eax,ecx
1092
	jb	@f
1093
	cmp	eax,edx
1094
	jbe	.lp2
1095
    @@: mov	ebx,eax
1096
	call	draw_editor_text.part
1097
  .lp2: call	draw_editor_caret
1098
	jmp	.exit
1099
 
1100
  .redraw_sel:
1101
	;// use checker_ed and cur_editor
1102
	mov	eax,[checker_ed.Caret.Y]
1103
	mov	ebx,[cur_editor.Caret.Y]
1104
	cmp	eax,ebx
1105
	jb	@f
1106
	xchg	eax,ebx
1107
    @@: call	draw_editor_text.part
1108
	call	draw_editor_caret
1109
	jmp	.exit
1110
 
1111
  .redraw:
824 mikedld 1112
	mov	[checker_ed_ll],ecx
297 mikedld 1113
	push	edx
1114
	call	draw_editor_gutter
1115
	call	draw_editor_text
1116
	call	draw_editor_caret
1117
	test	byte[esp],REDRAW_VSCROLL
1118
	jz	@f
1119
	call	draw_editor_vscroll
1120
    @@: pop	edx
1121
	test	dl,REDRAW_HSCROLL
1122
	jz	@f
1123
	call	draw_editor_hscroll
1124
    @@: jmp	.exit
1125
 
1126
  .exit:
1127
	mov	esi,cur_editor
1128
	mov	edi,checker_ed
1129
	mov	ecx,sizeof.EDITOR/4
1130
	cld
1131
	rep	movsd
1132
	ret
1133
 
1134
  .check_cursor_visibility:
1135
	push	eax ebx
1136
    .chk_y:
1137
	mov	eax,[cur_editor.Caret.Y]
1138
	or	eax,eax
1139
	jge	@f
1140
	mov	[cur_editor.Caret.Y],0
1141
	jmp	.chk_dy
1142
    @@: cmp	eax,[cur_editor.Lines.Count]
1143
	jl	.chk_dy
1144
	mov	eax,[cur_editor.Lines.Count]
1145
	dec	eax
1146
	mov	[cur_editor.Caret.Y],eax
1147
    .chk_dy:
1148
	mov	eax,[cur_editor.TopLeft.Y]
1149
	cmp	eax,[cur_editor.Caret.Y]
1150
	jle	@f
1151
	m2m	[cur_editor.TopLeft.Y],[cur_editor.Caret.Y]
1152
    @@: add	eax,[lines.scr]
1153
	cmp	eax,[cur_editor.Caret.Y]
1154
	jg	.chk_x
1155
	mov	eax,[cur_editor.Caret.Y]
1156
	sub	eax,[lines.scr]
1157
	inc	eax
1158
	mov	[cur_editor.TopLeft.Y],eax
1159
    .chk_x:
1160
	mov	eax,[cur_editor.Caret.X]
1161
	or	eax,eax
1162
	jge	@f
1163
	mov	[cur_editor.Caret.X],0
1164
	jmp	.chk_dx
1165
    @@: cmp	eax,[cur_editor.Columns.Count]
1166
	jl	.chk_dx
1167
	mov	eax,[cur_editor.Columns.Count]
1168
	mov	[cur_editor.Caret.X],eax
1169
    .chk_dx:
1170
	mov	eax,[cur_editor.TopLeft.X]
1171
	cmp	eax,[cur_editor.Caret.X]
1172
	jle	@f
1173
	m2m	[cur_editor.TopLeft.X],[cur_editor.Caret.X]
1174
    @@: add	eax,[columns.scr]
1175
	cmp	eax,[cur_editor.Caret.X]
1176
	jg	@f
1177
	mov	eax,[cur_editor.Caret.X]
1178
	sub	eax,[columns.scr]
1179
	inc	eax
1180
	mov	[cur_editor.TopLeft.X],eax
1181
    @@: cmp	[mev],MEV_LDOWN
1182
	jne	@f
1183
	push	[cur_editor.Caret.X] [cur_editor.Caret.Y]
1184
	pop	[cur_editor.SelStart.Y] [cur_editor.SelStart.X]
1185
    @@: pop	ebx eax
1186
	ret
617 mikedld 1187
endp