scale progress bar to terminal size
This commit is contained in:
parent
a2902cdaaf
commit
a5d89633c3
2 changed files with 5 additions and 3 deletions
|
@ -16,6 +16,7 @@ import Types.Messages
|
||||||
import Types.Key
|
import Types.Key
|
||||||
|
|
||||||
import System.Console.AsciiProgress
|
import System.Console.AsciiProgress
|
||||||
|
import qualified System.Console.Terminal.Size as Terminal
|
||||||
import Control.Concurrent
|
import Control.Concurrent
|
||||||
|
|
||||||
{- Shows a progress meter while performing a transfer of a key.
|
{- Shows a progress meter while performing a transfer of a key.
|
||||||
|
@ -31,11 +32,12 @@ metered combinemeterupdate key af a = case keySize key of
|
||||||
showOutput
|
showOutput
|
||||||
liftIO $ putStrLn ""
|
liftIO $ putStrLn ""
|
||||||
|
|
||||||
let desc = truncatepretty 79 $ fromMaybe (key2file key) af
|
cols <- liftIO $ maybe 79 Terminal.width <$> Terminal.size
|
||||||
|
let desc = truncatepretty cols $ fromMaybe (key2file key) af
|
||||||
|
|
||||||
result <- liftIO newEmptyMVar
|
result <- liftIO newEmptyMVar
|
||||||
pg <- liftIO $ newProgressBar def
|
pg <- liftIO $ newProgressBar def
|
||||||
{ pgWidth = 79
|
{ pgWidth = cols
|
||||||
, pgFormat = desc ++ " :percent :bar ETA :eta"
|
, pgFormat = desc ++ " :percent :bar ETA :eta"
|
||||||
, pgTotal = size
|
, pgTotal = size
|
||||||
, pgOnCompletion = do
|
, pgOnCompletion = do
|
||||||
|
|
|
@ -113,7 +113,7 @@ Executable git-annex
|
||||||
cryptohash (>= 0.10.0),
|
cryptohash (>= 0.10.0),
|
||||||
esqueleto, persistent-sqlite, persistent, persistent-template,
|
esqueleto, persistent-sqlite, persistent, persistent-template,
|
||||||
monad-logger, resourcet,
|
monad-logger, resourcet,
|
||||||
ascii-progress (<= 0.2.1.2)
|
ascii-progress (<= 0.2.1.2), terminal-size
|
||||||
CC-Options: -Wall
|
CC-Options: -Wall
|
||||||
GHC-Options: -Wall
|
GHC-Options: -Wall
|
||||||
Extensions: PackageImports
|
Extensions: PackageImports
|
||||||
|
|
Loading…
Reference in a new issue