cwidget  0.5.17
Classes | Typedefs | Functions | Variables
cwidget::config Namespace Reference

Routines that support parsing and interpreting user configuration. More...

Classes

struct  column_definition
 Defines how a single column is to be generated. More...
 
class  column_generator
 The class that defines how to parse and generate columns. More...
 
class  column_parameters
 Defines the string arguments passed into the layout process. More...
 
struct  column_type_defaults
 Defines the default settings for a particular column type. More...
 
class  empty_column_parameters
 An empty list of parameters. More...
 
struct  key
 Represents a keystroke as seen by curses. More...
 
class  keybindings
 Stores the keys bound to various functions. More...
 

Typedefs

typedef std::list< column_definitioncolumn_definition_list
 The type used to store lists of column definitions. More...
 
typedef int(* column_parser_func) (char id)
 The type of a function that parses a single-character column type flag and returns an integer identifying the column type.
 
typedef std::vector< keykeybinding
 The type used to store the keybindings of a function. More...
 

Functions

void init_colors ()
 Set up the colors as we expect them to be. More...
 
int get_color_pair (short fg, short bg)
 
int mix_color (short color, short fg, short bg)
 
column_definition_listparse_columns (wstring config, column_parser_func parser, column_type_defaults *defaults)
 
column_definition_listparse_columns (std::wstring config, column_parser_func parser, column_type_defaults *defaults)
 Parse the given string into a list of column definitions. More...
 
void init_key_tables ()
 
key parse_key (wstring keystr)
 
wstring keyname (const key &k)
 Convert a keystroke to its string definition. More...
 
wstring readable_keyname (const key &k)
 Convert a keystroke to a human-readable keyname. More...
 
key parse_key (std::wstring keystr)
 Parse a keystroke definition. More...
 

Variables

keybindings global_bindings
 The global keybindings object. More...
 
map< wstring, keykeynames
 
map< wstring, keys_keynames
 
map< key, wstring > rev_keynames
 
bool key_tables_initialized =false
 

Detailed Description

Routines that support parsing and interpreting user configuration.

For instance, routines to handle keybindings are placed in this namespace.

Typedef Documentation

◆ column_definition_list

The type used to store lists of column definitions.

◆ keybinding

typedef std::vector<key> cwidget::config::keybinding

The type used to store the keybindings of a function.

Function Documentation

◆ get_color_pair()

int cwidget::config::get_color_pair ( short  fg,
short  bg 
)
Returns
a color pair for the given foreground and background.

Referenced by mix_color().

◆ init_colors()

void cwidget::config::init_colors ( )

Set up the colors as we expect them to be.

Call this once when the program starts.

This will normally be invoked during the library's initialization and does not need to be called by clients of the library.

Referenced by cwidget::chstring::operator=().

◆ keyname()

std::wstring cwidget::config::keyname ( const key k)

Convert a keystroke to its string definition.

Parameters
kThe key that is to be converted to a string.
Returns
a string that, when passed to parse_key(), will return #k.
See also
readable_keyname

References cwidget::config::key::ch, cwidget::config::key::function_key, and keyname().

Referenced by cwidget::config::keybindings::keybindings(), keyname(), readable_keyname(), cwidget::config::keybindings::set(), and cwidget::widgets::menu::width_request().

◆ mix_color()

int cwidget::config::mix_color ( short  color,
short  fg,
short  bg 
)
Parameters
colorattributes containing the starting color value
fgthe new foreground (-1 to use color)
bgthe new background (-2 to use color; -1 to use the default background)
Returns
a color pair created by mixing the given foreground and background into color.

References get_color_pair().

Referenced by cwidget::style::apply_to(), and cwidget::style::get_attrs().

◆ parse_columns()

column_definition_list* cwidget::config::parse_columns ( std::wstring  config,
column_parser_func  parser,
column_type_defaults defaults 
)

Parse the given string into a list of column definitions.

Parameters
configThe format string describing the columns to create.
parserThe parsing function used to parse %-escapes.
defaultsAn array of the default options for each column; must have elements corresponding to each column id returned by the parser.
Returns
A freshly allocated column definition list. The caller is responsible for deleting it.

◆ parse_key()

key cwidget::config::parse_key ( std::wstring  keystr)

Parse a keystroke definition.

Parameters
keystrThe definition to parse.
Returns
the corresponding key, or ERR if the parse fails.

Referenced by cwidget::config::keybindings::key_matches().

◆ readable_keyname()

std::wstring cwidget::config::readable_keyname ( const key k)

Convert a keystroke to a human-readable keyname.

Returns
a human-readable string identifying the given keystroke.
See also
keyname

References keyname(), and readable_keyname().

Referenced by cwidget::config::keybindings::keybindings(), readable_keyname(), and cwidget::config::keybindings::set().

Variable Documentation

◆ global_bindings

keybindings cwidget::config::global_bindings