wxcore-0.92.2.0: wxHaskell core

Copyright(c) Daan Leijen 2003
LicensewxWindows
Maintainerwxhaskell-devel@lists.sourceforge.net
Stabilityprovisional
Portabilityportable
Safe HaskellNone
LanguageHaskell98

Graphics.UI.WXCore.Process

Contents

Description

Process and stream wrappers.

Synopsis

Process

type OnReceive = String -> StreamStatus -> IO () Source

Type of input receiver function.

type OnEndProcess = Int -> IO () Source

Type of end-of-process event handler. Gets the exitcode as its argument.

processExecAsyncTimed :: Window a -> String -> Bool -> OnEndProcess -> OnReceive -> OnReceive -> IO (String -> IO StreamStatus, Process (), Int) Source

(processExecAsyncTimer command processOutputOnEnd onEndProcess onOutput onErrorOutput parent) starts the command asynchronously. The handler onEndProcess is called when the process terminates. onOutput receives the output from stdout, while onErrorOutput receives output from stderr. If processOutputOnEnd is True, the remaining output of a terminated process is processed (calling onOutput). The call returns a triple (send,process,pid): The send function is used to send input to the stdin pipe of the process. The process object is returned in process and the process identifier in pid.

Note: The method uses idle event timers to process the output channels. On many platforms this is much more trustworthy and robust than the processExecAsync that uses threads (which can cause all kinds of portability problems).

processExecAsync :: Window a -> String -> Int -> OnEndProcess -> OnReceive -> OnReceive -> IO (String -> IO (), Process (), Int) Source

Deprecated: Use processExecAsyncTimed instead (if possible)

deprecated: use processExecAsyncTimed instead (if possible). (processExecAsync command bufferSize onEndProcess onOutput onErrorOutput parent) starts the command asynchronously. The handler onEndProcess is called when the process terminates. onOutput receives the output from stdout, while onErrorOutput receives output from stderr. The bufferSize determines the intermediate buffer used to cache the output from those channels. The calls returns a triple (send,process,pid): The send function is used to send input to the stdin pipe of the process. The process object is returned in process and the process identifier in pid.

Streams

data StreamStatus Source

The status of a stream (see StreamBase)

Constructors

StreamOk

No error.

StreamEof

No more input.

StreamReadError

Read error.

StreamWriteError

Write error.

streamBaseStatus :: StreamBase a -> IO StreamStatus Source

Return the status of the stream

Blocking IO

inputStreamGetContents :: InputStream a -> IO String Source

Get the entire contents of an input stream. The content is returned as a lazy stream (like hGetContents).

inputStreamGetContentsN :: InputStream a -> Int -> IO String Source

Get the entire contents of an input stream. The content is returned as a lazy stream (like hGetContents). The contents are returned in lazy batches, whose size is determined by the first parameter.

inputStreamGetLine :: InputStream a -> Int -> IO String Source

inputStreamGetLine s n reads a line of at most n characters from the input stream (potentially waiting for input). The function does automatic end-of-line conversion. If the line ends with \n, an entire line has been read, otherwise, either the maximum has been reached, or no more input was available.

inputStreamGetString :: InputStream a -> Int -> IO String Source

The expression (inputStreamGetString n input) reads a string of maximally n characters from input.

inputStreamGetChar :: InputStream a -> IO Char Source

Read a single character from the input. (equals inputStreamGetC)

outputStreamPutString :: OutputStream a -> String -> IO () Source

Write a string to an output stream, potentially blocking until all output has been written.

Non-blocking IO

inputStreamGetLineNoWait :: InputStream a -> Int -> IO String Source

inputStreamGetLineNoWait stream n reads a line of at most n characters from the input stream in a non-blocking way. The function does automatic end-of-line conversion. If the line ends with \n, an entire line has been read, otherwise, either the maximum has been reached, or no more input was available.

inputStreamGetStringNoWait :: InputStream a -> Int -> IO String Source

inputStreamGetStringNoWait stream n reads a line of at most n characters from the input stream in a non-blocking way.

inputStreamGetCharNoWait :: InputStream a -> IO (Maybe Char) Source

Read a single character from the input, returning Nothing if no input was available (using inputStreamCanRead).

outputStreamPutStringNoWait :: OutputStream a -> String -> IO Int Source

Write a string to an output stream, returning the number of bytes actually written.