brick-list-search-0.1.0.0: 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.

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

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.

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.

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.

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.

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 #