_tracechtype2(int bufnum, chtype ch)
{
    char *result = _nc_trace_buf(bufnum, (size_t) BUFSIZ);

    if (result != 0) {
	const char *found;
	attr_t attr = ChAttrOf(ch);

	_nc_STRCPY(result, l_brace, TRACE_BUF_SIZE(bufnum));
	if ((found = _nc_altcharset_name(attr, ch)) != 0) {
	    (void) _nc_trace_bufcat(bufnum, found);
	    attr &= ~A_ALTCHARSET;
	} else
	    (void) _nc_trace_bufcat(bufnum,
				    _nc_tracechar(CURRENT_SCREEN,
						  (int) ChCharOf(ch)));

	if (attr != A_NORMAL) {
	    (void) _nc_trace_bufcat(bufnum, " | ");
	    (void) _nc_trace_bufcat(bufnum,
				    _traceattr2(bufnum + 20, attr));
	}

	result = _nc_trace_bufcat(bufnum, r_brace);
    }
    return result;
}
示例#2
0
_tracecchar_t2 (int bufnum, const cchar_t *ch)
{
    char *buf = _nc_trace_buf(bufnum, BUFSIZ);
    attr_t attr;
    const char *found;

    strcpy(buf, l_brace);
    if (ch != 0) {
	attr = AttrOfD(ch);
	if ((found = _nc_altcharset_name(attr, CharOfD(ch))) != 0) {
	    (void) _nc_trace_bufcat(bufnum, found);
	    attr &= ~A_ALTCHARSET;
	} else if (isWidecExt(CHDEREF(ch))) {
	    (void) _nc_trace_bufcat(bufnum, "{NAC}");
	    attr &= ~A_CHARTEXT;
	} else {
	    PUTC_DATA;
	    int n;

	    PUTC_INIT;
	    (void) _nc_trace_bufcat(bufnum, "{ ");
	    do {
		PUTC_ch = PUTC_i < CCHARW_MAX ? ch->chars[PUTC_i] : L'\0';
		PUTC_n = wcrtomb(PUTC_buf, ch->chars[PUTC_i], &PUT_st);
		if (PUTC_ch == L'\0')
		    --PUTC_n;
		if (PUTC_n <= 0) {
		    if (PUTC_ch != L'\0') {
			/* it could not be a multibyte sequence */
			(void) _nc_trace_bufcat(bufnum, _tracechar(UChar(ch->chars[PUTC_i])));
		    }
		    break;
		}
		for (n = 0; n < PUTC_n; n++) {
		    if (n)
			(void) _nc_trace_bufcat(bufnum, ", ");
		    (void) _nc_trace_bufcat(bufnum, _tracechar(UChar(PUTC_buf[n])));
		}
		++PUTC_i;
	    } while (PUTC_ch != L'\0');
	    (void) _nc_trace_bufcat(bufnum, " }");
	}
	if (attr != A_NORMAL) {
	    (void) _nc_trace_bufcat(bufnum, " | ");
	    (void) _nc_trace_bufcat(bufnum, _traceattr2(bufnum + 20, attr));
	}
    }

    return (_nc_trace_bufcat(bufnum, r_brace));
}
示例#3
0
_tracechtype2(int bufnum, chtype ch)
{
    const char *found;

    strcpy(_nc_trace_buf(bufnum, BUFSIZ), l_brace);
    if ((found = _nc_altcharset_name(ChAttrOf(ch), ch)) != 0) {
	(void) _nc_trace_bufcat(bufnum, found);
    } else
	(void) _nc_trace_bufcat(bufnum, _tracechar((int)ChCharOf(ch)));

    if (ChAttrOf(ch) != A_NORMAL) {
	(void) _nc_trace_bufcat(bufnum, " | ");
	(void) _nc_trace_bufcat(bufnum,
		_traceattr2(bufnum + 20, ChAttrOf(ch)));
    }

    return (_nc_trace_bufcat(bufnum, r_brace));
}
示例#4
0
_tracechtype2(int bufnum, chtype ch)
{
    const char *found;
    char *result = _nc_trace_buf(bufnum, BUFSIZ);

    if (result != 0) {
	strcpy(result, l_brace);
	if ((found = _nc_altcharset_name(ChAttrOf(ch), ch)) != 0) {
	    (void) _nc_trace_bufcat(bufnum, found);
	} else
	    (void) _nc_trace_bufcat(bufnum,
				    _nc_tracechar(CURRENT_SCREEN,
						  (int) ChCharOf(ch)));

	if (ChAttrOf(ch) != A_NORMAL) {
	    (void) _nc_trace_bufcat(bufnum, " | ");
	    (void) _nc_trace_bufcat(bufnum,
				    _traceattr2(bufnum + 20, ChAttrOf(ch)));
	}

	result = _nc_trace_bufcat(bufnum, r_brace);
    }
    return result;
}
示例#5
0
_traceattr2(int bufnum, attr_t newmode)
{
    char *buf = _nc_trace_buf(bufnum, BUFSIZ);
    char temp[80];
    static const struct {
	unsigned int val;
	const char *name;
    } names[] =
    {
	/* *INDENT-OFF* */
	{ A_STANDOUT,		"A_STANDOUT" },
	{ A_UNDERLINE,		"A_UNDERLINE" },
	{ A_REVERSE,		"A_REVERSE" },
	{ A_BLINK,		"A_BLINK" },
	{ A_DIM,		"A_DIM" },
	{ A_BOLD,		"A_BOLD" },
	{ A_ALTCHARSET,		"A_ALTCHARSET" },
	{ A_INVIS,		"A_INVIS" },
	{ A_PROTECT,		"A_PROTECT" },
	{ A_CHARTEXT,		"A_CHARTEXT" },
	{ A_NORMAL,		"A_NORMAL" },
	{ A_COLOR,		"A_COLOR" },
	/* *INDENT-ON* */

    }
#ifndef USE_TERMLIB
    ,
	colors[] =
    {
	/* *INDENT-OFF* */
	{ COLOR_BLACK,		"COLOR_BLACK" },
	{ COLOR_RED,		"COLOR_RED" },
	{ COLOR_GREEN,		"COLOR_GREEN" },
	{ COLOR_YELLOW,		"COLOR_YELLOW" },
	{ COLOR_BLUE,		"COLOR_BLUE" },
	{ COLOR_MAGENTA,	"COLOR_MAGENTA" },
	{ COLOR_CYAN,		"COLOR_CYAN" },
	{ COLOR_WHITE,		"COLOR_WHITE" },
	/* *INDENT-ON* */

    }
#endif /* !USE_TERMLIB */
    ;
    size_t n;
    unsigned save_nc_tracing = _nc_tracing;
    _nc_tracing = 0;

    strcpy(buf, l_brace);

    for (n = 0; n < SIZEOF(names); n++) {
	if ((newmode & names[n].val) != 0) {
	    if (buf[1] != '\0')
		buf = _nc_trace_bufcat(bufnum, "|");
	    buf = _nc_trace_bufcat(bufnum, names[n].name);

	    if (names[n].val == A_COLOR) {
		short pairnum = PAIR_NUMBER(newmode);
#ifdef USE_TERMLIB
		/* pair_content lives in libncurses */
		(void) sprintf(temp, "{%d}", pairnum);
#else
		short fg, bg;

		if (pair_content(pairnum, &fg, &bg) == OK) {
		    (void) sprintf(temp,
				   "{%d = {%s, %s}}",
				   pairnum,
				   COLOR_OF(fg),
				   COLOR_OF(bg));
		} else {
		    (void) sprintf(temp, "{%d}", pairnum);
		}
#endif
		buf = _nc_trace_bufcat(bufnum, temp);
	    }
	}
    }
    if (ChAttrOf(newmode) == A_NORMAL) {
	if (buf[1] != '\0')
	    (void) _nc_trace_bufcat(bufnum, "|");
	(void) _nc_trace_bufcat(bufnum, "A_NORMAL");
    }

    _nc_tracing = save_nc_tracing;
    return (_nc_trace_bufcat(bufnum, r_brace));
}
示例#6
0
_tracecchar_t2(int bufnum, const cchar_t *ch)
{
    char *result = _nc_trace_buf(bufnum, BUFSIZ);
    attr_t attr;
    const char *found;

    if (result != 0) {
	strcpy(result, l_brace);
	if (ch != 0) {
	    attr = AttrOfD(ch);
	    if ((found = _nc_altcharset_name(attr, (chtype) CharOfD(ch))) != 0) {
		(void) _nc_trace_bufcat(bufnum, found);
		attr &= ~A_ALTCHARSET;
	    } else if (isWidecExt(CHDEREF(ch))) {
		(void) _nc_trace_bufcat(bufnum, "{NAC}");
		attr &= ~A_CHARTEXT;
	    } else {
		PUTC_DATA;
		int n;

		PUTC_INIT;
		(void) _nc_trace_bufcat(bufnum, "{ ");
		for (PUTC_i = 0; PUTC_i < CCHARW_MAX; ++PUTC_i) {
		    PUTC_ch = ch->chars[PUTC_i];
		    if (PUTC_ch == L'\0') {
			if (PUTC_i == 0)
			    result = _nc_trace_bufcat(bufnum, "\\000");
			break;
		    }
		    PUTC_n = wcrtomb(PUTC_buf, ch->chars[PUTC_i], &PUT_st);
		    if (PUTC_n <= 0) {
			if (PUTC_ch != L'\0') {
			    /* it could not be a multibyte sequence */
			    (void) _nc_trace_bufcat(bufnum,
						    _nc_tracechar(CURRENT_SCREEN,
								  UChar(ch->chars[PUTC_i])));
			}
			break;
		    }
		    for (n = 0; n < PUTC_n; n++) {
			if (n)
			    (void) _nc_trace_bufcat(bufnum, ", ");
			(void) _nc_trace_bufcat(bufnum,
						_nc_tracechar(CURRENT_SCREEN,
							      UChar(PUTC_buf[n])));
		    }
		}
		(void) _nc_trace_bufcat(bufnum, " }");
	    }
	    if (attr != A_NORMAL) {
		(void) _nc_trace_bufcat(bufnum, " | ");
		(void) _nc_trace_bufcat(bufnum, _traceattr2(bufnum + 20, attr));
	    }
	}

	result = _nc_trace_bufcat(bufnum, r_brace);
    }
    return result;
}
_traceattr2(int bufnum, chtype newmode)
{
#define DATA(name) { name, { #name } }
    static const struct {
	unsigned int val;
	const char name[14];
    } names[] =
    {
	DATA(A_STANDOUT),
	    DATA(A_UNDERLINE),
	    DATA(A_REVERSE),
	    DATA(A_BLINK),
	    DATA(A_DIM),
	    DATA(A_BOLD),
	    DATA(A_ALTCHARSET),
	    DATA(A_INVIS),
	    DATA(A_PROTECT),
	    DATA(A_CHARTEXT),
	    DATA(A_NORMAL),
	    DATA(A_COLOR),
#if USE_ITALIC
	    DATA(A_ITALIC),
#endif
    }
#ifndef USE_TERMLIB
    ,
	colors[] =
    {
	DATA(COLOR_BLACK),
	    DATA(COLOR_RED),
	    DATA(COLOR_GREEN),
	    DATA(COLOR_YELLOW),
	    DATA(COLOR_BLUE),
	    DATA(COLOR_MAGENTA),
	    DATA(COLOR_CYAN),
	    DATA(COLOR_WHITE),
    }
#endif /* !USE_TERMLIB */
    ;
#undef DATA
    char *result = _nc_trace_buf(bufnum, (size_t) BUFSIZ);

    if (result != 0) {
	size_t n;
	unsigned save_nc_tracing = _nc_tracing;

	_nc_tracing = 0;

	_nc_STRCPY(result, l_brace, TRACE_BUF_SIZE(bufnum));

	for (n = 0; n < SIZEOF(names); n++) {

	    if ((newmode & names[n].val) != 0) {
		if (result[1] != '\0')
		    (void) _nc_trace_bufcat(bufnum, "|");
		result = _nc_trace_bufcat(bufnum, names[n].name);

		if (names[n].val == A_COLOR) {
		    char temp[80];
		    short pairnum = (short) PairNumber(newmode);
#ifdef USE_TERMLIB
		    /* pair_content lives in libncurses */
		    _nc_SPRINTF(temp, _nc_SLIMIT(sizeof(temp))
				"{%d}", pairnum);
#else
		    NCURSES_COLOR_T fg, bg;

		    if (pair_content(pairnum, &fg, &bg) == OK) {
			_nc_SPRINTF(temp, _nc_SLIMIT(sizeof(temp))
				    "{%d = {%s, %s}}",
				    pairnum,
				    COLOR_OF(fg),
				    COLOR_OF(bg));
		    } else {
			_nc_SPRINTF(temp, _nc_SLIMIT(sizeof(temp))
				    "{%d}", pairnum);
		    }
#endif
		    result = _nc_trace_bufcat(bufnum, temp);
		}
	    }
	}
	if (ChAttrOf(newmode) == A_NORMAL) {
	    if (result != 0 && result[1] != '\0')
		(void) _nc_trace_bufcat(bufnum, "|");
	    (void) _nc_trace_bufcat(bufnum, "A_NORMAL");
	}

	_nc_tracing = save_nc_tracing;
	result = _nc_trace_bufcat(bufnum, r_brace);
    }
    return result;
}
_tracecchar_t2(int bufnum, const cchar_t *ch)
{
    char *result = _nc_trace_buf(bufnum, (size_t) BUFSIZ);

    if (result != 0) {
	_nc_STRCPY(result, l_brace, TRACE_BUF_SIZE(bufnum));
	if (ch != 0) {
	    const char *found;
	    attr_t attr = AttrOfD(ch);

	    if ((found = _nc_altcharset_name(attr, (chtype) CharOfD(ch))) != 0) {
		(void) _nc_trace_bufcat(bufnum, found);
		attr &= ~A_ALTCHARSET;
	    } else if (isWidecExt(CHDEREF(ch))) {
		(void) _nc_trace_bufcat(bufnum, "{NAC}");
		attr &= ~A_CHARTEXT;
	    } else {
		PUTC_DATA;
		int n;

		(void) _nc_trace_bufcat(bufnum, "{ ");
		for (PUTC_i = 0; PUTC_i < CCHARW_MAX; ++PUTC_i) {
		    PUTC_ch = ch->chars[PUTC_i];
		    if (PUTC_ch == L'\0') {
			if (PUTC_i == 0)
			    (void) _nc_trace_bufcat(bufnum, "\\000");
			break;
		    }
		    PUTC_INIT;
		    PUTC_n = (int) wcrtomb(PUTC_buf, ch->chars[PUTC_i], &PUT_st);
		    if (PUTC_n <= 0) {
			if (PUTC_ch != L'\0') {
			    /* it could not be a multibyte sequence */
			    (void) _nc_trace_bufcat(bufnum,
						    _nc_tracechar(CURRENT_SCREEN,
								  UChar(ch->chars[PUTC_i])));
			}
			break;
		    } else if (ch->chars[PUTC_i] > 255) {
			char temp[80];
			_nc_SPRINTF(temp, _nc_SLIMIT(sizeof(temp))
				    "{%d:\\u%lx}",
				    wcwidth(ch->chars[PUTC_i]),
				    (unsigned long) ch->chars[PUTC_i]);
			(void) _nc_trace_bufcat(bufnum, temp);
			break;
		    }
		    for (n = 0; n < PUTC_n; n++) {
			if (n)
			    (void) _nc_trace_bufcat(bufnum, ", ");
			(void) _nc_trace_bufcat(bufnum,
						_nc_tracechar(CURRENT_SCREEN,
							      UChar(PUTC_buf[n])));
		    }
		}
		(void) _nc_trace_bufcat(bufnum, " }");
	    }
	    if (attr != A_NORMAL) {
		(void) _nc_trace_bufcat(bufnum, " | ");
		(void) _nc_trace_bufcat(bufnum, _traceattr2(bufnum + 20, attr));
	    }
#if NCURSES_EXT_COLORS
	    /*
	     * Just in case the extended color is different from the chtype
	     * value, trace both.
	     */
	    if (ch->ext_color != PairNumber(attr)) {
		char temp[80];
		_nc_SPRINTF(temp, _nc_SLIMIT(sizeof(temp))
			    " X_COLOR{%d:%d}", ch->ext_color, PairNumber(attr));
		(void) _nc_trace_bufcat(bufnum, temp);
	    }
#endif
	}

	result = _nc_trace_bufcat(bufnum, r_brace);
    }
    return result;
}