Output: add supportsItalics and supportsStrikethrough to check for feature support

This commit is contained in:
Jonathan Daugherty 2020-10-13 08:52:18 -07:00
parent 63adf9e4db
commit bcbf7fabc1
3 changed files with 10 additions and 0 deletions

View File

@ -101,6 +101,10 @@ data Output = Output
, ringTerminalBell :: IO ()
-- | Returns whether the terminal has an audio bell feature.
, supportsBell :: IO Bool
-- | Returns whether the terminal supports italicized text.
, supportsItalics :: IO Bool
-- | Returns whether the terminal supports strikethrough text.
, supportsStrikethrough :: IO Bool
}
displayContext :: Output -> DisplayRegion -> IO DisplayContext

View File

@ -48,6 +48,8 @@ mockTerminal r = liftIO $ do
, releaseDisplay = return ()
, ringTerminalBell = return ()
, supportsBell = return False
, supportsItalics = return False
, supportsStrikethrough = return False
, setDisplayBounds = const $ return ()
, displayBounds = return r
, outputByteBuffer = \bytes -> do

View File

@ -168,6 +168,10 @@ reserveTerminal termName outFd = do
sendCap setDefaultAttr []
maybeSendCap cnorm []
, supportsBell = return $ isJust $ ringBellAudio terminfoCaps
, supportsItalics = return $ (isJust $ enterItalic (displayAttrCaps terminfoCaps)) &&
(isJust $ exitItalic (displayAttrCaps terminfoCaps))
, supportsStrikethrough = return $ (isJust $ enterStrikethrough (displayAttrCaps terminfoCaps)) &&
(isJust $ exitStrikethrough (displayAttrCaps terminfoCaps))
, ringTerminalBell = maybeSendCap ringBellAudio []
, reserveDisplay = do
-- If there is no support for smcup: Clear the screen