¤ fileShellF, textFileShellF, et al

Shells

Types

fileShellF :: (c1 -> String, String -> String  c1, Maybe c1) ->
              String -> F c1 (InputMsg c1) -> F c2 d
textFileShellF :: String -> F String (InputMsg String) -> F c d
showReadFileShellF :: (Show a, Read a) => Maybe a -> String -> F a (InputMsg a) -> F c d

Synopsis

fileShellF (show,parse,optEmpty) title editor

Description

These fudgets create shell windows with a file menu and are thus suitable for creating file editors of various kinds. The file menu contains the usual commands, 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.

Arguments

(show,parse,optEmpty) :: (c1 -> String, String -> String c1, Maybe c1)
This triple contains conversion functions. The function show is applied to the value before it is saved in a file. The function parse is applied to the contents of openned files. If the value optEmpty is Just empty, empty is sent to the editor fudget when the command New is selected from the menu.

title :: String
The window title. Appears in the title bar attached to the window by the window manager. .

editor :: F c1 (InputMsg c1)
an input editor fudget. It will receive values to be edited on the high level input. It should produce InputMsg values on the output whenever a change is made to the value being edited. The Save and Save As commands will save the most resently output value.

Example

 main = fudlogue $ textFileShellF "Text Editor" (scrollF inputEditorF)

This is all that is needed to create a simple text editor.

See Also

Input editors: stringF, inputEditorF.

Customisable versions: fileShellF' et al.

Bugs

No warning message is given if the user quits or opens a new document when there are unsaved changes in the current document.

There is currently no good way of adding a conventional Edit menu to the menu bar.