vgrep-0.2.3.0: A pager for grep
Safe HaskellNone
LanguageHaskell2010

Vgrep.Widget.HorizontalSplit

Description

A split-view widget that displays two widgets side-by-side.

Synopsis

Horizontal split view widget

hSplitWidget :: Widget s -> Widget t -> HSplitWidget s t Source #

Compose two Widgets side-by-side

  • Initial state

    Initially, the left widget is rendered full-screen.

  • Drawing the Widgets

    Drawing is delegated to the child widgets in a local environment reduced to thir respective Viewport.

type HSplitWidget s t = Widget (HSplit s t) Source #

Widget state

data HSplit s t Source #

The internal state of the split-view widget. Tracks the state of both child widgets and the current layout.

data Focus Source #

Constructors

FocusLeft 
FocusRight 

Instances

Instances details
Eq Focus Source # 
Instance details

Defined in Vgrep.Widget.HorizontalSplit.Internal

Methods

(==) :: Focus -> Focus -> Bool #

(/=) :: Focus -> Focus -> Bool #

Widget actions

leftOnly :: Monad m => VgrepT (HSplit s t) m Redraw Source #

Display the left widget full-screen

rightOnly :: Monad m => VgrepT (HSplit s t) m Redraw Source #

Display the right widget full-screen

splitView Source #

Arguments

:: Monad m 
=> Focus

Focus left or right area

-> Rational

Left area width as fraction of overall width

-> VgrepT (HSplit s t) m Redraw 

Display both widgets in a split view.

switchFocus :: Monad m => VgrepT (HSplit s t) m Redraw Source #

Switch focus from left to right child widget and vice versa (only if the _layout is Split)

Lenses

leftWidget :: forall s t s. Lens (HSplit s t) (HSplit s t) s s Source #

rightWidget :: forall s t t. Lens (HSplit s t) (HSplit s t) t t Source #

currentWidget :: Lens' (HSplit s t) (Either s t) Source #

The currently focused child widget

>>> view currentWidget $ HSplit { _leftWidget = "foo", _layout = LeftOnly }
Left "foo"

leftWidgetFocused :: Traversal' (HSplit s t) s Source #

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

rightWidgetFocused :: Traversal' (HSplit s t) t Source #

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