Editor
Description
Main datas and types for the editor
- data Stato w = Stato {}
- type StatoE m w = UndoT (Stato w) m
- liftStatoE :: Ctx m w => StatoE m w a -> Editor m w a
- hputfile :: Ctx m w => w -> Editor m w ()
- class (Engine w, SIO m, HCtx m (Stato w)) => Ctx m w
- data Err
- class Monad m => SIO m where
- liftSio :: Ctx m w => m a -> Editor m w a
- data Command
- = Append
- | Insert
- | Change
- | Delete
- | SmallG String
- | BigG String
- | NoCommand
- | Edit String
- | Write
- | WriteNew String
- | SetFilename String
- | GetFilename
- | EditExternal String
- | UndoChange
- | RedoChange
- | HelpList
- | HelpTopic String
- data Offset
- data Range = Range Offset Offset
- data OffsetOrRange
- data CompleteCommand = CC Command OffsetOrRange
- type Editor m w = ErrorT Err (StatoE m w)
- backend :: Ctx m w => Maybe a -> Editor m w a
- through :: Ctx m w => (w -> Maybe a) -> Editor m w a
- pinput :: Ctx m w => String -> Editor m w (Maybe String)
- input :: Ctx m w => Editor m w (Maybe String)
- output :: Ctx m w => String -> Editor m w ()
- history :: Ctx m w => String -> Editor m w ()
- errorlog :: Ctx m w => String -> Editor m w ()
- run :: Ctx m w => Editor m w a -> Stato w -> m (Stato w)
Documentation
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 | |
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
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 |
| 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 |
class Monad m => SIO m whereSource
Methods
inputSio :: String -> m (Maybe String)Source
accepts a prompt and should return Nothing on eof else a line of input
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 |
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 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 |
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 |
data OffsetOrRange Source
wrapper a round the two possible addressing for a command Offset and Range
Instances
data CompleteCommand Source
a complete command is a Command coupled with a Range or an Offset
Constructors
| CC Command OffsetOrRange |
Instances
wrap a maybe action and throw a backend error on a Nothing
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