The screen in AppCUI is a 2D matrix of characters, with different widths (w) and heights (h).

It is important to note that each character is going to have the same size.
For each character we have the following attributes:
- Forenground color (the color of the character that we are printing)
- Background color (the color of the character background)
- Attributes: Bold, Italic, Underline, Boxed
The following collors are supported by AppCUI via Color enum from AppCUI::graphics module:
| Color | Enum variant | RGB | Color |
| Black | Color::Black | Red=0, Green=0, Blue=0 | |
| Dark Blue | Color::DarkBlue | Red=0, Green=0, Blue=128 | |
| Dark Green | Color::DarkGreen | Red=0, Green=128, Blue=0 | |
| Dark Red | Color::DarkRed | Red=128, Green=0, Blue=0 | |
| Teal | Color::Teal | Red=0, Green=128, Blue=128 | |
| Magenta | Color::Magenta | Red=128, Green=0, Blue=128 | |
| Olive | Color::Olive | Red=128, Green=128, Blue=0 | |
| Silver | Color::Silver | Red=192, Green=192, Blue=192 | |
| Gray | Color::Gray | Red=128, Green=128, Blue=128 | |
| Blue | Color::Blue | Red=0, Green=0, Blue=255 | |
| Green | Color::Green | Red=0, Green=255, Blue=0 | |
| Red | Color::Red | Red=255, Green=0, Blue=0 | |
| Aqua | Color::Aqua | Red=0, Green=255, Blue=255 | |
| Pink | Color::Pink | Red=255, Green=0, Blue=255 | |
| Yellow | Color::Yellow | Red=255, Green=255, Blue=0 | |
| White | Color::White | Red=255, Green=255, Blue=255 | |
Besides this list, a special enuma variant Color::Transparent can be used to draw without a color (or in simple terms to keep the existing color). For example, if the current character has a forenground color Red writing another character on the same position with color Transparent will keep the color Red for the character.
Additionally, if the TRUE_COLORS feature is enabled, the following variant is supported:
Color::RGB(r, g, b) - this is a custom color that is defined by the RGB values.
REMARKS:
- Not all terminals support this exact set of colors. Further more, some terminals might allow changing the RGB color for certain colors in the pallete.
- Enabling
TRUE_COLORS feature does not mean that the terminal supports 24-bit colors. It only means that the AppCUI framework will use 24-bit colors for the screen, but the terminal might still need to convert them to the terminal's color pallete.
- Enabling
TRUE_COLORS feature will make the size of the Color enum to be 4 bytes (instead of 1 byte without this feature). If memory is a concern and you don't need true colors, it is recommended to NOT enable this feature.
The list of attributes available in AppCUI are described by CharFlags enum from AppCUI::graphics module and include the following flags:
Bold - bolded character
Underline - underlined character
Italic - italic character
DoubleUnderline - a character that is undelined twice
CurlyUnderline - a character with a curly underline
DottedUnderline - a character with a dotted undeline
StrikeThrough - strike through character
These flags can be used with | operator if you want to combine them. For example: CharFlags::Bold | CharFlags::Underline means a character that is both bolded and underlined.
As previously explained, a character is the basic unit of AppCUI (we can say that it is similar to what a pixel is for a regular UX system).
The following method can be used to build a character:
#![allow(unused)]
fn main() {
pub fn new<T>(code: T, fore: Color, back: Color, flags: CharFlags) -> Character
}
where:
fore and back are characters colors (foreground and background)
code can be a character (like 'a' or 'b') or a value of type SpecialCharacter that can be used to quickly access special characters (like arrows). Any type of UTF-8 character is allowed.
flags are a set of flags (like Bold, Underline, ...) that can be used.
The list of all special characters that are supported by AppCUI (as described in the SpacialCharacter enum) are:
Variant (appcui::graphics::SpecialCharacter enum) | Unicode code | Visual Representation |
SpecialCharacter::BoxTopLeftCornerDoubleLine | 0x2554 | |
SpecialCharacter::BoxTopRightCornerDoubleLine | 0x2557 | |
SpecialCharacter::BoxBottomRightCornerDoubleLine | 0x255D | |
SpecialCharacter::BoxBottomLeftCornerDoubleLine | 0x255A | |
SpecialCharacter::BoxHorizontalDoubleLine | 0x2550 | |
SpecialCharacter::BoxVerticalDoubleLine | 0x2551 | |
SpecialCharacter::BoxCrossDoubleLine | 0x256C | |
SpecialCharacter::BoxTopLeftCornerSingleLine | 0x250C | |
SpecialCharacter::BoxTopRightCornerSingleLine | 0x2510 | |
SpecialCharacter::BoxBottomRightCornerSingleLine | 0x2518 | |
SpecialCharacter::BoxBottomLeftCornerSingleLine | 0x2514 | |
SpecialCharacter::BoxHorizontalSingleLine | 0x2500 | |
SpecialCharacter::BoxVerticalSingleLine | 0x2502 | |
SpecialCharacter::BoxCrossSingleLine | 0x253C | |
Variant (appcui::graphics::SpecialCharacter enum) | Unicode code | Visual Representation |
SpecialCharacter::ArrowUp | 0x2191 | |
SpecialCharacter::ArrowDown | 0x2193 | |
SpecialCharacter::ArrowLeft | 0x2190 | |
SpecialCharacter::ArrowRight | 0x2192 | |
SpecialCharacter::ArrowUpDown | 0x2195 | |
SpecialCharacter::ArrowLeftRight | 0x2194 | |
SpecialCharacter::TriangleUp | 0x25B2 | |
SpecialCharacter::TriangleDown | 0x25BC | |
SpecialCharacter::TriangleLeft | 0x25C4 | |
SpecialCharacter::TriangleRight | 0x25BA | |
Variant (appcui::graphics::SpecialCharacter enum) | Unicode code | Visual Representation |
SpecialCharacter::Block0 | 0x20 | |
SpecialCharacter::Block25 | 0x2591 | |
SpecialCharacter::Block50 | 0x2592 | |
SpecialCharacter::Block75 | 0x2593 | |
SpecialCharacter::Block100 | 0x2588 | |
SpecialCharacter::BlockUpperHalf | 0x2580 | |
SpecialCharacter::BlockLowerHalf | 0x2584 | |
SpecialCharacter::BlockLeftHalf | 0x258C | |
SpecialCharacter::BlockRightHalf | 0x2590 | |
SpecialCharacter::BlockCentered | 0x25A0 | |
SpecialCharacter::LineOnTop | 0x2594 | |
SpecialCharacter::LineOnBottom | 0x2581 | |
SpecialCharacter::LineOnLeft | 0x258F | |
SpecialCharacter::LineOnRight | 0x2595 | |
Variant (appcui::graphics::SpecialCharacter enum) | Unicode code | Visual Representation |
SpecialCharacter::CircleFilled | 0x25CF | |
SpecialCharacter::CircleEmpty | 0x25CB | |
SpecialCharacter::CheckMark | 0x221A | |
SpecialCharacter::MenuSign | 0x2261 | |
SpecialCharacter::FourPoints | 0x205E | |
SpecialCharacter::ThreePointsHorizontal | 0x2026 | |
Besides Character::new(...) the following constructors are also available:
-
#![allow(unused)]
fn main() {
pub fn with_char<T>(code: T) -> Character
}
this is the same as calling:
#![allow(unused)]
fn main() {
Character::new(code, Color::Transparent, Color::Transparent, CharFlags::None)
}
-
#![allow(unused)]
fn main() {
pub fn with_color(fore: Color, back: Color) -> Character
}
this is the same as calling:
#![allow(unused)]
fn main() {
Character::new(0, fore, fore, CharFlags::None)
}
Note: Using the character with code 0 means keeping the existing character but chainging the colors and attributes.
You can also use char! macro to quickly create a character. The macro supports tha following positional and named parameters:
| Position | Parameter | Type |
| #1 (first) | character | character or string (for special chars) |
| #2 (second) | foreground color | Color for foreground (special constants are accepted in this case - see below) |
| #3 (third) | background color | Color for background (special constants are accepted in this case - see below) |
and the named parameters:
| Name | Type | Optional | Description |
value or char or ch | String | Yes | The character or the name or representation of a special character. If string characters ' or " are being used, the content of the string is analyzed. This is useful for when the character is a special token such as : or = or ,. If not specified a special character with value 0 is being used that translates as an invariant character (meaning that it will not modify the existing character, but only its color and attributes.) |
code or unicode | Hex value | Yes | The unicode value of a character. Using this parameter will invalidate the previous parameter |
fore or foreground or forecolor or color | Color | Yes | The foreground color of the character. If not specified it is defaulted to Transparent. |
back or background or backcolor | Color | Yes | The background color of the character. If not specified it is defaulted to Transparent. |
attr or attributes | Flags | Yes | One of the following combination: Bold, Italic, Underline |
The following values can be used as color parameters for foreground and background parameters:
| Values | Color | Enum variant | Color |
black | Black | Color::Black | |
DarkBlue or db | Dark Blue | Color::DarkBlue | |
DarkGreen or dg | Dark Green | Color::DarkGreen | |
DarkRed or dr | Dark Red | Color::DarkRed | |
Teal | Teal | Color::Teal | |
Magenta | Magenta | Color::Magenta | |
Olive | Olive | Color::Olive | |
Silver or Gray75 | Silver | Color::Silver | |
Gray or gray50 | Gray | Color::Yellow | |
Blue or b | Blue | Color::Blue | |
Green or g | Green | Color::Green | |
Red or r | Red | Color::Red | |
Aqua or a | Aqua | Color::Aqua | |
Pink | Pink | Color::Pink | |
Yellow or y | Yellow | Color::Yellow | |
White or w | White | Color::White | |
For Transparent color you can use the following values: transparent, invisible or ?.
You can also specify special characters by either using their specific name from the enum SpecialChars or by using certaing adnotations as presented in the following table:
| Value | Variant (appcui::graphics::SpecialCharacter enum) | Visual Representation |
up or /|\ | SpecialCharacter::ArrowUp | |
down or \|/ | SpecialCharacter::ArrowDown | |
left or <- | SpecialCharacter::ArrowLeft | |
right or -> | SpecialCharacter::ArrowRight | |
updown or up-down | SpecialCharacter::ArrowUpDown | |
leftright or left-right or
<-> | SpecialCharacter::ArrowLeftRight | |
/\ | SpecialCharacter::TriangleUp | |
\/ | SpecialCharacter::TriangleDown | |
| <| | SpecialCharacter::TriangleLeft | |
| |> | SpecialCharacter::TriangleRight | |
... | SpecialCharacter::ThreePointsHorizontal | |
Sometimes, you might want to use a character with a specific color and attributes. For example, you might want to use a bolded character with a red color on a yellow background. This is in particular useful when building a theme where you just select the attributes and colors and then apply them to the characters.
AppCUI provides a specific structure called CharAttribute that allows you to define colors and attributes for a character.
To create a CharAttribute you can use the following methods:
#![allow(unused)]
fn main() {
impl CharAttribute {
pub fn new(fore: Color, back: Color, flags: CharFlags) -> CharAttribute {...}
pub fn with_color(fore: Color, back: Color) -> CharAttribute {...}
pub fn with_fore_color(fore: Color) -> CharAttribute {...}
pub fn with_back_color(back: Color) -> CharAttribute {...}
}
}
or
the macro charattr! that works similar to char! but it returns a CharAttribute object. The macro supports tha following positional and named parameters:
| Position | Parameter | Type |
| #1 (second) | foreground color | Color for foreground (special constants are accepted in this case - see below) |
| #2 (third) | background color | Color for background (special constants are accepted in this case - see below) |
and the named parameters:
| Name | Type | Optional | Description |
fore or foreground or forecolor or color | Color | Yes | The foreground color of the character. If not specified it is defaulted to Transparent. |
back or background or backcolor | Color | Yes | The background color of the character. If not specified it is defaulted to Transparent. |
attr or attributes | Flags | Yes | One of the following combination: Bold, Italic, Underline |
Example 1: Letter A with a Red color on an Yellow background:
#![allow(unused)]
fn main() {
Character::new('A',Color::Red,Color::Yellow,CharFlags::None)
}
or
char!("A,red,yellow")
or
char!("A,r,y")
Example 2: Letter A (bolded and underlined) with a White color on a Dark blue background:
#![allow(unused)]
fn main() {
Character::new('A',Color::White,Color::DarkBlue,CharFlags::Bold | CharFlags::Underline)
}
or
char!("A,fore=White,back=DarkBlue,attr=[Bold,Underline]")
or
char!("A,w,db,attr=Bold+Underline")
Example 3: An arrow towards left a Red color while keeping the current background:
#![allow(unused)]
fn main() {
Character::new(SpecialCharacter::ArrowLeft,Color::Red,Color::Transparent,CharFlags::None)
}
or
char!("ArrowLeft,fore=Red,back=Transparent")
or
char!("<-,red")
or
char!("<-,r")
Example 4: An arrow towards left a DarkGreen color, Bolded and Underlined while keeping the current background. We will use a CharAttribute for this example:
#![allow(unused)]
fn main() {
let attr = CharAttribute::new(Color::DarkGreen,Color::Transparent,CharFlags::Bold | CharFlags::Underline);
let c = Character::with_attr(SpecialCharacter::ArrowLeft,attr);
}
or
let attr = charattr!("DarkGreen,Transparent,attr:Bold+Underline");
let c = Character::with_attr(SpecialCharacter::ArrowLeft,attr));
or
let attr = charattr!("dg,?,attr:Bold+Underline");
let c = Character::with_attr(SpecialCharacter::ArrowLeft,attr);