packages feed

pgdl 10.2 → 10.3

raw patch · 4 files changed

+24/−26 lines, 4 filesdep ~brick

Dependency ranges changed: brick

Files

README.md view
@@ -5,8 +5,7 @@ pgdl is a program for viewing and accessing directory listing webpage in terminal.  Browsing files on directory listings like-[this](https://www.kernel.org/pub/linux/) and-[this](https://nixos.org/channels/)+[this](https://www.kernel.org/pub/linux/) is often annoying and hard to find the files we want.  pgdl provids a simple interface for browsing and downloading the files in web-engine-generated directory listings.
pgdl.cabal view
@@ -1,6 +1,6 @@  name:                pgdl-version:             10.2+version:             10.3 license:             PublicDomain license-file:        LICENSE author:              mingchuan@@ -11,7 +11,7 @@ cabal-version:       >=1.10 description:         pgdl is a program for viewing and accessing directory listing webpage in terminal.                      .-                     Browsing files on directory listings like <https://www.kernel.org/pub/> and <https://nixos.org/channels/> is often annoying and hard to find the sutff we want.+                     Browsing files on directory listings like <https://www.kernel.org/pub/> is often annoying and hard to find the sutff we want.                      .                      pgdl provids a simple interface for browsing and downloading the files in web-engine-generated directory listings. @@ -38,7 +38,7 @@                        data-default,                        tagsoup,                        directory-listing-webpage-parser >= 0.1.1.0,-                       brick >= 0.10 && < 0.12, vty, microlens,+                       brick >= 0.13 && < 0.14, vty, microlens,                        conduit, conduit-extra,                        http-conduit, http-types, resourcet,                        configurator >= 0.3,
src/DownloadInterface.hs view
@@ -56,9 +56,8 @@                    | UserInput DownloadState (E.Editor String String)                    --          ^ download progress -data DEvent = VtyEvent V.Event-            | UpdateFinishedSize Integer-            | DownloadFinish+data DownloadEvent = UpdateFinishedSize Integer+                   | DownloadFinish  downloadInterface :: DownloadSettings -> IO ()  downloadInterface dSettings = do@@ -80,11 +79,10 @@                   , M.appHandleEvent = appEvent                   , M.appStartEvent = return                   , M.appAttrMap = const theMap -                  , M.appLiftVtyEvent = VtyEvent                   }-        appEvent :: DownloadState -> DEvent -> T.EventM String (T.Next DownloadState)-        appEvent ds@(DownloadState _) de = case de of-            VtyEvent e -> case e of+        appEvent :: DownloadState -> T.BrickEvent String DownloadEvent -> T.EventM String (T.Next DownloadState)+        appEvent ds@(DownloadState _) be = case be of+            T.VtyEvent e -> case e of                 V.EvKey V.KEsc [] -> M.halt ds                 V.EvKey (V.KChar 'q') _ -> M.halt ds                 V.EvKey (V.KChar 'o') [] -> M.continue $ UserInput ds (E.editor "command" (str.unlines) (Just 1) "")@@ -92,10 +90,11 @@                     liftIO $ localStoragePath dSettings `openBy` ""                     M.continue ds                 _ -> M.continue ds-            UpdateFinishedSize b -> M.continue . DownloadState $ b-            DownloadFinish -> M.continue FinishedState-        appEvent FinishedState de = case de of-            VtyEvent e -> case e of+            T.AppEvent ae -> case ae of+                UpdateFinishedSize b -> M.continue . DownloadState $ b+                DownloadFinish -> M.continue FinishedState+        appEvent FinishedState be = case be of+            T.VtyEvent e -> case e of                 V.EvKey (V.KChar 'q') _ -> M.halt FinishedState                 V.EvKey (V.KChar 'o') [] -> M.continue $ UserInput FinishedState (E.editor "command" (str.unlines) (Just 1) "")                 V.EvKey V.KEnter [] -> do@@ -104,8 +103,8 @@                     -- ^ file opened, we can quit download interface now                 _ -> M.continue FinishedState             _ -> error "received non vty event after FinishedState was reached."-        appEvent (UserInput st ed) de = case de of-            VtyEvent e -> case e of+        appEvent (UserInput st ed) be = case be of+            T.VtyEvent e -> case e of                 V.EvKey V.KEsc [] -> M.continue st                 V.EvKey V.KEnter [] -> do                     liftIO $ localStoragePath dSettings `openBy` concat (E.getEditContents ed)@@ -116,8 +115,9 @@                 ev -> do                     newEd <- E.handleEditorEvent ev ed                     M.continue $ UserInput st newEd-            UpdateFinishedSize b -> M.continue (UserInput (DownloadState b) ed)-            DownloadFinish -> M.continue (UserInput FinishedState ed)+            T.AppEvent de -> case de of+                UpdateFinishedSize b -> M.continue (UserInput (DownloadState b) ed)+                DownloadFinish -> M.continue (UserInput FinishedState ed)         theMap = A.attrMap V.defAttr [ (P.progressCompleteAttr, V.black `on` V.cyan)                                      , (P.progressIncompleteAttr, V.black `on` V.white)                                      , ("input box", V.black `on` V.blue)@@ -144,7 +144,7 @@                   forceAttr "input box" .                    hLimit 40 $                   E.renderEditor True ed-    M.customMain (V.mkVty Data.Default.def) eventChan theApp initialState+    M.customMain (V.mkVty Data.Default.def) (Just eventChan) theApp initialState     return ()  openBy :: Text -> String -> IO ()@@ -181,7 +181,7 @@         True -> Just . fromIntegral . fileSize <$> getFileStatus path      download :: DownloadSettings -> -            (DEvent -> IO ()) ->+            (DownloadEvent -> IO ()) ->             IO () download dSettings tell = do     -- this implementation needs to be change
src/Main.hs view
@@ -51,10 +51,9 @@                   , M.appHandleEvent = appEvent                   , M.appStartEvent = return                   , M.appAttrMap = const theMap -                  , M.appLiftVtyEvent = id                   }-        appEvent :: MainState -> V.Event -> T.EventM String (T.Next MainState)-        appEvent ls@(LState dlst) e = case e of+        appEvent :: MainState -> T.BrickEvent String e -> T.EventM String (T.Next MainState)+        appEvent ls@(LState dlst) (T.VtyEvent e) = case e of             V.EvKey V.KEsc [] -> M.halt ls             V.EvKey (V.KChar 'q') [] -> M.halt ls             V.EvKey V.KEnter mdf -> case extractSelectedDNode dlst of@@ -115,7 +114,7 @@             ev -> M.continue =<< do                 dlst' <- adjustCurrentBrickList dlst $ L.handleListEvent ev                 return $ LState dlst'-        appEvent ss@(SearchState dlst ed) e = case e of+        appEvent ss@(SearchState dlst ed) (T.VtyEvent e) = case e of             V.EvKey V.KEsc [] -> M.halt ss             V.EvKey V.KEnter [] -> case E.getEditContents ed of                 [""] -> M.continue (LState $ popDList dlst)