Next: Adding characters, Previous: Errors and Exceptions, Up: The basic curses library [Contents][Index]
Many curses functions take rendered, complex characters: characters with associated color and attribute information.
For those who are familiar with the C API for ncurses, you know that
a rendered character is either a chtype
, which is a 32-bit
integer containing an 8-bit char
and 24-bits of color and
rendering information, or is a cchar_t
, which is one or more
wchar_t
characters plus associated color and rendering
information. Guile-Ncurses abstracts away the difference between
these two types and presents a consistent API for both. The
Guile-Ncurses complex rendered character will get converted
automatically to chtype
or cchar_t
when necessary.
There is a family of functions to convert unrendered, simple characters or strings to rendered complex characters and strings.
These procedures take x, which can be either a simple character, a complex character, a simple string, or a complex string, and returns a rendered character or string with the attribute blink, bold, dim, horizontal, invisible, left, low, normal, protect, inverse, right, top, underline, or vertical, respectively. If the input x was a rendered character or a rendered string, the old attributes are replaced. If x was a rendered character or string with an associated color pair, the returned character or string will have the same associated color pair.
Note that whether these attributes can actually be visualized depends on the capabilities of the terminal itself. Most terminals can handle bold, dim, inverse, and sometimes blink, underline and invisible. The rest should probably not be used.
These procedures take x, which can be either a simple character, a complex character, a simple string, or a complex string. If x is a simple character or simple string, it sets its rendering to blink, bold, dim, horizontal, invisible, left, low, normal, protect, inverse, right, top, underline, or vertical, respectively. If the input x was a rendered character or a rendered string, these attributes are added to the rendered character.
Most terminals can’t actually visualize multiple attributes on a single character: some terminals can handle the combination of blink and bold, bold and underline, or inverse and bold.
These procedures take x, which can be either a simple character, a complex character, a simple string, or a complex string. If x is a simple character or simple string, it sets its rendering to normal. If the input x was a rendered character or a rendered string and had the given attribute, these attributes is removed from the resulting rendered character.
These procedure takes x, which can be either a simple character, a complex character, a simple string, or a complex string. It returns a rendered character or string with an associated color pair n.
This procedure should only be used if start-color
has been
called.
There are a set of primitives to operate directly on complex characters.
Returns #t
if c is a complex character.
These three procedures return the attributes, color pair number, and list of constituent characters of a complex character, respectively.
These procedures directly set the attributes, color-pair number, and the list of characters of a complex character, respectively.
Complex characters can have a base character and a set of accent
characters that overwrite the base character. That is why
set-xchar-chars!
takes a list of characters, instead of a
single character. But, for these complex characters to be rendered
correctly on the terminal, you need both a terminal that can do
overstrike characters and you need to have compiled with the wide
Ncurses library. If either of these conditions are not true, only the
first character in the list of characters will appear on the screen.
There are also a couple of low-level functions to do conversion between C characters and Guile characters.
Given an 8-bit integer c that represents a C character in the current locale, this returns the associated scheme character.
This returns an 8-bit integer that is the C representation of
character c
in the current locale. If the character cannot be
represented in the current locale, it will return the integer 63,
which is the ASCII code for the question mark.
Given an integer c that represents a wchar_t representation of a C wide character, this returns the associated scheme character.
This returns an integer that is the C wchar_t
representation of
character c
. If the character cannot be represented in the
current locale, it will return the integer #xFFFD, which is the
Unicode codepoint for the replacement character.
Next: Adding characters, Previous: Errors and Exceptions, Up: The basic curses library [Contents][Index]