packages feed

concurrent-output 1.10.18 → 1.10.19

raw patch · 4 files changed

+49/−23 lines, 4 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

CHANGELOG view
@@ -1,3 +1,9 @@+concurrent-output (1.10.19) unstable; urgency=medium++  * Support building for WASM.++ -- Joey Hess <id@joeyh.name>  Wed, 30 Aug 2023 16:03:03 -0400+ concurrent-output (1.10.18) unstable; urgency=medium    * Avoid some build warnings on Windows.
System/Console/Regions.hs view
@@ -126,17 +126,19 @@ import Control.Concurrent.STM.TSem import Control.Concurrent.Async import System.Console.ANSI-import qualified System.Console.Terminal.Size as Console import System.IO import System.IO.Unsafe (unsafePerformIO) import Text.Read import Data.List (intercalate, nubBy)+import Control.Applicative+import Prelude+#ifdef VERSION_terminal_size+import qualified System.Console.Terminal.Size as Console #ifndef mingw32_HOST_OS import System.Posix.Signals import System.Posix.Signals.Exts #endif-import Control.Applicative-import Prelude+#endif  import System.Console.Concurrent import Utility.Monad@@ -182,22 +184,26 @@ regionList :: TMVar [ConsoleRegion] regionList = unsafePerformIO newEmptyTMVarIO --- | On Unix systems, this TVar is automatically updated when the--- terminal is resized. On Windows, it is only initialized on program start--- with the current terminal size.+data ConsoleSize = ConsoleSize+	{ _consoleHeight :: Int+	, _consoleWidth :: Int+	}+ {-# NOINLINE consoleSize #-}-consoleSize :: TVar (Console.Window Int)-consoleSize = unsafePerformIO $ newTVarIO $ -	Console.Window { Console.width = 80, Console.height = 25}+consoleSize :: TVar ConsoleSize+consoleSize = unsafePerformIO $ newTVarIO $+	ConsoleSize { _consoleWidth = 80, _consoleHeight = 25}  type Width = Int  -- | Gets the width of the console. -- -- On Unix, this is automatically updated when the terminal is resized.--- On Windows, it is only initialized on program start.+-- On Windows, it is determined at start. On WASM,+-- the console width is hard coded to 80 since WASI does not provide a way+-- to determine it. consoleWidth :: STM Int-consoleWidth = munge . Console.width <$> readTVar consoleSize+consoleWidth = munge . _consoleWidth <$> readTVar consoleSize   where #ifndef mingw32_HOST_OS 	munge = id@@ -208,8 +214,13 @@ #endif  -- | Get the height of the console.+--+-- On Unix, this is automatically updated when the terminal is resized.+-- On Windows, it is determined at start. On WASM,+-- the console heigth is hard coded to 25 since WASI does not provide a way+-- to determine it. consoleHeight :: STM Int-consoleHeight = Console.height <$> readTVar consoleSize+consoleHeight = _consoleHeight <$> readTVar consoleSize  -- | Check if `displayConsoleRegions` is running. regionDisplayEnabled :: IO Bool@@ -453,11 +464,20 @@ 			installResizeHandler Nothing  trackConsoleWidth :: IO ()+#ifdef VERSION_terminal_size trackConsoleWidth = do-	let getsz = maybe noop (atomically . writeTVar consoleSize)+	let getsz = maybe noop (atomically . writeTVar consoleSize . conv) 		=<< Console.size 	getsz 	installResizeHandler (Just getsz)+  where+	conv wsz = ConsoleSize+		{ _consoleWidth = Console.width wsz+		, _consoleHeight = Console.height wsz+		}+#else+trackConsoleWidth = return ()+#endif  data DisplayChange 	= BufferChange BufferSnapshot @@ -694,8 +714,12 @@  installResizeHandler :: Maybe (IO ()) -> IO () #ifndef mingw32_HOST_OS+#ifdef VERSION_terminal_size installResizeHandler h = void $ 	installHandler windowChange (maybe Default Catch h) Nothing+#else+installResizeHandler _ = return ()+#endif #else installResizeHandler _ = return () #endif
concurrent-output.cabal view
@@ -1,5 +1,5 @@ Name: concurrent-output-Version: 1.10.18+Version: 1.10.19 Cabal-Version: >= 1.10 License: BSD2 Maintainer: Joey Hess <id@joeyh.name>@@ -40,7 +40,6 @@     , transformers (>= 0.3.0 && < 0.7.0)     , exceptions (>= 0.6.0 && < 0.11.0)     , ansi-terminal (>= 0.6.2 && < 1.1.0)-    , terminal-size (>= 0.3.0 && < 0.4.0)   Exposed-Modules:     System.Console.Concurrent     System.Console.Concurrent.Internal@@ -52,6 +51,8 @@    if (! os(Windows))     Build-Depends: unix (>= 2.7.0 && < 2.9.0)+  if (! arch(wasm32))+    Build-Depends: terminal-size (>= 0.3.0 && < 0.4.0)  source-repository head   type: git
demo2.hs view
@@ -1,21 +1,16 @@ import Control.Concurrent.Async import Control.Concurrent-import System.Console.Concurrent import System.Console.Regions-import System.Console.Terminal.Size-import qualified Data.Text as T-import Control.Concurrent.STM-import Control.Applicative-import Data.Time.Clock import Control.Monad -main = displayConsoleRegions $ mapConcurrently id+main :: IO ()+main = displayConsoleRegions $ void $ mapConcurrently id 	[ spinner 100 1 "Pinwheels!!" setConsoleRegion "/-\\|" (withtitle 1) 	, spinner 100 1 "Bubbles!!!!" setConsoleRegion ".oOo." (withtitle 1) 	, spinner 100 1 "Dots......!" appendConsoleRegion "."  (const (take 3)) 	, spinner  30 2 "KleisiFish?" setConsoleRegion "  <=<   <=<  " (withtitle 10) 	, spinner  10 9 "Countdowns!" setConsoleRegion-		(reverse [1..10])+		(reverse ([1..10] :: [Int])) 		(\t n -> t ++ show (head n)) 	]   where