Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Screen overlays.
Synopsis
- data DisplayFont
- isPropFont :: DisplayFont -> Bool
- isSquareFont :: DisplayFont -> Bool
- isMonoFont :: DisplayFont -> Bool
- textSize :: DisplayFont -> [a] -> Int
- data FontSetup = FontSetup {}
- multiFontSetup :: FontSetup
- singleFontSetup :: FontSetup
- type AttrString = [AttrCharW32]
- blankAttrString :: Int -> AttrString
- textToAS :: Text -> AttrString
- textFgToAS :: Color -> Text -> AttrString
- stringToAS :: String -> AttrString
- attrStringToString :: AttrString -> String
- (<+:>) :: AttrString -> AttrString -> AttrString
- (<\:>) :: AttrString -> AttrString -> AttrString
- data AttrLine
- attrLine :: AttrLine -> AttrString
- emptyAttrLine :: AttrLine
- attrStringToAL :: AttrString -> AttrLine
- firstParagraph :: AttrString -> AttrLine
- textToAL :: Text -> AttrLine
- textFgToAL :: Color -> Text -> AttrLine
- stringToAL :: String -> AttrLine
- linesAttr :: AttrString -> [AttrLine]
- splitAttrString :: Int -> Int -> AttrString -> [AttrLine]
- indentSplitAttrString :: DisplayFont -> Int -> AttrString -> [AttrLine]
- type Overlay = [(PointUI, AttrLine)]
- xytranslateOverlay :: Int -> Int -> Overlay -> Overlay
- xtranslateOverlay :: Int -> Overlay -> Overlay
- ytranslateOverlay :: Int -> Overlay -> Overlay
- offsetOverlay :: [AttrLine] -> Overlay
- offsetOverlayX :: [(Int, AttrLine)] -> Overlay
- typesetXY :: (Int, Int) -> [AttrLine] -> Overlay
- updateLine :: Int -> (Int -> AttrString -> AttrString) -> Overlay -> Overlay
- rectangleOfSpaces :: Int -> Int -> Overlay
- maxYofOverlay :: Overlay -> Int
- labDescOverlay :: DisplayFont -> Int -> AttrString -> (Overlay, Overlay)
- nonbreakableRev :: [String]
- isPrefixOfNonbreakable :: AttrString -> Bool
- breakAtSpace :: AttrString -> (AttrString, AttrString)
- splitAttrPhrase :: Int -> Int -> AttrLine -> [AttrLine]
DisplayFont
data DisplayFont Source #
Three types of fonts used in the UI. Overlays (layers, more or less) in proportional font are overwritten by layers in square font, which are overwritten by layers in mono font. All overlays overwrite the rendering of the game map, which is the underlying basic UI frame, comprised of square font glyps.
This type needs to be kept abstract to ensure that frontend-enforced
or user config-enforced font assignments in FontSetup
(e.g., stating that the supposedly proportional font is overriden
to be the square font) can't be ignored. Otherwise a programmer
could use arbirary DisplayFont
, instead of the one taken from FontSetup
,
and so, e.g., calculating the width of an overlay so constructed
in order to decide where another overlay can start would be inconsistent
what what font is really eventually used when rendering.
Note that the order of constructors has limited effect, but it illustrates how overwriting is explicitly implemented in frontends that support all fonts.
Instances
Enum DisplayFont Source # | |
Defined in Game.LambdaHack.Client.UI.Overlay succ :: DisplayFont -> DisplayFont # pred :: DisplayFont -> DisplayFont # toEnum :: Int -> DisplayFont # fromEnum :: DisplayFont -> Int # enumFrom :: DisplayFont -> [DisplayFont] # enumFromThen :: DisplayFont -> DisplayFont -> [DisplayFont] # enumFromTo :: DisplayFont -> DisplayFont -> [DisplayFont] # enumFromThenTo :: DisplayFont -> DisplayFont -> DisplayFont -> [DisplayFont] # | |
Show DisplayFont Source # | |
Defined in Game.LambdaHack.Client.UI.Overlay showsPrec :: Int -> DisplayFont -> ShowS # show :: DisplayFont -> String # showList :: [DisplayFont] -> ShowS # | |
Eq DisplayFont Source # | |
Defined in Game.LambdaHack.Client.UI.Overlay (==) :: DisplayFont -> DisplayFont -> Bool # (/=) :: DisplayFont -> DisplayFont -> Bool # |
isPropFont :: DisplayFont -> Bool Source #
isSquareFont :: DisplayFont -> Bool Source #
isMonoFont :: DisplayFont -> Bool Source #
textSize :: DisplayFont -> [a] -> Int Source #
FontSetup
AttrString
type AttrString = [AttrCharW32] Source #
String of colourful text. End of line characters permitted.
blankAttrString :: Int -> AttrString Source #
textToAS :: Text -> AttrString Source #
textFgToAS :: Color -> Text -> AttrString Source #
stringToAS :: String -> AttrString Source #
attrStringToString :: AttrString -> String Source #
Transform AttrString
type to String
.
(<+:>) :: AttrString -> AttrString -> AttrString infixr 6 Source #
(<\:>) :: AttrString -> AttrString -> AttrString infixr 6 Source #
AttrLine
Line of colourful text. End of line characters forbidden. Trailing
White
space forbidden.
attrLine :: AttrLine -> AttrString Source #
attrStringToAL :: AttrString -> AttrLine Source #
firstParagraph :: AttrString -> AttrLine Source #
stringToAL :: String -> AttrLine Source #
linesAttr :: AttrString -> [AttrLine] Source #
splitAttrString :: Int -> Int -> AttrString -> [AttrLine] Source #
Split a string into lines. Avoid breaking the line at a character other than space. Remove the spaces on which lines are broken, keep other spaces. In expensive assertions mode (dev debug mode) fail at trailing spaces, but keep leading spaces, e.g., to make distance from a text in another font. Newlines are respected.
Note that we only split wrt White
space, nothing else,
and the width, in the first argument, is calculated in characters,
not in UI (mono font) coordinates, so that taking and dropping characters
is performed correctly.
indentSplitAttrString :: DisplayFont -> Int -> AttrString -> [AttrLine] Source #
Overlay
type Overlay = [(PointUI, AttrLine)] Source #
A series of screen lines with start positions at which they should
be overlayed over the base frame or a blank screen, depending on context.
The position point is represented as in integer that is an index into the
frame character array.
The lines either fit the width of the screen or are intended
for truncation when displayed. The start positions of lines may fall outside
the length of the screen, too, unlike in SingleFrame
. Then they are
simply not shown.
offsetOverlay :: [AttrLine] -> Overlay Source #
updateLine :: Int -> (Int -> AttrString -> AttrString) -> Overlay -> Overlay Source #
maxYofOverlay :: Overlay -> Int Source #
labDescOverlay :: DisplayFont -> Int -> AttrString -> (Overlay, Overlay) Source #
Internal operations
nonbreakableRev :: [String] Source #
breakAtSpace :: AttrString -> (AttrString, AttrString) Source #