This is so ugly
This commit is contained in:
parent
7f9eaf5621
commit
2b72c64cb3
16
app/Main.hs
16
app/Main.hs
@ -76,6 +76,20 @@ attributeMap = const $ attrMap defAttr
|
||||
select :: Widget () -> Widget ()
|
||||
select = withAttr (attrName "selected")
|
||||
|
||||
unitSize :: Integer -> String
|
||||
unitSize s
|
||||
| fromInteger s / (k2^(3 :: Int)) >= 1 / 2 =
|
||||
show (f $ fromInteger s / (k2^(3 :: Int))) ++ " GB"
|
||||
| fromInteger s / (k2^(2 :: Int)) >= 1 / 2 =
|
||||
show (f $ fromInteger s / (k2^(2 :: Int))) ++ " MB"
|
||||
| fromInteger s / k2 >= 1 / 2 =
|
||||
show (f $ fromInteger s / k2 ) ++ " KB"
|
||||
| otherwise =
|
||||
show s ++ " B"
|
||||
where k2 = 1024 :: Double
|
||||
f :: Double -> Double
|
||||
f q = fromInteger (truncate $ q * 100) / 100
|
||||
|
||||
browse :: AppS -> Widget ()
|
||||
browse s =
|
||||
str "Path" <+> padLeft Max (str "Size") <=>
|
||||
@ -88,7 +102,7 @@ widgetCons s w@(f,_) ws =
|
||||
pathWidget w
|
||||
|
||||
pathWidget :: (FilePath, Integer) -> Widget ()
|
||||
pathWidget (f, s) = str (show f) <+> padLeft Max (str (show s))
|
||||
pathWidget (f, s) = str (show f) <+> padLeft Max (str (unitSize s))
|
||||
|
||||
sizeDir :: AppS -> IO AppS
|
||||
sizeDir s = do
|
||||
|
Loading…
Reference in New Issue
Block a user