Subversion Repositories Kolibri OS

Rev

Rev 327 | Rev 626 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 327 Rev 617
Line 1... Line 1...
1
;-----------------------------------------------------------------------------
1
;-----------------------------------------------------------------------------
2
func clear_selection ;////////////////////////////////////////////////////////
2
proc clear_selection ;////////////////////////////////////////////////////////
3
;-----------------------------------------------------------------------------
3
;-----------------------------------------------------------------------------
4
	push	eax ebx
4
	push	eax ebx
5
	mov	eax,[cur_editor.SelStart.Y]
5
	mov	eax,[cur_editor.SelStart.Y]
6
	mov	ebx,[cur_editor.Caret.Y]
6
	mov	ebx,[cur_editor.Caret.Y]
7
	cmp	eax,ebx
7
	cmp	eax,ebx
Line 9... Line 9...
9
	xchg	eax,ebx
9
	xchg	eax,ebx
10
    @@: push	[cur_editor.Caret.X] [cur_editor.Caret.Y]
10
    @@: push	[cur_editor.Caret.X] [cur_editor.Caret.Y]
11
	pop	[cur_editor.SelStart.Y] [cur_editor.SelStart.X]
11
	pop	[cur_editor.SelStart.Y] [cur_editor.SelStart.X]
12
	pop	ebx eax
12
	pop	ebx eax
13
	ret
13
	ret
14
endf
14
endp
Line 15... Line 15...
15
 
15
 
16
;-----------------------------------------------------------------------------
16
;-----------------------------------------------------------------------------
17
func pt_in_rect ;/////////////////////////////////////////////////////////////
17
proc pt_in_rect ;/////////////////////////////////////////////////////////////
18
;-----------------------------------------------------------------------------
18
;-----------------------------------------------------------------------------
19
	cmp	eax,[ecx+0x0]
19
	cmp	eax,[ecx+0x0]
20
	jl	@f
20
	jl	@f
21
	cmp	ebx,[ecx+0x4]
21
	cmp	ebx,[ecx+0x4]
Line 26... Line 26...
26
	jg	@f
26
	jg	@f
27
	stc
27
	stc
28
	ret
28
	ret
29
    @@: clc
29
    @@: clc
30
	ret
30
	ret
31
endf
31
endp
Line 32... Line 32...
32
 
32
 
33
;-----------------------------------------------------------------------------
33
;-----------------------------------------------------------------------------
34
func check_bottom_right ;/////////////////////////////////////////////////////
34
proc check_bottom_right ;/////////////////////////////////////////////////////
35
;-----------------------------------------------------------------------------
35
;-----------------------------------------------------------------------------
36
	push	eax
36
	push	eax
-
 
37
	mov	eax,[cur_editor.TopLeft.Y]
-
 
38
	or	eax,eax
-
 
39
	jns	@f
-
 
40
	xor	eax,eax
37
	mov	eax,[cur_editor.TopLeft.Y]
41
	mov	[cur_editor.TopLeft.Y],eax
38
	add	eax,[lines.scr]
42
    @@: add	eax,[lines.scr]
39
	cmp	eax,[cur_editor.Lines.Count]
43
	cmp	eax,[cur_editor.Lines.Count]
40
	jbe	.lp1
44
	jbe	.lp1
41
	mov	eax,[cur_editor.Lines.Count]
45
	mov	eax,[cur_editor.Lines.Count]
42
	sub	eax,[lines.scr]
46
	sub	eax,[lines.scr]
43
	jns	@f
47
	jns	@f
44
	xor	eax,eax
48
	xor	eax,eax
45
    @@: mov	[cur_editor.TopLeft.Y],eax
49
    @@: mov	[cur_editor.TopLeft.Y],eax
-
 
50
  .lp1: mov	eax,[cur_editor.TopLeft.X]
-
 
51
	or	eax,eax
-
 
52
	jns	@f
-
 
53
	xor	eax,eax
46
  .lp1: mov	eax,[cur_editor.TopLeft.X]
54
	mov	[cur_editor.TopLeft.X],eax
