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

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

Classes

struct  column_type_defaults
 Defines the default settings for a particular column type. More...
class  column_parameters
 Defines the string arguments passed into the layout process. More...
class  empty_column_parameters
 An empty list of parameters. More...
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...
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_definition
column_definition_list
 The type used to store lists of column definitions.
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.

Functions

void init_colors ()
 Set up the colors as we expect them to be.
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.
void init_key_tables ()
key parse_key (wstring keystr)
wstring keyname (const key &k)
 Convert a keystroke to its string definition.
wstring readable_keyname (const key &k)
 Convert a keystroke to a human-readable keyname.
key parse_key (std::wstring keystr)
 Parse a keystroke definition.

Variables

keybindings global_bindings
 The global keybindings object.
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

The type used to store lists of column definitions.

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

The type used to store the keybindings of a function.


Function Documentation

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

Referenced by mix_color().

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.

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 keyname(), readable_keyname(), and cwidget::widgets::menu::width_request().

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

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


Variable Documentation

keybindings cwidget::config::global_bindings

The global keybindings object.

This object is the root of the keybindings hierarchy; normally all other keybindings objects should be descendents of it.

Referenced by cwidget::widgets::button::handle_key(), cwidget::toplevel::init(), cwidget::dialogs::ok(), cwidget::widgets::menu::paint(), cwidget::widgets::menu::width_request(), and cwidget::dialogs::yesno().