module Graphics.Vty.Platform.Unix
( mkVty
, mkVtyWithSettings
)
where
import Control.Monad (when)
import Graphics.Vty (Vty, installCustomWidthTable, mkVtyFromPair)
import Graphics.Vty.Config (VtyUserConfig(..))
import Graphics.Vty.Platform.Unix.Settings
import Graphics.Vty.Platform.Unix.Output
import Graphics.Vty.Platform.Unix.Input
mkVty :: VtyUserConfig
-> IO Vty
mkVty :: VtyUserConfig -> IO Vty
mkVty VtyUserConfig
userConfig =
VtyUserConfig -> UnixSettings -> IO Vty
mkVtyWithSettings VtyUserConfig
userConfig forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< IO UnixSettings
defaultSettings
mkVtyWithSettings :: VtyUserConfig
-> UnixSettings
-> IO Vty
mkVtyWithSettings :: VtyUserConfig -> UnixSettings -> IO Vty
mkVtyWithSettings VtyUserConfig
userConfig UnixSettings
settings = do
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (VtyUserConfig -> Maybe Bool
configAllowCustomUnicodeWidthTables VtyUserConfig
userConfig forall a. Eq a => a -> a -> Bool
/= forall a. a -> Maybe a
Just Bool
False) forall a b. (a -> b) -> a -> b
$
Maybe FilePath -> Maybe FilePath -> [(FilePath, FilePath)] -> IO ()
installCustomWidthTable (VtyUserConfig -> Maybe FilePath
configDebugLog VtyUserConfig
userConfig)
(forall a. a -> Maybe a
Just forall a b. (a -> b) -> a -> b
$ UnixSettings -> FilePath
settingTermName UnixSettings
settings)
(VtyUserConfig -> [(FilePath, FilePath)]
configTermWidthMaps VtyUserConfig
userConfig)
Input
input <- VtyUserConfig -> UnixSettings -> IO Input
buildInput VtyUserConfig
userConfig UnixSettings
settings
Output
out <- UnixSettings -> IO Output
buildOutput UnixSettings
settings
Input -> Output -> IO Vty
mkVtyFromPair Input
input Output
out