summaryrefslogtreecommitdiff
path: root/Messages
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2015-04-14 16:39:30 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2015-04-14 16:39:30 -0400
commita3b23acd92cadfd5107dd8f2f56c737ed7e90d28 (patch)
tree08d33e6e6b5cd6efd6e6d1cc886140200104aca8 /Messages
parentefec2521cc14b3dec895066c9e7c16e740ab12ec (diff)
scale progress bar to terminal size
Diffstat (limited to 'Messages')
-rw-r--r--Messages/Progress.hs6
1 files changed, 4 insertions, 2 deletions
diff --git a/Messages/Progress.hs b/Messages/Progress.hs
index 20c713e06..64aede514 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