-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | A pager for grep -- -- Please see README.md @package vgrep @version 0.1.3.0 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 -> Set Int -> Seq Text -> Seq Text -> Pager [_column] :: Pager -> Int [_highlighted] :: Pager -> Set Int [_above] :: Pager -> Seq Text [_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 (Set Int) instance GHC.Show.Show Vgrep.Widget.Pager.Internal.Pager instance GHC.Classes.Eq Vgrep.Widget.Pager.Internal.Pager 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_af70 t_af71 s_afam. Lens (HSplit s_af70 t_af71) (HSplit s_afam t_af71) s_af70 s_afam rightWidget :: forall s_af70 t_af71 t_afan. Lens (HSplit s_af70 t_af71) (HSplit s_af70 t_afan) t_af71 t_afan layout :: forall s_af70 t_af71. Lens' (HSplit s_af70 t_af71) 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.Results
newtype File
File :: Text -> File
[getFileName] :: File -> Text
data LineReference
LineReference :: Maybe Int -> Text -> LineReference
[getLineNumber] :: LineReference -> Maybe Int
[getLineText] :: LineReference -> Text
data FileLineReference
FileLineReference :: File -> LineReference -> FileLineReference
[getFile] :: FileLineReference -> File
[getLineReference] :: 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.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:
--
--
-- >>> parseLine "path/to/file:123:foobar"
-- Just (FileLineReference {getFile = File {getFileName = "path/to/file"}, getLineReference = LineReference {getLineNumber = Just 123, getLineText = "foobar"}})
--
--
-- Omitting the line number still produces valid output:
--
--
-- >>> parseLine "path/to/file:foobar"
-- Just (FileLineReference {getFile = File {getFileName = "path/to/file"}, getLineReference = LineReference {getLineNumber = Nothing, getLineText = "foobar"}})
--
--
-- However, an file name must be present:
--
-- -- >>> parseLine "foobar" -- Nothing --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 () module Vgrep.Environment.Config data Config Config :: Colors -> Int -> String -> 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 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 tabstop :: Lens' Config Int 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 defaultConfig :: Config withConfiguredEditor :: Config -> 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.Colors instance GHC.Classes.Eq Vgrep.Environment.Config.Colors module Vgrep.Environment -- | VgrepT actions can read from the environment. data Environment Env :: Config -> DisplayRegion -> Environment -- | External configuration (colors, editor executable, …) [_config] :: Environment -> Config -- | The bounds (width and height) of the display region where the -- App or the current Widget is displayed [_region] :: Environment -> DisplayRegion config :: Lens' Environment Config region :: Lens' Environment DisplayRegion instance GHC.Show.Show Vgrep.Environment.Environment instance GHC.Classes.Eq Vgrep.Environment.Environment 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.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 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 () -- | 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) hoist :: MFunctor t => forall (m :: * -> *) (n :: * -> *) b. 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 -- | 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 -> 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 -> 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 () -- | Opens devtty read-only. Should be connected to the -- stdin of a GUI process (e. g. Vty). ttyIn :: IO Fd -- | Opens devtty write-only. Should be connected to the -- stdout of a GUI process (e. g. Vty). ttyOut :: IO Fd 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) -> (forall m. Monad m => Event -> s -> Next (VgrepT s m Redraw)) -> 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 -- | The default event handler for this Widget. May provide e.g. -- default keybindings. [handle] :: Widget s -> forall m. Monad m => Event -> s -> Next (VgrepT s m Redraw) 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 -- | A split-view widget that displays two widgets side-by-side. module Vgrep.Widget.HorizontalSplit -- | Compose two Widgets side-by-side -- --
Tab -- switchFocus f full screen (leftOnly / rightOnly) -- q close right widget (leftOnly if right widget is focused) --
-- >>> 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.Pager
-- | Display lines of text with line numbers
--
-- ←↓↑→, hjkl hScroll (-1), -- scroll 1, scroll (-1), hScroll 1 PgUp, PgDn -- scrollPage (-1), scrollPage 1
-- 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 -- | 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 -> [Int] -> VgrepT Pager m () module Vgrep.Widget.Results -- | The results widget displays a list of lines with line numbers, grouped -- by files. -- --
jk, ↓↑ nextLine, -- prevLine PgDn, PgUp pageDown, pageUp