Skip to main content Link Search Menu Expand Document (external link)

Terminal overview

Added in v1.0.0


Table of contents


model

Key (interface)

Signature

export interface Key {
  /**
   * The name of the key being pressed.
   */
  readonly name: string
  /**
   * If set to `true`, then the user is also holding down the `Ctrl` key.
   */
  readonly ctrl: boolean
  /**
   * If set to `true`, then the user is also holding down the `Meta` key.
   */
  readonly meta: boolean
  /**
   * If set to `true`, then the user is also holding down the `Shift` key.
   */
  readonly shift: boolean
}

Added in v1.0.0

QuitException (class)

A QuitException represents an exception that occurs when a user attempts to quit out of a Terminal prompt for input (usually by entering ctrl+c).

Signature

export declare class QuitException

Added in v1.0.0

UserInput (interface)

Signature

export interface UserInput {
  /**
   * The character read from the user (if any).
   */
  readonly input: Option<string>
  /**
   * The key that the user pressed.
   */
  readonly key: Key
}

Added in v1.0.0

models

Terminal (interface)

A Terminal represents a command-line interface which can read input from a user and display messages to a user.

Signature

export interface Terminal {
  /**
   * The number of columns available on the platform's terminal interface.
   */
  readonly columns: Effect<number>
  /**
   * Reads a single input event from the default standard input.
   */
  readonly readInput: Effect<UserInput, QuitException>
  /**
   * Reads a single line from the default standard input.
   */
  readonly readLine: Effect<string, QuitException>
  /**
   * Displays text to the the default standard output.
   */
  readonly display: (text: string) => Effect<void, PlatformError>
}

Added in v1.0.0

tag

Terminal

Signature

export declare const Terminal: Tag<Terminal, Terminal>

Added in v1.0.0