diff options
Diffstat (limited to 'spec/src')
-rw-r--r-- | spec/src/Thermoprint/Printout.hs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/spec/src/Thermoprint/Printout.hs b/spec/src/Thermoprint/Printout.hs index 8c33e07..752ccb5 100644 --- a/spec/src/Thermoprint/Printout.hs +++ b/spec/src/Thermoprint/Printout.hs | |||
@@ -11,7 +11,9 @@ module Thermoprint.Printout | |||
11 | , Block(..) | 11 | , Block(..) |
12 | , Line( HSpace | 12 | , Line( HSpace |
13 | , JuxtaPos | 13 | , JuxtaPos |
14 | , Markup | ||
14 | ) | 15 | ) |
16 | , MarkupMode(..) | ||
15 | , text, cotext | 17 | , text, cotext |
16 | , prop_text | 18 | , prop_text |
17 | ) where | 19 | ) where |
@@ -48,6 +50,9 @@ import Data.Monoid (Monoid(..), (<>)) | |||
48 | 50 | ||
49 | import Data.List (dropWhile, dropWhileEnd, groupBy, genericLength, genericReplicate) | 51 | import Data.List (dropWhile, dropWhileEnd, groupBy, genericLength, genericReplicate) |
50 | 52 | ||
53 | import Data.Set (Set) | ||
54 | import qualified Data.Set as Set | ||
55 | |||
51 | import Data.Sequence as Seq (fromList, null, singleton) | 56 | import Data.Sequence as Seq (fromList, null, singleton) |
52 | import Data.Sequence (ViewL(..), viewl) | 57 | import Data.Sequence (ViewL(..), viewl) |
53 | 58 | ||
@@ -143,6 +148,7 @@ We don't export all constructors and instead encourage the use of 'text'. | |||
143 | -} | 148 | -} |
144 | data Line = Word Text | 149 | data Line = Word Text |
145 | | HSpace Integer | 150 | | HSpace Integer |
151 | | Markup (Set MarkupMode) Line | ||
146 | | JuxtaPos (Seq Line) | 152 | | JuxtaPos (Seq Line) |
147 | deriving (Generic, NFData, Show, CoArbitrary, FromJSON, ToJSON) | 153 | deriving (Generic, NFData, Show, CoArbitrary, FromJSON, ToJSON) |
148 | 154 | ||
@@ -215,6 +221,7 @@ cotext (Line x) = cotext' x | |||
215 | where | 221 | where |
216 | cotext' (Word x) = x | 222 | cotext' (Word x) = x |
217 | cotext' (HSpace n) = TL.pack . genericReplicate n $ ' ' | 223 | cotext' (HSpace n) = TL.pack . genericReplicate n $ ' ' |
224 | cotext' (Markup _ l) = cotext' l | ||
218 | cotext' (JuxtaPos xs) = mconcat . map cotext' . toList $ xs | 225 | cotext' (JuxtaPos xs) = mconcat . map cotext' . toList $ xs |
219 | 226 | ||
220 | prop_text :: Text -> Bool | 227 | prop_text :: Text -> Bool |
@@ -231,6 +238,14 @@ prop_text x = (cotext . either id Line . text $ x') == x' | |||
231 | | otherwise = c | 238 | | otherwise = c |
232 | keep = [' ', '\n'] :: [Char] | 239 | keep = [' ', '\n'] :: [Char] |
233 | 240 | ||
241 | data MarkupMode = Bold | ||
242 | | Underline | ||
243 | | DoubleHeight | ||
244 | | DoubleWidth | ||
245 | deriving (Generic, NFData, Show, Arbitrary, CoArbitrary, FromJSON, ToJSON | ||
246 | , Eq, Ord, Enum | ||
247 | ) | ||
248 | |||
234 | -- | We don't test 'Raw' 'Chunk's | 249 | -- | We don't test 'Raw' 'Chunk's |
235 | instance Arbitrary Chunk where | 250 | instance Arbitrary Chunk where |
236 | shrink = genericShrink | 251 | shrink = genericShrink |