| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Imj.Graphics.Text.Alignment
Description
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.
Constructors
| 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 ^ |
Constructors
| Alignment | |
Fields
| |
Helpers
toNextLine :: Alignment -> Alignment Source #
Moves the reference coordinate one line down.
Utilities
Arguments
| :: 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.