CNDP  22.08.0
vt100_out.h File Reference
#include <stdarg.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <termios.h>
#include <unistd.h>
#include <cne_atomic.h>
#include <cne_common.h>
#include <cne_system.h>
#include <cne_tty.h>

Go to the source code of this file.

Macros

#define COLOR_DEFAULT   0xc0dedead
 

Typedefs

typedef uint8_t vt_rgb_t
 

Enumerations

enum  vt_color_e
 
enum  vt_attr_e
 

Functions

 _s (vt_pos(int r, int c), tty_printf(vt100_pos, r, c)) _s(vt_top(void)
 
 tty_printf (vt100_home)) _s(vt_home(void)
 
 tty_printf (vt100_cursor_off)) _s(vt_con(void)
 
 tty_printf (vt100_cursor_on)) _s(vt_turn_on(void)
 
 tty_printf (vt100_save_cursor)) _s(vt_restore(void)
 
 tty_printf (vt100_restore_cursor)) _s(vt_eol(void)
 
 tty_printf (vt100_clr_eol)) _s(vt_cbl(void)
 
 tty_printf (vt100_clear_left)) _s(vt_cel(void)
 
 tty_printf (vt100_clear_line)) _s(vt_clw(void)
 
 tty_printf (vt100_clr_eos)) _s(vt_clb(void)
 
 tty_printf (vt100_clear_up)) _s(vt_cls(void)
 
 tty_printf (vt100_clear_screen)) _s(vt_reverse(void)
 
 tty_printf (ESC "[7m")) _s(vt_normal(void)
 
 tty_printf (ESC "[0m")) _s(vt_scroll(int r)
 
 tty_printf (vt100_scroll_up, r)) _s(vt_scroll_up(int r)
 
 tty_printf (vt100_scroll_down, r)) _s(vt_nlines(int r)
 
 tty_printf (vt100_move_down_nlines, r)) _s(vt_setw(int t)
 
 tty_printf (vt100_setw, t)) _s(vt_cpos(void)
 
 tty_printf (vt100_cursor_pos)) _s(vt_cup(int n)
 
 tty_printf (vt100_up_lines, n)) _s(vt_cnright(int n)
 
 tty_printf (vt100_right_columns, n)) _s(vt_cnleft(int n)
 
 tty_printf (vt100_left_columns, n)) _s(vt_newline(void)
 
 tty_printf (ESC "[20h")) _s(vt_cright(void)
 
 tty_printf (vt100_right_arr)) _s(vt_cleft(void)
 
 tty_printf (vt100_left_arr)) _s(vt_bol(void)
 
 tty_printf ("\r")) static __inline__ void vt_make_space(int n)
 
static __inline__ void vt_clr_line (int r)
 
static __inline__ void vt_eol_pos (int r, int c)
 
static __inline__ int vt_center_col (int16_t ncols, const char *msg)
 
static __inline__ void vt_erase (int16_t nrows)
 
static __inline__ void vt_repeat (int16_t r, int16_t c, const char *str, int cnt)
 
static __inline__ void vt_col_repeat (int16_t r, int16_t c, const char *str, int cnt)
 
static __inline__ void vt_fgcolor (vt_color_e color, vt_attr_e attr)
 
static __inline__ void vt_bgcolor (vt_color_e color, vt_attr_e attr)
 
static __inline__ void vt_fgbgcolor (vt_color_e fg, vt_color_e bg, vt_attr_e attr)
 
static __inline__ void vt_color (vt_color_e fg, vt_color_e bg, vt_attr_e attr)
 
static __inline__ void vt_rgb (uint8_t fg_bg, vt_rgb_t r, vt_rgb_t g, vt_rgb_t b)
 
static __inline__ int vt_fgcolor_str (char *str, int len, vt_color_e color, vt_attr_e attr)
 
static __inline__ int vt_bgcolor_str (char *str, int len, vt_color_e color, vt_attr_e attr)
 
