[Pkg-haskell-commits] [SCM] haskell-testpack branch, master, updated. debian/1.0.2-1-4-gb0d6b36

John Goerzen jgoerzen at complete.org
Fri Apr 23 15:14:05 UTC 2010


The following commit has been merged in the master branch:
commit 811522c469ad5949f973651ab290a7e6990725db
Author: John Goerzen <jgoerzen at complete.org>
Date:   Thu Nov 23 07:07:14 2006 +0100

    New clear-the-meter functions

diff --git a/MissingH/ProgressMeter.hs b/MissingH/ProgressMeter.hs
index 25a8841..d2837b5 100644
--- a/MissingH/ProgressMeter.hs
+++ b/MissingH/ProgressMeter.hs
@@ -80,12 +80,20 @@ setComponents meter componentlist = modifyMVar_ meter (\m -> return $ m {compone
 setWidth :: ProgressMeter -> Int -> IO ()
 setWidth meter w = modifyMVar_ meter (\m -> return $ m {width = w})
 
-{- | Like renderMeter, but prints it to the screen instead of returning it. -}
+{- | Like renderMeter, but prints it to the screen instead of returning it. 
+
+This function will output CR, then the meter. -}
 displayMeter :: ProgressMeter -> IO ()
 displayMeter r = 
     do s <- renderMeter r
        putStr ("\r" ++ s)
 
+{- | Clears the meter -- outputs CR, spaces equal to the width - 1,
+then another CR. -}
+clearMeter :: ProgressMeter -> IO ()
+clearMeter pm = withMVar pm $ \m ->
+                putStr $ "\r" ++ replicate (width m - 1) " " ++ "\r"
+
 {- | Starts a thread that updates the meter every n seconds by calling
 the specified function.  Note: 'displayMeter' is an ideal function here.
 
@@ -109,7 +117,9 @@ autoDisplayMeter pm delay displayfunc =
                                   then return True
                                   else return False
 
-{- | Stops the specified meter from displaying. -}
+{- | Stops the specified meter from displaying.
+
+You should probably call 'clearMeter' after a call to this. -}
 killAutoDisplayMeter :: ProgressMeter -> ThreadId -> IO ()
 killAutoDisplayMeter pm t = 
     modifyMVar_ pm (\p -> return $ p {autoDisplayers = filter (/= t) (autoDisplayers p)})

-- 
haskell-testpack



More information about the Pkg-haskell-commits mailing list