on master help sign in
compile fixup
commitaa67f22b38de8b188ffc6109905565954b5244a5 authorCorey O'Connor <coreyoconnor@gmail.com> dateMon 26 May 2014, 21:46 (12 years ago) parent522b740
6 files changed+29−13
src/Graphics/Vty/Config.hs+1−1 src/Graphics/Vty/Inline/Unsafe.hs+3−1 src/Graphics/Vty/Input/Loop.hs+22−8 src/Graphics/Vty/Input/Terminfo.hs+1−1 src/Graphics/Vty/Input/Terminfo/ANSIVT.hs−2 src/Graphics/Vty/Output.hs+2
src/Graphics/Vty/Config.hs+1−1
@@ -127,7 +127,7 @@ userConfig = do
127127 overridePath <- tryJust (guard . isDoesNotExistError) $ getEnv "VTY_CONFIG_FILE"
128128 overrideConfig <- either (const $ return def) parseConfigFile overridePath
129129 debugLogPath <- tryJust (guard . isDoesNotExistError) $ getEnv "VTY_DEBUG_LOG"
130− let debugLogConfig = either (const $ return def) (def { debugLog = Just debugLogPath })
130+ let debugLogConfig = either (const def) (\p -> def { debugLog = Just p }) debugLogPath
131131 return $ mconcat [userConfig, overrideConfig, debugLogConfig]
132132
133133parseConfigFile :: FilePath -> IO Config
src/Graphics/Vty/Inline/Unsafe.hs+3−1
@@ -1,6 +1,7 @@
11module Graphics.Vty.Inline.Unsafe where
22
33import Graphics.Vty
4+import Graphics.Vty.Config (userConfig)
45
56import Data.Default
67import Data.IORef
@@ -33,7 +34,8 @@ withOutput f = do
3334 mout <- readIORef globalOutput
3435 out <- case mout of
3536 Nothing -> do
36− out <- outputForCurrentTerminal
37+ config <- userConfig
38+ out <- outputForCurrentTerminal config
3739 writeIORef globalOutput (Just out)
3840 return out
3941 Just out -> return out
src/Graphics/Vty/Input/Loop.hs+22−8
@@ -71,6 +71,13 @@ makeLenses ''InputState
7171
7272type InputM a = StateT InputState (ReaderT Input IO) a
7373
74+logMsg :: String -> InputM ()
75+logMsg msg = do
76+ d <- view inputDebug
77+ case d of
78+ Nothing -> return ()
79+ Just h -> liftIO $ hPutStrLn h msg >> hFlush h
80+
7481-- this must be run on an OS thread dedicated to this input handling.
7582-- otherwise the terminal timing read behavior will block the execution of the lightweight threads.
7683loopInputProcessor :: InputM ()
@@ -85,11 +92,15 @@ addBytesToProcess :: String -> InputM ()
8592addBytesToProcess block = unprocessedBytes <>= block
8693
8794emit :: Event -> InputM ()
88−emit event = view eventChannel >>= liftIO . flip writeChan event
95+emit event = do
96+ logMsg $ "parsed event: " ++ show event
97+ view eventChannel >>= liftIO . flip writeChan event
8998
90−-- There should be two versions of this method:
91−-- 1. using VMIN and VTIME when under the threaded runtime
92−-- 2. emulating VMIN and VTIME in userspace when under the non-threaded runtime.
99+-- The timing requirements are assured by the VMIN and VTIME set for the device.
100+--
101+-- Precondition: Under the threaded runtime. Only current use is from a forkOS thread. That case
102+-- satisfies precondition.
103+-- TODO: When under the non-threaded runtime emulate VMIN and VTIME
93104readFromDevice :: InputM String
94105readFromDevice = do
95106 newConfig <- view configRef >>= liftIO . readIORef
@@ -100,11 +111,13 @@ readFromDevice = do
100111 appliedConfig .= newConfig
101112 bufferPtr <- use $ inputBuffer.ptr
102113 maxBytes <- use $ inputBuffer.size
103− liftIO $ do
114+ stringRep <- liftIO $ do
104115 bytesRead <- fdReadBuf fd bufferPtr (fromIntegral maxBytes)
105116 if bytesRead > 0
106117 then fmap (map $ chr . fromIntegral) $ peekArray (fromIntegral bytesRead) bufferPtr
107118 else return []
119+ logMsg $ "input bytes: " ++ show stringRep
120+ return stringRep
108121
109122applyTimingConfig :: Fd -> Config -> IO ()
110123applyTimingConfig fd config =
@@ -170,9 +183,10 @@ initInputForFd config classifyTable inFd = do
170183 <*> pure (writeIORef stopFlag True)
171184 <*> newIORef config
172185 <*> pure inFd
173− <*> maybe Nothing (\f -> Just <$> openFile f AppendMode)
174− (debugLog config)
175− logClassifyTable classifyTable
186+ <*> maybe (return Nothing)
187+ (\f -> Just <$> openFile f AppendMode)
188+ (debugLog config)
189+ logClassifyTable input classifyTable
176190 _ <- forkOS $ runInputProcessorLoop classifyTable input stopFlag
177191 return input
178192
src/Graphics/Vty/Input/Terminfo.hs+1−1
@@ -37,7 +37,7 @@ classifyTableForTerm :: String -> Terminal -> ClassifyTable
3737classifyTableForTerm termName term =
3838 concat $ capsClassifyTable term keysFromCapsTable
3939 : universalTable
40− : termSpecificTable termName
40+ : termSpecificTables termName
4141
4242-- | key table applicable to all terminals.
4343--
src/Graphics/Vty/Input/Terminfo/ANSIVT.hs−2
@@ -7,8 +7,6 @@ module Graphics.Vty.Input.Terminfo.ANSIVT where
77
88import Graphics.Vty.Input.Events
99
10−import Data.List (isInfixOf, isPrefixOf)
11−
1210-- | Encoding for navigation keys.
1311--
1412-- TODO: This is not the same as the input bytes pulled from teh caps table.
src/Graphics/Vty/Output.hs+2
@@ -28,6 +28,8 @@ module Graphics.Vty.Output ( module Graphics.Vty.Output
2828
2929import Graphics.Vty.Prelude
3030
31+import Graphics.Vty.Config
32+
3133import Graphics.Vty.Output.Interface
3234import Graphics.Vty.Output.MacOSX as MacOSX
3335import Graphics.Vty.Output.XTermColor as XTermColor