Hedi-0.1: Line oriented editor

Editor

Description

Main datas and types for the editor

Synopsis

Documentation

data Stato w Source

Stato is parametrized on an Engine instance and hold the engine with the last regex entered , regex G and g are not implemented now

Constructors

Stato 

Fields

file :: w

data holding the file

lastre :: String

a regex

filename :: Maybe String

the file we are editing

pending :: Maybe Command

a sensible state for data lost

lastsaved :: Maybe w
 

Instances

Eq w => Eq (Stato w) 
Show w => Show (Stato w) 

type StatoE m w = UndoT (Stato w) mSource

the core editor runs under the state monad with state (Stato w) . Wrapped around a monad (IO mainly) to permit console input and output of commands with IO and testing with State

liftStatoE :: Ctx m w => StatoE m w a -> Editor m w aSource

hputfile :: Ctx m w => w -> Editor m w ()Source

push a new file (data Engine instance) in the core State, pushing the old state in the undo stack

class (Engine w, SIO m, HCtx m (Stato w)) => Ctx m w Source

placeholder for the two constraints

Instances

(Engine w, SIO m, HCtx m (Stato w)) => Ctx m w 

data Err Source

the errors (monad failers) which can break the monad flow

Constructors

StopErr

issued on ctrl-d or q command (q not implemented)

ParserErr String

command line was not parsed to a CompleteCommand

RegexUnmatched

the regex doesn't match a line

EvalErr Err

something bad happened in the evaluation process

BackendErr

lines were addressed out of file (see Engine)

Ahi String

uncontrolled errors

FileReadErr String

io error trying to load a file

FileNameMissing

filename is not set

FileWriteErr String

io error trying to write the file

ExternalCommandErr String

io error executing an external program

PendingState Command

a sensible data discarding command has been entered

NoMoreUndo

reached the first state remembered

NoMoreRedo

reached the last state remembered

CommandHelpMissing

a help for a missing command was asked

CommandHelpParseErr String

error parsing the help for commands

Instances

class Monad m => SIO m whereSource

a layer for IO simulation, see Main for the real program one and Test for tests

Methods

inputSio :: String -> m (Maybe String)Source

accepts a prompt and should return Nothing on eof else a line of input

outputSioSource

Arguments

:: String 
-> m ()

output a normal string

historySioSource

Arguments

:: String 
-> m ()

put a line in the history (which is global)

errorSIOSource

Arguments

:: String 
-> m ()

output an error string

readfileSioSource

Arguments

:: String 
-> ErrorT String m String

read a file

writefileSioSource

Arguments

:: String 
-> String 
-> ErrorT String m ()

write a file | runs an external command , first arg is the command the output is returned or an error is signalled in the errort monad

externalSio :: String -> ErrorT String m StringSource

commandhelpSIO :: m FilePathSource

Instances

SIO IO

a SIO data made right for running the editor

SIO CState 

liftSio :: Ctx m w => m a -> Editor m w aSource

data Command Source

commands for the editor

Constructors

Append

get some text and add it after the addressed line

Insert

get some text and add it before the addressed line

Change

get some text and add it in place of some deleted lines

Delete

delete some lines

Print

print some lines

SmallG String

get some commands and execute them on each line matching a regex

BigG String

interactively execute commands on each line matching a regex

NoCommand

Change the addressed line

Edit String

Load a file

Write

Write the file

WriteNew String

Write a new file

SetFilename String

Set filename

GetFilename

Print filename

EditExternal String

Load the output of an external command

UndoChange

Revert the last change if ever

RedoChange

Restore via the last change

HelpList

Asking help

HelpTopic String

Spedific help

Instances

data Offset Source

represents a line position in the file

Constructors

LastLine

beyond last line, the append line

Absolute Int

the nth line

Current

the line addressed by the engine

Prev Int

the nth line before the addressed one

Next Int

the nth line aftor the addressed one

ReNext String

the next line (wrapping around) matching a regex

LastReNext

the next line matching the last learned regex

RePrev String

the previous line (wrapping around) matching a regex

LastRePrev

the previous matching the last learned regex

MarkedAs Char

the line marked previously with a char

Instances

data Range Source

a couple of Offsets

Constructors

Range Offset Offset 

Instances

data OffsetOrRange Source

wrapper a round the two possible addressing for a command Offset and Range

Constructors

ORO Offset 
ORR Range 
ORN 

Instances

data CompleteCommand Source

a complete command is a Command coupled with a Range or an Offset

Constructors

CC Command OffsetOrRange 

type Editor m w = ErrorT Err (StatoE m w)Source

main datatype for the program-- beyond the core state, a simulation layer SIO can be read and errors Err can be thrown to kill the monad flow

backendSource

Arguments

:: Ctx m w 
=> Maybe a

maybe action

-> Editor m w a

monading

wrap a maybe action and throw a backend error on a Nothing

throughSource

Arguments

:: Ctx m w 
=> (w -> Maybe a)

an action from an engine w to a maybe

-> Editor m w a

the result from Just in the Editor monad

execute an action on the file

pinput :: Ctx m w => String -> Editor m w (Maybe String)Source

the inputSio action lifted to Editor

input :: Ctx m w => Editor m w (Maybe String)Source

the inputSio action lifted to Editor with empty prompt

output :: Ctx m w => String -> Editor m w ()Source

the outputSio action lifted to Editor

history :: Ctx m w => String -> Editor m w ()Source

the historySIO action lifted to Editor

errorlog :: Ctx m w => String -> Editor m w ()Source

the errorSIO action lifted to Editor

runSource

Arguments

:: Ctx m w 
=> Editor m w a

the action to run

-> Stato w

the initial state

-> m (Stato w)

the final state wrapped in the monad choosen for the SIO

editor runner . resolve the all monad from a core state to another