rasa-0.1.4: A modular text editor

Safe HaskellNone
LanguageHaskell2010

Rasa.Internal.Range

Synopsis

Documentation

data Coord Source #

(Coord Row Column) represents a char in a block of text. (zero indexed) e.g. Coord 0 0 is the first character in the text, Coord 2 1 is the second character of the third row

Constructors

Coord Int Int 

Instances

newtype Offset Source #

An Offset represents an exact position in a file as a number of characters from the start.

Constructors

Offset Int 

Instances

asCoord :: YiString -> Iso' Offset Coord Source #

Given the text you're operating over, creates an iso from an Offset to a Coord.

clampCoord :: YiString -> Coord -> Coord Source #

This will restrict a given Coord to a valid one which lies within the given text.

clampRange :: YiString -> Range -> Range Source #

This will restrict a given Range to a valid one which lies within the given text.

data Range Source #

This represents a range between two coordinates (Coord)

Constructors

Range Coord Coord 

Instances

Eq Range Source # 

Methods

(==) :: Range -> Range -> Bool #

(/=) :: Range -> Range -> Bool #

Ord Range Source # 

Methods

compare :: Range -> Range -> Ordering #

(<) :: Range -> Range -> Bool #

(<=) :: Range -> Range -> Bool #

(>) :: Range -> Range -> Bool #

(>=) :: Range -> Range -> Bool #

max :: Range -> Range -> Range #

min :: Range -> Range -> Range #

Show Range Source # 

Methods

showsPrec :: Int -> Range -> ShowS #

show :: Range -> String #

showList :: [Range] -> ShowS #

sizeOf :: YiString -> Coord Source #

Returns the number of rows and columns that a chunk of text spans as a Coord

sizeOfR :: Range -> Coord Source #

Returns the number of rows and columns that a Range spans as a Coord

moveRange :: Coord -> Range -> Range Source #

Moves a Range by a given Coord It may be unintuitive, but for (Coord row col) a given range will be moved down by row and to the right by col.

moveRangeByN :: Int -> Range -> Range Source #

Moves a range forward by the given amount

moveCursorByN :: Int -> Coord -> Coord Source #

Moves a Coord forward by the given amount of columns

moveCursor :: Coord -> Coord -> Coord Source #

Adds the rows and columns of the given two Coords.

data Span a Source #

A span which maps a piece of Monoidal data over a range.

Constructors

Span 

Fields

Instances

Functor Span Source # 

Methods

fmap :: (a -> b) -> Span a -> Span b #

(<$) :: a -> Span b -> Span a #

Eq a => Eq (Span a) Source # 

Methods

(==) :: Span a -> Span a -> Bool #

(/=) :: Span a -> Span a -> Bool #

Show a => Show (Span a) Source # 

Methods

showsPrec :: Int -> Span a -> ShowS #

show :: Span a -> String #

showList :: [Span a] -> ShowS #

combineSpans :: forall a. Monoid a => [Span a] -> [(Coord, a)] Source #

Combines a list of spans containing some monoidal data into a list of offsets with with the data that applies from each Offset forwards.

clamp :: Int -> Int -> Int -> Int Source #

clamp min max val restricts val to be within min and max (inclusive)

beforeC :: Coord -> Lens' YiString YiString Source #

A lens over text before a given Coord

afterC :: Coord -> Lens' YiString YiString Source #

A lens over text after a given Coord