on master help sign in
compile fixup
aa67f22Corey O'Connor
src/Graphics/Vty/Config.hs+1−1
@@ -127,7 +127,7 @@ userConfig = do
127 overridePath <- tryJust (guard . isDoesNotExistError) $ getEnv "VTY_CONFIG_FILE"
127 overridePath <- tryJust (guard . isDoesNotExistError) $ getEnv "VTY_CONFIG_FILE"
128 overrideConfig <- either (const $ return def) parseConfigFile overridePath
128 overrideConfig <- either (const $ return def) parseConfigFile overridePath
129 debugLogPath <- tryJust (guard . isDoesNotExistError) $ getEnv "VTY_DEBUG_LOG"
129 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
131 return $ mconcat [userConfig, overrideConfig, debugLogConfig]
131 return $ mconcat [userConfig, overrideConfig, debugLogConfig]
132
132
133parseConfigFile :: FilePath -> IO Config
133parseConfigFile :: FilePath -> IO Config
src/Graphics/Vty/Inline/Unsafe.hs+3−1
@@ -1,6 +1,7 @@
1module Graphics.Vty.Inline.Unsafe where
1module Graphics.Vty.Inline.Unsafe where
2
2
3import Graphics.Vty
3import Graphics.Vty
4+import Graphics.Vty.Config (userConfig)
4
5
5import Data.Default
6import Data.Default
6import Data.IORef
7import Data.IORef
@@ -33,7 +34,8 @@ withOutput f = do
33 mout <- readIORef globalOutput
34 mout <- readIORef globalOutput
34 out <- case mout of
35 out <- case mout of
35 Nothing -> do
36 Nothing -> do
37+ config <- userConfig
36− out <- outputForCurrentTerminal
38+ out <- outputForCurrentTerminal config
37 writeIORef globalOutput (Just out)
39 writeIORef globalOutput (Just out)
38 return out
40 return out
39 Just out -> return out
41 Just out -> return out
src/Graphics/Vty/Input/Loop.hs+22−8
@@ -71,6 +71,13 @@ makeLenses ''InputState
71
71
72type InputM a = StateT InputState (ReaderT Input IO) a
72type InputM a = StateT InputState (ReaderT Input IO) a
73
73
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+
74-- this must be run on an OS thread dedicated to this input handling.
81-- this must be run on an OS thread dedicated to this input handling.
75-- otherwise the terminal timing read behavior will block the execution of the lightweight threads.
82-- otherwise the terminal timing read behavior will block the execution of the lightweight threads.
76loopInputProcessor :: InputM ()
83loopInputProcessor :: InputM ()
@@ -85,11 +92,15 @@ addBytesToProcess :: String -> InputM ()
85addBytesToProcess block = unprocessedBytes <>= block
92addBytesToProcess block = unprocessedBytes <>= block
86
93
87emit :: Event -> InputM ()
94emit :: Event -> InputM ()
95+emit event = do
96+ logMsg $ "parsed event: " ++ show event
88−emit event = view eventChannel >>= liftIO . flip writeChan event
97+ view eventChannel >>= liftIO . flip writeChan event
89
98
90−-- There should be two versions of this method:
99+-- The timing requirements are assured by the VMIN and VTIME set for the device.
91−-- 1. using VMIN and VTIME when under the threaded runtime
100+--
101+-- Precondition: Under the threaded runtime. Only current use is from a forkOS thread. That case
102+-- satisfies precondition.
92−-- 2. emulating VMIN and VTIME in userspace when under the non-threaded runtime.
103+-- TODO: When under the non-threaded runtime emulate VMIN and VTIME
93readFromDevice :: InputM String
104readFromDevice :: InputM String
94readFromDevice = do
105readFromDevice = do
95 newConfig <- view configRef >>= liftIO . readIORef
106 newConfig <- view configRef >>= liftIO . readIORef
@@ -100,11 +111,13 @@ readFromDevice = do
100 appliedConfig .= newConfig
111 appliedConfig .= newConfig
101 bufferPtr <- use $ inputBuffer.ptr
112 bufferPtr <- use $ inputBuffer.ptr
102 maxBytes <- use $ inputBuffer.size
113 maxBytes <- use $ inputBuffer.size
103− liftIO $ do
114+ stringRep <- liftIO $ do
104 bytesRead <- fdReadBuf fd bufferPtr (fromIntegral maxBytes)
115 bytesRead <- fdReadBuf fd bufferPtr (fromIntegral maxBytes)
105 if bytesRead > 0
116 if bytesRead > 0
106 then fmap (map $ chr . fromIntegral) $ peekArray (fromIntegral bytesRead) bufferPtr
117 then fmap (map $ chr . fromIntegral) $ peekArray (fromIntegral bytesRead) bufferPtr
107 else return []
118 else return []
119+ logMsg $ "input bytes: " ++ show stringRep
120+ return stringRep
108
121
109applyTimingConfig :: Fd -> Config -> IO ()
122applyTimingConfig :: Fd -> Config -> IO ()
110applyTimingConfig fd config =
123applyTimingConfig fd config =
@@ -170,9 +183,10 @@ initInputForFd config classifyTable inFd = do
170 <*> pure (writeIORef stopFlag True)
183 <*> pure (writeIORef stopFlag True)
171 <*> newIORef config
184 <*> newIORef config
172 <*> pure inFd
185 <*> pure inFd
186+ <*> maybe (return Nothing)
173− <*> maybe Nothing (\f -> Just <$> openFile f AppendMode)
187+ (\f -> Just <$> openFile f AppendMode)
174− (debugLog config)
188+ (debugLog config)
175− logClassifyTable classifyTable
189+ logClassifyTable input classifyTable
176 _ <- forkOS $ runInputProcessorLoop classifyTable input stopFlag
190 _ <- forkOS $ runInputProcessorLoop classifyTable input stopFlag
177 return input
191 return input
178
192
src/Graphics/Vty/Input/Terminfo.hs+1−1
@@ -37,7 +37,7 @@ classifyTableForTerm :: String -> Terminal -> ClassifyTable
37classifyTableForTerm termName term =
37classifyTableForTerm termName term =
38 concat $ capsClassifyTable term keysFromCapsTable
38 concat $ capsClassifyTable term keysFromCapsTable
39 : universalTable
39 : universalTable
40− : termSpecificTable termName
40+ : termSpecificTables termName
41
41
42-- | key table applicable to all terminals.
42-- | key table applicable to all terminals.
43--
43--
src/Graphics/Vty/Input/Terminfo/ANSIVT.hs−2
@@ -7,8 +7,6 @@ module Graphics.Vty.Input.Terminfo.ANSIVT where
7
7
8import Graphics.Vty.Input.Events
8import Graphics.Vty.Input.Events
9
9
10−import Data.List (isInfixOf, isPrefixOf)
11−
12-- | Encoding for navigation keys.
10-- | Encoding for navigation keys.
13--
11--
14-- TODO: This is not the same as the input bytes pulled from teh caps table.
12-- 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
28
28
29import Graphics.Vty.Prelude
29import Graphics.Vty.Prelude
30
30
31+import Graphics.Vty.Config
32+
31import Graphics.Vty.Output.Interface
33import Graphics.Vty.Output.Interface
32import Graphics.Vty.Output.MacOSX as MacOSX
34import Graphics.Vty.Output.MacOSX as MacOSX
33import Graphics.Vty.Output.XTermColor as XTermColor
35import Graphics.Vty.Output.XTermColor as XTermColor