Hedi-0.1.1: Line oriented editorSource codeContentsIndex
Engine
Description
A zipped list with special cursor at the ends. In fact it handles inserting at start and appending at end where the cursor is pointing to non existing lines.
Synopsis
type Change a = a -> Maybe a
data Pos
= Line {
nth :: Int
}
| Begin
| End {
lns :: Int
}
data Engine
= Inside {
left :: [String]
cursor :: String
right :: [String]
}
| Corner {
elems :: Either [String] [String]
}
empty :: Engine
listIn :: [String] -> Engine
listOut :: Engine -> Maybe [String]
linen :: Int -> Engine -> Maybe [String]
line :: Engine -> Maybe String
jump :: Int -> Change Engine
ins :: [String] -> Change Engine
add :: [String] -> Change Engine
del :: Change Engine
deln :: Int -> Change Engine
end :: Change Engine
start :: Change Engine
pos :: Engine -> Pos
next :: Change Engine
prev :: Change Engine
prevn :: Int -> Change Engine
nextn :: Int -> Change Engine
rjump :: Int -> Change Engine
tillend :: Engine -> [Engine]
fwdcycle :: Engine -> [Engine]
fromstart :: Engine -> [Engine]
bwdcycle :: Engine -> [Engine]
last :: Change Engine
first :: Change Engine
isInside :: Engine -> Bool
runner :: Change Engine -> Engine -> [Engine]
Documentation
type Change a = a -> Maybe aSource
represent an action, which can fail with Nothing , an index error
data Pos Source
Pos represent the position addressed in the engine
Constructors
Linethe engine addresses a real line
nth :: IntThe index of the line starting from 1
Beginthe engine addresses before first line , if ever present
Endthe engine addresses after last line
lns :: IntThe number of lines in the engine
show/hide Instances
data Engine Source
relative distance between two positions
Constructors
Insidethe cursor when its pointing to a real line (eg line function doesn't fail)
left :: [String]lines before the cursor (reversed order)
cursor :: Stringaddressed line
right :: [String]lines after the cursor
Cornerthe cursor is pointing either to insert at the front of the file or append at the end of the file.
elems :: Either [String] [String]Left lines is in append mode, Right is in insert at front mode.
show/hide Instances
empty :: EngineSource
An empty engine
listIn :: [String] -> EngineSource
An engine is isomorphic to Engine list
listOut :: Engine -> Maybe [String]Source
Extract the list from the engine
linen :: Int -> Engine -> Maybe [String]Source
Extract n lines from the position addressed
line :: Engine -> Maybe StringSource
Extract the addressed line
jump :: Int -> Change EngineSource
Possibly set the addressed line to the nth line
ins :: [String] -> Change EngineSource
Insert some lines before the addressed line
add :: [String] -> Change EngineSource
Insert some lines after the addressed line
del :: Change EngineSource
Delete the addressed line , address the next one
deln :: Int -> Change EngineSource
Delete n lines from the addressed position
end :: Change EngineSource
Address an append position
start :: Change EngineSource
Address before the first line
pos :: Engine -> PosSource
The number of the addressed line
next :: Change EngineSource
Address the next line
prev :: Change EngineSource
Address the prev line
prevn :: Int -> Change EngineSource
Jump back n lines
nextn :: Int -> Change EngineSource
Jump ahead n lines
rjump :: Int -> Change EngineSource
Jump n lines relative to the addredded line
tillend :: Engine -> [Engine]Source
Create all the engines from the addressed one to the last one
fwdcycle :: Engine -> [Engine]Source
all the next engines from the addressed next to itself , wrapping around
fromstart :: Engine -> [Engine]Source
Create all the engines from the start to the addressed one included
bwdcycle :: Engine -> [Engine]Source
all the prev engines from the addressed prev to itself , wrapping around
last :: Change EngineSource
last element if present
first :: Change EngineSource
first element if present
isInside :: Engine -> BoolSource
runner :: Change Engine -> Engine -> [Engine]Source
Produced by Haddock version 2.3.0