-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/

-- | Pseudo terminal interaction with subprocesses.
--   
--   This package simplifies the creation of subprocesses that interact
--   with their parent via a pseudo terminal (see man pty).
@package posix-pty
@version 0.2.2

-- | A module for interacting with subprocesses through a pseudo terminal
--   (pty). Provides functions for reading from, writing to and resizing
--   pseudo terminals. Re-exports most of System.Posix.Terminal,
--   providing wrappers that work with the Pty type where necessary.
module System.Posix.Pty

-- | Create a new process that is connected to the current process through
--   a pseudo terminal. If an environment is specified, then only the
--   specified environment variables will be set. If no environment is
--   specified the process will inherit its environment from the current
--   process. Example:
--   
--   
--   pty <- spawnWithPty (Just [("SHELL", "tcsh")]) True "ls" ["-l"] (20, 10)
--   
--   
--   This searches the user's PATH for a binary called ls, then
--   runs this binary with the commandline argument -l in a
--   terminal that is 20 characters wide and 10 characters high. The
--   environment of ls will contains one variable, SHELL, which
--   will be set to the value "tcsh".
spawnWithPty :: Maybe [(String, String)] -> Bool -> FilePath -> [String] -> (Int, Int) -> IO (Pty, ProcessHandle)

-- | Abstract pseudo terminal type.
data Pty

-- | Pseudo terminal control information.
--   
--   
--   
- Terminal read queue The terminal read queue contains the
--   data that was written from the master terminal to the slave terminal,
--   which was not read from the slave yet.
--   
- Terminal write queue The terminal write queue contains the
--   data that was written from the slave terminal, which was not sent to
--   the master yet.
--   
data PtyControlCode

-- | Terminal read queue was flushed.
FlushRead :: PtyControlCode

-- | Terminal write queue was flushed.
FlushWrite :: PtyControlCode

-- | Terminal output was stopped.
OutputStopped :: PtyControlCode

-- | Terminal output was restarted.
OutputStarted :: PtyControlCode

-- | Terminal stop and start characters are ^S and ^Q
--   respectively.
DoStop :: PtyControlCode

-- | Terminal stop and start characters are NOT ^S and
--   ^Q.
NoStop :: PtyControlCode

-- | Produces a Pty if the file descriptor is associated with a
--   terminal and Nothing if not.
createPty :: Fd -> IO (Maybe Pty)

-- | Close this pseudo terminal.
closePty :: Pty -> IO ()

-- | Attempt to read data from a pseudo terminal. Produces either the data
--   read or a list of PtyControlCodes indicating which
--   control status events that have happened on the slave terminal.
--   
--   Throws an IOError of type eofErrorType when the terminal
--   has been closed, for example when the subprocess has terminated.
tryReadPty :: Pty -> IO (Either [PtyControlCode] ByteString)

-- | The same as tryReadPty, but discards any control status events.
readPty :: Pty -> IO ByteString

-- | Write a ByteString to the pseudo terminal, throws an
--   IOError when the terminal has been closed, for example when the
--   subprocess has terminated.
writePty :: Pty -> ByteString -> IO ()

-- | Set the pseudo terminal's dimensions to the specified width and
--   height.
resizePty :: Pty -> (Int, Int) -> IO ()

-- | Produces the pseudo terminal's current dimensions.
ptyDimensions :: Pty -> IO (Int, Int)

-- | Equivalent to threadWaitRead.
threadWaitReadPty :: Pty -> IO ()

-- | Equivalent to threadWaitWrite.
threadWaitWritePty :: Pty -> IO ()

-- | Equivalent to threadWaitReadSTM.
threadWaitReadPtySTM :: Pty -> IO (STM (), IO ())

-- | Equivalent to threadWaitWriteSTM.
threadWaitWritePtySTM :: Pty -> IO (STM (), IO ())

-- | See getTerminalAttributes.
getTerminalAttributes :: Pty -> IO TerminalAttributes

-- | See setTerminalAttributes.
setTerminalAttributes :: Pty -> TerminalAttributes -> TerminalState -> IO ()

-- | See sendBreak.
sendBreak :: Pty -> Int -> IO ()

-- | See drainOutput.
drainOutput :: Pty -> IO ()

-- | See discardData.
discardData :: Pty -> QueueSelector -> IO ()

-- | See controlFlow.
controlFlow :: Pty -> FlowAction -> IO ()

-- | See getTerminalProcessGroupID.
getTerminalProcessGroupID :: Pty -> IO ProcessGroupID

-- | See getTerminalName.
getTerminalName :: Pty -> IO FilePath

-- | See getSlaveTerminalName.
getSlaveTerminalName :: Pty -> IO FilePath
data FlowAction

