The one process that writes a session's terminal, for Drafter.Compositor.
{:ok, writer} = Drafter.Render.Writer.start_link(:tty)
Drafter.Render.Writer.write(writer, text_rows)
Drafter.Render.Writer.write_image(writer, image_bytes)Every write is one call to the sink, in the order the calls were made, so no sequence
is ever cut by another, and neither call blocks the caller. write/2 is for text and
control sequences and is never dropped; behind?/1 tells whether any of it is still
unwritten, for a caller that would rather merge its next frames into one than queue
them. write_image/2 is for a frame's image bytes: while the terminal is slow to
accept one, a newer image that has arrived by the time an older one's turn comes
replaces it, so the terminal sees the latest picture and no backlog.
The sink is a function of iodata, or {:tty, fallback} to write /dev/tty — which the
writer opens itself, since a raw file is usable only by the process that opened it —
using the fallback function when /dev/tty cannot be opened.
Summary
Functions
Whether text handed over by write/2 is still waiting to be written.
Returns a specification to start this module under a supervisor.
Return once everything handed over so far has been written.
Start a writer whose sink is a function of iodata, or {:tty, fallback}.
Write bytes after everything already handed over. Asynchronous, never dropped.
Write a frame's image bytes after everything already handed over, unless a newer image has arrived by then. Asynchronous.
Functions
@spec behind?(GenServer.server()) :: boolean()
Whether text handed over by write/2 is still waiting to be written.
Returns a specification to start this module under a supervisor.
See Supervisor.
@spec flush(GenServer.server()) :: :ok
Return once everything handed over so far has been written.
@spec start_link((iodata() -> term()) | {:tty, (iodata() -> term())}) :: GenServer.on_start()
Start a writer whose sink is a function of iodata, or {:tty, fallback}.
@spec write(GenServer.server(), iodata()) :: :ok
Write bytes after everything already handed over. Asynchronous, never dropped.
@spec write_image(GenServer.server(), iodata()) :: :ok
Write a frame's image bytes after everything already handed over, unless a newer image has arrived by then. Asynchronous.