vgrep-0.2.2.0: A pager for grep

Safe HaskellNone
LanguageHaskell2010

Vgrep.Widget.Results.Internal

Contents

Synopsis

Results widget state

data Results Source #

Results widget state

Constructors

EmptyResults

The results list is empty

Results !(Seq FileLineReference) !(Seq FileLineReference) !FileLineReference !(Seq FileLineReference) !(Seq FileLineReference)

The structure of the Results buffer is a double Zipper:

  • lines above the current screen
  • lines on screen above the current item
  • the current item
  • lines on screen below the current item
  • lines below the current screen

Lenses

currentFileName :: Getter Results (Maybe Text) Source #

The file name of the currently selected item

currentLineNumber :: Getter Results (Maybe Int) Source #

The line number of the currently selected item

currentFileResults :: Getter Results (IntMap AnsiFormatted) Source #

The line numbers with matches in the file of the currentliy selected item

Actions

In general, actions return Just newResults if the buffer has changed, and Nothing otherwise. This way it is easy to recognize whether or not a Redraw is necessary.

feed :: FileLineReference -> Results -> Results Source #

Append a line to the Results. The line is appended below the visible screen, so use showNext to make it visible.

showPrev :: Results -> Maybe Results Source #

Show one more item at the top of the screen if available.

showNext :: Results -> Maybe Results Source #

Show one more item at the bottom of the screen if available.

hidePrev :: Results -> Maybe Results Source #

Remove the first item from the top of the screen and append it to the invisible items above.

hideNext :: Results -> Maybe Results Source #

Remove the last item from the bottom of the screen and prepend it to the invisible items below.

moveUp :: Results -> Maybe Results Source #

Move the cursor one item up.

moveDown :: Results -> Maybe Results Source #

Move the cursor one item down.

resize Source #

Arguments

:: Int

the new height

-> Results 
-> Maybe Results

Nothing if the height has not changed, Just newResults otherwise

Adjust the number of on-screen items to the given height:

  • If the current list is too long for the new height, take items from the top until the current item is topmost, then from the bottom.
  • If the current list is too short for the new height, add items below until the buffer is empty, then above.

Utilities for displaying

data DisplayLine Source #

Ad-hoc data structure to render the (visible) Results as list of lines.

toLines :: Results -> [DisplayLine] Source #

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.