~alcinnz/CatTrap

ref: 0eabb5958ef005e5b25651b4520bd033f642d59f CatTrap/Graphics/Layout/Grid/Table.hs -rw-r--r-- 472 bytes
0eabb595 — Adrian Cochrane Implement table layout. 11 months ago
                                                                                
0eabb595 Adrian Cochrane
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
module Graphics.Layout.Grid.Table where

type Overflowed = [Int]

emptyRow :: Overflowed
emptyRow = []

commitRow :: Overflowed -> Overflowed
commitRow = map $ max 0 . pred

allocCol :: Int -> Overflowed -> Int
allocCol ix cols = ix + length (span (> 0) $ drop ix cols)

insertCell :: Int -> Int -> Int -> Overflowed -> Overflowed
insertCell ix colspan rowspan cols =
    before ++ replicate colspan rowspan ++ drop colspan after
  where (before, after) = splitAt ix cols