Safe Haskell | None |
---|
- select :: Wybor a -> IO (Either TTYException (Maybe a))
- selections :: MonadResource m => Wybor a -> Source m a
- data Wybor a
- fromAssoc :: NonEmpty (Text, a) -> Wybor a
- fromTexts :: NonEmpty Text -> Wybor Text
- fromIO :: IO (Maybe (Maybe (NonEmpty (Text, a)))) -> Wybor a
- class HasWybor t a | t -> a where
- newtype TTYException = TTYIOException IOException
- reset :: Text
- bold :: Text
- regular :: Text
- underlining :: Underlining -> Text
- swap :: Text
- unswap :: Text
- fgcolor :: ColorIntensity -> Color -> Text
- bgcolor :: ColorIntensity -> Color -> Text
- data Underlining
- data ColorIntensity
- data Color
Documentation
selections :: MonadResource m => Wybor a -> Source m aSource
Continuously select items from Wybor
Exceptions (see TTYException
) aren't caught
The description of the alternative choices, see HasWybor
fromAssoc :: NonEmpty (Text, a) -> Wybor aSource
Construct Wybor
from the nonempty list of key-value pairs
fromTexts :: NonEmpty Text -> Wybor TextSource
Construct Wybor
from the nonempty list of strings
The strings are used both as keys and values
fromIO :: IO (Maybe (Maybe (NonEmpty (Text, a)))) -> Wybor aSource
Construct Wybor
from the IO
action that streams choices
It's useful when the list of alternatives is populated over time from multiple sources (for instance, from HTTP responses)
The interface is tailored for the use with closeable queues from the stm-chans package:
>>>
q <- newTMQueueIO
>>>
... {- a bunch of threads populating and eventually closing the queue -}
>>>
c <- 'select' ('fromIO' (atomically (tryReadTMQueue q)))
>>>
print c
That is, if the IO
action returns
the queue will never be read from again
and it can return Nothing
when there's nothing to add to the choices __yet__
Just
Nothing
It's still possible to use non-fancy queues:
>>>
q <- newTQueueIO
>>>
... {- a bunch of threads populating the queue -}
>>>
c <- 'select' ('fromIO' (fmap Just (atomically (tryReadTQueue q))))
>>>
print c
If choices are static, you will be served better by fromAssoc
and fromTexts
class HasWybor t a | t -> a whereSource
A bunch of lenses to pick and configure Wybor
wybor :: Lens' t (Wybor a)Source
How many alternative choices to show at once? (default: 10
)
How many lines every alternative takes on the screen? (default: 1
)
Prompt prefix (default: >>>
)
focused :: Lens' t (Text -> Text)Source
Decoration applied to the focused item (swaps foreground and background colors by default)
Note: should not introduce any printable symbols
normal :: Lens' t (Text -> Text)Source
Decoration applied to other items (is id
by default)
Note: should not introduce any printable symbols
newtype TTYException Source
Exceptions thrown while manipulating /dev/tty
device
A bunch of helpers to use with focused
and normal
underlining :: Underlining -> TextSource
Set underlining style
fgcolor :: ColorIntensity -> Color -> TextSource
Set foreground color
bgcolor :: ColorIntensity -> Color -> TextSource
Set background color
data Underlining
ANSI text underlining
SingleUnderline | |
DoubleUnderline | Not widely supported |
NoUnderline |
data ColorIntensity
ANSI colors come in two intensities