Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package ghc-ansi-terminal for 
openSUSE:Factory checked in at 2024-01-21 23:09:44
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/ghc-ansi-terminal (Old)
 and      /work/SRC/openSUSE:Factory/.ghc-ansi-terminal.new.16006 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "ghc-ansi-terminal"

Sun Jan 21 23:09:44 2024 rev:25 rq:1140219 version:1.0.2

Changes:
--------
--- /work/SRC/openSUSE:Factory/ghc-ansi-terminal/ghc-ansi-terminal.changes      
2023-11-23 21:43:08.112987597 +0100
+++ 
/work/SRC/openSUSE:Factory/.ghc-ansi-terminal.new.16006/ghc-ansi-terminal.changes
   2024-01-21 23:10:11.721527688 +0100
@@ -1,0 +2,9 @@
+Sat Jan 13 17:39:56 UTC 2024 - Peter Simons <psim...@suse.com>
+
+- Update ansi-terminal to version 1.0.2.
+  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-1.0.2/src/CHANGELOG.md
+
+-------------------------------------------------------------------

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

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

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

Other differences:
------------------
++++++ ghc-ansi-terminal.spec ++++++
--- /var/tmp/diff_new_pack.izV1Fo/_old  2024-01-21 23:10:12.301548832 +0100
+++ /var/tmp/diff_new_pack.izV1Fo/_new  2024-01-21 23:10:12.301548832 +0100
@@ -1,7 +1,7 @@
 #
 # spec file for package ghc-ansi-terminal
 #
-# Copyright (c) 2023 SUSE LLC
+# Copyright (c) 2024 SUSE LLC
 #
 # All modifications and additions to the file contributed by third parties
 # remain the property of their copyright owners, unless otherwise agreed
@@ -19,7 +19,7 @@
 %global pkg_name ansi-terminal
 %global pkgver %{pkg_name}-%{version}
 Name:           ghc-%{pkg_name}
-Version:        1.0
+Version:        1.0.2
 Release:        0
 Summary:        Simple ANSI terminal support
 License:        BSD-3-Clause

++++++ ansi-terminal-1.0.tar.gz -> ansi-terminal-1.0.2.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/ansi-terminal-1.0/CHANGELOG.md 
new/ansi-terminal-1.0.2/CHANGELOG.md
--- old/ansi-terminal-1.0/CHANGELOG.md  2023-05-13 14:42:37.000000000 +0200
+++ new/ansi-terminal-1.0.2/CHANGELOG.md        2024-01-13 18:23:51.000000000 
+0100
@@ -1,10 +1,35 @@
 Changes
 =======
 
+Version 1.0.2
+-------------
+
+* On Windows, fix linker error about a duplicate symbol `castUINTPtrToPtr`.
+
+Version 1.0.1
+-------------
+
+* On Windows, the processing of \'ANSI\' control characters in output is 
enabled
+  by default in Windows Terminal but is not enabled by default in ConHost
+  terminals. Additions have been made to allow support of users of ConHost
+  terminals.
+* Add `hNowSupportsANSI`. On Unix, the function is equivalent to
+  `hSupportsANSI`. On Windows, in Windows Terminal and ConHost terminals, the
+  action can try to enable the processing of \'ANSI\' control characters in
+  output.
+* In Windows Terminal and ConHost terminals, `hSupportsANSI` will yield `False`
+  if the the processing of \'ANSI\' control characters in output is not 
enabled.
+* Deprecated `hSupportsANSIWithoutEmulation` is now consistent with
+  `hNowSupportsANSI`.
+* Improvements to Haddock documentation.
+
 Version 1.0
 -----------
 
-* On Windows, drop support for legacy Windows requiring emulation.
+* On Windows, drop support for legacy Windows requiring emulation. The package
+  assumes Windows Terminal has replaced ConHost terminals on supported versions
+  of Windows. Functions that yield actions no longer enable (re-enable) the
+  processing of \'ANSI\' control characters in output.
 * On Windows, the package no longer depends (directly or indirectly) on the
   `Win32`, `array`,`containers`, `deepseq`, `filepath`, `ghc-boot-th`, 
