The terminal the program runs in, used without the alternate screen.
open/1 returns a terminal for the calling process, which must also be the process
that uses and closes it:
{:ok, terminal} = Drafter.Prompt.Terminal.Local.open()
{event, terminal} = Drafter.Prompt.Terminal.next_event(terminal, :infinity)
Drafter.Prompt.Terminal.close(terminal)Options
:input-boolean(), defaulttrue. Withtruethe terminal is put into raw mode, bracketed paste is turned on and keys are read throughDrafter.Terminal.Stdin; closing the terminal undoes all three and leaves the terminal in line mode, where a line feed returns to the first column. Withfalsethe terminal mode is left alone andnext_event/2only waits.
Frames are written to /dev/tty, and to standard output where that cannot be
opened. While a terminal opened with input: true is open, Ctrl+C arrives as the
event {:key, :c, [:ctrl]}.
Events decoded but not consumed when the terminal closes are kept for the next terminal the same process opens.
Summary
Functions
Whether prompts can be drawn here: standard input is a terminal and TERM is not
dumb.
Open the terminal for the calling process.
Whether standard input is a terminal.
Types
@type t() :: %Drafter.Prompt.Terminal.Local{ buffer: Drafter.Terminal.InputBuffer.t() | nil, device: :file.io_device() | :stdio, events: [Drafter.Prompt.Terminal.event()], input: boolean(), mode: Drafter.Terminal.RawMode.mode(), region: Drafter.Prompt.Region.t() }
Functions
@spec available?() :: boolean()
Whether prompts can be drawn here: standard input is a terminal and TERM is not
dumb.
Open the terminal for the calling process.
{:error, reason} means the terminal could not be put into raw mode; nothing was
changed.
@spec stdin_terminal?() :: boolean()
Whether standard input is a terminal.