cwidget
0.5.17
|
The namespace containing everything defined by cwidget. More...
Namespaces | |
config | |
Routines that support parsing and interpreting user configuration. | |
dialogs | |
Routines to construct simple dialog boxes. | |
threads | |
C++ wrappers for the POSIX threading primitives. | |
toplevel | |
The namespace containing functions to manage the global state of cwidget. | |
util | |
Miscellaneous utility functions that are not directly related to the core functionality of cwidget. | |
Classes | |
class | chstring |
A string class which stores attributes along with characters. More... | |
struct | column |
struct | column_disposition |
class | cwindow |
class | fragment |
A fragment represents a logical unit of text. More... | |
class | fragment_cache |
A fragment that caches its contents; a cached result is used if the same width is passed to the layout routine twice in a row. More... | |
struct | fragment_column_entry |
Stores information on a single column of fragments. More... | |
class | fragment_contents |
This class represents the formatted contents of a fragment. More... | |
class | style |
A "style" is a setting to be applied to a display element (widget, text, etc). More... | |
class | wchstring |
struct | wchtype |
A structure that amalgamates a wchar_t together with attributes. More... | |
Typedefs | |
typedef std::list< column > | column_list |
typedef std::list< column > | layout |
typedef wchstring | fragment_line |
The type used to represent a line of a fragment; it might be worthwhile to change this to a rope<chtype> if this class is used to format larger pieces of text. | |
Functions | |
wstring | columnify (const layout &format, int width) |
void | init_curses () |
void | resize () |
chtype | _getbkgd (WINDOW *win) |
int | _box (WINDOW *win, chtype verch, chtype horch) |
void | _getyx (WINDOW *win, int &y, int &x) |
void | _getparyx (WINDOW *win, int &y, int &x) |
void | _getbegyx (WINDOW *win, int &y, int &x) |
void | _getmaxyx (WINDOW *win, int &y, int &x) |
int | _getmaxy (WINDOW *win) |
int | _getmaxx (WINDOW *win) |
int | _touchwin (WINDOW *win) |
int | _untouchwin (WINDOW *win) |
fragment * | text_fragment (const wstring &s) |
fragment * | text_fragment (const wstring &s, const style &st) |
fragment * | text_fragment (const string &s, const char *encoding) |
fragment * | text_fragment (const string &s, const style &st, const char *encoding) |
fragment * | newline_fragment () |
Create a fragment which simply produces a newline wherever it occurs. More... | |
fragment * | style_fragment (fragment *f, const style &st) |
Create a fragment which alters the style of its contents. More... | |
fragment * | sequence_fragment (const vector< fragment *> &contents) |
fragment * | sequence_fragment (fragment *f,...) |
Create a fragment from a sequence of other fragments. More... | |
fragment * | join_fragments (const vector< fragment *> &fragments, const wstring &between) |
fragment * | flowbox (fragment *contents) |
Create a flowbox. More... | |
fragment * | fillbox (fragment *contents) |
Create a fillbox. More... | |
fragment * | hardwrapbox (fragment *contents) |
Create a hardwrapbox. More... | |
fragment * | clipbox (fragment *contents) |
Create a clipbox. More... | |
fragment * | indentbox (size_t firstindent, size_t restindent, fragment *contents) |
Create an indentbox. More... | |
fragment * | dropbox (fragment *header, fragment *contents) |
Indent a paragraph, placing the given text on the first line. More... | |
fragment * | fragment_columns (const vector< fragment_column_entry > &columns) |
string | char_to_str (char code) |
fragment * | fragf (const char *format,...) |
A printf-alike for fragments. More... | |
fragment * | text_fragment (const std::wstring &s) |
Create a fragment from a string of text. More... | |
fragment * | text_fragment (const std::wstring &s, const style &st) |
Create a fragment from a string of text. More... | |
fragment * | text_fragment (const std::string &s, const char *encoding=NULL) |
Create a fragment from a string of multibyte-encoded text. More... | |
fragment * | text_fragment (const std::string &s, const style &st, const char *encoding=NULL) |
Create a fragment from a string of multibyte-encoded text, wrapping an implicit style_fragment around it. | |
fragment * | text_fragment (const char *s, const style &st=style()) |
Create a fragment from a string of text. More... | |
fragment * | sequence_fragment (const std::vector< fragment *> &fragments) |
Create a fragment from a sequence of other fragments. More... | |
fragment * | join_fragments (const std::vector< fragment *> &fragments, const std::wstring &between) |
Join fragments into a single fragment, placing text between them. More... | |
fragment * | fragment_columns (const std::vector< fragment_column_entry > &columns) |
A fragment that formats its contents into columns. More... | |
const style & | get_style (const std::string &name) |
Look up a style in the global registry. More... | |
void | set_style (const std::string &name, const style &style) |
Place a style in the global registry. More... | |
style | style_fg (short fg) |
style | style_bg (short bg) |
style | style_attrs_on (attr_t attrs) |
style | style_attrs_off (attr_t attrs) |
style | style_attrs_flip (attr_t attrs) |
std::string | version () |
Return the version number of the library. More... | |
Variables | |
cwindow | rootwin =NULL |
cwindow | rootwinhack =NULL |
map< string, style > | styles |
The namespace containing everything defined by cwidget.
Create a clipbox.
Each line of the fragment placed inside the clipbox will be clipped to the current width. The whole layout widget implicitly uses one of these, but there may be other uses for clipboxes as well.
contents | the contents of the clipbox |
References cwidget::wchstring::apply_style(), clipbox(), and cwidget::style::get_attrs().
Referenced by clipbox(), and text_fragment().
Indent a paragraph, placing the given text on the first line.
This just expands to an invocation of indentbox, with the indentation constants set appropriately. The result will consist of "header" prepended to the first line of "contents", with successive lines of "contents" indented to line up with the first line of "contents".
References dropbox(), cwidget::fragment_column_entry::expandable, cwidget::style::get_attrs(), indentbox(), cwidget::fragment::layout(), cwidget::fragment_column_entry::lines, cwidget::fragment::max_width(), cwidget::fragment_column_entry::proportional, and cwidget::wchstring::width().
Referenced by dropbox(), and text_fragment().
Create a fillbox.
Each line of the fragment placed inside the fillbox will be reflowed (word-wrapped) and expanded to the current width, possibly to several lines.
The contents of a fillbox always have final_nl=true.
contents | the contents of the fillbox |
References fillbox().
Referenced by fillbox(), and text_fragment().
Create a flowbox.
Each line of the fragment placed inside the flowbox will be reflowed (word-wrapped) to the current width, possibly to several lines.
The contents of a flowbox always have final_nl=true. (ie, a flowbox is always followed by a line break)
contents | the contents of the flowbox |
References flowbox(), cwidget::style::get_attrs(), and cwidget::wchstring::width().
Referenced by flowbox(), and text_fragment().
fragment * cwidget::fragf | ( | const char * | format, |
... | |||
) |
A printf-alike for fragments.
Formatting codes:
For instance,
fragf("%S%BWARNING%b: something bad happened in routine %s," "expect a segfault.", "Error", some_routine);
Note: if you use a parameter index multiple times, you are virtually GUARANTEED to segfault!
format | the format string |
References cwidget::style::attrs_flip(), fragf(), get_style(), and newline_fragment().
Referenced by fragf(), and cwidget::fragment_column_entry::fragment_column_entry().
fragment* cwidget::fragment_columns | ( | const std::vector< fragment_column_entry > & | columns | ) |
A fragment that formats its contents into columns.
If the fixed-width columns overflow the available space, they will be clipped hard.
This fragment may NOT be placed inside an indent box or any other box that alters the shape of its contents. Doing so will cause the program to abort.
columns | a list of column entry information ordered from left to right. |
const style & cwidget::get_style | ( | const std::string & | name | ) |
Look up a style in the global registry.
NoSuchStyle | if the style does not exist. |
References get_style().
Referenced by fragf(), get_style(), cwidget::chstring::operator=(), cwidget::widgets::multiplex::paint(), cwidget::widgets::tree::paint(), cwidget::widgets::menubar::paint(), cwidget::widgets::menu::paint(), cwidget::toplevel::resume(), cwidget::widgets::minibuf_win::show_all(), style_attrs_flip(), cwidget::toplevel::update(), and cwidget::fragment::~fragment().
Create a hardwrapbox.
Each line of the fragment inside the box will be hard-wrapped to the current width.
The contents of a wrapbox always have final_nl=true.
contents | the contents of the hardwrapbox |
References hardwrapbox().
Referenced by hardwrapbox(), and text_fragment().
Create an indentbox.
Each line of the indentbox will be indented by the specified amount. (this effectively decreases the width of each line) If desired, the first line can be indented a different amount (typically less) than the remaining lines, although it is formatted to the same width; this supports things like bulletted lists.
firstindent | the number of spaces of indentation to use for the first line |
restindent | the number of spaces of indentation to use for later lines |
contents | the contents of the indentbox |
References indentbox().
Referenced by dropbox(), indentbox(), and text_fragment().
fragment* cwidget::join_fragments | ( | const std::vector< fragment *> & | fragments, |
const std::wstring & | between | ||
) |
Join fragments into a single fragment, placing text between them.
This is useful for creating lists, for instance. The new fragment takes ownership of all pointers in fragments.
fragments | the list of fragments to join |
between | a string to place between adjacent items in the input list |
fragment * cwidget::newline_fragment | ( | ) |
Create a fragment which simply produces a newline wherever it occurs.
References newline_fragment().
Referenced by fragf(), newline_fragment(), text_fragment(), and cwidget::fragment::~fragment().
Create a fragment from a sequence of other fragments.
The fragment will simply "shove" the two sequences together, respecting the value of final_nl on each.
fragments | the fragments in the sequence |
Create a fragment from a sequence of other fragments.
The fragment will simply "shove" the two sequences together, respecting the value of final_nl on each.
f | the first fragment in the sequence; the sequence should be terminated with a NULL pointer. |
void cwidget::set_style | ( | const std::string & | name, |
const style & | style | ||
) |
Place a style in the global registry.
References set_style().
Referenced by cwidget::toplevel::init(), set_style(), and style_attrs_flip().
|
inline |
References cwidget::style::attrs_flip(), get_style(), and set_style().
Referenced by cwidget::widgets::togglebutton::paint(), cwidget::widgets::button::paint(), and cwidget::dialogs::yesno().
|
inline |
References cwidget::style::attrs_off().
Referenced by cwidget::toplevel::init().
|
inline |
References cwidget::style::attrs_on().
Referenced by cwidget::toplevel::init(), cwidget::widgets::staticitem::paint(), and cwidget::widgets::menu::paint().
|
inline |
References cwidget::style::set_bg().
Referenced by cwidget::toplevel::init().
|
inline |
References cwidget::style::set_fg().
Referenced by cwidget::toplevel::init().
Create a fragment which alters the style of its contents.
f | the child of this fragment |
attr | the text attribute which should be assigned to f |
References style_fragment(), and cwidget::wchstring::width().
Referenced by style_fragment(), text_fragment(), and cwidget::fragment::~fragment().
fragment* cwidget::text_fragment | ( | const std::wstring & | s | ) |
Create a fragment from a string of text.
The text will simply be formatted as is, with line breaks at newlines and tabs replaced by eight spaces.
s | the text to use |
Create a fragment from a string of text.
The text will simply be formatted as a single line without clipping.
s | the text to use |
style | the base style for the new fragment; an implicit style_fragment for this style is wrapped around the new text_fragment. |
fragment* cwidget::text_fragment | ( | const std::string & | s, |
const char * | encoding = NULL |
||
) |
Create a fragment from a string of multibyte-encoded text.
s | the text to use |
encoding | the text's encoding; if this is null or unspecified, LC_CTYPE will be used. |
Create a fragment from a string of text.
The text will simply be formatted as a single line without clipping.
s | the text to use |
attr | attributes to assign to it |
References clipbox(), dropbox(), fillbox(), flowbox(), hardwrapbox(), indentbox(), newline_fragment(), and style_fragment().
std::string cwidget::version | ( | ) |
Return the version number of the library.