Hello community,

here is the log from the commit of package ghc-ansi-terminal for 
openSUSE:Factory checked in at 2019-10-18 14:33:38
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/ghc-ansi-terminal (Old)
 and      /work/SRC/openSUSE:Factory/.ghc-ansi-terminal.new.2352 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "ghc-ansi-terminal"

Fri Oct 18 14:33:38 2019 rev:13 rq:737188 version:0.10.1

Changes:
--------
--- /work/SRC/openSUSE:Factory/ghc-ansi-terminal/ghc-ansi-terminal.changes      
2019-05-17 23:42:37.681930453 +0200
+++ 
/work/SRC/openSUSE:Factory/.ghc-ansi-terminal.new.2352/ghc-ansi-terminal.changes
    2019-10-18 14:33:39.896203220 +0200
@@ -1,0 +2,22 @@
+Sun Oct  6 02:03:01 UTC 2019 - [email protected]
+
+- Update ansi-terminal to version 0.10.1.
+  Version 0.10.1
+  --------------
+
+  * Add `hGetCursorPosition` and `hGetTerminalSize`.
+  * On Unix-like operating systems, fix a bug where `getReportedCursorPosition`
+    could block indefinitely if no information was forthcoming on the console
+    input stream.
+  * Improvements to Haddock documentation.
+
+-------------------------------------------------------------------
+Fri Sep  6 06:39:58 UTC 2019 - [email protected]
+
+- Update ansi-terminal to version 0.10.
+  Upstream has edited the change log file since the last release in
+  a non-trivial way, i.e. they did more than just add a new entry
+  at the top. You can review the file at:
+  http://hackage.haskell.org/package/ansi-terminal-0.10/src/CHANGELOG.md
+
+-------------------------------------------------------------------

Old:
----
  ansi-terminal-0.9.1.tar.gz

New:
----
  ansi-terminal-0.10.1.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ ghc-ansi-terminal.spec ++++++
--- /var/tmp/diff_new_pack.ChIUBB/_old  2019-10-18 14:33:40.468201731 +0200
+++ /var/tmp/diff_new_pack.ChIUBB/_new  2019-10-18 14:33:40.472201720 +0200
@@ -18,7 +18,7 @@
 
 %global pkg_name ansi-terminal
 Name:           ghc-%{pkg_name}
-Version:        0.9.1
+Version:        0.10.1
 Release:        0
 Summary:        Simple ANSI terminal support, with Windows compatibility
 License:        BSD-3-Clause

++++++ ansi-terminal-0.9.1.tar.gz -> ansi-terminal-0.10.1.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/ansi-terminal-0.9.1/CHANGELOG.md 
new/ansi-terminal-0.10.1/CHANGELOG.md
--- old/ansi-terminal-0.9.1/CHANGELOG.md        2019-05-12 20:55:57.000000000 
+0200
+++ new/ansi-terminal-0.10.1/CHANGELOG.md       2019-10-05 20:30:29.000000000 
+0200
@@ -1,6 +1,23 @@
 Changes
 =======
 
