From: <kr_...@us...> - 2003-07-26 20:39:30
|
Update of /cvsroot/htoolkit/port/src/Port In directory sc8-pr-cvs1:/tmp/cvs-serv6008/src/Port Modified Files: Document.hs Log Message: Add revertDoc function Index: Document.hs =================================================================== RCS file: /cvsroot/htoolkit/port/src/Port/Document.hs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Document.hs 26 Jul 2003 20:19:03 -0000 1.3 --- Document.hs 26 Jul 2003 20:39:27 -0000 1.4 *************** *** 21,25 **** , readDoc, writeDoc , getDocModified, getDocFilePath ! , newDoc, openDoc, saveDoc , openDocWindow, printDoc --- 21,25 ---- , readDoc, writeDoc , getDocModified, getDocFilePath ! , newDoc, openDoc, revertDoc, saveDoc , openDocWindow, printDoc *************** *** 108,113 **** writeDoc (Document ref _ refWindows _) x = do (modified, _) <- readIORef ref - when (not modified) (readIORef refWindows >>= mapM_ (updateWindowModifiedState True)) writeIORef ref (True,x) -- | Retrieve the value of the modification flag in the document --- 108,113 ---- writeDoc (Document ref _ refWindows _) x = do (modified, _) <- readIORef ref writeIORef ref (True,x) + when (not modified) (readIORef refWindows >>= mapM_ (updateWindowModifiedState True)) -- | Retrieve the value of the modification flag in the document *************** *** 142,145 **** --- 142,157 ---- return (Document ref refPath refWindows templ) + -- | Revert the document + revertDoc :: Document a -> IO () + revertDoc (Document ref refPath refWindows templ) = do + path <- readIORef refPath + (modified, x) <- readIORef ref + case path of + Left path | modified -> do + x <- dtOpenDocument templ path + writeIORef ref (False, x) + readIORef refWindows >>= mapM_ (updateWindowModifiedState False) + _ -> return () + -- | Save the document to the file specified with its path. The function automatically turns off the modification flag. saveDoc :: FilePath -> Document a -> IO () *************** *** 148,154 **** when modified $ do dtSaveDocument templ path x - readIORef refWindows >>= mapM_ (updateWindowModifiedState False) writeIORef ref (False, x) writeIORef refPath (Left path) -- | Open new window to display the document. --- 160,166 ---- when modified $ do dtSaveDocument templ path x writeIORef ref (False, x) writeIORef refPath (Left path) + readIORef refWindows >>= mapM_ (updateWindowModifiedState False) -- | Open new window to display the document. |