rtl433
UNKNOWN
RTL-433 utility
|
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_help_printf (_Printf_format_string_ char const *format,...) __attribute__((format(printf |
Print to terminal with markup turned into colors. More... | |
int int int | term_puts (void *ctx, const char *buf) |
Like 'term_printf()', but no var-arg format. More... | |
int | term_help_puts (void *ctx, const char *buf) |
Like 'term_help_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... | |
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 enum term_color term_color_t |
enum term_color |
void term_free | ( | void * | ctx | ) |
References _term_free(), and term_has_color().
Referenced by data_output_kv_free(), and term_help_printf().
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_help_puts(), and term_puts().
int term_get_columns | ( | void * | ctx | ) |
References console::hnd.
Referenced by print_kv_data().
int term_has_color | ( | void * | ctx | ) |
References _term_has_color().
Referenced by data_output_kv_create(), term_free(), and term_help_printf().
int int term_help_printf | ( | _Printf_format_string_ char const * | format, |
... | |||
) |
Print to terminal with markup turned into colors.
Like 'term_printf()', but with automatic coloring for markup.
Markup: = Heading = [option argument] "quoted" 'quoted'
Referenced by help_device(), help_gain(), help_meta(), help_output(), help_protocols(), help_read(), help_write(), and usage().
int term_help_puts | ( | void * | ctx, |
const char * | buf | ||
) |
Like 'term_help_printf()', but no var-arg format.
Simply takes a 0-terminated buffer.
References color_map, console::file, strlen(), term_get_color_map(), and term_set_fg().
Referenced by term_help_printf().
void* term_init | ( | FILE * | fp | ) |
References _term_init().
Referenced by data_output_kv_create(), and term_help_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 stderr' with no colors.
int 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().
void term_ring_bell | ( | void * | ctx | ) |
Referenced by print_kv_data().
void term_set_bg | ( | void * | ctx, |
term_color_t | color | ||
) |
References _term_set_color(), and TERM_COLOR_RESET.
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.
void term_set_fg | ( | void * | ctx, |
term_color_t | color | ||
) |
References _term_set_color(), and TERM_COLOR_RESET.
Referenced by print_kv_data(), term_help_puts(), and term_puts().