From a5d89633c3918b40c397d0a73ed0dbe06cde24ca Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 14 Apr 2015 16:39:30 -0400 Subject: [PATCH] scale progress bar to terminal size --- Messages/Progress.hs | 6 ++++-- git-annex.cabal | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Messages/Progress.hs b/Messages/Progress.hs index 20c713e06e..64aede5149 100644 --- a/Messages/Progress.hs +++ b/Messages/Progress.hs @@ -16,6 +16,7 @@ import Types.Messages import Types.Key import System.Console.AsciiProgress +import qualified System.Console.Terminal.Size as Terminal import Control.Concurrent {- 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 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 pg <- liftIO $ newProgressBar def - { pgWidth = 79 + { pgWidth = cols , pgFormat = desc ++ " :percent :bar ETA :eta" , pgTotal = size , pgOnCompletion = do diff --git a/git-annex.cabal b/git-annex.cabal index 3c1af0df29..4340deafff 100644 --- a/git-annex.cabal +++ b/git-annex.cabal @@ -113,7 +113,7 @@ Executable git-annex cryptohash (>= 0.10.0), esqueleto, persistent-sqlite, persistent, persistent-template, monad-logger, resourcet, - ascii-progress (<= 0.2.1.2) + ascii-progress (<= 0.2.1.2), terminal-size CC-Options: -Wall GHC-Options: -Wall Extensions: PackageImports