module Termbox

Overview

A thin wrapper around Termbox 2.

Included Modules

Extended Modules

Defined in:

termbox2.cr
termbox2/color.cr
termbox2/input.cr
termbox2/mode.cr

Class Method Summary

Instance Method Summary

Class Method Detail

def self.enabled? #

Returns whether Termbox is currently enabled.


[View source]

Instance Method Detail

def 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.


[View source]
def clear(fg : Attribute, bg : Attribute) #

Sets clear background and foreground attributes.


[View source]
def clear #

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


[View source]
def disable #

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


[View source]
def each(nap = nil, &) #

Initializes Termbox for the duration of the block. If nap is given and is not nil, does not wait for events but naps for that span between the non-blocking polls. Else, waits for events. Yields event to the block (can be nil).


[View source]
def enable #

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


[View source]
def get_input_mode #

[View source]
def get_output_mode #

[View source]
def height : Int32 #

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


[View source]
def hide_cursor #

Hides the cursor.


[View source]
def 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.


[View source]
def 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.


[View source]
def present #

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


[View source]
def print(x, y, fg : Attribute, bg : Attribute, object) #

Prints the string representation of object at the given position, with the given foreground and background attributes.


[View source]
def print(x, y, object) #

Prints the string representation of object at the given position with default attributes (see Color::Default).


[View source]
def 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.


[View source]
def set_input_mode(mode : InputMode) : InputMode #

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


[View source]
def 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.


[View source]
def width : Int32 #

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


[View source]