module

Termbox

Inherits Termbox::Event

A thin wrapper around Termbox 2.

Class methods

enabled?

Returns whether Termbox is currently enabled.

Source

Instance methods

change(x, y, fg : Attribute = Color::Default, bg : Attribute = Color::Default, fill = ' ')

Changes the attributes of the cell at x, y. fill specifies the character that is used when the referred cell has no content, otherwise, existing cell content is used.

Source
clear(fg : Attribute, bg : Attribute)

Sets clear background and foreground attributes.

Source
clear

Clears the internal back buffer using NormalColor::Default or the color/attributes set by clear(fg, bg).

Source
disable

Finalizes Termbox. Must be called after successful initialization. Does nothing if Termbox is off already.

Source
each(nap = nil, & : BaseEvent | Nil -> )

Initializes Termbox for the duration of the block.

  • If nap is nil, waits for an event indefinitely before calling the block.
  • If nap is not nil, checks if an event in a non-blocking manner; and yields that event (or nil if none) to the block. After the block, sleeps for nap.
Source
enable

Initializes Termbox. Must be called before any other function. If Termbox is already on, does nothing.

Source
get_input_mode

Same as set_input_mode(InputMode::Current).

Source
get_output_mode

Same as set_output_mode(InputMode::Current).

Source
height

Returns the width of the terminal window (in rows).

Source
hide_cursor

Hides the cursor.

Source
peek?(timeout : Time::Span) : BaseEvent | Nil

Waits for an event up to timeout and returns a BaseEvent, or nil if no event is available within the timeout.

Source
peek?(timeout = -1) : BaseEvent | Nil

Waits for an event up to timeout milliseconds and returns a BaseEvent, or nil if no event is available within the timeout.

Source
present

Synchronizes the internal back buffer with the terminal by writing to tty.

Source
set_cursor(x, y)

Moves the cursor to the specified position (in rows, cols). Upper-left corner is at (0, 0). The cursor is shown if it was hidden.

Source
set_input_mode(mode : InputMode) : InputMode

Sets the input mode (see InputMode). The default mode is InputMode::Escape.

Source
set_output_mode(mode : OutputMode) : OutputMode

Sets the termbox output mode (see OutputMode).

Note that not all terminals support all output modes, especially beyond OutputMode::Normal. There is also no very reliable way to determine color support dynamically. If portability is desired, users are recommended to use OutputMode::Normal or make output mode end-user configurable.

Source
width

Returns the width of the terminal window (in columns).

Source

Nested types