| Copyright | (C) 2016-2017 Ryan Scott |
|---|---|
| License | BSD-style (see the file LICENSE) |
| Maintainer | Ryan Scott |
| Stability | Provisional |
| Portability | Portable |
| Safe Haskell | Safe |
| Language | Haskell2010 |
System.IO.Echo.Internal
Description
Exports functions that handle whether or not terminal input is handled in a way that should be portable across different platforms and consoles.
Unlike System.IO.Echo, this module exports internal functionality which, if used improperly, can lead to runtime errors. Make sure to read the documentation beforehand!
Synopsis
- withoutInputEcho :: IO a -> IO a
- bracketInputEcho :: IO a -> IO a
- getInputEchoState :: IO EchoState
- setInputEchoState :: EchoState -> IO ()
- echoOff :: EchoState
- echoOn :: EchoState
- getInputEcho :: IO Bool
- setInputEcho :: Bool -> IO ()
- data EchoState
- = MinTTY STTYSettings
- | DefaultTTY Bool
- type STTYSettings = String
- getInputEchoSTTY :: IO STTYSettings
- setInputEchoSTTY :: STTYSettings -> IO ()
- sttyRaw :: String -> IO STTYSettings
- minTTY :: Bool
Safe public interface
withoutInputEcho :: IO a -> IO a Source #
Perform a computation with the terminal's input echoing disabled. Before
running the computation, the terminal's input EchoState is saved, and the
saved EchoState is restored after the computation finishes.
withoutInputEcho action =bracketInputEcho(setInputEchoStateechoOff>> action)
bracketInputEcho :: IO a -> IO a Source #
Save the terminal's current input EchoState, perform a computation,
restore the saved EchoState, and then return the result of the
computation.
bracketInputEcho action =bracketgetInputEchoStatesetInputEchoState(const action)
getInputEchoState :: IO EchoState Source #
Return the terminal's current input EchoState.
setInputEchoState :: EchoState -> IO () Source #
Set the terminal's input EchoState.
Alternative (safe) interface
getInputEcho :: IO Bool Source #
Return whether the terminal's echoing is on (True) or off (False).
Note that while this works on MinTTY, it is not as efficient as
getInputEchoState, as it involves a somewhat expensive substring
computation.
setInputEcho :: Bool -> IO () Source #
Set the terminal's echoing on (True) or off (False).
Unsafe STTY internals
A representation of the terminal input's current echoing state. Example
values include echoOff and echoOn.
Constructors
| MinTTY STTYSettings | The argument to (or value returned from) an invocation of the However, native Windows consoles like |
| DefaultTTY Bool | A simple on ( |
type STTYSettings = String Source #
Settings used to configure the stty command-line utility.
getInputEchoSTTY :: IO STTYSettings Source #
Return all of stty's current settings in a non-human-readable format.
This function is not very useful on its own. Its greater purpose is to
provide a compact STTYSettings that can be fed back into
setInputEchoState.
setInputEchoSTTY :: STTYSettings -> IO () Source #
Create an stty process and wait for it to complete. This is useful for
changing stty's settings, after which stty does not output anything.
setInputEchoSTTY =void.sttyRaw
sttyRaw :: String -> IO STTYSettings Source #
Create an stty process, wait for it to complete, and return its output.