-- | TCOOFF
SuspendOutput :: FlowAction

-- | TCOON
RestartOutput :: FlowAction

-- | TCIOFF
TransmitStop :: FlowAction

-- | TCION
TransmitStart :: FlowAction
data QueueSelector
InputQueue :: QueueSelector
OutputQueue :: QueueSelector
BothQueues :: QueueSelector
data TerminalState
Immediately :: TerminalState
WhenDrained :: TerminalState
WhenFlushed :: TerminalState

-- | Serial line baudrate. The set of supported speeds is system-dependent.
--   Portable use of the provided pattern synonyms that are outside the
--   list mandated by POSIX requires #ifdef guards.
--   
--   Applications may need to be prepared to encounter speeds not known at
--   compile time, these can be handled generically via the BaudRate
--   constructor. In other words, the provided pattern synonyms are not
--   necessarily a COMPLETE set.
--   
--   All non-zero pseudo-terminal baud rates are functionally
--   equivalent, and the pty driver may accept any speed within a
--   suitable range. Requested speeds may be rounded up or down to fit into
--   the supported range.
newtype BaudRate
BaudRate :: CSpeed -> BaudRate

-- | 4000000 baud, non-POSIX system-dependent extension
pattern B4000000 :: BaudRate

-- | 3500000 baud, non-POSIX system-dependent extension
pattern B3500000 :: BaudRate

-- | 3000000 baud, non-POSIX system-dependent extension
pattern B3000000 :: BaudRate

-- | 2500000 baud, non-POSIX system-dependent extension
pattern B2500000 :: BaudRate

-- | 2000000 baud, non-POSIX system-dependent extension
pattern B2000000 :: BaudRate

-- | 1500000 baud, non-POSIX system-dependent extension
pattern B1500000 :: BaudRate

-- | 1152000 baud, non-POSIX system-dependent extension
pattern B1152000 :: BaudRate

-- | 1000000 baud, non-POSIX system-dependent extension
pattern B1000000 :: BaudRate

-- | 921600 baud, non-POSIX system-dependent extension
pattern B921600 :: BaudRate

-- | 576000 baud, non-POSIX system-dependent extension
pattern B576000 :: BaudRate

-- | 500000 baud, non-POSIX system-dependent extension
pattern B500000 :: BaudRate

-- | 460800 baud, non-POSIX system-dependent extension
pattern B460800 :: BaudRate

-- | 230400 baud, non-POSIX system-dependent extension
pattern B230400 :: BaudRate

-- | 115200 baud, non-POSIX system-dependent extension
pattern B115200 :: BaudRate

-- | 76800 baud, non-POSIX system-dependent extension
pattern B76800 :: BaudRate

-- | 57600 baud, non-POSIX system-dependent extension
pattern B57600 :: BaudRate

-- | 28800 baud, non-POSIX system-dependent extension
pattern B28800 :: BaudRate

-- | 14400 baud, non-POSIX system-dependent extension
pattern B14400 :: BaudRate

-- | 7200 baud, non-POSIX system-dependent extension
pattern B7200 :: BaudRate

-- | 38400 baud
pattern B38400 :: BaudRate

-- | 19200 baud
pattern B19200 :: BaudRate

-- | 9600 baud
pattern B9600 :: BaudRate

-- | 4800 baud
pattern B4800 :: BaudRate

-- | 2400 baud
pattern B2400 :: BaudRate

-- | 1800 baud
pattern B1800 :: BaudRate

-- | 1200 baud
pattern B1200 :: BaudRate

-- | 600 baud
pattern B600 :: BaudRate

-- | 300 baud
pattern B300 :: BaudRate

-- | 200 baud
pattern B200 :: BaudRate

-- | 150 baud
pattern B150 :: BaudRate

-- | 
--   
- 5 baud
--   
pattern B134 :: BaudRate

-- | 110 baud
pattern B110 :: BaudRate

-- | 75 baud
pattern B75 :: BaudRate

-- | 50 baud
pattern B50 :: BaudRate

-- | Hang up
pattern B0 :: BaudRate
data ControlCharacter
EndOfFile :: ControlCharacter
EndOfLine :: ControlCharacter
Erase :: ControlCharacter
Interrupt :: ControlCharacter
Kill :: ControlCharacter
Quit :: ControlCharacter
Start :: ControlCharacter
Stop :: ControlCharacter
Suspend :: ControlCharacter
data TerminalMode

-- | BRKINT - Signal interrupt on break
InterruptOnBreak :: TerminalMode

-- | ICRNL - Map CR to NL on input
MapCRtoLF :: TerminalMode

-- | IGNBRK - Ignore break condition
IgnoreBreak :: TerminalMode

