Update of /cvsroot/htoolkit/port/src/Port
In directory sc8-pr-cvs1:/tmp/cvs-serv2741/src/Port
Modified Files:
Document.hs
Log Message:
Comments
Index: Document.hs
===================================================================
RCS file: /cvsroot/htoolkit/port/src/Port/Document.hs,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** Document.hs 26 Jul 2003 20:01:50 -0000 1.2
--- Document.hs 26 Jul 2003 20:19:03 -0000 1.3
***************
*** 16,26 ****
(
-- * Document templates
! DocumentTemplate(..), registerDocTemplate, clearDocTemplates
-- * Documents
! , registerDocument, unregisterDocument
, readDoc, writeDoc
, getDocModified, getDocFilePath
, newDoc, openDoc, saveDoc
, openDocWindow, printDoc
)where
--- 16,29 ----
(
-- * Document templates
! DocumentTemplate(..), registerDocTemplate
-- * Documents
! , Document
, readDoc, writeDoc
, getDocModified, getDocFilePath
, newDoc, openDoc, saveDoc
, openDocWindow, printDoc
+
+ -- * Internals
+ , clearDocTemplates, unregisterDocument
)where
***************
*** 62,65 ****
--- 65,69 ----
documentTemplates = unsafePerformIO (newMVar [])
+ -- | Register new document template
registerDocTemplate :: DocumentTemplate a -> IO ()
registerDocTemplate template = do
***************
*** 94,97 ****
--- 98,102 ----
-----------------------------------------------------------------------------------------
+ -- | Read the value of a Document
readDoc :: Document a -> IO a
readDoc (Document ref _ _ _) = do
***************
*** 99,102 ****
--- 104,108 ----
return x
+ -- | Write a new value into a Document. The function automatically turns on the modification flag in the document.
writeDoc :: Document a -> a -> IO ()
writeDoc (Document ref _ refWindows _) x = do
***************
*** 105,108 ****
--- 111,115 ----
writeIORef ref (True,x)
+ -- | Retrieve the value of the modification flag in the document
getDocModified :: Document a -> IO Bool
getDocModified (Document ref _ _ _) = do
***************
*** 110,113 ****
--- 117,121 ----
return modified
+ -- | Returns the path to the file associated with the document. If there is no such file the returned value is Nothing.
getDocFilePath :: Document a -> IO (Maybe FilePath)
getDocFilePath (Document _ refPath _ _) = do
***************
*** 115,118 ****
--- 123,127 ----
return (case path of {Left path -> Just path; Right _ -> Nothing})
+ -- | Create a new document from the specified template
newDoc :: DocumentTemplate a -> IO (Document a)
newDoc templ = do
***************
*** 124,127 ****
--- 133,137 ----
return (Document ref refPath refWindows templ)
+ -- | Open the specified file and create a document associated with it.
openDoc :: FilePath -> DocumentTemplate a -> IO (Document a)
openDoc path templ = do
***************
*** 132,135 ****
--- 142,146 ----
return (Document ref refPath refWindows templ)
+ -- | Save the document to the file specified with its path. The function automatically turns off the modification flag.
saveDoc :: FilePath -> Document a -> IO ()
saveDoc path (Document ref refPath refWindows templ) = do
***************
*** 141,147 ****
writeIORef refPath (Left path)
openDocWindow :: Document a -> IO WindowHandle
! openDocWindow d@(Document _ _ _ templ) = dtOpenWindow templ d
printDoc :: Document a -> IO ()
printDoc (Document ref _ _ templ) = do
--- 152,163 ----
writeIORef refPath (Left path)
+ -- | Open new window to display the document.
openDocWindow :: Document a -> IO WindowHandle
! openDocWindow d@(Document _ _ _ templ) = do
! window <- dtOpenWindow templ d
! registerDocument window d
! return window
+ -- | Print the document
printDoc :: Document a -> IO ()
printDoc (Document ref _ _ templ) = do
|