-- GENERATED by C->Haskell Compiler, version 0.25.2 Snowboundest, 31 Oct 2014 (Haskell)
-- Edit the ORIGNAL .chs file instead!


{-# LINE 1 "src/Termbox/Modes.chs" #-}
module Termbox.Modes where

import Data.Bits



data InputMode = InputMode
  { isEsc :: Bool
  , isAlt :: Bool
  , isMouse :: Bool
  } deriving (Show, Eq)

toInputMode :: Int -> InputMode
toInputMode bits = InputMode
  { isEsc   = 0 /= bits .&. 1
{-# LINE 15 "src/Termbox/Modes.chs" #-}

  , isAlt   = 0 /= bits .&. 2
{-# LINE 16 "src/Termbox/Modes.chs" #-}

  , isMouse = 0 /= bits .&. 4
{-# LINE 17 "src/Termbox/Modes.chs" #-}

  }

fromInputMode :: InputMode -> Int
fromInputMode mode =
  let e = if isEsc mode   then 1 else 0
      a = if isAlt mode   then 2 else 0
      m = if isMouse mode then 4 else 0
  in e .|. a .|. m

inputMode :: InputMode
inputMode = InputMode False False False

data OutputMode = OutputMode
  { isNormal :: Bool
  , is256 :: Bool
  , is216 :: Bool
  , isGrayscale :: Bool
  } deriving (Show, Eq)

toOutputMode :: Int -> OutputMode
toOutputMode bits = OutputMode
  { isNormal    = 0 /= bits .&. 1
{-# LINE 39 "src/Termbox/Modes.chs" #-}

  , is256       = 0 /= bits .&. 2
{-# LINE 40 "src/Termbox/Modes.chs" #-}

  , is216       = 0 /= bits .&. 3
{-# LINE 41 "src/Termbox/Modes.chs" #-}

  , isGrayscale = 0 /= bits .&. 4
{-# LINE 42 "src/Termbox/Modes.chs" #-}

  }

fromOutputMode :: OutputMode -> Int
fromOutputMode mode =
  let n = if isNormal mode    then 1 else 0
      h = if is256 mode       then 2 else 0
      l = if is216 mode       then 3 else 0
      g = if isGrayscale mode then 4 else 0
  in n .|. h .|. l .|. g

outputMode :: OutputMode
outputMode = OutputMode False False False False