47
	add	eax,[columns.scr]
55
    @@: add	eax,[columns.scr]
48
	cmp	eax,[cur_editor.Columns.Count]
56
	cmp	eax,[cur_editor.Columns.Count]
49
	jbe	.exit
57
	jbe	.exit
50
	mov	eax,[cur_editor.Columns.Count]
58
	mov	eax,[cur_editor.Columns.Count]
51
	sub	eax,[columns.scr]
59
	sub	eax,[columns.scr]
52
	jns	@f
60
	jns	@f
53
	xor	eax,eax
61
	xor	eax,eax
54
    @@: mov	[cur_editor.TopLeft.X],eax
62
    @@: mov	[cur_editor.TopLeft.X],eax
55
  .exit:
63
  .exit:
56
	pop	eax
64
	pop	eax
57
	ret
65
	ret
Line 58... Line 66...
58
endf
66
endp
59
 
67
 
60
;-----------------------------------------------------------------------------
68
;-----------------------------------------------------------------------------
61
func get_real_length ;////////////////////////////////////////////////////////
69
proc get_real_length ;////////////////////////////////////////////////////////
62
;-----------------------------------------------------------------------------
70
;-----------------------------------------------------------------------------
63
	movzx	eax,word[esi]
71
	movzx	eax,word[esi]
64
    @@: cmp	byte[esi+eax+4-1],' '
72
    @@: cmp	byte[esi+eax+4-1],' '
65
	jne	@f
73
	jne	@f
66
	dec	eax
74
	dec	eax
67
	jnz	@b
75
	jnz	@b
Line 68... Line 76...
68
    @@: ret
76
    @@: ret
69
endf
77
endp
70
 
78
 
71
;-----------------------------------------------------------------------------
79
;-----------------------------------------------------------------------------
72
func get_line_offset ;////////////////////////////////////////////////////////
80
proc get_line_offset ;////////////////////////////////////////////////////////
73
;-----------------------------------------------------------------------------
81
;-----------------------------------------------------------------------------
74
; Input:
82
; Input:
Line 84... Line 92...
84
	lea	esi,[esi+eax+4]
92
	lea	esi,[esi+eax+4]
85
	jmp	@b
93
	jmp	@b
86
  .exit:
94
  .exit:
87
	pop	ecx eax
95
	pop	ecx eax
88
	ret
96
	ret
89
endf
97
endp
Line 90... Line 98...
90
 
98
 
91
;-----------------------------------------------------------------------------
99
;-----------------------------------------------------------------------------
92
func init_sel_vars ;//////////////////////////////////////////////////////////
100
proc init_sel_vars ;//////////////////////////////////////////////////////////
93
;-----------------------------------------------------------------------------
101
;-----------------------------------------------------------------------------
94
	pushad
102
	pushad
95
	mov	[sel.selected],1
103
	mov	[sel.selected],1
96
	mov	eax,[ebp+EDITOR.SelStart.X]
104
	mov	eax,[ebp+EDITOR.SelStart.X]
Line 111... Line 119...
111
	mov	[sel.begin.y],ebx
119
	mov	[sel.begin.y],ebx
112
	mov	[sel.end.x],ecx
120
	mov	[sel.end.x],ecx
113
	mov	[sel.end.y],edx
121
	mov	[sel.end.y],edx
114
	popad
122
	popad
115
	ret
123
	ret
116
endf
124
endp
Line 117... Line 125...
117
 
125
 
118
;-----------------------------------------------------------------------------
126
;-----------------------------------------------------------------------------
119
func get_scroll_vars ;////////////////////////////////////////////////////////
127
proc get_scroll_vars ;////////////////////////////////////////////////////////
120
;-----------------------------------------------------------------------------
128
;-----------------------------------------------------------------------------
121
; Input:
129
; Input:
122
;  EAX = maximum data size      (units)
130
;  EAX = maximum data size      (units)
123
;  EBX = visible data size      (units)
131
;  EBX = visible data size      (units)
Line 157... Line 165...
157
	ret
165
	ret
158
  .null:
166
  .null:
