ansi-terminal 0.9.1 → 0.10
raw patch · 8 files changed
+29/−7 lines, 8 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ System.Console.ANSI.Types: SetDefaultColor :: !ConsoleLayer -> SGR
Files
- CHANGELOG.md +9/−1
- ansi-terminal.cabal +1/−1
- src/System/Console/ANSI/Codes.hs +2/−0
- src/System/Console/ANSI/Types.hs +4/−0
- src/System/Console/ANSI/Unix.hs +2/−3
- src/System/Console/ANSI/Windows.hs +1/−1
- src/System/Console/ANSI/Windows/Emulator.hs +7/−1
- src/includes/Common-Include.hs +3/−0
CHANGELOG.md view
@@ -1,6 +1,14 @@ Changes ======= +Version 0.10 +------------ + +* Add support for setting the default color with new `SetDefaultColor` + constructor of the `SGR` type. +* `getTerminalSize` now flushes the `stdout` channel, to ensure the cursor + position is unaffected. + Version 0.9.1 ------------- @@ -11,7 +19,7 @@ ----------- * Add support for 256-color palettes with new `SetPaletteColor` constructor of - `SGR` type, and `xterm6LevelRGB`, `xterm24LevelGray` and `xtermSystem`. + the `SGR` type, and `xterm6LevelRGB`, `xterm24LevelGray` and `xtermSystem`. * Remove deprecated `getCursorPosition`. (Use `getCursorPosition0` instead.) * Add `hSupportsANSIColor`. * Add `getTerminalSize`.
ansi-terminal.cabal view
@@ -1,5 +1,5 @@ Name: ansi-terminal -Version: 0.9.1 +Version: 0.10 Cabal-Version: >= 1.8 Category: User Interfaces Synopsis: Simple ANSI terminal support, with Windows compatibility
src/System/Console/ANSI/Codes.hs view
@@ -121,6 +121,8 @@ SetPaletteColor Background index -> [48, 5, fromIntegral index] SetRGBColor Foreground color -> [38, 2] ++ toRGB color SetRGBColor Background color -> [48, 2] ++ toRGB color + SetDefaultColor Foreground -> [39] + SetDefaultColor Background -> [49] where toRGB color = let RGB r g b = toSRGB24 color in map fromIntegral [r, g, b]
src/System/Console/ANSI/Types.hs view
@@ -132,6 +132,10 @@ -- -- @since 0.9 | SetPaletteColor !ConsoleLayer !Word8 + -- | Set a color to the default (implementation-defined) + -- + -- @since 0.10 + | SetDefaultColor !ConsoleLayer deriving (Eq, Show, Read) -- | Given xterm's standard protocol for a 256-color palette, returns the index
src/System/Console/ANSI/Unix.hs view
@@ -10,9 +10,8 @@ ) where import Control.Exception.Base (bracket) -import System.IO (BufferMode (..), Handle, hFlush, hGetBuffering, hGetEcho, - hIsTerminalDevice, hIsWritable, hPutStr, hSetBuffering, hSetEcho, stdin, - stdout) +import System.IO (BufferMode (..), Handle, hGetBuffering, hGetEcho, + hIsTerminalDevice, hIsWritable, hPutStr, hSetBuffering, hSetEcho, stdin) import Text.ParserCombinators.ReadP (readP_to_S) import System.Console.ANSI.Codes
src/System/Console/ANSI/Windows.hs view
@@ -9,7 +9,7 @@ #include "Exports-Include.hs" ) where -import System.IO (Handle, stdout) +import System.IO (Handle) import System.Console.ANSI.Types import qualified System.Console.ANSI.Unix as U
src/System/Console/ANSI/Windows/Emulator.hs view
@@ -14,7 +14,7 @@ import Data.List (foldl', minimumBy) import Data.Maybe (mapMaybe) import qualified Data.Map.Strict as Map (Map, empty, insert, lookup) -import System.IO (Handle, hFlush, hIsTerminalDevice, stdin, stdout) +import System.IO (Handle, hIsTerminalDevice, stdin) import System.IO.Unsafe (unsafePerformIO) import Text.ParserCombinators.ReadP (readP_to_S) @@ -263,6 +263,12 @@ applyANSISGRToAttribute :: WORD -> SGR -> WORD -> WORD applyANSISGRToAttribute def sgr attribute = case sgr of Reset -> def + SetDefaultColor Foreground -> + (attribute .&. complement fOREGROUND_INTENSE_WHITE) .|. + (def .&. fOREGROUND_INTENSE_WHITE) + SetDefaultColor Background -> + (attribute .&. complement bACKGROUND_INTENSE_WHITE) .|. + (def .&. bACKGROUND_INTENSE_WHITE) SetConsoleIntensity intensity -> case intensity of BoldIntensity -> attribute .|. iNTENSITY FaintIntensity -> attribute .&. (complement iNTENSITY) -- Not supported
src/includes/Common-Include.hs view
@@ -12,6 +12,7 @@ import Data.Char (isDigit) import Data.Functor ((<$>)) import System.Environment (getEnvironment) +import System.IO (hFlush, stdout) import Text.ParserCombinators.ReadP (char, many1, ReadP, satisfy) hCursorUp, hCursorDown, hCursorForward, hCursorBackward @@ -254,4 +255,6 @@ -- bottom right corner of the terminal. mPos <- getCursorPosition0 restoreCursor + hFlush stdout -- ensure the restore cursor position code is sent to the + -- operating system return $ fmap (\(r, c) -> (r + 1, c + 1)) mPos