text-region-0.1.0.0: Provides functions to update text region positions according to text edit actions

Safe HaskellNone
LanguageHaskell2010

Data.Text.Region

Synopsis

Documentation

pt :: Int -> Int -> Point Source

Make Point from line and column

start :: Point Source

Point at the beginning

lineStart :: Int -> Point Source

Point at the beginning of line

till :: Point -> Point -> Region Source

Region from one Point to another

linesSize :: Int -> Size Source

Distance of n lines

line :: Int -> Region Source

n'th line region, starts at the beginning of line and ends on the next line

regionSize :: Point -> Size -> Region Source

Make Region by start position and Size

expandLines :: Region -> Region Source

Expand Region to contain full lines

atRegion :: Editable s => Region -> Lens' (Contents s) (Contents s) Source

Get contents at Region

updateMap :: (EditAction e s, ApplyMap a) => e s -> a -> a Source

Update Region after some action

cutMap :: Region -> Map Source

Cut Region mapping

insertMap :: Region -> Map Source

Opposite to cutMap

cutRegion :: Region -> Region -> Region Source

Update second Region position as if it was data cutted at first Region

insertRegion :: Region -> Region -> Region Source

Update second region position as if it was data inserted at first region

class (Editable s, ApplyMap (e s)) => EditAction e s where Source

Methods

replace :: Region -> Contents s -> e s Source

Make replace action over Region and Contents

actionMap :: e s -> Map Source

Make Map from action

perform :: e s -> State (Contents s) (e s) Source

Perform action, modifying Contents and returning inverse (undo) action

cut :: EditAction e s => Region -> e s Source

Cuts region

paste :: EditAction e s => Point -> Contents s -> e s Source

Pastes Contents at some Point

overwrite :: EditAction e s => Point -> Contents s -> e s Source

Overwrites Contents at some Point

inverse :: EditAction e s => Contents s -> e s -> e s Source

Get undo-action

applyEdit :: EditAction e s => e s -> Contents s -> Contents s Source

Apply action to Contents

edit :: EditAction Replace s => s -> r -> EditM s r a -> (a, s) Source

Run edit monad and return result with updated contents

edit_ :: EditAction Replace s => s -> r -> EditM s r a -> s Source

Run edit monad and return updated contents

push :: EditAction Replace s => ActionIso (Edit s) -> EditM s r () Source

Push action into history, also drops redo stack

run_ :: (EditAction Replace s, ApplyMap r) => Edit s -> EditM s r (ActionIso (Edit s)) Source

Run edit action and returns corresponding redo-undo action

run :: (EditAction Replace s, ApplyMap r) => Edit s -> EditM s r () Source

Run edit action with updating undo/redo stack

runGroup :: (EditAction Replace s, ApplyMap r) => [Edit s] -> EditM s r () Source

Run edit actions, updating undo/redo stack for each of them, but act like they was applied simultaneously For example, cutting 1-st and then 3-rd letter: run (cut first) >> run (cut third) -- 1234 -> 234 -> 23 runGroup [cut first, cut third] -- 1234 -> 234 -> 24

undo :: (EditAction Replace s, ApplyMap r) => EditM s r () Source

Undo last action