rtl433  UNKNOWN
RTL-433 utility
term_ctl.h File Reference

Terminal control utility functions. More...

Go to the source code of this file.

Typedefs

typedef enum term_color term_color_t
 

Enumerations

enum  term_color {
  TERM_COLOR_RESET = 0, TERM_COLOR_BLACK = 30, TERM_COLOR_RED = 31, TERM_COLOR_GREEN = 32,
  TERM_COLOR_YELLOW = 33, TERM_COLOR_BLUE = 34, TERM_COLOR_MAGENTA = 35, TERM_COLOR_CYAN = 36,
  TERM_COLOR_WHITE = 37, TERM_COLOR_BRIGHT_BLACK = 90, TERM_COLOR_BRIGHT_RED = 91, TERM_COLOR_BRIGHT_GREEN = 92,
  TERM_COLOR_BRIGHT_YELLOW = 93, TERM_COLOR_BRIGHT_BLUE = 94, TERM_COLOR_BRIGHT_MAGENTA = 95, TERM_COLOR_BRIGHT_CYAN = 96,
  TERM_COLOR_BRIGHT_WHITE = 97
}
 

Functions

void * term_init (FILE *fp)
 
void term_free (void *ctx)
 
int term_get_columns (void *ctx)
 
int term_has_color (void *ctx)
 
void term_ring_bell (void *ctx)
 
void term_set_fg (void *ctx, term_color_t color)
 
void term_set_bg (void *ctx, term_color_t color)
 
int term_printf (void *ctx, _Printf_format_string_ const char *format,...) __attribute__((format(printf
 Print to terminal with color-codes inline turned into above colors. More...
 
int int term_puts (void *ctx, const char *buf)
 Like 'term_printf()', but no var-arg format. More...
 
int term_set_color_map (int idx, term_color_t color)
 Change the default color map. More...
 
int term_get_color_map (int idx)
 Returns the current color-value ('enum term_color') for color-index. More...
 

Detailed Description

Terminal control utility functions.

Copyright (C) 2018 Christian Zuckschwerdt

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

Typedef Documentation

◆ term_color_t

typedef enum term_color term_color_t

Enumeration Type Documentation

◆ term_color

enum term_color
Enumerator
TERM_COLOR_RESET 
TERM_COLOR_BLACK 
TERM_COLOR_RED 
TERM_COLOR_GREEN 
TERM_COLOR_YELLOW 
TERM_COLOR_BLUE 
TERM_COLOR_MAGENTA 
TERM_COLOR_CYAN 
TERM_COLOR_WHITE 
TERM_COLOR_BRIGHT_BLACK 
TERM_COLOR_BRIGHT_RED 
TERM_COLOR_BRIGHT_GREEN 
TERM_COLOR_BRIGHT_YELLOW 
TERM_COLOR_BRIGHT_BLUE 
TERM_COLOR_BRIGHT_MAGENTA 
TERM_COLOR_BRIGHT_CYAN 
TERM_COLOR_BRIGHT_WHITE 

Function Documentation

◆ term_free()

void term_free ( void *  ctx)

References _term_free().

Referenced by data_output_kv_free().

◆ term_get_color_map()

int term_get_color_map ( int  idx)

Returns the current color-value ('enum term_color') for color-index.

'idx'. This index goes from ASCII '0' to 'X'. 'X' = '0' + the dimension of the internal 'color_map[]'.

References color_map.

Referenced by term_puts().

◆ term_get_columns()

int term_get_columns ( void *  ctx)

References console::hnd.

Referenced by print_kv_data().

◆ term_has_color()

int term_has_color ( void *  ctx)

References _term_has_color().

Referenced by data_output_kv_create().

◆ term_init()

void* term_init ( FILE *  fp)

References _term_init().

Referenced by data_output_kv_create().

◆ term_printf()

int term_printf ( void *  ctx,
_Printf_format_string_ const char *  format,
  ... 
)

Print to terminal with color-codes inline turned into above colors.

Takes a var-arg format.

E.g.: void *term = term_init(stdout); term_printf (term, "~4Hello ~2world~0.\n");

will print to stdout with 'Hello' mapped to colour 4 and 'world' mapped to colour 2. See 'term_set_color_map()' below.

And a 'term_printf (NULL, "~4Hello ~2world~0.\n");' will print "Hello world" to stder' with no colors.

◆ term_puts()

int int term_puts ( void *  ctx,
const char *  buf 
)

Like 'term_printf()', but no var-arg format.

Simply takes a 0-terminated buffer.

References console::file, strlen(), term_get_color_map(), and term_set_fg().

Referenced by term_printf().

◆ term_ring_bell()

void term_ring_bell ( void *  ctx)

Referenced by print_kv_data().

◆ term_set_bg()

void term_set_bg ( void *  ctx,
term_color_t  color 
)

◆ term_set_color_map()

int term_set_color_map ( int  idx,
term_color_t  color 
)

Change the default color map.

By default, the color-codes maps to these foreground colour: "~0": always restores terminal-colors; TERM_COLOR_RESET. "~1": print using TERM_COLOR_GREEN. "~2": print using TERM_COLOR_WHITE. "~3": print using TERM_COLOR_BLUE. "~4": print using TERM_COLOR_CYAN. "~5": print using TERM_COLOR_MAGENTA. "~6": print using TERM_COLOR_YELLOW. "~7": print using TERM_COLOR_BLACK. "~8": print using TERM_COLOR_RED.

References color_map.

◆ term_set_fg()

void term_set_fg ( void *  ctx,
term_color_t  color 
)

References _term_set_color(), and TERM_COLOR_RESET.

Referenced by print_kv_data(), and term_puts().