LF OS
Hobby operating system for amd64 with high ambitions
Loading...
Searching...
No Matches
pen.c File Reference

(475a4fe LLVM update: finally on 18.x!)

#include "vterm_internal.h"
#include <stdio.h>
+ Include dependency graph for pen.c:

Go to the source code of this file.

Data Structures

struct  VTermRGB
 

Functions

static void lookup_default_colour_ansi (long idx, VTermColor *col)
 
static bool lookup_colour_ansi (const VTermState *state, long index, VTermColor *col)
 
static bool lookup_colour_palette (const VTermState *state, long index, VTermColor *col)
 
static int lookup_colour (const VTermState *state, int palette, const long args[], int argcount, VTermColor *col)
 
static void setpenattr (VTermState *state, VTermAttr attr, VTermValueType type, VTermValue *val)
 
static void setpenattr_bool (VTermState *state, VTermAttr attr, int boolean)
 
static void setpenattr_int (VTermState *state, VTermAttr attr, int number)
 
static void setpenattr_col (VTermState *state, VTermAttr attr, VTermColor color)
 
static void set_pen_col_ansi (VTermState *state, VTermAttr attr, long col)
 
INTERNAL void vterm_state_newpen (VTermState *state)
 
INTERNAL void vterm_state_resetpen (VTermState *state)
 
INTERNAL void vterm_state_savepen (VTermState *state, int save)
 
int vterm_color_is_equal (const VTermColor *a, const VTermColor *b)
 
void vterm_state_get_default_colors (const VTermState *state, VTermColor *default_fg, VTermColor *default_bg)
 
void vterm_state_get_palette_color (const VTermState *state, int index, VTermColor *col)
 
void vterm_state_set_default_colors (VTermState *state, const VTermColor *default_fg, const VTermColor *default_bg)
 
void vterm_state_set_palette_color (VTermState *state, int index, const VTermColor *col)
 
void vterm_state_convert_color_to_rgb (const VTermState *state, VTermColor *col)
 
void vterm_state_set_bold_highbright (VTermState *state, int bold_is_highbright)
 
INTERNAL void vterm_state_setpen (VTermState *state, const long args[], int argcount)
 
static int vterm_state_getpen_color (const VTermColor *col, int argi, long args[], int fg)
 
INTERNAL int vterm_state_getpen (VTermState *state, long args[], int argcount)
 
int vterm_state_get_penattr (const VTermState *state, VTermAttr attr, VTermValue *val)
 

Variables

static const VTermRGB ansi_colors []
 
static int ramp6 []
 
static int ramp24 []
 

Data Structure Documentation

◆ VTermRGB

struct VTermRGB

Structure used to store RGB triples without the additional metadata stored in VTermColor.

Definition at line 9 of file pen.c.

+ Collaboration diagram for VTermRGB:
Data Fields
uint8_t blue
uint8_t green
uint8_t red

Function Documentation

◆ lookup_colour()

static int lookup_colour ( const VTermState state,
int  palette,
const long  args[],
int  argcount,
VTermColor col 
)
static

Definition at line 91 of file pen.c.

References CSI_ARG, CSI_ARG_IS_MISSING, DEBUG_LOG, vterm_color_indexed(), and vterm_color_rgb().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ lookup_colour_ansi()

static bool lookup_colour_ansi ( const VTermState state,
long  index,
VTermColor col 
)
static

Definition at line 53 of file pen.c.

References VTermState::colors, and state.

+ Here is the caller graph for this function:

◆ lookup_colour_palette()

static bool lookup_colour_palette ( const VTermState state,
long  index,
VTermColor col 
)
static

Definition at line 63 of file pen.c.

References lookup_colour_ansi(), ramp24, ramp6, state, and vterm_color_rgb().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ lookup_default_colour_ansi()

static void lookup_default_colour_ansi ( long  idx,
VTermColor col 
)
static

Definition at line 44 of file pen.c.

References ansi_colors, and vterm_color_rgb().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ set_pen_col_ansi()

static void set_pen_col_ansi ( VTermState state,
VTermAttr  attr,
long  col 
)
static

Definition at line 150 of file pen.c.

References VTermPen::bg, VTermPen::fg, VTermState::pen, setpenattr_col(), state, VTERM_ATTR_BACKGROUND, and vterm_color_indexed().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setpenattr()

