Terminal

This lets you interact with the user's terminal, if an interactive terminal is connected to this application.

Initialization

type Permission

The permission for performing commands specified in this module.

type alias Configuration =
{ permission : Permission
, colorDepth : Int
, columns : Int
, rows : Int
}

The configuration of the attached interactive terminal.

type alias Size = { columns : Int, rows : Int }

Size of a terminal. Handy to know for drawing a text-based UI.

initialize : Task (Maybe Configuration)

Initializes the Terminal subsystem.

Nothing is returned if this program isn't connected to an interactive terminal, which can happen in CI-setups or when used as part of a unix pipe.

Commands

setStdInRawMode : Permission -> Bool -> Task x {}

In it's default mode, stdin only sends data when the user hits the enter key.

If you switch over to raw mode, every keypress will be sent over the stream, and special combinations like Ctrl-C will no longer trigger the kill signal.

Enable this when you need full control over how input is handled.

setProcessTitle : Permission -> String -> Task x {}

Set the title of the running process. This will usually display in activity monitors or in the title bar of your terminal emulator.

Subscriptions

onResize : Permission -> (Size -> msg) -> Sub msg

A subscription that triggers every time the size of the terminal changes.