+Version 0.10.1
+--------------
+
+* Add `hGetCursorPosition` and `hGetTerminalSize`.
+* On Unix-like operating systems, fix a bug where `getReportedCursorPosition`
+  could block indefinitely if no information was forthcoming on the console
+  input stream.
+* Improvements to Haddock documentation.
+
+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 +28,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`.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/ansi-terminal-0.9.1/ansi-terminal.cabal 
new/ansi-terminal-0.10.1/ansi-terminal.cabal
--- old/ansi-terminal-0.9.1/ansi-terminal.cabal 2019-05-12 20:56:56.000000000 
+0200
+++ new/ansi-terminal-0.10.1/ansi-terminal.cabal        2019-10-05 
20:30:38.000000000 +0200
@@ -1,5 +1,5 @@
 Name:                ansi-terminal
-Version:             0.9.1
+Version:             0.10.1
 Cabal-Version:       >= 1.8
 Category:            User Interfaces
 Synopsis:            Simple ANSI terminal support, with Windows compatibility
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/ansi-terminal-0.9.1/src/System/Console/ANSI/Codes.hs 
new/ansi-terminal-0.10.1/src/System/Console/ANSI/Codes.hs
--- old/ansi-terminal-0.9.1/src/System/Console/ANSI/Codes.hs    2019-05-12 
20:48:27.000000000 +0200
+++ new/ansi-terminal-0.10.1/src/System/Console/ANSI/Codes.hs   2019-10-05 
20:22:20.000000000 +0200
@@ -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]
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/ansi-terminal-0.9.1/src/System/Console/ANSI/Types.hs 
new/ansi-terminal-0.10.1/src/System/Console/ANSI/Types.hs
--- old/ansi-terminal-0.9.1/src/System/Console/ANSI/Types.hs    2019-05-12 
20:48:27.000000000 +0200
+++ new/ansi-terminal-0.10.1/src/System/Console/ANSI/Types.hs   2019-10-05 
20:22:20.000000000 +0200
@@ -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
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/ansi-terminal-0.9.1/src/System/Console/ANSI/Unix.hs 
new/ansi-terminal-0.10.1/src/System/Console/ANSI/Unix.hs
--- old/ansi-terminal-0.9.1/src/System/Console/ANSI/Unix.hs     2019-05-12 
14:54:10.000000000 +0200
+++ new/ansi-terminal-0.10.1/src/System/Console/ANSI/Unix.hs    2019-10-05 
20:22:20.000000000 +0200
@@ -9,10 +9,11 @@
 #include "Exports-Include.hs"
   ) where
 
+import Data.Maybe (fromMaybe)
 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 System.Timeout (timeout)
 import Text.ParserCombinators.ReadP (readP_to_S)
 
 import System.Console.ANSI.Codes
@@ -82,7 +83,10 @@
 -- (See Common-Include.hs for Haddock documentation)
 getReportedCursorPosition = bracket (hGetEcho stdin) (hSetEcho stdin) $ \_ -> 
do
   hSetEcho stdin False   -- Turn echo off
-  get
+  -- If, unexpectedly, no data is available on the console input stream then
+  -- the timeout will prevent the getChar blocking. For consistency with the
+  -- Windows equivalent, returns "" if the expected information is unavailable.
+  fromMaybe "" <$> timeout 500000 get -- 500 milliseconds
  where
   get = do
     c <- getChar
@@ -99,9 +103,9 @@
                       -- in order to avoid O(n^2) complexity.
       else return $ reverse (c:s) -- Reverse the order of the built list.
 
--- getCursorPosition0 :: IO (Maybe (Int, Int))
+-- hGetCursorPosition :: Handle -> IO (Maybe (Int, Int))
 -- (See Common-Include.hs for Haddock documentation)
-getCursorPosition0 = fmap to0base <$> getCursorPosition
+hGetCursorPosition h = fmap to0base <$> getCursorPosition
  where
   to0base (row, col) = (row - 1, col - 1)
   getCursorPosition = do
@@ -110,9 +114,9 @@
                                       -- buffer will be discarded, so this 
needs
                                       -- to be done before the cursor positon 
is
                                       -- emitted)
-      reportCursorPosition
-      hFlush stdout -- ensure the report cursor position code is sent to the
-                    -- operating system
+      hReportCursorPosition h
+      hFlush h -- ensure the report cursor position code is sent to the
+               -- operating system
       getReportedCursorPosition
     case readP_to_S cursorPosition input of
       [] -> return Nothing
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/ansi-terminal-0.9.1/src/System/Console/ANSI/Windows/Emulator.hs 
new/ansi-terminal-0.10.1/src/System/Console/ANSI/Windows/Emulator.hs
--- old/ansi-terminal-0.9.1/src/System/Console/ANSI/Windows/Emulator.hs 
2019-05-12 20:48:27.000000000 +0200
+++ new/ansi-terminal-0.10.1/src/System/Console/ANSI/Windows/Emulator.hs        
2019-10-05 20:22:20.000000000 +0200
@@ -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
@@ -471,18 +477,18 @@
       isKeyDown = keyEventKeyDown keyEventRecord
       isKeyDownEvent = eventType == 1 && isKeyDown
 
--- getCursorPosition0 :: IO (Maybe (Int, Int))
+-- hGetCursorPosition :: Handle -> IO (Maybe (Int, Int))
 -- (See Common-Include.hs for Haddock documentation)
-getCursorPosition0 = fmap to0base <$> getCursorPosition
+hGetCursorPosition h = fmap to0base <$> getCursorPosition
  where
   to0base (row, col) = (row - 1, col - 1)
   getCursorPosition = CE.catch getCursorPosition' getCPExceptionHandler
    where
     getCursorPosition' = do
       withHandleToHANDLE stdin flush -- Flush the console input buffer
-      reportCursorPosition
-      hFlush stdout -- ensure the report cursor position code is sent to the
-                    -- operating system
+      hReportCursorPosition h
+      hFlush h -- ensure the report cursor position code is sent to the
+               -- operating system
       input <- getReportedCursorPosition
       case readP_to_S cursorPosition input of
         [] -> return Nothing
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/ansi-terminal-0.9.1/src/System/Console/ANSI/Windows.hs 
new/ansi-terminal-0.10.1/src/System/Console/ANSI/Windows.hs
--- old/ansi-terminal-0.9.1/src/System/Console/ANSI/Windows.hs  2019-05-12 
14:54:10.000000000 +0200
+++ new/ansi-terminal-0.10.1/src/System/Console/ANSI/Windows.hs 2019-10-05 
20:22:20.000000000 +0200
@@ -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
@@ -191,6 +191,6 @@
 -- (See Common-Include.hs for Haddock documentation)
 getReportedCursorPosition = E.getReportedCursorPosition
 
--- getCursorPosition0 :: IO (Maybe (Int, Int))
+-- hGetCursorPosition :: Handle -> IO (Maybe (Int, Int))
 -- (See Common-Include.hs for Haddock documentation)
-getCursorPosition0 = E.getCursorPosition0
+hGetCursorPosition = E.hGetCursorPosition
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/ansi-terminal-0.9.1/src/System/Console/ANSI.hs 
new/ansi-terminal-0.10.1/src/System/Console/ANSI.hs
--- old/ansi-terminal-0.9.1/src/System/Console/ANSI.hs  2019-05-12 
20:48:27.000000000 +0200
+++ new/ansi-terminal-0.10.1/src/System/Console/ANSI.hs 2019-10-05 
20:22:20.000000000 +0200
@@ -23,6 +23,10 @@
 
  * Changing the title of the terminal
 
+A terminal that supports control character sequences acts on them when they
+are flushed from the output buffer (with a newline character @\"\\n\"@ or, for
+the standard output channel, @hFlush stdout@).
+
 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
@@ -88,6 +92,7 @@
 > import System.Console.ANSI
 >
 > -- Set colors and write some text in those colors.
+> main :: IO ()
 > main = do
 >   setSGR [SetColor Foreground Vivid Red]
 >   setSGR [SetColor Background Vivid Blue]
@@ -95,6 +100,24 @@
 >   setSGR [Reset]  -- Reset to default colour scheme
 >   putStrLn "Default colors."
 
+Another example:
+
+> module Main where
+>
+> import System.IO (hFlush, stdout)
+> import System.Console.ANSI
+>
+> main :: IO ()
+> main = do
+>   setSGR [SetColor Foreground Dull Blue]
+>   putStr "Enter your name: "
+>   setSGR [SetColor Foreground Dull Yellow]
+>   hFlush stdout  -- flush the output buffer before getLine
+>   name <- getLine
+>   setSGR [SetColor Foreground Dull Blue]
+>   putStrLn $ "Hello, " ++ name ++ "!"
+>   setSGR [Reset]  -- reset to default colour scheme
+
 For many more examples, see the project's extensive
 <https://github.com/feuerbach/ansi-terminal/blob/master/app/Example.hs 
Example.hs> file.
 -}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/ansi-terminal-0.9.1/src/includes/Common-Include.hs 
new/ansi-terminal-0.10.1/src/includes/Common-Include.hs
--- old/ansi-terminal-0.9.1/src/includes/Common-Include.hs      2019-05-12 
14:54:10.000000000 +0200
+++ new/ansi-terminal-0.10.1/src/includes/Common-Include.hs     2019-10-05 
20:22:20.000000000 +0200
@@ -5,13 +5,14 @@
 -- documentation.
 
 #if !MIN_VERSION_base(4,8,0)
-import Control.Applicative
+import Control.Applicative ((<*>))
+import Data.Functor ((<$>))
 #endif
 
 import Control.Monad (void)
 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
@@ -226,10 +227,12 @@
 -- 'reportCursorPosition', 'getReportedCursorPosition' and 'cursorPosition'. 
Any
 -- position @(row, column)@ is translated to be 0-based (that is, the top-left
 -- corner is at @(0, 0)@), consistent with `setCursorColumn` and
--- `setCursorPosition`. (Note that the information emitted by
--- 'reportCursorPosition' is 1-based.) Returns 'Nothing' if any data emitted by
--- 'reportCursorPosition', obtained by 'getReportedCursorPosition', cannot be
--- parsed by 'cursorPosition'.
+-- `setCursorPosition`. (Note that the information emitted into the console
+-- input stream by 'reportCursorPosition' is 1-based.) Returns 'Nothing' if any
+-- data emitted by 'reportCursorPosition', obtained by
+-- 'getReportedCursorPosition', cannot be parsed by 'cursorPosition'. Uses
+-- 'stdout'. If 'stdout' will be redirected, see 'hGetCursorPosition' for a 
more
+-- general function.
 --
 -- On Windows operating systems, the function is not supported on consoles, 
such
 -- as mintty, that are not based on the Win32 console of the Windows API.
@@ -237,10 +240,30 @@
 --
 -- @since 0.8.2
 getCursorPosition0 :: IO (Maybe (Int, Int))
+getCursorPosition0 = hGetCursorPosition stdout
+
+-- | Attempts to get the reported cursor position, combining the functions
+-- 'hReportCursorPosition' (with the specified handle),
+-- 'getReportedCursorPosition' and 'cursorPosition'. Any position
+-- @(row, column)@ is translated to be 0-based (that is, the top-left corner is
+-- at @(0, 0)@), consistent with 'hSetCursorColumn' and 'hSetCursorPosition'.
+-- (Note that the information emitted into the console input stream by
+-- 'hReportCursorPosition' is 1-based.) Returns 'Nothing' if any data emitted 
by
+-- 'hReportCursorPosition', obtained by 'getReportedCursorPosition', cannot be
+-- parsed by 'cursorPosition'.
+--
+-- On Windows operating systems, the function is not supported on consoles, 
such
+-- 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.1
+hGetCursorPosition :: Handle -> IO (Maybe (Int, Int))
 
 -- | Attempts to get the current terminal size (height in rows, width in
--- columns), by using `getCursorPosition0` after attempting to set the cursor
--- position beyond the bottom right corner of the terminal.
+-- columns), by using 'getCursorPosition0' 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.
 --
 -- On Windows operating systems, the function is not supported on consoles, 
such
 -- as mintty, that are not based on the Win32 console of the Windows API.
@@ -248,10 +271,26 @@
 --
 -- @since 0.9
 getTerminalSize :: IO (Maybe (Int, Int))
-getTerminalSize = do
-  saveCursor
-  setCursorPosition 999 999  -- Attempt to set the cursor position beyond the
-                             -- bottom right corner of the terminal.
-  mPos <- getCursorPosition0
-  restoreCursor
+getTerminalSize = hGetTerminalSize stdout
+
+-- | Attempts to get the current terminal size (height in rows, width in
+-- columns), by writing control character sequences to the specified handle
+-- (which will typically be 'stdout' or 'stderr') and using 
'hGetCursorPosition'
+-- to query the console input stream after attempting to set the cursor 
position
+-- beyond the bottom right corner of the terminal.
+--
+-- On Windows operating systems, the function is not supported on consoles, 
such
+-- 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.1
+hGetTerminalSize :: Handle -> IO (Maybe (Int, Int))
+hGetTerminalSize h = do
+  hSaveCursor h
+  hSetCursorPosition h 999 999  -- Attempt to set the cursor position beyond 
the
+                                -- bottom right corner of the terminal.
+  mPos <- hGetCursorPosition h
+  hRestoreCursor h
+  hFlush h -- ensure the restore cursor position code is sent to the
+           -- operating system
   return $ fmap (\(r, c) -> (r + 1, c + 1)) mPos
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/ansi-terminal-0.9.1/src/includes/Exports-Include.hs 
new/ansi-terminal-0.10.1/src/includes/Exports-Include.hs
--- old/ansi-terminal-0.9.1/src/includes/Exports-Include.hs     2019-01-26 
19:25:41.000000000 +0100
+++ new/ansi-terminal-0.10.1/src/includes/Exports-Include.hs    2019-10-05 
20:22:20.000000000 +0200
@@ -112,8 +112,10 @@
 
     -- * Getting the cursor position
   , getCursorPosition0
+  , hGetCursorPosition
   , getReportedCursorPosition
   , cursorPosition
 
     -- * Getting the terminal size
   , getTerminalSize
+  , hGetTerminalSize


Reply via email to