@@ -25,9 +25,6 @@ import Graphics.Vty.Output.Interface
2525
2626import Blaze.ByteString.Builder (Write, writeToByteString, writeStorable)
2727
28−import Control.Monad.Fail (MonadFail)
29−import Control.Monad.Trans
30−
3128import Data.Bits ((.&.))
3229import Data.Foldable (foldMap)
3330import Data.IORef
@@ -101,8 +98,8 @@ sendCapToTerminal t cap capParams = do
10198--
10299-- * Providing independent string capabilities for all display
103100-- attributes.
104−reserveTerminal :: ( Applicative m, MonadIO m ) => String -> Fd -> m Output
105−reserveTerminal termName outFd = liftIO $ do
101+reserveTerminal :: String -> Fd -> IO Output
102+reserveTerminal termName outFd = do
106103 ti <- Terminfo.setupTerm termName
107104 -- assumes set foreground always implies set background exists.
108105 -- if set foreground is not set then all color changing style
@@ -131,13 +128,13 @@ reserveTerminal termName outFd = liftIO $ do
131128 curStatus <- terminfoModeStatus m
132129 when (newStatus /= curStatus) $
133130 case m of
134− Hyperlink -> liftIO $ do
131+ Hyperlink -> do
135132 writeIORef hyperlinkModeStatus newStatus
136133 writeIORef newAssumedStateRef initialAssumedState
137134 _ -> return ()
138135 terminfoModeStatus m =
139136 case m of
140− Hyperlink -> liftIO $ readIORef hyperlinkModeStatus
137+ Hyperlink -> readIORef hyperlinkModeStatus
141138 _ -> return False
142139 terminfoModeSupported Hyperlink = True
143140 terminfoModeSupported _ = False
@@ -159,22 +156,22 @@ reserveTerminal termName outFd = liftIO $ do
159156 <*> probeCap ti "bel"
160157 let t = Output
161158 { terminalID = termName
162− , releaseTerminal = liftIO $ do
159+ , releaseTerminal = do
163160 sendCap setDefaultAttr []
164161 maybeSendCap cnorm []
165162 , supportsBell = return $ isJust $ ringBellAudio terminfoCaps
166− , ringTerminalBell = liftIO $ maybeSendCap ringBellAudio []
167− , reserveDisplay = liftIO $ do
163+ , ringTerminalBell = maybeSendCap ringBellAudio []
164+ , reserveDisplay = do
168165 -- If there is no support for smcup: Clear the screen
169166 -- and then move the mouse to the home position to
170167 -- approximate the behavior.
171168 maybeSendCap smcup []
172169 sendCap clearScreen []
173− , releaseDisplay = liftIO $ do
170+ , releaseDisplay = do
174171 maybeSendCap rmcup []
175172 maybeSendCap cnorm []
176173 , displayBounds = do
177− rawSize <- liftIO $ getWindowSize outFd
174+ rawSize <- getWindowSize outFd
178175 case rawSize of
179176 (w, h) | w < 0 || h < 0 -> fail $ "getwinsize returned < 0 : " ++ show rawSize
180177 | otherwise -> return (w,h)
@@ -198,33 +195,31 @@ reserveTerminal termName outFd = liftIO $ do
198195 , assumedStateRef = newAssumedStateRef
199196 -- I think fix would help assure tActual is the only
200197 -- reference. I was having issues tho.
201− , mkDisplayContext = \tActual -> liftIO . terminfoDisplayContext tActual terminfoCaps
198+ , mkDisplayContext = \tActual -> terminfoDisplayContext tActual terminfoCaps
202199 }
203200 sendCap s = sendCapToTerminal t (s terminfoCaps)
204201 maybeSendCap s = when (isJust $ s terminfoCaps) . sendCap (fromJust . s)
205202 return t
206203
207−requireCap :: (Applicative m, MonadIO m, MonadFail m) => Terminfo.Terminal -> String -> m CapExpression
204+requireCap :: Terminfo.Terminal -> String -> IO CapExpression
208205requireCap ti capName
209206 = case Terminfo.getCapability ti (Terminfo.tiGetStr capName) of
210207 Nothing -> fail $ "Terminal does not define required capability \"" ++ capName ++ "\""
211208 Just capStr -> parseCap capStr
212209
213−probeCap :: (Applicative m, MonadIO m, MonadFail m) => Terminfo.Terminal -> String -> m (Maybe CapExpression)
210+probeCap :: Terminfo.Terminal -> String -> IO (Maybe CapExpression)
214211probeCap ti capName
215212 = case Terminfo.getCapability ti (Terminfo.tiGetStr capName) of
216213 Nothing -> return Nothing
217214 Just capStr -> Just <$> parseCap capStr
218215
219−parseCap :: (Applicative m, MonadIO m, MonadFail m) => String -> m CapExpression
216+parseCap :: String -> IO CapExpression
220217parseCap capStr = do
221218 case parseCapExpression capStr of
222219 Left e -> fail $ show e
223220 Right cap -> return cap
224221
225−currentDisplayAttrCaps :: ( Applicative m, MonadIO m, MonadFail m )
226− => Terminfo.Terminal
227− -> m DisplayAttrCaps
222+currentDisplayAttrCaps :: Terminfo.Terminal -> IO DisplayAttrCaps
228223currentDisplayAttrCaps ti
229224 = pure DisplayAttrCaps
230225 <*> probeCap ti "sgr"