    -- Copyright 2009-2010 Corey O'Connor
    module Graphics.Vty.Debug
      ( MockWindow(..)
      , SpanConstructLog
      , regionForWindow
      , allSpansHaveWidth
      , spanOpsAffectedColumns
      , spanOpsAffectedRows
      , rowOpsAffectedColumns
      , isSetAttr
      )
    where

    import Graphics.Vty.Attributes
    import Graphics.Vty.Image (DisplayRegion)
    import Graphics.Vty.Span

    import qualified Data.Vector as Vector

    rowOpsAffectedColumns :: DisplayOps -> [Int]
    rowOpsAffectedColumns :: DisplayOps -> [Int]
    rowOpsAffectedColumns DisplayOps
    ops
        = Vector Int -> [Int]
    forall a. Vector a -> [a]
    Vector.toList (Vector Int -> [Int]) -> Vector Int -> [Int]
    forall a b. (a -> b) -> a -> b
    $ (SpanOps -> Int) -> DisplayOps -> Vector Int
    forall a b. (a -> b) -> Vector a -> Vector b
    Vector.map SpanOps -> Int
    spanOpsAffectedColumns DisplayOps
    ops

    allSpansHaveWidth :: DisplayOps -> Int -> Bool
    allSpansHaveWidth :: DisplayOps -> Int -> Bool
    allSpansHaveWidth DisplayOps
    ops Int
    expected
        = (Int -> Bool) -> [Int] -> Bool
    forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
    all (Int -> Int -> Bool
    forall a. Eq a => a -> a -> Bool
    == Int
    expected) ([Int] -> Bool) -> [Int] -> Bool
    forall a b. (a -> b) -> a -> b
    $ Vector Int -> [Int]
    forall a. Vector a -> [a]
    Vector.toList (Vector Int -> [Int]) -> Vector Int -> [Int]
    forall a b. (a -> b) -> a -> b
    $ (SpanOps -> Int) -> DisplayOps -> Vector Int
    forall a b. (a -> b) -> Vector a -> Vector b
    Vector.map SpanOps -> Int
    spanOpsAffectedColumns DisplayOps
    ops

    spanOpsAffectedRows :: DisplayOps -> Int
    spanOpsAffectedRows :: DisplayOps -> Int
    spanOpsAffectedRows DisplayOps
    ops
        = Int -> Int
    forall a. Enum a => Int -> a
    toEnum (Int -> Int) -> Int -> Int
    forall a b. (a -> b) -> a -> b
    $ [SpanOps] -> Int
    forall a. [a] -> Int
    forall (t :: * -> *) a. Foldable t => t a -> Int
    length ((SpanOps -> Bool) -> [SpanOps] -> [SpanOps]
    forall a. (a -> Bool) -> [a] -> [a]
    filter (Bool -> Bool
    not (Bool -> Bool) -> (SpanOps -> Bool) -> SpanOps -> Bool
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . [SpanOp] -> Bool
    forall a. [a] -> Bool
    forall (t :: * -> *) a. Foldable t => t a -> Bool
    null ([SpanOp] -> Bool) -> (SpanOps -> [SpanOp]) -> SpanOps -> Bool
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . SpanOps -> [SpanOp]
    forall a. Vector a -> [a]
    Vector.toList) (DisplayOps -> [SpanOps]
    forall a. Vector a -> [a]
    Vector.toList DisplayOps
    ops))

    type SpanConstructLog = [SpanConstructEvent]
    data SpanConstructEvent = SpanSetAttr Attr

    isSetAttr :: Attr -> SpanConstructEvent -> Bool
    isSetAttr :: Attr -> SpanConstructEvent -> Bool
    isSetAttr Attr
    expectedAttr (SpanSetAttr Attr
    inAttr)
        | Attr
    inAttr Attr -> Attr -> Bool
    forall a. Eq a => a -> a -> Bool
    == Attr
    expectedAttr = Bool
    True
    isSetAttr Attr
    _attr SpanConstructEvent
    _event = Bool
    False

    data MockWindow = MockWindow Int Int
        deriving (Int -> MockWindow -> ShowS
    [MockWindow] -> ShowS
    MockWindow -> String
    (Int -> MockWindow -> ShowS)
    -> (MockWindow -> String)
    -> ([MockWindow] -> ShowS)
    -> Show MockWindow
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> MockWindow -> ShowS
    showsPrec :: Int -> MockWindow -> ShowS
    $cshow :: MockWindow -> String
    show :: MockWindow -> String
    $cshowList :: [MockWindow] -> ShowS
    showList :: [MockWindow] -> ShowS
    Show, MockWindow -> MockWindow -> Bool
    (MockWindow -> MockWindow -> Bool)
    -> (MockWindow -> MockWindow -> Bool) -> Eq MockWindow
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: MockWindow -> MockWindow -> Bool
    == :: MockWindow -> MockWindow -> Bool
    $c/= :: MockWindow -> MockWindow -> Bool
    /= :: MockWindow -> MockWindow -> Bool
    Eq)

    regionForWindow :: MockWindow -> DisplayRegion
    regionForWindow :: MockWindow -> DisplayRegion
    regionForWindow (MockWindow Int
    w Int
    h) = (Int
    w,Int
    h)