Safe Haskell | None |
---|---|
Language | Haskell2010 |
This module exports functions and types to handle text alignemnt.
- data AlignmentKind
- data Alignment = Alignment {
- _alignmentKing :: !AlignmentKind
- _alignmentRef :: !(Coords Pos)
- mkRightAlign :: Coords Pos -> Alignment
- mkCentered :: Coords Pos -> Alignment
- toNextLine :: Alignment -> Alignment
- align :: AlignmentKind -> Int -> (Int, Direction)
- align' :: Alignment -> Int -> Coords Pos
Alignment
data AlignmentKind Source #
Specifies where the Text
is w.r.t the reference coordinates.
Centered | Centered on reference coordinates, favoring the 1 12 123 1234 ^ |
RightAligned | Left of the reference coordinates, including it: 1 12 123 1234 ^ |
LeftAligned | Right of the reference coordinates, including it: 1 12 123 1234 ^ |
Alignment | |
|
Helpers
toNextLine :: Alignment -> Alignment Source #
Moves the reference coordinate one line down.
Utilities
:: AlignmentKind | |
-> Int | Count of characters |
-> (Int, Direction) |
Given a number of characters and an alignment, returns the displacement
that should be done relatively to the reference coordinates in order to find
the first character Coords
.
For Centered
, when we have an even count of characters to draw, we
(somewhat arbitrarily) chose to favor the RIGHT
Direction
, as illustrated
here where ^
indicates where the reference Coords
is:
1 12 123 1234 ^
Note that this choice impacts the implementation of
getSideCentersAtDistance
.