Fixup how the standardIOConfig is applied. Correct the Config Monoid. #77

This commit is contained in:
Corey O'Connor 2015-08-09 13:55:12 -07:00
parent 07b7a89f90
commit 954e0f14ec
7 changed files with 15 additions and 9 deletions

View File

@ -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

View File

@ -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

View File

@ -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
}
@ -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

View File

@ -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

View File

@ -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'.
@ -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

View File

@ -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_)

View File

@ -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`
@ -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.
--