matterhorn-50200.13.0: Terminal client for the Mattermost chat system
Safe HaskellNone
LanguageHaskell2010

Matterhorn.Draw.RichText.Wrap

Description

This module performs line-wrapping of sequences of flattend inline values produced by flattenInlineSeq.

This process works by maintaining a WrapState in the WrapM monad, where inline values are pushed onto the current line, and line breaks are introduced as inlines exceed the available width. The most important caveat of this module is that wrapping depends on knowing the width of each FlattenedValue, which is provided by the fvWidth function. But fvWidth must return values that are consistent with the how the inlines actually get rendered by renderFlattenedValue. This is because there are visual aspects to how some inlines get rendered that are implicit, such as user or channel sigils that get added at drawing time, that have an impact on their visible width.

Synopsis

Documentation

doLineWrapping :: Int -> Seq (FlattenedValue a) -> Seq (WrappedLine a) Source #

Given a maximum width and an inline sequence, produce a sequence of lines wrapped at the specified column. This only returns lines longer than the maximum width when those lines have a single inline value that cannot be broken down further (such as a long URL).