brick-list-search-0.1.2.2: Search forward or backward for certain kinds of items in brick list
Safe HaskellSafe-Inferred
LanguageHaskell2010

Brick.Widgets.List.Search

Description

Functions that brick event handlers can use to search forward or backward for certain kinds of items in brick list.

For example, in the above demo program, you can search forward or backward for a list element that is not a separator.

Synopsis

Types

type IncludeCurrent = Bool Source #

Should the search include the current location?

Low-level functions

These functions are used in list manipulation and list display.

searchListForward Source #

Arguments

:: Searchable t 
=> IncludeCurrent 
-> (e -> Bool)

The test

-> GenericList n t e 
-> Maybe Int

The first element index that passes the test

Search forward for the first element index that passes the test

searchListBackward Source #

Arguments

:: Searchable t 
=> IncludeCurrent 
-> (e -> Bool)

The test

-> GenericList n t e 
-> Maybe Int

The first element index that passes the test

Search backward for the first element index that passes the test

List manipulation

listSearchBy Source #

Arguments

:: (Searchable t, Foldable t, Splittable t) 
=> (e -> Bool)

The test

-> Int

The amount of list elements to move by

-> GenericList n t e 
-> GenericList n t e 

Move by an amount of list elements in the list. If the amount to move by is 0, no change is made. Otherwise, call listMoveBy.

The element chosen by listMoveBy is included in the search.

After calling listMoveBy, if the amount to move by was positive, search forward for the first element that passes the test. If forward search fails, search backward for the first such element. If backward search fails too, no change is made.

After calling listMoveBy, if the amount to move by was negative, search backward for the first element that passes the test. If backward search fails, search forward for the first such element. If forward search fails too, no change is made.

listSearchUp Source #

Arguments

:: Searchable t 
=> (e -> Bool)

The test

-> GenericList n t e 
-> GenericList n t e 

Search backward for the first element that passes the test.

The current element is not included in the search.

If backward search fails, no change is made.

listSearchDown Source #

Arguments

:: Searchable t 
=> (e -> Bool)

The test

-> GenericList n t e 
-> GenericList n t e 

Search forward for the first element that passes the test.

The current element is not included in the search.

If forward search fails, no change is made.

listSearchByPages Source #

Arguments

:: (Searchable t, Foldable t, Splittable t, Ord n, RealFrac pages) 
=> (e -> Bool)

The test

-> pages

Pages to move by

-> EventM n (GenericList n t e) () 

Move by a (fractional) number of pages in the list. If the number of pages to move by is 0, no change is made. Otherwise, call listMoveByPages with the number of pages to move by.

The element chosen by listMoveByPages is included in the search.

After calling listMoveByPages, if the number of pages to move by was positive, search forward for the first element that passes the test. If forward search fails, then search backward for the first such element. If backward search fails too, cancel movements made by this function.

After calling listMoveByPages, if the number of pages to move by was negative, search backward for the first element that passes the test. If backward search fails, then search forward for the first such element. If forward search fails too, cancel movements made by this function.

listSearchPageUp Source #

Arguments

:: (Searchable t, Foldable t, Splittable t, Ord n) 
=> (e -> Bool)

The test

-> EventM n (GenericList n t e) () 

Move up one page, and search backward for the first element that passes the test.

The element chosen by moving up one page is included in the search.

If backward search fails, search forward for the first element that passes the test.

If forward search fails too, cancel movements made by this function.

listSearchPageDown Source #

Arguments

:: (Searchable t, Foldable t, Splittable t, Ord n) 
=> (e -> Bool)

The test

-> EventM n (GenericList n t e) () 

Move down one page, and search forward for the first element that passes the test.

The element chosen by moving down one page is included in the search.

If forward search fails, search backward for the first element that passes the test.

If backward search fails too, cancel movements made by this function.

listSearchFromBeginning Source #

Arguments

:: (Searchable t, Foldable t, Splittable t) 
=> (e -> Bool)

The test

-> GenericList n t e 
-> GenericList n t e 

From the first element, search forward for the first element that passes the test.

The first element is included in the search.

If forward search fails, no change is made.

listSearchFromEnd Source #

Arguments

:: (Searchable t, Foldable t, Splittable t) 
=> (e -> Bool)

The test

-> GenericList n t e 
-> GenericList n t e 

From the last element, search backward for the first element that passes the test.

The last element is included in the search.

If backward search fails, no change is made.

List display

List display functions do not change the current list element.

listShowTheTop Source #

Arguments

:: Searchable t 
=> (e -> Bool)

The test

-> EventM n (GenericList n t e) () 

If searching backward for a list element that passes the test fails, show as many list elements as possible above the current element.

The current list element is not included in the backward search.

Call this after moving backward by calling one of list manipulation functions.

listShowTheBottom Source #

Arguments

:: Searchable t 
=> (e -> Bool)

The test

-> EventM n (GenericList n t e) () 

If searching forward for a list element that passes the test fails, show as many list elements as possible below the current element.

The current list element is not included in the forward search.

Call this after moving forward by calling one of list manipulation functions.

Classes

class Searchable (t :: * -> *) where Source #

Functions for searching elements.

Methods

viewHead :: t a -> Maybe (a, t a) Source #

Get the head and the rest

viewLast :: t a -> Maybe (t a, a) Source #

Get the last element and the rest

take :: Int -> t a -> t a Source #

Take a number of elements from the beginning

drop :: Int -> t a -> t a Source #

Drop a number of elements from the beginning

Instances

Instances details
Searchable Seq Source #

O(1) for viewHead and viewLast. O(log(min(i,n-i))) for take and drop.

Instance details

Defined in Brick.Widgets.List.Search

Methods

viewHead :: Seq a -> Maybe (a, Seq a) Source #

viewLast :: Seq a -> Maybe (Seq a, a) Source #

take :: Int -> Seq a -> Seq a Source #

drop :: Int -> Seq a -> Seq a Source #

Searchable Vector Source #

O(1) for all operations

Instance details

Defined in Brick.Widgets.List.Search

Methods

viewHead :: Vector a -> Maybe (a, Vector a) Source #

viewLast :: Vector a -> Maybe (Vector a, a) Source #

take :: Int -> Vector a -> Vector a Source #

drop :: Int -> Vector a -> Vector a Source #