159
	mov	dword[esp+4],0
167
	mov	dword[esp+4],0
160
	mov	dword[esp+8],0
168
	mov	dword[esp+8],0
161
	jmp	@b
169
	jmp	@b
162
endf
170
endp
Line 163... Line 171...
163
 
171
 
164
;-----------------------------------------------------------------------------
172
;-----------------------------------------------------------------------------
165
func uint2strz ;//////////////////////////////////////////////////////////////
173
proc uint2strz ;//////////////////////////////////////////////////////////////
166
;-----------------------------------------------------------------------------
174
;-----------------------------------------------------------------------------
167
	dec	ebx
175
	dec	ebx
168
	jz	@f
176
	jz	@f
169
	xor	edx,edx
177
	xor	edx,edx
Line 174... Line 182...
174
    @@: cmp	al,10
182
    @@: cmp	al,10
175
	sbb	al,$69
183
	sbb	al,$69
176
	das
184
	das
177
	stosb
185
	stosb
178
	ret
186
	ret
179
endf
187
endp
Line 180... Line 188...
180
 
188
 
181
;-----------------------------------------------------------------------------
189
;-----------------------------------------------------------------------------
182
func uint2str ;///////////////////////////////////////////////////////////////
190
proc uint2str ;///////////////////////////////////////////////////////////////
183
;-----------------------------------------------------------------------------
191
;-----------------------------------------------------------------------------
184
	cmp	eax,ecx
192
	cmp	eax,ecx
185
	jb	@f
193
	jb	@f
186
	xor	edx,edx
194
	xor	edx,edx
Line 191... Line 199...
191
    @@: cmp	al,10
199
    @@: cmp	al,10
192
	sbb	al,$69
200
	sbb	al,$69
193
	das
201
	das
194
	stosb
202
	stosb
195
	ret
203
	ret
196
endf
204
endp
Line 197... Line 205...
197
 
205
 
198
;-----------------------------------------------------------------------------
206
;-----------------------------------------------------------------------------
199
func strlen ;/////////////////////////////////////////////////////////////////
207
proc strlen ;/////////////////////////////////////////////////////////////////
200
;-----------------------------------------------------------------------------
208
;-----------------------------------------------------------------------------
201
	push	ebx
209
	push	ebx
202
	mov	ebx,eax
210
	mov	ebx,eax
203
	xor	eax,eax
211
	xor	eax,eax
204
    @@: cmp	byte[ebx+eax],0
212
    @@: cmp	byte[ebx+eax],0
205
	je	@f
213
	je	@f
206
	inc	eax
214
	inc	eax
207
	jmp	@b
215
	jmp	@b
208
    @@: pop	ebx
216
    @@: pop	ebx
209
	ret
217
	ret
Line 210... Line 218...
210
endf
218
endp
211
 
219
 
212
;-----------------------------------------------------------------------------
220
;-----------------------------------------------------------------------------
213
func rgb_to_gray ;////////////////////////////////////////////////////////////
221
proc rgb_to_gray ;////////////////////////////////////////////////////////////
214
;-----------------------------------------------------------------------------
222
;-----------------------------------------------------------------------------
215
	push	0 eax
223
	push	0 eax
216
	and	dword[esp],0x000000FF
224
	and	dword[esp],0x000000FF
Line 233... Line 241...
233
	fist	dword[esp+1]
241
	fist	dword[esp+1]
234
	fistp	dword[esp+2]
242
	fistp	dword[esp+2]
235
	pop	eax
243
	pop	eax
236
	add	esp,4
244
	add	esp,4
237
	ret
245
	ret
238
endf
246
endp
Line 239... Line 247...
239
 
247
 
240
;float_gray_r dd 0.30f
248
;float_gray_r dd 0.30f
241
;float_gray_g dd 0.59f
249
;float_gray_g dd 0.59f
Line 242... Line 250...
242
;float_gray_b dd 0.11f
250
;float_gray_b dd 0.11f
243
 
251
 
