rtl433  UNKNOWN
RTL-433 utility
term_ctl.c File Reference

Terminal control utility functions. More...

Data Structures

struct  console
 

Typedefs

typedef struct console console_t
 

Functions

static WORD _term_get_win_color (BOOL fore, term_color_t color)
 
static void _term_set_color (console_t *console, BOOL fore, term_color_t color)
 
static void _term_free (console_t *console)
 
static BOOL _term_has_color (console_t *console)
 
static void * _term_init (FILE *fp)
 
int term_get_columns (void *ctx)
 
int term_has_color (void *ctx)
 
void * term_init (FILE *fp)
 
void term_free (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_set_color_map (int ascii_idx, term_color_t color)
 Change the default color map. More...
 
int term_get_color_map (int ascii_idx)
 Returns the current color-value ('enum term_color') for color-index. More...
 
int term_puts (void *ctx, char const *buf)
 Like 'term_printf()', but no var-arg format. More...
 
int term_printf (void *ctx, char const *format,...)
 
int term_help_puts (void *ctx, char const *buf)
 Like 'term_help_printf()', but no var-arg format. More...
 
int term_help_printf (char const *format,...)
 

Variables

static term_color_t color_map []
 

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

◆ console_t

typedef struct console console_t

Function Documentation

◆ _term_free()

static void _term_free ( console_t console)
static

References console::file, console::hnd, and console::info.

Referenced by term_free().

◆ _term_get_win_color()

◆ _term_has_color()

static BOOL _term_has_color ( console_t console)
static

References console::hnd, and console::redirected.

Referenced by term_has_color().

◆ _term_init()

static void* _term_init ( FILE *  fp)
static

◆ _term_set_color()

static void _term_set_color ( console_t console,
BOOL  fore,
term_color_t  color 
)
static

◆ term_free()

void term_free ( void *  ctx)

◆ 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_help_puts(), and 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)

◆ term_help_printf()

int term_help_printf ( char const *  format,
  ... 
)

◆ term_help_puts()

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().

◆ term_init()

void* term_init ( FILE *  fp)

References _term_init().

Referenced by data_output_kv_create(), and term_help_printf().

◆ term_printf()

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

References term_puts().

◆ term_puts()

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 
)

Variable Documentation

◆ color_map

term_color_t color_map[]
static
Initial value:
= {
}
Definition: term_ctl.h:35
Definition: term_ctl.h:34
Definition: term_ctl.h:30
Definition: term_ctl.h:32
Definition: term_ctl.h:28
Definition: term_ctl.h:33
Definition: term_ctl.h:29
Definition: term_ctl.h:36
Definition: term_ctl.h:31

Referenced by term_get_color_map(), term_help_puts(), and term_set_color_map().