ansi-terminal 0.11.1 → 0.11.2
raw patch · 9 files changed
+49/−32 lines, 9 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- CHANGELOG.md +10/−3
- ansi-terminal.cabal +1/−1
- app/Example.hs +2/−2
- src/System/Console/ANSI/Codes.hs +9/−10
- src/System/Console/ANSI/Unix.hs +1/−1
- src/System/Console/ANSI/Windows.hs +1/−1
- src/System/Console/ANSI/Windows/Emulator.hs +7/−4
- src/System/Win32/Compat.hs +10/−4
- src/includes/Common-Include.hs +8/−6
CHANGELOG.md view
@@ -1,6 +1,13 @@ Changes ======= +Version 0.11.2 +-------------- + +* On Windows, fix compatability with the Windows I/O Manager (WinIO) when + GHC >= 9.0.1 but `Win32` < 2.9.0.0. +* Improvements to Haddock documentation. + Version 0.11.1 -------------- @@ -78,9 +85,9 @@ Version 0.8.1 ------------- -* Add `hSupportsANSIWithoutEmulation`. On Windows 10, if the handle is identifed - as connected to a native terminal ('Command Prompt' or 'PowerShell'), the - processing of 'ANSI' control characters will be enabled. +* Add `hSupportsANSIWithoutEmulation`. On Windows 10, if the handle is + identified as connected to a native terminal ('Command Prompt' or + 'PowerShell'), the processing of 'ANSI' control characters will be enabled. Version 0.8.0.4 ---------------
ansi-terminal.cabal view
@@ -1,5 +1,5 @@ Name: ansi-terminal -Version: 0.11.1 +Version: 0.11.2 Cabal-Version: >= 1.10 Category: User Interfaces Synopsis: Simple ANSI terminal support, with Windows compatibility
app/Example.hs view
@@ -28,7 +28,7 @@ ] main :: IO () -main = mapM_ (\example -> resetScreen >> example) examples +main = mapM_ (resetScreen >>) examples -- Annex D to Standard ECMA-48 (5th Ed, 1991) identifies that the representation -- of an erased state is implementation-dependent. There may or may not be a @@ -229,7 +229,7 @@ forM_ colors $ \color -> do setSGR [Reset] setSGR [SetColor layer intensity color] - putStrLn (show color) + print color pause -- The ANSI eight standard colors, 4 times in sequence (two layers and two -- intensities)
src/System/Console/ANSI/Codes.hs view
@@ -48,19 +48,13 @@ , hideCursorCode, showCursorCode -- * Changing the title - -- | Thanks to Brandon S. Allbery and Curt Sampson for pointing me in the - -- right direction on xterm title setting on haskell-cafe. The "0" - -- signifies that both the title and "icon" text should be set: i.e. the - -- text for the window in the Start bar (or similar) as well as that in - -- the actual window title. This is chosen for consistent behaviour - -- between Unixes and Windows. , setTitleCode -- * Utilities , colorToCode, csi, sgrToCode ) where -import Data.List (intersperse) +import Data.List (intercalate) import Data.Colour.SRGB (toSRGB24, RGB (..)) @@ -74,7 +68,7 @@ csi :: [Int] -- ^ List of parameters for the control sequence -> String -- ^ Character(s) that identify the control function -> String -csi args code = "\ESC[" ++ concat (intersperse ";" (map show args)) ++ code +csi args code = "\ESC[" ++ intercalate ";" (map show args) ++ code -- | 'colorToCode' @color@ returns the 0-based index of the color (one of the -- eight colors in the ANSI standard). @@ -206,8 +200,13 @@ hideCursorCode = csi [] "?25l" showCursorCode = csi [] "?25h" +-- | Code to set the terminal window title and the icon name (that is, the text +-- for the window in the Start bar, or similar). --- | XTerm control sequence to set the Icon Name and Window Title. -setTitleCode :: String -- ^ New Icon Name and Window Title +-- Thanks to Brandon S. Allbery and Curt Sampson for pointing me in the right +-- direction on xterm title setting on haskell-cafe. The "0" signifies that both +-- the title and "icon" text should be set. This is chosen for consistent +-- behaviour between Unixes and Windows. +setTitleCode :: String -- ^ New window title and icon name -> String setTitleCode title = "\ESC]0;" ++ filter (/= '\007') title ++ "\007"
src/System/Console/ANSI/Unix.hs view
@@ -24,7 +24,7 @@ -- This file contains code that is common to modules System.Console.ANSI.Unix, -- System.Console.ANSI.Windows and System.Console.ANSI.Windows.Emulator, such as -- type signatures and the definition of functions specific to stdout in terms --- of the corresponding more general functions, inclduding the related Haddock +-- of the corresponding more general functions, including the related Haddock -- documentation. #include "Common-Include.hs" -- This file contains code that is common save that different code is required
src/System/Console/ANSI/Windows.hs view
@@ -20,7 +20,7 @@ -- This file contains code that is common to modules System.Console.ANSI.Unix, -- System.Console.ANSI.Windows and System.Console.ANSI.Windows.Emulator, such as -- type signatures and the definition of functions specific to stdout in terms --- of the corresponding more general functions, inclduding the related Haddock +-- of the corresponding more general functions, including the related Haddock -- documentation. #include "Common-Include.hs" -- This file contains code that is common save that different code is required
src/System/Console/ANSI/Windows/Emulator.hs view
@@ -33,7 +33,7 @@ -- This file contains code that is common to modules System.Console.ANSI.Unix, -- System.Console.ANSI.Windows and System.Console.ANSI.Windows.Emulator, such as -- type signatures and the definition of functions specific to stdout in terms --- of the corresponding more general functions, inclduding the related Haddock +-- of the corresponding more general functions, including the related Haddock -- documentation. #include "Common-Include.hs" -- This file contains code that is required in the case of the module @@ -474,14 +474,17 @@ return $ stringFromInputEvents es stringFromInputEvents = cWcharsToChars . wCharsFromInputEvents wCharsFromInputEvents = mapMaybe wCharFromInputEvent - wCharFromInputEvent e = if isKeyDownEvent + wCharFromInputEvent e = if isKeyEvent && isKeyDown then Just (unicodeAsciiChar $ keyEventChar keyEventRecord) else Nothing where eventType = inputEventType e - InputKeyEvent keyEventRecord = inputEvent e + eventRecord = inputEvent e + isKeyEvent = eventType == 1 + keyEventRecord = case eventRecord of + InputKeyEvent keyEventRecord' -> keyEventRecord' + _ -> error "Unexpected input event, given input event type." isKeyDown = keyEventKeyDown keyEventRecord - isKeyDownEvent = eventType == 1 && isKeyDown -- hGetCursorPosition :: Handle -> IO (Maybe (Int, Int)) -- (See Common-Include.hs for Haddock documentation)
src/System/Win32/Compat.hs view
@@ -40,8 +40,14 @@ TCHAR, UINT, WORD, failIfFalse_, getLastError, iNVALID_HANDLE_VALUE, nullHANDLE, withTString) +-- Circumstancees in which the patching of Win32 package for the Windows I/O +-- Manager is required +#if defined(__IO_MANAGER_WINIO__)&&MIN_VERSION_Win32(2,9,0)&&!MIN_VERSION_Win32(2,13,2) +#define PATCHING_WIN32_PACKAGE_FOR_WINIO +#endif + -- Circumstances in which the patching of Win32 package is required -#if !MIN_VERSION_Win32(2,5,1)||(defined(__IO_MANAGER_WINIO__)&&!MIN_VERSION_Win32(2,13,2)) +#if !MIN_VERSION_Win32(2,5,1)||defined(PATCHING_WIN32_PACKAGE_FOR_WINIO) #define PATCHING_WIN32_PACKAGE #endif @@ -57,7 +63,7 @@ import Foreign.StablePtr (StablePtr, freeStablePtr, newStablePtr) import GHC.IO.Handle.Types (Handle (..), Handle__ (..)) -#if defined(__IO_MANAGER_WINIO__)&&!MIN_VERSION_Win32(2,13,2) +#if defined(PATCHING_WIN32_PACKAGE_FOR_WINIO) import GHC.IO.Exception (IOErrorType (InappropriateType), IOException (IOError), ioException) import GHC.IO.SubSystem ((<!>)) @@ -87,7 +93,7 @@ withStablePtr :: a -> (StablePtr a -> IO b) -> IO b withStablePtr value = bracket (newStablePtr value) freeStablePtr -#if defined(__IO_MANAGER_WINIO__)&&!MIN_VERSION_Win32(2,13,2) +#if defined(PATCHING_WIN32_PACKAGE_FOR_WINIO) withHandleToHANDLE :: Handle -> (HANDLE -> IO a) -> IO a withHandleToHANDLE = withHandleToHANDLEPosix <!> withHandleToHANDLENative @@ -162,7 +168,7 @@ foreign import WINDOWS_CCONV unsafe "_get_osfhandle" cget_osfhandle :: CInt -> IO HANDLE --- defined(__IO_MANAGER_WINIO__)&&!MIN_VERSION_Win32(2,13,2) +-- defined(PATCHING_WIN32_PACKAGE_FOR_WINIO) #endif -- defined(PATCHING_WIN32_PACKAGE)
src/includes/Common-Include.hs view
@@ -1,7 +1,7 @@ -- This file contains code that is common to modules System.Console.ANSI.Unix, -- System.Console.ANSI.Windows and System.Console.ANSI.Windows.Emulator, such as -- type signatures and the definition of functions specific to stdout in terms --- of the corresponding more general functions, inclduding the related Haddock +-- of the corresponding more general functions, including the related Haddock -- documentation. #if !MIN_VERSION_base(4,8,0) @@ -103,12 +103,14 @@ hideCursor = hHideCursor stdout showCursor = hShowCursor stdout --- | Set the terminal window title +-- | Set the terminal window title and icon name (that is, the text for the +-- window in the Start bar, or similar). hSetTitle :: Handle - -> String -- ^ New title + -> String -- ^ New window title and icon name -> IO () --- | Set the terminal window title -setTitle :: String -- ^ New title +-- | Set the terminal window title and icon name (that is, the text for the +-- window in the Start bar, or similar). +setTitle :: String -- ^ New window title and icon name -> IO () setTitle = hSetTitle stdout @@ -161,7 +163,7 @@ -- On Windows, what is returned will depend on what the handle is connected to -- and the version of the operating system. If the handle is identified as -- connected to a \'mintty\' terminal, @return (Just True)@ is --- returned. If it is identifed as connected to a native terminal, then, on +-- returned. If it is identified as connected to a native terminal, then, on -- Windows 10, the processing of \'ANSI\' control characters will be enabled and -- @return (Just True)@ returned; and, on versions of Windows before Windows 10, -- @return (Just False)@ is returned. Otherwise, if a @TERM@ environment