From 657363fded4bc4d4928aae227b235813cace0aa1 Mon Sep 17 00:00:00 2001 From: Mike Pilgrem Date: Tue, 23 Apr 2024 22:16:01 +0100 Subject: [PATCH] Reporting of layer colours: underlining is not supported --- ansi-terminal/src/System/Console/ANSI.hs | 10 ++++++++++ ansi-terminal/src/System/Console/ANSI/Codes.hs | 2 ++ ansi-terminal/unix/System/Console/ANSI/Internal.hs | 2 ++ 3 files changed, 14 insertions(+) diff --git a/ansi-terminal/src/System/Console/ANSI.hs b/ansi-terminal/src/System/Console/ANSI.hs index 042d459..ce624c5 100644 --- a/ansi-terminal/src/System/Console/ANSI.hs +++ b/ansi-terminal/src/System/Console/ANSI.hs @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/ansi-terminal/src/System/Console/ANSI/Codes.hs b/ansi-terminal/src/System/Console/ANSI/Codes.hs index 5f9eb3f..d300406 100644 --- a/ansi-terminal/src/System/Console/ANSI/Codes.hs +++ b/ansi-terminal/src/System/Console/ANSI/Codes.hs @@ -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" "?" diff --git a/ansi-terminal/unix/System/Console/ANSI/Internal.hs b/ansi-terminal/unix/System/Console/ANSI/Internal.hs index 56b5088..b4a5556 100644 --- a/ansi-terminal/unix/System/Console/ANSI/Internal.hs +++ b/ansi-terminal/unix/System/Console/ANSI/Internal.hs @@ -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