Subversion Repositories Kolibri OS

Rev

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

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