static __inline__ int vt_attr_str (char *str, int len, vt_attr_e attr)
 
static __inline__ int vt_fgbgcolor_str (char *str, int len, vt_color_e fg, vt_color_e bg, vt_attr_e attr)
 
static __inline__ int vt_color_str (char *str, int len, vt_color_e fg, vt_color_e bg, vt_attr_e attr)
 
static __inline__ int vt_rgb_str (char *str, int len, uint8_t fg_bg, vt_rgb_t r, vt_rgb_t g, vt_rgb_t b)
 
CNDP_API int vt_color_parse (char *buff, int len)
 

Detailed Description

CNE cursor and color support for VT100 using ANSI color escape codes.

Definition in file vt100_out.h.

Macro Definition Documentation

◆ COLOR_DEFAULT

#define COLOR_DEFAULT   0xc0dedead

Magic number to detect default color

Definition at line 446 of file vt100_out.h.

Typedef Documentation

◆ vt_rgb_t

typedef uint8_t vt_rgb_t

A single byte to hold lport of a Red/Green/Blue color value

Definition at line 34 of file vt100_out.h.

Enumeration Type Documentation

◆ vt_color_e

enum vt_color_e

ANSI color codes zero based, need to add 30 or 40 for foreground or background color code

Definition at line 38 of file vt100_out.h.

◆ vt_attr_e

enum vt_attr_e

ANSI color codes zero based for attributes per color

Definition at line 1020 of file vt100_out.h.

Function Documentation

◆ _s()

_s ( vt_pos(int r, int c)  ,
tty_printf(vt100_pos, r, c)   
)

position cursor to row and column Move cursor to the top left of the screen

◆ tty_printf() [1/25]

tty_printf ( vt100_home  )

Move cursor to the Home position

Turn cursor off

◆ tty_printf() [2/25]

tty_printf ( vt100_cursor_off  )

Turn cursor on

Display cursor

◆ tty_printf() [3/25]

tty_printf ( vt100_cursor_on  )

Hide cursor

Save current cursor position

◆ tty_printf() [4/25]

tty_printf ( vt100_save_cursor  )

Restore the saved cursor position

◆ tty_printf() [5/25]

tty_printf ( vt100_restore_cursor  )

Clear from cursor to end of line

◆ tty_printf() [6/25]

tty_printf ( vt100_clr_eol  )

Clear from cursor to beginning of line

◆ tty_printf() [7/25]

tty_printf ( vt100_clear_left  )

Clear entire line

◆ tty_printf() [8/25]

tty_printf ( vt100_clear_line  )

Clear from cursor to end of screen

◆ tty_printf() [9/25]

tty_printf ( vt100_clr_eos  )

Clear from cursor to beginning of screen

◆ tty_printf() [10/25]

tty_printf ( vt100_clear_up  )

Clear the screen, more cursor to home

◆ tty_printf() [11/25]

tty_printf ( vt100_clear_screen  )

Start reverse video

◆ tty_printf() [12/25]

tty_printf ( ESC "[7m"  )

Stop attribute like reverse and underscore

◆ tty_printf() [13/25]

tty_printf ( ESC "[0m"  )

Scroll whole screen up r number of lines

◆ tty_printf() [14/25]

tty_printf ( vt100_scroll_up  ,
 
)

Scroll whole screen up r number of lines

Scroll whole screen down r number of lines

◆ tty_printf() [15/25]

tty_printf ( vt100_scroll_down  ,
 
)

Move down nlines plus move to column 1

◆ tty_printf() [16/25]

tty_printf ( vt100_move_down_nlines  ,
 
)

Set window size, from to end of screen

◆ tty_printf() [17/25]

tty_printf ( vt100_setw  ,
 
)

Cursor position report

◆ tty_printf() [18/25]

tty_printf ( vt100_cursor_pos  )

Cursor up N lines

◆ tty_printf() [19/25]

tty_printf ( vt100_up_lines  ,
 
)

