Copyright | Copyright (C) 2006-2011 John Goerzen |
---|---|
License | BSD3 |
Maintainer | John Goerzen <jgoerzen@complete.org> |
Stability | provisional |
Portability | portable |
Safe Haskell | None |
Language | Haskell98 |
Tool for maintaining a status bar, supporting multiple simultaneous tasks, as a layer atop Data.Progress.Tracker.
Written by John Goerzen, jgoerzen@complete.org
- type ProgressMeter = MVar ProgressMeterR
- simpleNewMeter :: Progress -> IO ProgressMeter
- newMeter :: Progress -> String -> Int -> ([Integer] -> [String]) -> IO ProgressMeter
- setComponents :: ProgressMeter -> [Progress] -> IO ()
- addComponent :: ProgressMeter -> Progress -> IO ()
- removeComponent :: ProgressMeter -> String -> IO ()
- setWidth :: ProgressMeter -> Int -> IO ()
- renderMeter :: ProgressMeter -> IO String
- displayMeter :: Handle -> ProgressMeter -> IO ()
- clearMeter :: Handle -> ProgressMeter -> IO ()
- writeMeterString :: Handle -> ProgressMeter -> String -> IO ()
- autoDisplayMeter :: ProgressMeter -> Int -> (ProgressMeter -> IO ()) -> IO ThreadId
- killAutoDisplayMeter :: ProgressMeter -> ThreadId -> IO ()
Types
type ProgressMeter = MVar ProgressMeterR Source
Creation and Configuration
simpleNewMeter :: Progress -> IO ProgressMeter Source
Set up a new status bar using defaults:
- The given tracker
- Width 80
- Data.Quantity.renderNums binaryOpts 1
- Unit inticator
B
:: Progress | The top-level |
-> String | Unit indicator string |
-> Int | Width of the terminal -- usually 80 |
-> ([Integer] -> [String]) | A function to render sizes |
-> IO ProgressMeter |
Set up a new status bar.
setComponents :: ProgressMeter -> [Progress] -> IO () Source
Adjust the list of components of this ProgressMeter
.
addComponent :: ProgressMeter -> Progress -> IO () Source
Add a new component to the list of components.
removeComponent :: ProgressMeter -> String -> IO () Source
Remove a component by name.
setWidth :: ProgressMeter -> Int -> IO () Source
Adjusts the width of this ProgressMeter
.
Rendering and Output
renderMeter :: ProgressMeter -> IO String Source
Render the current status.
displayMeter :: Handle -> ProgressMeter -> IO () Source
Like renderMeter, but prints it to the screen instead of returning it.
This function will output CR, then the meter.
Pass stdout as the handle for regular display to the screen.
clearMeter :: Handle -> ProgressMeter -> IO () Source
Clears the meter -- outputs CR, spaces equal to the width - 1, then another CR.
Pass stdout as the handle for regular display to the screen.
writeMeterString :: Handle -> ProgressMeter -> String -> IO () Source
Clears the meter, writes the given string, then restores the meter. The string is assumed to contain a trailing newline.
Pass stdout as the handle for regular display to the screen.
:: ProgressMeter | The meter to display |
-> Int | Update interval in seconds |
-> (ProgressMeter -> IO ()) | Function to display it |
-> IO ThreadId | Resulting thread id |
Starts a thread that updates the meter every n seconds by calling
the specified function. Note: displayMeter stdout
is an ideal function here.
Save this threadID and use it later to call stopAutoDisplayMeter
.
killAutoDisplayMeter :: ProgressMeter -> ThreadId -> IO () Source
Stops the specified meter from displaying.
You should probably call clearMeter
after a call to this.