List package:brick
This module provides a scrollable list type and functions for
manipulating and rendering it.
Note that lenses are provided for direct manipulation purposes, but
lenses are *not* safe and should be used with care. (For example,
listElementsL permits direct manipulation of the list container
without performing bounds checking on the selected index.) If you need
a safe API, consider one of the various functions for list
manipulation. For example, instead of
listElementsL, consider
listReplace.
An alias for
GenericList specialized to use a
Vector
as its container type.
Construct a list in terms of container t with element type
e.
A form field for selecting a single choice from a set of possible
choices in a scrollable list. This uses a
List internally.
This field's attributes are governed by those exported from
List.
This field responds to the same input events that a
List does.
The top-level attribute used for the entire list.
Remove all elements from the list and clear the selection.
O(1)
The list's sequence of elements.
Starting from the currently-selected position, attempt to find and
select the next element matching the predicate. If there are no
matches for the remainder of the list or if the list has no selection
at all, the search starts at the beginning. If no matching element is
found anywhere in the list, leave the list unmodified.
O(n). Only evaluates as much of the container as needed.
Find the first element in the list that satisfies the specified
predicate. If such an element is found, return the resulting index and
element.
O(n).
Insert an item into a list at the specified position.
Complexity: the worse of
splitAt and
<> for the
container type.
listInsert for List: O(n)
listInsert for Seq: O(log(min(i, length n - i)))
The height of an individual item in the list.
Apply a function to the selected element. If no element is selected
the list is not modified.
Complexity: same as
traverse for the container type (typically
O(n)).
Complexity: same as
listSelectedElementL for the list's
container type.
listModify for List: O(n)
listModify for Seq: O(log(min(i, n - i)))
Move the list selected index.
If the current selection is
Just x, the selection is adjusted
by the specified amount. The value is clamped to the extents of the
list (i.e. the selection does not "wrap").
If the current selection is
Nothing (i.e. there is no
selection) and the direction is positive, set to
Just 0
(first element), otherwise set to
Just (length - 1) (last
element).
Complexity: same as
splitAt for the container type.
listMoveBy for List: O(1)
listMoveBy for Seq: O(log(min(i,n-i)))
Move the list selected index by some (fractional) number of pages.
Move the list selected index down by one. (Moves the cursor down, adds
one to the index.)
Move the list selected index down by one page.
Move the list selected index up by one page.
Set the selected index for a list to the specified index, subject to
validation.
If
pos >= 0, indexes from the start of the list (which
gets evaluated up to the target index)
If
pos < 0, indexes from the end of the list (which
evaluates
length of the list).
Complexity: same as
splitAt for the container type.
listMoveTo for List: O(1)
listMoveTo for Seq: O(log(min(i,n-i)))
Move the list selection to the first element in the list.
Set the selected index for a list to the index of the first occurrence
of the specified element if it is in the list, or leave the list
unmodified otherwise.
O(n). Only evaluates as much of the container as needed.
Move the list selection to the last element in the list.
Move the list selected index up by one. (Moves the cursor up,
subtracts one from the index.)