`mintty`,
   `pretty` or `template-haskell` packages.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/ansi-terminal-1.0/README.md 
new/ansi-terminal-1.0.2/README.md
--- old/ansi-terminal-1.0/README.md     2023-05-07 12:14:00.000000000 +0200
+++ new/ansi-terminal-1.0.2/README.md   2024-01-13 17:38:22.000000000 +0100
@@ -62,21 +62,28 @@
 
 ``` haskell
 import System.Console.ANSI
+import System.IO (stdout)
 
+main :: IO ()
 main = do
-    setCursorPosition 5 0
-    setTitle "ANSI Terminal Short Example"
+  stdoutSupportsANSI <- hNowSupportsANSI stdout
+  if stdoutSupportsANSI
+    then do
+      setCursorPosition 5 0
+      setTitle "ANSI Terminal Short Example"
 
-    setSGR [ SetConsoleIntensity BoldIntensity
-           , SetColor Foreground Vivid Red
-           ]
-    putStr "Hello"
+      setSGR [ SetConsoleIntensity BoldIntensity
+             , SetColor Foreground Vivid Red
+             ]
+      putStr "Hello"
 
-    setSGR [ SetConsoleIntensity NormalIntensity
-           , SetColor Foreground Vivid White
-           , SetColor Background Dull Blue
-           ]
-    putStrLn "World!"
+      setSGR [ SetConsoleIntensity NormalIntensity
+             , SetColor Foreground Vivid White
+             , SetColor Background Dull Blue
+             ]
+      putStrLn "World!"
+    else
+      putStrLn "Standard output does not support 'ANSI' escape codes."
 ```
 
 
![](https://raw.githubusercontent.com/feuerbach/ansi-terminal/master/example.png)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/ansi-terminal-1.0/ansi-terminal.cabal 
new/ansi-terminal-1.0.2/ansi-terminal.cabal
--- old/ansi-terminal-1.0/ansi-terminal.cabal   2023-05-13 15:29:17.000000000 
+0200
+++ new/ansi-terminal-1.0.2/ansi-terminal.cabal 2024-01-13 18:06:54.000000000 
+0100
@@ -1,6 +1,6 @@
 Cabal-Version:       1.22
 Name:                ansi-terminal
-Version:             1.0
+Version:             1.0.2
 Category:            User Interfaces
 Synopsis:            Simple ANSI terminal support
 Description:         ANSI terminal support for Haskell: allows cursor movement,
@@ -16,6 +16,7 @@
 Extra-Source-Files:     CHANGELOG.md
                         README.md
                         win/include/errors.h
+                        win/include/HsWin32.h
                         win/include/winternl_compat.h
 
 Source-repository head
@@ -47,8 +48,11 @@
                                 System.Console.ANSI.Windows.Win32.MinTTY
             Include-Dirs:       win/include
             Includes:           errors.h
+                                HsWin32.h
                                 winternl_compat.h
+            Install-Includes:   HsWin32.h
             C-Sources:          win/c-source/errors.c
+                                win/c-source/HsWin32.c
         else
             Hs-Source-Dirs:     unix
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/ansi-terminal-1.0/app/Example.hs 
new/ansi-terminal-1.0.2/app/Example.hs
--- old/ansi-terminal-1.0/app/Example.hs        2023-03-18 12:32:07.000000000 
+0100
+++ new/ansi-terminal-1.0.2/app/Example.hs      2024-01-13 17:15:35.000000000 
+0100
@@ -31,7 +31,13 @@
            ]
 
 main :: IO ()
