on master help sign in
Add Output.{ringTerminalBell,supportsBell} to control the terminal bell (fixes #102)
commitf8c9c956d7ab7617eb05bba25fd5f6c8de5ac639 authorJonathan Daugherty <cygnus@foobox.com> dateSun 28 Aug 2016, 10:35 (10 years ago) parent2f29157
3 files changed+10
src/Graphics/Vty/Output/Interface.hs+4 src/Graphics/Vty/Output/Mock.hs+2 src/Graphics/Vty/Output/TerminfoBased.hs+4
src/Graphics/Vty/Output/Interface.hs+4
@@ -83,6 +83,10 @@ data Output = Output
8383 -- Currently all regions have the upper left corner of (0,0) and the lower right corner at
8484 -- (max displayWidth providedWidth, max displayHeight providedHeight)
8585 , mkDisplayContext :: forall m. MonadIO m => Output -> DisplayRegion -> m DisplayContext
86+ -- | Ring the terminal bell if supported.
87+ , ringTerminalBell :: forall m. MonadIO m => m ()
88+ -- | Returns whether the terminal has an audio bell feature.
89+ , supportsBell :: forall m. MonadIO m => m Bool
8690 }
8791
8892displayContext :: MonadIO m => Output -> DisplayRegion -> m DisplayContext
src/Graphics/Vty/Output/Mock.hs+2
@@ -41,6 +41,8 @@ mockTerminal r = liftIO $ do
4141 , releaseTerminal = return ()
4242 , reserveDisplay = return ()
4343 , releaseDisplay = return ()
44+ , ringTerminalBell = return ()
45+ , supportsBell = return False
4446 , displayBounds = return r
4547 , outputByteBuffer = \bytes -> do
4648 putStrLn $ "mock outputByteBuffer of " ++ show (BS.length bytes) ++ " bytes"
src/Graphics/Vty/Output/TerminfoBased.hs+4
@@ -64,6 +64,7 @@ data TerminfoCaps = TerminfoCaps
6464 , clearScreen :: CapExpression
6565 , clearEol :: CapExpression
6666 , displayAttrCaps :: DisplayAttrCaps
67+ , ringBellAudio :: Maybe CapExpression
6768 }
6869
6970data DisplayAttrCaps = DisplayAttrCaps
@@ -140,12 +141,15 @@ reserveTerminal termName outFd = liftIO $ do
140141 <*> requireCap ti "clear"
141142 <*> requireCap ti "el"
142143 <*> currentDisplayAttrCaps ti
144+ <*> probeCap ti "bel"
143145 newAssumedStateRef <- newIORef initialAssumedState
144146 let t = Output
145147 { terminalID = termName
146148 , releaseTerminal = liftIO $ do
147149 sendCap setDefaultAttr []
148150 maybeSendCap cnorm []
151+ , supportsBell = return $ isJust $ ringBellAudio terminfoCaps
152+ , ringTerminalBell = liftIO $ maybeSendCap ringBellAudio []
149153 , reserveDisplay = liftIO $ do
150154 -- If there is no support for smcup: Clear the screen and then move the mouse to the
151155 -- home position to approximate the behavior.