brick-0.49: A declarative terminal user interface library

Safe HaskellSafe
LanguageHaskell2010

Data.Text.Markup

Description

This module provides an API for "marking up" text with arbitrary values. A piece of markup can then be converted to a list of pairs representing the sequences of characters assigned the same markup value.

This interface is experimental. Don't use this for your full-file syntax highlighter just yet!

Synopsis

Documentation

data Markup a Source #

Markup with metadata type a assigned to each character.

Instances
Show a => Show (Markup a) Source # 
Instance details

Defined in Data.Text.Markup

Methods

showsPrec :: Int -> Markup a -> ShowS #

show :: Markup a -> String #

showList :: [Markup a] -> ShowS #

Monoid a => IsString (Markup a) Source # 
Instance details

Defined in Data.Text.Markup

Methods

fromString :: String -> Markup a #

Semigroup (Markup a) Source # 
Instance details

Defined in Data.Text.Markup

Methods

(<>) :: Markup a -> Markup a -> Markup a #

sconcat :: NonEmpty (Markup a) -> Markup a #

stimes :: Integral b => b -> Markup a -> Markup a #

Monoid (Markup a) Source # 
Instance details

Defined in Data.Text.Markup

Methods

mempty :: Markup a #

mappend :: Markup a -> Markup a -> Markup a #

mconcat :: [Markup a] -> Markup a #

markupToList :: Eq a => Markup a -> [[(Text, a)]] Source #

Convert markup to a list of lines. Each line is represented by a list of pairs in which each pair contains the longest subsequence of characters having the same metadata.

markupSet :: Eq a => (Int, Int) -> a -> Markup a -> Markup a Source #

Set the metadata for a range of character positions in a piece of markup. This is useful for, e.g., syntax highlighting.

fromList :: [(Text, a)] -> Markup a Source #

Convert a list of text and metadata pairs into markup.

fromText :: Monoid a => Text -> Markup a Source #

Build markup from text with the default metadata.

toText :: Eq a => Markup a -> Text Source #

Extract the text from markup, discarding the markup metadata.

isEmpty :: Markup a -> Bool Source #

Test whether the markup is empty.

(@@) :: Text -> a -> Markup a Source #

Build a piece of markup; assign the specified metadata to every character in the specified text.