vgrep 0.2.1.0 → 0.2.2.0
raw patch · 19 files changed
+56/−49 lines, 19 filesdep ~aesondep ~vty
Dependency ranges changed: aeson, vty
Files
- .travis.yml +11/−9
- CHANGELOG.md +4/−0
- README.md +1/−1
- src/Vgrep/Ansi.hs +1/−1
- src/Vgrep/Ansi/Parser.hs +7/−6
- src/Vgrep/Ansi/Type.hs +4/−4
- src/Vgrep/Ansi/Vty/Attributes.hs +2/−2
- src/Vgrep/App.hs +1/−1
- src/Vgrep/App/Internal.hs +1/−1
- src/Vgrep/Environment/Config.hs +5/−5
- src/Vgrep/Key.hs +1/−1
- src/Vgrep/Parser.hs +1/−1
- src/Vgrep/Widget/HorizontalSplit.hs +1/−1
- src/Vgrep/Widget/Pager.hs +1/−1
- src/Vgrep/Widget/Pager/Internal.hs +3/−3
- stack.yaml +1/−1
- test/Test/Case.hs +5/−5
- test/Test/Vgrep/Widget/Results.hs +4/−4
- vgrep.cabal +2/−2
.travis.yml view
@@ -18,14 +18,15 @@ matrix: fast_finish: true include:- - env: ARGS=""- - env: ARGS="--resolver lts-5"- - env: ARGS="--resolver lts-6"- - env: ARGS="--resolver lts-7"- - env: ARGS="--resolver lts-8"- - env: ARGS="--resolver lts-9"- - env: ARGS="--resolver lts"- - env: ARGS="--resolver nightly"+ - env: ARGS="" SKIP_DOCTESTS=false+ - env: ARGS="--resolver lts" SKIP_DOCTESTS=false+ - env: ARGS="--resolver nightly" SKIP_DOCTESTS=false+ - env: ARGS="--resolver lts-10" SKIP_DOCTESTS=false+ - env: ARGS="--resolver lts-9" SKIP_DOCTESTS=true+ - env: ARGS="--resolver lts-8" SKIP_DOCTESTS=true+ - env: ARGS="--resolver lts-7" SKIP_DOCTESTS=true+ - env: ARGS="--resolver lts-6" SKIP_DOCTESTS=true+ - env: ARGS="--resolver lts-5" SKIP_DOCTESTS=true before_install: # Download and unpack the stack executable@@ -40,7 +41,8 @@ - stack $ARGS --no-terminal build --pedantic # Tests- - stack $ARGS --no-terminal test --pedantic+ - stack $ARGS --no-terminal test --pedantic :vgrep-test+ - $SKIP_DOCTESTS || stack $ARGS --no-terminal test --pedantic :doctest - stack $ARGS --no-terminal haddock --no-haddock-deps - stack $ARGS --no-terminal sdist
CHANGELOG.md view
@@ -1,6 +1,10 @@ Changelog ========= +## v0.2.2++* Add support for aeson 1.2.x to enable build with Stackage LTS 10.x+ ## v0.2.1 * Add support for aeson 1.x to enable build with Stackage LTS 9.x
README.md view
@@ -73,6 +73,6 @@ ``` [1]: https://github.com/fmthoma/vgrep/releases/latest-[2]: https://hackage.haskell.org/packages/vgrep+[2]: https://hackage.haskell.org/package/vgrep [3]: https://github.com/commercialhaskell/stack/blob/master/doc/install_and_upgrade.md [4]: https://github.com/fmthoma/vgrep
src/Vgrep/Ansi.hs view
@@ -32,7 +32,7 @@ -- root of the 'Formatted' tree. -- -- >>> renderAnsi Vty.defAttr (bare "Text")--- HorizText "Text"@(Attr {attrStyle = Default, attrForeColor = Default, attrBackColor = Default},4,4)+-- HorizText "Text"@(Attr {attrStyle = Default, attrForeColor = Default, attrBackColor = Default, attrURL = Default},4,4) -- renderAnsi :: Attr -> AnsiFormatted -> Vty.Image renderAnsi attr = \case
src/Vgrep/Ansi/Parser.hs view
@@ -9,6 +9,7 @@ import Control.Applicative import Data.Attoparsec.Text import Data.Bits+import Data.Functor import Data.Monoid import Data.Text (Text) import qualified Data.Text as T@@ -24,22 +25,22 @@ Parsing ANSI color codes: >>> parseAnsi "Hello \ESC[31mWorld\ESC[m!"-Cat 12 [Text 6 "Hello ",Format 5 (Attr {attrStyle = KeepCurrent, attrForeColor = SetTo (ISOColor 1), attrBackColor = KeepCurrent}) (Text 5 "World"),Text 1 "!"]+Cat 12 [Text 6 "Hello ",Format 5 (Attr {attrStyle = KeepCurrent, attrForeColor = SetTo (ISOColor 1), attrBackColor = KeepCurrent, attrURL = KeepCurrent}) (Text 5 "World"),Text 1 "!"] More elaborate example with nested foreground and background colors: >>> parseAnsi "\ESC[m\ESC[40mHello \ESC[31mWorld\ESC[39m!"-Cat 12 [Format 6 (Attr {attrStyle = KeepCurrent, attrForeColor = KeepCurrent, attrBackColor = SetTo (ISOColor 0)}) (Text 6 "Hello "),Format 5 (Attr {attrStyle = KeepCurrent, attrForeColor = SetTo (ISOColor 1), attrBackColor = SetTo (ISOColor 0)}) (Text 5 "World"),Format 1 (Attr {attrStyle = KeepCurrent, attrForeColor = KeepCurrent, attrBackColor = SetTo (ISOColor 0)}) (Text 1 "!")]+Cat 12 [Format 6 (Attr {attrStyle = KeepCurrent, attrForeColor = KeepCurrent, attrBackColor = SetTo (ISOColor 0), attrURL = KeepCurrent}) (Text 6 "Hello "),Format 5 (Attr {attrStyle = KeepCurrent, attrForeColor = SetTo (ISOColor 1), attrBackColor = SetTo (ISOColor 0), attrURL = KeepCurrent}) (Text 5 "World"),Format 1 (Attr {attrStyle = KeepCurrent, attrForeColor = KeepCurrent, attrBackColor = SetTo (ISOColor 0), attrURL = KeepCurrent}) (Text 1 "!")] Some CSI sequences are ignored, since they are not supported by 'Vty': >>> parseAnsi "\ESC[A\ESC[B\ESC[31mfoo\ESC[1K\ESC[mbar"-Cat 6 [Format 3 (Attr {attrStyle = KeepCurrent, attrForeColor = SetTo (ISOColor 1), attrBackColor = KeepCurrent}) (Text 3 "foo"),Text 3 "bar"]+Cat 6 [Format 3 (Attr {attrStyle = KeepCurrent, attrForeColor = SetTo (ISOColor 1), attrBackColor = KeepCurrent, attrURL = KeepCurrent}) (Text 3 "foo"),Text 3 "bar"] Non-CSI sequences are not parsed, but included in the output: >>> parseAnsi "\ESC]710;font\007foo\ESC[31mbar"-Cat 17 [Text 14 "\ESC]710;font\afoo",Format 3 (Attr {attrStyle = KeepCurrent, attrForeColor = SetTo (ISOColor 1), attrBackColor = KeepCurrent}) (Text 3 "bar")]+Cat 17 [Text 14 "\ESC]710;font\afoo",Format 3 (Attr {attrStyle = KeepCurrent, attrForeColor = SetTo (ISOColor 1), attrBackColor = KeepCurrent, attrURL = KeepCurrent}) (Text 3 "bar")] -} parseAnsi :: Text -> AnsiFormatted@@ -59,7 +60,7 @@ ansiFormatted = go mempty where go :: Attr -> Parser AnsiFormatted- go attr = endOfInput *> pure mempty+ go attr = endOfInput $> mempty <|> formattedText attr formattedText :: Attr -> Parser AnsiFormatted@@ -71,7 +72,7 @@ pure (format attr' (bare t) <> rest) rawText :: Parser Text- rawText = atLeastOneTill (== '\ESC') <|> endOfInput *> pure ""+ rawText = atLeastOneTill (== '\ESC') <|> endOfInput $> "" atLeastOneTill :: (Char -> Bool) -> Parser Text atLeastOneTill = liftA2 T.cons anyChar . takeTill
src/Vgrep/Ansi/Type.hs view
@@ -193,10 +193,10 @@ | amount <= 0 = txt | length txt < amount = emptyFormatted | otherwise = case txt of- Empty -> emptyFormatted- Text _ t -> bare (T.drop amount t)- Format _ attr t -> format' attr (dropFormatted amount t)- Cat _ ts -> cat' (dropChunks amount ts)+ Empty -> emptyFormatted+ Text _ t -> bare (T.drop amount t)+ Format _ attr t -> format' attr (dropFormatted amount t)+ Cat _ ts -> cat' (dropChunks amount ts) where dropChunks n = \case [] -> []
src/Vgrep/Ansi/Vty/Attributes.hs view
@@ -5,13 +5,13 @@ import Data.Bits ((.|.)) import Data.Monoid ((<>))-import Graphics.Vty.Attributes (Attr (..), MaybeDefault (..))+import Graphics.Vty.Attributes (Attr (..), MaybeDefault (..), defAttr) -- | Combines two 'Attr's. This differs from 'mappend' from the 'Monoid' -- instance of 'Attr' in that 'Vty.Style's are combined rather than -- overwritten. combineStyles :: Attr -> Attr -> Attr-combineStyles l r = Attr+combineStyles l r = defAttr { attrStyle = case (attrStyle l, attrStyle r) of (SetTo l', SetTo r') -> SetTo (l' .|. r') (l', r') -> l' <> r'
src/Vgrep/App.hs view
@@ -9,7 +9,7 @@ import Control.Concurrent.Async import Graphics.Vty (Vty) import qualified Graphics.Vty as Vty-import Pipes hiding (next)+import Pipes import Pipes.Concurrent.PQueue import Pipes.Prelude as P
src/Vgrep/App/Internal.hs view
@@ -6,7 +6,7 @@ import Control.Exception import Graphics.Vty (Vty) import qualified Graphics.Vty as Vty-import Pipes hiding (next)+import Pipes import System.Posix.IO import System.Posix.Types (Fd)
src/Vgrep/Environment/Config.hs view
@@ -2,11 +2,11 @@ {-# LANGUAGE TemplateHaskell #-} module Vgrep.Environment.Config where -import Control.Lens.Compat-import Control.Monad.IO.Class-import Data.Maybe-import Data.Monoid-import Graphics.Vty.Attributes+import Control.Lens.Compat+import Control.Monad.IO.Class+import Data.Maybe+import Data.Monoid+import Graphics.Vty.Attributes ( Attr , blue , bold
src/Vgrep/Key.hs view
@@ -21,12 +21,12 @@ , withModifier )where -import Prelude hiding (Left, Right) import Control.Applicative import Data.Set (Set) import qualified Data.Set as S import GHC.Generics import qualified Graphics.Vty.Input.Events as Vty+import Prelude hiding (Left, Right) -- | A chord of keys and modifiers pressed simultaneously.
src/Vgrep/Parser.hs view
@@ -45,7 +45,7 @@ -- ANSI escape codes in the line text are parsed correctly: -- -- >>> parseLine "path/to/file:foo\ESC[31mbar\ESC[mbaz"--- Just (FileLineReference {_file = File {_fileName = "path/to/file"}, _lineReference = LineReference {_lineNumber = Nothing, _lineText = Cat 9 [Text 3 "foo",Format 3 (Attr {attrStyle = KeepCurrent, attrForeColor = SetTo (ISOColor 1), attrBackColor = KeepCurrent}) (Text 3 "bar"),Text 3 "baz"]}})+-- Just (FileLineReference {_file = File {_fileName = "path/to/file"}, _lineReference = LineReference {_lineNumber = Nothing, _lineText = Cat 9 [Text 3 "foo",Format 3 (Attr {attrStyle = KeepCurrent, attrForeColor = SetTo (ISOColor 1), attrBackColor = KeepCurrent, attrURL = KeepCurrent}) (Text 3 "bar"),Text 3 "baz"]}}) -- parseLine :: Text -> Maybe FileLineReference parseLine line = case parseOnly lineParser line of
src/Vgrep/Widget/HorizontalSplit.hs view
@@ -24,7 +24,7 @@ import Control.Applicative (liftA2) import Control.Lens.Compat-import Graphics.Vty.Image hiding (resize)+import Graphics.Vty.Image import Vgrep.Environment import Vgrep.Event
src/Vgrep/Widget/Pager.hs view
@@ -27,7 +27,7 @@ import Data.Text (Text) import qualified Data.Text as T import Graphics.Vty.Attributes-import Graphics.Vty.Image hiding (resize)+import Graphics.Vty.Image import Vgrep.Ansi import Vgrep.Environment
src/Vgrep/Widget/Pager/Internal.hs view
@@ -23,16 +23,16 @@ -- | Keeps track of the lines of text to display, the current scroll -- positions, and the set of highlighted line numbers. data Pager = Pager- { _column :: Int+ { _column :: Int -- ^ The current column offset for horizontal scrolling , _highlighted :: IntMap AnsiFormatted -- ^ Set of line numbers that are highlighted (i.e. they contain matches) - , _above :: Seq Text+ , _above :: Seq Text -- ^ Zipper: Lines above the screen - , _visible :: Seq Text+ , _visible :: Seq Text -- ^ Zipper: Lines on screen and below } deriving (Eq, Show)
stack.yaml view
@@ -1,7 +1,7 @@ # For more information, see: https://github.com/commercialhaskell/stack/blob/release/doc/yaml_configuration.md # Specifies the GHC version and set of packages available (e.g., lts-3.5, nightly-2015-09-21, ghc-7.10.2)-resolver: lts-9.0+resolver: lts-10.7 # Local packages, usually specified by relative directory name packages:
test/Test/Case.hs view
@@ -47,14 +47,14 @@ runTestCase = \case TestProperty {..} -> testProperty description $ do (initialState, initialEnv) <- testData- pure . monadic (`runVgrepForTest` (initialState, initialEnv)) $ do+ pure . monadic (`runVgrepForTest` (initialState, initialEnv)) . void $ do monitor (counterexample (show initialState)) monitor (counterexample (show initialEnv)) params <- testCase stop =<< assertion params TestInvariant {..} -> testProperty description $ do (initialState, initialEnv) <- testData- pure . monadic (`runVgrepForTest` (initialState, initialEnv)) $ do+ pure . monadic (`runVgrepForTest` (initialState, initialEnv)) . void $ do monitor (counterexample (show initialState)) monitor (counterexample (show initialEnv)) before <- use invariant@@ -83,16 +83,16 @@ runVgrepForTest action (s, env) = fst (runIdentity (runVgrepT action s env)) monadicVgrep- :: Arbitrary s+ :: (Arbitrary s, Testable a) => PropertyM (Vgrep s) a -> Gen Property monadicVgrep testcase = do initialState <- arbitrary initialEnv <- arbitrary- pure (monadic (`runVgrepForTest` (initialState, initialEnv)) testcase)+ pure (monadic (`runVgrepForTest` (initialState, initialEnv)) (fmap property testcase)) testPropertyVgrep- :: Arbitrary s+ :: (Arbitrary s, Testable a) => TestName -> PropertyM (Vgrep s) a -> TestTree
test/Test/Vgrep/Widget/Results.hs view
@@ -2,7 +2,7 @@ {-# LANGUAGE LambdaCase #-} module Test.Vgrep.Widget.Results (test) where -import Control.Lens.Compat (Getter, over, to, view, _1)+import Control.Lens.Compat (Getter, over, to, view, (<&>), _1) import Control.Monad (void) import Data.Map.Strict ((!)) import qualified Data.Map.Strict as Map@@ -34,7 +34,7 @@ { description = "Scrolling one page down jumps to end of screen" , testData = arbitrary , testCase = run pageDown- , assertion = const $ get >>= pure . \case+ , assertion = const $ get <&> \case EmptyResults -> True Results _ _ _ ds _ -> null ds }@@ -42,7 +42,7 @@ { description = "Scrolling one page up jumps to start of screen" , testData = arbitrary , testCase = run pageUp- , assertion = const $ get >>= pure . \case+ , assertion = const $ get <&> \case EmptyResults -> True Results _ bs _ _ _ -> null bs }@@ -121,6 +121,6 @@ (linesOnScreen <= height) numberOfLinesOnScreen :: MonadState Results m => m Int-numberOfLinesOnScreen = get >>= pure . \case+numberOfLinesOnScreen = get <&> \case EmptyResults -> 0 Results _ bs c ds _ -> length (mconcat [bs, pure c, ds])
vgrep.cabal view
@@ -1,5 +1,5 @@ name: vgrep-version: 0.2.1.0+version: 0.2.2.0 synopsis: A pager for grep description: @vgrep@ is a pager for navigating through @grep@ output.@@ -70,7 +70,7 @@ , Vgrep.Widget.Results.Internal , Vgrep.Widget.Type build-depends: base >= 4.7 && < 5- , aeson (>= 0.11 && < 1.2) || (>= 0.9 && < 0.10)+ , aeson (>= 0.11 && < 1.3) || (>= 0.9 && < 0.10) , async >= 2.0.2 , attoparsec >= 0.12.1.6 , containers >= 0.5.6.2