Portability | semi-portable (uses MPTC and type families) |
---|---|
Stability | experimental |
Maintainer | felipe.lessa@gmail.com |
- dbar :: (Num a, Enum a, Ord a) => Bool -> Width -> (a, a) -> a -> DString
- cdbar :: (Num a, Enum a, Ord a) => Bool -> Width -> (a, a) -> Printer a
- gdbar :: (Num a, Enum a, Ord a) => Bool -> (Width, Height) -> Maybe DColour -> Maybe DColour -> Bool -> (a, a) -> a -> DString
- cgdbar :: (Num a, Enum a, Ord a) => Bool -> (Width, Height) -> Maybe DColour -> Maybe DColour -> Bool -> (a, a) -> Printer a
- bar :: (Num a, Enum a, Ord a) => BarText -> BarType -> (a, a) -> a -> DString
- cbar :: (Num a, Enum a, Ord a) => BarText -> BarType -> (a, a) -> Printer a
- data BarType
- data BarTextType
- = Percentage
- | Absolute
- data BarText
- = AtLeft !BarTextType
- | AtRight !BarTextType
- | None
- dbar_style :: Char -> Width -> BarType
- gdbar_style :: (Width, Height) -> Maybe DColour -> Maybe DColour -> Bool -> BarType
Simple interface
Mimicking dbar
:: (Num a, Enum a, Ord a) | |
=> Bool | If |
-> Width | Width of the bar interior. |
-> (a, a) | Minimum and maximum values. |
-> a | Actual value. |
-> DString |
Mimics the dbar utility. Uses the dbar_style
.
cdbar :: (Num a, Enum a, Ord a) => Bool -> Width -> (a, a) -> Printer aSource
Mimics the dbar utility while getting the input dinamically.
Mimicking gdbar
:: (Num a, Enum a, Ord a) | |
=> Bool | If |
-> (Width, Height) | Size of the whole bar (excluding text). |
-> Maybe DColour | Filled colour (see |
-> Maybe DColour | Background/border colour
(see |
-> Bool |
|
-> (a, a) | Minimum and maximum values. |
-> a | Actual value. |
-> DString |
Mimics the gdbar utility. Uses the gdbar_style
.
cgdbar :: (Num a, Enum a, Ord a) => Bool -> (Width, Height) -> Maybe DColour -> Maybe DColour -> Bool -> (a, a) -> Printer aSource
Mimics the gdbar utility while getting the input dinamically.
Generic interface
bar :: (Num a, Enum a, Ord a) => BarText -> BarType -> (a, a) -> a -> DStringSource
Draws a bar and optionally some text describing some quantity in relation to some range. For example,
bar (AtLeft Percentage) (Text "[" "=" (Just ">") " " "]" 20) (-10,10) i
produces the bars
" 2% [ ]" where i = -9.6 " 2% [> ]" where i = -9.5 " 50% [=========> ]" where i = 0 " 96% [==================> ]" where i = 9.4 " 99% [===================>]" where i = 9.99 "100% [====================]" where i = 10
Note that the text is always padded to four characters. If the
first bar above had AtRight Percentage
the result would be
"[ ] 2% "
so the padding always inserts the spaces on the outside.
The type of the bar to be drawn.
Text | Draws a text bar. Note, however, that the
|
| |
Filled | Draws a filled graphical bar, like |
Hollow | Draws a filled graphical bar with a surrounding border. |
|
data BarTextType Source
The type of text to be written.
How to draw the bar text. AtLeft
and AtRight
are used to
specify if the text is at the left or the right of the bar,
and None
means that no text will be written.
Styles of the simple interfaces
dbar_style :: Char -> Width -> BarTypeSource
The style produced by the dbar utility.