Handbook
Glossary
validate-loc ( loc document -- newloc )
Factor handbook
»
UI framework
»
Building user interfaces
»
Pre-made UI gadgets
»
Editor gadgets
»
Documents
»
Document locations
Prev:
lines-equal? ( loc1 loc2 -- ? )
Vocabulary
documents
Inputs
loc
a pair of integers
document
a
document
Outputs
newloc
a pair of integers
Word description
Ensures that the line and column numbers in
loc
are valid, clamping them to the permitted range if they are not.
Definition
USING:
accessors
arrays
kernel
math
sequences
;
IN:
documents
:
validate-loc
( loc document -- newloc )
2dup
[
first
]
[
value>>
length
]
bi*
>=
[
nip
doc-end
]
[
over
first
0
<
[
2drop
{
0 0
}
]
[
[
first2
over
]
dip
validate-col
2array
]
if
]
if
;