-main = mapM_ (resetScreen >>) examples
+main = do
+  stdoutSupportsANSI <- hNowSupportsANSI stdout
+  if stdoutSupportsANSI
+    then
+      mapM_ (resetScreen >>) examples
+    else
+      putStrLn "Standard output does not support 'ANSI' escape codes."
 
 -- 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
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/ansi-terminal-1.0/src/System/Console/ANSI.hs 
new/ansi-terminal-1.0.2/src/System/Console/ANSI.hs
--- old/ansi-terminal-1.0/src/System/Console/ANSI.hs    2023-05-13 
15:20:23.000000000 +0200
+++ new/ansi-terminal-1.0.2/src/System/Console/ANSI.hs  2024-01-13 
17:41:40.000000000 +0100
@@ -65,6 +65,17 @@
 API with the use of control character sequences and retiring the historical
 user-interface role of Windows Console Host (\'ConHost\').
 
+Windows Terminal is supported on Windows 10 version 19041.0 or higher and
+provided with Windows 11. It can be downloaded from the Microsoft Store. 
Windows
+Terminal can be set as the default terminal application on Windows 10 (from
+the 22H2 update) and is the default application on Windows 11 (from the 22H2
+update).
+
+Despite the above developments, some Windows users may continue to use ConHost.
+ConHost does not enable the processing of \'ANSI\' control characters in output
+by default. See 'hNowSupportsANSI' for a function that can try to enable such
+processing.
+
 Terminal software other than the native software exists for Windows. One 
example
 is the \'mintty\' terminal emulator for \'Cygwin\', \'MSYS\' or \'MSYS2\', and
 dervied projects, and for \'WSL\' (Windows Subsystem for Linux).
@@ -120,15 +131,21 @@
 > module Main where
 >
 > import System.Console.ANSI
+> import System.IO (stdout)
 >
 > -- Set colors and write some text in those colors.
 > main :: IO ()
 > main = do
->   setSGR [SetColor Foreground Vivid Red]
->   setSGR [SetColor Background Vivid Blue]
->   putStrLn "Red-On-Blue"
->   setSGR [Reset]  -- Reset to default colour scheme
->   putStrLn "Default colors."
+>   stdoutSupportsANSI <- hNowSupportsANSI stdout
+>   if stdoutSupportsANSI
+>     then do
+>       setSGR [SetColor Foreground Vivid Red]
+>       setSGR [SetColor Background Vivid Blue]
+>       putStrLn "Red-On-Blue"
+>       setSGR [Reset]  -- Reset to default colour scheme
+>       putStrLn "Default colors."
+>     else
+>       putStrLn "Standard output does not support 'ANSI' escape codes."
 
 Another example is below:
 
@@ -139,14 +156,19 @@
 >
 > 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
+>   stdoutSupportsANSI <- hNowSupportsANSI stdout
+>   if stdoutSupportsANSI
+>     then 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
+>     else
+>       putStrLn "Standard output does not support 'ANSI' escape codes."
 
 For many more examples, see the project's extensive
 <https://github.com/UnkindPartition/ansi-terminal/blob/master/app/Example.hs 
Example.hs> file.
@@ -317,6 +339,7 @@
 
     -- * Checking if handle supports ANSI (not portable: GHC only)
   , hSupportsANSI
+  , hNowSupportsANSI
   , hSupportsANSIColor
 
     -- * Getting the cursor position
@@ -573,29 +596,41 @@
          -> IO ()
 setTitle = hSetTitle stdout
 
--- | Use heuristics to determine whether the functions defined in this
--- package will work with a given handle.
+-- | Use heuristics to determine whether the functions defined in this package
+-- will work with a given handle.
 --
 -- If the handle is not writable (that is, it cannot manage output - see
 -- 'hIsWritable'), then @pure False@ is returned.
 --
 -- For Unix-like operating systems, the current implementation checks
--- that: (1) the handle is a terminal; and (2) a @TERM@
--- environment variable is not set to @dumb@ (which is what the GNU Emacs text
--- editor sets for its integrated terminal).
---
--- For Windows, the current implementation performs the same checks as for
--- Unix-like operating systems and, as an alternative, checks whether the
--- handle is connected to a \'mintty\' terminal. (That is because the function
--- 'hIsTerminalDevice' is used to check if the handle is a
--- terminal. However, where a non-native Windows terminal (such as \'mintty\')
--- is implemented using redirection, that function will not identify a
--- handle to the terminal as a terminal.)
+-- that: (1) the handle is a terminal; and (2) a @TERM@ environment variable is
+-- not set to @dumb@ (which is what the GNU Emacs text editor sets for its
+-- integrated terminal).
+--
+-- For Windows, the current implementation checks: first that (1) the handle is
+-- a terminal, (2) a @TERM@ environment variable is not set to @dumb@, and (3)
+-- the processing of \'ANSI\' control characters in output is enabled; and
+-- second, as an alternative, whether the handle is connected to a \'mintty\'
+-- terminal. (That is because the function 'hIsTerminalDevice' is used to check
+-- if the handle is a terminal. However, where a non-native Windows terminal
+-- (such as \'mintty\') is implemented using redirection, that function will 
not
+-- identify a handle to the terminal as a terminal.) If it is not already
+-- enabled, this function does *not* enable the processing of \'ANSI\' control
+-- characters in output (see 'hNowSupportsANSI').
 --
 -- @since 0.6.2
 hSupportsANSI :: Handle -> IO Bool
 hSupportsANSI = Internal.hSupportsANSI
 
+-- | With one exception, equivalent to 'hSupportsANSI'. The exception is that,
+-- on Windows only, if a @TERM@ environment variable is not set to @dumb@ and
+-- the processing of \'ANSI\' control characters in output is not enabled, this
+-- function first tries to enable such processing.
+--
+-- @Since 1.0.1
+hNowSupportsANSI :: Handle -> IO Bool
+hNowSupportsANSI = Internal.hNowSupportsANSI
+
 -- | Some terminals (e.g. Emacs) are not fully ANSI compliant but can support
 -- ANSI colors. This can be used in such cases, if colors are all that is
 -- needed.
@@ -610,15 +645,15 @@
 
 -- | Use heuristics to determine whether a given handle will support \'ANSI\'
 -- control characters in output. The function is consistent with
--- 'hSupportsANSI'.
+-- 'hNowSupportsANSI'.
 --
 -- This function is deprecated as, from version 1.0, the package no longer
 -- supports legacy versions of Windows that required emulation.
 --
 -- @since 0.8.1
-{-# DEPRECATED hSupportsANSIWithoutEmulation "See Haddock documentation and 
hSupportsANSI." #-}
+{-# DEPRECATED hSupportsANSIWithoutEmulation "See Haddock documentation and 
hNowSupportsANSI." #-}
 hSupportsANSIWithoutEmulation :: Handle -> IO (Maybe Bool)
-hSupportsANSIWithoutEmulation h = Just <$> hSupportsANSI h
+hSupportsANSIWithoutEmulation h = Just <$> hNowSupportsANSI h
 
 -- | Parses the characters emitted by 'reportCursorPosition' into the console
 -- input stream. Returns the cursor row and column as a tuple.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/ansi-terminal-1.0/unix/System/Console/ANSI/Internal.hs 
new/ansi-terminal-1.0.2/unix/System/Console/ANSI/Internal.hs
--- old/ansi-terminal-1.0/unix/System/Console/ANSI/Internal.hs  2023-05-07 
12:14:00.000000000 +0200
+++ new/ansi-terminal-1.0.2/unix/System/Console/ANSI/Internal.hs        
2024-01-13 17:15:35.000000000 +0100
@@ -4,6 +4,7 @@
   ( getReportedCursorPosition
   , getReportedLayerColor
   , hSupportsANSI
+  , hNowSupportsANSI
   ) where
 
 import Data.List ( uncons )
@@ -73,3 +74,6 @@
  where
   hSupportsANSI' = (&&) <$> hIsTerminalDevice h <*> isNotDumb
   isNotDumb = (/= Just "dumb") <$> lookupEnv "TERM"
+
+hNowSupportsANSI :: Handle -> IO Bool
+hNowSupportsANSI = hSupportsANSI
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/ansi-terminal-1.0/win/System/Console/ANSI/Internal.hs 
new/ansi-terminal-1.0.2/win/System/Console/ANSI/Internal.hs
--- old/ansi-terminal-1.0/win/System/Console/ANSI/Internal.hs   2023-05-13 
15:20:23.000000000 +0200
+++ new/ansi-terminal-1.0.2/win/System/Console/ANSI/Internal.hs 2024-01-13 
17:15:35.000000000 +0100
@@ -3,10 +3,12 @@
 module System.Console.ANSI.Internal
   ( getReportedCursorPosition
   , getReportedLayerColor
+  , hNowSupportsANSI
   , hSupportsANSI
   ) where
 
-import Control.Exception ( IOException, catch )
+import Control.Exception ( IOException, SomeException, catch, try )
+import Data.Bits ( (.&.), (.|.) )
 import Data.Maybe ( mapMaybe )
 import System.Environment ( lookupEnv )
 import System.IO ( Handle, hIsTerminalDevice, hIsWritable, stdin )
@@ -15,12 +17,13 @@
 -- Provided by the ansi-terminal package
 import System.Console.ANSI.Windows.Foreign
          ( INPUT_RECORD (..), INPUT_RECORD_EVENT (..), KEY_EVENT_RECORD (..)
-         , cWcharsToChars, getNumberOfConsoleInputEvents, readConsoleInput
-         , unicodeAsciiChar
+         , cWcharsToChars, eNABLE_VIRTUAL_TERMINAL_PROCESSING
+         , getConsoleMode, getNumberOfConsoleInputEvents, iNVALID_HANDLE_VALUE
+         , nullHANDLE, readConsoleInput, setConsoleMode, unicodeAsciiChar
          )
 import System.Console.ANSI.Windows.Win32.MinTTY ( isMinTTYHandle )
-import System.Console.ANSI.Windows.Win32.Types ( withHandleToHANDLE )
-
+import System.Console.ANSI.Windows.Win32.Types
+         ( DWORD, HANDLE, withHandleToHANDLE )
 
 getReportedCursorPosition :: IO String
 getReportedCursorPosition = getReported
@@ -62,11 +65,41 @@
         "or PowerShell."
 
 hSupportsANSI :: Handle -> IO Bool
-hSupportsANSI h = (&&) <$> hIsWritable h <*> hSupportsANSI'
- where
-  hSupportsANSI' = (||) <$> isTDNotDumb <*> isMinTTY
-  -- Borrowed from an HSpec patch by Simon Hengel
-  -- 
(https://github.com/hspec/hspec/commit/d932f03317e0e2bd08c85b23903fb8616ae642bd)
-  isTDNotDumb = (&&) <$> hIsTerminalDevice h <*> isNotDumb
-  isNotDumb = (/= Just "dumb") <$> lookupEnv "TERM"
-  isMinTTY = withHandleToHANDLE h isMinTTYHandle
+hSupportsANSI = hSupportsANSI' False
+
+hNowSupportsANSI :: Handle -> IO Bool
+hNowSupportsANSI = hSupportsANSI' True
+
+hSupportsANSI' :: Bool -> Handle -> IO Bool
+hSupportsANSI' tryToEnable handle = do
+  isWritable <- hIsWritable handle
+  if isWritable
+    then withHandleToHANDLE handle $ withHANDLE
+      (pure False) -- Invalid handle or no handle
+      ( \h -> do
+          tryMode <- try (getConsoleMode h) :: IO (Either SomeException DWORD)
+          case tryMode of
+            Left _ -> isMinTTYHandle h -- No ConHost mode
+            Right mode -> do
+              let isVTEnabled = mode .&. eNABLE_VIRTUAL_TERMINAL_PROCESSING /= 0
+                  isNotDumb = (/= Just "dumb") <$> lookupEnv "TERM"
+              isTDNotDumb <- (&&) <$> hIsTerminalDevice handle <*> isNotDumb
+              if isTDNotDumb && not isVTEnabled && tryToEnable
+                then do
+                  let mode' = mode .|. eNABLE_VIRTUAL_TERMINAL_PROCESSING
+                  trySetMode <- try (setConsoleMode h mode')
+                    :: IO (Either SomeException ())
+                  case trySetMode of
+                    Left _ -> pure False -- Can't enable VT processing
+                    Right () -> pure True -- VT processing enabled
+                else pure $ isTDNotDumb && isVTEnabled
+      )
+    else pure False
+
+-- | This function applies another to the Windows handle, if the handle is
+-- valid. If it is invalid, the specified default action is returned.
+withHANDLE :: IO a -> (HANDLE -> IO a) -> HANDLE -> IO a
+withHANDLE invalid action h =
+  if h == iNVALID_HANDLE_VALUE || h == nullHANDLE
+    then invalid  -- Invalid handle or no handle
+    else action h
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/ansi-terminal-1.0/win/System/Console/ANSI/Windows/Foreign.hs 
new/ansi-terminal-1.0.2/win/System/Console/ANSI/Windows/Foreign.hs
--- old/ansi-terminal-1.0/win/System/Console/ANSI/Windows/Foreign.hs    
2023-05-13 15:20:23.000000000 +0200
+++ new/ansi-terminal-1.0.2/win/System/Console/ANSI/Windows/Foreign.hs  
2024-01-13 18:13:16.000000000 +0100
@@ -1,6 +1,6 @@
 {-# LANGUAGE DeriveDataTypeable #-}
 {-# LANGUAGE RankNTypes         #-}
-{-# LANGUAGE Safe               #-}
+{-# LANGUAGE Trustworthy        #-}
 
 module System.Console.ANSI.Windows.Foreign
   (
@@ -11,6 +11,11 @@
   , readConsoleInput
   , cWcharsToChars
   , unicodeAsciiChar
+  , eNABLE_VIRTUAL_TERMINAL_PROCESSING
+  , iNVALID_HANDLE_VALUE
+  , nullHANDLE
+  , getConsoleMode
+  , setConsoleMode
   ) where
 
 import Control.Exception ( Exception )
@@ -20,11 +25,11 @@
 import Foreign.C.Types ( CWchar (..) )
 import Foreign.Marshal.Alloc ( alloca )
 import Foreign.Marshal.Array ( allocaArray, peekArray, pokeArray )
-import Foreign.Ptr ( Ptr, castPtr, plusPtr )
+import Foreign.Ptr ( Ptr, castPtr, plusPtr, nullPtr )
 import Foreign.Storable ( Storable (..) )
 import System.Console.ANSI.Windows.Win32.Types
-         ( BOOL, DWORD, ErrCode, HANDLE, LPDWORD, SHORT, UINT, ULONG, WCHAR
-         , WORD, failIfFalse_
+         ( BOOL, DWORD, ErrCode, HANDLE, LPDWORD, SHORT, UINT, UINT_PTR, ULONG
+         , WCHAR, WORD, failIfFalse_
          )
 
 peekAndOffset :: Storable a => Ptr a -> IO (a, Ptr b)
@@ -461,3 +466,29 @@
       ((c1 - 0xd800)*0x400 + (c2 - 0xdc00) + 0x10000) : fromUTF16 wcs
   fromUTF16 (c:wcs) = c : fromUTF16 wcs
   fromUTF16 [] = []
+
+eNABLE_VIRTUAL_TERMINAL_PROCESSING :: DWORD
+eNABLE_VIRTUAL_TERMINAL_PROCESSING = 4
+
+iNVALID_HANDLE_VALUE :: HANDLE
+iNVALID_HANDLE_VALUE = castUINTPtrToPtr maxBound
+
+nullHANDLE :: HANDLE
+nullHANDLE = nullPtr
+
+foreign import ccall unsafe "HsWin32.h _ansi_terminal_castUINTPtrToPtr"
+  castUINTPtrToPtr :: UINT_PTR -> Ptr a
+
+foreign import ccall unsafe "windows.h GetConsoleMode"
+  c_GetConsoleMode :: HANDLE -> LPDWORD -> IO BOOL
+
+foreign import ccall unsafe "windows.h SetConsoleMode"
+  c_SetConsoleMode :: HANDLE -> DWORD -> IO BOOL
+
+getConsoleMode :: HANDLE -> IO DWORD
+getConsoleMode h = alloca $ \ptr -> do
+  failIfFalse_ "GetConsoleMode" $ c_GetConsoleMode h ptr
+  peek ptr
+
+setConsoleMode :: HANDLE -> DWORD -> IO ()
+setConsoleMode h mode = failIfFalse_ "SetConsoleMode" $ c_SetConsoleMode h mode
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/ansi-terminal-1.0/win/System/Console/ANSI/Windows/Win32/Types.hs 
new/ansi-terminal-1.0.2/win/System/Console/ANSI/Windows/Win32/Types.hs
--- old/ansi-terminal-1.0/win/System/Console/ANSI/Windows/Win32/Types.hs        
2023-05-13 15:20:23.000000000 +0200
+++ new/ansi-terminal-1.0.2/win/System/Console/ANSI/Windows/Win32/Types.hs      
2024-01-13 18:13:52.000000000 +0100
@@ -19,6 +19,7 @@
   , SHORT
   , TCHAR
   , UINT
+  , UINT_PTR
   , ULONG
   , USHORT
   , WCHAR
@@ -68,6 +69,7 @@
 type SHORT = CShort
 type TCHAR = CWchar
 type UINT = Word32
+type UINT_PTR = Word
 type ULONG = Word32
 type USHORT = Word16
 type WCHAR = CWchar
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/ansi-terminal-1.0/win/c-source/HsWin32.c 
new/ansi-terminal-1.0.2/win/c-source/HsWin32.c
--- old/ansi-terminal-1.0/win/c-source/HsWin32.c        1970-01-01 
01:00:00.000000000 +0100
+++ new/ansi-terminal-1.0.2/win/c-source/HsWin32.c      2024-01-13 
17:15:35.000000000 +0100
@@ -0,0 +1,3 @@
+// Out-of-line versions of all the inline functions from HsWin32.h
+#define INLINE  /* nothing */
+#include "HsWin32.h"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/ansi-terminal-1.0/win/include/HsWin32.h 
new/ansi-terminal-1.0.2/win/include/HsWin32.h
--- old/ansi-terminal-1.0/win/include/HsWin32.h 1970-01-01 01:00:00.000000000 
+0100
+++ new/ansi-terminal-1.0.2/win/include/HsWin32.h       2024-01-13 
18:13:16.000000000 +0100
@@ -0,0 +1,23 @@
+#ifndef _ANSI_TERMINAL_HSWIN32_H
+#define _ANSI_TERMINAL_HSWIN32_H
+
+#define UNICODE
+#include <windows.h>
+
+/* Copied from the Win32-2.13.4.0 package, but renamed `castUINTPtrToPtr` to
+ * `_ansi_terminal_castUINTPtrToPtr`, in order to avoid problems with duplicate
+ * symbols in GHC's object files. See:
+ * https://gitlab.haskell.org/ghc/ghc/-/issues/23365.
+ */
+
+#ifndef INLINE
+# if defined(_MSC_VER)
+#  define INLINE extern __inline
+# else
+#  define INLINE extern inline
+# endif
+#endif
+
+INLINE void *_ansi_terminal_castUINTPtrToPtr(UINT_PTR n) { return (void *)n; }
+
+#endif /* _ANSI_TERMINAL_HSWIN32_H */

Reply via email to