244
;-----------------------------------------------------------------------------
252
;-----------------------------------------------------------------------------
245
func get_active_menu_item ;///////////////////////////////////////////////////
253
proc get_active_menu_item ;///////////////////////////////////////////////////
246
;-----------------------------------------------------------------------------
254
;-----------------------------------------------------------------------------
247
	pushad
255
	pushad
248
	mov	[mi_cur],0
256
	mov	[mi_cur],0
Line 274... Line 282...
274
	ret
282
	ret
275
  .outside_menu:
283
  .outside_menu:
276
	or	[mi_cur],-1
284
	or	[mi_cur],-1
277
    @@: popad
285
    @@: popad
278
	ret
286
	ret
279
endf
287
endp
Line 280... Line 288...
280
 
288
 
281
;-----------------------------------------------------------------------------
289
;-----------------------------------------------------------------------------
282
func get_active_popup_item ;//////////////////////////////////////////////////
290
proc get_active_popup_item ;//////////////////////////////////////////////////
283
;-----------------------------------------------------------------------------
291
;-----------------------------------------------------------------------------
284
	pushad
292
	pushad
285
	mov	[pi_cur],0
293
	mov	[pi_cur],0
286
	mcall	37,1
294
	mcall	37,1
Line 294... Line 302...
294
	movzx	edx,[ebp+POPUP.height]
302
	movzx	edx,[ebp+POPUP.height]
295
	mov	dword[ecx+0xC],edx
303
	mov	dword[ecx+0xC],edx
296
	call	pt_in_rect
304
	call	pt_in_rect
297
	jnc	.outside_window
305
	jnc	.outside_window
298
	inc	dword[ecx+0x0]
306
	inc	dword[ecx+0x0]
299
	mov	dword[ecx+0x4],3
307
	mov	dword[ecx+0x4],2
300
	dec	dword[ecx+0x8]
308
	dec	dword[ecx+0x8]
301
	mov	dword[ecx+0xC],3+POP_IHEIGHT-1
309
	mov	dword[ecx+0xC],2+POP_IHEIGHT-1
302
	mov	edx,[ebp+POPUP.data]
310
	mov	edx,[ebp+POPUP.data]
303
    @@: inc	[pi_cur]
311
    @@: inc	[pi_cur]
304
	inc	edx
312
	inc	edx
305
	movzx	esi,byte[edx-1]
313
	movzx	esi,byte[edx-1]
306
	cmp	byte[edx],'-'
314
	cmp	byte[edx],'-'
307
	jne	.lp1
315
	jne	.lp1
308
	pushd	[ecx+0xC]
316
	pushd	[ecx+0xC]
309
	sub	dword[ecx+0xC],POP_IHEIGHT-4
317
	sub	dword[ecx+0xC],POP_IHEIGHT-POP_SHEIGHT
310
	call	pt_in_rect
318
	call	pt_in_rect
311
	popd	[ecx+0xC]
319
	popd	[ecx+0xC]
312
	jc	.separator
320
	jc	.separator
313
	add	dword[ecx+0x4],4
321
	add	dword[ecx+0x4],POP_SHEIGHT
314
	add	dword[ecx+0xC],4
322
	add	dword[ecx+0xC],POP_SHEIGHT
315
	jmp	.lp3
323
	jmp	.lp3
316
  .lp1: call	pt_in_rect
324
  .lp1: call	pt_in_rect
317
	jnc	.lp2
325
	jnc	.lp2
318
	mov	eax,[pi_cur]
326
	mov	eax,[pi_cur]
319
	test	byte[ebp+eax-1],1
327
	test	byte[ebp+eax-1],1
Line 333... Line 341...
333
	popad
341
	popad
334
	ret
342
	ret
335
  .outside_window:
343
  .outside_window:
336
	or	[pi_cur],-1
344
	or	[pi_cur],-1
337
	jmp	.exit
345
	jmp	.exit
338
endf
346
endp
Line 339... Line 347...
339
 
347
 
