TinyMUSH 3.3
TinyMUSH Server
Loading...
Searching...
No Matches
vt100.c File Reference

VT100/ANSI terminal control helpers and telnet negotiation support. More...

#include "config.h"
#include "constants.h"
#include "typedefs.h"
#include "macros.h"
#include "externs.h"
#include "prototypes.h"
#include <stdbool.h>
#include <ctype.h>
#include <math.h>
#include <stddef.h>
Include dependency graph for vt100.c:

Classes

struct  ColorCacheEntry
 

Macros

#define COLOR_PALETTE_CACHE_MAX   256
 
#define SGR_CODES_MAX   32
 

Functions

xyzColor rgbToXyz (rgbColor rgb)
 Convert RGB color to XYZ coordonates.
 
CIELABColor xyzToCIELAB (xyzColor xyz)
 Convert XYZ coordinates to CIELAB Color Space coordinates.
 
COLORMATCH getColorMatch (rgbColor rgb, uint8_t schemes)
 Find the closest color in a palette.
 
char * TrueColor2VT100 (rgbColor rgb, bool background)
 Format RGB color to VT100 color sequence.
 
char * X112VT100 (uint8_t color, bool background)
 Format X11 color to VT100 color sequence.
 
char * Ansi2VT100 (uint8_t color, bool background)
 Format ANSI color to VT100 color sequence.
 
rgbColor X112RGB (int color)
 Convert X11 color code to RGB value.
 
uint8_t RGB2X11 (rgbColor rgb)
 Convert RGB values to X11 color code.
 
uint8_t X112Ansi (int color)
 Convert X11 color code to RGB value.
 
uint8_t RGB2Ansi (rgbColor rgb)
 Convert RGB values to ANSI color code.
 
VT100ATTR decodeVT100 (const char **ansi)
 

Variables

COLORINFO colorPalette []
 

Detailed Description

VT100/ANSI terminal control helpers and telnet negotiation support.

Author
TinyMUSH development team (https://github.com/TinyMUSH)
Version
4.0

Function Documentation

◆ Ansi2VT100()

char * Ansi2VT100 ( uint8_t color,
bool background )

Format ANSI color to VT100 color sequence.

Parameters
colorANSI color code
backgroundTrue if background color
Returns
char* VT100 color sequence

◆ getColorMatch()

COLORMATCH getColorMatch ( rgbColor rgb,
uint8_t schemes )

Find the closest color in a palette.

Parameters
rgb
palette
Returns
COLORMATCH

◆ RGB2Ansi()

uint8_t RGB2Ansi ( rgbColor rgb)

Convert RGB values to ANSI color code.

Parameters
rgbRGB Color
Returns
uint8_t ANSI color code

◆ RGB2X11()

uint8_t RGB2X11 ( rgbColor rgb)

Convert RGB values to X11 color code.

Parameters
rgbRGB Color
Returns
uint8_t X11 color code

◆ rgbToXyz()

xyzColor rgbToXyz ( rgbColor rgb)

Convert RGB color to XYZ coordonates.

The CIE 1931 color spaces are the first defined quantitative links between distributions of wavelengths in the electromagnetic visible spectrum, and physiologically perceived colors in human color vision. The mathematical relationships that define these color spaces are essential tools for color management, important when dealing with color inks, illuminated displays, and recording devices such as digital cameras. The system was designed in 1931 by the "Commission Internationale de l'éclairage", known in English as the International Commission on Illumination.

Parameters
cRGB Color to conver
Returns
xyzColor XYZ Coordinates

◆ TrueColor2VT100()

char * TrueColor2VT100 ( rgbColor rgb,
bool background )

Format RGB color to VT100 color sequence.

Parameters
rgbRGB Color to format
backgroundTrue if background color
Returns
char* VT100 color sequence

◆ X112Ansi()

uint8_t X112Ansi ( int color)

Convert X11 color code to RGB value.

Parameters
colorANSI color code
Returns
rgbColor RGB Color

◆ X112RGB()

rgbColor X112RGB ( int color)

Convert X11 color code to RGB value.

Parameters
colorX11 color code
Returns
rgbColor RGB Color

◆ X112VT100()

char * X112VT100 ( uint8_t color,
bool background )

Format X11 color to VT100 color sequence.

Parameters
colorX11 color code
backgroundTrue if background color
Returns
char* VT100 color sequence

◆ xyzToCIELAB()

CIELABColor xyzToCIELAB ( xyzColor xyz)

Convert XYZ coordinates to CIELAB Color Space coordinates.

The CIELAB color space also referred to as L*a*b* is a color space defined by the International Commission on Illumination (abbreviated CIE) in 1976. (Referring to CIELAB as "Lab" without asterisks should be avoided to prevent confusion with Hunter Lab.) It expresses color as three values: L* for perceptual lightness, and a* and b* for the four unique colors of human vision: red, green, blue, and yellow. CIELAB was intended as a perceptually uniform space, where a given numerical change corresponds to similar perceived change in color. While the LAB space is not truly perceptually uniform, it nevertheless is useful in industry for detecting small differences in color.

Parameters
c
Returns
CIELABColorSpace