Back to index

tetex-bin  3.0
Functions
lib_cchar.c File Reference
#include <curses.priv.h>

Go to the source code of this file.

Functions

 setcchar (cchar_t *wcval, const wchar_t *wch, const attr_t attrs, short color_pair, const void *opts)
 getcchar (const cchar_t *wcval, wchar_t *wch, attr_t *attrs, short *color_pair, void *opts)

Function Documentation

getcchar ( const cchar_t *  wcval,
wchar_t *  wch,
attr_t *  attrs,
short color_pair,
void opts 
)

Definition at line 94 of file lib_cchar.c.

{
    wchar_t *wp;
    int len;
    int code = ERR;

    TR(TRACE_CCALLS, (T_CALLED("getcchar(%p,%p,%p,%p,%p)"),
                    wcval, wch, attrs, color_pair, opts));

    if (opts == NULL) {
       len = (wp = wmemchr(wcval->chars, L'\0', CCHARW_MAX))
           ? wp - wcval->chars
           : CCHARW_MAX;

       if (wch == NULL) {
           code = len;
       } else if (attrs == 0 || color_pair == 0) {
           code = ERR;
       } else if (len >= 0) {
           *attrs = AttrOf(*wcval) & A_ATTRIBUTES;
           *color_pair = PAIR_NUMBER(AttrOf(*wcval));
           wmemcpy(wch, wcval->chars, (unsigned) len);
           wch[len] = L'\0';
           code = OK;
       }
    }

    TR(TRACE_CCALLS, (T_RETURN("%d"), code));
    return (code);
}

Here is the call graph for this function:

setcchar ( cchar_t *  wcval,
const wchar_t *  wch,
const attr_t  attrs,
short  color_pair,
const void opts 
)

Definition at line 47 of file lib_cchar.c.

{
    int i;
    int len;
    int code = OK;

    TR(TRACE_CCALLS, (T_CALLED("setcchar(%p,%s,%ld,%d,%p)"),
                    wcval, _nc_viswbuf(wch), attrs, color_pair, opts));

    len = wcslen(wch);
    if (opts != NULL
       || (len > 1 && wcwidth(wch[0]) < 0)) {
       code = ERR;
    } else {
       if (len > CCHARW_MAX)
           len = CCHARW_MAX;

       /*
        * If we have a following spacing-character, stop at that point.  We
        * are only interested in adding non-spacing characters.
        */
       for (i = 1; i < len; ++i) {
           if (wcwidth(wch[i]) != 0) {
              len = i;
              break;
           }
       }

       memset(wcval, 0, sizeof(*wcval));

       if (len != 0) {
           SetAttr(*wcval, attrs | COLOR_PAIR(color_pair));
           memcpy(&wcval->chars, wch, len * sizeof(wchar_t));
           TR(TRACE_CCALLS, ("copy %d wchars, first is %s", len,
                           _tracecchar_t(wcval)));
       }
    }

    TR(TRACE_CCALLS, (T_RETURN("%d"), code));
    return (code);
}

Here is the call graph for this function:

Here is the caller graph for this function: