MissingH-1.2.0.0: Large utility library

Portabilityportable
Stabilityprovisional
MaintainerJohn Goerzen <jgoerzen@complete.org>
Safe HaskellNone

Data.Progress.Meter

Contents

Description

Tool for maintaining a status bar, supporting multiple simultaneous tasks, as a layer atop Data.Progress.Tracker.

Written by John Goerzen, jgoerzen@complete.org

Synopsis

Types

type ProgressMeter = MVar ProgressMeterRSource

Creation and Configuration

simpleNewMeter :: Progress -> IO ProgressMeterSource

Set up a new status bar using defaults:

  • The given tracker
  • Width 80
  • Data.Quantity.renderNums binaryOpts 1
  • Unit inticator B

newMeterSource

Arguments

:: Progress

The top-level Progress

-> 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 StringSource

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.

autoDisplayMeterSource

Arguments

:: 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.