Skip to content

Commit

Permalink
Fixup how the standardIOConfig is applied. Correct the Config Monoid. #…
Browse files Browse the repository at this point in the history
  • Loading branch information
coreyoconnor committed Aug 9, 2015
1 parent 07b7a89 commit 954e0f1
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 9 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG
@@ -1,4 +1,7 @@
5.2.12
- The standard IO Config (standardIOConfig) was overriding any provided application config.
In addition, the inputFd and outputFd could not be changed if mkVty was used.
Fixed.
- Correct handling of display attributes at end of line. The output attributes are set to default
at the end of content for the line and at the start of a new line. Previously the current
attribute would extend to the next start of content. This was odd to reason about and was the
Expand Down
2 changes: 1 addition & 1 deletion Demo.hs
Expand Up @@ -20,7 +20,7 @@ type App = RWST Vty () (Seq String) IO
main = do
vty <- if True -- change to false for emacs-like input processing
then mkVty def
else mkVty (def { vmin = Just 2, vtime = Just 100 } )
else mkVty (def { vmin = Just 2, vtime = Just 300 } )
_ <- execRWST (vtyInteract False) vty Seq.empty
shutdown vty

Expand Down
8 changes: 4 additions & 4 deletions src/Graphics/Vty/Config.hs
Expand Up @@ -139,8 +139,8 @@ instance Monoid Config where
, vtime = vtime c1 <|> vtime c0
, debugLog = debugLog c1 <|> debugLog c0
, inputMap = inputMap c0 <> inputMap c1
, inputFd = inputFd c1 <|> inputFd c1
, outputFd = outputFd c1 <|> outputFd c1
, inputFd = inputFd c1 <|> inputFd c0
, outputFd = outputFd c1 <|> outputFd c0
, termName = termName c1 <|> termName c0
}

Expand All @@ -151,8 +151,8 @@ userConfig :: IO Config
userConfig = do
configFile <- (mappend <$> getAppUserDataDirectory "vty" <*> pure "/config") >>= parseConfigFile
overrideConfig <- maybe (return def) parseConfigFile =<< getEnv "VTY_CONFIG_FILE"
base <- (<> configFile <> overrideConfig) <$> standardIOConfig
(mappend base) <$> overrideEnvConfig
let base = configFile <> overrideConfig
mappend base <$> overrideEnvConfig

overrideEnvConfig :: IO Config
overrideEnvConfig = do
Expand Down
2 changes: 1 addition & 1 deletion src/Graphics/Vty/Inline/Unsafe.hs
Expand Up @@ -61,7 +61,7 @@ withOutput f = do
mout <- readIORef globalOutput
out <- case mout of
Nothing -> do
config <- (<>) <$> userConfig <*> mkDupeConfig
config <- mappend <$> userConfig <*> mkDupeConfig
out <- outputForConfig config
writeIORef globalOutput (Just out)
return out
Expand Down
4 changes: 3 additions & 1 deletion src/Graphics/Vty/Input.hs
Expand Up @@ -145,6 +145,8 @@ import System.Posix.Signals.Exts
#if !(MIN_VERSION_base(4,8,0))
import Data.Functor ((<$>))
import Data.Monoid
#else
import Data.Monoid ((<>))
#endif

-- | Set up the terminal with file descriptor `inputFd` for input. Returns a 'Input'.
Expand Down Expand Up @@ -201,4 +203,4 @@ inputForConfig config@Config{ termName = Just termName
_ <- installHandler continueProcess Ignore Nothing
unsetAttrs
}
inputForConfig config = mappend config <$> standardIOConfig >>= inputForConfig
inputForConfig config = (<> config) <$> standardIOConfig >>= inputForConfig
1 change: 0 additions & 1 deletion src/Graphics/Vty/Input/Loop.hs
Expand Up @@ -19,7 +19,6 @@ import Graphics.Vty.Input.Events

import Control.Applicative
import Control.Concurrent
import Control.Concurrent.MVar
import Control.Exception (mask, try, SomeException)
import Control.Lens
import Control.Monad (when, mzero, forM_)
Expand Down
4 changes: 3 additions & 1 deletion src/Graphics/Vty/Output.hs
Expand Up @@ -50,6 +50,8 @@ import Data.List (isPrefixOf)

#if !(MIN_VERSION_base(4,8,0))
import Data.Monoid (mappend)
#else
import Data.Monoid ((<>))
#endif

-- | Returns a `Output` for the terminal specified in `Config`
Expand All @@ -76,7 +78,7 @@ outputForConfig Config{ outputFd = Just fd, termName = Just termName, .. } = do
-- Not an xterm-like terminal. try for generic terminfo.
else TerminfoBased.reserveTerminal termName fd
return t
outputForConfig config = mappend config <$> standardIOConfig >>= outputForConfig
outputForConfig config = (<> config) <$> standardIOConfig >>= outputForConfig

-- | Sets the cursor position to the given output column and row.
--
Expand Down

0 comments on commit 954e0f1

Please sign in to comment.