-- | IGNCR - Ignore CR
IgnoreCR :: TerminalMode

-- | IGNPAR - Ignore characters with parity errors
IgnoreParityErrors :: TerminalMode

-- | INLCR - Map NL to CR on input
MapLFtoCR :: TerminalMode

-- | INPCK - Enable input parity check
CheckParity :: TerminalMode

-- | ISTRIP - Strip character
StripHighBit :: TerminalMode

-- | IXANY - Enable any character to restart output
RestartOnAny :: TerminalMode

-- | IXOFF - Enable start/stop input control
StartStopInput :: TerminalMode

-- | IXON - Enable start/stop output control
StartStopOutput :: TerminalMode

-- | PARMRK - Mark parity errors
MarkParityErrors :: TerminalMode

-- | OPOST - Post-process output
ProcessOutput :: TerminalMode

-- | ONLCR - (XSI) Map NL to CR-NL on output
MapLFtoCRLF :: TerminalMode

-- | OCRNL - (XSI) Map CR to NL on output
OutputMapCRtoLF :: TerminalMode

-- | ONOCR - (XSI) No CR output at column 0
NoCRAtColumnZero :: TerminalMode

-- | ONLRET - (XSI) NL performs CR function
ReturnMeansLF :: TerminalMode

-- | TABDLY(TAB0) - (XSI) Select horizontal-tab delays: type 0
TabDelayMask0 :: TerminalMode

-- | TABDLY(TAB3) - (XSI) Select horizontal-tab delays: type 3
TabDelayMask3 :: TerminalMode

-- | CLOCAL - Ignore modem status lines
LocalMode :: TerminalMode

-- | CREAD - Enable receiver
ReadEnable :: TerminalMode

-- | CSTOPB - Send two stop bits, else one
TwoStopBits :: TerminalMode

-- | HUPCL - Hang up on last close
HangupOnClose :: TerminalMode

-- | PARENB - Parity enable
EnableParity :: TerminalMode

-- | PARODD - Odd parity, else even
OddParity :: TerminalMode

-- | ECHO - Enable echo
EnableEcho :: TerminalMode

-- | ECHOE - Echo erase character as error-correcting backspace
EchoErase :: TerminalMode

-- | ECHOK - Echo KILL
EchoKill :: TerminalMode

-- | ECHONL - Echo NL
EchoLF :: TerminalMode

-- | ICANON - Canonical input (erase and kill processing)
ProcessInput :: TerminalMode

-- | IEXTEN - Enable extended input character processing
ExtendedFunctions :: TerminalMode

-- | ISIG - Enable signals
KeyboardInterrupts :: TerminalMode

-- | NOFLSH - Disable flush after interrupt or quit
NoFlushOnInterrupt :: TerminalMode

-- | TOSTOP - Send SIGTTOU for background output
BackgroundWriteInterrupt :: TerminalMode
data TerminalAttributes
withoutMode :: TerminalAttributes -> TerminalMode -> TerminalAttributes
withMode :: TerminalAttributes -> TerminalMode -> TerminalAttributes
terminalMode :: TerminalMode -> TerminalAttributes -> Bool
bitsPerByte :: TerminalAttributes -> Int
withBits :: TerminalAttributes -> Int -> TerminalAttributes
controlChar :: TerminalAttributes -> ControlCharacter -> Maybe Char
withCC :: TerminalAttributes -> (ControlCharacter, Char) -> TerminalAttributes
withoutCC :: TerminalAttributes -> ControlCharacter -> TerminalAttributes
inputTime :: TerminalAttributes -> Int
withTime :: TerminalAttributes -> Int -> TerminalAttributes
minInput :: TerminalAttributes -> Int
withMinInput :: TerminalAttributes -> Int -> TerminalAttributes
inputSpeed :: TerminalAttributes -> BaudRate
withInputSpeed :: TerminalAttributes -> BaudRate -> TerminalAttributes
outputSpeed :: TerminalAttributes -> BaudRate
withOutputSpeed :: TerminalAttributes -> BaudRate -> TerminalAttributes

-- | getControllingTerminalName calls ctermid to obtain a
--   name associated with the controlling terminal for the process. If a
--   controlling terminal exists, getControllingTerminalName
--   returns the name of the controlling terminal.
--   
--   Throws IOError ("unsupported operation") if platform does not
--   provide ctermid(3) (use #if HAVE_CTERMID CPP guard
--   to detect availability).
getControllingTerminalName :: IO FilePath
instance GHC.Classes.Eq System.Posix.Pty.PtyControlCode
instance GHC.Internal.Read.Read System.Posix.Pty.PtyControlCode
instance GHC.Internal.Show.Show System.Posix.Pty.PtyControlCode