340
;-----------------------------------------------------------------------------
348
;-----------------------------------------------------------------------------
341
func line_add_spaces ;////////////////////////////////////////////////////////
349
proc line_add_spaces ;////////////////////////////////////////////////////////
342
;-----------------------------------------------------------------------------
350
;-----------------------------------------------------------------------------
343
; Input:
351
; Input:
344
;  ESI = line offset
352
;  ESI = line offset
345
;  ECX = needed line length
353
;  ECX = needed line length
Line 376... Line 384...
376
	cld
384
	cld
377
	rep	stosb
385
	rep	stosb
378
  .exit:
386
  .exit:
379
	popad
387
	popad
380
	ret
388
	ret
381
endf
389
endp
Line 382... Line 390...
382
 
390
 
383
;-----------------------------------------------------------------------------
391
;-----------------------------------------------------------------------------
384
func delete_selection ;///////////////////////////////////////////////////////
392
proc delete_selection ;///////////////////////////////////////////////////////
385
;-----------------------------------------------------------------------------
393
;-----------------------------------------------------------------------------
Line 386... Line 394...
386
;       call    init_sel_vars
394
;       call    init_sel_vars
387
 
395
 
Line 468... Line 476...
468
	ret
476
	ret
Line 469... Line 477...
469
 
477
 
470
  .exit.2:
478
  .exit.2:
471
	stc
479
	stc
472
	ret
480
	ret
Line 473... Line 481...
473
endf
481
endp
474
 
482
 
475
;-----------------------------------------------------------------------------
483
;-----------------------------------------------------------------------------
476
func get_selection_size ;/////////////////////////////////////////////////////
484
proc get_selection_size ;/////////////////////////////////////////////////////
477
;-----------------------------------------------------------------------------
485
;-----------------------------------------------------------------------------
478
	push	ecx esi
486
	push	ecx esi
479
	mov	ecx,[sel.end.y]
487
	mov	ecx,[sel.end.y]
Line 483... Line 491...
483
	mov	ecx,[sel.begin.y]
491
	mov	ecx,[sel.begin.y]
484
	call	get_line_offset
492
	call	get_line_offset
485
	sub	eax,esi
493
	sub	eax,esi
486
	pop	esi ecx
494
	pop	esi ecx
487
	ret
495
	ret
488
endf
496
endp
Line 489... Line 497...
489
 
497
 
490
;-----------------------------------------------------------------------------
498
;-----------------------------------------------------------------------------
491
func get_lines_in_file ;//////////////////////////////////////////////////////
499
proc get_lines_in_file ;//////////////////////////////////////////////////////
492
;-----------------------------------------------------------------------------
500
;-----------------------------------------------------------------------------
493
; Input:
501
; Input:
494
;  ESI = data pointer
502
;  ESI = data pointer
495
;  ECX = data length
503
;  ECX = data length
Line 526... Line 534...
526
   .TB: and	edx,00000111b
534
   .TB: and	edx,00000111b
527
	add	dword[esp],ATABW
535
	add	dword[esp],ATABW
528
	sub	[esp],edx
536
	sub	[esp],edx
529
	xor	edx,edx
537
	xor	edx,edx
530
	jmp	.lp1
538
	jmp	.lp1
531
endf
539
endp
Line 532... Line 540...
532
 
540
 
533
;-----------------------------------------------------------------------------
541
;-----------------------------------------------------------------------------
534
func update_caption ;/////////////////////////////////////////////////////////
542
proc update_caption ;/////////////////////////////////////////////////////////
535
;-----------------------------------------------------------------------------
543
;-----------------------------------------------------------------------------
536
	lea	esi,[cur_editor.FilePath]
544
	lea	esi,[cur_editor.FilePath]
Line 537... Line 545...
537
	mov	edi,s_title
545
	mov	edi,s_title
Line 570... Line 578...
570
	ret
578
	ret
571
    @@:
579
    @@:
572
	add	esp,4
580
	add	esp,4
573
	clc
581
	clc
574
	ret
582
	ret
575
endf
583
endp
Line 576... Line 584...
576
 
584
 
577
;-----------------------------------------------------------------------------
585
;-----------------------------------------------------------------------------
578
func mem.Alloc ;//////////////////////////////////////////////////////////////
586
proc mem.Alloc,size ;/////////////////////////////////////////////////////////
579
;-----------------------------------------------------------------------------
587
;-----------------------------------------------------------------------------
-
 
