Skip to content

Commit

Permalink
Reporting of layer colours: underlining is not supported
Browse files Browse the repository at this point in the history
  • Loading branch information
mpilgrem committed Apr 23, 2024
1 parent 660b10b commit 657363f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
10 changes: 10 additions & 0 deletions ansi-terminal/src/System/Console/ANSI.hs
Original file line number Diff line number Diff line change
Expand Up @@ -783,6 +783,8 @@ hGetCursorPosition h = fmap to0base <$> getCursorPosition'
-- emulated, but the emulation does not work on Windows Terminal and (2) of
-- difficulties in obtaining the data emitted into the console input stream.
--
-- Underlining is not supported.
--
-- @since 0.11.4
reportLayerColor :: ConsoleLayer -> IO ()
reportLayerColor = hReportLayerColor stdout
Expand Down Expand Up @@ -814,6 +816,8 @@ hReportLayerColor h layer = hPutStr h $ reportLayerColorCode layer
-- as mintty, that are not based on the Windows' Console API. (Command Prompt
-- and PowerShell are based on the Console API.)
--
-- Underlining is not supported.
--
-- @since 0.11.4
getReportedLayerColor :: ConsoleLayer -> IO String
getReportedLayerColor = Internal.getReportedLayerColor
Expand All @@ -831,6 +835,8 @@ getReportedLayerColor = Internal.getReportedLayerColor
-- and PowerShell are based on the Console API.) This function also relies on
-- emulation that does not work on Windows Terminal.
--
-- Underlining is not supported.
--
-- @since 0.11.4
getLayerColor :: ConsoleLayer -> IO (Maybe(RGB Word16))
getLayerColor = hGetLayerColor stdout
Expand All @@ -847,6 +853,8 @@ getLayerColor = hGetLayerColor stdout
-- and PowerShell are based on the Console API.) This function also relies on
-- emulation that does not work on Windows Terminal.
--
-- Underlining is not supported.
--
-- @since 0.11.4
hGetLayerColor :: Handle -> ConsoleLayer -> IO (Maybe (RGB Word16))
hGetLayerColor h layer = do
Expand Down Expand Up @@ -886,6 +894,8 @@ hGetLayerColor h layer = do
-- > [(col, _)] -> putStrLn $ "The color was " ++ show col ++ "."
-- > (_:_) -> putStrLn $ "Error: parse not unique"
--
-- Underlining is not supported.
--
-- @since 0.11.4
layerColor :: ConsoleLayer -> ReadP (RGB Word16)
layerColor layer = do
Expand Down
2 changes: 2 additions & 0 deletions ansi-terminal/src/System/Console/ANSI/Codes.hs
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,8 @@ reportCursorPositionCode = csi [] "6n"
-- terminals (2) of difficulties in obtaining the data emitted into the
-- console input stream. See 'System.Console.ANSI.getReportedLayerColor'.
--
-- Underlining is not supported.
--
-- @since 0.11.4
reportLayerColorCode :: ConsoleLayer -> String
reportLayerColorCode Foreground = osc "10" "?"
Expand Down
2 changes: 2 additions & 0 deletions ansi-terminal/unix/System/Console/ANSI/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ getReportedCursorPosition :: IO String
getReportedCursorPosition = getReport "\ESC[" ["R"]

getReportedLayerColor :: ConsoleLayer -> IO String
getReportedLayerColor Underlining =
error "getReportedLayerColor does not support underlining."
getReportedLayerColor layer =
getReport ("\ESC]" ++ pS ++ ";rgb:") ["\BEL", "\ESC\\"]
where
Expand Down

0 comments on commit 657363f

Please sign in to comment.