static void setpenattr ( VTermState state,
VTermAttr  attr,
VTermValueType  type,
VTermValue val 
)
static

Definition at line 119 of file pen.c.

References VTermState::callbacks, VTermState::cbdata, DEBUG_LOG, VTermStateCallbacks::setpenattr, state, type, and vterm_get_attr_type().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setpenattr_bool()

static void setpenattr_bool ( VTermState state,
VTermAttr  attr,
int  boolean 
)
static

Definition at line 132 of file pen.c.

References VTermValue::boolean, setpenattr(), state, and VTERM_VALUETYPE_BOOL.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setpenattr_col()

static void setpenattr_col ( VTermState state,
VTermAttr  attr,
VTermColor  color 
)
static

Definition at line 144 of file pen.c.

References VTermValue::color, setpenattr(), state, and VTERM_VALUETYPE_COLOR.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setpenattr_int()

static void setpenattr_int ( VTermState state,
VTermAttr  attr,
int  number 
)
static

Definition at line 138 of file pen.c.

References VTermValue::number, setpenattr(), state, and VTERM_VALUETYPE_INT.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vterm_color_is_equal()

int vterm_color_is_equal ( const VTermColor a,
const VTermColor b 
)

Compares two colours. Returns true if the colors are equal, false otherwise.

Definition at line 211 of file pen.c.

References VTermColor::indexed, VTermColor::rgb, VTermColor::type, VTERM_COLOR_IS_INDEXED, and VTERM_COLOR_IS_RGB.

+ Here is the caller graph for this function:

◆ vterm_state_convert_color_to_rgb()

void vterm_state_convert_color_to_rgb ( const VTermState state,
VTermColor col 
)

Makes sure that the given color col is indeed an RGB colour. After this function returns, VTERM_COLOR_IS_RGB(col) will return true, while all other flags stored in col->type will have been reset.

Parameters
stateis the VTermState instance from which the colour palette should be extracted.
colis a pointer at the VTermColor instance that should be converted to an RGB colour.

Definition at line 263 of file pen.c.

References VTermColor::indexed, lookup_colour_palette(), state, VTermColor::type, VTERM_COLOR_IS_INDEXED, and VTERM_COLOR_TYPE_MASK.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vterm_state_get_default_colors()

void vterm_state_get_default_colors ( const VTermState state,
VTermColor default_fg,
VTermColor default_bg 
)

Definition at line 231 of file pen.c.

References VTermState::default_bg, VTermState::default_fg, and state.

+ Here is the caller graph for this function:

◆ vterm_state_get_palette_color()

void vterm_state_get_palette_color ( const VTermState state,
int  index,
VTermColor col 
)

Definition at line 237 of file pen.c.

References lookup_colour_palette(), and state.

+ Here is the call graph for this function:

◆ vterm_state_get_penattr()

◆ vterm_state_getpen()

INTERNAL int vterm_state_getpen ( VTermState state,
long  args[],
int  argcount 
)

Definition at line 504 of file pen.c.

References VTermPen::baseline, VTermPen::bg, VTermPen::blink, VTermPen::bold, VTermPen::conceal, CSI_ARG_FLAG_MORE, VTermPen::fg, VTermPen::font, VTermPen::italic, VTermState::pen, VTermPen::reverse, VTermPen::small, state, VTermPen::strike, VTermPen::underline, VTERM_BASELINE_LOWER, VTERM_BASELINE_RAISE, vterm_state_getpen_color(), VTERM_UNDERLINE_CURLY, VTERM_UNDERLINE_DOUBLE, and VTERM_UNDERLINE_SINGLE.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vterm_state_getpen_color()

static int vterm_state_getpen_color ( const VTermColor col,
int  argi,
long  args[],
int  fg 
)
static

Definition at line 471 of file pen.c.

References CSI_ARG_FLAG_MORE, VTermColor::indexed, VTermColor::rgb, VTERM_COLOR_IS_DEFAULT_BG, VTERM_COLOR_IS_DEFAULT_FG, VTERM_COLOR_IS_INDEXED, and VTERM_COLOR_IS_RGB.

+ Here is the caller graph for this function:

◆ vterm_state_newpen()

INTERNAL void vterm_state_newpen ( VTermState state)

Definition at line 159 of file pen.c.

References VTermState::colors, VTermState::default_bg, VTermState::default_fg, lookup_default_colour_ansi(), state, vterm_color_rgb(), and vterm_state_set_default_colors().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vterm_state_resetpen()