Cursor move right n characters

◆ tty_printf() [20/25]

tty_printf ( vt100_right_columns  ,
 
)

Cursor move left n characters

◆ tty_printf() [21/25]

tty_printf ( vt100_left_columns  ,
 
)

New line

◆ tty_printf() [22/25]

tty_printf ( ESC "[20h"  )

Move one character right

◆ tty_printf() [23/25]

tty_printf ( vt100_right_arr  )

Move one character left

◆ tty_printf() [24/25]

tty_printf ( vt100_left_arr  )

Move cursor to beginning of line

◆ tty_printf() [25/25]

tty_printf ( "\r"  )

scroll or move the cursor down N number of rows

Parameters
nThe number or rows to move the cursor using newlines

Definition at line 1200 of file vt100_out.h.

◆ vt_clr_line()

static __inline__ void vt_clr_line ( int  r)
static

Position the cursor to a line and clear the entire line

Parameters
rThe row number

Definition at line 1223 of file vt100_out.h.

◆ vt_eol_pos()

static __inline__ void vt_eol_pos ( int  r,
int  c 
)
static

Position cursor to row/column and clear to end of line

Parameters
rThe row number
cThe column number

Definition at line 1238 of file vt100_out.h.

◆ vt_center_col()

static __inline__ int vt_center_col ( int16_t  ncols,
const char *  msg 
)
static

Output a message of the current line centered

Parameters
ncolsThe number of columns to use for centering the text on a line
msgThe message to center
Returns
The column to place the msg string

Definition at line 1255 of file vt100_out.h.

◆ vt_erase()

static __inline__ void vt_erase ( int16_t  nrows)
static

Erase the screen by scrolling it off the display, then put cursor at the bottom

Parameters
nrowsThe number of rows to scroll the screen

Definition at line 1271 of file vt100_out.h.

◆ vt_repeat()

static __inline__ void vt_repeat ( int16_t  r,
int16_t  c,
const char *  str,
int  cnt 
)
static

Output a string at a row/column for a number of times

Parameters
rThe row number
cThe column number
strThe string to output
cntThe number of times to output the string.

Definition at line 1292 of file vt100_out.h.

◆ vt_col_repeat()

static __inline__ void vt_col_repeat ( int16_t  r,
int16_t  c,
const char *  str,
int  cnt 
)
static

Output a column of strings at a given starting row for a given number of times

Parameters
rThe row number
cThe column number
strThe string to output on each row
cntThe number of rows to write the at the given column

Definition at line 1314 of file vt100_out.h.

◆ vt_fgcolor()

static __inline__ void vt_fgcolor ( vt_color_e  color,
vt_attr_e  attr 
)
static

Set the foreground color + attribute at the current cursor position

Parameters
colorThe color identifier for the foreground color
attrThe type of attribute to apply to the color or text string

Definition at line 1333 of file vt100_out.h.

◆ vt_bgcolor()

static __inline__ void vt_bgcolor ( vt_color_e  color,
vt_attr_e  attr 
)
static

Set the background color + attribute at the current cursor position

Parameters
colorThe color identifier for the background color
attrThe type of attribute to apply to the color or text string

Definition at line 1347 of file vt100_out.h.

◆ vt_fgbgcolor()

static __inline__ void vt_fgbgcolor ( vt_color_e  fg,
vt_color_e  bg,
vt_attr_e  attr 
)
static

Set the foreground/background color + attribute at the current cursor position

Parameters
fgThe color identifier for the foreground color
bgThe color identifier for the background color
attrThe type of attribute to apply to the color or text string

Definition at line 1363 of file vt100_out.h.

◆ vt_color()

static __inline__ void vt_color ( vt_color_e  fg,
vt_color_e  bg,
vt_attr_e  attr 
)
static

Main routine to set color for foreground and background and a attribute at the current position

Parameters
fgThe color identifier for the foreground color, can be VT_NO_CHANGE
bgThe color identifier for the background color, can be VT_NO_CHANGE
attrThe type of attribute to apply to the color or text string

