module Yi.Window where
import Data.Binary
import Data.Typeable
import Yi.Buffer.Basic (BufferRef)
import Yi.Region (Region,emptyRegion)
import Control.Applicative
type WindowRef = Int
data Window = Window {
isMini :: !Bool
,bufkey :: !BufferRef
,bufAccessList :: ![BufferRef]
,height :: Int
,winRegion :: Region
,wkey :: !WindowRef
}
deriving (Typeable)
instance Binary Window where
put (Window mini bk bl _h _rgn key) = put mini >> put bk >> put bl >> put key
get = Window <$> get <*> get <*> get
<*> return 0 <*> return emptyRegion
<*> get
winkey :: Window -> (Bool, BufferRef)
winkey w = (isMini w, bufkey w)
instance Show Window where
show w = "Window to " ++ show (bufkey w)
++ "(" ++ show (height w) ++ ")"
instance Eq Window where
(==) w1 w2 = wkey w1 == wkey w2
dummyWindowKey :: Int
dummyWindowKey = (1)
dummyWindow :: BufferRef -> Window
dummyWindow b = Window False b [] 0 emptyRegion dummyWindowKey