Safe Haskell | Safe-Inferred |
---|
Rainbox.Reader
Contents
Description
Box
with many functions in a Reader
monad.
The advantage of this module over Rainbox is that many of the
functions have fewer arguments because they are instead carried
in the Reader
monad. This also allows you to use four infix
operators to easily join up Box
. The disadvantage is that
using the Reader
monad adds a layer of indirection.
- data Background = Background {}
- defaultBackground :: Background
- same :: Color8 -> Background
- newtype Bar = Bar {}
- data Box
- unBox :: Box -> BoxP
- newtype Height = Height {}
- height :: Box -> Int
- newtype Width = Width {}
- class HasWidth a where
- data Align a
- data Vert
- data Horiz
- center :: Align a
- top :: Align Vert
- bottom :: Align Vert
- left :: Align Horiz
- right :: Align Horiz
- data Specs = Specs {}
- type Env = ReaderT Specs
- runEnv :: Specs -> Env Identity a -> a
- blank :: Background -> Height -> Width -> Box
- blankH :: Monad m => Int -> Env m Box
- blankV :: Monad m => Int -> Env m Box
- chunks :: [Chunk] -> Box
- chunk :: Chunk -> Box
- catH :: Monad m => [Box] -> Env m Box
- catV :: Monad m => [Box] -> Env m Box
- sepH :: Monad m => Int -> [Box] -> Env m Box
- sepV :: Monad m => Int -> [Box] -> Env m Box
- punctuateH :: Monad m => Box -> [Box] -> Env m Box
- punctuateV :: Monad m => Box -> [Box] -> Env m Box
- (<->) :: Monad m => Box -> Box -> Env m Box
- (<+>) :: Monad m => Box -> Box -> Env m Box
- (/-/) :: Monad m => Box -> Box -> Env m Box
- (/+/) :: Monad m => Box -> Box -> Env m Box
- view :: Monad m => Height -> Width -> Box -> Env m Box
- viewH :: Monad m => Int -> Box -> Env m Box
- viewV :: Monad m => Int -> Box -> Env m Box
- grow :: Monad m => Height -> Width -> Box -> Env m Box
- growH :: Monad m => Int -> Box -> Env m Box
- growV :: Monad m => Int -> Box -> Env m Box
- column :: Monad m => [Box] -> Env m [Box]
- resize :: Monad m => Height -> Width -> Box -> Env m Box
- resizeH :: Monad m => Int -> Box -> Env m Box
- resizeV :: Monad m => Int -> Box -> Env m Box
- render :: Box -> [Chunk]
- printBox :: Box -> IO ()
Backgrounds
data Background Source
Background colors to use when inserting necessary padding.
Constructors
Background | |
Fields |
Instances
defaultBackground :: BackgroundSource
Use the default background colors of the current terminal.
same :: Color8 -> BackgroundSource
Use the same color for 8 and 256-color backgrounds.
Box properties
Occupies a single row on screen. The Chunk
you place in a
Bar
should not have any control characters such as newlines or
tabs, as rainbox assumes that each character in a Bar
takes up
one screen column and that each character does not create
newlines. Leave newline handling up to rainbox. However,
rainbox will not check to make sure that your inputs do not
contain newlines, tabs, or other spurious characters. Similarly, use of
combining characters will create unexpected results, as Rainbox
will see something that takes up (for instance) two characters
and think it takes up two screen columns, when in reality it will
take up only one screen column. So, if you need accented
characters, use a single Unicode code point, not two code points.
For example, for é, use U+00E9, not U+0065 and U+0301.
A Box
has a width in columns and a height in rows. Its
height and width both are always at least zero. It can have
positive height even if its width is zero, and it can have
positive width even if its height is zero.
Each row in a Box
always has the same number of characters; a
Box
with zero height has no characters but still has a certain
width.
Height and columns
A count of rows
A count of columns
Alignment
Reader monad
Constructors
Specs | |
Making Boxes
Pasting Boxes together
(<->) :: Monad m => Box -> Box -> Env m BoxSource
Paste two Box
together horizontally with no intervening
space. Left fixity, precedence 5.
(/-/) :: Monad m => Box -> Box -> Env m BoxSource
Paste two Box
together vertically with no intervening space.
Left fixity, precedence 6.