packages feed

hledger-iadd 1.2.2 → 1.2.3

raw patch · 7 files changed

+85/−34 lines, 7 filesdep +microlens-thdep ~brickdep ~hledger-libPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

Dependencies added: microlens-th

Dependency ranges changed: brick, hledger-lib

API changes (from Hackage documentation)

+ Brick.Widgets.Edit.EmacsBindings: applyEdit :: (TextZipper Text -> TextZipper Text) -> Editor n -> Editor n
+ Brick.Widgets.Edit.EmacsBindings: data Editor n
+ Brick.Widgets.Edit.EmacsBindings: editContentsL :: Lens (Editor n) (Editor n) (TextZipper Text) (TextZipper Text)
+ Brick.Widgets.Edit.EmacsBindings: editorText :: n -> ([Text] -> Widget n) -> Maybe Int -> Text -> Editor n
+ Brick.Widgets.Edit.EmacsBindings: getEditContents :: Editor n -> [Text]
+ Brick.Widgets.Edit.EmacsBindings: renderEditor :: (Ord n, Show n) => Bool -> Editor n -> Widget n
- Brick.Widgets.Edit.EmacsBindings: handleEditorEvent :: (Eq t, GenericTextZipper t) => Event -> Editor t n -> EventM n (Editor t n)
+ Brick.Widgets.Edit.EmacsBindings: handleEditorEvent :: Event -> Editor n -> EventM n (Editor n)

Files