588
	push	ebx ecx
580
	push	ebx ecx
589
	mov	eax,[size]
581
	lea	ecx,[eax+4+4095]
590
	lea	ecx,[eax+4+4095]
582
	and	ecx,not 4095
591
	and	ecx,not 4095
583
	mcall	68,12
592
	mcall	68,12
584
	add	ecx,-4
593
	add	ecx,-4
585
	mov	[eax],ecx
594
	mov	[eax],ecx
586
	add	eax,4
595
	add	eax,4
587
	pop	ecx ebx
596
	pop	ecx ebx
-
 
597
	ret
-
 
598
@^
-
 
599
	push	ebx ecx
-
 
600
	mcall	68,12,[size]
-
 
601
	pop	ecx ebx
-
 
602
	ret
588
	ret
603
^@
Line 589... Line 604...
589
endf
604
endp
590
 
605
 
591
;-----------------------------------------------------------------------------
606
;-----------------------------------------------------------------------------
592
func mem.ReAlloc ;////////////////////////////////////////////////////////////
607
proc mem.ReAlloc,mptr,size ;//////////////////////////////////////////////////
-
 
608
;-----------------------------------------------------------------------------
-
 
609
	push	ebx ecx esi edi eax
593
;-----------------------------------------------------------------------------
610
	mov	eax,[mptr]
594
	push	ebx ecx esi edi eax
611
	mov	ebx,[size]
595
	or	eax,eax
612
	or	eax,eax
596
	jz	@f
613
	jz	@f
597
	lea	ecx,[ebx+4+4095]
614
	lea	ecx,[ebx+4+4095]
598
	and	ecx,not 4095
615
	and	ecx,not 4095
599
	add	ecx,-4
616
	add	ecx,-4
600
	cmp	ecx,[eax-4]
617
	cmp	ecx,[eax-4]
601
	je	.exit
-
 
602
    @@: mov	eax,ebx
618
	je	.exit
603
	call	mem.Alloc
619
    @@: stdcall mem.Alloc,ebx
604
	xchg	eax,[esp]
620
	xchg	eax,[esp]
605
	or	eax,eax
621
	or	eax,eax
606
	jz	.exit
622
	jz	.exit
Line 614... Line 630...
614
    @@: add	ecx,3
630
    @@: add	ecx,3
615
	shr	ecx,2
631
	shr	ecx,2
616
	cld
632
	cld
617
	rep	movsd
633
	rep	movsd
618
	xchg	eax,[esp]
634
	xchg	eax,[esp]
619
	call	mem.Free
635
	stdcall mem.Free,eax
620
  .exit:
636
  .exit:
621
	pop	eax edi esi ecx ebx
637
	pop	eax edi esi ecx ebx
622
	ret
638
	ret
-
 
639
@^
-
 
640
	push	ebx ecx edx
-
 
641
	mcall	68,20,[size],[mptr]
-
 
642
	pop	edx ecx ebx
-
 
643
	ret
-
 
644
^@
623
endf
645
endp
Line 624... Line 646...
624
 
646
 
625
;-----------------------------------------------------------------------------
647
;-----------------------------------------------------------------------------
626
func mem.Free ;///////////////////////////////////////////////////////////////
648
proc mem.Free,mptr ;//////////////////////////////////////////////////////////
627
;-----------------------------------------------------------------------------
649
;-----------------------------------------------------------------------------
-
 
650
	push	ebx ecx
628
	push	ebx ecx
651
	mov	eax,[mptr]
629
	lea	ecx,[eax-4]
652
	lea	ecx,[eax-4]
630
	mcall	68,13
653
	mcall	68,13
631
	pop	ecx ebx
654
	pop	ecx ebx
-
 
655
	ret
-
 
656
@^
-
 
657
	push	ebx ecx
-
 
658
	mcall	68,13,[mptr]
-
 
659
	pop	ecx ebx
-
 
660
	ret
632
	ret
661
^@