Types and utility functions for expression text selections.
- type Range = (Int, Int)
- data Bounds = Bounds {
- leftMargin :: Range
- rightMargin :: Range
- innerRange :: Bounds -> Range
- outerRange :: Bounds -> Range
- posInRange :: Int -> Range -> Bool
- rangeInRange :: Range -> Range -> Bool
- rangeInBounds :: Range -> Bounds -> Bool
- rangesInBounds :: Bounds -> [Range]
- distRange :: Range -> Range -> Int
Types
A simple textual selection: starting offset and ending offset, respectively. Offsets are 0-based.
A structural selection expressed as a textual selection. The margins indicate the whitespace directly around the selected structure.
Bounds | |
|
innerRange :: Bounds -> RangeSource
A Bounds
' inner range does not include the whitespace around the selected structure.
outerRange :: Bounds -> RangeSource
A Bounds
' outer range includes the whitespace around the selected structure.
Membership predicates
posInRange :: Int -> Range -> BoolSource
Tells whether the offset falls within the given range.
rangeInRange :: Range -> Range -> BoolSource
Tells whether the first range is enclosed by the second range.
rangeInBounds :: Range -> Bounds -> BoolSource
A range is within certain bounds if its left offset is within the bounds' left margin and its right offset is within the bounds' right margin.
rangesInBounds :: Bounds -> [Range]Source
rangesInBounds b
yields all those ranges r
for which
rangeInBounds r b
.