on ee20876 help sign in
vty/src/Graphics/Vty/Debug.hs
39 lines 1.1 kB history raw
1-- Copyright 2009-2010 Corey O'Connor
2module Graphics.Vty.Debug
3 ( module Graphics.Vty.Debug
4 , module Graphics.Vty.Debug.Image
5 )
6where
8import Graphics.Vty.Attributes
9import Graphics.Vty.Image (DisplayRegion)
10import Graphics.Vty.Debug.Image
11import Graphics.Vty.Span
13import qualified Data.Vector as Vector
15rowOpsAffectedColumns :: DisplayOps -> [Int]
16rowOpsAffectedColumns ops
17 = Vector.toList $ Vector.map spanOpsAffectedColumns ops
19allSpansHaveWidth :: DisplayOps -> Int -> Bool
20allSpansHaveWidth ops expected
21 = all (== expected) $ Vector.toList $ Vector.map spanOpsAffectedColumns ops
23spanOpsAffectedRows :: DisplayOps -> Int
24spanOpsAffectedRows ops
25 = toEnum $ length (filter (not . null . Vector.toList) (Vector.toList ops))
27type SpanConstructLog = [SpanConstructEvent]
28data SpanConstructEvent = SpanSetAttr Attr
30isSetAttr :: Attr -> SpanConstructEvent -> Bool
31isSetAttr expectedAttr (SpanSetAttr inAttr)
32 | inAttr == expectedAttr = True
33isSetAttr _attr _event = False
35data MockWindow = MockWindow Int Int
36 deriving (Show, Eq)
38regionForWindow :: MockWindow -> DisplayRegion
39regionForWindow (MockWindow w h) = (w,h)