-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | A pager for grep -- -- vgrep is a pager for navigating through grep output. -- -- Usage: -- --
--   grep -rn foo | vgrep
--   vgrep foo /some/path
--   vgrep foo /some/path | vgrep bar
--   
-- -- Use hjkl or arrow keys to navigate, Enter to view -- file, q to quit. -- @package vgrep @version 0.2.2.0 -- | A transactional priority queue, based on a Finger Tree. module Control.Concurrent.STM.TPQueue -- | TPQueue is an unbounded priority queue based on a Finger Tree. data TPQueue k v -- | Build a new TPQueue. newTPQueue :: Ord k => STM (TPQueue k v) -- | IO version of newTPQueue. This is useful for creating top-level -- TPQueues using unsafePerformIO, because using -- atomically inside unsafePerformIO isn't possible. newTPQueueIO :: Ord k => IO (TPQueue k v) -- | Write a value to a TPQueue. writeTPQueue :: Ord k => TPQueue k v -> k -> v -> STM () -- | Read the next minimal value from a TPQueue. readTPQueue :: Ord k => TPQueue k v -> STM v -- | A version of readTPQueue that does not retry, but returns -- Nothing instead if no value is available. tryReadTPQueue :: Ord k => TPQueue k v -> STM (Maybe v) -- | Get the next minimal value from a TPQueue without removing it. peekTPQueue :: Ord k => TPQueue k v -> STM v -- | A version of peekTPQueue that does not retry, but returns -- Nothing instead if no value is available. tryPeekTPQueue :: Ord k => TPQueue k v -> STM (Maybe v) -- | Returns True if the TPQueue is empty. isEmptyTPQueue :: Ord k => TPQueue k v -> STM Bool module Control.Lens.Compat -- | Build an (index-preserving) Getter from an arbitrary Haskell -- function. See Control.Lens.to for details. -- -- In lens-4.14, the constraint Functor f is -- missing from the definition of to. When compiling with GHC 8.0, -- this leads to warnings for definitions like -- --
--   foo :: Getter Bar Foo
--   foo = to fooFromBar
--   
-- -- because of the redundant Functor f constraint. This -- definition is identical to Control.Lens.to except for -- the additional constraint Functor f. to :: (Profunctor p, Functor f, Contravariant f) => (s -> a) -> Optic' p f s a module Control.Monad.State.Extended liftState :: MonadState s m => State s a -> m a whenS :: MonadState s m => (s -> Bool) -> m () -> m () unlessS :: MonadState s m => (s -> Bool) -> m () -> m () -- | A variant of Pipes.Concurrent that uses a Finger Tree-based -- Priority Queue (TPQueue) instead of a normal TQueue. module Pipes.Concurrent.PQueue -- | Spawn a mailbox to store prioritized messages in a Mailbox. Using -- recv on the Input will return Just the minimal -- element, or Nothing if the mailbox is closed. -- -- This function is analogous to -- Pipes.Concurrent.spawn' Unbounded, but -- it uses a TPQueue instead of a TQueue to store messages. spawn :: Ord p => IO (Output (p, a), Input a, STM ()) -- | withSpawn passes its enclosed action an Output and -- Input like you'd get from spawn, but automatically -- seals them after the action completes. This can be used when -- you need the sealing behavior available from spawn, -- but want to work at a bit higher level: -- --
--   withSpawn buffer $ \(output, input) -> ...
--   
-- -- withSpawn is exception-safe, since it uses bracket -- internally. withSpawn :: Ord p => ((Output (p, a), Input a) -> IO r) -> IO r -- | An exhaustible source of values -- -- recv returns Nothing if the source is exhausted newtype Input a :: * -> * Input :: STM Maybe a -> Input a [recv] :: Input a -> STM Maybe a -- | An exhaustible sink of values -- -- send returns False if the sink is exhausted newtype Output a :: * -> * Output :: (a -> STM Bool) -> Output a [send] :: Output a -> a -> STM Bool -- | Convert an Input to a Producer -- -- fromInput terminates when the Input is exhausted. fromInput :: MonadIO m => Input a -> Producer' a m () -- | Convert an Output to a Consumer -- -- toOutput terminates when the Output is exhausted. toOutput :: MonadIO m => Output a -> Consumer' a m () module Vgrep.Ansi.Type -- | A representattion of formatted Text. The attribute is usually a -- Monoid so that different formattings can be combined by nesting -- them. data Formatted attr -- | An empty block Empty :: Formatted attr -- | A bare (unformatted) text node Text :: !Int -> Text -> Formatted attr -- | Adds formatting to a block Format :: !Int -> attr -> (Formatted attr) -> Formatted attr -- | Concatenates several blocks of formatted text Cat :: !Int -> [Formatted attr] -> Formatted attr -- | Type alias for Text formatted with Attr from -- Graphics.Vty. type AnsiFormatted = Formatted Attr -- | Smart constructor for an empty Formatted text. emptyFormatted :: Formatted attr -- | Smart constructor for bare (unformatted) text. -- --
--   >>> bare ""
--   Empty
--   
-- --
--   >>> bare "Text"
--   Text 4 "Text"
--   
bare :: Text -> Formatted attr -- | Adds formatting to a Formatted text. The Eq and -- Monoid instances for attr are used to flatten -- redundant formattings. -- --
--   >>> format (Just ()) (format Nothing (bare "Text"))
--   Format 4 (Just ()) (Text 4 "Text")
--   
-- --
--   >>> format (Just ()) (format (Just ()) (bare "Text"))
--   Format 4 (Just ()) (Text 4 "Text")
--   
-- --
--   >>> format Nothing (bare "Text")
--   Text 4 "Text"
--   
format :: (Eq attr, Monoid attr) => attr -> Formatted attr -> Formatted attr -- | Concatenates pieces of Formatted text. Redundant formattings -- and blocks of equal formatting are fused together. cat :: (Eq attr, Monoid attr) => [Formatted attr] -> Formatted attr -- | Apply a function to each piece of text in the Formatted tree. -- --
--   >>> mapText T.toUpper (Cat 11 [Text 6 "Hello ", Format 5 () (Text 5 "World")])
--   Cat 11 [Text 6 "HELLO ",Format 5 () (Text 5 "WORLD")]
--   
mapText :: (Text -> Text) -> Formatted a -> Formatted a -- | Like mapText, but passes the position of the text chunk to the -- function as well. Can be used for formatting text -- position-dependently, e.g. for expanding tabs to spaces. mapTextWithPos :: (Int -> Text -> Text) -> Formatted a -> Formatted a -- | Crops the text to a given length. If the text is already shorter than -- the desired width, it is returned as-is. takeFormatted :: Int -> Formatted a -> Formatted a -- | Drops a prefix of the given length. If the text is already shorter -- than the number of characters to be dropped, emptyFormatted is -- returned. dropFormatted :: Int -> Formatted a -> Formatted a -- | Pads the text to a given width. If the text is already longer than the -- desired width, it is returned as-is. padFormatted :: Int -> Char -> Formatted a -> Formatted a -- | Simplifies Formatted text by leaving out redundant empty bits, -- joining pieces of text with the same formatting, and flattening -- redundant applications of the same style. -- --
--   >>> emptyFormatted `fuse` bare "Text"
--   Text 4 "Text"
--   
-- --
--   >>> format (Just ()) (bare "Left") `fuse` format (Just ()) (bare "Right")
--   Format 9 (Just ()) (Text 9 "LeftRight")
--   
fuse :: (Eq attr, Monoid attr) => Formatted attr -> Formatted attr -> Formatted attr instance GHC.Show.Show attr => GHC.Show.Show (Vgrep.Ansi.Type.Formatted attr) instance GHC.Classes.Eq attr => GHC.Classes.Eq (Vgrep.Ansi.Type.Formatted attr) instance GHC.Base.Functor Vgrep.Ansi.Type.Formatted instance (GHC.Classes.Eq attr, GHC.Base.Monoid attr) => GHC.Base.Monoid (Vgrep.Ansi.Type.Formatted attr) module Vgrep.Ansi.Parser -- | Directly parses ANSI formatted text using ansiFormatted. -- -- 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, 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), 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, 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, attrURL = KeepCurrent}) (Text 3 "bar")]
--   
parseAnsi :: Text -> AnsiFormatted -- | Parser for ANSI formatted text. Recognized escape sequences are the -- SGR (Select Graphic Rendition) sequences (ESC[…m) supported -- by Attr. Unsupported SGR sequences and other CSI escape -- sequences (ESC[…) are ignored. Other (non-CSI) escape -- sequences are not parsed, and included in the output. -- -- This parser does not fail, it will rather consume and return the -- remaining input as unformatted text. ansiFormatted :: Parser AnsiFormatted -- | Parser for ANSI CSI escape sequences. Recognized escape sequences are -- the SGR (Select Graphic Rendition) sequences (ESC[…m) -- supported by Attr. Unsupported SGR sequences and other CSI -- escape sequences (ESC[…) are ignored by returning id. -- -- This parser fails when encountering any other (non-CSI) escape -- sequence. attrChange :: Parser (Attr -> Attr) module Vgrep.Ansi.Vty.Attributes -- | A display attribute defines the Color and Style of all the characters -- rendered after the attribute is applied. -- -- At most 256 colors, picked from a 240 and 16 color palette, are -- possible for the background and foreground. The 240 colors and 16 -- colors are points in different palettes. See Color for more -- information. data Attr :: * -- | Combines two Attrs. This differs from mappend from the -- Monoid instance of Attr in that Styles are -- combined rather than overwritten. combineStyles :: Attr -> Attr -> Attr -- | Utilities for printing ANSI formatted text. module Vgrep.Ansi -- | Type alias for Text formatted with Attr from -- Graphics.Vty. type AnsiFormatted = Formatted Attr -- | A representattion of formatted Text. The attribute is usually a -- Monoid so that different formattings can be combined by nesting -- them. data Formatted attr -- | Smart constructor for an empty Formatted text. emptyFormatted :: Formatted attr -- | Smart constructor for bare (unformatted) text. -- --
--   >>> bare ""
--   Empty
--   
-- --
--   >>> bare "Text"
--   Text 4 "Text"
--   
bare :: Text -> Formatted attr -- | Adds formatting to a Formatted text. The Eq and -- Monoid instances for attr are used to flatten -- redundant formattings. -- --
--   >>> format (Just ()) (format Nothing (bare "Text"))
--   Format 4 (Just ()) (Text 4 "Text")
--   
-- --
--   >>> format (Just ()) (format (Just ()) (bare "Text"))
--   Format 4 (Just ()) (Text 4 "Text")
--   
-- --
--   >>> format Nothing (bare "Text")
--   Text 4 "Text"
--   
format :: (Eq attr, Monoid attr) => attr -> Formatted attr -> Formatted attr -- | Concatenates pieces of Formatted text. Redundant formattings -- and blocks of equal formatting are fused together. cat :: (Eq attr, Monoid attr) => [Formatted attr] -> Formatted attr -- | Apply a function to each piece of text in the Formatted tree. -- --
--   >>> mapText T.toUpper (Cat 11 [Text 6 "Hello ", Format 5 () (Text 5 "World")])
--   Cat 11 [Text 6 "HELLO ",Format 5 () (Text 5 "WORLD")]
--   
mapText :: (Text -> Text) -> Formatted a -> Formatted a -- | Like mapText, but passes the position of the text chunk to the -- function as well. Can be used for formatting text -- position-dependently, e.g. for expanding tabs to spaces. mapTextWithPos :: (Int -> Text -> Text) -> Formatted a -> Formatted a -- | Crops the text to a given length. If the text is already shorter than -- the desired width, it is returned as-is. takeFormatted :: Int -> Formatted a -> Formatted a -- | Drops a prefix of the given length. If the text is already shorter -- than the number of characters to be dropped, emptyFormatted is -- returned. dropFormatted :: Int -> Formatted a -> Formatted a -- | Pads the text to a given width. If the text is already longer than the -- desired width, it is returned as-is. padFormatted :: Int -> Char -> Formatted a -> Formatted a -- | Converts ANSI formatted text to an Image. Nested formattings -- are combined with combineStyles. The given Attr is used -- as style for the root of the Formatted tree. -- --
--   >>> renderAnsi Vty.defAttr (bare "Text")
--   HorizText "Text"@(Attr {attrStyle = Default, attrForeColor = Default, attrBackColor = Default, attrURL = Default},4,4)
--   
renderAnsi :: Attr -> AnsiFormatted -> Image -- | Strips away all formattings to plain Text. stripAnsi :: Formatted a -> Text module Vgrep.Command data Command -- | Display the pager full-screen DisplayPagerOnly :: Command -- | Display the results list full-screen DisplayResultsOnly :: Command -- | Split screen, focus on pager SplitFocusPager :: Command -- | Split screen, focus on results list SplitFocusResults :: Command -- | Scroll one line up in pager PagerUp :: Command -- | Scroll one line down in pager PagerDown :: Command -- | Scroll one page up in pager PagerPageUp :: Command -- | Scroll one page down in pager PagerPageDown :: Command -- | Scroll half a page up in pager PagerHalfPageUp :: Command -- | Scroll half a page down in pager PagerHalfPageDown :: Command -- | Scroll eight characters left in pager PagerScrollLeft :: Command -- | Scroll eight characters right in pager PagerScrollRight :: Command -- | Move to previous result ResultsUp :: Command -- | Move to next result ResultsDown :: Command -- | Move one page up in results list ResultsPageUp :: Command -- | Move one page down in results list ResultsPageDown :: Command -- | Move to previous result and update pager PrevResult :: Command -- | Move to next result and update pager NextResult :: Command -- | Update pager with currently selected result PagerGotoResult :: Command -- | Open file in external editor and jump to currently selected result OpenFileInEditor :: Command -- | Exit the application Exit :: Command -- | Treat keybinding as if not present, fall back to alternative binding -- (used to override keybindings) Unset :: Command instance GHC.Generics.Generic Vgrep.Command.Command instance GHC.Show.Show Vgrep.Command.Command instance GHC.Classes.Eq Vgrep.Command.Command -- | Basic definitions for Keys, Modifiers, and Chords -- of Keys and Modifiers. We can read key Chords -- from Graphics.Vty EvKey events using fromVty. -- -- This module is intended for qualified import: -- --
--   import qualified Vgrep.Key as Key
--   
-- -- We define our own Key and Mod types rather than using -- Graphics.Vty's Key and Modifier, because it -- simplifies parsing (of keys like Space and Tab, which -- are represented as ' ' and '\t' in -- Graphics.Vty), and because a Set of Mods is -- simpler to check for equality than a list of Modifiers. module Vgrep.Key -- | A chord of keys and modifiers pressed simultaneously. data Chord Chord :: (Set Mod) -> Key -> Chord data Key Char :: Char -> Key Space :: Key Esc :: Key Backspace :: Key Enter :: Key Del :: Key Tab :: Key Left :: Key Right :: Key Up :: Key Down :: Key Home :: Key End :: Key PageUp :: Key PageDown :: Key data Mod Ctrl :: Mod Meta :: Mod Shift :: Mod -- | Reads the key and modifiers from an Event. Non-key events and -- events with unknown keys are mapped to Nothing. fromVty :: Event -> Maybe Chord -- | Build a Chord from a single Key key :: Key -> Chord -- | Add a Modifier to a Chord withModifier :: Chord -> Mod -> Chord instance GHC.Generics.Generic Vgrep.Key.Chord instance GHC.Show.Show Vgrep.Key.Chord instance GHC.Classes.Ord Vgrep.Key.Chord instance GHC.Classes.Eq Vgrep.Key.Chord instance GHC.Generics.Generic Vgrep.Key.Mod instance GHC.Show.Show Vgrep.Key.Mod instance GHC.Classes.Ord Vgrep.Key.Mod instance GHC.Classes.Eq Vgrep.Key.Mod instance GHC.Generics.Generic Vgrep.Key.Key instance GHC.Read.Read Vgrep.Key.Key instance GHC.Show.Show Vgrep.Key.Key instance GHC.Classes.Ord Vgrep.Key.Key instance GHC.Classes.Eq Vgrep.Key.Key module Vgrep.KeybindingMap newtype KeybindingMap KeybindingMap :: Map Chord Command -> KeybindingMap [unKeybindingMap] :: KeybindingMap -> Map Chord Command lookup :: Chord -> KeybindingMap -> Maybe Command fromList :: [(Chord, Command)] -> KeybindingMap instance GHC.Base.Monoid Vgrep.KeybindingMap.KeybindingMap instance GHC.Classes.Eq Vgrep.KeybindingMap.KeybindingMap instance GHC.Show.Show Vgrep.KeybindingMap.KeybindingMap module Vgrep.Environment.Config.Monoid -- | A Monoid for reading partial configs. The ConfigMonoid -- can be converted to an actual Config using -- fromConfigMonoid. -- -- The Monoid consists mostly of 'First a' values, so the most important -- config (the one that overrides all the others) should be read first. data ConfigMonoid ConfigMonoid :: ColorsMonoid -> First Int -> First String -> KeybindingsMonoid -> ConfigMonoid [_mcolors] :: ConfigMonoid -> ColorsMonoid [_mtabstop] :: ConfigMonoid -> First Int [_meditor] :: ConfigMonoid -> First String [_mkeybindings] :: ConfigMonoid -> KeybindingsMonoid -- | A Monoid for reading partial Colors configurations. -- -- Note that the attributes are not merged, but overridden: -- --
--   >>> import Graphics.Vty.Attributes
--   
--   >>> let leftStyle  = defAttr `withStyle` standout
--   
--   >>> let rightStyle = defAttr `withForeColor` black
--   
--   >>> let l = mempty { _mnormal = First (Just leftStyle)}
--   
--   >>> let r = mempty { _mnormal = First (Just rightStyle)}
--   
--   >>> _mnormal (l <> r) == First (Just (leftStyle <> rightStyle))
--   False
--   
--   >>> _mnormal (l <> r) == First (Just leftStyle)
--   True
--   
data ColorsMonoid ColorsMonoid :: First Attr -> First Attr -> First Attr -> First Attr -> First Attr -> First Attr -> ColorsMonoid [_mlineNumbers] :: ColorsMonoid -> First Attr [_mlineNumbersHl] :: ColorsMonoid -> First Attr [_mnormal] :: ColorsMonoid -> First Attr [_mnormalHl] :: ColorsMonoid -> First Attr [_mfileHeaders] :: ColorsMonoid -> First Attr [_mselected] :: ColorsMonoid -> First Attr -- | A Monoid for reading a partial Keybindings -- configuration. -- -- Mappings are combined using left-biased union: -- --
--   >>> let l = Just (KeybindingMap (fromList [(Key.Chord mempty Key.Down, ResultsDown), (Key.Chord mempty Key.Up, ResultsUp)]))
--   
--   >>> let r = Just (KeybindingMap (fromList [(Key.Chord mempty Key.Down, PagerDown)]))
--   
--   >>> l <> r
--   Just (KeybindingMap {unKeybindingMap = fromList [(Chord (fromList []) Up,ResultsUp),(Chord (fromList []) Down,ResultsDown)]})
--   
--   >>> r <> l
--   Just (KeybindingMap {unKeybindingMap = fromList [(Chord (fromList []) Up,ResultsUp),(Chord (fromList []) Down,PagerDown)]})
--   
-- -- In particular, Just (fromList []) (declaring an -- empty list of mappings) and Nothing (not declaring -- anything) are equivalent, given that there are already default -- mappings: -- --
--   >>> l <> Just (KeybindingMap (fromList [])) == l <> Nothing
--   True
--   
-- -- This means that new keybindings override the previous ones if they -- collide, otherwise they are simply added. To remove a keybinding, it -- has to be mapped to Unset explicitly. data KeybindingsMonoid KeybindingsMonoid :: Maybe KeybindingMap -> Maybe KeybindingMap -> Maybe KeybindingMap -> KeybindingsMonoid [_mresultsKeybindings] :: KeybindingsMonoid -> Maybe KeybindingMap [_mpagerKeybindings] :: KeybindingsMonoid -> Maybe KeybindingMap [_mglobalKeybindings] :: KeybindingsMonoid -> Maybe KeybindingMap instance GHC.Generics.Generic Vgrep.Environment.Config.Monoid.ConfigMonoid instance GHC.Show.Show Vgrep.Environment.Config.Monoid.ConfigMonoid instance GHC.Classes.Eq Vgrep.Environment.Config.Monoid.ConfigMonoid instance GHC.Generics.Generic Vgrep.Environment.Config.Monoid.KeybindingsMonoid instance GHC.Show.Show Vgrep.Environment.Config.Monoid.KeybindingsMonoid instance GHC.Classes.Eq Vgrep.Environment.Config.Monoid.KeybindingsMonoid instance GHC.Generics.Generic Vgrep.Environment.Config.Monoid.ColorsMonoid instance GHC.Show.Show Vgrep.Environment.Config.Monoid.ColorsMonoid instance GHC.Classes.Eq Vgrep.Environment.Config.Monoid.ColorsMonoid instance GHC.Base.Monoid Vgrep.Environment.Config.Monoid.ConfigMonoid instance GHC.Base.Monoid Vgrep.Environment.Config.Monoid.KeybindingsMonoid instance GHC.Base.Monoid Vgrep.Environment.Config.Monoid.ColorsMonoid module Vgrep.Environment.Config.Sources.File -- | Reads the configuration from a JSON or YAML file. The file should be -- located in one of the following places: -- -- -- -- When none of these files exist, no error is raised. When a file -- exists, but cannot be parsed, a warning is written to stderr. -- -- Supported formats are JSON and YAML. The example YAML config given in -- the project directory (config.yaml.example) is equivalent to -- the default config: -- --
--   >>> import qualified Vgrep.Environment.Config as C
--   
--   >>> Right config <- decodeFileEither "config.yaml.example" :: IO (Either ParseException ConfigMonoid)
--   
--   >>> C.fromConfigMonoid config == C.defaultConfig
--   True
--   
-- -- Example YAML config file for defaultConfig: -- --
--   colors:
--     line-numbers:
--       fore-color: blue
--     line-numbers-hl:
--       fore-color: blue
--       style: bold
--     normal: {}
--     normal-hl:
--       style: bold
--     file-headers:
--       back-color: green
--     selected:
--       style: standout
--   tabstop: 8
--   editor: "vi"
--   
-- -- Example JSON file for the same config: -- --
--   {
--     "colors": {
--       "line-numbers" : {
--         "fore-color": "blue"
--       },
--       "line-numbers-hl": {
--         "fore-color": "blue",
--         "style": "bold"
--       },
--       "normal": {},
--       "normal-hl": {
--         "style": "bold"
--       },
--       "file-headers": {
--         "back-color": "green"
--       },
--       "selected": {
--         "style": "standout"
--       }
--     },
--     "tabstop": 8,
--     "editor": "vi"
--   }
--   
-- -- The JSON/YAML keys correspond to the lenses in -- Vgrep.Environment.Config, the values for Color and -- Style can be obtained from the corresponding predefined -- constants in Graphics.Vty.Attributes. configFromFile :: MonadIO io => io ConfigMonoid -- | A JSON-parsable data type for Attr. -- -- JSON example: -- --
--   >>> decodeEither "{\"fore-color\": \"black\", \"style\": \"standout\"}" :: Either String Attr
--   Right (Attr {foreColor = Just Black, backColor = Nothing, style = Just Standout})
--   
-- -- JSON example without quotes: >>> decodeEither "{fore-color: -- black, style: standout}" :: Either String Attr Right (Attr {foreColor -- = Just Black, backColor = Nothing, style = Just Standout}) -- -- YAML example: -- --
--   >>> :{
--   
--   >>> decodeEither
--   
--   >>> $  "fore-color: \"blue\"\n"
--   
--   >>> <> "back-color: \"bright-blue\"\n"
--   
--   >>> <> "style: \"reverse-video\"\n"
--   
--   >>> :: Either String Attr
--   
--   >>> :}
--   Right (Attr {foreColor = Just Blue, backColor = Just BrightBlue, style = Just ReverseVideo})
--   
-- -- YAML example without quotes: -- --
--   >>> :{
--   
--   >>> decodeEither
--   
--   >>> $  "fore-color: blue\n"
--   
--   >>> <> "back-color: bright-blue\n"
--   
--   >>> <> "style: reverse-video\n"
--   
--   >>> :: Either String Attr
--   
--   >>> :}
--   Right (Attr {foreColor = Just Blue, backColor = Just BrightBlue, style = Just ReverseVideo})
--   
-- -- An empty JSON/YAML object yields the default colors: -- --
--   >>> decodeEither "{}" :: Either String Attr
--   Right (Attr {foreColor = Nothing, backColor = Nothing, style = Nothing})
--   
data Attr -- | A JSON-parsable data type for Color. -- --
--   >>> decodeEither "[\"black\",\"red\",\"bright-black\"]" :: Either String [Color]
--   Right [Black,Red,BrightBlack]
--   
-- -- Also works without quotes: -- --
--   >>> decodeEither "[black,red,bright-black]" :: Either String [Color]
--   Right [Black,Red,BrightBlack]
--   
-- -- Fails with error message if the Color cannot be parsed: -- --
--   >>> let Left err = decodeEither "foo" :: Either String Color
--   
--   >>> "The key \"foo\" was not found" `isInfixOf` err
--   True
--   
data Color -- | A JSON-parsable data type for Style. -- --
--   >>> decodeEither "[\"standout\", \"underline\", \"bold\"]" :: Either String [Style]
--   Right [Standout,Underline,Bold]
--   
-- -- Also works without quotes: -- --
--   >>> decodeEither "[standout, underline, bold]" :: Either String [Style]
--   Right [Standout,Underline,Bold]
--   
-- -- Fails with error message if the Style cannot be parsed: -- --
--   >>> let Left err = decodeEither "foo" :: Either String Style
--   
--   >>> "The key \"foo\" was not found" `isInfixOf` err
--   True
--   
data Style instance GHC.Generics.Generic Vgrep.Environment.Config.Sources.File.Attr instance GHC.Show.Show Vgrep.Environment.Config.Sources.File.Attr instance GHC.Classes.Eq Vgrep.Environment.Config.Sources.File.Attr instance GHC.Generics.Generic Vgrep.Environment.Config.Sources.File.Style instance GHC.Show.Show Vgrep.Environment.Config.Sources.File.Style instance GHC.Classes.Eq Vgrep.Environment.Config.Sources.File.Style instance GHC.Generics.Generic Vgrep.Environment.Config.Sources.File.Color instance GHC.Show.Show Vgrep.Environment.Config.Sources.File.Color instance GHC.Classes.Eq Vgrep.Environment.Config.Sources.File.Color instance Data.Aeson.Types.FromJSON.FromJSON Vgrep.Environment.Config.Sources.File.Attr instance Data.Aeson.Types.FromJSON.FromJSON Vgrep.Environment.Config.Sources.File.Style instance Data.Aeson.Types.FromJSON.FromJSON Vgrep.Environment.Config.Sources.File.Color instance Data.Aeson.Types.FromJSON.FromJSON Vgrep.Environment.Config.Monoid.ConfigMonoid instance Data.Aeson.Types.FromJSON.FromJSON Vgrep.Environment.Config.Monoid.ColorsMonoid instance Data.Aeson.Types.FromJSON.FromJSON Graphics.Vty.Attributes.Attr instance Data.Aeson.Types.FromJSON.FromJSON Vgrep.Environment.Config.Monoid.KeybindingsMonoid instance Data.Aeson.Types.FromJSON.FromJSON Vgrep.Command.Command instance Data.Aeson.Types.FromJSON.FromJSON Vgrep.KeybindingMap.KeybindingMap module Vgrep.Environment.Config.Sources.Env -- | Determines the ConfigMonoid value for _editor -- (_meditor) from the environment variable $EDITOR. editorConfigFromEnv :: MonadIO io => io ConfigMonoid module Vgrep.Environment.Config.Sources module Vgrep.Environment.Config data Config Config :: Colors -> Int -> String -> Keybindings -> Config -- | Color configuration [_colors] :: Config -> Colors -- | Tabstop width (default: 8) [_tabstop] :: Config -> Int -- | Executable for e key (default: environment variable -- $EDITOR, or vi if $EDITOR is not set) [_editor] :: Config -> String [_keybindings] :: Config -> Keybindings data Colors Colors :: Attr -> Attr -> Attr -> Attr -> Attr -> Attr -> Colors -- | Line numbers (default: blue) [_lineNumbers] :: Colors -> Attr -- | Highlighted line numbers (default: bold blue) [_lineNumbersHl] :: Colors -> Attr -- | Normal text (default: terminal default) [_normal] :: Colors -> Attr -- | Highlighted text (default: bold) [_normalHl] :: Colors -> Attr -- | File names in results view (default: terminal default color on green -- background) [_fileHeaders] :: Colors -> Attr -- | Selected entry (default: terminal default, inverted) [_selected] :: Colors -> Attr data Keybindings Keybindings :: KeybindingMap -> KeybindingMap -> KeybindingMap -> Keybindings -- | Keybindings in effect when results list is focused. [_resultsKeybindings] :: Keybindings -> KeybindingMap -- | Keybindings in effect when pager is focused. [_pagerKeybindings] :: Keybindings -> KeybindingMap -- | Global keybindings are in effect both for pager and results list, but -- can be overridden by either one. [_globalKeybindings] :: Keybindings -> KeybindingMap tabstop :: Lens' Config Int keybindings :: Lens' Config Keybindings editor :: Lens' Config String colors :: Lens' Config Colors selected :: Lens' Colors Attr normalHl :: Lens' Colors Attr normal :: Lens' Colors Attr lineNumbersHl :: Lens' Colors Attr lineNumbers :: Lens' Colors Attr fileHeaders :: Lens' Colors Attr resultsKeybindings :: Lens' Keybindings KeybindingMap pagerKeybindings :: Lens' Keybindings KeybindingMap globalKeybindings :: Lens' Keybindings KeybindingMap -- | Convert a ConfigMonoid to a Config. Missing -- (mempty) values in the ConfigMonoid are -- supplied from the defaultConfig. fromConfigMonoid :: ConfigMonoid -> Config -- | Convert a ColorsMonoid to a Colors config. fromColorsMonoid :: ColorsMonoid -> Colors fromFirst :: a -> First a -> a fromKeybindingsMonoid :: KeybindingsMonoid -> Keybindings defaultConfig :: Config defaultColors :: Colors defaultKeybindings :: Keybindings -- | Gathers ConfigMonoids from various sources and builds a -- Config based on the defaultConfig: -- -- -- -- where the latter ones override the earlier ones. loadConfig :: MonadIO io => ConfigMonoid -> io Config instance GHC.Show.Show Vgrep.Environment.Config.Config instance GHC.Classes.Eq Vgrep.Environment.Config.Config instance GHC.Show.Show Vgrep.Environment.Config.Keybindings instance GHC.Classes.Eq Vgrep.Environment.Config.Keybindings instance GHC.Show.Show Vgrep.Environment.Config.Colors instance GHC.Classes.Eq Vgrep.Environment.Config.Colors module Vgrep.Environment -- | VgrepT actions can read from the environment. data Environment Env :: Config -> Viewport -> Environment -- | External configuration (colors, editor executable, …) [_config] :: Environment -> Config -- | The bounds (width and height) of the display viewport where the -- App or the current Widget is displayed [_viewport] :: Environment -> Viewport -- | The bounds (width and height) of a display viewport. data Viewport Viewport :: Int -> Int -> Viewport [_vpWidth] :: Viewport -> Int [_vpHeight] :: Viewport -> Int config :: Lens' Environment Config viewport :: Lens' Environment Viewport vpHeight :: Lens' Viewport Int vpWidth :: Lens' Viewport Int viewportWidth :: Lens' Environment Int viewportHeight :: Lens' Environment Int instance GHC.Show.Show Vgrep.Environment.Environment instance GHC.Classes.Eq Vgrep.Environment.Environment instance GHC.Show.Show Vgrep.Environment.Viewport instance GHC.Classes.Eq Vgrep.Environment.Viewport module Vgrep.Event -- | The type of action to be performed on an event. data Next a -- | Do not handle the event (fall-through to other event handlers) Skip :: Next a -- | Handle the event by performing an action Continue :: a -> Next a -- | Interrupt the application Interrupt :: Interrupt -> Next a data Redraw -- | Indicates that the state has been changed visibly, so the screen -- should be refreshed. Redraw :: Redraw -- | The state has not changed or the change would not be visible, so -- refreshing the screen is not required. Unchanged :: Redraw data Interrupt -- | Suspend the application and run the action, e. g. invoking an external -- process, then resume the application. Suspend :: (forall m. MonadIO m => Environment -> m ()) -> Interrupt -- | Shut down. Halt :: Interrupt -- | If the lookup returns Just action, then handle it with -- Continue action', otherwise Skip this event -- handler. dispatch :: (e -> Maybe a) -> e -> Next a -- | Special case of dispatch where actions are looked up from a -- map. dispatchMap :: Ord e => Map e a -> e -> Next a instance GHC.Base.Monoid (Vgrep.Event.Next a) instance GHC.Base.Functor Vgrep.Event.Next instance GHC.Base.Monoid Vgrep.Event.Redraw module Vgrep.Results newtype File File :: Text -> File [_fileName] :: File -> Text fileName :: Iso' File Text data LineReference LineReference :: Maybe Int -> AnsiFormatted -> LineReference [_lineNumber] :: LineReference -> Maybe Int [_lineText] :: LineReference -> AnsiFormatted lineNumber :: Lens' LineReference (Maybe Int) lineText :: Lens' LineReference AnsiFormatted data FileLineReference FileLineReference :: File -> LineReference -> FileLineReference [_file] :: FileLineReference -> File [_lineReference] :: FileLineReference -> LineReference file :: Lens' FileLineReference File lineReference :: Lens' FileLineReference LineReference instance GHC.Show.Show Vgrep.Results.FileLineReference instance GHC.Classes.Eq Vgrep.Results.FileLineReference instance GHC.Show.Show Vgrep.Results.LineReference instance GHC.Classes.Eq Vgrep.Results.LineReference instance GHC.Show.Show Vgrep.Results.File instance GHC.Classes.Eq Vgrep.Results.File module Vgrep.Parser -- | Parses lines of Text, skipping lines that are not valid -- grep output. parseGrepOutput :: [Text] -> [FileLineReference] -- | Parses a line of grep output. Returns Nothing if the -- line cannot be parsed. -- -- The output should consist of a file name, line number and the content, -- separated by colons: -- --
--   >>> parseLine "path/to/file:123:foobar"
--   Just (FileLineReference {_file = File {_fileName = "path/to/file"}, _lineReference = LineReference {_lineNumber = Just 123, _lineText = Text 6 "foobar"}})
--   
-- -- Omitting the line number still produces valid output: -- --
--   >>> parseLine "path/to/file:foobar"
--   Just (FileLineReference {_file = File {_fileName = "path/to/file"}, _lineReference = LineReference {_lineNumber = Nothing, _lineText = Text 6 "foobar"}})
--   
-- -- However, an file name must be present: -- --
--   >>> parseLine "foobar"
--   Nothing
--   
-- -- 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, attrURL = KeepCurrent}) (Text 3 "bar"),Text 3 "baz"]}})
--   
parseLine :: Text -> Maybe FileLineReference data FileLineReference -- | Utilities for invoking grep module Vgrep.System.Grep -- | Takes a Text stream and runs it through a grep -- process, returning a stream of results. The original command line -- arguments are passed to the process. grep :: Producer Text IO () -> Producer Text IO () -- | Like grep, but if the input is not prefixed with a file and -- line number, i. e. is not valid grep -nH output, then adds -- -nH (-n: with line number, -H: with file -- name) to the grep command line arguments. grepForApp :: Producer Text IO () -> Producer Text IO () -- | Invokes grep -nH -rI (-n: with line number, -- -H: with file name, -r: recursive, -I: -- ignore binary files) and returns the results as a stream. More -- arguments (e. g. pattern and directory) are taken from the command -- line. recursiveGrep :: Producer Text IO () grepVersion :: Producer Text IO () module Vgrep.Text -- | Expand a list of lines expandForDisplay :: (Functor f, MonadReader Environment m) => f Text -> m (f Text) -- | Expand a single line expandLineForDisplay :: MonadReader Environment m => Text -> m Text -- | Expand an ANSI formatted line expandFormattedLine :: MonadReader Environment m => Formatted a -> m (Formatted a) -- | The VgrepT monad transformer allows reading from the -- Environment and changing the state of the App or a -- Widget. module Vgrep.Type -- | The VgrepT monad transformer is parameterized over the state -- s of a Widget or an App. data VgrepT s m a type Vgrep s = VgrepT s Identity -- | Lift a monadic action to VgrepT. mkVgrepT :: Monad m => (s -> Environment -> m (a, s)) -> VgrepT s m a -- | Pass an initial state and an Environment and reduce a -- VgrepT action to an action in the base monad. runVgrepT :: Monad m => VgrepT s m a -> s -> Environment -> m (a, s) -- | The Environment of VgrepT is not stateful, however it -- can be modified globally. An example is resizing the application by -- changing the display bounds. modifyEnvironment :: Monad m => (Environment -> Environment) -> VgrepT s m () -- | A version of bracket where the action is lifted to -- VgrepT. vgrepBracket :: IO a -> (a -> IO c) -> (a -> VgrepT s IO b) -> VgrepT s IO b -- | Lift a computation from the argument monad to the constructed monad. lift :: MonadTrans t => forall (m :: * -> *) a. Monad m => m a -> t m a -- | Lift a monad morphism from m to n into a monad -- morphism from (t m) to (t n) -- -- The first argument to hoist must be a monad morphism, even -- though the type system does not enforce this hoist :: MFunctor k t => forall (m :: * -> *) (n :: * -> *) (b :: k). Monad m => (forall a. () => m a -> n a) -> t m b -> t n b instance Control.Monad.IO.Class.MonadIO m => Control.Monad.IO.Class.MonadIO (Vgrep.Type.VgrepT s m) instance GHC.Base.Monad m => GHC.Base.Monad (Vgrep.Type.VgrepT s m) instance GHC.Base.Monad m => GHC.Base.Applicative (Vgrep.Type.VgrepT s m) instance GHC.Base.Functor m => GHC.Base.Functor (Vgrep.Type.VgrepT s m) instance GHC.Base.Monad m => Control.Monad.Reader.Class.MonadReader Vgrep.Environment.Environment (Vgrep.Type.VgrepT s m) instance GHC.Base.Monad m => Control.Monad.State.Class.MonadState s (Vgrep.Type.VgrepT s m) instance Control.Monad.Trans.Class.MonadTrans (Vgrep.Type.VgrepT s) instance Control.Monad.Morph.MFunctor (Vgrep.Type.VgrepT s) instance GHC.Base.Monad m => Control.Lens.Zoom.Zoom (Vgrep.Type.VgrepT s m) (Vgrep.Type.VgrepT t m) s t module Vgrep.App.Internal -- | User events do have higher priority than System events, -- so that the application stays responsive even in case of event queue -- congestion. data EventPriority User :: EventPriority System :: EventPriority -- | We need the viewport in order to initialize the app, which in turn -- will start Vty. To resolve this circular dependency, we start -- once Vty in order to determine the display viewport, and shut -- it down again immediately. viewportHack :: IO Viewport -- | Spawns a thread parallel to the action that listens to Vty -- events and redirects them to the Consumer. withEvThread :: Consumer Event IO () -> Vty -> VgrepT s IO a -> VgrepT s IO a -- | Passes a Vty instance to the action and shuts it down properly -- after the action finishes. The inputFd and outputFd -- handles are connected to /dev/tty (see tty). withVty :: (Vty -> IO a) -> IO a -- | Like withVty, but lifted to VgrepT s IO. withVgrepVty :: (Vty -> VgrepT s IO a) -> VgrepT s IO a -- | Passes two file descriptors for read and write access to -- /dev/tty to the action, and closes them after the action has -- finished. withTty :: (Fd -> IO a) -> IO a -- | Like withTty, but lifted to VgrepT s IO. withVgrepTty :: (Fd -> VgrepT s IO a) -> VgrepT s IO a -- | Opens /dev/tty in Read/Write mode. Should be connected to the -- stdin and stdout of a GUI process (e. g. -- Vty). tty :: IO Fd instance GHC.Enum.Enum Vgrep.App.Internal.EventPriority instance GHC.Classes.Ord Vgrep.App.Internal.EventPriority instance GHC.Classes.Eq Vgrep.App.Internal.EventPriority module Vgrep.App -- | The App type is parameterized over the type e of -- events it handles and the type s of its state. data App e s App :: (forall m. MonadIO m => m s) -> (Event -> e) -> (forall m. MonadIO m => e -> Environment -> s -> Next (VgrepT s m Redraw)) -> (forall m. Monad m => VgrepT s m Picture) -> App e s -- | Creates the initial state for the app. [initialize] :: App e s -> forall m. MonadIO m => m s -- | How to convert an external Event to the App's event [liftEvent] :: App e s -> Event -> e -- | Handles an event, possibly modifying the App's state. -- --
--   handleEvent e s = case e of
--       EvKey KEnter [] -> Continue (pure Unchanged)
--       -- Handles the Enter key, but does nothing.
--   
--       EvKey KUp [] -> Continue (pure Redraw)
--       -- Handles the Up key and triggers a redraw.
--   
--       _otherwise          -> Skip
--       -- Does not handle the event, so other handlers may be invoked.
--   
[handleEvent] :: App e s -> forall m. MonadIO m => e -> Environment -> s -> Next (VgrepT s m Redraw) -- | Creates a Picture to be displayed. May modify the App's state -- (e. g. for resizing). [render] :: App e s -> forall m. Monad m => VgrepT s m Picture -- | Runs runs the event loop until an Interrupt -- Halt is encountered. Events handled with -- Interrupt (Suspend action) will shut down -- Vty, run the action (e. g. invoking an external editor), and -- start Vty again. runApp :: App e s -> Config -> Producer e IO () -> IO s -- | Like runApp, but does not return the final state. runApp_ :: App e s -> Config -> Producer e IO () -> IO () module Vgrep.Widget.HorizontalSplit.Internal -- | The internal state of the split-view widget. Tracks the state of both -- child widgets and the current layout. data HSplit s t HSplit :: s -> t -> Layout -> HSplit s t -- | State of the left widget [_leftWidget] :: HSplit s t -> s -- | State of the right widget [_rightWidget] :: HSplit s t -> t -- | Current layout [_layout] :: HSplit s t -> Layout data Layout LeftOnly :: Layout RightOnly :: Layout Split :: Focus -> Rational -> Layout data Focus FocusLeft :: Focus FocusRight :: Focus leftWidget :: forall s_aVZv t_aVZw s_aW25. Lens (HSplit s_aVZv t_aVZw) (HSplit s_aW25 t_aVZw) s_aVZv s_aW25 rightWidget :: forall s_aVZv t_aVZw t_aW26. Lens (HSplit s_aVZv t_aVZw) (HSplit s_aVZv t_aW26) t_aVZw t_aW26 layout :: forall s_aVZv t_aVZw. Lens' (HSplit s_aVZv t_aVZw) Layout -- | The currently focused child widget -- --
--   >>> view currentWidget $ HSplit { _leftWidget = "foo", _layout = LeftOnly }
--   Left "foo"
--   
currentWidget :: Lens' (HSplit s t) (Either s t) -- | Traverses the left widget if focused -- --
--   >>> has leftWidgetFocused $ HSplit { _layout = LeftOnly }
--   True
--   
-- --
--   >>> has leftWidgetFocused $ HSplit { _layout = RightOnly }
--   False
--   
-- --
--   >>> has leftWidgetFocused $ HSplit { _layout = Split FocusLeft (1 % 2) }
--   True
--   
leftWidgetFocused :: Traversal' (HSplit s t) s -- | Traverses the right widget if focused -- --
--   >>> has rightWidgetFocused $ HSplit { _layout = RightOnly }
--   True
--   
-- --
--   >>> has rightWidgetFocused $ HSplit { _layout = LeftOnly }
--   False
--   
-- --
--   >>> has rightWidgetFocused $ HSplit { _layout = Split FocusRight (1 % 2) }
--   True
--   
rightWidgetFocused :: Traversal' (HSplit s t) t -- | Forms the ratio of two integral numbers. (%) :: Integral a => a -> a -> Ratio a infixl 7 % instance GHC.Classes.Eq Vgrep.Widget.HorizontalSplit.Internal.Layout instance GHC.Classes.Eq Vgrep.Widget.HorizontalSplit.Internal.Focus module Vgrep.Widget.Pager.Internal -- | Keeps track of the lines of text to display, the current scroll -- positions, and the set of highlighted line numbers. data Pager Pager :: Int -> IntMap AnsiFormatted -> Seq Text -> Seq Text -> Pager -- | The current column offset for horizontal scrolling [_column] :: Pager -> Int -- | Set of line numbers that are highlighted (i.e. they contain matches) [_highlighted] :: Pager -> IntMap AnsiFormatted -- | Zipper: Lines above the screen [_above] :: Pager -> Seq Text -- | Zipper: Lines on screen and below [_visible] :: Pager -> Seq Text -- | The number of invisible lines above the screen position :: Getter Pager Int column :: Lens' Pager Int above :: Lens' Pager (Seq Text) visible :: Lens' Pager (Seq Text) highlighted :: Lens' Pager (IntMap AnsiFormatted) instance GHC.Show.Show Vgrep.Widget.Pager.Internal.Pager instance GHC.Classes.Eq Vgrep.Widget.Pager.Internal.Pager module Vgrep.Widget.Results.Internal -- | Results widget state data Results -- | The results list is empty EmptyResults :: Results -- | The structure of the Results buffer is a double Zipper: -- -- Results :: !(Seq FileLineReference) -> !(Seq FileLineReference) -> !FileLineReference -> !(Seq FileLineReference) -> !(Seq FileLineReference) -> Results -- | The file name of the currently selected item currentFileName :: Getter Results (Maybe Text) -- | The line number of the currently selected item currentLineNumber :: Getter Results (Maybe Int) -- | The line numbers with matches in the file of the currentliy selected -- item currentFileResults :: Getter Results (IntMap AnsiFormatted) -- | Append a line to the Results. The line is appended below the -- visible screen, so use showNext to make it visible. feed :: FileLineReference -> Results -> Results -- | Show one more item at the top of the screen if available. showPrev :: Results -> Maybe Results -- | Show one more item at the bottom of the screen if available. showNext :: Results -> Maybe Results -- | Remove the first item from the top of the screen and append it to the -- invisible items above. hidePrev :: Results -> Maybe Results -- | Remove the last item from the bottom of the screen and prepend it to -- the invisible items below. hideNext :: Results -> Maybe Results -- | Move the cursor one item up. moveUp :: Results -> Maybe Results -- | Move the cursor one item down. moveDown :: Results -> Maybe Results -- | Adjust the number of on-screen items to the given height: -- -- resize :: Int -> Results -> Maybe Results -- | Ad-hoc data structure to render the (visible) Results as list -- of lines. data DisplayLine FileHeader :: File -> DisplayLine Line :: LineReference -> DisplayLine SelectedLine :: LineReference -> DisplayLine -- | Converts the visible Results to a list of DisplayLines. -- Each item in the returned list corresponds to a line on the screen. -- -- Each group of Lines that points to the same file is prepended -- with a FileHeader. The item below the cursor becomes a -- SelectedLine. toLines :: Results -> [DisplayLine] -- | The line number of a DisplayLine. Nothing for -- FileHeaders. displayLineNumber :: DisplayLine -> Maybe Int instance GHC.Classes.Eq Vgrep.Widget.Results.Internal.DisplayLine instance GHC.Show.Show Vgrep.Widget.Results.Internal.Results instance GHC.Classes.Eq Vgrep.Widget.Results.Internal.Results module Vgrep.Widget.Type -- | A Widget is a unit that is displayed on the screen. It is -- associated with a mutable state s. It provides an event -- handler with default keybindings and can generate a renderable -- Image. -- -- Widget modules should provide a Widget instance and -- additionally a collection of actions that can be invoked by external -- event handlers: -- --
--   widgetAction :: VgrepT s m Redraw
--   
data Widget s Widget :: s -> (forall m. Monad m => VgrepT s m Image) -> Widget s -- | The initial state of the widget [initialize] :: Widget s -> s -- | Generate a renderable Image from the widget state. The state -- can be modified (e. g. for resizing). [draw] :: Widget s -> forall m. Monad m => VgrepT s m Image data Redraw -- | Indicates that the state has been changed visibly, so the screen -- should be refreshed. Redraw :: Redraw -- | The state has not changed or the change would not be visible, so -- refreshing the screen is not required. Unchanged :: Redraw -- | The type of action to be performed on an event. data Next a -- | Do not handle the event (fall-through to other event handlers) Skip :: Next a -- | Handle the event by performing an action Continue :: a -> Next a -- | Interrupt the application Interrupt :: Interrupt -> Next a module Vgrep.Widget.Results -- | The results widget displays a list of lines with line numbers, grouped -- by files. -- -- resultsWidget :: ResultsWidget type ResultsWidget = Widget Results -- | Results widget state data Results -- | Add a line to the results list. If the result is found in the same -- file as the current last result, it will be added to the same results -- group, otherwise a new group will be opened. feedResult :: Monad m => FileLineReference -> VgrepT Results m Redraw resizeToWindow :: Monad m => VgrepT Results m Redraw -- | Move up/down one results line. File group headers will be skipped. prevLine :: Monad m => VgrepT Results m () -- | Move up/down one results line. File group headers will be skipped. nextLine :: Monad m => VgrepT Results m () -- | Move up/down one results page. File group headers will be skipped. pageUp :: Monad m => VgrepT Results m () -- | Move up/down one results page. File group headers will be skipped. pageDown :: Monad m => VgrepT Results m () -- | The file name of the currently selected item currentFileName :: Getter Results (Maybe Text) -- | The line number of the currently selected item currentLineNumber :: Getter Results (Maybe Int) -- | The line numbers with matches in the file of the currentliy selected -- item currentFileResults :: Getter Results (IntMap AnsiFormatted) module Vgrep.Widget.Pager -- | Display lines of text with line numbers -- -- pagerWidget :: PagerWidget type PagerWidget = Widget Pager -- | Keeps track of the lines of text to display, the current scroll -- positions, and the set of highlighted line numbers. data Pager -- | Scroll to the given line number. moveToLine :: Monad m => Int -> VgrepT Pager m Redraw -- | Scroll up or down one line. -- --
--   scroll (-1)  -- scroll one line up
--   scroll 1     -- scroll one line down
--   
scroll :: Monad m => Int -> VgrepT Pager m Redraw -- | Scroll up or down one page. The first line on the current screen will -- be the last line on the scrolled screen and vice versa. -- --
--   scrollPage (-1)  -- scroll one page up
--   scrollPage 1     -- scroll one page down
--   
scrollPage :: Monad m => Int -> VgrepT Pager m Redraw -- | Scroll up or down a fraction of a page. For integers, -- 'scrollPageFraction n == scrollPage n'. -- --
--   scrollPageFraction (-1%2)            -- scroll one half page up
--   scrollPageFraction (1%2)             -- scroll one half page down
--   scrollPageFraction (fromRational 1)  -- scroll one page down
--   
scrollPageFraction :: Monad m => Rational -> VgrepT Pager m Redraw -- | Horizontal scrolling. Increment is one tabstop. -- --
--   hScroll (-1)  -- scroll one tabstop left
--   hScroll 1     -- scroll one tabstop right
--   
hScroll :: Monad m => Int -> VgrepT Pager m Redraw -- | Replace the currently displayed text. replaceBufferContents :: Monad m => Seq Text -> IntMap AnsiFormatted -> VgrepT Pager m () -- | A split-view widget that displays two widgets side-by-side. module Vgrep.Widget.HorizontalSplit -- | Compose two Widgets side-by-side -- -- hSplitWidget :: Widget s -> Widget t -> HSplitWidget s t type HSplitWidget s t = Widget (HSplit s t) -- | The internal state of the split-view widget. Tracks the state of both -- child widgets and the current layout. data HSplit s t data Focus FocusLeft :: Focus FocusRight :: Focus -- | Display the left widget full-screen leftOnly :: Monad m => VgrepT (HSplit s t) m Redraw -- | Display the right widget full-screen rightOnly :: Monad m => VgrepT (HSplit s t) m Redraw -- | Display both widgets in a split view. splitView :: Monad m => Focus -> Rational -> VgrepT (HSplit s t) m Redraw -- | Switch focus from left to right child widget and vice versa (only if -- the _layout is Split) switchFocus :: Monad m => VgrepT (HSplit s t) m Redraw leftWidget :: forall s_aVZv t_aVZw s_aW25. Lens (HSplit s_aVZv t_aVZw) (HSplit s_aW25 t_aVZw) s_aVZv s_aW25 rightWidget :: forall s_aVZv t_aVZw t_aW26. Lens (HSplit s_aVZv t_aVZw) (HSplit s_aVZv t_aW26) t_aVZw t_aW26 -- | The currently focused child widget -- --
--   >>> view currentWidget $ HSplit { _leftWidget = "foo", _layout = LeftOnly }
--   Left "foo"
--   
currentWidget :: Lens' (HSplit s t) (Either s t) -- | Traverses the left widget if focused -- --
--   >>> has leftWidgetFocused $ HSplit { _layout = LeftOnly }
--   True
--   
-- --
--   >>> has leftWidgetFocused $ HSplit { _layout = RightOnly }
--   False
--   
-- --
--   >>> has leftWidgetFocused $ HSplit { _layout = Split FocusLeft (1 % 2) }
--   True
--   
leftWidgetFocused :: Traversal' (HSplit s t) s -- | Traverses the right widget if focused -- --
--   >>> has rightWidgetFocused $ HSplit { _layout = RightOnly }
--   True
--   
-- --
--   >>> has rightWidgetFocused $ HSplit { _layout = LeftOnly }
--   False
--   
-- --
--   >>> has rightWidgetFocused $ HSplit { _layout = Split FocusRight (1 % 2) }
--   True
--   
rightWidgetFocused :: Traversal' (HSplit s t) t module Vgrep.Widget