mirror of
https://github.com/ilyakooo0/vty.git
synced 2024-11-30 02:13:36 +03:00
compile fixup
This commit is contained in:
parent
522b740b8a
commit
aa67f22b38
@ -127,7 +127,7 @@ userConfig = do
|
|||||||
overridePath <- tryJust (guard . isDoesNotExistError) $ getEnv "VTY_CONFIG_FILE"
|
overridePath <- tryJust (guard . isDoesNotExistError) $ getEnv "VTY_CONFIG_FILE"
|
||||||
overrideConfig <- either (const $ return def) parseConfigFile overridePath
|
overrideConfig <- either (const $ return def) parseConfigFile overridePath
|
||||||
debugLogPath <- tryJust (guard . isDoesNotExistError) $ getEnv "VTY_DEBUG_LOG"
|
debugLogPath <- tryJust (guard . isDoesNotExistError) $ getEnv "VTY_DEBUG_LOG"
|
||||||
let debugLogConfig = either (const $ return def) (def { debugLog = Just debugLogPath })
|
let debugLogConfig = either (const def) (\p -> def { debugLog = Just p }) debugLogPath
|
||||||
return $ mconcat [userConfig, overrideConfig, debugLogConfig]
|
return $ mconcat [userConfig, overrideConfig, debugLogConfig]
|
||||||
|
|
||||||
parseConfigFile :: FilePath -> IO Config
|
parseConfigFile :: FilePath -> IO Config
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
module Graphics.Vty.Inline.Unsafe where
|
module Graphics.Vty.Inline.Unsafe where
|
||||||
|
|
||||||
import Graphics.Vty
|
import Graphics.Vty
|
||||||
|
import Graphics.Vty.Config (userConfig)
|
||||||
|
|
||||||
import Data.Default
|
import Data.Default
|
||||||
import Data.IORef
|
import Data.IORef
|
||||||
@ -33,7 +34,8 @@ withOutput f = do
|
|||||||
mout <- readIORef globalOutput
|
mout <- readIORef globalOutput
|
||||||
out <- case mout of
|
out <- case mout of
|
||||||
Nothing -> do
|
Nothing -> do
|
||||||
out <- outputForCurrentTerminal
|
config <- userConfig
|
||||||
|
out <- outputForCurrentTerminal config
|
||||||
writeIORef globalOutput (Just out)
|
writeIORef globalOutput (Just out)
|
||||||
return out
|
return out
|
||||||
Just out -> return out
|
Just out -> return out
|
||||||
|
@ -71,6 +71,13 @@ makeLenses ''InputState
|
|||||||
|
|
||||||
type InputM a = StateT InputState (ReaderT Input IO) a
|
type InputM a = StateT InputState (ReaderT Input IO) a
|
||||||
|
|
||||||
|
logMsg :: String -> InputM ()
|
||||||
|
logMsg msg = do
|
||||||
|
d <- view inputDebug
|
||||||
|
case d of
|
||||||
|
Nothing -> return ()
|
||||||
|
Just h -> liftIO $ hPutStrLn h msg >> hFlush h
|
||||||
|
|
||||||
-- this must be run on an OS thread dedicated to this input handling.
|
-- this must be run on an OS thread dedicated to this input handling.
|
||||||
-- otherwise the terminal timing read behavior will block the execution of the lightweight threads.
|
-- otherwise the terminal timing read behavior will block the execution of the lightweight threads.
|
||||||
loopInputProcessor :: InputM ()
|
loopInputProcessor :: InputM ()
|
||||||
@ -85,11 +92,15 @@ addBytesToProcess :: String -> InputM ()
|
|||||||
addBytesToProcess block = unprocessedBytes <>= block
|
addBytesToProcess block = unprocessedBytes <>= block
|
||||||
|
|
||||||
emit :: Event -> InputM ()
|
emit :: Event -> InputM ()
|
||||||
emit event = view eventChannel >>= liftIO . flip writeChan event
|
emit event = do
|
||||||
|
logMsg $ "parsed event: " ++ show event
|
||||||
|
view eventChannel >>= liftIO . flip writeChan event
|
||||||
|
|
||||||
-- There should be two versions of this method:
|
-- The timing requirements are assured by the VMIN and VTIME set for the device.
|
||||||
-- 1. using VMIN and VTIME when under the threaded runtime
|
--
|
||||||
-- 2. emulating VMIN and VTIME in userspace when under the non-threaded runtime.
|
-- Precondition: Under the threaded runtime. Only current use is from a forkOS thread. That case
|
||||||
|
-- satisfies precondition.
|
||||||
|
-- TODO: When under the non-threaded runtime emulate VMIN and VTIME
|
||||||
readFromDevice :: InputM String
|
readFromDevice :: InputM String
|
||||||
readFromDevice = do
|
readFromDevice = do
|
||||||
newConfig <- view configRef >>= liftIO . readIORef
|
newConfig <- view configRef >>= liftIO . readIORef
|
||||||
@ -100,11 +111,13 @@ readFromDevice = do
|
|||||||
appliedConfig .= newConfig
|
appliedConfig .= newConfig
|
||||||
bufferPtr <- use $ inputBuffer.ptr
|
bufferPtr <- use $ inputBuffer.ptr
|
||||||
maxBytes <- use $ inputBuffer.size
|
maxBytes <- use $ inputBuffer.size
|
||||||
liftIO $ do
|
stringRep <- liftIO $ do
|
||||||
bytesRead <- fdReadBuf fd bufferPtr (fromIntegral maxBytes)
|
bytesRead <- fdReadBuf fd bufferPtr (fromIntegral maxBytes)
|
||||||
if bytesRead > 0
|
if bytesRead > 0
|
||||||
then fmap (map $ chr . fromIntegral) $ peekArray (fromIntegral bytesRead) bufferPtr
|
then fmap (map $ chr . fromIntegral) $ peekArray (fromIntegral bytesRead) bufferPtr
|
||||||
else return []
|
else return []
|
||||||
|
logMsg $ "input bytes: " ++ show stringRep
|
||||||
|
return stringRep
|
||||||
|
|
||||||
applyTimingConfig :: Fd -> Config -> IO ()
|
applyTimingConfig :: Fd -> Config -> IO ()
|
||||||
applyTimingConfig fd config =
|
applyTimingConfig fd config =
|
||||||
@ -170,9 +183,10 @@ initInputForFd config classifyTable inFd = do
|
|||||||
<*> pure (writeIORef stopFlag True)
|
<*> pure (writeIORef stopFlag True)
|
||||||
<*> newIORef config
|
<*> newIORef config
|
||||||
<*> pure inFd
|
<*> pure inFd
|
||||||
<*> maybe Nothing (\f -> Just <$> openFile f AppendMode)
|
<*> maybe (return Nothing)
|
||||||
(debugLog config)
|
(\f -> Just <$> openFile f AppendMode)
|
||||||
logClassifyTable classifyTable
|
(debugLog config)
|
||||||
|
logClassifyTable input classifyTable
|
||||||
_ <- forkOS $ runInputProcessorLoop classifyTable input stopFlag
|
_ <- forkOS $ runInputProcessorLoop classifyTable input stopFlag
|
||||||
return input
|
return input
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ classifyTableForTerm :: String -> Terminal -> ClassifyTable
|
|||||||
classifyTableForTerm termName term =
|
classifyTableForTerm termName term =
|
||||||
concat $ capsClassifyTable term keysFromCapsTable
|
concat $ capsClassifyTable term keysFromCapsTable
|
||||||
: universalTable
|
: universalTable
|
||||||
: termSpecificTable termName
|
: termSpecificTables termName
|
||||||
|
|
||||||
-- | key table applicable to all terminals.
|
-- | key table applicable to all terminals.
|
||||||
--
|
--
|
||||||
|
@ -7,8 +7,6 @@ module Graphics.Vty.Input.Terminfo.ANSIVT where
|
|||||||
|
|
||||||
import Graphics.Vty.Input.Events
|
import Graphics.Vty.Input.Events
|
||||||
|
|
||||||
import Data.List (isInfixOf, isPrefixOf)
|
|
||||||
|
|
||||||
-- | Encoding for navigation keys.
|
-- | Encoding for navigation keys.
|
||||||
--
|
--
|
||||||
-- TODO: This is not the same as the input bytes pulled from teh caps table.
|
-- TODO: This is not the same as the input bytes pulled from teh caps table.
|
||||||
|
@ -28,6 +28,8 @@ module Graphics.Vty.Output ( module Graphics.Vty.Output
|
|||||||
|
|
||||||
import Graphics.Vty.Prelude
|
import Graphics.Vty.Prelude
|
||||||
|
|
||||||
|
import Graphics.Vty.Config
|
||||||
|
|
||||||
import Graphics.Vty.Output.Interface
|
import Graphics.Vty.Output.Interface
|
||||||
import Graphics.Vty.Output.MacOSX as MacOSX
|
import Graphics.Vty.Output.MacOSX as MacOSX
|
||||||
import Graphics.Vty.Output.XTermColor as XTermColor
|
import Graphics.Vty.Output.XTermColor as XTermColor
|
||||||
|
Loading…
Reference in New Issue
Block a user