on master help sign in
Fixup how the standardIOConfig is applied. Correct the Config Monoid. #77
954e0f1Corey O'Connor
CHANGELOG+3
@@ -1,4 +1,7 @@
15.2.12
15.2.12
2+ - The standard IO Config (standardIOConfig) was overriding any provided application config.
3+ In addition, the inputFd and outputFd could not be changed if mkVty was used.
4+ Fixed.
2 - Correct handling of display attributes at end of line. The output attributes are set to default
5 - Correct handling of display attributes at end of line. The output attributes are set to default
3 at the end of content for the line and at the start of a new line. Previously the current
6 at the end of content for the line and at the start of a new line. Previously the current
4 attribute would extend to the next start of content. This was odd to reason about and was the
7 attribute would extend to the next start of content. This was odd to reason about and was the
Demo.hs+1−1
@@ -20,7 +20,7 @@ type App = RWST Vty () (Seq String) IO
20main = do
20main = do
21 vty <- if True -- change to false for emacs-like input processing
21 vty <- if True -- change to false for emacs-like input processing
22 then mkVty def
22 then mkVty def
23− else mkVty (def { vmin = Just 2, vtime = Just 100 } )
23+ else mkVty (def { vmin = Just 2, vtime = Just 300 } )
24 _ <- execRWST (vtyInteract False) vty Seq.empty
24 _ <- execRWST (vtyInteract False) vty Seq.empty
25 shutdown vty
25 shutdown vty
26
26
src/Graphics/Vty/Config.hs+4−4
@@ -139,8 +139,8 @@ instance Monoid Config where
139 , vtime = vtime c1 <|> vtime c0
139 , vtime = vtime c1 <|> vtime c0
140 , debugLog = debugLog c1 <|> debugLog c0
140 , debugLog = debugLog c1 <|> debugLog c0
141 , inputMap = inputMap c0 <> inputMap c1
141 , inputMap = inputMap c0 <> inputMap c1
142− , inputFd = inputFd c1 <|> inputFd c1
142+ , inputFd = inputFd c1 <|> inputFd c0
143− , outputFd = outputFd c1 <|> outputFd c1
143+ , outputFd = outputFd c1 <|> outputFd c0
144 , termName = termName c1 <|> termName c0
144 , termName = termName c1 <|> termName c0
145 }
145 }
146
146
@@ -151,8 +151,8 @@ userConfig :: IO Config
151userConfig = do
151userConfig = do
152 configFile <- (mappend <$> getAppUserDataDirectory "vty" <*> pure "/config") >>= parseConfigFile
152 configFile <- (mappend <$> getAppUserDataDirectory "vty" <*> pure "/config") >>= parseConfigFile
153 overrideConfig <- maybe (return def) parseConfigFile =<< getEnv "VTY_CONFIG_FILE"
153 overrideConfig <- maybe (return def) parseConfigFile =<< getEnv "VTY_CONFIG_FILE"
154− base <- (<> configFile <> overrideConfig) <$> standardIOConfig
154+ let base = configFile <> overrideConfig
155− (mappend base) <$> overrideEnvConfig
155+ mappend base <$> overrideEnvConfig
156
156
157overrideEnvConfig :: IO Config
157overrideEnvConfig :: IO Config
158overrideEnvConfig = do
158overrideEnvConfig = do
src/Graphics/Vty/Inline/Unsafe.hs+1−1
@@ -61,7 +61,7 @@ withOutput f = do
61 mout <- readIORef globalOutput
61 mout <- readIORef globalOutput
62 out <- case mout of
62 out <- case mout of
63 Nothing -> do
63 Nothing -> do
64− config <- (<>) <$> userConfig <*> mkDupeConfig
64+ config <- mappend <$> userConfig <*> mkDupeConfig
65 out <- outputForConfig config
65 out <- outputForConfig config
66 writeIORef globalOutput (Just out)
66 writeIORef globalOutput (Just out)
67 return out
67 return out
src/Graphics/Vty/Input.hs+3−1
@@ -145,6 +145,8 @@ import System.Posix.Signals.Exts
145#if !(MIN_VERSION_base(4,8,0))
145#if !(MIN_VERSION_base(4,8,0))
146import Data.Functor ((<$>))
146import Data.Functor ((<$>))
147import Data.Monoid
147import Data.Monoid
148+#else
149+import Data.Monoid ((<>))
148#endif
150#endif
149
151
150-- | Set up the terminal with file descriptor `inputFd` for input. Returns a 'Input'.
152-- | Set up the terminal with file descriptor `inputFd` for input. Returns a 'Input'.
@@ -201,4 +203,4 @@ inputForConfig config@Config{ termName = Just termName
201 _ <- installHandler continueProcess Ignore Nothing
203 _ <- installHandler continueProcess Ignore Nothing
202 unsetAttrs
204 unsetAttrs
203 }
205 }
204−inputForConfig config = mappend config <$> standardIOConfig >>= inputForConfig
206+inputForConfig config = (<> config) <$> standardIOConfig >>= inputForConfig
src/Graphics/Vty/Input/Loop.hs−1
@@ -19,7 +19,6 @@ import Graphics.Vty.Input.Events
19
19
20import Control.Applicative
20import Control.Applicative
21import Control.Concurrent
21import Control.Concurrent
22−import Control.Concurrent.MVar
23import Control.Exception (mask, try, SomeException)
22import Control.Exception (mask, try, SomeException)
24import Control.Lens
23import Control.Lens
25import Control.Monad (when, mzero, forM_)
24import Control.Monad (when, mzero, forM_)
src/Graphics/Vty/Output.hs+3−1
@@ -50,6 +50,8 @@ import Data.List (isPrefixOf)
50
50
51#if !(MIN_VERSION_base(4,8,0))
51#if !(MIN_VERSION_base(4,8,0))
52import Data.Monoid (mappend)
52import Data.Monoid (mappend)
53+#else
54+import Data.Monoid ((<>))
53#endif
55#endif
54
56
55-- | Returns a `Output` for the terminal specified in `Config`
57-- | Returns a `Output` for the terminal specified in `Config`
@@ -76,7 +78,7 @@ outputForConfig Config{ outputFd = Just fd, termName = Just termName, .. } = do
76 -- Not an xterm-like terminal. try for generic terminfo.
78 -- Not an xterm-like terminal. try for generic terminfo.
77 else TerminfoBased.reserveTerminal termName fd
79 else TerminfoBased.reserveTerminal termName fd
78 return t
80 return t
79−outputForConfig config = mappend config <$> standardIOConfig >>= outputForConfig
81+outputForConfig config = (<> config) <$> standardIOConfig >>= outputForConfig
80
82
81-- | Sets the cursor position to the given output column and row.
83-- | Sets the cursor position to the given output column and row.
82--
84--