INTERNAL void vterm_state_resetpen ( VTermState state)

Definition at line 170 of file pen.c.

References VTermPen::baseline, VTermPen::bg, VTermPen::blink, VTermPen::bold, VTermPen::conceal, VTermState::default_bg, VTermState::default_fg, VTermPen::fg, VTermPen::font, VTermPen::italic, VTermState::pen, VTermPen::reverse, setpenattr_bool(), setpenattr_col(), setpenattr_int(), VTermPen::small, state, VTermPen::strike, VTermPen::underline, VTERM_ATTR_BACKGROUND, VTERM_ATTR_BASELINE, VTERM_ATTR_BLINK, VTERM_ATTR_BOLD, VTERM_ATTR_CONCEAL, VTERM_ATTR_FONT, VTERM_ATTR_FOREGROUND, VTERM_ATTR_ITALIC, VTERM_ATTR_REVERSE, VTERM_ATTR_SMALL, VTERM_ATTR_STRIKE, and VTERM_ATTR_UNDERLINE.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vterm_state_savepen()

INTERNAL void vterm_state_savepen ( VTermState state,
int  save 
)

Definition at line 187 of file pen.c.

References VTermPen::baseline, VTermPen::bg, VTermPen::blink, VTermPen::bold, VTermPen::conceal, VTermPen::fg, VTermPen::font, VTermPen::italic, VTermState::pen, VTermPen::reverse, VTermState::saved, setpenattr_bool(), setpenattr_col(), setpenattr_int(), VTermPen::small, state, VTermPen::strike, VTermPen::underline, VTERM_ATTR_BACKGROUND, VTERM_ATTR_BASELINE, VTERM_ATTR_BLINK, VTERM_ATTR_BOLD, VTERM_ATTR_CONCEAL, VTERM_ATTR_FONT, VTERM_ATTR_FOREGROUND, VTERM_ATTR_ITALIC, VTERM_ATTR_REVERSE, VTERM_ATTR_SMALL, VTERM_ATTR_STRIKE, and VTERM_ATTR_UNDERLINE.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vterm_state_set_bold_highbright()

void vterm_state_set_bold_highbright ( VTermState state,
int  bold_is_highbright 
)

Definition at line 271 of file pen.c.

References VTermState::bold_is_highbright, and state.

+ Here is the caller graph for this function:

◆ vterm_state_set_default_colors()

void vterm_state_set_default_colors ( VTermState state,
const VTermColor default_fg,
const VTermColor default_bg 
)

Definition at line 242 of file pen.c.

References VTermState::default_bg, VTermState::default_fg, state, VTermColor::type, VTERM_COLOR_DEFAULT_BG, and VTERM_COLOR_DEFAULT_FG.

+ Here is the caller graph for this function:

◆ vterm_state_set_palette_color()

void vterm_state_set_palette_color ( VTermState state,
int  index,
const VTermColor col 
)

Definition at line 257 of file pen.c.

References VTermState::colors, and state.

◆ vterm_state_setpen()

Variable Documentation

◆ ansi_colors

const VTermRGB ansi_colors[]
static
Initial value:
= {
{ 0, 0, 0 },
{ 224, 0, 0 },
{ 0, 224, 0 },
{ 224, 224, 0 },
{ 0, 0, 224 },
{ 224, 0, 224 },
{ 0, 224, 224 },
{ 224, 224, 224 },
{ 128, 128, 128 },
{ 255, 64, 64 },
{ 64, 255, 64 },
{ 255, 255, 64 },
{ 64, 64, 255 },
{ 255, 64, 255 },
{ 64, 255, 255 },
{ 255, 255, 255 },
}

Definition at line 13 of file pen.c.

◆ ramp24

int ramp24[]
static
Initial value:
= {
0x00, 0x0B, 0x16, 0x21, 0x2C, 0x37, 0x42, 0x4D, 0x58, 0x63, 0x6E, 0x79,
0x85, 0x90, 0x9B, 0xA6, 0xB1, 0xBC, 0xC7, 0xD2, 0xDD, 0xE8, 0xF3, 0xFF,
}

Definition at line 39 of file pen.c.

◆ ramp6

int ramp6[]
static
Initial value:
= {
0x00, 0x33, 0x66, 0x99, 0xCC, 0xFF,
}

Definition at line 35 of file pen.c.