packages feed

vty-windows 0.1.0.3 → 0.2.0.0

raw patch · 5 files changed

+18/−15 lines, 5 filesdep ~Win32dep ~basedep ~vty

Dependency ranges changed: Win32, base, vty

Files

CHANGELOG.md view
@@ -20,3 +20,8 @@ 
 Package changes:
  * Removed unnecessary version bounds on dependencies.
+
+0.2.0.0
+-------
+* The color mode configuration moved from Windows specific
+  settings to the vty user config.
src/Graphics/Vty/Platform/Windows.hs view
@@ -38,5 +38,5 @@                                 (configTermWidthMaps userConfig)
 
     input <- buildInput userConfig settings
-    out <- buildOutput settings
+    out <- buildOutput userConfig settings
     mkVtyFromPair input out
src/Graphics/Vty/Platform/Windows/Output.hs view
@@ -9,7 +9,9 @@   )
 where
 
+import Graphics.Vty.Config
 import Graphics.Vty.Platform.Windows.Settings
+import Graphics.Vty.Platform.Windows.Output.Color (detectColorMode)
 import Graphics.Vty.Platform.Windows.Output.XTermColor as XTermColor
 import Graphics.Vty.Platform.Windows.Output.TerminfoBased as TerminfoBased
 import Graphics.Vty.Output
@@ -30,11 +32,14 @@ --
 --      * If TERM starts with "xterm", "screen" or "tmux", use XTermColor.
 --      * otherwise use the TerminfoBased driver.
-buildOutput :: WindowsSettings -> IO Output
-buildOutput settings = do
+buildOutput :: VtyUserConfig -> WindowsSettings -> IO Output
+buildOutput config settings = do
     let outHandle = settingOutputFd settings
         termName = settingTermName settings
-        colorMode = settingColorMode settings
+
+    colorMode <- case configPreferredColorMode config of
+        Nothing -> detectColorMode termName
+        Just m -> return m
 
     if isXtermLike termName
         then XTermColor.reserveTerminal termName outHandle colorMode
src/Graphics/Vty/Platform/Windows/Settings.hs view
@@ -7,8 +7,6 @@ where
 
 import Data.Maybe ( fromMaybe ) 
-import Graphics.Vty.Attributes.Color ( ColorMode(..) )
-import Graphics.Vty.Platform.Windows.Output.Color ( detectColorMode, defaultColorMode )
 import System.Environment ( lookupEnv )
 import System.IO ( Handle, stdin, stdout )
 
@@ -20,9 +18,6 @@   -- ^ The output file descriptor to use.
   , settingTermName :: String
   -- ^ The terminal name used to look up terminfo capabilities.
-  , settingColorMode :: ColorMode
-  -- ^ The color mode used to know how many colors the terminal
-  -- supports.
   }
   deriving (Show, Eq)
 
@@ -31,12 +26,10 @@ defaultSettings = do
     mb <- lookupEnv termVariable
     let termName = fromMaybe "xterm-256color" mb
-    colorMode <- maybe defaultColorMode detectColorMode mb
 
     return $ WindowsSettings { settingInputFd  = stdin
                              , settingOutputFd  = stdout
                              , settingTermName  = termName
-                             , settingColorMode = colorMode
                              }
 
 -- | The TERM environment variable
vty-windows.cabal view
@@ -1,6 +1,6 @@ cabal-version:      3.0
 name:               vty-windows
-version:            0.1.0.3
+version:            0.2.0.0
 license:            BSD-3-Clause
 license-file:       LICENSE
 author:             Chris hackett
@@ -43,7 +43,7 @@                       Graphics.Vty.Platform.Windows.WindowsCapabilities
                       Graphics.Vty.Platform.Windows.WindowsConsoleInput
                       Graphics.Vty.Platform.Windows.WindowsInterfaces
-    build-depends:    base                >= 4.9.0.0 && < 5.0,
+    build-depends:    base                >= 4.9 && < 5,
                       blaze-builder,
                       bytestring,
                       containers,
@@ -59,7 +59,7 @@                       transformers,
                       utf8-string,
                       vector,
-                      vty                 >= 6.0 && < 7.0,
-                      Win32               >= 2.8.5.0 && < 3.0,
+                      vty                 >= 6.1,
+                      Win32               >= 2.8.5.0,
     hs-source-dirs:   src
     default-language: Haskell2010