Subversion Repositories Kolibri OS

Rev

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

Rev Author Line No. Line
258 mikedld 1
;-----------------------------------------------------------------------------
617 mikedld 2
proc clear_selection ;////////////////////////////////////////////////////////
258 mikedld 3
;-----------------------------------------------------------------------------
4
	push	eax ebx
297 mikedld 5
	mov	eax,[cur_editor.SelStart.Y]
6
	mov	ebx,[cur_editor.Caret.Y]
258 mikedld 7
	cmp	eax,ebx
8
	jle	@f
9
	xchg	eax,ebx
297 mikedld 10
    @@: push	[cur_editor.Caret.X] [cur_editor.Caret.Y]
11
	pop	[cur_editor.SelStart.Y] [cur_editor.SelStart.X]
258 mikedld 12
	pop	ebx eax
13
	ret
617 mikedld 14
endp
258 mikedld 15
 
16
;-----------------------------------------------------------------------------
617 mikedld 17
proc pt_in_rect ;/////////////////////////////////////////////////////////////
258 mikedld 18
;-----------------------------------------------------------------------------
19
	cmp	eax,[ecx+0x0]
20
	jl	@f
21
	cmp	ebx,[ecx+0x4]
22
	jl	@f
23
	cmp	eax,[ecx+0x8]
24
	jg	@f
25
	cmp	ebx,[ecx+0xC]
26
	jg	@f
27
	stc
28
	ret
29
    @@: clc
30
	ret
617 mikedld 31
endp
258 mikedld 32
 
33
;-----------------------------------------------------------------------------
617 mikedld 34
proc check_bottom_right ;/////////////////////////////////////////////////////
258 mikedld 35
;-----------------------------------------------------------------------------
36
	push	eax
297 mikedld 37
	mov	eax,[cur_editor.TopLeft.Y]
617 mikedld 38
	or	eax,eax
39
	jns	@f
40
	xor	eax,eax
41
	mov	[cur_editor.TopLeft.Y],eax
42
    @@: add	eax,[lines.scr]
297 mikedld 43
	cmp	eax,[cur_editor.Lines.Count]
258 mikedld 44
	jbe	.lp1
297 mikedld 45
	mov	eax,[cur_editor.Lines.Count]
258 mikedld 46
	sub	eax,[lines.scr]
47
	jns	@f
48
	xor	eax,eax
297 mikedld 49
    @@: mov	[cur_editor.TopLeft.Y],eax
50
  .lp1: mov	eax,[cur_editor.TopLeft.X]
617 mikedld 51
	or	eax,eax
52
	jns	@f
53
	xor	eax,eax
54
	mov	[cur_editor.TopLeft.X],eax
55
    @@: add	eax,[columns.scr]
297 mikedld 56
	cmp	eax,[cur_editor.Columns.Count]
258 mikedld 57
	jbe	.exit
297 mikedld 58
	mov	eax,[cur_editor.Columns.Count]
258 mikedld 59
	sub	eax,[columns.scr]
60
	jns	@f
61
	xor	eax,eax
297 mikedld 62
    @@: mov	[cur_editor.TopLeft.X],eax
258 mikedld 63
  .exit:
64
	pop	eax
65
	ret
617 mikedld 66
endp
258 mikedld 67
 
68
;-----------------------------------------------------------------------------
617 mikedld 69
proc get_real_length ;////////////////////////////////////////////////////////
258 mikedld 70
;-----------------------------------------------------------------------------
71
	movzx	eax,word[esi]
72
    @@: cmp	byte[esi+eax+4-1],' '
73
	jne	@f
74
	dec	eax
75
	jnz	@b
76
    @@: ret
617 mikedld 77
endp
258 mikedld 78
 
79
;-----------------------------------------------------------------------------
617 mikedld 80
proc get_line_offset ;////////////////////////////////////////////////////////
258 mikedld 81
;-----------------------------------------------------------------------------
82
; Input:
83
;  ECX = line number
84
; Output:
85
;  ESI = line data offset
86
;-----------------------------------------------------------------------------
87
	push	eax ecx
297 mikedld 88
	mov	esi,[cur_editor.Lines]
259 mikedld 89
    @@: dec	ecx
90
	js	.exit
91
	movzx	eax,word[esi]
258 mikedld 92
	lea	esi,[esi+eax+4]
259 mikedld 93
	jmp	@b
258 mikedld 94
  .exit:
95
	pop	ecx eax
96
	ret
617 mikedld 97
endp
258 mikedld 98
 
99
;-----------------------------------------------------------------------------
617 mikedld 100
proc init_sel_vars ;//////////////////////////////////////////////////////////
258 mikedld 101
;-----------------------------------------------------------------------------
102
	pushad
103
	mov	[sel.selected],1
297 mikedld 104
	mov	eax,[ebp+EDITOR.SelStart.X]
105
	mov	ebx,[ebp+EDITOR.SelStart.Y]
106
	mov	ecx,[ebp+EDITOR.Caret.X]
107
	mov	edx,[ebp+EDITOR.Caret.Y]
258 mikedld 108
	cmp	ebx,edx
109
	jl	.lp2
110
	jne	@f
111
	cmp	eax,ecx
112
	jl	.lp2
113
	jne	.lp1
114
	dec	[sel.selected]
115
	jmp	.lp2
116
    @@: xchg	ebx,edx
117
  .lp1: xchg	eax,ecx
118
  .lp2: mov	[sel.begin.x],eax
119
	mov	[sel.begin.y],ebx
120
	mov	[sel.end.x],ecx
121
	mov	[sel.end.y],edx
122
	popad
123
	ret
617 mikedld 124
endp
258 mikedld 125
 
126
;-----------------------------------------------------------------------------
617 mikedld 127
proc get_scroll_vars ;////////////////////////////////////////////////////////
258 mikedld 128
;-----------------------------------------------------------------------------
129
; Input:
130
;  EAX = maximum data size      (units)
131
;  EBX = visible data size      (units)
132
;  ECX = current data position  (units)
133
;  EDX = scrolling area size    (pixels)
134
; Output:
135
;  EAX = srcoller offset        (pixels)
136
;  EBX = scroller size          (pixels)
137
;-----------------------------------------------------------------------------
138
	push	eax ebx edx
139
;       sub     eax,ebx
140
	mov	esi,eax
141
	mov	eax,edx
142
	imul	ebx
143
	idiv	esi
144
	cmp	eax,[esp]
145
	jge	.null
146
	cmp	eax,AMINS
147
	jge	@f
148
	neg	eax
149
	add	eax,AMINS
150
	sub	[esp],eax
151
	mov	eax,AMINS
152
    @@: mov	[esp+4],eax	; scroller size
153
	mov	eax,[esp]
154
	imul	ecx
155
	idiv	esi
156
	or	eax,eax
157
	jns	@f
158
	xor	eax,eax
297 mikedld 159
   @@:	mov	[esp+8],eax	; scroller offset
258 mikedld 160
	add	eax,[esp+4]
161
	cmp	eax,[esp]
162
	jle	@f
163
    @@:
164
	pop	edx ebx eax
165
	ret
166
  .null:
167
	mov	dword[esp+4],0
168
	mov	dword[esp+8],0
169
	jmp	@b
617 mikedld 170
endp
258 mikedld 171
 
172
;-----------------------------------------------------------------------------
617 mikedld 173
proc uint2strz ;//////////////////////////////////////////////////////////////
258 mikedld 174
;-----------------------------------------------------------------------------
175
	dec	ebx
176
	jz	@f
177
	xor	edx,edx
178
	div	ecx
179
	push	edx
180
	call	uint2strz
181
	pop	eax
182
    @@: cmp	al,10
183
	sbb	al,$69
184
	das
185
	stosb
186
	ret
617 mikedld 187
endp
258 mikedld 188
 
189
;-----------------------------------------------------------------------------
617 mikedld 190
proc uint2str ;///////////////////////////////////////////////////////////////
258 mikedld 191
;-----------------------------------------------------------------------------
192
	cmp	eax,ecx
193
	jb	@f
194
	xor	edx,edx
195
	div	ecx
196
	push	edx
197
	call	uint2str
198
	pop	eax
199
    @@: cmp	al,10
200
	sbb	al,$69
201
	das
202
	stosb
203
	ret
617 mikedld 204
endp
258 mikedld 205
 
206
;-----------------------------------------------------------------------------
617 mikedld 207
proc strlen ;/////////////////////////////////////////////////////////////////
259 mikedld 208
;-----------------------------------------------------------------------------
209
	push	ebx
210
	mov	ebx,eax
211
	xor	eax,eax
212
    @@: cmp	byte[ebx+eax],0
213
	je	@f
214