module RemiCharms
Overview
RemiCharms is an interface to libcurses for Crystal. It provides both a raw, low-level interface to libcurses via C bindings, and a more higher-level interface.
It is intended to be a bit easier to use than straight-up ncurses bindings. It is based on cl-charms, a similar interface to ncurses for Common Lisp.
Currently, the low-level interface (the NCurses
module) is pretty close to
ncurses itself. The high-level interface can be used directly alongside the
low-level interface for those instances where the high level interface is
missing functionality.
Defined in:
remicharms.crremicharms/errors.cr
remicharms/window.cr
Constant Summary
-
VERSION =
"0.1.0"
-
The current version of the library.
Class Method Summary
-
.beep : Nil
Audibly beep to alert the user.
-
.cursesVersion : String
Return a string representing the version of the underlying curses implementation.
-
.deinit : Nil
Finalizes ncurses
-
.disableRawInput : Nil
Disables raw input mode.
-
.echoing=(value : Bool) : Nil
Enables or disables the echoing of input.
-
.enableRawInput(interpretControlChars : Bool = false) : Nil
Enables raw input mode.
-
.flash : Nil
Visually flash the console.
-
.init : Window
Initializes ncurses and the terminal for drawing.
-
.inputMode
The current
InputMode
. -
.inputMode=(mode : InputMode) : Nil
Changes the input mode.
-
.standardWindow
The equivalent to
stdscr
in ncurses. -
.standardWindow?
The equivalent to
stdscr
in ncurses. -
.withCurses(&) : Nil
Flushes standard input, output, standard error, initializes ncurses via
RemiCharms.init
, then yields the standard window.
Instance Method Summary
-
#attributeOff(attrs : Attribute) : Nil
Turn off the attributes without affecting any others.
-
#attributeOff(*attrs : Attribute) : Nil
Turn off the attributes without affecting any others.
-
#attributeOn(attrs : Attribute) : Nil
Turn on the attributes without affecting any others.
-
#attributeOn(*attrs : Attribute) : Nil
Turn on the attributes without affecting any others.
-
#cursorVisibility=(vis : Visibility) : Nil
Sets the visibility of the cursor.
-
#enableColors : Bool
Attempts to enable color support.
-
#getColorPair(num : Int16) : Int16
Given a color pair represented by num, returns a new integer that can be used with an attribute function.
-
#initColor(color : Int16, r : Int16, g : Int16, b : Int16) : Bool
Attempts to change the definition of the color represented by color to the given RGB values.
-
#initColor(color : Int16, rgb : Tuple(Int16, Int16, Int16)) : Bool
Attempts to change the definition of the color represented by color to the given RGB values.
-
#initColorPair(pair : Int16, fg : Color, bg : Color) : Nil
Initializes a color pair that will be represented by pair.
-
#useEnterAsNewline=(value : Bool) : Nil
Controlls whether the underlying display device translates the return key into newline on input.
-
#withAttributes(attrs : Attribute, &) : Nil
Temporarily turns on the given attributes in the block, then turns them off before returning.
Class Method Detail
Return a string representing the version of the underlying curses implementation.
Finalizes ncurses
This function must be called before exiting. Consider using
RemiCharms.withCurses
instead to ensure proper initialization and cleanup.
Disables raw input mode. This undoes the action of
RemiCharms.enableRawInput
.
Enables raw input mode. This disables line buffering and will make characters available as soon as they're typed.
If interpretControlChars is true
, then control characters like Ctrl-C
will be interpreted as usual.
Initializes ncurses and the terminal for drawing. This then returns the
standard window (i.e. RemiCharms.standardWindow
).
This function must be called before using curses functions. Consider using
RemiCharms.withCurses
instead to ensure proper initialization and cleanup.
Changes the input mode. See RemiCharms.enableRawInput
and
RemiCharms.disableRawInput
for more information.
Flushes standard input, output, standard error, initializes ncurses via
RemiCharms.init
, then yields the standard window. This ensures
RemiCharms.deinit
is called before returning.
Instance Method Detail
Turn off the attributes without affecting any others.
Turn off the attributes without affecting any others.
Turn on the attributes without affecting any others.
Turn on the attributes without affecting any others.
Attempts to enable color support. On success, this returns true
,
otherwise it returns false
if the terminal does not support color.
Given a color pair represented by num, returns a new integer that can be used with an attribute function.
Attempts to change the definition of the color represented by color to the
given RGB values. On success, this returns true
, otherwise if the
terminal does not support the changing of colors, this returns false
.
When #initColor
is called, all occurences of color are immediately
changed.
Attempts to change the definition of the color represented by color to the
given RGB values. On success, this returns true
, otherwise if the
terminal does not support the changing of colors, this returns false
.
When #initColor
is called, all occurences of color are immediately
changed.
Initializes a color pair that will be represented by pair.
Controlls whether the underlying display device translates the return key into newline on input.
Temporarily turns on the given attributes in the block, then turns them off before returning.