~jaro/balkon

8537ba994a9fe1d81fd7138dfceef32f718b8231 — Jaro 1 year, 7 months ago 07b55a3
Move BiDi Level to separate module.
M balkon.cabal => balkon.cabal +1 -0
@@ 106,6 106,7 @@ library balkon-internal
    exposed-modules:
        Data.Text.ParagraphLayout.Internal.AncestorBox,
        Data.Text.ParagraphLayout.Internal.ApplyBoxes,
        Data.Text.ParagraphLayout.Internal.BiDiLevels,
        Data.Text.ParagraphLayout.Internal.BiDiReorder,
        Data.Text.ParagraphLayout.Internal.BoxOptions,
        Data.Text.ParagraphLayout.Internal.Break,

A src/Data/Text/ParagraphLayout/Internal/BiDiLevels.hs => src/Data/Text/ParagraphLayout/Internal/BiDiLevels.hs +13 -0
@@ 0,0 1,13 @@
module Data.Text.ParagraphLayout.Internal.BiDiLevels (Level, WithLevel, level)
where

import Data.Word (Word8)

-- | BiDi level, between 0 and 125 inclusive.
-- Even values mean left-to-right text.
-- Odd values mean right-to-left text.
type Level = Word8

-- | Typeclass for any data structure with an associated BiDi level.
class WithLevel a where
    level :: a -> Level

M src/Data/Text/ParagraphLayout/Internal/BiDiReorder.hs => src/Data/Text/ParagraphLayout/Internal/BiDiReorder.hs +2 -15
@@ 1,24 1,11 @@
module Data.Text.ParagraphLayout.Internal.BiDiReorder
    ( Level
    , WithLevel
    , level
    , reorder
    )
module Data.Text.ParagraphLayout.Internal.BiDiReorder (reorder)
where

import Data.List.NonEmpty (NonEmpty ((:|)))
import qualified Data.List.NonEmpty as NonEmpty
import Data.Semigroup (sconcat)
import Data.Word (Word8)

-- | BiDi level, between 0 and 125 inclusive.
-- Even values mean left-to-right text.
-- Odd values mean right-to-left text.
type Level = Word8

-- | Typeclass for any data structure with an associated BiDi level.
class WithLevel a where
    level :: a -> Level
import Data.Text.ParagraphLayout.Internal.BiDiLevels

-- | Generic reordering of bidirectional text according to rule L2 of UAX #9
-- <https://www.unicode.org/reports/tr9/#Reordering_Resolved_Levels>.

M src/Data/Text/ParagraphLayout/Internal/ProtoFragment.hs => src/Data/Text/ParagraphLayout/Internal/ProtoFragment.hs +1 -1
@@ 7,7 7,7 @@ where
import Data.Int (Int32)
import Data.Text.Glyphize (Direction (..), GlyphInfo, GlyphPos (x_advance))

import Data.Text.ParagraphLayout.Internal.BiDiReorder
import Data.Text.ParagraphLayout.Internal.BiDiLevels

-- | A box fragment which has not been positioned yet.
data ProtoFragment = ProtoFragment

M src/Data/Text/ParagraphLayout/Internal/WithSpan.hs => src/Data/Text/ParagraphLayout/Internal/WithSpan.hs +1 -1
@@ 4,7 4,7 @@ module Data.Text.ParagraphLayout.Internal.WithSpan
    )
where

import Data.Text.ParagraphLayout.Internal.BiDiReorder
import Data.Text.ParagraphLayout.Internal.BiDiLevels
import Data.Text.ParagraphLayout.Internal.ResolvedBox
import Data.Text.ParagraphLayout.Internal.ResolvedSpan
import Data.Text.ParagraphLayout.Internal.TextContainer

M test/Data/Text/ParagraphLayout/Internal/BiDiReorderSpec.hs => test/Data/Text/ParagraphLayout/Internal/BiDiReorderSpec.hs +1 -0
@@ 5,6 5,7 @@ import Data.List.NonEmpty (NonEmpty, fromList)
import Data.Word (Word8)

import Test.Hspec
import Data.Text.ParagraphLayout.Internal.BiDiLevels
import Data.Text.ParagraphLayout.Internal.BiDiReorder

ne :: [a] -> NonEmpty a