ansi-terminal 0.10.2 → 0.10.3
raw patch · 9 files changed
+29/−14 lines, 9 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ System.Console.ANSI: getCursorPosition :: IO (Maybe (Int, Int))
Files
- CHANGELOG.md +5/−0
- ansi-terminal.cabal +1/−1
- app/Example.hs +1/−1
- src/System/Console/ANSI.hs +1/−1
- src/System/Console/ANSI/Codes.hs +1/−1
- src/System/Console/ANSI/Unix.hs +2/−2
- src/System/Console/ANSI/Windows/Emulator.hs +3/−3
- src/includes/Common-Include.hs +11/−4
- src/includes/Exports-Include.hs +4/−1
CHANGELOG.md view
@@ -1,6 +1,11 @@ Changes ======= +Version 0.10.3 +-------------- +* Add `getCursorPosition` as a synonym of `getCursorPosition0` and deprecate the + latter. + Version 0.10.2 --------------
ansi-terminal.cabal view
@@ -1,5 +1,5 @@ Name: ansi-terminal -Version: 0.10.2 +Version: 0.10.3 Cabal-Version: >= 1.8 Category: User Interfaces Synopsis: Simple ANSI terminal support, with Windows compatibility
app/Example.hs view
@@ -388,7 +388,7 @@ -- 11111111112222222222 -- 12345678901234567890123456789 -- Report cursor position here:| - result <- getCursorPosition0 + result <- getCursorPosition putStrLn " (3rd row, 29th column) to stdin, as CSI 3 ; 29 R.\n" case result of Just (row, col) -> putStrLn $ "The cursor was at row number " ++
src/System/Console/ANSI.hs view
@@ -29,7 +29,7 @@ The functions moving the cursor to an absolute position are 0-based (the top-left corner is considered to be at row 0 column 0) (see 'setCursorPosition') -and so is 'getCursorPosition0'. The \'ANSI\' standards themselves are 1-based +and so is 'getCursorPosition'. The \'ANSI\' standards themselves are 1-based (that is, the top-left corner is considered to be at row 1 column 1) and some functions reporting the position of the cursor are too (see 'reportCursorPosition').
src/System/Console/ANSI/Codes.hs view
@@ -165,7 +165,7 @@ -- Note that the information that is emitted is 1-based (the top-left corner is -- at row 1 column 1) but 'setCursorPositionCode' is 0-based. -- --- In isolation of 'getReportedCursorPosition' or 'getCursorPosition0', this +-- In isolation of 'getReportedCursorPosition' or 'getCursorPosition', this -- function may be of limited use on Windows operating systems because of -- difficulties in obtaining the data emitted into the console input stream. -- The function 'hGetBufNonBlocking' in module "System.IO" does not work on
src/System/Console/ANSI/Unix.hs view
@@ -105,10 +105,10 @@ -- hGetCursorPosition :: Handle -> IO (Maybe (Int, Int)) -- (See Common-Include.hs for Haddock documentation) -hGetCursorPosition h = fmap to0base <$> getCursorPosition +hGetCursorPosition h = fmap to0base <$> getCursorPosition' where to0base (row, col) = (row - 1, col - 1) - getCursorPosition = do + getCursorPosition' = do input <- bracket (hGetBuffering stdin) (hSetBuffering stdin) $ \_ -> do hSetBuffering stdin NoBuffering -- set no buffering (the contents of the -- buffer will be discarded, so this needs
src/System/Console/ANSI/Windows/Emulator.hs view
@@ -485,12 +485,12 @@ -- hGetCursorPosition :: Handle -> IO (Maybe (Int, Int)) -- (See Common-Include.hs for Haddock documentation) -hGetCursorPosition h = fmap to0base <$> getCursorPosition +hGetCursorPosition h = fmap to0base <$> getCursorPosition' where to0base (row, col) = (row - 1, col - 1) - getCursorPosition = CE.catch getCursorPosition' getCPExceptionHandler + getCursorPosition' = CE.catch getCursorPosition'' getCPExceptionHandler where - getCursorPosition' = do + getCursorPosition'' = do withHandleToHANDLE stdin flush -- Flush the console input buffer hReportCursorPosition h hFlush h -- ensure the report cursor position code is sent to the
src/includes/Common-Include.hs view
@@ -72,7 +72,7 @@ restoreCursor :: IO () -- | Looking for a way to get the cursors position? See --- 'getCursorPosition0'. +-- 'getCursorPosition'. -- -- Emit the cursor position into the console input stream, immediately after -- being recognised on the output stream, as: @@ -82,7 +82,7 @@ -- at row 1 column 1) but 'setCursorColumn' and 'setCursorPosition' are -- 0-based. -- --- In isolation of 'getReportedCursorPosition' or 'getCursorPosition0', this +-- In isolation of 'getReportedCursorPosition' or 'getCursorPosition', this -- function may be of limited use on Windows operating systems because of -- difficulties in obtaining the data emitted into the console input stream. -- The function 'hGetBufNonBlocking' in module "System.IO" does not work on @@ -238,9 +238,16 @@ -- as mintty, that are not based on the Win32 console of the Windows API. -- (Command Prompt and PowerShell are based on the Win32 console.) -- +-- @since 0.10.3 +getCursorPosition :: IO (Maybe (Int, Int)) +getCursorPosition = hGetCursorPosition stdout + +-- | A synonym for 'getCursorPosition'. +-- -- @since 0.8.2 +{-# DEPRECATED getCursorPosition0 "Use getCursorPosition instead." #-} getCursorPosition0 :: IO (Maybe (Int, Int)) -getCursorPosition0 = hGetCursorPosition stdout +getCursorPosition0 = getCursorPosition -- | Attempts to get the reported cursor position, combining the functions -- 'hReportCursorPosition' (with the specified handle), @@ -260,7 +267,7 @@ hGetCursorPosition :: Handle -> IO (Maybe (Int, Int)) -- | Attempts to get the current terminal size (height in rows, width in --- columns), by using 'getCursorPosition0' to query the console input stream +-- columns), by using 'getCursorPosition' to query the console input stream -- after attempting to set the cursor position beyond the bottom right corner of -- the terminal. Uses 'stdout'. If 'stdout' will be redirected, see -- 'hGetTerminalSize' for a more general function.
src/includes/Exports-Include.hs view
@@ -111,7 +111,7 @@ , hSupportsANSIWithoutEmulation -- * Getting the cursor position - , getCursorPosition0 + , getCursorPosition , hGetCursorPosition , getReportedCursorPosition , cursorPosition @@ -119,3 +119,6 @@ -- * Getting the terminal size , getTerminalSize , hGetTerminalSize + + -- * Deprecated + , getCursorPosition0