packages feed

pgdl 9.3 → 10.0

raw patch · 3 files changed

+28/−19 lines, 3 files

Files

pgdl.cabal view
@@ -1,6 +1,6 @@  name:                pgdl-version:             9.3+version:             10.0 license:             PublicDomain license-file:        LICENSE author:              mingchuan
src/Main.hs view
@@ -134,7 +134,7 @@         theMap = A.attrMap V.defAttr [ (L.listAttr, V.white `on` V.black)                                      , ("directory", V.black `on` V.magenta)                                      , ("file", V.black `on` V.cyan)-                                     , ("downloaded file", V.black `on` V.red)+                                     , ("downloaded file", V.black `on` V.yellow)                                      , ("statusBar", V.black `on` V.green)                                      , ("searchBar", V.black `on` V.blue)                                      ]@@ -144,31 +144,40 @@ -- | use cropping to draw UI in the future? drawUI :: MainState -> [Widget String] drawUI mainState = case mainState of-        (LState dlst) -> [ C.hCenter . hLimit U.terminalWidth $+        (LState dlst) -> [ C.hCenter . hLimit U.terminalWidth $                             vBox [entryList dlst, statusBar (extractSelectedDNode dlst)]                          ]         (SearchState dlst e) -> [ C.hCenter . hLimit U.terminalWidth $                                   vBox [entryList dlst, searchBar e]                                 ]     where-    entryList dlist = renderDList dlist listDrawElement-    listDrawElement False (Directory a _) = C.hCenter . txt . mid . stripWidth $ decodedName a -    listDrawElement False (File a _ _) = C.hCenter . txt . mid . stripWidth $ decodedName a -    listDrawElement True d@(Directory _ _) = withAttr "directory" $ listDrawElement False d-    listDrawElement True f@(File _ _ False) = withAttr "file" $ listDrawElement False f-    listDrawElement True f@(File _ _ True) = withAttr "downloaded file" $ listDrawElement False f-    mid s = T.unlines ["", s, ""]-    stripWidth :: Text -> Text-    stripWidth t = case U.cutTextByDisplayLength (U.terminalWidth-5) t of-                    [] -> ""-                    [singleLine] -> singleLine-                    (x:_) -> x `T.append` "..."-    searchBar ed = forceAttr "searchBar" $ hBox [txt "search: ", E.renderEditor True ed]+    entryList dlist = renderDList dlist $ \b d -> hBox $ listDrawElement b d+    listDrawElement :: Bool -> DNode -> [Widget String]+    listDrawElement sel dn = [ color (not sel) attrName . vLimit 3 . hLimit 1 $ fill ' '+                             , color sel attrName text+                             ]+        where+        attrName = case dn of+            Directory _ _ -> "directory"+            File _ _ False -> "file"+            File _ _ True -> "downloaded file"+        name = case dn of+            Directory a _ -> a+            File a _ _ -> a+        text = txt . placeTextIntoRectangle 3 (U.terminalWidth-1) . stripWidth $ decodedName name+        color True attr = withAttr attr+        color False _ = id+        stripWidth :: Text -> Text+        stripWidth t = case U.cutTextByDisplayLength (U.terminalWidth-7) t of+                        [] -> ""+                        [singleLine] -> singleLine+                        (x:_) -> x `T.append` "..."+    searchBar ed = forceAttr "searchBar" $ hBox [txt " search: ", E.renderEditor True ed]     statusBar = withAttr "statusBar" . str . expand . info     info Nothing = "  Nothing selected by user"-    info (Just sel) = "  " ++ show (lastModified e) ++ "    " ++ maybe "Nothing" friendlySize (fileSize e)+    info (Just sel) = "  " ++ show (lastModified etr) ++ "    " ++ maybe "Directory" friendlySize (fileSize etr)         where-        e = entry sel+        etr = entry sel         entry (Directory e _) = e         entry (File e _ _) = e     expand s = s ++ replicate 88 ' '
src/Utils.hs view
@@ -30,7 +30,7 @@     s2s = printf "%6s" . (printf "%.1f" :: Double -> String)  terminalWidth :: Num a => a-terminalWidth = 80+terminalWidth = 83  -- | charDisplayLen returns the display length of a character charDisplayLen :: Char -> Integer