module Termbox
Overview
A thin wrapper around Termbox 2.
Included Modules
Extended Modules
Defined in:
termbox2.crtermbox2/color.cr
termbox2/input.cr
termbox2/mode.cr
Class Method Summary
-
.enabled?
Returns whether Termbox is currently enabled.
Instance Method Summary
-
#change(x, y, fg : Attribute = Color::Default, bg : Attribute = Color::Default, fill = ' ')
Changes the attributes of the cell at x, y.
-
#clear(fg : Attribute, bg : Attribute)
Sets clear background and foreground attributes.
-
#clear
Clears the internal back buffer using
NormalColor::Default
or the color/attributes set by#clear(fg, bg)
. -
#disable
Finalizes Termbox.
-
#each(nap = nil, &)
Initializes Termbox for the duration of the block.
-
#enable
Initializes Termbox.
-
#get_input_mode
Same as
#set_input_mode(InputMode::Current)
. -
#get_output_mode
Same as
#set_output_mode(InputMode::Current)
. -
#height : Int32
Returns the width of the terminal window (in rows).
-
#hide_cursor
Hides the cursor.
-
#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. -
#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. -
#present
Synchronizes the internal back buffer with the terminal by writing to tty.
-
#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.
-
#print(x, y, object)
Prints the string representation of object at the given position with default attributes (see
Color::Default
). -
#set_cursor(x, y)
Moves the cursor to the specified position (in rows, cols).
-
#set_input_mode(mode : InputMode) : InputMode
Sets the input mode (see
InputMode
). -
#set_output_mode(mode : OutputMode) : OutputMode
Sets the termbox output mode (see
OutputMode
). -
#width : Int32
Returns the width of the terminal window (in columns).
Class Method Detail
Instance Method Detail
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.
Sets clear background and foreground attributes.
Clears the internal back buffer using NormalColor::Default
or the color/attributes set by #clear(fg, bg)
.
Finalizes Termbox. Must be called after successful initialization. Does nothing if Termbox is off already.
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).
Initializes Termbox. Must be called before any other function. If Termbox is already on, does nothing.
Waits for an event up to timeout and returns a BaseEvent
,
or nil if no event is available within the timeout.
Waits for an event up to timeout milliseconds and
returns a BaseEvent
, or nil if no event is available
within the timeout.
Prints the string representation of object at the given position, with the given foreground and background attributes.
Prints the string representation of object at the given
position with default attributes (see Color::Default
).
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.
Sets the input mode (see InputMode
). The default mode
is InputMode::Escape
.
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.