Definition at line 1379 of file vt100_out.h.

◆ vt_rgb()

static __inline__ void vt_rgb ( uint8_t  fg_bg,
vt_rgb_t  r,
vt_rgb_t  g,
vt_rgb_t  b 
)
static

Setup for 256 RGB color methods. A routine to output RGB color codes if supported

Parameters
fg_bgThe combined fore/back ground color value
rThe red color for RGB
gThe green color for RGB
bThe blue color for RGB

Definition at line 1403 of file vt100_out.h.

◆ vt_fgcolor_str()

static __inline__ int vt_fgcolor_str ( char *  str,
int  len,
vt_color_e  color,
vt_attr_e  attr 
)
static

Set the foreground color + attribute at the current cursor position

Parameters
strThe string to place the color vt100 bytes
lenThe number of bytes in the str pointer
colorThe color type for the foreground
attrThe attribute of the string color
Returns
The number of bytes written into the string.

Definition at line 1423 of file vt100_out.h.

◆ vt_bgcolor_str()

static __inline__ int vt_bgcolor_str ( char *  str,
int  len,
vt_color_e  color,
vt_attr_e  attr 
)
static

Set the background color + attribute at the current cursor position

Parameters
strThe string to place the color vt100 bytes
lenThe number of bytes in the str pointer
colorThe color type for the background
attrThe attribute of the string color
Returns
The number of bytes written into the string.

Definition at line 1443 of file vt100_out.h.

◆ vt_attr_str()

static __inline__ int vt_attr_str ( char *  str,
int  len,
vt_attr_e  attr 
)
static

Set the attribute at the current cursor position

Parameters
strThe string to place the color vt100 bytes
lenThe number of bytes in the str pointer
attrThe attribute of the string color
Returns
The number of bytes written into the string.

Definition at line 1461 of file vt100_out.h.

◆ vt_fgbgcolor_str()

static __inline__ int vt_fgbgcolor_str ( char *  str,
int  len,
vt_color_e  fg,
vt_color_e  bg,
vt_attr_e  attr 
)
static

Set the foreground/background color + attribute at the current cursor position

Parameters
strThe string to place the color vt100 bytes
lenThe number of bytes in the str pointer
fgThe color type for the foreground
bgThe color type for the background
attrThe attribute of the string color
Returns
The number of bytes written into the string.

Definition at line 1483 of file vt100_out.h.

◆ vt_color_str()

static __inline__ int vt_color_str ( char *  str,
int  len,
vt_color_e  fg,
vt_color_e  bg,
vt_attr_e  attr 
)
static

Main routine to set color for foreground and background and attribute at the current position.

Parameters
strThe string to place the color vt100 bytes
lenThe number of bytes in the str pointer
fgThe color type for the foreground
bgThe color type for the background
attrThe attribute of the string color
Returns
The number of bytes written into the string.

Definition at line 1506 of file vt100_out.h.

◆ vt_rgb_str()

static __inline__ int vt_rgb_str ( char *  str,
int  len,
uint8_t  fg_bg,
vt_rgb_t  r,
vt_rgb_t  g,
vt_rgb_t  b 
)
static

Setup for 256 RGB color methods. A routine to output RGB color codes if supported

Parameters
strThe string to place the color vt100 bytes
lenThe number of bytes in the str pointer
fg_bgThe color type for the foreground/background
rThe red color for RGB
gThe green color for RGB
bThe blue color for RGB
Returns
The number of bytes written into the string.

Definition at line 1537 of file vt100_out.h.

◆ vt_color_parse()

CNDP_API int vt_color_parse ( char *  buff,
int  len 
)

Convert the buffer with color tuples into vt100 color codes.

Parameters
buffThe buffer to parse for color tuples.
lenThe max length of the buffer, must be large enough to hold the output string.
Returns
The number of bytes in buff with the vt100 color codes.