packages feed

vty 6.0 → 6.1

raw patch · 4 files changed

+44/−3 lines, 4 files

Files

CHANGELOG.md view
@@ -1,4 +1,17 @@ +6.1+---++API changes:+* `ColorMode` got a `Read` instance.+* The `Config` type got a new `configPreferredColorMode` field for+  specifying a preferred `ColorMode`. Backend packages should respect+  this field, but note that `vty` itself does not (and cannot) enact+  this preference since it's up to the backend driver to configure the+  color mode.+* The Vty configuration file got a new `colorMode` field whose value is+  a string literal compatible with the `ColorMode` `Read` instance.+ 6.0 --- 
src/Graphics/Vty/Attributes/Color.hs view
@@ -110,7 +110,7 @@     | ColorMode16     | ColorMode240 !Word8     | FullColor-    deriving ( Eq, Show )+    deriving ( Eq, Show, Read )  black, red, green, yellow, blue, magenta, cyan, white :: Color black  = ISOColor 0
src/Graphics/Vty/Config.hs view
@@ -10,6 +10,20 @@ -- -- = Debug --+-- == @colorMode@+--+-- Format:+--+-- @+--  colorMode \"<ColorMode8|ColorMode16|ColorMode240 <int>|FullColor>\"+-- @+--+-- The preferred color mode to use, chosen from the constructors of the+-- 'ColorMode' type. If absent, the backend driver may detect and choose+-- an appropriate color mode. Implementor's note: backend packages+-- should respect this setting when it is present even when their+-- detection indicates that a different color mode should be used.+-- -- == @debugLog@ -- -- Format:@@ -113,7 +127,9 @@ #if !(MIN_VERSION_base(4,11,0)) import Data.Semigroup (Semigroup(..)) #endif+import Text.Read (readMaybe) +import Graphics.Vty.Attributes.Color (ColorMode(..)) import Graphics.Vty.Input.Events  import GHC.Generics@@ -158,6 +174,9 @@                   -- configuration specifies one. If no custom table is loaded                   -- (or if a load fails), the built-in character width table                   -- will be used.+                  , configPreferredColorMode :: Maybe ColorMode+                  -- ^ Preferred color mode. If set, this should+                  -- override platform color mode detection.                   }                   deriving (Show, Eq) @@ -175,6 +194,8 @@                           configTermWidthMaps c1 <|> configTermWidthMaps c0                       , configAllowCustomUnicodeWidthTables =                           configAllowCustomUnicodeWidthTables c1 <|> configAllowCustomUnicodeWidthTables c0+                      , configPreferredColorMode =+                          configPreferredColorMode c1 <|> configPreferredColorMode c0                       }  instance Monoid VtyUserConfig where@@ -183,6 +204,7 @@                       , configInputMap = mempty                       , configTermWidthMaps = []                       , configAllowCustomUnicodeWidthTables = Nothing+                      , configPreferredColorMode = Nothing                       } #if !(MIN_VERSION_base(4,11,0))     mappend = (<>)@@ -285,6 +307,12 @@     path       <- P.stringLiteral configLexer     return defaultConfig { configDebugLog = Just path } +colorModeDecl :: Parser VtyUserConfig+colorModeDecl = do+    "colorMode" <- P.identifier configLexer+    mode <- P.stringLiteral configLexer+    return defaultConfig { configPreferredColorMode = readMaybe mode }+ widthMapDecl :: Parser VtyUserConfig widthMapDecl = do     "widthMap" <- P.identifier configLexer@@ -298,7 +326,7 @@ parseConfig :: Parser VtyUserConfig parseConfig = liftM mconcat $ many $ do     P.whiteSpace configLexer-    let directives = [try mapDecl, try debugLogDecl, try widthMapDecl]+    let directives = [try mapDecl, try debugLogDecl, try widthMapDecl, try colorModeDecl]     choice directives <|> (ignoreLine >> return defaultConfig)  class    Parse a        where parseValue :: Parser a
vty.cabal view
@@ -1,5 +1,5 @@ name:                vty-version:             6.0+version:             6.1 license:             BSD3 license-file:        LICENSE author:              AUTHORS