Skip to content

Modern Tui TuiColor

Paul Squires edited this page Oct 19, 2026 · 6 revisions

Home › Terminal TUI Library › Colour and Style › TuiColor

TuiColor

Holds a colour: the terminal's default, one of 16 or 256, or 24-bit RGB.

Syntax

type TuiColor
    as uint8 kind      '' TuiColorKind
    as uint8 r, g, b
end type

Description

A tagged colour value, four bytes, deliberately not a UNION -- a ustring inside a union is rejected by the compiler and the layout was designed around that. You always write the colour you mean; the downgrade ladder reduces it at write time to whatever the terminal can actually show.

Example

#import "std/tui"
using tui

dim as TuiColor d = TuiDefaultColor( )       '' the terminal's own default
dim as TuiColor a = TuiAnsi( TUIC_BRIGHTBLUE )
dim as TuiColor x = TuiIndexed( 214 )        '' the 256-colour cube
dim as TuiColor t = TuiRgb( 235, 80, 80 )    '' 24-bit

print d.IsDefault( )              '' true
print t.r, t.g, t.b               '' 235 80 80
print a.Equals( TuiAnsi( TUIC_BRIGHTBLUE ) ) '' true

'' r, g and b MEAN SOMETHING ONLY FOR AN RGB COLOUR. For an ANSI16 or a
'' 256-colour value the palette entry is in Index( ), and reading .r gives
'' you the raw storage instead of a red component.
print a.Index( )                  '' 12
print x.Index( )                  '' 214

See also

TuiColor.IsDefault TuiColor.Index TuiAnsi TuiRgb TuiRed TuiYellow
TuiColor.Equals TuiDefaultColor TuiIndexed TuiBlack TuiGreen TuiBlue

Library: Terminal TUI Library
Category: Terminal TUI Library
Documented under: Colour and Style
Working examples: hello.tiko · form.tiko · dashboard.tiko


Home · Keyword Index

Clone this wiki locally