ChangeLog.md view
@@ -1,3 +1,9 @@+# 1.2.3++  - Support for brick-0.20+  - Restore compatibility with brick-0.17+  - Support for hledger-lib-1.3+ # 1.2.2    - Support for megaparsec-5.3.0
hledger-iadd.cabal view
@@ -1,5 +1,5 @@ name:                hledger-iadd-version:             1.2.2+version:             1.2.3 synopsis:            A terminal UI as drop-in replacement for hledger add description:         This is a terminal UI as drop-in replacement for hledger add.                      .@@ -26,7 +26,7 @@ license-file:        LICENSE author:              Hans-Peter Deifel <hpd@hpdeifel.de> maintainer:          Hans-Peter Deifel <hpd@hpdeifel.de>-copyright:           2016 Hans-Peter Deifel+copyright:           2017 Hans-Peter Deifel category:            Finance, Console build-type:          Simple cabal-version:       >=1.10@@ -56,11 +56,12 @@                      , Brick.Widgets.Edit.EmacsBindings   default-language:    Haskell2010   build-depends:       base >= 4.8 && < 5-                     , hledger-lib >= 1.0 && < 1.3-                     , brick >= 0.19 && < 0.20+                     , hledger-lib >= 1.0 && < 1.4+                     , brick >= 0.17 && < 0.21                      , vty >= 5.4                      , text                      , microlens+                     , microlens-th                      , text-zipper >= 0.10                      , transformers >= 0.3                      , time >= 1.5@@ -81,8 +82,8 @@   default-language:    Haskell2010   build-depends:       base >= 4.8 && < 5                      , hledger-iadd-                     , hledger-lib >= 1.0 && < 1.3-                     , brick >= 0.19 && < 0.20+                     , hledger-lib >= 1.0 && < 1.4+                     , brick >= 0.17 && < 0.21                      , vty >= 5.4                      , text                      , microlens@@ -110,7 +111,7 @@   default-language:   Haskell2010   build-depends:      base >= 4.8 && < 5                     , hledger-iadd-                    , hledger-lib >= 1.0 && < 1.3+                    , hledger-lib >= 1.0 && < 1.4                     , text                     , transformers >= 0.3                     , time >= 1.5
src/Brick/Widgets/CommentDialog.hs view
@@ -12,7 +12,6 @@ import           Data.Monoid  import           Brick-import           Brick.Widgets.Edit hiding (handleEditorEvent) import           Brick.Widgets.Dialog import           Brick.Widgets.Center import           Data.Text.Zipper@@ -24,7 +23,7 @@  data CommentWidget n = CommentWidget   { origComment :: Text-  , textArea :: Editor Text n+  , textArea :: Editor n   , dialogWidget :: Dialog ()   , promptPrefix :: Text   }@@ -35,7 +34,7 @@     title = "ESC: cancel, RET: accept, Alt-RET: New line"     maxWidth = 80     diag = dialog (Just title) Nothing maxWidth-    edit = editorText name Nothing comment+    edit = editorText name (txt . T.unlines) Nothing comment   in     CommentWidget       { origComment = comment@@ -62,9 +61,8 @@ renderCommentWidget widget =   let     height = min (length (getEditContents (textArea widget)) + 4) 24-    drawer = txt . T.unlines     textArea' =  padTop (Pad 1) $-      txt (promptPrefix widget <> ": ") <+> renderEditor drawer True (textArea widget)+      txt (promptPrefix widget <> ": ") <+> renderEditor True (textArea widget)   in     vCenterLayer $ vLimit height $ renderDialog (dialogWidget widget) textArea' 
src/Brick/Widgets/Edit/EmacsBindings.hs view
@@ -1,21 +1,62 @@+{-# LANGUAGE TemplateHaskell, CPP #-}+ -- | Widget like "Brick.Widgets.Edit", but with more emacs style keybindings. --+-- This is also a complete wrapper around the "Brick.Widgets.Edit" API to retain+-- compatability with older brick versions.+-- -- See 'handleEditorEvent' for a list of added keybindings. module Brick.Widgets.Edit.EmacsBindings-  ( handleEditorEvent-  , module Brick.Widgets.Edit+  ( Editor+  , editorText+  , getEditContents+  , applyEdit+  , editContentsL+  , handleEditorEvent+  , renderEditor   ) where  import           Brick import           Graphics.Vty import qualified Brick.Widgets.Edit as E-import           Brick.Widgets.Edit hiding (handleEditorEvent) import           Data.Text.Zipper-import           Data.Text.Zipper.Generic (GenericTextZipper)+import           Data.Text (Text)+import           Lens.Micro.TH+import           Lens.Micro  import           Data.Text.Zipper.Generic.Words --- | Same as 'E.handleEditorEvent', but with more emacs-style keybindings+-- | Wrapper around 'E.Editor', but specialized to 'Text'+data Editor n = Editor {+  _origEditor :: E.Editor Text n,+  _drawingFunction :: [Text] -> Widget n+}++makeLenses ''Editor++-- | Wrapper for 'E.editorText' specialized to 'Text'+editorText :: n -> ([Text] -> Widget n)-> Maybe Int -> Text -> Editor n+editorText name draw linum content =+#if MIN_VERSION_brick(0,19,0)+  Editor (E.editorText name linum content) draw+#else+  Editor (E.editorText name draw linum content) draw+#endif++-- | Wrapper for 'E.getEditContents' specialized to 'Text'+getEditContents :: Editor n -> [Text]+getEditContents edit = edit ^. origEditor . to E.getEditContents++-- | Wrapper for 'E.applyEdit' specialized to 'Text'+applyEdit :: (TextZipper Text -> TextZipper Text) -> Editor n -> Editor n+applyEdit f = over origEditor (E.applyEdit f)++-- | Wrapper for 'E.editContentsL' specialized to 'Text'+editContentsL :: Lens (Editor n) (Editor n) (TextZipper Text) (TextZipper Text)+editContentsL = origEditor . E.editContentsL++-- | Same as 'E.handleEditorEvent', but with more emacs-style keybindings and+-- specialized to 'Text' -- -- Specifically: --@@ -26,7 +67,7 @@ --  - Alt-Backspace: Delete the previous word --  - Ctrl-w: Delete the previous word --  - Alt-d: Delete the next word-handleEditorEvent :: (Eq t, GenericTextZipper t) => Event -> Editor t n -> EventM n (Editor t n)+handleEditorEvent :: Event -> Editor n -> EventM n (Editor n) handleEditorEvent event edit = case event of   EvKey (KChar 'f') [MCtrl] -> return $ applyEdit moveRight edit   EvKey (KChar 'b') [MCtrl] -> return $ applyEdit moveLeft edit@@ -41,4 +82,16 @@   EvKey KHome       []      -> return $ applyEdit gotoBOL edit   EvKey KEnd        []      -> return $ applyEdit gotoEOL edit -  _ -> E.handleEditorEvent event edit+  _ -> do+    newOrig <- E.handleEditorEvent event (edit^.origEditor)+    return $ edit & origEditor .~ newOrig+++-- | Wrapper for 'E.renderEditor' specialized to 'Text'+renderEditor :: (Ord n, Show n) => Bool -> Editor n -> Widget n+renderEditor focus edit =+#if MIN_VERSION_brick(0,19,0)+  E.renderEditor (edit^.drawingFunction) focus (edit^.origEditor)+#else+  E.renderEditor focus (edit^.origEditor)+#endif
src/Brick/Widgets/WrappedText.hs view
@@ -1,3 +1,4 @@+-- | TODO Use the built-in wrapping feature in brick-0.20 module Brick.Widgets.WrappedText (wrappedText) where  import           Brick
src/main/Main.hs view
@@ -49,7 +49,7 @@ import qualified Paths_hledger_iadd as Paths  data AppState = AppState-  { asEditor :: Editor Text Name+  { asEditor :: Editor Name   , asStep :: Step   , asJournal :: HL.Journal   , asContext :: List Name Text@@ -118,7 +118,7 @@           <=> (viewQuestion (asStep as)                <+> viewSuggestion (asSuggestion as)                <+> txt ": "-               <+> renderEditor (txt . T.concat) True (asEditor as))+               <+> renderEditor True (asEditor as))           <=> hBorder           <=> expand (viewContext (asContext as))           <=> hBorder@@ -314,10 +314,10 @@   , (helpAttr <> "title", fg green)   ] -clearEdit :: Editor Text n -> Editor Text n+clearEdit :: Editor n -> Editor n clearEdit = setEdit "" -setEdit :: Text -> Editor Text n -> Editor Text n+setEdit :: Text -> Editor n -> Editor n setEdit content edit = edit & editContentsL .~ zipper   where zipper = gotoEOL (textZipper [content] (Just 1)) @@ -501,7 +501,7 @@   runExceptT (HL.parseAndFinaliseJournal HL.journalp True path journalContents) >>= \case     Left err -> hPutStrLn stderr err >> exitFailure     Right journal -> do-      let edit = editor EditorName (Just 1) ""+      let edit = editorText EditorName (txt . T.concat) (Just 1) ""        sugg <- suggest journal date (DateQuestion "") 
tests/ModelSpec.hs view
@@ -148,18 +148,10 @@   foldl (\j t -> HL.addTransaction (mkTransaction t) j) HL.nulljournal transactions  mkTransaction :: (Date, Text, [(Text, Int)]) -> HL.Transaction-mkTransaction ((year,month,day), desc, postings) = HL.Transaction-  { HL.tindex = 0-  , HL.tsourcepos = undefined-  , HL.tdate = fromGregorian year month day-  , HL.tdate2 = Nothing-  , HL.tstatus = HL.Uncleared-  , HL.tcode = ""+mkTransaction ((year,month,day), desc, postings) = HL.nulltransaction+  { HL.tdate = fromGregorian year month day   , HL.tdescription = desc-  , HL.tcomment = ""-  , HL.ttags = []   , HL.tpostings = map mkPosting postings-  , HL.tpreceding_comment_lines = ""   }    where