ascii-progress-0.3.3.0: A simple progress bar for the console.

Safe HaskellNone
LanguageHaskell2010

System.Console.AsciiProgress

Synopsis

Documentation

data Options #

The progress bar's options.

Constructors

Options 

Fields

  • pgFormat :: String

    A format string for the progress bar. Currently the following format strings are supported: - ":eta" (ETA displayed in seconds) - ":current" (current tick) - ":total" (total number of ticks) - ":percent" (percentage completed) - ":elapsed" (elapsed time in seconds) - ":bar" (the actual progress bar)

  • pgCompletedChar :: Char

    Character to be used on the completed part of the bar

  • pgPendingChar :: Char

    Character to be used on the pending part of the bar

  • pgTotal :: Integer

    Total amount of ticks expected

  • pgWidth :: Int

    The progress bar's width

  • pgOnCompletion :: Maybe String

    What to output when the progress bar is done. The same format placeholders used in pgFormat may be used.

  • pgGetProgressStr :: Options -> Stats -> String
     

Instances

data Stats #

Represents a point in time for the progress bar.

isComplete :: ProgressBar -> IO Bool #

Returns if the progress bar rendering thread has exited (it has done enough ticks)

newProgressBar :: Options -> IO ProgressBar #

Creates a new progress bar with the given Options. Multiple progress bars may be created. This package depends on `concurrent-output`, so it's -- necessary that progress-bar usage is wrapped with a call to displayConsoleRegions.

import           Control.Concurrent           (threadDelay)
import           Control.Monad                (unless)
import           System.Console.AsciiProgress

main :: IO ()
main = displayConsoleRegions $ do
   pg <- newProgressBar def { pgWidth = 100
                            , pgOnCompletion = Just "Done :percent after :elapsed seconds"
                            }
   loop pg
 where
   loop pg = do
       b <- isComplete pg
       unless b $ do
           threadDelay $ 200 * 1000
           tick pg
           loop pg

complete :: ProgressBar -> IO () #

Forces a ProgressBar to finish

tick :: ProgressBar -> IO () #

Tick the progress bar

tickN :: ProgressBar -> Int -> IO () #

Tick the progress bar N times

tickNI :: ProgressBar -> Integer -> IO () #

Tick the progress bar N times

getProgressStrIO :: ProgressBar -> IO String #

Like getProgressStr but works on the ProgressBar object and uses the IO monad.

getProgressStats :: ProgressBar -> IO Stats #

Gets the progress bar current Stats object

getProgressStr :: Options -> Stats -> String #

Gets the string to be printed given the options object and a certain stats object representing the rendering moment.

class Default a where #

A class for types with a default value.

Methods

def :: a #

The default value for this type.

Instances

Default Double 

Methods

def :: Double #

Default Float 

Methods

def :: Float #

Default Int 

Methods

def :: Int #

Default Int8 

Methods

def :: Int8 #

Default Int16 

Methods

def :: Int16 #

Default Int32 

Methods

def :: Int32 #

Default Int64 

Methods

def :: Int64 #

Default Integer 

Methods

def :: Integer #

Default Ordering 

Methods

def :: Ordering #

Default Word 

Methods

def :: Word #

Default Word8 

Methods

def :: Word8 #

Default Word16 

Methods

def :: Word16 #

Default Word32 

Methods

def :: Word32 #

Default Word64 

Methods

def :: Word64 #

Default () 

Methods

def :: () #

Default CShort 

Methods

def :: CShort #

Default CUShort 

Methods

def :: CUShort #

Default CInt 

Methods

def :: CInt #

Default CUInt 

Methods

def :: CUInt #

Default CLong 

Methods

def :: CLong #

Default CULong 

Methods

def :: CULong #

Default CLLong 

Methods

def :: CLLong #

Default CULLong 

Methods

def :: CULLong #

Default CFloat 

Methods

def :: CFloat #

Default CDouble 

Methods

def :: CDouble #

Default CPtrdiff 

Methods

def :: CPtrdiff #

Default CSize 

Methods

def :: CSize #

Default CSigAtomic 

Methods

def :: CSigAtomic #

Default CClock 

Methods

def :: CClock #

Default CTime 

Methods

def :: CTime #

Default CUSeconds 

Methods

def :: CUSeconds #

Default CSUSeconds 

Methods

def :: CSUSeconds #

Default CIntPtr 

Methods

def :: CIntPtr #

Default CUIntPtr 

Methods

def :: CUIntPtr #

Default CIntMax 

Methods

def :: CIntMax #

Default CUIntMax 

Methods

def :: CUIntMax #

Default All 

Methods

def :: All #

Default Any 

Methods

def :: Any #

Default Options # 

Methods

def :: Options #

Default [a] 

Methods

def :: [a] #

Default (Maybe a) 

Methods

def :: Maybe a #

Integral a => Default (Ratio a) 

Methods

def :: Ratio a #

Default a => Default (IO a) 

Methods

def :: IO a #

(Default a, RealFloat a) => Default (Complex a) 

Methods

def :: Complex a #

Default a => Default (Dual a) 

Methods

def :: Dual a #

Default (Endo a) 

Methods

def :: Endo a #

Num a => Default (Sum a) 

Methods

def :: Sum a #

Num a => Default (Product a) 

Methods

def :: Product a #

Default (First a) 

Methods

def :: First a #

Default (Last a) 

Methods

def :: Last a #

Default r => Default (e -> r) 

Methods

def :: e -> r #

(Default a, Default b) => Default (a, b) 

Methods

def :: (a, b) #

(Default a, Default b, Default c) => Default (a, b, c) 

Methods

def :: (a, b, c) #

(Default a, Default b, Default c, Default d) => Default (a, b, c, d) 

Methods

def :: (a, b, c, d) #

(Default a, Default b, Default c, Default d, Default e) => Default (a, b, c, d, e) 

Methods

def :: (a, b, c, d, e) #

(Default a, Default b, Default c, Default d, Default e, Default f) => Default (a, b, c, d, e, f) 

Methods

def :: (a, b, c, d, e, f) #

(Default a, Default b, Default c, Default d, Default e, Default f, Default g) => Default (a, b, c, d, e, f, g) 

Methods

def :: (a, b, c, d, e, f, g) #