Puts the controlling terminal into raw mode and takes it out again.
enter/0 returns how raw mode was entered, and leave/1 takes that value back to
undo it:
{:ok, mode} = Drafter.Terminal.RawMode.enter()
Drafter.Terminal.RawMode.leave(mode)The termios NIF is used where it loads and stty otherwise. Off unix neither runs,
enter/0 returns {:ok, nil}, and the terminal mode is left alone.
In raw mode input arrives unbuffered and unechoed, control characters such as
Ctrl+C arrive as input instead of raising signals, and a line feed written to the
terminal no longer returns the cursor to the first column.
Summary
Types
@type mode() :: :nif | {:stty, binary()} | nil
How raw mode was entered: by the NIF, by stty with the saved settings, or not at all.