fileShellF :: FileConv c1 -> String -> F c1 (InputMsg c1) -> F c2 d
textFileShellF :: String -> F String (InputMsg String) -> F c d
showReadFileShellF :: (Show c1, Read c1) =>
Maybe c1 -> String -> F c1 (InputMsg c1) -> F c2 d
data FileConv a = FileConv {binaryIO :: Bool,
saveConv :: a -> String,
openConv :: String -> String ⊕ a,
newFile :: Maybe a}
textConv :: FileConv String
showReadConv :: (Show a, Read a) => Maybe a -> FileConv a
binaryConv :: FileConv String
fileShellF conv title editor
New, Open, Save, Save As and Quit.
The documents that are edited can be of any type, provided there is a way to
convert the values to and from strings that can be saved in files.
With fileShellF, conversion functions are supplied explicitly.
With showReadFileShellF the methods of the Show and Read
classes are used for conversion. With textFileShellF, no conversion is
performed.
conv :: FileConv c1saveConv is applied to the value before
it is saved in a file.
openConv is applied to the contents
of opened files. If the value newFile is
Just empty, empty is sent to the editor fudget
when the command New is selected from the menu.
It is also possible to specify that binary mode should
be used instead of text mode when reading and writing files.
title :: String
editor :: F c1 (InputMsg c1)Save and Save As commands will
save the most resently output value.
main = fudlogue $ textFileShellF "Text Editor" (scrollF inputEditorF)
This is all that is needed to create a simple text editor.
textFileShellF = fileShellF textConv
showReadFileShellF empty = fileShellF (showReadConv empty)
binaryConv = textConv{binaryIO=True}
Customisable versions: fileShellF' et al.
There is currently no good way of adding a conventional Edit menu
to the menu bar.