aZX!      Safe!"!"!"SafeN #$%&'()*+,-+./0123456789:;<=>?@ABCDEFGHIJKLM#$%&'()*+,- #$%&'()*+,-Safe NOPQRSTUVWX NOPQRSTUVWX NOPQRSTUVWXTU2013 Joey Hess <id@joeyh.name> BSD-2-clauseNone35FBuffered output.Values that can be output.Y.A shared global variable for the OutputHandle.Holds a lock while performing an action. This allows the action to perform its own output to the console, without using functions from this module.VWhile this is running, other threads that try to lockOutput will block. Any calls to   and  ^ will not block, but the output will be buffered and displayed only once the action is done.Z%Blocks until we have the output lock.[0Tries to take the output lock, without blocking.\/Only safe to call after taking the output lock.%Use this around any actions that use   or  nThis is necessary to ensure that buffered concurrent output actually gets displayed before the program exits.&Blocks until any processes started by  7 have finished, and any buffered output is displayed. J calls this at the end; you can call it anytime you want to flush output. Displays a value to stdout._No newline is appended to the value, so if you want a newline, be sure to include it yourself.{Uses locking to ensure that the whole output occurs atomically even when other threads are concurrently generating output.When something else is writing to the console at the same time, this does not block. It buffers the value, so it will be displayed once the other writer is done. 7This must be used to wait for processes started with  .This is necessary because  has a race condition when two threads check the same process. If the race is triggered, one thread will successfully wait, but the other throws a DoesNotExist exception. Wrapper around r that prevents multiple processes that are running concurrently from writing to stdout/stderr at the same time.If the process does not output to stdout or stderr, it's run by createProcess entirely as usual. Only processes that can generate output are handled specially:xA process is allowed to write to stdout and stderr in the usual way, assuming it can successfully take the output lock.MWhen the output lock is held (ie, by another concurrent process, or because   is being called at the same time), the process is instead run with its stdout and stderr redirected to a buffer. The buffered output will be displayed as soon as the output lock becomes free, or after the command has finished. 4Adds a value to the output buffer for later display.xNote that buffering large quantities of data this way will keep it resident in memory until it can be displayed. While  N uses temp files if the buffer gets too big, this STM function cannot do so. VA STM action that waits for some buffered output to become available, and returns it.The function can select a subset of output when only some is desired; the fst part is returned and the snd is left in the buffer.SThis will prevent it from being displayed in the usual way, so you'll need to use  to display it yourself. Use with  ~ to make it only return buffered output that ends with a newline. Anything buffered without a newline is left in the buffer.3Emits the content of the OutputBuffer to the Handle If you use this, you should use : to ensure you're the only thread writing to the console.7]^_`abcdefghijklmnYZ[op\ qrstuvwxy z {|}~   ']^_`abcdefghijklmnYZ[op\ qrstuvwxy z {|}~2013 Joey Hess <id@joeyh.name> BSD-2-clauseNoneF 8Function from console width to the height of this region1Controls how a region is laid out in the console.<Here's an annotated example of how the console layout works. scrolling...... scrolling...... scrolling...... aaaaaa......... -- Linear bbbbbbbbbbbbbbb -- Linear bbb............ (expanded to multiple lines) ccccccccc...... -- Linear ddd eee fffffff -- [InLine] ffff ggggg..... (expanded to multiple lines)  A shared global list of regions.Updates the list of regions. The list is ordered from the bottom of the screen up. Reordering it will change the order in which regions are displayed. It's also fine to remove, duplicate, or add new regions to the list.(The RegionList TMVar is left empty when   is not running.2Sets the value to display within a console region.NAppends the value to whatever was already on display within a console region.hRuns the action with a new console region, closing the region when the action finishes or on exception.&Opens a new console region for output.STM version of l. Allows atomically opening multiple regions at the same time, which guarantees they are on adjacent lines. I [r1, r2, r3] <- atomically $ replicateM 3 (openConsoleRegionSTM Linear)NCloses a console region. Once closed, the region is removed from the display.pCloses the console region and displays the passed value in the scrolling area above the active console regions. ;Handles all display for the other functions in this module.Note that this uses , so it takes over all output to the console while the passed IO action is running. As well as displaying the console regions, this handles display of anything buffered by   and  .YWhen standard output is not an ANSI capable terminal, console regions are not displayed.8   ,       !"#$%&'()*+,-./012345678978:78;78<78=789>?@>?A>?B>?C>?D>?E>?F>?G>?H>?I>?J>?K>?L>?M>?N>?O>?P>?Q>?R>?S>?T>?U>?V>?W>?X>?YZ[\]^_`abcdefghiijjklmno pqrrstuvwxyz{|}~concu_HQKI6J0Hi2w6qHcm1xkXutSystem.Console.ConcurrentSystem.Console.Regions Utility.DataUtility.Exception Utility.MonadSystem.ProcesswaitForProcess createProcess StdHandleStdOutStdErr OutputBuffer OutputabletoOutput lockOutputwithConcurrentOutputflushConcurrentOutputoutputConcurrentwaitForProcessConcurrentcreateProcessConcurrentbufferOutputSTMoutputBufferWaiterSTM waitAnyBufferwaitCompleteLinesemitOutputBufferConsoleRegionHandle RegionLayoutLinearInLineupdateRegionListSTMsetConsoleRegionsetConsoleRegionSTMappendConsoleRegionappendConsoleRegionSTMwithConsoleRegionopenConsoleRegionopenConsoleRegionSTMcloseConsoleRegioncloseConsoleRegionSTMfinishConsoleRegiondisplayConsoleRegions firstJust eitherToMaybe catchBoolIO catchMaybeIOcatchDefaultIO catchMsgIOcatchIOtryIO bracketIO catchNonAsync tryNonAsync tryWhenExistscatchHardwareFaultbase GHC.Exception SomeExceptiondisplayException fromException toException Exceptionexcep_8GsEeHgaIks3pVGk6GaELJControl.Monad.CatchbracketOnErrorfinallybracket_bracket onExceptioncatchestryJusttry handleJusthandleIf handleAll handleIOErrorhandle catchJustcatchIf catchIOErrorcatchAlluninterruptibleMask_mask_throwM MonadThrowcatch MonadCatchuninterruptibleMaskmask MonadMaskfirstMgetManyMallM untilTrueifM<||><&&>observeafternoopglobalOutputHandletakeOutputLocktryTakeOutputLockdropOutputLockBufSigAtEndOutputBufferedActivityOutput InTempFiletempFile endsInNewLineLockLocked OutputHandle outputLock outputBuffer errorBuffer outputThreadswithLocktakeOutputLock' willOutputtoHandle bufferForsetupOutputBuffer outputDrainerregisterOutputThreadunregisterOutputThread bufferWriteraddOutputBufferbufferOutputSTM' endsNewLine$fOutputable[]$fOutputableText$fOutputableByteString regionHeight regionListregionDisplayEnabledRegionSnapshot DisplayChange BufferChange RegionChangeTerminalResize EndSignal RegionListRegion regionContent regionLayoutregionChildrenHeightWidth modifyRegionfinishConsoleRegionSTM removeChildaddChild refreshParenttrackConsoleWidth displayThread readRegionsregionListWaiter regionWaiterchangedRegions diffUpdate updateRegions changeOffsets inAreaAbovedisplayRegionsinstallResizeHandlercalcRegionHeightcalcLineHeightcountInvisibleBytescountControlChars $fEqRegion